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