@xds/solid 1.1.0 → 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 (163) hide show
  1. package/dist/dom/Breadcrumb.js +87 -0
  2. package/dist/dom/Checkbox.js +12 -6
  3. package/dist/dom/Combobox.js +295 -0
  4. package/dist/dom/Link.js +62 -0
  5. package/dist/dom/Menu.js +15 -14
  6. package/dist/dom/Pagination.js +132 -0
  7. package/dist/dom/Popover.js +126 -0
  8. package/dist/dom/Select.js +75 -48
  9. package/dist/dom/Table.js +150 -0
  10. package/dist/dom/TimePicker.js +245 -0
  11. package/dist/dom/ToastQueue.js +59 -0
  12. package/dist/dom/base.js +16 -0
  13. package/dist/dom/index.js +9 -1
  14. package/dist/dom/modal-popover.js +2 -2
  15. package/dist/dom/presence.js +3 -2
  16. package/dist/dom/preview.js +19 -2
  17. package/dist/dom/rows.js +13 -0
  18. package/dist/source/Breadcrumb.d.ts +9 -0
  19. package/dist/source/Breadcrumb.jsx +26 -0
  20. package/dist/source/Checkbox.d.ts +1 -1
  21. package/dist/source/Checkbox.jsx +9 -3
  22. package/dist/source/Combobox.d.ts +16 -0
  23. package/dist/source/Combobox.jsx +137 -0
  24. package/dist/source/Link.d.ts +20 -0
  25. package/dist/source/Link.jsx +21 -0
  26. package/dist/source/Menu.jsx +8 -2
  27. package/dist/source/Pagination.d.ts +12 -0
  28. package/dist/source/Pagination.jsx +51 -0
  29. package/dist/source/Popover.d.ts +19 -0
  30. package/dist/source/Popover.jsx +65 -0
  31. package/dist/source/Select.d.ts +6 -0
  32. package/dist/source/Select.jsx +32 -8
  33. package/dist/source/Table.d.ts +17 -0
  34. package/dist/source/Table.jsx +46 -0
  35. package/dist/source/TimePicker.d.ts +19 -0
  36. package/dist/source/TimePicker.jsx +137 -0
  37. package/dist/source/ToastQueue.d.ts +19 -0
  38. package/dist/source/ToastQueue.jsx +27 -0
  39. package/dist/source/base.d.ts +15 -0
  40. package/dist/source/base.js +15 -0
  41. package/dist/source/controllable.d.ts +1 -1
  42. package/dist/source/index.d.ts +9 -1
  43. package/dist/source/index.js +8 -0
  44. package/dist/source/modal-popover.js +2 -2
  45. package/dist/source/presence.js +3 -2
  46. package/dist/source/preview.d.ts +10 -2
  47. package/dist/source/preview.jsx +12 -3
  48. package/dist/source/rows.d.ts +8 -0
  49. package/dist/source/rows.js +5 -0
  50. package/eject/files/Accordion.tsx +138 -0
  51. package/eject/files/Avatar.tsx +48 -0
  52. package/eject/files/AvatarStack.tsx +51 -0
  53. package/eject/files/Badge.tsx +39 -0
  54. package/eject/files/Banner.tsx +80 -0
  55. package/eject/files/Breadcrumb.tsx +57 -0
  56. package/eject/files/Button.tsx +90 -0
  57. package/eject/files/Card.tsx +100 -0
  58. package/eject/files/Checkbox.tsx +100 -0
  59. package/eject/files/Chip.tsx +40 -0
  60. package/eject/files/ChipBar.tsx +34 -0
  61. package/eject/files/Combobox.tsx +200 -0
  62. package/eject/files/CountBadge.tsx +55 -0
  63. package/eject/files/DatePicker.tsx +225 -0
  64. package/eject/files/DateRangePicker.tsx +319 -0
  65. package/eject/files/Dialog.tsx +117 -0
  66. package/eject/files/Divider.tsx +21 -0
  67. package/eject/files/EmptyState.tsx +39 -0
  68. package/eject/files/Icon.tsx +37 -0
  69. package/eject/files/IconButton.tsx +76 -0
  70. package/eject/files/Link.tsx +61 -0
  71. package/eject/files/ListRow.tsx +94 -0
  72. package/eject/files/MediaCard.tsx +116 -0
  73. package/eject/files/Menu.tsx +190 -0
  74. package/eject/files/Pagination.tsx +109 -0
  75. package/eject/files/Popover.tsx +124 -0
  76. package/eject/files/ProgressBar.tsx +37 -0
  77. package/eject/files/RadioGroup.tsx +138 -0
  78. package/eject/files/SearchField.tsx +124 -0
  79. package/eject/files/SectionHeader.tsx +59 -0
  80. package/eject/files/SegmentedControl.tsx +79 -0
  81. package/eject/files/Select.tsx +290 -0
  82. package/eject/files/Sidebar.tsx +156 -0
  83. package/eject/files/Skeleton.tsx +33 -0
  84. package/eject/files/Slider.tsx +131 -0
  85. package/eject/files/Spinner.tsx +44 -0
  86. package/eject/files/Switch.tsx +88 -0
  87. package/eject/files/Table.tsx +98 -0
  88. package/eject/files/Tabs.tsx +87 -0
  89. package/eject/files/Text.tsx +38 -0
  90. package/eject/files/TextField.tsx +171 -0
  91. package/eject/files/Thumbnail.tsx +84 -0
  92. package/eject/files/TimePicker.tsx +237 -0
  93. package/eject/files/Toast.tsx +100 -0
  94. package/eject/files/ToastQueue.tsx +62 -0
  95. package/eject/files/Tooltip.tsx +135 -0
  96. package/eject/files/accordion.css +89 -0
  97. package/eject/files/accordion.ts +67 -0
  98. package/eject/files/avatar-stack.ts +57 -0
  99. package/eject/files/avatar.ts +42 -0
  100. package/eject/files/badge.ts +30 -0
  101. package/eject/files/banner.ts +71 -0
  102. package/eject/files/base.css +38 -0
  103. package/eject/files/breadcrumb.css +51 -0
  104. package/eject/files/breadcrumb.ts +42 -0
  105. package/eject/files/button.css +241 -0
  106. package/eject/files/button.ts +106 -0
  107. package/eject/files/card.ts +58 -0
  108. package/eject/files/checkbox.ts +52 -0
  109. package/eject/files/chip-bar.ts +16 -0
  110. package/eject/files/chip.ts +35 -0
  111. package/eject/files/combobox.css +269 -0
  112. package/eject/files/combobox.ts +85 -0
  113. package/eject/files/count-badge.ts +32 -0
  114. package/eject/files/date-picker.css +375 -0
  115. package/eject/files/date-picker.ts +280 -0
  116. package/eject/files/date-range-picker.ts +338 -0
  117. package/eject/files/dialog.css +139 -0
  118. package/eject/files/dialog.ts +15 -0
  119. package/eject/files/divider.ts +5 -0
  120. package/eject/files/empty-state.ts +22 -0
  121. package/eject/files/icon.ts +36 -0
  122. package/eject/files/link.css +64 -0
  123. package/eject/files/link.ts +63 -0
  124. package/eject/files/list-row.ts +66 -0
  125. package/eject/files/media-card.ts +66 -0
  126. package/eject/files/menu.css +192 -0
  127. package/eject/files/menu.ts +84 -0
  128. package/eject/files/overlay.css +40 -0
  129. package/eject/files/pagination.css +106 -0
  130. package/eject/files/pagination.ts +68 -0
  131. package/eject/files/parts.ts +17 -0
  132. package/eject/files/popover.css +101 -0
  133. package/eject/files/popover.ts +37 -0
  134. package/eject/files/progress-bar.ts +26 -0
  135. package/eject/files/radio-group.css +184 -0
  136. package/eject/files/radio-group.ts +30 -0
  137. package/eject/files/section-header.ts +32 -0
  138. package/eject/files/segmented-control.ts +33 -0
  139. package/eject/files/select.css +347 -0
  140. package/eject/files/select.ts +77 -0
  141. package/eject/files/sidebar.ts +75 -0
  142. package/eject/files/skeleton.ts +51 -0
  143. package/eject/files/slider.css +160 -0
  144. package/eject/files/slider.ts +80 -0
  145. package/eject/files/spinner.ts +22 -0
  146. package/eject/files/switch.ts +45 -0
  147. package/eject/files/table.css +107 -0
  148. package/eject/files/table.ts +84 -0
  149. package/eject/files/tabs.css +120 -0
  150. package/eject/files/tabs.ts +37 -0
  151. package/eject/files/text-field.css +225 -0
  152. package/eject/files/text-field.ts +64 -0
  153. package/eject/files/text.ts +38 -0
  154. package/eject/files/thumbnail.ts +51 -0
  155. package/eject/files/time-picker.ts +113 -0
  156. package/eject/files/toast-queue.ts +64 -0
  157. package/eject/files/toast.ts +31 -0
  158. package/eject/files/tooltip.css +111 -0
  159. package/eject/files/tooltip.ts +21 -0
  160. package/eject/manifest.json +1027 -0
  161. package/package.json +12 -4
  162. package/styles.css +1064 -169
  163. 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
+ }
@@ -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
+ }
@@ -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";
@@ -6,7 +6,7 @@ import { type Accessor } from "solid-js";
6
6
  * `defaultValue`. Either way a change goes to `onChange`, read when the change comes. The state
7
7
  * is a plain value, never a function, which a signal would take for an update.
8
8
  */
9
- export declare function createControllable<T extends string | number | boolean | undefined>(options: {
9
+ export declare function createControllable<T extends string | number | boolean | undefined | readonly string[]>(options: {
10
10
  controlled: Accessor<boolean>;
11
11
  value: Accessor<T>;
12
12
  defaultValue: Accessor<T>;
@@ -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";
@@ -19,9 +20,12 @@ 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";
21
22
  export { type ComponentLabels, Labels, type LabelsProps } from "./Labels.tsx";
23
+ export { Link, type LinkProps } from "./Link.tsx";
22
24
  export { ListRow, type ListRowProps } from "./ListRow.tsx";
23
25
  export { MediaCard, type MediaCardProps } from "./MediaCard.tsx";
24
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";
25
29
  export { ProgressBar, type ProgressBarProps } from "./ProgressBar.tsx";
26
30
  export { RadioGroup, type RadioGroupProps, type RadioOption } from "./RadioGroup.tsx";
27
31
  export { SearchField, type SearchFieldProps } from "./SearchField.tsx";
@@ -33,9 +37,13 @@ export { Skeleton, type SkeletonProps } from "./Skeleton.tsx";
33
37
  export { Slider, type SliderProps } from "./Slider.tsx";
34
38
  export { Spinner, type SpinnerProps } from "./Spinner.tsx";
35
39
  export { Switch, type SwitchProps } from "./Switch.tsx";
40
+ export { type SortDirection, Table, type TableColumn, type TableProps, type TableRow, type TableSort, } from "./Table.tsx";
36
41
  export { Tabs, type TabsProps } from "./Tabs.tsx";
37
42
  export { Text, type TextProps } from "./Text.tsx";
38
43
  export { TextField, type TextFieldProps } from "./TextField.tsx";
39
44
  export { Thumbnail, type ThumbnailProps, type ThumbnailRatio } from "./Thumbnail.tsx";
45
+ export { type IsoTime, TimePicker, type TimePickerProps } from "./TimePicker.tsx";
40
46
  export { Toast, type ToastProps } from "./Toast.tsx";
47
+ export { type QueuedToast, queueToast, ToastQueue, type ToastQueueProps } from "./ToastQueue.tsx";
41
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";
@@ -18,9 +20,12 @@ export { EmptyState } from "./EmptyState.jsx";
18
20
  export { Icon } from "./Icon.jsx";
19
21
  export { IconButton } from "./IconButton.jsx";
20
22
  export { Labels } from "./Labels.jsx";
23
+ export { Link } from "./Link.jsx";
21
24
  export { ListRow } from "./ListRow.jsx";
22
25
  export { MediaCard } from "./MediaCard.jsx";
23
26
  export { Menu } from "./Menu.jsx";
27
+ export { Pagination } from "./Pagination.jsx";
28
+ export { Popover } from "./Popover.jsx";
24
29
  export { ProgressBar } from "./ProgressBar.jsx";
25
30
  export { RadioGroup } from "./RadioGroup.jsx";
26
31
  export { SearchField } from "./SearchField.jsx";
@@ -32,9 +37,12 @@ export { Skeleton } from "./Skeleton.jsx";
32
37
  export { Slider } from "./Slider.jsx";
33
38
  export { Spinner } from "./Spinner.jsx";
34
39
  export { Switch } from "./Switch.jsx";
40
+ export { Table, } from "./Table.jsx";
35
41
  export { Tabs } from "./Tabs.jsx";
36
42
  export { Text } from "./Text.jsx";
37
43
  export { TextField } from "./TextField.jsx";
38
44
  export { Thumbnail } from "./Thumbnail.jsx";
45
+ export { TimePicker } from "./TimePicker.jsx";
39
46
  export { Toast } from "./Toast.jsx";
47
+ export { queueToast, ToastQueue } from "./ToastQueue.jsx";
40
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, Labels, 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,24 +9,29 @@ 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,
20
22
  Defaults,
21
- Labels,
22
23
  Dialog,
23
24
  Divider,
24
25
  EmptyState,
25
26
  Icon,
26
27
  IconButton,
28
+ Labels,
29
+ Link,
27
30
  ListRow,
28
31
  MediaCard,
29
32
  Menu,
33
+ Pagination,
34
+ Popover,
30
35
  ProgressBar,
31
36
  RadioGroup,
32
37
  SearchField,
@@ -38,16 +43,20 @@ const COMPONENTS = {
38
43
  Slider,
39
44
  Spinner,
40
45
  Switch,
46
+ Table,
41
47
  Tabs,
42
48
  Text,
43
49
  TextField,
44
50
  Thumbnail,
51
+ TimePicker,
45
52
  Toast,
53
+ ToastQueue,
46
54
  Tooltip,
47
55
  };
48
56
  const _lacking = {};
49
57
  export function Preview(props) {
50
58
  const screen = untrack(() => props.screen);
59
+ const components = untrack(() => props.components);
51
60
  const state = {};
52
61
  const writes = new Map();
53
62
  for (const [key, first] of Object.entries(screen.state)) {
@@ -84,7 +93,7 @@ export function Preview(props) {
84
93
  }
85
94
  const type = slot.kind === "element"
86
95
  ? dynamic(() => slot.tag, { static: true })
87
- : COMPONENTS[slot.name];
96
+ : (components?.[slot.name] ?? COMPONENTS[slot.name]);
88
97
  return createComponent(type, propsOf(slot));
89
98
  },
90
99
  };
@@ -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
+ }
@@ -0,0 +1,138 @@
1
+ // Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
2
+ // as you need. `xds eject --list` says which ejected files differ from what was copied.
3
+
4
+ import { type RootProps, rootAttributes, withStyle } from "@xds/solid/base";
5
+ import type { JSX } from "@solidjs/web";
6
+ import * as accordion from "@zag-js/accordion";
7
+ import { mergeProps, normalizeProps, useMachine } from "@zag-js/solid";
8
+ import { createEffect, createMemo, createUniqueId, type Element, For, Show } from "solid-js";
9
+ import {
10
+ ACCORDION_PARTS,
11
+ type AccordionBaseProps,
12
+ type AccordionItemBase,
13
+ focusTitleOnClick,
14
+ setPanelOpen,
15
+ } from "./accordion.ts";
16
+ import { Icon } from "./Icon.tsx";
17
+ import { classes } from "./parts.ts";
18
+
19
+ export type AccordionItem<Value extends string = string> = AccordionItemBase<Value> & {
20
+ /** The body, shown under the title while the item is open. */
21
+ content: Element;
22
+ };
23
+
24
+ export type AccordionProps<Value extends string = string> = AccordionBaseProps<Value> &
25
+ RootProps & {
26
+ items: readonly AccordionItem<Value>[];
27
+ onChange: (expanded: Value[]) => void;
28
+ };
29
+
30
+ /**
31
+ * Items whose bodies open and close under their titles, separated by hairlines. The chevron
32
+ * turns over when an item is open, so the state does not depend on color. Opening and closing
33
+ * animate the height, and do not for people who ask for less motion.
34
+ *
35
+ * Each title is a heading holding a button that says whether its body is expanded and which
36
+ * body it controls. A closed body is hidden, but the browser's find in page still opens it.
37
+ */
38
+ export function Accordion<Value extends string = string>(props: AccordionProps<Value>) {
39
+ const id = createUniqueId();
40
+ const service = useMachine(accordion.machine, () => ({
41
+ id,
42
+ // The app's id goes on the root, where Zag looks for it by this one.
43
+ ids: { root: props.id },
44
+ value: [...props.expanded],
45
+ onValueChange: (details: accordion.ValueChangeDetails) =>
46
+ props.onChange(details.value as Value[]),
47
+ multiple: props.multiple ?? false,
48
+ collapsible: true,
49
+ hiddenUntilFound: true,
50
+ }));
51
+ const api = createMemo(() => accordion.connect(service, normalizeProps));
52
+ const root = withStyle(
53
+ () => api().getRootProps(),
54
+ () => props.style,
55
+ rootAttributes(props),
56
+ );
57
+ const body = (value: Value) => {
58
+ // The panel hides itself once it has finished closing; see Panel.
59
+ const { hidden: _hidden, ...attributes } = api().getItemContentProps({ value });
60
+ return attributes as JSX.HTMLAttributes<HTMLDivElement>;
61
+ };
62
+ return (
63
+ <div {...root} class={classes("{{prefix}}-accordion", props.class)}>
64
+ <For each={props.items}>
65
+ {(item) => (
66
+ <div {...api().getItemProps({ value: item.value })} class="{{prefix}}-accordion__item">
67
+ <h3
68
+ {...api().getItemHeaderProps({ value: item.value })}
69
+ class="{{prefix}}-accordion__heading"
70
+ >
71
+ <button
72
+ {...mergeProps(() => api().getItemTriggerProps({ value: item.value }), {
73
+ // Runs before Zag's handler.
74
+ onClick: focusTitleOnClick,
75
+ })}
76
+ class="{{prefix}}-accordion__trigger group"
77
+ >
78
+ <span class={ACCORDION_PARTS.text}>
79
+ <span class={ACCORDION_PARTS.title}>{item.title}</span>
80
+ <Show when={item.description}>
81
+ {(description) => (
82
+ <span class={ACCORDION_PARTS.description}>{description()}</span>
83
+ )}
84
+ </Show>
85
+ </span>
86
+ <Icon name="chevron-down" size="sm" class={ACCORDION_PARTS.chevron} />
87
+ </button>
88
+ </h3>
89
+ <Panel open={api().value.includes(item.value)} attributes={body(item.value)}>
90
+ {item.content}
91
+ </Panel>
92
+ </div>
93
+ )}
94
+ </For>
95
+ </div>
96
+ );
97
+ }
98
+
99
+ /**
100
+ * An item's body. Its height moves between zero and the height of what it holds, and it is
101
+ * hidden only once it has finished closing.
102
+ */
103
+ function Panel(props: {
104
+ open: boolean;
105
+ attributes: JSX.HTMLAttributes<HTMLDivElement>;
106
+ children: Element;
107
+ }) {
108
+ let panel!: HTMLDivElement;
109
+ let rendered = false;
110
+ // A page rendered on the server shows the panel before the effect below can run, so a closed
111
+ // one starts hidden. Read once so the effect owns `hidden` from then on.
112
+ const closedAtFirst = !props.open;
113
+ createEffect(
114
+ () => props.open,
115
+ (open) => {
116
+ const stop = setPanelOpen(panel, open, rendered);
117
+ rendered = true;
118
+ // The next toggle takes over from this one.
119
+ return stop;
120
+ },
121
+ );
122
+ // A group: a region is a landmark, and a page of accordions would fill the list of
123
+ // landmarks. A closed one is left out of the accessibility tree as soon as it starts closing;
124
+ // `hidden="until-found"` alone leaves the empty group in it.
125
+ return (
126
+ // A group, not a fieldset: it is the body of a disclosure, not a set of form fields.
127
+ <div
128
+ {...props.attributes}
129
+ ref={(element) => (panel = element)}
130
+ hidden={closedAtFirst || undefined}
131
+ role="group"
132
+ aria-hidden={props.open ? undefined : "true"}
133
+ class="{{prefix}}-accordion__panel"
134
+ >
135
+ <div class="{{prefix}}-accordion__body">{props.children}</div>
136
+ </div>
137
+ );
138
+ }
@@ -0,0 +1,48 @@
1
+ // Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
2
+ // as you need. `xds eject --list` says which ejected files differ from what was copied.
3
+
4
+ import { createPicture, type RootProps, rootAttributes, useDefaults } from "@xds/solid/base";
5
+ import { Show } from "solid-js";
6
+ import { type AvatarBaseProps, avatarClass, avatarInitials, pictureClass } from "./avatar.ts";
7
+ import { classes, rootPart } from "./parts.ts";
8
+
9
+ export type { AvatarSize } from "./avatar.ts";
10
+
11
+ export type AvatarProps = AvatarBaseProps & RootProps;
12
+
13
+ const ROOT = rootPart("Avatar");
14
+
15
+ /**
16
+ * Stands for a person or a team by a picture, or by their initials when there is none.
17
+ * Assistive technology gets the full name either way. The small size has room for one letter.
18
+ */
19
+ export function Avatar(props: AvatarProps) {
20
+ const defaults = useDefaults("Avatar");
21
+ const size = () => props.size ?? defaults().size;
22
+ const picture = createPicture(() => props.src);
23
+ return (
24
+ <span
25
+ {...rootAttributes(props)}
26
+ role="img"
27
+ aria-label={props.name}
28
+ class={classes(ROOT, avatarClass(size()), props.class)}
29
+ style={props.style}
30
+ >
31
+ {avatarInitials(props.name, size())}
32
+ <Show when={picture.loaded() !== false && props.src}>
33
+ {(src) => (
34
+ <img
35
+ ref={(element) => picture.sync(element, src())}
36
+ src={src()}
37
+ // The name is on the avatar itself; a second one on the picture would be read twice.
38
+ alt=""
39
+ aria-hidden="true"
40
+ class={pictureClass(picture.loaded() === true)}
41
+ onLoad={() => picture.onLoad(src())}
42
+ onError={() => picture.onError(src())}
43
+ />
44
+ )}
45
+ </Show>
46
+ </span>
47
+ );
48
+ }