@xds/svelte 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 (155) hide show
  1. package/dist/Breadcrumb.svelte +53 -0
  2. package/dist/Breadcrumb.svelte.d.ts +11 -0
  3. package/dist/Checkbox.svelte +11 -3
  4. package/dist/Checkbox.svelte.d.ts +2 -1
  5. package/dist/Combobox.svelte +194 -0
  6. package/dist/Combobox.svelte.d.ts +37 -0
  7. package/dist/DatePicker.svelte +5 -4
  8. package/dist/Link.svelte +86 -0
  9. package/dist/Link.svelte.d.ts +26 -0
  10. package/dist/Menu.svelte +8 -1
  11. package/dist/Pagination.svelte +108 -0
  12. package/dist/Pagination.svelte.d.ts +14 -0
  13. package/dist/Popover.svelte +91 -0
  14. package/dist/Popover.svelte.d.ts +21 -0
  15. package/dist/PopoverSurface.svelte +77 -0
  16. package/dist/PopoverSurface.svelte.d.ts +21 -0
  17. package/dist/Select.svelte +40 -8
  18. package/dist/Select.svelte.d.ts +6 -0
  19. package/dist/Table.svelte +92 -0
  20. package/dist/Table.svelte.d.ts +17 -0
  21. package/dist/TimePicker.svelte +222 -0
  22. package/dist/TimePicker.svelte.d.ts +20 -0
  23. package/dist/ToastQueue.svelte +57 -0
  24. package/dist/ToastQueue.svelte.d.ts +20 -0
  25. package/dist/base.d.ts +14 -0
  26. package/dist/base.js +27 -0
  27. package/dist/index.d.ts +11 -2
  28. package/dist/index.js +11 -0
  29. package/dist/modal-popover.svelte.js +5 -1
  30. package/dist/presence.svelte.js +5 -2
  31. package/dist/preview/Component.svelte +6 -3
  32. package/dist/preview/Preview.svelte +8 -2
  33. package/dist/preview/Preview.svelte.d.ts +2 -0
  34. package/dist/preview/components.d.ts +9 -2
  35. package/dist/preview/components.js +18 -2
  36. package/dist/preview/index.d.ts +1 -0
  37. package/eject/files/Accordion.svelte +100 -0
  38. package/eject/files/AccordionPanel.svelte +48 -0
  39. package/eject/files/Avatar.svelte +51 -0
  40. package/eject/files/AvatarStack.svelte +61 -0
  41. package/eject/files/Badge.svelte +52 -0
  42. package/eject/files/Banner.svelte +94 -0
  43. package/eject/files/Breadcrumb.svelte +52 -0
  44. package/eject/files/Button.svelte +126 -0
  45. package/eject/files/Card.svelte +112 -0
  46. package/eject/files/Checkbox.svelte +121 -0
  47. package/eject/files/Chip.svelte +51 -0
  48. package/eject/files/ChipBar.svelte +39 -0
  49. package/eject/files/Combobox.svelte +198 -0
  50. package/eject/files/CountBadge.svelte +51 -0
  51. package/eject/files/DatePicker.svelte +213 -0
  52. package/eject/files/DateRangePicker.svelte +294 -0
  53. package/eject/files/Dialog.svelte +119 -0
  54. package/eject/files/Divider.svelte +27 -0
  55. package/eject/files/EmptyState.svelte +52 -0
  56. package/eject/files/Icon.svelte +51 -0
  57. package/eject/files/IconButton.svelte +99 -0
  58. package/eject/files/Link.svelte +85 -0
  59. package/eject/files/ListRow.svelte +33 -0
  60. package/eject/files/MediaCard.svelte +117 -0
  61. package/eject/files/Menu.svelte +183 -0
  62. package/eject/files/Pagination.svelte +109 -0
  63. package/eject/files/PlaceRow.svelte +75 -0
  64. package/eject/files/Popover.svelte +100 -0
  65. package/eject/files/PopoverSurface.svelte +85 -0
  66. package/eject/files/ProgressBar.svelte +38 -0
  67. package/eject/files/RadioGroup.svelte +133 -0
  68. package/eject/files/SearchField.svelte +154 -0
  69. package/eject/files/SectionHeader.svelte +67 -0
  70. package/eject/files/SegmentedControl.svelte +85 -0
  71. package/eject/files/Select.svelte +276 -0
  72. package/eject/files/Sidebar.svelte +130 -0
  73. package/eject/files/SidebarRailButton.svelte +32 -0
  74. package/eject/files/Skeleton.svelte +55 -0
  75. package/eject/files/Slider.svelte +136 -0
  76. package/eject/files/Spinner.svelte +41 -0
  77. package/eject/files/Switch.svelte +105 -0
  78. package/eject/files/Table.svelte +90 -0
  79. package/eject/files/Tabs.svelte +85 -0
  80. package/eject/files/Text.svelte +43 -0
  81. package/eject/files/TextField.svelte +222 -0
  82. package/eject/files/Thumbnail.svelte +88 -0
  83. package/eject/files/TimePicker.svelte +237 -0
  84. package/eject/files/Toast.svelte +98 -0
  85. package/eject/files/ToastQueue.svelte +61 -0
  86. package/eject/files/Tooltip.svelte +51 -0
  87. package/eject/files/TooltipOverlay.svelte +88 -0
  88. package/eject/files/accordion.css +89 -0
  89. package/eject/files/accordion.ts +67 -0
  90. package/eject/files/avatar-stack.ts +57 -0
  91. package/eject/files/avatar.ts +42 -0
  92. package/eject/files/badge.ts +30 -0
  93. package/eject/files/banner.ts +71 -0
  94. package/eject/files/base.css +38 -0
  95. package/eject/files/breadcrumb.css +51 -0
  96. package/eject/files/breadcrumb.ts +42 -0
  97. package/eject/files/button.css +241 -0
  98. package/eject/files/button.ts +106 -0
  99. package/eject/files/card.ts +58 -0
  100. package/eject/files/checkbox.ts +52 -0
  101. package/eject/files/chip-bar.ts +16 -0
  102. package/eject/files/chip.ts +35 -0
  103. package/eject/files/combobox.css +269 -0
  104. package/eject/files/combobox.ts +85 -0
  105. package/eject/files/count-badge.ts +32 -0
  106. package/eject/files/date-picker.css +375 -0
  107. package/eject/files/date-picker.ts +280 -0
  108. package/eject/files/date-range-picker.ts +338 -0
  109. package/eject/files/dialog.css +139 -0
  110. package/eject/files/dialog.ts +15 -0
  111. package/eject/files/divider.ts +5 -0
  112. package/eject/files/empty-state.ts +22 -0
  113. package/eject/files/icon.ts +36 -0
  114. package/eject/files/link.css +64 -0
  115. package/eject/files/link.ts +63 -0
  116. package/eject/files/list-row.ts +66 -0
  117. package/eject/files/media-card.ts +66 -0
  118. package/eject/files/menu.css +192 -0
  119. package/eject/files/menu.ts +84 -0
  120. package/eject/files/overlay.css +40 -0
  121. package/eject/files/pagination.css +106 -0
  122. package/eject/files/pagination.ts +68 -0
  123. package/eject/files/parts.ts +17 -0
  124. package/eject/files/popover.css +101 -0
  125. package/eject/files/popover.ts +37 -0
  126. package/eject/files/progress-bar.ts +26 -0
  127. package/eject/files/radio-group.css +184 -0
  128. package/eject/files/radio-group.ts +30 -0
  129. package/eject/files/section-header.ts +32 -0
  130. package/eject/files/segmented-control.ts +33 -0
  131. package/eject/files/select.css +347 -0
  132. package/eject/files/select.ts +77 -0
  133. package/eject/files/sidebar.ts +75 -0
  134. package/eject/files/skeleton.ts +51 -0
  135. package/eject/files/slider.css +160 -0
  136. package/eject/files/slider.ts +80 -0
  137. package/eject/files/spinner.ts +22 -0
  138. package/eject/files/switch.ts +45 -0
  139. package/eject/files/table.css +107 -0
  140. package/eject/files/table.ts +84 -0
  141. package/eject/files/tabs.css +120 -0
  142. package/eject/files/tabs.ts +37 -0
  143. package/eject/files/text-field.css +225 -0
  144. package/eject/files/text-field.ts +64 -0
  145. package/eject/files/text.ts +38 -0
  146. package/eject/files/thumbnail.ts +51 -0
  147. package/eject/files/time-picker.ts +113 -0
  148. package/eject/files/toast-queue.ts +64 -0
  149. package/eject/files/toast.ts +31 -0
  150. package/eject/files/tooltip.css +111 -0
  151. package/eject/files/tooltip.ts +21 -0
  152. package/eject/manifest.json +1053 -0
  153. package/package.json +12 -4
  154. package/styles.css +1064 -169
  155. package/tailwind.css +1295 -218
@@ -0,0 +1,222 @@
1
+ <!--
2
+ @component
3
+ A field for choosing a time of day. Closed, it looks like a Select with a clock: the chosen time
4
+ on the locale's own clock ("9:30 AM", "09:30"). Pressed, it opens the times from `min` to `max`,
5
+ `step` minutes apart, under itself, with the chosen one in view; choosing one calls `onChange`
6
+ with it as `HH:MM` and closes the list.
7
+
8
+ The field is a button that says it opens a list box, as a Select's does: the arrow keys move,
9
+ typing the hour jumps to it, and Enter chooses. Without `value` it keeps its own choice, from
10
+ `defaultValue`.
11
+ -->
12
+ <script module lang="ts">
13
+ import type { IsoTime, TimePickerBaseProps } from "@xds/core";
14
+ import type { RootProps } from "./root.js";
15
+
16
+ export type { IsoTime } from "@xds/core";
17
+
18
+ export type TimePickerProps = TimePickerBaseProps &
19
+ RootProps & {
20
+ /** Called with the chosen time, as `HH:MM` on a 24-hour clock. */
21
+ onChange?: (value: IsoTime) => void;
22
+ };
23
+ </script>
24
+
25
+ <script lang="ts">
26
+ import { space } from "@xds/tokens";
27
+ import {
28
+ classes,
29
+ createItemPropsCache,
30
+ keepListKeys,
31
+ readCssPx,
32
+ rootAttributes,
33
+ type SelectOption,
34
+ timeOptions,
35
+ timePickerIds,
36
+ timePickerLocale,
37
+ underlayLayerStyle,
38
+ } from "@xds/core";
39
+ import * as select from "@zag-js/select";
40
+ import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
41
+ import type { HTMLAttributes, HTMLLabelAttributes } from "svelte/elements";
42
+ import { controllable, followFormReset } from "./controllable.svelte.js";
43
+ import Icon from "./Icon.svelte";
44
+ import { modalPopover } from "./modal-popover.svelte.js";
45
+ import Portal from "./Portal.svelte";
46
+ import { createPresence } from "./presence.svelte.js";
47
+
48
+ type KeyHandler = (event: KeyboardEvent) => void;
49
+
50
+ // `value` stays in the rest, where whether it is given at all can be asked.
51
+ let {
52
+ label,
53
+ defaultValue,
54
+ min,
55
+ max,
56
+ step,
57
+ placeholder,
58
+ description,
59
+ error,
60
+ name,
61
+ disabled,
62
+ locale,
63
+ onChange,
64
+ class: className,
65
+ style,
66
+ ...rest
67
+ }: TimePickerProps = $props();
68
+
69
+ const control = controllable<IsoTime | undefined, IsoTime>(
70
+ () => rest,
71
+ "value",
72
+ () => rest.value,
73
+ () => defaultValue,
74
+ () => onChange,
75
+ );
76
+ const value = $derived(control.current);
77
+ let root = $state<HTMLDivElement>();
78
+ followFormReset(() => root, control);
79
+
80
+ const id = $props.id();
81
+ const ids = timePickerIds(id);
82
+ const invalid = $derived(error !== undefined);
83
+ const options = $derived(timeOptions({ min, max, step, value }, timePickerLocale(locale)));
84
+ const collection = $derived(
85
+ select.collection<SelectOption<IsoTime>>({
86
+ items: options,
87
+ itemToValue: (option) => option.value,
88
+ itemToString: (option) => option.label,
89
+ }),
90
+ );
91
+ const service = useMachine(select.machine, () => ({
92
+ id,
93
+ collection,
94
+ value: value === undefined ? [] : [value],
95
+ onValueChange: (details: select.ValueChangeDetails<SelectOption<IsoTime>>) => {
96
+ const next = details.value[0];
97
+ if (next !== undefined) control.set(next);
98
+ },
99
+ disabled,
100
+ invalid,
101
+ positioning: {
102
+ placement: "bottom-start" as const,
103
+ gutter: readCssPx(null, "--xds-space-1", space[1]),
104
+ sameWidth: true,
105
+ overflowPadding: readCssPx(null, "--xds-space-3", space[3]),
106
+ },
107
+ }));
108
+ const api = $derived(select.connect(service, normalizeProps));
109
+ // The rows' props as they last were while they draw the same, so that a step of the highlight
110
+ // sets the attributes and the handlers of the two rows it moves between, not of every row.
111
+ const keep = createItemPropsCache();
112
+ // As in Select: a handler taken from the machine when the key comes reads whether a search by
113
+ // typing is still under way.
114
+ const current = () => select.connect(service, normalizeProps);
115
+ // A span: the field is a button, which a <label> cannot point at.
116
+ const labelProps = $derived.by(() => {
117
+ const { for: _, ...rest } = api.getLabelProps() as HTMLLabelAttributes;
118
+ return rest as HTMLAttributes<HTMLSpanElement>;
119
+ });
120
+ const triggerProps = $derived.by(() => {
121
+ const {
122
+ role: _role,
123
+ "aria-invalid": _invalid,
124
+ "aria-required": _required,
125
+ onkeydown: _onKeyDown,
126
+ ...rest
127
+ } = api.getTriggerProps();
128
+ return {
129
+ ...rest,
130
+ onkeydown: (event: KeyboardEvent) => {
131
+ if (!api.open && (event.key === "Home" || event.key === "End")) return;
132
+ (current().getTriggerProps().onkeydown as KeyHandler | undefined)?.(event);
133
+ },
134
+ };
135
+ });
136
+ let positioner = $state<HTMLDivElement>();
137
+ let surface = $state<HTMLDivElement>();
138
+ modalPopover(
139
+ () => api.open,
140
+ () => positioner,
141
+ );
142
+ const present = createPresence(
143
+ () => api.open,
144
+ () => [surface],
145
+ );
146
+ const content = $derived.by(() => {
147
+ const { onkeydown: _onKeyDown, ...rest } = api.getContentProps();
148
+ return mergeProps(rest, {
149
+ onkeydown: (event: KeyboardEvent) => {
150
+ keepListKeys(event, surface, ".xds-time-picker__item:not([data-disabled])", (value) =>
151
+ api.setHighlightedValue(value),
152
+ );
153
+ (current().getContentProps().onkeydown as KeyHandler | undefined)?.(event);
154
+ },
155
+ });
156
+ });
157
+ </script>
158
+
159
+ <!-- Merged, so that the app's style joins any the machine writes on the root. -->
160
+ <div
161
+ bind:this={root}
162
+ {...mergeProps(api.getRootProps(), {
163
+ ...rootAttributes(rest),
164
+ class: classes("xds-time-picker", className),
165
+ style,
166
+ })}
167
+ >
168
+ <span {...labelProps} class="xds-time-picker__label">{label}</span>
169
+ <button
170
+ {...triggerProps}
171
+ aria-labelledby={`${ids.value} ${labelProps.id}`}
172
+ aria-describedby={invalid ? ids.error : description ? ids.description : undefined}
173
+ class="xds-time-picker__trigger"
174
+ >
175
+ <span {...api.getValueTextProps()} id={ids.value} class="xds-time-picker__value"
176
+ >{api.valueAsString || placeholder}</span
177
+ >
178
+ <Icon name="clock" size="sm" class="text-xds-field-placeholder" />
179
+ </button>
180
+ <div class="xds-time-picker__footer">
181
+ {#if !invalid && description}
182
+ <span id={ids.description} class="xds-time-picker__description">{description}</span>
183
+ {/if}
184
+ <span id={ids.error} class="xds-time-picker__error" aria-live="polite">{error}</span>
185
+ </div>
186
+ <!-- What a form submits: the time as HH:MM, where the field shows it on the locale's clock. -->
187
+ {#if name !== undefined}
188
+ <input type="hidden" {name} value={value ?? ""} />
189
+ {/if}
190
+ <Portal>
191
+ {#if api.open}
192
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
193
+ <div
194
+ class="xds-time-picker__underlay"
195
+ style:--layer-index={underlayLayerStyle(api.getPositionerProps().style)?.["--layer-index"]}
196
+ onmousedown={(event) => event.preventDefault()}
197
+ ></div>
198
+ {/if}
199
+ <div {...api.getPositionerProps()} bind:this={positioner} class="xds-time-picker__positioner">
200
+ <div {...content} bind:this={surface} hidden={!present()} class="xds-time-picker__content">
201
+ <div {...api.getListProps()} class="xds-time-picker__list">
202
+ {#each collection.items as option (option.value)}
203
+ <div
204
+ {...keep(`item:${option.value}`, api.getItemProps({ item: option }))}
205
+ class="xds-time-picker__item"
206
+ >
207
+ <span class="xds-time-picker__item-words">
208
+ <span
209
+ {...keep(`text:${option.value}`, api.getItemTextProps({ item: option }))}
210
+ class="xds-time-picker__item-label">{option.label}</span
211
+ >
212
+ </span>
213
+ {#if api.getItemState({ item: option }).selected}
214
+ <Icon name="check" size="sm" />
215
+ {/if}
216
+ </div>
217
+ {/each}
218
+ </div>
219
+ </div>
220
+ </div>
221
+ </Portal>
222
+ </div>
@@ -0,0 +1,20 @@
1
+ import type { IsoTime, TimePickerBaseProps } from "@xds/core";
2
+ import type { RootProps } from "./root.js";
3
+ export type { IsoTime } from "@xds/core";
4
+ export type TimePickerProps = TimePickerBaseProps & RootProps & {
5
+ /** Called with the chosen time, as `HH:MM` on a 24-hour clock. */
6
+ onChange?: (value: IsoTime) => void;
7
+ };
8
+ /**
9
+ * A field for choosing a time of day. Closed, it looks like a Select with a clock: the chosen time
10
+ * on the locale's own clock ("9:30 AM", "09:30"). Pressed, it opens the times from `min` to `max`,
11
+ * `step` minutes apart, under itself, with the chosen one in view; choosing one calls `onChange`
12
+ * with it as `HH:MM` and closes the list.
13
+ *
14
+ * The field is a button that says it opens a list box, as a Select's does: the arrow keys move,
15
+ * typing the hour jumps to it, and Enter chooses. Without `value` it keeps its own choice, from
16
+ * `defaultValue`.
17
+ */
18
+ declare const TimePicker: import("svelte").Component<TimePickerProps, {}, "">;
19
+ type TimePicker = ReturnType<typeof TimePicker>;
20
+ export default TimePicker;
@@ -0,0 +1,57 @@
1
+ <!--
2
+ @component
3
+ Shows the app's toasts one at a time, in their order: the first of `toasts`, which stays for its
4
+ own `duration` or until its action is taken, and then the next, `motion.duration.normal` after the
5
+ one before has gone, so that each is read and announced as a message of its own. Add a toast
6
+ with `queueToast`, which keeps at most three waiting, and take one out in `onClose`. Put one
7
+ where a single Toast would go.
8
+ -->
9
+ <script module lang="ts">
10
+ import type { QueuedToast, ToastQueueBaseProps } from "@xds/core";
11
+ import type { RootProps } from "./root.js";
12
+
13
+ /** `class`, `style`, `id` and `data-*` go on the toast shown, as Toast takes them. */
14
+ export type ToastQueueProps = ToastQueueBaseProps &
15
+ RootProps & {
16
+ /**
17
+ * Called with a toast's id when its time is up or its action was taken. Take it out of
18
+ * `toasts` in it.
19
+ */
20
+ onClose: (id: QueuedToast["id"]) => void;
21
+ };
22
+ </script>
23
+
24
+ <script lang="ts">
25
+ import { motion } from "@xds/tokens";
26
+ import { readCssMs, toastQueueStep } from "@xds/core";
27
+ import Toast from "./Toast.svelte";
28
+
29
+ let { toasts, onClose, ...root }: ToastQueueProps = $props();
30
+
31
+ let visible = $state<QueuedToast["id"]>();
32
+ const step = $derived(toastQueueStep(toasts, visible));
33
+ const shown = $derived(step === "keep" ? toasts[0] : undefined);
34
+
35
+ $effect(() => {
36
+ const first = toasts[0];
37
+ if (step === "close") {
38
+ visible = undefined;
39
+ return;
40
+ }
41
+ if (step !== "wait" || first === undefined) return;
42
+ const gap = readCssMs(null, "--xds-motion-duration-normal", motion.duration.normal);
43
+ const timer = setTimeout(() => (visible = first.id), gap);
44
+ return () => clearTimeout(timer);
45
+ });
46
+ </script>
47
+
48
+ <Toast
49
+ {...root}
50
+ open={shown !== undefined}
51
+ message={shown?.message ?? ""}
52
+ action={shown?.action}
53
+ duration={shown?.duration}
54
+ onClose={() => {
55
+ if (shown !== undefined) onClose(shown.id);
56
+ }}
57
+ />
@@ -0,0 +1,20 @@
1
+ import type { QueuedToast, ToastQueueBaseProps } from "@xds/core";
2
+ import type { RootProps } from "./root.js";
3
+ /** `class`, `style`, `id` and `data-*` go on the toast shown, as Toast takes them. */
4
+ export type ToastQueueProps = ToastQueueBaseProps & RootProps & {
5
+ /**
6
+ * Called with a toast's id when its time is up or its action was taken. Take it out of
7
+ * `toasts` in it.
8
+ */
9
+ onClose: (id: QueuedToast["id"]) => void;
10
+ };
11
+ /**
12
+ * Shows the app's toasts one at a time, in their order: the first of `toasts`, which stays for its
13
+ * own `duration` or until its action is taken, and then the next, `motion.duration.normal` after the
14
+ * one before has gone, so that each is read and announced as a message of its own. Add a toast
15
+ * with `queueToast`, which keeps at most three waiting, and take one out in `onClose`. Put one
16
+ * where a single Toast would go.
17
+ */
18
+ declare const ToastQueue: import("svelte").Component<ToastQueueProps, {}, "">;
19
+ type ToastQueue = ReturnType<typeof ToastQueue>;
20
+ export default ToastQueue;
package/dist/base.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export { default as PlaceRow } from "./PlaceRow.svelte";
2
+ export { default as Portal } from "./Portal.svelte";
3
+ export { default as TooltipOverlay } from "./TooltipOverlay.svelte";
4
+ export { controllable, followFormReset } from "./controllable.svelte.js";
5
+ export { keepChecked, keepValue } from "./controlled.js";
6
+ export { useDefaults } from "./defaults.svelte.js";
7
+ export { useLabels } from "./labels.svelte.js";
8
+ export { modalPopover } from "./modal-popover.svelte.js";
9
+ export { createPicture } from "./picture.svelte.js";
10
+ export { createPresence } from "./presence.svelte.js";
11
+ export type { RootProps } from "./root.js";
12
+ export { provideTrigger, resetTrigger, type TriggerProps, withTrigger } from "./trigger.svelte.js";
13
+ export { type IconName, icons, motion, space } from "@xds/tokens";
14
+ export { AVATAR_SIZE, type AvatarSize, afterAnimations, buttonClass, type ComponentLabels, createItemPropsCache, DEFAULT_LABELS, focusWithoutRing, type IconSize, initials, keepListKeys, leaveEscapeToFields, PEER_FOCUS, PRESSABLE_ROW, pictureClass, readCssMs, readCssPx, type SelectOption, selectOptionIds, rootAttributes, switchClass, switchLabelClass, type ThumbnailRatio, type ToastAction, tooltipEndSide, underlayLayerStyle, } from "@xds/core";
package/dist/base.js ADDED
@@ -0,0 +1,27 @@
1
+ // What an ejected component takes from the library: the hooks and types the components share,
2
+ // the parts of a component that another draws, the classes and helpers of @xds/ui-core that a
3
+ // component's own recipe does not hold, and the token values a component reads. `xds eject`
4
+ // copies a component's own sources into an app; every other import of the copy comes from here
5
+ // (`@xds/svelte/base` once published), so the copy keeps working as the library moves on.
6
+ //
7
+ // What is here is public: a release that removes or changes a name breaks the apps that ejected
8
+ // a component that uses it, as a change to a component's props does.
9
+ // @if template
10
+ // npm/web/eject.test.ts fails when a copy imports a name that is not here, and when a name here
11
+ // is used by no copy.
12
+ // @endif
13
+ // keep-sorted start block=yes by_regex=['from "([^"]+)"']
14
+ export { default as PlaceRow } from "./PlaceRow.svelte";
15
+ export { default as Portal } from "./Portal.svelte";
16
+ export { default as TooltipOverlay } from "./TooltipOverlay.svelte";
17
+ export { controllable, followFormReset } from "./controllable.svelte.js";
18
+ export { keepChecked, keepValue } from "./controlled.js";
19
+ export { useDefaults } from "./defaults.svelte.js";
20
+ export { useLabels } from "./labels.svelte.js";
21
+ export { modalPopover } from "./modal-popover.svelte.js";
22
+ export { createPicture } from "./picture.svelte.js";
23
+ export { createPresence } from "./presence.svelte.js";
24
+ export { provideTrigger, resetTrigger, withTrigger } from "./trigger.svelte.js";
25
+ export { icons, motion, space } from "@xds/tokens";
26
+ export { AVATAR_SIZE, afterAnimations, buttonClass, createItemPropsCache, DEFAULT_LABELS, focusWithoutRing, initials, keepListKeys, leaveEscapeToFields, PEER_FOCUS, PRESSABLE_ROW, pictureClass, readCssMs, readCssPx, selectOptionIds, rootAttributes, switchClass, switchLabelClass, tooltipEndSide, underlayLayerStyle, } from "@xds/core";
27
+ // keep-sorted end
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- export type { IconName, IconSize, TextTone, TextVariant } from "@xds/core";
2
1
  export { default as Accordion, type AccordionItem, type AccordionProps } from "./Accordion.svelte";
3
2
  export { default as Avatar, type AvatarProps, type AvatarSize } from "./Avatar.svelte";
4
3
  export { default as AvatarStack, type AvatarStackProps } from "./AvatarStack.svelte";
5
4
  export { default as Badge, type BadgeProps, type BadgeTone } from "./Badge.svelte";
6
5
  export { default as Banner, type BannerProps, type BannerTone } from "./Banner.svelte";
6
+ export { type BreadcrumbItem, type BreadcrumbProps, default as Breadcrumb, } from "./Breadcrumb.svelte";
7
7
  export { default as Button, type ButtonProps, type ButtonVariant, type ControlSize, } from "./Button.svelte";
8
8
  export { default as Card, type CardProps } from "./Card.svelte";
9
9
  export { default as Checkbox, type CheckboxProps } from "./Checkbox.svelte";
10
10
  export { default as Chip, type ChipProps } from "./Chip.svelte";
11
11
  export { default as ChipBar, type ChipBarProps } from "./ChipBar.svelte";
12
+ export { default as Combobox, type ComboboxProps } from "./Combobox.svelte";
12
13
  export { default as CountBadge, type CountBadgeProps } from "./CountBadge.svelte";
13
14
  export { default as DatePicker, type DatePickerProps, type IsoDate } from "./DatePicker.svelte";
14
15
  export { type DateRange, default as DateRangePicker, type DateRangePickerProps, } from "./DateRangePicker.svelte";
@@ -19,12 +20,14 @@ export { default as EmptyState, type EmptyStateProps } from "./EmptyState.svelte
19
20
  export { default as Icon, type IconProps } from "./Icon.svelte";
20
21
  export { default as IconButton, type IconButtonProps } from "./IconButton.svelte";
21
22
  export { type ComponentLabels, default as Labels, type LabelsProps } from "./Labels.svelte";
23
+ export { default as Link, type LinkProps } from "./Link.svelte";
22
24
  export { default as ListRow, type ListRowProps } from "./ListRow.svelte";
23
25
  export { default as MediaCard, type MediaCardProps } from "./MediaCard.svelte";
24
26
  export { default as Menu, type MenuItem, type MenuProps } from "./Menu.svelte";
27
+ export { default as Pagination, type PaginationProps } from "./Pagination.svelte";
28
+ export { default as Popover, type PopoverProps } from "./Popover.svelte";
25
29
  export { default as ProgressBar, type ProgressBarProps } from "./ProgressBar.svelte";
26
30
  export { default as RadioGroup, type RadioGroupProps, type RadioOption } from "./RadioGroup.svelte";
27
- export type { RootProps } from "./root.js";
28
31
  export { default as SearchField, type SearchFieldProps } from "./SearchField.svelte";
29
32
  export { default as SectionHeader, type SectionHeaderProps } from "./SectionHeader.svelte";
30
33
  export { default as SegmentedControl, type SegmentedControlProps } from "./SegmentedControl.svelte";
@@ -34,9 +37,15 @@ export { default as Skeleton, type SkeletonProps } from "./Skeleton.svelte";
34
37
  export { default as Slider, type SliderProps } from "./Slider.svelte";
35
38
  export { default as Spinner, type SpinnerProps } from "./Spinner.svelte";
36
39
  export { default as Switch, type SwitchProps } from "./Switch.svelte";
40
+ export { type SortDirection, default as Table, type TableColumn, type TableProps, type TableRow, type TableSort, } from "./Table.svelte";
37
41
  export { default as Tabs, type TabsProps } from "./Tabs.svelte";
38
42
  export { default as Text, type TextProps } from "./Text.svelte";
39
43
  export { default as TextField, type TextFieldProps } from "./TextField.svelte";
40
44
  export { default as Thumbnail, type ThumbnailProps, type ThumbnailRatio } from "./Thumbnail.svelte";
45
+ export { type IsoTime, default as TimePicker, type TimePickerProps } from "./TimePicker.svelte";
41
46
  export { default as Toast, type ToastProps } from "./Toast.svelte";
47
+ export { default as ToastQueue, type ToastQueueProps } from "./ToastQueue.svelte";
42
48
  export { default as Tooltip, type TooltipProps } from "./Tooltip.svelte";
49
+ export type { RootProps } from "./root.js";
50
+ export type { IconName, IconSize, TextTone, TextVariant } from "@xds/core";
51
+ export { type QueuedToast, queueToast } from "@xds/core";
package/dist/index.js CHANGED
@@ -6,16 +6,19 @@
6
6
  // @xds/ui-vue, the React Native ones in @xds/ui-native, the GPUI ones in the xds-ui crate and
7
7
  // the Compose ones under kotlin/ui. All of them take the same variants, sizes and tones, and draw
8
8
  // them from the same design tokens.
9
+ // keep-sorted start block=yes by_regex=['from "([^"]+)"']
9
10
  export { default as Accordion } from "./Accordion.svelte";
10
11
  export { default as Avatar } from "./Avatar.svelte";
11
12
  export { default as AvatarStack } from "./AvatarStack.svelte";
12
13
  export { default as Badge } from "./Badge.svelte";
13
14
  export { default as Banner } from "./Banner.svelte";
15
+ export { default as Breadcrumb, } from "./Breadcrumb.svelte";
14
16
  export { default as Button, } from "./Button.svelte";
15
17
  export { default as Card } from "./Card.svelte";
16
18
  export { default as Checkbox } from "./Checkbox.svelte";
17
19
  export { default as Chip } from "./Chip.svelte";
18
20
  export { default as ChipBar } from "./ChipBar.svelte";
21
+ export { default as Combobox } from "./Combobox.svelte";
19
22
  export { default as CountBadge } from "./CountBadge.svelte";
20
23
  export { default as DatePicker } from "./DatePicker.svelte";
21
24
  export { default as DateRangePicker, } from "./DateRangePicker.svelte";
@@ -26,9 +29,12 @@ export { default as EmptyState } from "./EmptyState.svelte";
26
29
  export { default as Icon } from "./Icon.svelte";
27
30
  export { default as IconButton } from "./IconButton.svelte";
28
31
  export { default as Labels } from "./Labels.svelte";
32
+ export { default as Link } from "./Link.svelte";
29
33
  export { default as ListRow } from "./ListRow.svelte";
30
34
  export { default as MediaCard } from "./MediaCard.svelte";
31
35
  export { default as Menu } from "./Menu.svelte";
36
+ export { default as Pagination } from "./Pagination.svelte";
37
+ export { default as Popover } from "./Popover.svelte";
32
38
  export { default as ProgressBar } from "./ProgressBar.svelte";
33
39
  export { default as RadioGroup } from "./RadioGroup.svelte";
34
40
  export { default as SearchField } from "./SearchField.svelte";
@@ -40,9 +46,14 @@ export { default as Skeleton } from "./Skeleton.svelte";
40
46
  export { default as Slider } from "./Slider.svelte";
41
47
  export { default as Spinner } from "./Spinner.svelte";
42
48
  export { default as Switch } from "./Switch.svelte";
49
+ export { default as Table, } from "./Table.svelte";
43
50
  export { default as Tabs } from "./Tabs.svelte";
44
51
  export { default as Text } from "./Text.svelte";
45
52
  export { default as TextField } from "./TextField.svelte";
46
53
  export { default as Thumbnail } from "./Thumbnail.svelte";
54
+ export { default as TimePicker } from "./TimePicker.svelte";
47
55
  export { default as Toast } from "./Toast.svelte";
56
+ export { default as ToastQueue } from "./ToastQueue.svelte";
48
57
  export { default as Tooltip } from "./Tooltip.svelte";
58
+ export { queueToast } from "@xds/core";
59
+ // keep-sorted end
@@ -8,8 +8,12 @@ import { preventBodyScroll } from "@zag-js/remove-scroll";
8
8
  * while the component is set up.
9
9
  */
10
10
  export function modalPopover(open, popup) {
11
+ // Derived, so that the effect runs as the popup opens or closes: `open` usually reads the
12
+ // machine's api, which changes with every step of the highlight, and the effect would let the
13
+ // page scroll and hide it from assistive technology again each time.
14
+ const isOpen = $derived(open());
11
15
  $effect(() => {
12
- if (!open())
16
+ if (!isOpen)
13
17
  return;
14
18
  const unlock = preventBodyScroll(document);
15
19
  // A frame later, once the popup is shown.
@@ -6,14 +6,17 @@ import { afterAnimations } from "@xds/core";
6
6
  */
7
7
  export function createPresence(open, parts) {
8
8
  let exited = $state(true);
9
+ // Derived, so that the effect runs as the overlay opens or closes, not on every change to the
10
+ // machine that `open` usually reads.
11
+ const isOpen = $derived(open());
9
12
  $effect(() => {
10
- if (open()) {
13
+ if (isOpen) {
11
14
  exited = false;
12
15
  return;
13
16
  }
14
17
  // Opening again before the animation ends stops the wait.
15
18
  return afterAnimations(parts(), () => (exited = true));
16
19
  });
17
- const present = $derived(open() || !exited);
20
+ const present = $derived(isOpen || !exited);
18
21
  return () => present;
19
22
  }
@@ -16,8 +16,8 @@
16
16
  type Slot,
17
17
  type State,
18
18
  } from "@xds/core/preview";
19
- import { type Component, type Snippet, untrack } from "svelte";
20
- import { COMPONENTS } from "./components.js";
19
+ import { type Component, getContext, type Snippet, untrack } from "svelte";
20
+ import { COMPONENTS, COMPONENTS_KEY, type PreviewComponents } from "./components.js";
21
21
  import Snippets from "./Snippets.svelte";
22
22
 
23
23
  let { node, host }: { node: ComponentNode; host: Host<Snippet> } = $props();
@@ -48,10 +48,13 @@
48
48
  }
49
49
 
50
50
  const { values, slots } = untrack(() => split(node, host));
51
+ const components = getContext<PreviewComponents | undefined>(COMPONENTS_KEY);
51
52
  </script>
52
53
 
53
54
  <Snippets
54
- component={COMPONENTS[node.name] as Component<Record<string, unknown>>}
55
+ component={(components?.[node.name] ?? COMPONENTS[node.name]) as Component<
56
+ Record<string, unknown>
57
+ >}
55
58
  props={values}
56
59
  {slots}
57
60
  {host}
@@ -7,10 +7,16 @@
7
7
  -->
8
8
  <script lang="ts">
9
9
  import type { Host, Screen } from "@xds/core/preview";
10
- import { onMount, type Snippet, untrack } from "svelte";
10
+ import { onMount, setContext, type Snippet, untrack } from "svelte";
11
+ import { COMPONENTS_KEY, type PreviewComponents } from "./components.js";
11
12
  import Draw from "./Draw.svelte";
12
13
 
13
- let { screen }: { screen: Screen } = $props();
14
+ let { screen, components }: { screen: Screen; components?: PreviewComponents } = $props();
15
+
16
+ setContext(
17
+ COMPONENTS_KEY,
18
+ untrack(() => components),
19
+ );
14
20
 
15
21
  const { state: first, root, mount } = untrack(() => screen);
16
22
  const values: Record<string, unknown> = {};
@@ -1,6 +1,8 @@
1
1
  import type { Screen } from "@xds/core/preview";
2
+ import { type PreviewComponents } from "./components.js";
2
3
  type $$ComponentProps = {
3
4
  screen: Screen;
5
+ components?: PreviewComponents;
4
6
  };
5
7
  /**
6
8
  * Draws a screen of @xds/core/preview (the design preview, a behavior test's scenario) with
@@ -1,6 +1,6 @@
1
1
  import type { ComponentName, Components } from "@xds/core/preview";
2
2
  import type { Component, Snippet } from "svelte";
3
- type Table = {
3
+ type ComponentTable = {
4
4
  readonly [N in ComponentName]: Component<Components<Snippet>[N]>;
5
5
  };
6
6
  /**
@@ -8,5 +8,12 @@ type Table = {
8
8
  * each component, which a declaration file cannot name, and the published package would ship
9
9
  * this module without one.
10
10
  */
11
- export declare const COMPONENTS: Table;
11
+ export declare const COMPONENTS: ComponentTable;
12
+ /**
13
+ * Components to draw in place of the library's, by name: an app's ejected copies (`xds eject`),
14
+ * which the design preview then shows as it shows the library's.
15
+ */
16
+ export type PreviewComponents = Partial<ComponentTable>;
17
+ /** The context that Preview hands PreviewComponents to each component of the screen in. */
18
+ export declare const COMPONENTS_KEY: unique symbol;
12
19
  export {};
@@ -1,33 +1,43 @@
1
- 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";
1
+ import {
2
+ // keep-sorted start
3
+ 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,
4
+ // keep-sorted end
5
+ } from "../index.js";
2
6
  /**
3
7
  * Every component the data can name, each taking the props the data gives it, with a snippet
4
8
  * for each node. They are imported by name: a namespace import of the entry would put every
5
9
  * component in the chunk that the app's own screens load too.
6
10
  */
7
11
  const components = {
12
+ // keep-sorted start
8
13
  Accordion,
9
14
  Avatar,
10
15
  AvatarStack,
11
16
  Badge,
12
17
  Banner,
18
+ Breadcrumb,
13
19
  Button,
14
20
  Card,
15
21
  Checkbox,
16
22
  Chip,
17
23
  ChipBar,
24
+ Combobox,
18
25
  CountBadge,
19
26
  DatePicker,
20
27
  DateRangePicker,
21
28
  Defaults,
22
- Labels,
23
29
  Dialog,
24
30
  Divider,
25
31
  EmptyState,
26
32
  Icon,
27
33
  IconButton,
34
+ Labels,
35
+ Link,
28
36
  ListRow,
29
37
  MediaCard,
30
38
  Menu,
39
+ Pagination,
40
+ Popover,
31
41
  ProgressBar,
32
42
  RadioGroup,
33
43
  SearchField,
@@ -39,12 +49,16 @@ const components = {
39
49
  Slider,
40
50
  Spinner,
41
51
  Switch,
52
+ Table,
42
53
  Tabs,
43
54
  Text,
44
55
  TextField,
45
56
  Thumbnail,
57
+ TimePicker,
46
58
  Toast,
59
+ ToastQueue,
47
60
  Tooltip,
61
+ // keep-sorted end
48
62
  };
49
63
  /**
50
64
  * The table under a type of its own: inferred, its type would name the class that Svelte gives
@@ -52,4 +66,6 @@ const components = {
52
66
  * this module without one.
53
67
  */
54
68
  export const COMPONENTS = components;
69
+ /** The context that Preview hands PreviewComponents to each component of the screen in. */
70
+ export const COMPONENTS_KEY = Symbol("preview components");
55
71
  ({});
@@ -1,2 +1,3 @@
1
1
  export { designPreview } from "@xds/core/preview";
2
+ export type { PreviewComponents } from "./components.js";
2
3
  export { default as Preview } from "./Preview.svelte";