@domphy/ui 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -17,6 +17,25 @@ declare function abbreviation(props?: {
17
17
  accentColor?: ValueOrState<ThemeColor>;
18
18
  }): PartialElement;
19
19
 
20
+ /**
21
+ * Container patch that groups `<details>` elements into a bordered accordion.
22
+ * In `type: "single"` mode (default), opening one item closes all siblings.
23
+ *
24
+ * @param props.type - `"single"` (default) or `"multiple"`. Single mode auto-closes siblings.
25
+ * @param props.color - Theme color tone for borders and backgrounds. Defaults to `"neutral"`.
26
+ * @param props.accentColor - Accent color for focus outlines on summary. Defaults to `"primary"`.
27
+ * @example
28
+ * { div: [
29
+ * { details: [{ summary: "Section A" }, { p: "Content A" }], $: [details()] },
30
+ * { details: [{ summary: "Section B" }, { p: "Content B" }], $: [details()] },
31
+ * ], $: [accordion()] }
32
+ */
33
+ declare function accordion(props?: {
34
+ type?: "single" | "multiple";
35
+ color?: ValueOrState<ThemeColor>;
36
+ accentColor?: ValueOrState<ThemeColor>;
37
+ }): PartialElement;
38
+
20
39
  /**
21
40
  * A semantic alert surface block with a colored inset bar, padding, and
22
41
  * `role="alert"`. Typically applied to a `<div>` (any block container).
@@ -58,7 +77,7 @@ declare function badge(props?: {
58
77
  * shifted tone. Apply to a `<blockquote>` element.
59
78
  *
60
79
  * @hostTag blockquote
61
- * @param props.color - Surface/bar color tone. Optional `ValueOrState<ThemeColor>`, default "inherit".
80
+ * @param props.color - Surface/bar color tone. Optional `ValueOrState<ThemeColor>`, default "neutral".
62
81
  * @example { blockquote: "Design is how it works.", $: [blockquote({ color: "primary" })] }
63
82
  */
64
83
  declare function blockquote(props?: {
@@ -104,6 +123,20 @@ declare function button(props?: {
104
123
  color?: ValueOrState<ThemeColor>;
105
124
  }): PartialElement;
106
125
 
126
+ /**
127
+ * A transparent button with no border or background — suitable for icon
128
+ * actions, inline controls, and delete/close triggers. Apply to a `<button>`
129
+ * element.
130
+ *
131
+ * @hostTag button
132
+ * @param props.color - Text color tone. Optional `ValueOrState<ThemeColor>`, defaults to `"neutral"`.
133
+ * @example { button: "×", $: [buttonGhost()] }
134
+ * @example { button: { span: null, $: [icon({ name: "trash" })] }, $: [buttonGhost({ color: "error" })] }
135
+ */
136
+ declare function buttonGhost(props?: {
137
+ color?: ValueOrState<ThemeColor>;
138
+ }): PartialElement;
139
+
107
140
  /**
108
141
  * A pill-shaped toggle switch with `role="switch"`; clicking flips the bound
109
142
  * `checked` state and slides the thumb. Apply to a `<button>` element.
@@ -198,10 +231,11 @@ declare function commandSearch(props?: {
198
231
  accentColor?: ThemeColor;
199
232
  }): PartialElement;
200
233
  /**
201
- * Selectable item (`role="option"`) in a command palette. Subscribes to the
202
- * parent `command` context's query State and hides itself when its text content
203
- * does not match the current query. Typically applied to a `<button>` (or any
204
- * clickable element) used inside a `command()`.
234
+ * Selectable item (`role="option"`) in a command palette. On mount, immediately
235
+ * hides itself if the current query doesn't match its text content, and subscribes
236
+ * to future query changes — so items added dynamically after a search is typed are
237
+ * correctly filtered. Typically applied to a `<button>` (or any clickable element)
238
+ * used inside a `command()`.
205
239
  *
206
240
  * @param props.color - Base theme color tone. Defaults to "neutral".
207
241
  * @param props.accentColor - Accent color used for the focus outline. Defaults to "primary".
@@ -296,8 +330,9 @@ declare function details(props?: {
296
330
 
297
331
  /**
298
332
  * Modal dialog patch driven by an `open` State. Calls `showModal()`/`close()`,
299
- * fades via opacity, locks page scroll while open, focuses the first focusable
300
- * child, and closes on outside (backdrop) click. Apply to a `<dialog>` element.
333
+ * fades via opacity, locks page scroll while open, traps Tab focus within the
334
+ * dialog, restores focus to the previously focused element on close, sets
335
+ * `aria-modal`, and closes on outside (backdrop) click. Apply to a `<dialog>`.
301
336
  *
302
337
  * @hostTag dialog
303
338
  * @param props.color - Theme color tone for the dialog surface. Defaults to "neutral".
@@ -321,19 +356,30 @@ declare function divider(props?: {
321
356
  color?: ValueOrState<ThemeColor>;
322
357
  }): PartialElement;
323
358
 
324
- type Placement = "left" | "right" | "top" | "bottom";
359
+ type PhysicalPlacement = "left" | "right" | "top" | "bottom";
360
+ type Placement = PhysicalPlacement | "start" | "end";
325
361
  /**
326
362
  * Edge-anchored modal drawer driven by an `open` State. Slides in/out from a
327
- * chosen edge via a transform transition, calls `showModal()`/`close()`, locks
328
- * page scroll while open, and closes on backdrop click. Apply to a `<dialog>`
329
- * element.
363
+ * chosen edge via a 250 ms transform transition, calls `showModal()`/`close()`,
364
+ * locks page scroll while open, and closes on backdrop click. A 350 ms fallback
365
+ * ensures `close()` is always called even when `transitionend` doesn't fire
366
+ * (reduced-motion, `display:none`, detached element). Apply to a `<dialog>`.
367
+ *
368
+ * Because the patch uses the native `<dialog>` `showModal()` API, the browser
369
+ * traps focus inside the drawer while it is open and restores focus to the
370
+ * previously focused element when `close()` is called. Sets `aria-modal="true"`.
371
+ * Escape key closes the drawer via the animated state path (not immediate close).
372
+ *
373
+ * `"start"` and `"end"` placements resolve to left/right based on the
374
+ * document's `dir` attribute at mount time, enabling RTL-aware drawers:
375
+ * `"start"` → left (LTR) / right (RTL); `"end"` → right (LTR) / left (RTL).
330
376
  *
331
377
  * @hostTag dialog
332
378
  * @param props.color - Theme color tone for the drawer surface. Defaults to "neutral".
333
379
  * @param props.open - Open state (`ValueOrState<boolean>`); set true/false to show/hide. Defaults to false.
334
- * @param props.placement - Edge to anchor to, "left" | "right" | "top" | "bottom". Defaults to "right".
335
- * @param props.size - CSS length for the drawer's width (left/right) or height (top/bottom). Defaults to themeSpacing(80) for left/right, themeSpacing(64) for top/bottom.
336
- * @example { dialog: [...], $: [drawer({ open, placement: "left" })] }
380
+ * @param props.placement - Edge to anchor to. "left" | "right" | "top" | "bottom" | "start" | "end". Defaults to "end".
381
+ * @param props.size - CSS length for the drawer's width (left/right/start/end) or height (top/bottom). Defaults to themeSpacing(80) for left/right, themeSpacing(64) for top/bottom.
382
+ * @example { dialog: [...], $: [drawer({ open, placement: "start" })] }
337
383
  */
338
384
  declare function drawer(props?: {
339
385
  color?: ThemeColor;
@@ -353,6 +399,56 @@ declare function emphasis(props?: {
353
399
  color?: ValueOrState<ThemeColor>;
354
400
  }): PartialElement;
355
401
 
402
+ /**
403
+ * Styles a container as an empty-state placeholder: centered flex column with
404
+ * muted coloring and comfortable padding. Provide the icon, title, and
405
+ * description as child elements.
406
+ *
407
+ * @param props.color - Theme color tone for the muted text/icon. Defaults to `"neutral"`.
408
+ * @example
409
+ * { div: [
410
+ * { span: "📭" },
411
+ * { p: "No items yet", $: [paragraph()] },
412
+ * { span: "Add your first item to get started", $: [small()] },
413
+ * ], $: [empty()] }
414
+ */
415
+ declare function empty(props?: {
416
+ color?: ValueOrState<ThemeColor>;
417
+ }): PartialElement;
418
+
419
+ /**
420
+ * Catches errors thrown inside reactive child expressions and renders a
421
+ * fallback element instead of crashing the whole tree. Apply to any container.
422
+ *
423
+ * Only errors in *reactive* children (functions returning element arrays) are
424
+ * caught. Errors during static construction propagate normally — those are
425
+ * programming errors, not runtime data errors.
426
+ *
427
+ * @hostTag any
428
+ * @param props.fallback - Fallback element or factory `(error, reset) => element`. Defaults to a plain error message div.
429
+ * @param props.onError - Optional callback for logging/telemetry.
430
+ * @example { div: (l) => renderUserContent(l), $: [errorBoundary({ fallback: { p: "Something went wrong." } })] }
431
+ */
432
+ declare function errorBoundary(props?: {
433
+ fallback?: DomphyElement | ((error: unknown, reset: () => void) => DomphyElement);
434
+ onError?: (error: unknown) => void;
435
+ }): PartialElement;
436
+
437
+ /**
438
+ * Floating Action Button — a circular elevated button typically used for the
439
+ * primary action on a screen. Apply to a `<button>` element.
440
+ *
441
+ * @hostTag button
442
+ * @param props.color - Button color tone. Optional `ValueOrState<ThemeColor>`, defaults to `"primary"`.
443
+ * @param props.size - Button size preset. Optional `"small" | "medium" | "large"`, defaults to `"medium"`.
444
+ * @example { button: "+", $: [fab()] }
445
+ * @example { button: "+", $: [fab({ size: "small", color: "neutral" })] }
446
+ */
447
+ declare function fab(props?: {
448
+ color?: ValueOrState<ThemeColor>;
449
+ size?: "small" | "medium" | "large";
450
+ }): PartialElement;
451
+
356
452
  /**
357
453
  * Lays out a figure as a column with block-level media (img/svg/video/canvas)
358
454
  * and a themed `<figcaption>`. Apply to a `<figure>` element.
@@ -453,7 +549,7 @@ declare function inputCheckbox(props?: {
453
549
  * @param props.accentColor - Optional theme color tone (`ValueOrState<ThemeColor>`). Defaults to `"primary"`.
454
550
  * @example { input: null, type: "color", $: [inputColor()] }
455
551
  */
456
- declare function inputColor(props?: {
552
+ declare function inputColor(_props?: {
457
553
  color?: ValueOrState<ThemeColor>;
458
554
  accentColor?: ValueOrState<ThemeColor>;
459
555
  }): PartialElement;
@@ -635,6 +731,42 @@ declare function link(props?: {
635
731
  accentColor?: ValueOrState<ThemeColor>;
636
732
  }): PartialElement;
637
733
 
734
+ /**
735
+ * Styles a navigation/display list container. Sets `list-style: none` and
736
+ * zero padding; pairs with `listItem` and `listItemButton`. Apply to `<ul>`.
737
+ *
738
+ * @hostTag ul
739
+ * @param props.color - Surface color tone. Optional `ThemeColor`, defaults to `"neutral"`.
740
+ * @example { ul: [...], $: [list()] }
741
+ */
742
+ declare function list(_props?: {
743
+ color?: ThemeColor;
744
+ }): PartialElement;
745
+ /**
746
+ * A non-interactive list row. Typically wraps an icon + text. Apply to `<li>`.
747
+ *
748
+ * @hostTag li
749
+ * @param props.dense - Reduce vertical padding. Optional `boolean`, defaults to `false`.
750
+ * @example { li: "Item", $: [listItem()] }
751
+ */
752
+ declare function listItem(props?: {
753
+ dense?: boolean;
754
+ }): PartialElement;
755
+ /**
756
+ * An interactive (clickable) list row with hover/focus-visible states. Apply
757
+ * to `<button>` or `<a>` inside an `<li>`.
758
+ *
759
+ * @param props.color - Color tone. Optional `ValueOrState<ThemeColor>`, defaults to `"neutral"`.
760
+ * @param props.accentColor - Focus/active accent. Optional `ThemeColor`, defaults to `"primary"`.
761
+ * @param props.dense - Reduce vertical padding. Optional `boolean`, defaults to `false`.
762
+ * @example { button: "Action", $: [listItemButton()] }
763
+ */
764
+ declare function listItemButton(props?: {
765
+ color?: ValueOrState<ThemeColor>;
766
+ accentColor?: ThemeColor;
767
+ dense?: boolean;
768
+ }): PartialElement;
769
+
638
770
  /**
639
771
  * Themed highlight primitive: gives marked/highlighted inline text a tinted
640
772
  * background, rounded corners and padding. Apply to a `<mark>` element.
@@ -791,7 +923,7 @@ declare function paragraph(props?: {
791
923
  * @example { button: "Open", $: [popover({ openOn: "click", content: { div: "Hi" } })] }
792
924
  */
793
925
  declare function popover(props: {
794
- openOn: "click" | "hover";
926
+ openOn?: "click" | "hover";
795
927
  open?: ValueOrState<boolean>;
796
928
  placement?: ValueOrState<Placement$1>;
797
929
  content: DomphyElement;
@@ -850,6 +982,54 @@ declare function progress(props?: {
850
982
  accentColor?: ValueOrState<ThemeColor>;
851
983
  }): PartialElement;
852
984
 
985
+ /**
986
+ * Interactive star rating applied to a container `<div>`. Manages its own star
987
+ * children: click to set, Arrow keys to adjust, hover to preview. In `readOnly`
988
+ * mode stars are non-interactive. Apply to a `<div>` element.
989
+ *
990
+ * @hostTag div
991
+ * @param props.value - Current rating (0 – max). `ValueOrState<number>`, defaults to `0`.
992
+ * @param props.max - Total number of stars. Optional `number`, defaults to `5`.
993
+ * @param props.onChange - Called with the new value when the user picks a star.
994
+ * @param props.readOnly - Disable interaction. Optional `boolean`, defaults to `false`.
995
+ * @param props.color - Star color tone. Optional `ThemeColor`, defaults to `"warning"`.
996
+ * @example { div: null, $: [rating({ value: ratingState, onChange: (v) => ratingState.set(v) })] }
997
+ */
998
+ declare function rating(props?: {
999
+ value?: ValueOrState<number>;
1000
+ max?: number;
1001
+ onChange?: (value: number) => void;
1002
+ readOnly?: boolean;
1003
+ color?: ThemeColor;
1004
+ }): PartialElement;
1005
+
1006
+ /**
1007
+ * Container patch that establishes a `segmented` context for single-select navigation.
1008
+ * Style: inline pill-shaped control with muted background. Use with `segmentedItem` patches on child `<button>` elements.
1009
+ *
1010
+ * @param props.value - Initially selected item key. Accepts a value or state. Defaults to `""`.
1011
+ * @param props.color - Theme color for the control background. Defaults to `"neutral"`.
1012
+ * @example { div: null, $: [segmented({ value: "month" })] }
1013
+ */
1014
+ declare function segmented(props?: {
1015
+ value?: ValueOrState<string>;
1016
+ color?: ThemeColor;
1017
+ }): PartialElement;
1018
+
1019
+ /**
1020
+ * Styles and wires a single option inside a `segmented` control on the host `<button>`.
1021
+ * Sets `aria-checked` and handles click-to-select against the parent `segmented` context.
1022
+ *
1023
+ * @hostTag button
1024
+ * @param props.color - Theme color for resting state. Defaults to `"neutral"`.
1025
+ * @param props.accentColor - Theme color for selected state. Defaults to `"primary"`.
1026
+ * @example { button: "Month", $: [segmentedItem()] }
1027
+ */
1028
+ declare function segmentedItem(props?: {
1029
+ color?: ValueOrState<ThemeColor>;
1030
+ accentColor?: ValueOrState<ThemeColor>;
1031
+ }): PartialElement;
1032
+
853
1033
  /**
854
1034
  * Styles a native `<select>` control: removes the default appearance, applies themed
855
1035
  * colors, outline, density-scaled padding/radius, a custom chevron background icon, and
@@ -1004,13 +1184,41 @@ declare function splitter(props?: {
1004
1184
  declare function splitterPanel(): PartialElement;
1005
1185
  /**
1006
1186
  * The draggable divider inside a `splitter`. Reads the `splitter` context, shows the
1007
- * appropriate resize cursor, and on mouse drag updates the context `size` state (clamped to
1008
- * `min`/`max`). Warns if used outside a `splitter`. Takes no props.
1187
+ * appropriate resize cursor, and updates the context `size` state (clamped to `min`/`max`)
1188
+ * via mouse drag or keyboard: Arrow keys move by 1%, Home/End jump to min/max, hold Shift
1189
+ * for 10× step. Sets `role="separator"`, `tabindex="0"`, and `aria-value*` attributes.
1190
+ * Warns if used outside a `splitter`. Takes no props.
1009
1191
  *
1010
1192
  * @example { div: null, $: [splitterHandle()] }
1011
1193
  */
1012
1194
  declare function splitterHandle(): PartialElement;
1013
1195
 
1196
+ /**
1197
+ * Styles a single step inside a `steps` container. Sets `data-status`
1198
+ * (`"pending"` | `"active"` | `"done"`) and `aria-current="step"` on the host element
1199
+ * based on the parent `steps` context. The element's content is the step label.
1200
+ *
1201
+ * @example { li: "Shipping", $: [stepItem()] }
1202
+ */
1203
+ declare function stepItem(): PartialElement;
1204
+
1205
+ /**
1206
+ * Container patch for a step-progress indicator. Establishes `steps` context
1207
+ * with a reactive `current` index. Use with `stepItem` patches on child elements.
1208
+ *
1209
+ * @param props.current - Zero-based index of the active step. Accepts a value or state. Defaults to `0`.
1210
+ * @param props.direction - `"horizontal"` (default) or `"vertical"` layout.
1211
+ * @param props.color - Theme color for pending/track elements. Defaults to `"neutral"`.
1212
+ * @param props.accentColor - Theme color for active/completed elements. Defaults to `"primary"`.
1213
+ * @example { ol: null, $: [steps({ current: 1 })] }
1214
+ */
1215
+ declare function steps(props?: {
1216
+ current?: ValueOrState<number>;
1217
+ direction?: "horizontal" | "vertical";
1218
+ color?: ThemeColor;
1219
+ accentColor?: ThemeColor;
1220
+ }): PartialElement;
1221
+
1014
1222
  /**
1015
1223
  * Styles strongly emphasized (bold) text: inherited font size, `font-weight: 700`, and a
1016
1224
  * themed foreground color.
@@ -1127,6 +1335,30 @@ declare function textarea(props?: {
1127
1335
  autoResize?: boolean;
1128
1336
  }): PartialElement;
1129
1337
 
1338
+ /**
1339
+ * Container for a vertical timeline. Sets list reset styles. Apply to `<ol>` or `<ul>`.
1340
+ *
1341
+ * @example { ol: [...], $: [timeline()] }
1342
+ */
1343
+ declare function timeline(): PartialElement;
1344
+ /**
1345
+ * A single event row in a `timeline`. Uses a 2-column grid: the left column holds
1346
+ * a dot (`::before`) and optional connector line (`::after`); the right column holds
1347
+ * the user's content. Apply to `<li>`.
1348
+ *
1349
+ * @param props.active - Full-opacity dot (accent color). `ValueOrState<boolean>`, defaults to `false`.
1350
+ * @param props.last - Suppress the vertical connector below this item. `boolean`, defaults to `false`.
1351
+ * @param props.color - Dot/connector color tone. `ThemeColor`, defaults to `"neutral"`.
1352
+ * @param props.accentColor - Active dot color tone. `ThemeColor`, defaults to `"primary"`.
1353
+ * @example { li: [{ b: "2024" }, { p: "Event" }], $: [timelineItem({ active: true })] }
1354
+ */
1355
+ declare function timelineItem(props?: {
1356
+ active?: ValueOrState<boolean>;
1357
+ last?: boolean;
1358
+ color?: ThemeColor;
1359
+ accentColor?: ThemeColor;
1360
+ }): PartialElement;
1361
+
1130
1362
  type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
1131
1363
  /**
1132
1364
  * Renders a transient notification surface as a fixed-position overlay (portaled
@@ -1175,6 +1407,25 @@ declare function toggleGroup(props?: {
1175
1407
  color?: ThemeColor;
1176
1408
  }): PartialElement;
1177
1409
 
1410
+ /**
1411
+ * A horizontal flex row with vertically centered items. Useful for headers,
1412
+ * toolbars, navigation bars, and action strips.
1413
+ *
1414
+ * @param props.gap - Spacing multiplier for gap between items (default 4 = 1em).
1415
+ * @example { header: [...], $: [toolbar()] }
1416
+ * @example { nav: [...], $: [toolbar({ gap: 3 })] }
1417
+ */
1418
+ declare function toolbar(props?: {
1419
+ gap?: number;
1420
+ }): PartialElement;
1421
+ /**
1422
+ * A flex spacer that expands to fill available space in a toolbar, pushing
1423
+ * subsequent items to the far end.
1424
+ *
1425
+ * @example { header: [logo, toolbarSpacer(), nav, actions], $: [toolbar()] }
1426
+ */
1427
+ declare function toolbarSpacer(): DomphyElement;
1428
+
1178
1429
  /**
1179
1430
  * Attaches a floating tooltip to the host element, shown on hover/focus and
1180
1431
  * hidden on leave/blur/Escape. Returns the anchor (trigger) partial; the tooltip
@@ -1218,4 +1469,4 @@ declare function unorderedList(props?: {
1218
1469
  color?: ValueOrState<ThemeColor>;
1219
1470
  }): PartialElement;
1220
1471
 
1221
- export { type DatePickerProps, type DatePickerValue, type MotionKeyframe, type MotionProps, abbreviation, alert, avatar, badge, blockquote, breadcrumb, breadcrumbEllipsis, button, buttonSwitch, card, code, combobox, command, commandItem, commandSearch, datePicker, descriptionList, details, dialog, divider, drawer, emphasis, figure, formGroup, heading, horizontalRule, icon, image, inputCheckbox, inputColor, inputDateTime, inputFile, inputNumber, inputOTP, inputRadio, inputRange, inputSearch, inputSwitch, inputText, keyboard, label, link, mark, menu, menuItem, motion, orderedList, pagination, paragraph, popover, popoverArrow, preformated, progress, select, selectBox, selectItem, selectList, skeleton, small, spinner, splitter, splitterHandle, splitterPanel, strong, subscript, superscript, tab, tabPanel, table, tabs, tag, textarea, toast, toggle, toggleGroup, tooltip, transitionGroup, unorderedList };
1472
+ export { type DatePickerProps, type DatePickerValue, type MotionKeyframe, type MotionProps, abbreviation, accordion, alert, avatar, badge, blockquote, breadcrumb, breadcrumbEllipsis, button, buttonGhost, buttonSwitch, card, code, combobox, command, commandItem, commandSearch, datePicker, descriptionList, details, dialog, divider, drawer, emphasis, empty, errorBoundary, fab, figure, formGroup, heading, horizontalRule, icon, image, inputCheckbox, inputColor, inputDateTime, inputFile, inputNumber, inputOTP, inputRadio, inputRange, inputSearch, inputSwitch, inputText, keyboard, label, link, list, listItem, listItemButton, mark, menu, menuItem, motion, orderedList, pagination, paragraph, popover, popoverArrow, preformated, progress, rating, segmented, segmentedItem, select, selectBox, selectItem, selectList, skeleton, small, spinner, splitter, splitterHandle, splitterPanel, stepItem, steps, strong, subscript, superscript, tab, tabPanel, table, tabs, tag, textarea, timeline, timelineItem, toast, toggle, toggleGroup, toolbar, toolbarSpacer, tooltip, transitionGroup, unorderedList };