Expand description
The component kit: one builder shape for the reusable pieces of a DOM-like app (roadmap item 10).
Every piece follows the same three steps:
kit::thing(id, rect, data)starts a builder. The id is a stableWidgetId; child parts get"{id}:…"ids ("{id}:tab:2","{id}:row:5","{id}:footer:0").- Chain options (
.selected(i),.bind(&mut v),.disabled(true), …). .build(cx)registers hits, names the parts for assistive tech, paints with the token theme ofcx, and returns aResponse.
The app keeps its own values (text, selection, sizes): a piece reads them
from the builder and reports changes through Response or .bind. State
that only exists to drive a widget (a select’s open flag, a dialog’s
drag position, a splitter’s drag) lives in the frame’s widget state store
under the piece’s id, as a DOM element keeps its own :open.
| Piece | Start | Reports |
|---|---|---|
| button | button(id, rect) | .on_click, .bind_count |
| input | input(id, rect, &mut text) | changed, focused; edits itself |
| select | select(id, rect, options) + .key, .within | index picked, changed, checked open |
| menu | menu(id, at, items, open) | index picked |
| dialog | dialog(id, rect) | index footer button, clicked close |
| tabs | tabs(id, rect, labels) | index clicked, changed |
| list | list(id, rect, rows) | index clicked, changed |
| splitter | splitter(id, axis, span, &mut pos) | changed, pressed while dragging |
| tooltip | tooltip(id, rect) | — |
| toast | toasts(id, area, &mut stack, now_ms) | changed while any is shown |
| checkbox | checkbox(id, rect) + .bind(&mut b) | .build_response: checked, changed |
| switch | switch(id, rect) + .bind(&mut b) | .build_response: checked, changed |
| table | table(id, rect, columns, rows) | index row, column header, changed |
| drawer | drawer(id, area, &mut open) | changed when the scrim closes it |
| field | field(id, rect) in the app’s own chrome | text shown, focused; edits itself |
An app that paints its own chrome (its CSS, not the token theme) and
registers hits itself uses the paint half from
uzor::ui::widgets::composite::dialog: text_button_at (sized text
button), draw_close_button (✕ on a circle, a rounded rect or bare),
fill_circle, draw_switch, draw_card.
Overlay-like pieces (select’s list, menu, dialog) paint where they are built: build them last in a panel, or inside an overlay hook, so they sit on top.
use uzor_framework::widgets::kit;
let r = kit::tabs("settings-tabs", tabs_rect, &["General", "Usage"]).bind(&mut self.tab).build(cx);
kit::input("name", name_rect, &mut self.name).placeholder("Name").build(cx);
if kit::button("save", save_rect).text("Save").build_response(cx).clicked { self.save(); }Re-exports§
pub use super::lm::checkbox;pub use super::lm::toggle as switch;pub use super::lm::tooltip;pub use super::lm::ButtonBuilder;pub use super::lm::CheckboxBuilder;pub use super::lm::ToggleBuilder as SwitchBuilder;pub use super::lm::TooltipBuilder;pub use super::splitter::Axis;
Structs§
- Dialog
Builder - A modal frame with a title, close button and footer. Start with
dialog. - Drawer
Builder - A side panel over the content with a scrim. Start with
drawer. - Field
Builder - A borderless text field inside the app’s own chrome. Start with
field. - Field
Response - What a
fieldshows this frame. - Input
Builder - Single-line editable text field. Start with
input. - List
Builder - A vertical list of selectable text rows. Start with
list. - Menu
Builder - A context menu. Start with
menu. - Response
- What a piece reports after
.build(cx). - Select
Builder - A button that opens a list of options. Start with
select. - Select
Style - The look of an open list, set from CSS (
Styled): standardbackground,border-color,border-radius,box-shadow,color,font-size, plus the custom properties named after the fields (--row-h,--row-hi,--check, …). - Splitter
Builder - A draggable pane edge. Start with
splitter. - Table
Builder - A table with a header row and selectable body rows. Start with
table. - Tabs
Builder - A row of equal-width tabs. Start with
tabs. - Toast
Type - A toast notification instance.
- Toasts
Builder - The toast stack. Start with
toasts.
Enums§
- Side
- The edge a drawer slides from.
- Toast
Severity - Visual severity — uzor extends beyond mlc’s single variant. mlc has one visual (Info/blue); Success/Warning/Error are uzor additions.
Functions§
- dialog
- A dialog in
rect. Close is"{id}:close"(reported asclicked), footer buttons"{id}:footer:{i}"(reported asindex; the first is primary). The app decides whether either closes it. - drawer
- A drawer over
area, shown while*open. A click on the scrim ("{id}:scrim") clearsopenand reportschanged. Paint the body inDrawerBuilder::body_rectafterbuild. - field
- A text field whose box the app paints itself (a search pill, a dialog row, a sign-in
input): the kit registers it at
rect, names it, draws text, placeholder, caret and composition, and feeds caret geometry and the IME area back to the text store. The edit state lives in the store; seed or clear it there beforebuild. - input
- An editable text field bound to
value. - list
- Rows
rowsinsiderect. Parts are"{id}:row:{i}". Rows outsiderect(after.scroll) are neither painted nor hit. - menu
- A menu of
itemsatatwhile*open. Items are"{id}:item:{i}". A pick or a click elsewhere clears*open. - select
- A select showing
options[selected]. The trigger isid; options are"{id}:list:item:{i}"(i= index intooptions). The open state (flag, highlighted row, search text, scroll) lives in the widget state store. - select_
is_ open - Whether the select
idis open (its list shows). An app that closes its dialog on Escape asks this first: Escape belongs to the open list. - splitter
- An edge at
*posalongaxisacrossspan. Dragging writes*pos. - table
- A table of
rowsundercolumnsinrect. Parts are"{id}:col:{j}"(header cells, a click reportscolumn) and"{id}:row:{i}"(rows, a click reportsindex). Rows outsiderectafter.scrollare skipped. - tabs
- Tabs labelled
labels, laid out acrossrect. Parts are"{id}:tab:{i}". - toasts
- Paint the live toasts of
stackin the bottom-right ofarea, dropping expired ones. Push new ones withToastStackState::push.