@domphy/ui 0.16.0 → 0.17.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?: {
@@ -198,10 +217,11 @@ declare function commandSearch(props?: {
198
217
  accentColor?: ThemeColor;
199
218
  }): PartialElement;
200
219
  /**
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()`.
220
+ * Selectable item (`role="option"`) in a command palette. On mount, immediately
221
+ * hides itself if the current query doesn't match its text content, and subscribes
222
+ * to future query changes — so items added dynamically after a search is typed are
223
+ * correctly filtered. Typically applied to a `<button>` (or any clickable element)
224
+ * used inside a `command()`.
205
225
  *
206
226
  * @param props.color - Base theme color tone. Defaults to "neutral".
207
227
  * @param props.accentColor - Accent color used for the focus outline. Defaults to "primary".
@@ -296,8 +316,9 @@ declare function details(props?: {
296
316
 
297
317
  /**
298
318
  * 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.
319
+ * fades via opacity, locks page scroll while open, traps Tab focus within the
320
+ * dialog, restores focus to the previously focused element on close, sets
321
+ * `aria-modal`, and closes on outside (backdrop) click. Apply to a `<dialog>`.
301
322
  *
302
323
  * @hostTag dialog
303
324
  * @param props.color - Theme color tone for the dialog surface. Defaults to "neutral".
@@ -321,19 +342,30 @@ declare function divider(props?: {
321
342
  color?: ValueOrState<ThemeColor>;
322
343
  }): PartialElement;
323
344
 
324
- type Placement = "left" | "right" | "top" | "bottom";
345
+ type PhysicalPlacement = "left" | "right" | "top" | "bottom";
346
+ type Placement = PhysicalPlacement | "start" | "end";
325
347
  /**
326
348
  * 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.
349
+ * chosen edge via a 250 ms transform transition, calls `showModal()`/`close()`,
350
+ * locks page scroll while open, and closes on backdrop click. A 350 ms fallback
351
+ * ensures `close()` is always called even when `transitionend` doesn't fire
352
+ * (reduced-motion, `display:none`, detached element). Apply to a `<dialog>`.
353
+ *
354
+ * Because the patch uses the native `<dialog>` `showModal()` API, the browser
355
+ * traps focus inside the drawer while it is open and restores focus to the
356
+ * previously focused element when `close()` is called. Sets `aria-modal="true"`.
357
+ * Escape key closes the drawer via the animated state path (not immediate close).
358
+ *
359
+ * `"start"` and `"end"` placements resolve to left/right based on the
360
+ * document's `dir` attribute at mount time, enabling RTL-aware drawers:
361
+ * `"start"` → left (LTR) / right (RTL); `"end"` → right (LTR) / left (RTL).
330
362
  *
331
363
  * @hostTag dialog
332
364
  * @param props.color - Theme color tone for the drawer surface. Defaults to "neutral".
333
365
  * @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" })] }
366
+ * @param props.placement - Edge to anchor to. "left" | "right" | "top" | "bottom" | "start" | "end". Defaults to "end".
367
+ * @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.
368
+ * @example { dialog: [...], $: [drawer({ open, placement: "start" })] }
337
369
  */
338
370
  declare function drawer(props?: {
339
371
  color?: ThemeColor;
@@ -353,6 +385,56 @@ declare function emphasis(props?: {
353
385
  color?: ValueOrState<ThemeColor>;
354
386
  }): PartialElement;
355
387
 
388
+ /**
389
+ * Styles a container as an empty-state placeholder: centered flex column with
390
+ * muted coloring and comfortable padding. Provide the icon, title, and
391
+ * description as child elements.
392
+ *
393
+ * @param props.color - Theme color tone for the muted text/icon. Defaults to `"neutral"`.
394
+ * @example
395
+ * { div: [
396
+ * { span: "📭" },
397
+ * { p: "No items yet", $: [paragraph()] },
398
+ * { span: "Add your first item to get started", $: [small()] },
399
+ * ], $: [empty()] }
400
+ */
401
+ declare function empty(props?: {
402
+ color?: ValueOrState<ThemeColor>;
403
+ }): PartialElement;
404
+
405
+ /**
406
+ * Catches errors thrown inside reactive child expressions and renders a
407
+ * fallback element instead of crashing the whole tree. Apply to any container.
408
+ *
409
+ * Only errors in *reactive* children (functions returning element arrays) are
410
+ * caught. Errors during static construction propagate normally — those are
411
+ * programming errors, not runtime data errors.
412
+ *
413
+ * @hostTag any
414
+ * @param props.fallback - Fallback element or factory `(error, reset) => element`. Defaults to a plain error message div.
415
+ * @param props.onError - Optional callback for logging/telemetry.
416
+ * @example { div: (l) => renderUserContent(l), $: [errorBoundary({ fallback: { p: "Something went wrong." } })] }
417
+ */
418
+ declare function errorBoundary(props?: {
419
+ fallback?: DomphyElement | ((error: unknown, reset: () => void) => DomphyElement);
420
+ onError?: (error: unknown) => void;
421
+ }): PartialElement;
422
+
423
+ /**
424
+ * Floating Action Button — a circular elevated button typically used for the
425
+ * primary action on a screen. Apply to a `<button>` element.
426
+ *
427
+ * @hostTag button
428
+ * @param props.color - Button color tone. Optional `ValueOrState<ThemeColor>`, defaults to `"primary"`.
429
+ * @param props.size - Button size preset. Optional `"small" | "medium" | "large"`, defaults to `"medium"`.
430
+ * @example { button: "+", $: [fab()] }
431
+ * @example { button: "+", $: [fab({ size: "small", color: "neutral" })] }
432
+ */
433
+ declare function fab(props?: {
434
+ color?: ValueOrState<ThemeColor>;
435
+ size?: "small" | "medium" | "large";
436
+ }): PartialElement;
437
+
356
438
  /**
357
439
  * Lays out a figure as a column with block-level media (img/svg/video/canvas)
358
440
  * and a themed `<figcaption>`. Apply to a `<figure>` element.
@@ -635,6 +717,42 @@ declare function link(props?: {
635
717
  accentColor?: ValueOrState<ThemeColor>;
636
718
  }): PartialElement;
637
719
 
720
+ /**
721
+ * Styles a navigation/display list container. Sets `list-style: none` and
722
+ * zero padding; pairs with `listItem` and `listItemButton`. Apply to `<ul>`.
723
+ *
724
+ * @hostTag ul
725
+ * @param props.color - Surface color tone. Optional `ThemeColor`, defaults to `"neutral"`.
726
+ * @example { ul: [...], $: [list()] }
727
+ */
728
+ declare function list(props?: {
729
+ color?: ThemeColor;
730
+ }): PartialElement;
731
+ /**
732
+ * A non-interactive list row. Typically wraps an icon + text. Apply to `<li>`.
733
+ *
734
+ * @hostTag li
735
+ * @param props.dense - Reduce vertical padding. Optional `boolean`, defaults to `false`.
736
+ * @example { li: "Item", $: [listItem()] }
737
+ */
738
+ declare function listItem(props?: {
739
+ dense?: boolean;
740
+ }): PartialElement;
741
+ /**
742
+ * An interactive (clickable) list row with hover/focus-visible states. Apply
743
+ * to `<button>` or `<a>` inside an `<li>`.
744
+ *
745
+ * @param props.color - Color tone. Optional `ValueOrState<ThemeColor>`, defaults to `"neutral"`.
746
+ * @param props.accentColor - Focus/active accent. Optional `ThemeColor`, defaults to `"primary"`.
747
+ * @param props.dense - Reduce vertical padding. Optional `boolean`, defaults to `false`.
748
+ * @example { button: "Action", $: [listItemButton()] }
749
+ */
750
+ declare function listItemButton(props?: {
751
+ color?: ValueOrState<ThemeColor>;
752
+ accentColor?: ThemeColor;
753
+ dense?: boolean;
754
+ }): PartialElement;
755
+
638
756
  /**
639
757
  * Themed highlight primitive: gives marked/highlighted inline text a tinted
640
758
  * background, rounded corners and padding. Apply to a `<mark>` element.
@@ -791,7 +909,7 @@ declare function paragraph(props?: {
791
909
  * @example { button: "Open", $: [popover({ openOn: "click", content: { div: "Hi" } })] }
792
910
  */
793
911
  declare function popover(props: {
794
- openOn: "click" | "hover";
912
+ openOn?: "click" | "hover";
795
913
  open?: ValueOrState<boolean>;
796
914
  placement?: ValueOrState<Placement$1>;
797
915
  content: DomphyElement;
@@ -850,6 +968,54 @@ declare function progress(props?: {
850
968
  accentColor?: ValueOrState<ThemeColor>;
851
969
  }): PartialElement;
852
970
 
971
+ /**
972
+ * Interactive star rating applied to a container `<div>`. Manages its own star
973
+ * children: click to set, Arrow keys to adjust, hover to preview. In `readOnly`
974
+ * mode stars are non-interactive. Apply to a `<div>` element.
975
+ *
976
+ * @hostTag div
977
+ * @param props.value - Current rating (0 – max). `ValueOrState<number>`, defaults to `0`.
978
+ * @param props.max - Total number of stars. Optional `number`, defaults to `5`.
979
+ * @param props.onChange - Called with the new value when the user picks a star.
980
+ * @param props.readOnly - Disable interaction. Optional `boolean`, defaults to `false`.
981
+ * @param props.color - Star color tone. Optional `ThemeColor`, defaults to `"warning"`.
982
+ * @example { div: null, $: [rating({ value: ratingState, onChange: (v) => ratingState.set(v) })] }
983
+ */
984
+ declare function rating(props?: {
985
+ value?: ValueOrState<number>;
986
+ max?: number;
987
+ onChange?: (value: number) => void;
988
+ readOnly?: boolean;
989
+ color?: ThemeColor;
990
+ }): PartialElement;
991
+
992
+ /**
993
+ * Container patch that establishes a `segmented` context for single-select navigation.
994
+ * Style: inline pill-shaped control with muted background. Use with `segmentedItem` patches on child `<button>` elements.
995
+ *
996
+ * @param props.value - Initially selected item key. Accepts a value or state. Defaults to `""`.
997
+ * @param props.color - Theme color for the control background. Defaults to `"neutral"`.
998
+ * @example { div: null, $: [segmented({ value: "month" })] }
999
+ */
1000
+ declare function segmented(props?: {
1001
+ value?: ValueOrState<string>;
1002
+ color?: ThemeColor;
1003
+ }): PartialElement;
1004
+
1005
+ /**
1006
+ * Styles and wires a single option inside a `segmented` control on the host `<button>`.
1007
+ * Sets `aria-checked` and handles click-to-select against the parent `segmented` context.
1008
+ *
1009
+ * @hostTag button
1010
+ * @param props.color - Theme color for resting state. Defaults to `"neutral"`.
1011
+ * @param props.accentColor - Theme color for selected state. Defaults to `"primary"`.
1012
+ * @example { button: "Month", $: [segmentedItem()] }
1013
+ */
1014
+ declare function segmentedItem(props?: {
1015
+ color?: ValueOrState<ThemeColor>;
1016
+ accentColor?: ValueOrState<ThemeColor>;
1017
+ }): PartialElement;
1018
+
853
1019
  /**
854
1020
  * Styles a native `<select>` control: removes the default appearance, applies themed
855
1021
  * colors, outline, density-scaled padding/radius, a custom chevron background icon, and
@@ -1004,13 +1170,41 @@ declare function splitter(props?: {
1004
1170
  declare function splitterPanel(): PartialElement;
1005
1171
  /**
1006
1172
  * 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.
1173
+ * appropriate resize cursor, and updates the context `size` state (clamped to `min`/`max`)
1174
+ * via mouse drag or keyboard: Arrow keys move by 1%, Home/End jump to min/max, hold Shift
1175
+ * for 10× step. Sets `role="separator"`, `tabindex="0"`, and `aria-value*` attributes.
1176
+ * Warns if used outside a `splitter`. Takes no props.
1009
1177
  *
1010
1178
  * @example { div: null, $: [splitterHandle()] }
1011
1179
  */
1012
1180
  declare function splitterHandle(): PartialElement;
1013
1181
 
1182
+ /**
1183
+ * Styles a single step inside a `steps` container. Sets `data-status`
1184
+ * (`"pending"` | `"active"` | `"done"`) and `aria-current="step"` on the host element
1185
+ * based on the parent `steps` context. The element's content is the step label.
1186
+ *
1187
+ * @example { li: "Shipping", $: [stepItem()] }
1188
+ */
1189
+ declare function stepItem(): PartialElement;
1190
+
1191
+ /**
1192
+ * Container patch for a step-progress indicator. Establishes `steps` context
1193
+ * with a reactive `current` index. Use with `stepItem` patches on child elements.
1194
+ *
1195
+ * @param props.current - Zero-based index of the active step. Accepts a value or state. Defaults to `0`.
1196
+ * @param props.direction - `"horizontal"` (default) or `"vertical"` layout.
1197
+ * @param props.color - Theme color for pending/track elements. Defaults to `"neutral"`.
1198
+ * @param props.accentColor - Theme color for active/completed elements. Defaults to `"primary"`.
1199
+ * @example { ol: null, $: [steps({ current: 1 })] }
1200
+ */
1201
+ declare function steps(props?: {
1202
+ current?: ValueOrState<number>;
1203
+ direction?: "horizontal" | "vertical";
1204
+ color?: ThemeColor;
1205
+ accentColor?: ThemeColor;
1206
+ }): PartialElement;
1207
+
1014
1208
  /**
1015
1209
  * Styles strongly emphasized (bold) text: inherited font size, `font-weight: 700`, and a
1016
1210
  * themed foreground color.
@@ -1127,6 +1321,30 @@ declare function textarea(props?: {
1127
1321
  autoResize?: boolean;
1128
1322
  }): PartialElement;
1129
1323
 
1324
+ /**
1325
+ * Container for a vertical timeline. Sets list reset styles. Apply to `<ol>` or `<ul>`.
1326
+ *
1327
+ * @example { ol: [...], $: [timeline()] }
1328
+ */
1329
+ declare function timeline(): PartialElement;
1330
+ /**
1331
+ * A single event row in a `timeline`. Uses a 2-column grid: the left column holds
1332
+ * a dot (`::before`) and optional connector line (`::after`); the right column holds
1333
+ * the user's content. Apply to `<li>`.
1334
+ *
1335
+ * @param props.active - Full-opacity dot (accent color). `ValueOrState<boolean>`, defaults to `false`.
1336
+ * @param props.last - Suppress the vertical connector below this item. `boolean`, defaults to `false`.
1337
+ * @param props.color - Dot/connector color tone. `ThemeColor`, defaults to `"neutral"`.
1338
+ * @param props.accentColor - Active dot color tone. `ThemeColor`, defaults to `"primary"`.
1339
+ * @example { li: [{ b: "2024" }, { p: "Event" }], $: [timelineItem({ active: true })] }
1340
+ */
1341
+ declare function timelineItem(props?: {
1342
+ active?: ValueOrState<boolean>;
1343
+ last?: boolean;
1344
+ color?: ThemeColor;
1345
+ accentColor?: ThemeColor;
1346
+ }): PartialElement;
1347
+
1130
1348
  type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
1131
1349
  /**
1132
1350
  * Renders a transient notification surface as a fixed-position overlay (portaled
@@ -1175,6 +1393,25 @@ declare function toggleGroup(props?: {
1175
1393
  color?: ThemeColor;
1176
1394
  }): PartialElement;
1177
1395
 
1396
+ /**
1397
+ * A horizontal flex row with vertically centered items. Useful for headers,
1398
+ * toolbars, navigation bars, and action strips.
1399
+ *
1400
+ * @param props.gap - Spacing multiplier for gap between items (default 4 = 1em).
1401
+ * @example { header: [...], $: [toolbar()] }
1402
+ * @example { nav: [...], $: [toolbar({ gap: 3 })] }
1403
+ */
1404
+ declare function toolbar(props?: {
1405
+ gap?: number;
1406
+ }): PartialElement;
1407
+ /**
1408
+ * A flex spacer that expands to fill available space in a toolbar, pushing
1409
+ * subsequent items to the far end.
1410
+ *
1411
+ * @example { header: [logo, toolbarSpacer(), nav, actions], $: [toolbar()] }
1412
+ */
1413
+ declare function toolbarSpacer(): DomphyElement;
1414
+
1178
1415
  /**
1179
1416
  * Attaches a floating tooltip to the host element, shown on hover/focus and
1180
1417
  * hidden on leave/blur/Escape. Returns the anchor (trigger) partial; the tooltip
@@ -1218,4 +1455,4 @@ declare function unorderedList(props?: {
1218
1455
  color?: ValueOrState<ThemeColor>;
1219
1456
  }): PartialElement;
1220
1457
 
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 };
1458
+ export { type DatePickerProps, type DatePickerValue, type MotionKeyframe, type MotionProps, abbreviation, accordion, alert, avatar, badge, blockquote, breadcrumb, breadcrumbEllipsis, button, 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 };