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;
Modules§
- domkit
- The DOM widget catalog (CSS-styled controls, select popover, chat blocks).
The DOM widget catalog: ready-made
Eltrees for the common controls and chat building blocks, styled byKIT_CSS(every look is a CSS rule an app may override by appending its own sheet, seesheet_with).
Structs§
- Area
Builder - A multiline text area (a
<textarea>) whose box the app paints itself: the kit registers it atrect, wraps the text to its width, paints text, placeholder, selection, IME composition and a blinking caret line by line, and feeds per-line caret geometry to the text store, so clicks, drags, double / triple clicks, ArrowUp / ArrowDown and Home / End work by laid lines. Start witharea. - Area
Line - One laid line of a
area: charsstart..endof the shown text (a hard line break’s\nis not in any line), and whether a\nends it. - Area
Response - What an
areashows this frame. - Dialog
Builder - A modal frame with a title, close button and footer. Start with
dialog. - DomBuilder
- A DOM tree (
uzor::ui::dom) inside a kit panel. Start withdom. - DomResponse
- What a
domtree did this frame. - 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. - Paint
Slot - A custom-paint area (a chart, an order book) outside a DOM tree. Start with
paint_slot. Inside a DOM tree useuzor::ui::dom::El::paint_slotwithDomBuilder::paint_slotsinstead. - 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, …). - Slot
Frame - One custom-paint slot as the host paints it this frame (
DomBuilder::paint_slots,paint_slot). - Slot
Response - What a
paint_slotreported this frame. - 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§
- area
- A multiline text area at
rect(seeAreaBuilder). The text box isrectunlessAreaBuilder::text_rect; it scrolls up byAreaBuilder::scroll. - area_
lines - Lay
textout the wayareapaints it in a boxwidthwide with the font already set onrender: hard lines at\n, soft wrap after spaces (a word longer than the box breaks between chars). For sizing before layout (an auto-growing composer countslines.len()). Never empty: an empty text is one empty line. - 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. - dom
- Lay out
rootwithsheetinrect(scrolled up byDomBuilder::scroll), paint it, and register every element with an id: buttons, switches, checkboxes and rows become focusable click targets named by their accessible name (El::namefirst, then text) with their checked state; DOM text inputs (uzor::ui::dom::Control::Input) become text-store fields, so caret, selection, drag, clipboard and IME work as infield.position: fixedelements (a select popover, a side panel) are placed against the panel and stay put while it scrolls. - dom_
scroll_ to - Scroll the framework-owned DOM scroll container
idtoy(CSSel.scrollTop = y, clamped to its range on the next frame);smoothglides there. - dom_
scroll_ top - The
scrollTopof the framework-owned DOM scroll containerid(0 before its first frame). - 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, selection, a blinking 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. - paint_
slot - A custom-paint slot
idatrect: registered as a click, drag and wheel target that also captures touch (Sense::touch, so a finger on it pans / pinches it and never scrolls what is under it), painted by the closure given toPaintSlot::paint, clipped torect. The mouse drag and the wheel areSlotFrame::pressedandSlotFrame::wheel. Widgets registered after it (buttons drawn over a chart) stay ordinary targets. - 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.