@xds/solid 1.0.1 → 1.2.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.
Files changed (274) hide show
  1. package/dist/dom/Accordion.js +3 -2
  2. package/dist/dom/Avatar.js +17 -13
  3. package/dist/dom/AvatarStack.js +17 -13
  4. package/dist/dom/Badge.js +12 -10
  5. package/dist/dom/Banner.js +25 -15
  6. package/dist/dom/Breadcrumb.js +87 -0
  7. package/dist/dom/Button.js +10 -3
  8. package/dist/dom/Card.js +31 -26
  9. package/dist/dom/Checkbox.js +57 -26
  10. package/dist/dom/Chip.js +21 -17
  11. package/dist/dom/ChipBar.js +17 -13
  12. package/dist/dom/Combobox.js +295 -0
  13. package/dist/dom/CountBadge.js +28 -23
  14. package/dist/dom/DatePicker.js +13 -7
  15. package/dist/dom/DateRangePicker.js +16 -10
  16. package/dist/dom/Dialog.js +3 -2
  17. package/dist/dom/Divider.js +12 -10
  18. package/dist/dom/EmptyState.js +14 -11
  19. package/dist/dom/Icon.js +30 -19
  20. package/dist/dom/IconButton.js +10 -3
  21. package/dist/dom/Labels.js +26 -0
  22. package/dist/dom/Link.js +62 -0
  23. package/dist/dom/ListRow.js +34 -28
  24. package/dist/dom/MediaCard.js +32 -23
  25. package/dist/dom/Menu.js +18 -15
  26. package/dist/dom/Pagination.js +132 -0
  27. package/dist/dom/Popover.js +126 -0
  28. package/dist/dom/ProgressBar.js +27 -15
  29. package/dist/dom/RadioGroup.js +44 -23
  30. package/dist/dom/SearchField.js +58 -32
  31. package/dist/dom/SectionHeader.js +17 -10
  32. package/dist/dom/SegmentedControl.js +33 -19
  33. package/dist/dom/Select.js +91 -51
  34. package/dist/dom/Sidebar.js +17 -13
  35. package/dist/dom/Skeleton.js +15 -13
  36. package/dist/dom/Slider.js +15 -7
  37. package/dist/dom/Spinner.js +23 -17
  38. package/dist/dom/Switch.js +49 -24
  39. package/dist/dom/Table.js +150 -0
  40. package/dist/dom/Tabs.js +16 -6
  41. package/dist/dom/Text.js +6 -3
  42. package/dist/dom/TextField.js +37 -19
  43. package/dist/dom/Thumbnail.js +21 -14
  44. package/dist/dom/TimePicker.js +245 -0
  45. package/dist/dom/Toast.js +19 -20
  46. package/dist/dom/ToastQueue.js +59 -0
  47. package/dist/dom/Tooltip.js +10 -6
  48. package/dist/dom/base.js +16 -0
  49. package/dist/dom/controllable.js +44 -0
  50. package/dist/dom/index.js +10 -1
  51. package/dist/dom/modal-popover.js +2 -2
  52. package/dist/dom/presence.js +3 -2
  53. package/dist/dom/preview.js +20 -1
  54. package/dist/dom/root.js +16 -4
  55. package/dist/dom/rows.js +13 -0
  56. package/dist/dom/trigger.js +5 -3
  57. package/dist/source/Accordion.jsx +3 -2
  58. package/dist/source/Avatar.d.ts +1 -1
  59. package/dist/source/Avatar.jsx +2 -1
  60. package/dist/source/AvatarStack.d.ts +1 -1
  61. package/dist/source/AvatarStack.jsx +2 -1
  62. package/dist/source/Badge.d.ts +1 -1
  63. package/dist/source/Badge.jsx +2 -1
  64. package/dist/source/Banner.d.ts +1 -1
  65. package/dist/source/Banner.jsx +5 -2
  66. package/dist/source/Breadcrumb.d.ts +9 -0
  67. package/dist/source/Breadcrumb.jsx +26 -0
  68. package/dist/source/Button.d.ts +5 -1
  69. package/dist/source/Button.jsx +5 -2
  70. package/dist/source/Card.d.ts +1 -1
  71. package/dist/source/Card.jsx +3 -2
  72. package/dist/source/Checkbox.d.ts +10 -4
  73. package/dist/source/Checkbox.jsx +26 -8
  74. package/dist/source/Chip.d.ts +1 -1
  75. package/dist/source/Chip.jsx +2 -1
  76. package/dist/source/ChipBar.d.ts +1 -1
  77. package/dist/source/ChipBar.jsx +2 -1
  78. package/dist/source/Combobox.d.ts +16 -0
  79. package/dist/source/Combobox.jsx +137 -0
  80. package/dist/source/CountBadge.d.ts +1 -1
  81. package/dist/source/CountBadge.jsx +3 -2
  82. package/dist/source/DatePicker.jsx +13 -7
  83. package/dist/source/DateRangePicker.jsx +16 -10
  84. package/dist/source/Dialog.jsx +3 -2
  85. package/dist/source/Divider.d.ts +1 -1
  86. package/dist/source/Divider.jsx +2 -1
  87. package/dist/source/EmptyState.d.ts +1 -1
  88. package/dist/source/EmptyState.jsx +2 -1
  89. package/dist/source/Icon.d.ts +1 -1
  90. package/dist/source/Icon.jsx +2 -1
  91. package/dist/source/IconButton.d.ts +5 -1
  92. package/dist/source/IconButton.jsx +5 -2
  93. package/dist/source/Labels.d.ts +17 -0
  94. package/dist/source/Labels.jsx +11 -0
  95. package/dist/source/Link.d.ts +20 -0
  96. package/dist/source/Link.jsx +21 -0
  97. package/dist/source/ListRow.d.ts +1 -1
  98. package/dist/source/ListRow.jsx +3 -2
  99. package/dist/source/MediaCard.d.ts +1 -1
  100. package/dist/source/MediaCard.jsx +3 -2
  101. package/dist/source/Menu.d.ts +1 -1
  102. package/dist/source/Menu.jsx +11 -3
  103. package/dist/source/Pagination.d.ts +12 -0
  104. package/dist/source/Pagination.jsx +51 -0
  105. package/dist/source/Popover.d.ts +19 -0
  106. package/dist/source/Popover.jsx +65 -0
  107. package/dist/source/ProgressBar.d.ts +1 -1
  108. package/dist/source/ProgressBar.jsx +2 -1
  109. package/dist/source/RadioGroup.d.ts +5 -2
  110. package/dist/source/RadioGroup.jsx +18 -5
  111. package/dist/source/SearchField.d.ts +11 -3
  112. package/dist/source/SearchField.jsx +26 -12
  113. package/dist/source/SectionHeader.d.ts +1 -1
  114. package/dist/source/SectionHeader.jsx +2 -1
  115. package/dist/source/SegmentedControl.d.ts +4 -3
  116. package/dist/source/SegmentedControl.jsx +16 -5
  117. package/dist/source/Select.d.ts +10 -1
  118. package/dist/source/Select.jsx +46 -11
  119. package/dist/source/Sidebar.d.ts +1 -1
  120. package/dist/source/Sidebar.jsx +2 -1
  121. package/dist/source/Skeleton.jsx +2 -2
  122. package/dist/source/Slider.d.ts +2 -2
  123. package/dist/source/Slider.jsx +14 -6
  124. package/dist/source/Spinner.d.ts +1 -1
  125. package/dist/source/Spinner.jsx +2 -1
  126. package/dist/source/Switch.d.ts +10 -4
  127. package/dist/source/Switch.jsx +18 -6
  128. package/dist/source/Table.d.ts +17 -0
  129. package/dist/source/Table.jsx +46 -0
  130. package/dist/source/Tabs.d.ts +2 -2
  131. package/dist/source/Tabs.jsx +16 -5
  132. package/dist/source/Text.d.ts +1 -1
  133. package/dist/source/Text.jsx +2 -1
  134. package/dist/source/TextField.d.ts +12 -3
  135. package/dist/source/TextField.jsx +24 -9
  136. package/dist/source/Thumbnail.d.ts +1 -1
  137. package/dist/source/Thumbnail.jsx +2 -1
  138. package/dist/source/TimePicker.d.ts +19 -0
  139. package/dist/source/TimePicker.jsx +137 -0
  140. package/dist/source/Toast.d.ts +1 -1
  141. package/dist/source/Toast.jsx +2 -1
  142. package/dist/source/ToastQueue.d.ts +19 -0
  143. package/dist/source/ToastQueue.jsx +27 -0
  144. package/dist/source/Tooltip.jsx +4 -3
  145. package/dist/source/base.d.ts +15 -0
  146. package/dist/source/base.js +15 -0
  147. package/dist/source/controllable.d.ts +30 -0
  148. package/dist/source/controllable.js +30 -0
  149. package/dist/source/index.d.ts +10 -1
  150. package/dist/source/index.js +9 -0
  151. package/dist/source/modal-popover.js +2 -2
  152. package/dist/source/presence.js +3 -2
  153. package/dist/source/preview.d.ts +10 -2
  154. package/dist/source/preview.jsx +12 -2
  155. package/dist/source/root.d.ts +14 -4
  156. package/dist/source/root.js +7 -2
  157. package/dist/source/rows.d.ts +8 -0
  158. package/dist/source/rows.js +5 -0
  159. package/dist/source/trigger.d.ts +4 -2
  160. package/dist/source/trigger.js +2 -2
  161. package/eject/files/Accordion.tsx +138 -0
  162. package/eject/files/Avatar.tsx +48 -0
  163. package/eject/files/AvatarStack.tsx +51 -0
  164. package/eject/files/Badge.tsx +39 -0
  165. package/eject/files/Banner.tsx +80 -0
  166. package/eject/files/Breadcrumb.tsx +57 -0
  167. package/eject/files/Button.tsx +90 -0
  168. package/eject/files/Card.tsx +100 -0
  169. package/eject/files/Checkbox.tsx +100 -0
  170. package/eject/files/Chip.tsx +40 -0
  171. package/eject/files/ChipBar.tsx +34 -0
  172. package/eject/files/Combobox.tsx +200 -0
  173. package/eject/files/CountBadge.tsx +55 -0
  174. package/eject/files/DatePicker.tsx +225 -0
  175. package/eject/files/DateRangePicker.tsx +319 -0
  176. package/eject/files/Dialog.tsx +117 -0
  177. package/eject/files/Divider.tsx +21 -0
  178. package/eject/files/EmptyState.tsx +39 -0
  179. package/eject/files/Icon.tsx +37 -0
  180. package/eject/files/IconButton.tsx +76 -0
  181. package/eject/files/Link.tsx +61 -0
  182. package/eject/files/ListRow.tsx +94 -0
  183. package/eject/files/MediaCard.tsx +116 -0
  184. package/eject/files/Menu.tsx +190 -0
  185. package/eject/files/Pagination.tsx +109 -0
  186. package/eject/files/Popover.tsx +124 -0
  187. package/eject/files/ProgressBar.tsx +37 -0
  188. package/eject/files/RadioGroup.tsx +138 -0
  189. package/eject/files/SearchField.tsx +124 -0
  190. package/eject/files/SectionHeader.tsx +59 -0
  191. package/eject/files/SegmentedControl.tsx +79 -0
  192. package/eject/files/Select.tsx +290 -0
  193. package/eject/files/Sidebar.tsx +156 -0
  194. package/eject/files/Skeleton.tsx +33 -0
  195. package/eject/files/Slider.tsx +131 -0
  196. package/eject/files/Spinner.tsx +44 -0
  197. package/eject/files/Switch.tsx +88 -0
  198. package/eject/files/Table.tsx +98 -0
  199. package/eject/files/Tabs.tsx +87 -0
  200. package/eject/files/Text.tsx +38 -0
  201. package/eject/files/TextField.tsx +171 -0
  202. package/eject/files/Thumbnail.tsx +84 -0
  203. package/eject/files/TimePicker.tsx +237 -0
  204. package/eject/files/Toast.tsx +100 -0
  205. package/eject/files/ToastQueue.tsx +62 -0
  206. package/eject/files/Tooltip.tsx +135 -0
  207. package/eject/files/accordion.css +89 -0
  208. package/eject/files/accordion.ts +67 -0
  209. package/eject/files/avatar-stack.ts +57 -0
  210. package/eject/files/avatar.ts +42 -0
  211. package/eject/files/badge.ts +30 -0
  212. package/eject/files/banner.ts +71 -0
  213. package/eject/files/base.css +38 -0
  214. package/eject/files/breadcrumb.css +51 -0
  215. package/eject/files/breadcrumb.ts +42 -0
  216. package/eject/files/button.css +241 -0
  217. package/eject/files/button.ts +106 -0
  218. package/eject/files/card.ts +58 -0
  219. package/eject/files/checkbox.ts +52 -0
  220. package/eject/files/chip-bar.ts +16 -0
  221. package/eject/files/chip.ts +35 -0
  222. package/eject/files/combobox.css +269 -0
  223. package/eject/files/combobox.ts +85 -0
  224. package/eject/files/count-badge.ts +32 -0
  225. package/eject/files/date-picker.css +375 -0
  226. package/eject/files/date-picker.ts +280 -0
  227. package/eject/files/date-range-picker.ts +338 -0
  228. package/eject/files/dialog.css +139 -0
  229. package/eject/files/dialog.ts +15 -0
  230. package/eject/files/divider.ts +5 -0
  231. package/eject/files/empty-state.ts +22 -0
  232. package/eject/files/icon.ts +36 -0
  233. package/eject/files/link.css +64 -0
  234. package/eject/files/link.ts +63 -0
  235. package/eject/files/list-row.ts +66 -0
  236. package/eject/files/media-card.ts +66 -0
  237. package/eject/files/menu.css +192 -0
  238. package/eject/files/menu.ts +84 -0
  239. package/eject/files/overlay.css +40 -0
  240. package/eject/files/pagination.css +106 -0
  241. package/eject/files/pagination.ts +68 -0
  242. package/eject/files/parts.ts +17 -0
  243. package/eject/files/popover.css +101 -0
  244. package/eject/files/popover.ts +37 -0
  245. package/eject/files/progress-bar.ts +26 -0
  246. package/eject/files/radio-group.css +184 -0
  247. package/eject/files/radio-group.ts +30 -0
  248. package/eject/files/section-header.ts +32 -0
  249. package/eject/files/segmented-control.ts +33 -0
  250. package/eject/files/select.css +347 -0
  251. package/eject/files/select.ts +77 -0
  252. package/eject/files/sidebar.ts +75 -0
  253. package/eject/files/skeleton.ts +51 -0
  254. package/eject/files/slider.css +160 -0
  255. package/eject/files/slider.ts +80 -0
  256. package/eject/files/spinner.ts +22 -0
  257. package/eject/files/switch.ts +45 -0
  258. package/eject/files/table.css +107 -0
  259. package/eject/files/table.ts +84 -0
  260. package/eject/files/tabs.css +120 -0
  261. package/eject/files/tabs.ts +37 -0
  262. package/eject/files/text-field.css +225 -0
  263. package/eject/files/text-field.ts +64 -0
  264. package/eject/files/text.ts +38 -0
  265. package/eject/files/thumbnail.ts +51 -0
  266. package/eject/files/time-picker.ts +113 -0
  267. package/eject/files/toast-queue.ts +64 -0
  268. package/eject/files/toast.ts +31 -0
  269. package/eject/files/tooltip.css +111 -0
  270. package/eject/files/tooltip.ts +21 -0
  271. package/eject/manifest.json +1027 -0
  272. package/package.json +12 -4
  273. package/styles.css +1066 -167
  274. package/tailwind.css +1295 -218
@@ -0,0 +1,137 @@
1
+ import { space } from "@xds/tokens";
2
+ import { classes, isControlled, keepListKeys, readCssPx, timeOptions, timePickerIds, timePickerLocale, underlayLayerStyle, } from "@xds/core";
3
+ import * as select from "@zag-js/select";
4
+ import { mergeProps, normalizeProps, useMachine } from "@zag-js/solid";
5
+ import { createMemo, createUniqueId, For, Show } from "solid-js";
6
+ import { createControllable, resetWithForm } from "./controllable.js";
7
+ import { Icon } from "./Icon.jsx";
8
+ import { modalPopover } from "./modal-popover.js";
9
+ import { Portal } from "./portal.jsx";
10
+ import { createPresence } from "./presence.js";
11
+ import { rootAttributes, withStyle } from "./root.js";
12
+ import { createItemProps } from "./rows.js";
13
+ export function TimePicker(props) {
14
+ const id = createUniqueId();
15
+ const ids = timePickerIds(id);
16
+ const invalid = () => props.error !== undefined;
17
+ const controlled = () => isControlled(props, "value");
18
+ const value = createControllable({
19
+ controlled,
20
+ value: () => props.value,
21
+ defaultValue: () => props.defaultValue,
22
+ onChange: (next) => {
23
+ if (next !== undefined)
24
+ props.onChange?.(next);
25
+ },
26
+ });
27
+ let element;
28
+ resetWithForm(() => element, controlled, value.reset);
29
+ const options = createMemo(() => timeOptions({ min: props.min, max: props.max, step: props.step, value: value.value() }, timePickerLocale(props.locale)));
30
+ const collection = createMemo(() => select.collection({
31
+ items: options(),
32
+ itemToValue: (option) => option.value,
33
+ itemToString: (option) => option.label,
34
+ }));
35
+ const service = useMachine(select.machine, () => ({
36
+ id,
37
+ ids: { root: props.id },
38
+ collection: collection(),
39
+ value: value.value() === undefined ? [] : [value.value()],
40
+ onValueChange: (details) => {
41
+ const next = details.value[0];
42
+ if (next !== undefined)
43
+ value.set(next);
44
+ },
45
+ disabled: props.disabled,
46
+ invalid: invalid(),
47
+ positioning: {
48
+ placement: "bottom-start",
49
+ gutter: readCssPx(null, "--xds-space-1", space[1]),
50
+ sameWidth: true,
51
+ overflowPadding: readCssPx(null, "--xds-space-3", space[3]),
52
+ },
53
+ }));
54
+ const api = createMemo(() => select.connect(service, normalizeProps));
55
+ const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
56
+ const current = () => select.connect(service, normalizeProps);
57
+ const labelProps = createMemo(() => {
58
+ const { for: _, ...rest } = api().getLabelProps();
59
+ return rest;
60
+ });
61
+ const triggerProps = createMemo(() => {
62
+ const { role: _role, "aria-invalid": _invalid, "aria-required": _required, onKeyDown: _onKeyDown, ...rest } = api().getTriggerProps();
63
+ return {
64
+ ...rest,
65
+ onKeyDown: (event) => {
66
+ if (!api().open && (event.key === "Home" || event.key === "End"))
67
+ return;
68
+ current().getTriggerProps().onKeyDown?.(event);
69
+ },
70
+ };
71
+ });
72
+ let positioner;
73
+ let surface;
74
+ modalPopover(() => api().open, () => positioner);
75
+ const present = createPresence(() => api().open, () => [surface]);
76
+ const content = mergeProps(() => {
77
+ const { onKeyDown: _onKeyDown, ...rest } = api().getContentProps();
78
+ return rest;
79
+ }, {
80
+ onKeyDown: (event) => {
81
+ keepListKeys(event, surface, ".xds-time-picker__item:not([data-disabled])", (value) => api().setHighlightedValue(value));
82
+ current().getContentProps().onKeyDown?.(event);
83
+ },
84
+ });
85
+ return (<div {...root} ref={(node) => (element = node)} class={classes("xds-time-picker", props.class)}>
86
+ <span {...labelProps()} class="xds-time-picker__label">
87
+ {props.label}
88
+ </span>
89
+ <button {...triggerProps()} aria-labelledby={`${ids.value} ${labelProps().id}`} aria-describedby={invalid() ? ids.error : props.description ? ids.description : undefined} class="xds-time-picker__trigger">
90
+ <span {...api().getValueTextProps()} id={ids.value} class="xds-time-picker__value">
91
+ {api().valueAsString || props.placeholder}
92
+ </span>
93
+ <Icon name="clock" size="sm" class="text-xds-field-placeholder"/>
94
+ </button>
95
+ <div class="xds-time-picker__footer">
96
+ <Show when={!invalid() && props.description}>
97
+ <span id={ids.description} class="xds-time-picker__description">
98
+ {props.description}
99
+ </span>
100
+ </Show>
101
+ <span id={ids.error} class="xds-time-picker__error" aria-live="polite">
102
+ {props.error}
103
+ </span>
104
+ </div>
105
+
106
+ <input type="hidden" name={props.name} value={value.value() ?? ""}/>
107
+ <Portal>
108
+ <Show when={api().open}>
109
+
110
+ <div class="xds-time-picker__underlay" style={underlayLayerStyle(api().getPositionerProps().style)} onMouseDown={(event) => event.preventDefault()}/>
111
+ </Show>
112
+ <div ref={(element) => (positioner = element)} {...api().getPositionerProps()} class="xds-time-picker__positioner">
113
+ <div {...content} ref={(element) => (surface = element)} hidden={!present()} class="xds-time-picker__content">
114
+ <div {...api().getListProps()} class="xds-time-picker__list">
115
+ <For each={collection().items}>
116
+ {(option) => {
117
+ const itemProps = createItemProps(() => api().getItemProps({ item: option }));
118
+ const textProps = createItemProps(() => api().getItemTextProps({ item: option }));
119
+ const selected = createMemo(() => api().getItemState({ item: option }).selected);
120
+ return (<div {...itemProps()} class="xds-time-picker__item">
121
+ <span class="xds-time-picker__item-words">
122
+ <span {...textProps()} class="xds-time-picker__item-label">
123
+ {option.label}
124
+ </span>
125
+ </span>
126
+ <Show when={selected()}>
127
+ <Icon name="check" size="sm"/>
128
+ </Show>
129
+ </div>);
130
+ }}
131
+ </For>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ </Portal>
136
+ </div>);
137
+ }
@@ -1,5 +1,5 @@
1
1
  import { type ToastBaseProps } from "@xds/core";
2
- import type { RootProps } from "./root.ts";
2
+ import { type RootProps } from "./root.ts";
3
3
  export type ToastProps = ToastBaseProps & RootProps & {
4
4
  /** Called when the time is up and after the action. Set `open` to false in it. */
5
5
  onClose: () => void;
@@ -1,6 +1,7 @@
1
1
  import { motion } from "@xds/tokens";
2
2
  import { classes, readCssMs, rootPart, TOAST_PARTS } from "@xds/core";
3
3
  import { createEffect, createSignal, onSettled, Show } from "solid-js";
4
+ import { rootAttributes } from "./root.js";
4
5
  const ROOT = rootPart("Toast");
5
6
  export function Toast(props) {
6
7
  let region;
@@ -31,7 +32,7 @@ export function Toast(props) {
31
32
  return (<div ref={(element) => (region = element)} role="status" popover="manual" class={TOAST_PARTS.region}>
32
33
  <Show when={props.open}>
33
34
 
34
- <div onPointerEnter={(event) => setHovered(event.currentTarget)} onPointerLeave={() => setHovered(undefined)} onFocusIn={(event) => setFocused(event.currentTarget)} onFocusOut={() => setFocused(undefined)} class={classes(ROOT, TOAST_PARTS.toast, props.class)} style={props.style}>
35
+ <div {...rootAttributes(props)} onPointerEnter={(event) => setHovered(event.currentTarget)} onPointerLeave={() => setHovered(undefined)} onFocusIn={(event) => setFocused(event.currentTarget)} onFocusOut={() => setFocused(undefined)} class={classes(ROOT, TOAST_PARTS.toast, props.class)} style={props.style}>
35
36
  <span class={TOAST_PARTS.message}>{props.message}</span>
36
37
  <Show when={props.action}>
37
38
  {(action) => (<button type="button" onClick={() => {
@@ -0,0 +1,19 @@
1
+ import { type QueuedToast, type ToastQueueBaseProps } from "@xds/core";
2
+ import { type RootProps } from "./root.ts";
3
+ export { type QueuedToast, queueToast } from "@xds/core";
4
+ /** `class`, `style`, `id` and `data-*` go on the toast shown, as Toast takes them. */
5
+ export type ToastQueueProps = ToastQueueBaseProps & RootProps & {
6
+ /**
7
+ * Called with a toast's id when its time is up or its action was taken. Take it out of
8
+ * `toasts` in it.
9
+ */
10
+ onClose: (id: QueuedToast["id"]) => void;
11
+ };
12
+ /**
13
+ * Shows the app's toasts one at a time, in their order: the first of `toasts`, which stays for
14
+ * its own `duration` or until its action is taken, and then the next, `motion.duration.normal`
15
+ * after the one before has gone, so that each is read and announced as a message of its own.
16
+ * Add a toast with `queueToast`, which keeps at most three waiting, and take one out in
17
+ * `onClose`. Put one where a single Toast would go.
18
+ */
19
+ export declare function ToastQueue(props: ToastQueueProps): import("@solidjs/web").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { motion } from "@xds/tokens";
2
+ import { readCssMs, toastQueueStep, } from "@xds/core";
3
+ import { createEffect, createMemo, createSignal } from "solid-js";
4
+ import { rootAttributes } from "./root.js";
5
+ import { Toast } from "./Toast.jsx";
6
+ export { queueToast } from "@xds/core";
7
+ export function ToastQueue(props) {
8
+ const [visible, setVisible] = createSignal(undefined);
9
+ const step = createMemo(() => toastQueueStep(props.toasts, visible()));
10
+ const shown = () => (step() === "keep" ? props.toasts[0] : undefined);
11
+ createEffect(() => ({ step: step(), first: props.toasts[0] }), ({ step, first }) => {
12
+ if (step === "close") {
13
+ setVisible(undefined);
14
+ return undefined;
15
+ }
16
+ if (step !== "wait" || first === undefined)
17
+ return undefined;
18
+ const gap = readCssMs(null, "--xds-motion-duration-normal", motion.duration.normal);
19
+ const timer = setTimeout(() => setVisible(() => first.id), gap);
20
+ return () => clearTimeout(timer);
21
+ });
22
+ return (<Toast {...rootAttributes(props)} class={props.class} style={props.style} open={shown() !== undefined} message={shown()?.message ?? ""} action={shown()?.action} duration={shown()?.duration} onClose={() => {
23
+ const toast = shown();
24
+ if (toast !== undefined)
25
+ props.onClose(toast.id);
26
+ }}/>);
27
+ }
@@ -5,10 +5,10 @@ import * as tooltip from "@zag-js/tooltip";
5
5
  import { createMemo, createUniqueId, Show } from "solid-js";
6
6
  import { Portal } from "./portal.jsx";
7
7
  import { createPresence } from "./presence.js";
8
- import { withStyle } from "./root.js";
8
+ import { rootAttributes, withStyle } from "./root.js";
9
9
  import { provideTrigger, TriggerContext } from "./trigger.js";
10
10
  export function Tooltip(props) {
11
- return (<Overlay label={props.label} shortcut={props.shortcut} placement={() => props.placement ?? "top"} class={props.class} style={props.style}>
11
+ return (<Overlay label={props.label} shortcut={props.shortcut} placement={() => props.placement ?? "top"} {...rootAttributes(props)} class={props.class} style={props.style}>
12
12
  {props.children}
13
13
  </Overlay>);
14
14
  }
@@ -21,6 +21,7 @@ function Overlay(props) {
21
21
  const id = createUniqueId();
22
22
  const service = useMachine(tooltip.machine, () => ({
23
23
  id,
24
+ ids: { content: props.id },
24
25
  openDelay: readCssMs(null, "--xds-motion-duration-tooltip-delay", motion.duration.tooltipDelay),
25
26
  closeDelay: 0,
26
27
  closeOnScroll: false,
@@ -31,7 +32,7 @@ function Overlay(props) {
31
32
  }));
32
33
  const api = createMemo(() => tooltip.connect(service, normalizeProps));
33
34
  const trigger = provideTrigger(() => api().getTriggerProps());
34
- const contentProps = withStyle(() => api().getContentProps(), () => props.style);
35
+ const contentProps = withStyle(() => api().getContentProps(), () => props.style, rootAttributes(props));
35
36
  let content;
36
37
  const present = createPresence(() => api().open, () => [content]);
37
38
  return (<>
@@ -0,0 +1,15 @@
1
+ export { useDefaults } from "./Defaults.tsx";
2
+ export { useLabels } from "./Labels.tsx";
3
+ export { PlaceRow } from "./ListRow.tsx";
4
+ export { TooltipBeside } from "./Tooltip.tsx";
5
+ export { composeRefs, createControllable, resetWithForm } from "./controllable.ts";
6
+ export { keepChecked, keepValue } from "./controlled.ts";
7
+ export { modalPopover } from "./modal-popover.ts";
8
+ export { createPicture } from "./picture.ts";
9
+ export { Portal } from "./portal.tsx";
10
+ export { createPresence } from "./presence.ts";
11
+ export { layStyle, type RootProps, rootAttributes, withStyle } from "./root.ts";
12
+ export { createItemProps } from "./rows.ts";
13
+ export { provideTrigger, TriggerContext, type TriggerProps, withTrigger } from "./trigger.ts";
14
+ export { type IconName, icons, motion, space } from "@xds/tokens";
15
+ export { AVATAR_SIZE, type AvatarSize, afterAnimations, buttonClass, type ComponentLabels, DEFAULT_LABELS, focusWithoutRing, type IconSize, initials, isControlled, keepListKeys, leaveEscapeToFields, PEER_FOCUS, PRESSABLE_ROW, pictureClass, readCssMs, readCssPx, type SelectOption, selectOptionIds, switchClass, switchLabelClass, type ThumbnailRatio, type ToastAction, underlayLayerStyle, } from "@xds/core";
@@ -0,0 +1,15 @@
1
+ export { useDefaults } from "./Defaults.jsx";
2
+ export { useLabels } from "./Labels.jsx";
3
+ export { PlaceRow } from "./ListRow.jsx";
4
+ export { TooltipBeside } from "./Tooltip.jsx";
5
+ export { composeRefs, createControllable, resetWithForm } from "./controllable.js";
6
+ export { keepChecked, keepValue } from "./controlled.js";
7
+ export { modalPopover } from "./modal-popover.js";
8
+ export { createPicture } from "./picture.js";
9
+ export { Portal } from "./portal.jsx";
10
+ export { createPresence } from "./presence.js";
11
+ export { layStyle, rootAttributes, withStyle } from "./root.js";
12
+ export { createItemProps } from "./rows.js";
13
+ export { provideTrigger, TriggerContext, withTrigger } from "./trigger.js";
14
+ export { icons, motion, space } from "@xds/tokens";
15
+ export { AVATAR_SIZE, afterAnimations, buttonClass, DEFAULT_LABELS, focusWithoutRing, initials, isControlled, keepListKeys, leaveEscapeToFields, PEER_FOCUS, PRESSABLE_ROW, pictureClass, readCssMs, readCssPx, selectOptionIds, switchClass, switchLabelClass, underlayLayerStyle, } from "@xds/core";
@@ -0,0 +1,30 @@
1
+ import type { JSX } from "@solidjs/web";
2
+ import { type Accessor } from "solid-js";
3
+ /**
4
+ * The state of a control that the app may keep or leave to it. It is the app's while the app
5
+ * gives the prop (`controlled`, from `isControlled`), and the control's own otherwise, from
6
+ * `defaultValue`. Either way a change goes to `onChange`, read when the change comes. The state
7
+ * is a plain value, never a function, which a signal would take for an update.
8
+ */
9
+ export declare function createControllable<T extends string | number | boolean | undefined | readonly string[]>(options: {
10
+ controlled: Accessor<boolean>;
11
+ value: Accessor<T>;
12
+ defaultValue: Accessor<T>;
13
+ onChange: (value: T) => void;
14
+ }): {
15
+ value: Accessor<T>;
16
+ set: (next: T) => void;
17
+ reset: () => void;
18
+ };
19
+ /**
20
+ * Sets a control that keeps its own state back to its default when its form is reset, as the
21
+ * form sets the native field back. A controlled one shows what its owner gives it, whatever the
22
+ * form does.
23
+ */
24
+ export declare function resetWithForm(element: () => Element | undefined, controlled: Accessor<boolean>, reset: () => void): void;
25
+ /**
26
+ * One ref from the component's own and the one the app gives (`ref`, read when the element is
27
+ * made), which reaches the native input or button. Solid hands a component a ref the app
28
+ * writes as a variable as a function that sets it.
29
+ */
30
+ export declare function composeRefs<T>(own: (element: T) => void, ref: () => JSX.Ref<T> | undefined): (element: T) => void;
@@ -0,0 +1,30 @@
1
+ import { onFormReset } from "@xds/core";
2
+ import { createEffect, createSignal, untrack } from "solid-js";
3
+ export function createControllable(options) {
4
+ const [own, setOwn] = createSignal(untrack(options.defaultValue));
5
+ return {
6
+ value: () => (options.controlled() ? options.value() : own()),
7
+ set: (next) => {
8
+ if (!untrack(options.controlled))
9
+ setOwn(() => next);
10
+ options.onChange(next);
11
+ },
12
+ reset: () => setOwn(() => untrack(options.defaultValue)),
13
+ };
14
+ }
15
+ export function resetWithForm(element, controlled, reset) {
16
+ createEffect(controlled, (isControlled) => isControlled ? undefined : onFormReset(element(), reset));
17
+ }
18
+ export function composeRefs(own, ref) {
19
+ return (element) => {
20
+ own(element);
21
+ apply(ref(), element);
22
+ };
23
+ }
24
+ function apply(ref, element) {
25
+ if (typeof ref === "function")
26
+ ref(element);
27
+ else if (Array.isArray(ref))
28
+ for (const each of ref)
29
+ apply(each, element);
30
+ }
@@ -1,14 +1,15 @@
1
- export type { IconName, IconSize, TextTone, TextVariant } from "@xds/core";
2
1
  export { Accordion, type AccordionItem, type AccordionProps } from "./Accordion.tsx";
3
2
  export { Avatar, type AvatarProps, type AvatarSize } from "./Avatar.tsx";
4
3
  export { AvatarStack, type AvatarStackProps } from "./AvatarStack.tsx";
5
4
  export { Badge, type BadgeProps, type BadgeTone } from "./Badge.tsx";
6
5
  export { Banner, type BannerProps, type BannerTone } from "./Banner.tsx";
6
+ export { Breadcrumb, type BreadcrumbItem, type BreadcrumbProps } from "./Breadcrumb.tsx";
7
7
  export { Button, type ButtonProps, type ButtonVariant, type ControlSize } from "./Button.tsx";
8
8
  export { Card, type CardProps } from "./Card.tsx";
9
9
  export { Checkbox, type CheckboxProps } from "./Checkbox.tsx";
10
10
  export { Chip, type ChipProps } from "./Chip.tsx";
11
11
  export { ChipBar, type ChipBarProps } from "./ChipBar.tsx";
12
+ export { Combobox, type ComboboxProps } from "./Combobox.tsx";
12
13
  export { CountBadge, type CountBadgeProps } from "./CountBadge.tsx";
13
14
  export { DatePicker, type DatePickerProps, type IsoDate } from "./DatePicker.tsx";
14
15
  export { type DateRange, DateRangePicker, type DateRangePickerProps } from "./DateRangePicker.tsx";
@@ -18,9 +19,13 @@ export { Divider, type DividerProps } from "./Divider.tsx";
18
19
  export { EmptyState, type EmptyStateProps } from "./EmptyState.tsx";
19
20
  export { Icon, type IconProps } from "./Icon.tsx";
20
21
  export { IconButton, type IconButtonProps } from "./IconButton.tsx";
22
+ export { type ComponentLabels, Labels, type LabelsProps } from "./Labels.tsx";
23
+ export { Link, type LinkProps } from "./Link.tsx";
21
24
  export { ListRow, type ListRowProps } from "./ListRow.tsx";
22
25
  export { MediaCard, type MediaCardProps } from "./MediaCard.tsx";
23
26
  export { Menu, type MenuItem, type MenuProps } from "./Menu.tsx";
27
+ export { Pagination, type PaginationProps } from "./Pagination.tsx";
28
+ export { Popover, type PopoverProps } from "./Popover.tsx";
24
29
  export { ProgressBar, type ProgressBarProps } from "./ProgressBar.tsx";
25
30
  export { RadioGroup, type RadioGroupProps, type RadioOption } from "./RadioGroup.tsx";
26
31
  export { SearchField, type SearchFieldProps } from "./SearchField.tsx";
@@ -32,9 +37,13 @@ export { Skeleton, type SkeletonProps } from "./Skeleton.tsx";
32
37
  export { Slider, type SliderProps } from "./Slider.tsx";
33
38
  export { Spinner, type SpinnerProps } from "./Spinner.tsx";
34
39
  export { Switch, type SwitchProps } from "./Switch.tsx";
40
+ export { type SortDirection, Table, type TableColumn, type TableProps, type TableRow, type TableSort, } from "./Table.tsx";
35
41
  export { Tabs, type TabsProps } from "./Tabs.tsx";
36
42
  export { Text, type TextProps } from "./Text.tsx";
37
43
  export { TextField, type TextFieldProps } from "./TextField.tsx";
38
44
  export { Thumbnail, type ThumbnailProps, type ThumbnailRatio } from "./Thumbnail.tsx";
45
+ export { type IsoTime, TimePicker, type TimePickerProps } from "./TimePicker.tsx";
39
46
  export { Toast, type ToastProps } from "./Toast.tsx";
47
+ export { type QueuedToast, queueToast, ToastQueue, type ToastQueueProps } from "./ToastQueue.tsx";
40
48
  export { Tooltip, type TooltipProps } from "./Tooltip.tsx";
49
+ export type { IconName, IconSize, TextTone, TextVariant } from "@xds/core";
@@ -3,11 +3,13 @@ export { Avatar } from "./Avatar.jsx";
3
3
  export { AvatarStack } from "./AvatarStack.jsx";
4
4
  export { Badge } from "./Badge.jsx";
5
5
  export { Banner } from "./Banner.jsx";
6
+ export { Breadcrumb } from "./Breadcrumb.jsx";
6
7
  export { Button } from "./Button.jsx";
7
8
  export { Card } from "./Card.jsx";
8
9
  export { Checkbox } from "./Checkbox.jsx";
9
10
  export { Chip } from "./Chip.jsx";
10
11
  export { ChipBar } from "./ChipBar.jsx";
12
+ export { Combobox } from "./Combobox.jsx";
11
13
  export { CountBadge } from "./CountBadge.jsx";
12
14
  export { DatePicker } from "./DatePicker.jsx";
13
15
  export { DateRangePicker } from "./DateRangePicker.jsx";
@@ -17,9 +19,13 @@ export { Divider } from "./Divider.jsx";
17
19
  export { EmptyState } from "./EmptyState.jsx";
18
20
  export { Icon } from "./Icon.jsx";
19
21
  export { IconButton } from "./IconButton.jsx";
22
+ export { Labels } from "./Labels.jsx";
23
+ export { Link } from "./Link.jsx";
20
24
  export { ListRow } from "./ListRow.jsx";
21
25
  export { MediaCard } from "./MediaCard.jsx";
22
26
  export { Menu } from "./Menu.jsx";
27
+ export { Pagination } from "./Pagination.jsx";
28
+ export { Popover } from "./Popover.jsx";
23
29
  export { ProgressBar } from "./ProgressBar.jsx";
24
30
  export { RadioGroup } from "./RadioGroup.jsx";
25
31
  export { SearchField } from "./SearchField.jsx";
@@ -31,9 +37,12 @@ export { Skeleton } from "./Skeleton.jsx";
31
37
  export { Slider } from "./Slider.jsx";
32
38
  export { Spinner } from "./Spinner.jsx";
33
39
  export { Switch } from "./Switch.jsx";
40
+ export { Table, } from "./Table.jsx";
34
41
  export { Tabs } from "./Tabs.jsx";
35
42
  export { Text } from "./Text.jsx";
36
43
  export { TextField } from "./TextField.jsx";
37
44
  export { Thumbnail } from "./Thumbnail.jsx";
45
+ export { TimePicker } from "./TimePicker.jsx";
38
46
  export { Toast } from "./Toast.jsx";
47
+ export { queueToast, ToastQueue } from "./ToastQueue.jsx";
39
48
  export { Tooltip } from "./Tooltip.jsx";
@@ -1,8 +1,8 @@
1
1
  import { ariaHidden } from "@zag-js/aria-hidden";
2
2
  import { preventBodyScroll } from "@zag-js/remove-scroll";
3
- import { createEffect } from "solid-js";
3
+ import { createEffect, createMemo } from "solid-js";
4
4
  export function modalPopover(open, popup) {
5
- createEffect(open, (isOpen) => {
5
+ createEffect(createMemo(open), (isOpen) => {
6
6
  if (!isOpen)
7
7
  return;
8
8
  const unlock = preventBodyScroll(document);
@@ -2,12 +2,13 @@ import { afterAnimations } from "@xds/core";
2
2
  import { createEffect, createMemo, createSignal } from "solid-js";
3
3
  export function createPresence(open, parts) {
4
4
  const [exited, setExited] = createSignal(true);
5
- createEffect(open, (isOpen) => {
5
+ const isOpen = createMemo(open);
6
+ createEffect(isOpen, (isOpen) => {
6
7
  if (isOpen) {
7
8
  setExited(false);
8
9
  return;
9
10
  }
10
11
  return afterAnimations(parts(), () => setExited(true));
11
12
  });
12
- return createMemo(() => open() || !exited());
13
+ return createMemo(() => isOpen() || !exited());
13
14
  }
@@ -1,6 +1,14 @@
1
- import { type Screen } from "@xds/core/preview";
2
- import { type Element } from "solid-js";
1
+ import { type ComponentName, type Components, type Screen } from "@xds/core/preview";
2
+ import { type Component, type Element } from "solid-js";
3
3
  export { designPreview } from "@xds/core/preview";
4
+ /**
5
+ * Components to draw in place of the library's, by name: an app's ejected copies (`xds eject`),
6
+ * which the design preview then shows as it shows the library's.
7
+ */
8
+ export type PreviewComponents = {
9
+ [N in ComponentName]?: Component<Components<Element>[N]>;
10
+ };
4
11
  export declare function Preview(props: {
5
12
  screen: Screen;
13
+ components?: PreviewComponents;
6
14
  }): Element;
@@ -1,7 +1,7 @@
1
1
  import { isNode, isStatic, resolve, } from "@xds/core/preview";
2
2
  import { dynamic, memo } from "@solidjs/web";
3
3
  import { createComponent, createSignal, onSettled, Show, untrack, } from "solid-js";
4
- import { Accordion, Avatar, AvatarStack, Badge, Banner, Button, Card, Checkbox, Chip, ChipBar, CountBadge, DatePicker, DateRangePicker, Defaults, Dialog, Divider, EmptyState, Icon, IconButton, ListRow, MediaCard, Menu, ProgressBar, RadioGroup, SearchField, SectionHeader, SegmentedControl, Select, Sidebar, Skeleton, Slider, Spinner, Switch, Tabs, Text, TextField, Thumbnail, Toast, Tooltip, } from "./index.js";
4
+ import { Accordion, Avatar, AvatarStack, Badge, Banner, Breadcrumb, Button, Card, Checkbox, Chip, ChipBar, Combobox, CountBadge, DatePicker, DateRangePicker, Defaults, Dialog, Divider, EmptyState, Icon, IconButton, Labels, Link, ListRow, MediaCard, Menu, Pagination, Popover, ProgressBar, RadioGroup, SearchField, SectionHeader, SegmentedControl, Select, Sidebar, Skeleton, Slider, Spinner, Switch, Table, Tabs, Text, TextField, Thumbnail, TimePicker, Toast, ToastQueue, Tooltip, } from "./index.js";
5
5
  export { designPreview } from "@xds/core/preview";
6
6
  const COMPONENTS = {
7
7
  Accordion,
@@ -9,11 +9,13 @@ const COMPONENTS = {
9
9
  AvatarStack,
10
10
  Badge,
11
11
  Banner,
12
+ Breadcrumb,
12
13
  Button,
13
14
  Card,
14
15
  Checkbox,
15
16
  Chip,
16
17
  ChipBar,
18
+ Combobox,
17
19
  CountBadge,
18
20
  DatePicker,
19
21
  DateRangePicker,
@@ -23,9 +25,13 @@ const COMPONENTS = {
23
25
  EmptyState,
24
26
  Icon,
25
27
  IconButton,
28
+ Labels,
29
+ Link,
26
30
  ListRow,
27
31
  MediaCard,
28
32
  Menu,
33
+ Pagination,
34
+ Popover,
29
35
  ProgressBar,
30
36
  RadioGroup,
31
37
  SearchField,
@@ -37,16 +43,20 @@ const COMPONENTS = {
37
43
  Slider,
38
44
  Spinner,
39
45
  Switch,
46
+ Table,
40
47
  Tabs,
41
48
  Text,
42
49
  TextField,
43
50
  Thumbnail,
51
+ TimePicker,
44
52
  Toast,
53
+ ToastQueue,
45
54
  Tooltip,
46
55
  };
47
56
  const _lacking = {};
48
57
  export function Preview(props) {
49
58
  const screen = untrack(() => props.screen);
59
+ const components = untrack(() => props.components);
50
60
  const state = {};
51
61
  const writes = new Map();
52
62
  for (const [key, first] of Object.entries(screen.state)) {
@@ -83,7 +93,7 @@ export function Preview(props) {
83
93
  }
84
94
  const type = slot.kind === "element"
85
95
  ? dynamic(() => slot.tag, { static: true })
86
- : COMPONENTS[slot.name];
96
+ : (components?.[slot.name] ?? COMPONENTS[slot.name]);
87
97
  return createComponent(type, propsOf(slot));
88
98
  },
89
99
  };
@@ -1,14 +1,23 @@
1
+ import type { RootAttributes } from "@xds/core";
1
2
  import type { JSX } from "@solidjs/web";
2
3
  /**
3
4
  * What every component takes for its root element, beside its root part (`xds-<name>`): the
4
- * app's own handle on it.
5
+ * app's own handle on it. Its root is its outermost element, or the surface of an overlay. An
6
+ * `id` and `data-*` attributes, such as a test's `data-testid`, go on it too.
5
7
  */
6
- export type RootProps = {
8
+ export type RootProps = RootAttributes & {
7
9
  /** Added to the classes of the component's root element. */
8
10
  class?: string;
9
11
  /** Inline style on the component's root element, laid over any it sets itself. */
10
12
  style?: JSX.CSSProperties | string;
11
13
  };
14
+ /**
15
+ * The `id` and `data-*` attributes among a component's props, to spread on its root element.
16
+ * A live view rather than ui-core's `rootAttributes`, which copies the values: an attribute
17
+ * whose prop changes follows it, and one the app leaves out is not in it, so it overrides
18
+ * nothing it is spread before.
19
+ */
20
+ export declare function rootAttributes(props: RootAttributes): RootAttributes;
12
21
  type Style = JSX.CSSProperties | string | undefined;
13
22
  /**
14
23
  * The style of a root element that sets one of its own: the app's comes after it, so that it
@@ -19,7 +28,8 @@ export declare function layStyle(own: Style, app: Style): Style;
19
28
  /**
20
29
  * The props Zag gives a component's root element, with the app's style laid over the one Zag
21
30
  * sets: Zag's mergeProps merges the two, where a `style` after the spread would replace Zag's.
22
- * Spread the result on the element.
31
+ * The app's root attributes win over Zag's, so give the machine the app's `id` for the part
32
+ * too (`ids`), which is how Zag finds it. Spread the result on the element.
23
33
  */
24
- export declare function withStyle<T extends object>(zag: () => T, style: () => Style): T;
34
+ export declare function withStyle<T extends object>(zag: () => T, style: () => Style, attributes?: RootAttributes): T;
25
35
  export {};
@@ -1,4 +1,9 @@
1
1
  import { mergeProps } from "@zag-js/solid";
2
+ import { omit } from "solid-js";
3
+ const isRootAttribute = (key) => key === "id" || (typeof key === "string" && key.startsWith("data-"));
4
+ export function rootAttributes(props) {
5
+ return omit(props, (key) => !isRootAttribute(key));
6
+ }
2
7
  const css = (style) => typeof style === "string"
3
8
  ? style
4
9
  : Object.entries(style)
@@ -14,6 +19,6 @@ export function layStyle(own, app) {
14
19
  return `${css(own)};${css(app)}`;
15
20
  return { ...own, ...app };
16
21
  }
17
- export function withStyle(zag, style) {
18
- return mergeProps(zag, () => ({ style: style() }));
22
+ export function withStyle(zag, style, attributes = {}) {
23
+ return mergeProps(zag, attributes, () => ({ style: style() }));
19
24
  }
@@ -0,0 +1,8 @@
1
+ import { type Accessor } from "solid-js";
2
+ /**
3
+ * The props a machine gives one row's part, followed only while they draw something else
4
+ * (`sameItemProps`). Read through `api()`, a row's props are made anew on every change to the
5
+ * machine, and each row's spread would set its attributes and its handlers again; this way a
6
+ * step of the highlight sets them on the two rows it moves between.
7
+ */
8
+ export declare function createItemProps<T extends object>(props: () => T): Accessor<T>;
@@ -0,0 +1,5 @@
1
+ import { sameItemProps } from "@xds/core";
2
+ import { createMemo } from "solid-js";
3
+ export function createItemProps(props) {
4
+ return createMemo(props, { equals: sameItemProps });
5
+ }
@@ -13,6 +13,8 @@ export declare function provideTrigger(own: Accessor<TriggerProps>): Accessor<Tr
13
13
  * For a control that can open an overlay: its own props, after those of the overlays it opens.
14
14
  * Its own attributes win, its own handlers run first, and its class is added to theirs, so the
15
15
  * own class must be a string. While `inert` is true, as for a loading button, the overlays get
16
- * none of its events and so do not open. Spread the result on the element.
16
+ * none of its events and so do not open. The app's root attributes (`root`) come before the
17
+ * overlays': an overlay finds its trigger by the id it gives it. Spread the result on the
18
+ * element.
17
19
  */
18
- export declare function withTrigger<T extends object>(own: Accessor<T>, inert?: Accessor<boolean>): T;
20
+ export declare function withTrigger<T extends object>(own: Accessor<T>, inert?: Accessor<boolean>, root?: object): T;
@@ -6,7 +6,7 @@ export function provideTrigger(own) {
6
6
  const merged = mergeProps(() => outer?.() ?? {}, own);
7
7
  return () => merged;
8
8
  }
9
- export function withTrigger(own, inert) {
9
+ export function withTrigger(own, inert, root = {}) {
10
10
  const trigger = useContext(TriggerContext);
11
11
  const overlays = () => {
12
12
  const props = trigger?.() ?? {};
@@ -14,5 +14,5 @@ export function withTrigger(own, inert) {
14
14
  return props;
15
15
  return Object.fromEntries(Object.entries(props).filter(([key]) => !key.startsWith("on")));
16
16
  };
17
- return mergeProps(overlays, own);
17
+ return mergeProps(root, overlays, own);
18
18
  }