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
14// External-piece registration surface (§8.2): the `renderer!` macro + `fill_measure`, plus the
15// re-exports the macro expands to (so a piece needs only a `day-pieces` dependency, not linkme).
16pub mod async_image;
17pub mod colorpicker;
18pub mod combobox;
19pub mod datetime;
20pub mod pager;
21pub mod pullrefresh;
22pub mod searchfield;
23pub mod stepper;
24pub use async_image::{AsyncImage, AsyncImageBuilder, async_image};
25pub mod render;
26
27// The dynamic piece registry (docs/lite.md §4 in https://github.com/daybrite/day-lite): drive
28// pieces by name with loosely-typed values, the surface interpreted languages (day-lite) build
29// UIs through.
30#[cfg(feature = "dyn-registry")]
31pub mod dynreg;
32/// `#[day_pieces::builder(FooBuilder)]`: a piece's builder trait, generated from its inherent
33/// impl (docs/api-style.md "Typed builders and erasure").
34pub use day_core::{ElementId, IntoElementKey, id};
35pub use day_macros::builder;
36pub use day_spec::Renderer;
37pub use linkme;
38pub use render::fill_measure;
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 pager::{Pager, PagerState, pager};
103pub use pullrefresh::{PullRefresh, PullRefreshBuilder, pull_to_refresh};
104pub use searchfield::{SearchField, SearchFieldBuilder, search_field};
105pub use stepper::{Stepper, StepperIdiom, stepper};
106
107pub mod prelude {
108    pub use crate::colorpicker::{ColorPicker, ColorPickerBuilder, PickerIdiom, color_picker};
109    pub use crate::combobox::{ComboBox, ComboBoxBuilder, combo_box};
110    pub use crate::datetime::{
111        DatePicker, DatePickerBuilder, DayDate, DayTime, TimePicker, TimePickerBuilder,
112        date_picker, time_picker,
113    };
114    pub use crate::pager::{Pager, PagerState, pager};
115    pub use crate::pullrefresh::{PullRefresh, PullRefreshBuilder, pull_to_refresh};
116    pub use crate::searchfield::{SearchField, SearchFieldBuilder, search_field};
117    pub use crate::stepper::{Stepper, StepperIdiom, stepper};
118    pub use crate::{AsyncImage, AsyncImageBuilder, async_image};
119
120    pub use crate::{DocumentTabs, TabActions, TabSet, document_tabs};
121    pub use day_core::{ElementId, IntoElementKey, id};
122    // Model-driven rows (docs/model.md): the store-as-RowSource surface.
123    pub use crate::TextStyle;
124    pub use crate::ToolbarEntry;
125    pub use crate::routes;
126    pub use crate::{
127        A11yBuilder, Alert, Ambient, BackRequest, BackResponse, Binding, ButtonBuilder,
128        ColumnBuilder, Command, Confirm, ContentList, Corner, Cover, Decorate, Decorated, Delete,
129        Drag, Draw, FileAccess, FileUrl, Form, FormSection, Grid, GridRow, HAlign, Inspector,
130        IntoFocusBinding, IntoFraction, IntoImageSource, IntoReactive, IntoText, ItemSlot,
131        LabelBuilder, Labeled, Link, List, ListItem, ListItemBuilder, Loaded, MenuContent,
132        MenuEntry, Modifier, Move, NativeRef, Nav, NavContent, NavDrag, NavDrop, NavItem, NavStack,
133        NavStyle, OpenFile, OpenFiles, OpenFolder, Pan, PathBuilder, Pinch, ProgressBuilder,
134        Prompt, Reactive, Reorder, ReorderVerdict, Route, RoutePath, RowBuilder, RowFit, SaveFile,
135        Search, SearchReveal, Sections, ShapeKind, ShapePiece, StatusItem, SwipeAction,
136        TextBuilder, VAlign, VectorWeight, When, ZStack, adaptive, alert, app_environment,
137        app_menu, arc, button, canvas, capsule, circle, column, confirm, cover, current_route,
138        divider, dock_menu, each, ellipse, environment, focused_environment, form, frame_clock,
139        grid, grid_row, image, inspector, item, items, keyed, label, labeled, line, link, list,
140        list_item, load, menu_item, menu_role, menu_separator, nav, nav_back, nav_items, nav_link,
141        nav_link_to, nav_stack, navigate, navigate_to, open_file, open_files, open_folder,
142        open_link, picker, picker_optional, polygon, progress, prompt, rectangle,
143        rounded_rectangle, route, route_param, route_params, row, save_file, scroll, section,
144        secure_field, segment, shape, shape_group, shape_group_fn, slider, spacer, spinner, split,
145        status_item, sub_menu, swipe_action, switch, text_area, text_field, toggle, toolbar_button,
146        toolbar_label, toolbar_menu, toolbar_segmented, toolbar_separator, toolbar_toggle, vector,
147        when, with_environment, zstack,
148    };
149    pub use crate::{Space, TextPreset};
150    // Canvas export (docs/canvas.md "Exporting"): record a drawing once, render it to a bitmap
151    // or a PDF through the toolkit's own painter, and ask what this target can do first.
152    pub use crate::{CanvasExports, Drawing, PdfDocument, canvas_exports};
153    pub use day_spec::ExportError;
154    // The hierarchical tree (docs/tree.md): the piece, its sources, and its verdict enum.
155    pub use crate::{
156        Branches, MoveVerdict, NodeSource, TreeBuilder, TreeConn, TreePiece, branches, tree,
157    };
158    // Typed builder traits (docs/api-style.md "Typed builders and erasure"): each piece's own
159    // builders, forwarded through `Decorated` so they still chain after a generic modifier. A
160    // piece implements exactly one, so the names they share (`title`, `style`, `align`, …) never
161    // become ambiguous at a call site. (`LabelBuilder`, `ButtonBuilder`, `ColumnBuilder` and
162    // `RowBuilder` sit in the list above, in alphabetical company.)
163    pub use crate::{
164        AdaptiveBuilder, CoverBuilder, DividerBuilder, FormSectionBuilder, GridBuilder,
165        GridRowBuilder, ImageBuilder, InspectorBuilder, LinkBuilder, ListBuilder, NavBuilder,
166        NavStackBuilder, PickerBuilder, ScrollBuilder, ShapePieceBuilder, SliderBuilder,
167        SplitBuilder, TextAreaBuilder, TextFieldBuilder, ToggleBuilder, VectorBuilder, WhenBuilder,
168        ZStackBuilder,
169    };
170    #[cfg(feature = "model")]
171    pub use crate::{ModelSlot, Rows, StoreRows, StoreTree, StoreTrees};
172    pub use crate::{Picker, TextArea};
173    pub use day_core::{
174        Alignment, AnyPiece, BuildCx, Either, Piece, PieceFn, PieceSeq, RNode, ScrollTarget,
175        announce, announce_urgent, invalidate_size, open_url, piece_fn, with_animation,
176    };
177    pub use day_geometry::{Affine, Animatable, Color, Insets, Point, Rect, Size, Transform};
178    pub use day_reactive::{
179        AnyBinding, Effect, Memo, Scope, Setter, Signal, Trigger, batch, bind, untrack, watch,
180    };
181    // `Nav::presentation` takes one (docs/size-classes.md); apps that leave the
182    // presentation automatic never name it.
183    pub use day_spec::props::NavPresentation;
184    pub use day_spec::props::PickerStyle;
185    pub use day_spec::props::RowHeight;
186    pub use day_spec::props::TextAlign;
187    pub use day_spec::props::{PaneEdge, SplitAxis};
188    pub use day_spec::{AnimSpec, AnimSpec as Animation, Curve};
189    pub use day_spec::{AssetName, FontFamily, ImageName};
190    pub use day_spec::{DragPhase, Edges, GestureKind};
191    // Text entry (docs/textfield.md): what a field collects and what its action key says.
192    pub use day_spec::{
193        DrawOp, LinearGradient, Paint, RadialGradient, Shape, TextAnchor, TextVAlign, UnitPoint,
194    };
195    pub use day_spec::{InputPurpose, SubmitLabel};
196    // Canvas fonts and the platform font list (docs/fonts.md).
197    pub use day_spec::{CanvasFont, FontFace, FontFamilyInfo, TextMetrics};
198    pub use day_spec::{Font, FontSpec, FontWeight, Role};
199    // The styled-text document (docs/texteditor.md): what `.markdown()` parses into, what a
200    // label's runs are, and what `day-piece-text-editor` edits, plus the Markdown / HTML / RTF
201    // codecs over it.
202    pub use day_spec::{
203        LabelStyle, Symbol, ToolbarItem, ToolbarItemKind, ToolbarPlacement, ToolbarValue,
204    };
205    pub use day_spec::{
206        ListStyle, ParagraphAlign, ParagraphRun, ParagraphStyle, RunStyle, StyledText, TextRun,
207        Underline,
208    };
209    pub use day_spec::{MenuBarRole, MenuItem, MenuRole, Shortcut};
210    pub use std::time::Duration;
211}