Skip to main content

day_pieces/
lib.rs

1// Copyright © The Daybrite Project
2// SPDX-License-Identifier: MPL-2.0
3
4//! day-pieces: the built-in piece library (DESIGN.md §5.3).
5//!
6//! Every constructor is a plain function returning a piece value; builder methods configure;
7//! `build` runs once. Dynamic attributes become seeded bindings writing sparse typed patches
8//! through the thread-local tree.
9//!
10//! The vocabulary is split across sibling modules (one logical group each) and re-exported here,
11//! so the public API stays flat (`day_pieces::button`, `day_pieces::stack`, …) regardless of
12//! which module a piece is defined in.
13
14day_reactive::tls_root! {
15    menus: crate::menus::TlsGroupSlots,
16    nav: crate::nav::TlsGroupSlots,
17}
18
19// External-piece registration surface (§8.2): the `renderer!` macro + `fill_measure`, plus the
20// re-exports the macro expands to (so a piece needs only a `day-pieces` dependency, not linkme).
21pub mod async_image;
22pub mod colorpicker;
23pub mod combobox;
24pub mod datetime;
25pub mod pager;
26pub mod pullrefresh;
27pub mod searchfield;
28pub mod stepper;
29pub use async_image::{AsyncImage, AsyncImageBuilder, async_image};
30pub mod render;
31
32// The dynamic piece registry (docs/lite.md §4 in https://github.com/daybrite/day-lite): drive
33// pieces by name with loosely-typed values, the surface interpreted languages (day-lite) build
34// UIs through.
35#[cfg(feature = "dyn-registry")]
36pub mod dynreg;
37/// `#[day_pieces::builder(FooBuilder)]`: a piece's builder trait, generated from its inherent
38/// impl (docs/api-style.md "Typed builders and erasure").
39pub use day_core::{Dimension, ElementId, IntoElementKey, id};
40pub use day_macros::builder;
41pub use day_spec::Renderer;
42pub use linkme;
43pub use render::fill_measure;
44
45// The piece vocabulary: one logical group per module, re-exported flat (see each module's docs).
46mod canvas;
47mod commands;
48pub use commands::Command;
49mod containers;
50mod decorators;
51mod dialogs;
52mod file_access;
53pub use file_access::FileAccess;
54#[cfg(feature = "conformance")]
55pub mod conformance;
56mod forms;
57mod image;
58mod inputs;
59mod leaves;
60/// Inline markdown → styled runs (docs/markdown.md). The parser moved to day-spec, beside
61/// the `TextRun`s it produces and the other format codecs; this keeps the old path working.
62pub use day_spec::markdown;
63mod inspector;
64mod menus;
65mod nav;
66mod shapes;
67mod sources;
68mod split;
69mod status;
70mod structure;
71mod tabs;
72mod tokens;
73mod toolbar;
74pub use tabs::*;
75pub use tokens::*;
76
77pub use canvas::*;
78pub use containers::*;
79pub use decorators::*;
80pub use dialogs::*;
81pub use forms::*;
82pub use image::*;
83pub use inputs::*;
84pub use inspector::*;
85pub use leaves::*;
86pub use menus::*;
87pub use nav::*;
88pub use shapes::*;
89pub use sources::*;
90pub use split::*;
91pub use status::{StatusItem, StatusItemHandle, status_item};
92pub use structure::*;
93// The ambient environment and the `Ambient` state trait (docs/state.md) live in day-core, so an
94// app's `*-core` crate (which depends on day-core but not on day-pieces) can `impl Ambient`
95// for its view-model. Re-exported here so `day_pieces::environment` and the prelude are unchanged.
96pub use day_core::{Ambient, app_environment, environment, focused_environment, with_environment};
97// Canvas export (docs/canvas.md "Exporting"): what this toolkit can render a `Drawing` to.
98pub use day_core::{CanvasExports, RenderBitmap, RenderPdf, canvas_exports};
99pub use toolbar::*;
100
101pub use colorpicker::{ColorPicker, ColorPickerBuilder, PickerIdiom, color_picker};
102pub use combobox::{ComboBox, ComboBoxBuilder, combo_box};
103pub use datetime::{
104    DatePicker, DatePickerBuilder, DayDate, DayTime, TimePicker, TimePickerBuilder, date_picker,
105    time_picker,
106};
107pub use day_localization::NumberFormat;
108pub use pager::{Pager, PagerState, pager};
109pub use pullrefresh::{PullRefresh, PullRefreshBuilder, pull_to_refresh};
110pub use searchfield::{SearchField, SearchFieldBuilder, search_field};
111pub use stepper::{
112    NumberField, NumberFieldBuilder, Stepper, StepperBuilder, StepperIdiom, number_field, stepper,
113};
114
115pub mod prelude {
116    pub use crate::colorpicker::{ColorPicker, ColorPickerBuilder, PickerIdiom, color_picker};
117    pub use crate::combobox::{ComboBox, ComboBoxBuilder, combo_box};
118    pub use crate::datetime::{
119        DatePicker, DatePickerBuilder, DayDate, DayTime, TimePicker, TimePickerBuilder,
120        date_picker, time_picker,
121    };
122    pub use crate::pager::{Pager, PagerState, pager};
123    pub use crate::pullrefresh::{PullRefresh, PullRefreshBuilder, pull_to_refresh};
124    pub use crate::searchfield::{SearchField, SearchFieldBuilder, search_field};
125    pub use crate::stepper::{
126        NumberField, NumberFieldBuilder, Stepper, StepperBuilder, StepperIdiom, number_field,
127        stepper,
128    };
129    pub use crate::{AsyncImage, AsyncImageBuilder, async_image};
130    pub use day_localization::NumberFormat;
131
132    pub use crate::{DocumentTabs, TabActions, TabSet, document_tabs};
133    pub use day_core::{ElementId, IntoElementKey, id};
134    // Model-driven rows (docs/model.md): the store-as-RowSource surface.
135    pub use crate::TextStyle;
136    pub use crate::ToolbarEntry;
137    pub use crate::routes;
138    pub use crate::{
139        A11yBuilder, Alert, Ambient, BackRequest, BackResponse, Binding, ButtonBuilder,
140        ColumnBuilder, Command, Confirm, ContentList, Corner, Cover, Decorate, Decorated, Delete,
141        Drag, Draw, FileAccess, FileUrl, Form, FormSection, Grid, GridRow, HAlign, Inspector,
142        IntoFocusBinding, IntoFraction, IntoImageSource, IntoReactive, IntoText, ItemSlot,
143        LabelBuilder, Labeled, Link, List, ListItem, ListItemBuilder, Loaded, MenuButton,
144        MenuButtonBuilder, MenuContent, MenuEntry, Modifier, Move, NativeRef, Nav, NavContent,
145        NavDrag, NavDrop, NavItem, NavStack, NavStyle, OpenFile, OpenFiles, OpenFolder, Pan,
146        PathBuilder, Pinch, ProgressBuilder, Prompt, Reactive, Reorder, ReorderVerdict, Rotate,
147        Route, RoutePath, RowBuilder, RowFit, SaveFile, Search, SearchReveal, Sections, ShapeKind,
148        ShapePiece, Share, ShareAction, StatusItem, SwipeAction, TextBuilder, VAlign, VectorWeight,
149        When, ZStack, adaptive, alert, app_environment, app_menu, arc, button, canvas, capsule,
150        circle, column, confirm, cover, current_route, divider, dock_menu, each, ellipse,
151        environment, focused_environment, form, frame_clock, grid, grid_row, image, inspector,
152        item, items, keyed, label, labeled, line, link, list, list_item, load, menu_button,
153        menu_item, menu_role, menu_separator, nav, nav_back, nav_items, nav_link, nav_link_to,
154        nav_stack, navigate, navigate_to, open_file, open_files, open_folder, open_link, picker,
155        picker_optional, polygon, progress, prompt, rectangle, rounded_rectangle, route,
156        route_param, route_params, row, save_file, scroll, section, secure_field, segment, shape,
157        shape_group, shape_group_fn, share_action, share_support, slider, spacer, spinner, split,
158        status_item, sub_menu, swipe_action, switch, text_area, text_field, toggle, toolbar_button,
159        toolbar_label, toolbar_menu, toolbar_segmented, toolbar_separator, toolbar_toggle, vector,
160        when, with_environment, zstack,
161    };
162    pub use crate::{Space, TextPreset};
163    // Canvas export (docs/canvas.md "Exporting"): record a drawing once, render it to a bitmap
164    // or a PDF through the toolkit's own painter, and ask what this target can do first.
165    pub use crate::{CanvasExports, Drawing, PdfDocument, canvas_exports};
166    pub use day_core::system_color;
167    pub use day_spec::{ExportError, SystemColor};
168    // The hierarchical tree (docs/tree.md): the piece, its sources, and its verdict enum.
169    pub use crate::{
170        Branches, MoveVerdict, NodeSource, TreeBuilder, TreeConn, TreePiece, branches, tree,
171    };
172    // Typed builder traits (docs/api-style.md "Typed builders and erasure"): each piece's own
173    // builders, forwarded through `Decorated` so they still chain after a generic modifier. A
174    // piece implements exactly one, so the names they share (`title`, `style`, `align`, …) never
175    // become ambiguous at a call site. (`LabelBuilder`, `ButtonBuilder`, `ColumnBuilder` and
176    // `RowBuilder` sit in the list above, in alphabetical company.)
177    pub use crate::{
178        AdaptiveBuilder, CoverBuilder, DividerBuilder, FormSectionBuilder, GridBuilder,
179        GridRowBuilder, ImageBuilder, InspectorBuilder, LinkBuilder, ListBuilder, NavBuilder,
180        NavStackBuilder, PickerBuilder, ScrollBuilder, ShapePieceBuilder, SliderBuilder,
181        SplitBuilder, TextAreaBuilder, TextFieldBuilder, ToggleBuilder, VectorBuilder, WhenBuilder,
182        ZStackBuilder,
183    };
184    #[cfg(feature = "model")]
185    pub use crate::{ModelSlot, Rows, StoreRows, StoreTree, StoreTrees};
186    pub use crate::{Picker, TextArea};
187    pub use day_core::{
188        Alignment, AnyPiece, BuildCx, Dimension, Either, Piece, PieceFn, PieceSeq, RNode,
189        ScrollTarget, announce, announce_urgent, invalidate_size, open_url, piece_fn,
190        with_animation,
191    };
192    pub use day_geometry::{Affine, Animatable, Color, Insets, Point, Rect, Size, Transform};
193    pub use day_reactive::{
194        AnyBinding, Effect, Memo, Scope, Setter, Signal, Trigger, batch, bind, untrack, watch,
195    };
196    // `Nav::presentation` takes one (docs/size-classes.md); apps that leave the
197    // presentation automatic never name it.
198    pub use day_spec::props::NavPresentation;
199    pub use day_spec::props::PickerStyle;
200    pub use day_spec::props::RowHeight;
201    pub use day_spec::props::TextAlign;
202    pub use day_spec::props::{PaneEdge, SplitAxis};
203    pub use day_spec::{AnimSpec, AnimSpec as Animation, Curve};
204    pub use day_spec::{AssetName, FontFamily, ImageName};
205    pub use day_spec::{DragPhase, Edges, GestureKind};
206    // Text entry (docs/textfield.md): what a field collects and what its action key says.
207    pub use day_spec::{
208        DrawOp, LinearGradient, Paint, RadialGradient, Shape, TextAnchor, TextVAlign, UnitPoint,
209    };
210    pub use day_spec::{InputPurpose, SubmitLabel};
211    // Canvas fonts and the platform font list (docs/fonts.md).
212    pub use day_spec::{CanvasFont, FontFace, FontFamilyInfo, TextMetrics};
213    pub use day_spec::{Font, FontSpec, FontWeight, Role};
214    // The styled-text document (docs/texteditor.md): what `.markdown()` parses into, what a
215    // label's runs are, and what `day-piece-text-editor` edits, plus the Markdown / HTML / RTF
216    // codecs over it.
217    pub use day_spec::{
218        LabelStyle, Symbol, ToolbarItem, ToolbarItemKind, ToolbarPlacement, ToolbarValue,
219    };
220    pub use day_spec::{
221        ListStyle, ParagraphAlign, ParagraphRun, ParagraphStyle, RunStyle, StyledText, TextRun,
222        Underline,
223    };
224    pub use day_spec::{MenuBarRole, MenuItem, MenuRole, Shortcut};
225    pub use std::time::Duration;
226}