Skip to main content

Module kit

Module kit 

Source
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:

  1. kit::thing(id, rect, data) starts a builder. The id is a stable WidgetId; child parts get "{id}:…" ids ("{id}:tab:2", "{id}:row:5", "{id}:footer:0").
  2. Chain options (.selected(i), .bind(&mut v), .disabled(true), …).
  3. .build(cx) registers hits, names the parts for assistive tech, paints with the token theme of cx, and returns a Response.

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.

PieceStartReports
buttonbutton(id, rect).on_click, .bind_count
inputinput(id, rect, &mut text)changed, focused; edits itself
selectselect(id, rect, options) + .key, .withinindex picked, changed, checked open
menumenu(id, at, items, open)index picked
dialogdialog(id, rect)index footer button, clicked close
tabstabs(id, rect, labels)index clicked, changed
listlist(id, rect, rows)index clicked, changed
splittersplitter(id, axis, span, &mut pos)changed, pressed while dragging
tooltiptooltip(id, rect)—
toasttoasts(id, area, &mut stack, now_ms)changed while any is shown
checkboxcheckbox(id, rect) + .bind(&mut b).build_response: checked, changed
switchswitch(id, rect) + .bind(&mut b).build_response: checked, changed
tabletable(id, rect, columns, rows)index row, column header, changed
drawerdrawer(id, area, &mut open)changed when the scrim closes it
fieldfield(id, rect) in the app’s own chrometext 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::button;
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 El trees for the common controls and chat building blocks, styled by KIT_CSS (every look is a CSS rule an app may override by appending its own sheet, see sheet_with).

Structs§

DialogBuilder
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 with dom.
DomResponse
What a dom tree did this frame.
DrawerBuilder
A side panel over the content with a scrim. Start with drawer.
FieldBuilder
A borderless text field inside the app’s own chrome. Start with field.
FieldResponse
What a field shows this frame.
InputBuilder
Single-line editable text field. Start with input.
ListBuilder
A vertical list of selectable text rows. Start with list.
MenuBuilder
A context menu. Start with menu.
Response
What a piece reports after .build(cx).
SelectBuilder
A button that opens a list of options. Start with select.
SelectStyle
The look of an open list, set from CSS (Styled): standard background, border-color, border-radius, box-shadow, color, font-size, plus the custom properties named after the fields (--row-h, --row-hi, --check, …).
SplitterBuilder
A draggable pane edge. Start with splitter.
TableBuilder
A table with a header row and selectable body rows. Start with table.
TabsBuilder
A row of equal-width tabs. Start with tabs.
ToastType
A toast notification instance.
ToastsBuilder
The toast stack. Start with toasts.

Enums§

Side
The edge a drawer slides from.
ToastSeverity
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 as clicked), footer buttons "{id}:footer:{i}" (reported as index; the first is primary). The app decides whether either closes it.
dom
Lay out root with sheet in rect (scrolled up by DomBuilder::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::name first, 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 in field. position: fixed elements (a select popover, a side panel) are placed against the panel and stay put while it scrolls.
drawer
A drawer over area, shown while *open. A click on the scrim ("{id}:scrim") clears open and reports changed. Paint the body in DrawerBuilder::body_rect after build.
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 before build.
input
An editable text field bound to value.
list
Rows rows inside rect. Parts are "{id}:row:{i}". Rows outside rect (after .scroll) are neither painted nor hit.
menu
A menu of items at at while *open. Items are "{id}:item:{i}". A pick or a click elsewhere clears *open.
select
A select showing options[selected]. The trigger is id; options are "{id}:list:item:{i}" (i = index into options). The open state (flag, highlighted row, search text, scroll) lives in the widget state store.
select_is_open
Whether the select id is 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 *pos along axis across span. Dragging writes *pos.
table
A table of rows under columns in rect. Parts are "{id}:col:{j}" (header cells, a click reports column) and "{id}:row:{i}" (rows, a click reports index). Rows outside rect after .scroll are skipped.
tabs
Tabs labelled labels, laid out across rect. Parts are "{id}:tab:{i}".
toasts
Paint the live toasts of stack in the bottom-right of area, dropping expired ones. Push new ones with ToastStackState::push.