@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,200 @@
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 {
5
+ createControllable,
6
+ createItemProps,
7
+ isControlled,
8
+ Portal,
9
+ type RootProps,
10
+ readCssPx,
11
+ resetWithForm,
12
+ rootAttributes,
13
+ type SelectOption,
14
+ selectOptionIds,
15
+ space,
16
+ useLabels,
17
+ withStyle,
18
+ } from "@xds/solid/base";
19
+ import * as combobox from "@zag-js/combobox";
20
+ import { mergeProps, normalizeProps, useMachine } from "@zag-js/solid";
21
+ import { createMemo, createSignal, createUniqueId, For, Show } from "solid-js";
22
+ import { COMBOBOX_PARTS as PARTS, type ComboboxBaseProps, matchOptions } from "./combobox.ts";
23
+ import { Icon } from "./Icon.tsx";
24
+ import { classes } from "./parts.ts";
25
+
26
+ export type ComboboxProps<Value extends string = string> = ComboboxBaseProps<Value> &
27
+ RootProps & {
28
+ onChange?: (value: Value) => void;
29
+ };
30
+
31
+ /**
32
+ * A field for choosing one option from a list by typing part of its name. As the person types,
33
+ * the options whose label holds what was typed open under it, those that start with it first,
34
+ * and the first is highlighted, so Enter chooses it. Choosing an option calls `onChange`, puts
35
+ * its label in the field and closes the list. Text that names no option goes back to the chosen
36
+ * option's label when the field is left. When nothing matches, the list says so.
37
+ *
38
+ * Without `value` it keeps its own choice, from `defaultValue`. Given `value`, even as
39
+ * `undefined`, it shows that.
40
+ */
41
+ export function Combobox<Value extends string = string>(props: ComboboxProps<Value>) {
42
+ const id = createUniqueId();
43
+ const descriptionId = `${id}-description`;
44
+ const errorId = `${id}-error`;
45
+ const labels = useLabels();
46
+ const invalid = () => props.error !== undefined;
47
+ const controlled = () => isControlled(props, "value");
48
+ const value = createControllable<Value | undefined>({
49
+ controlled,
50
+ value: () => props.value,
51
+ defaultValue: () => props.defaultValue,
52
+ onChange: (next) => {
53
+ if (next !== undefined) props.onChange?.(next);
54
+ },
55
+ });
56
+ let element: HTMLDivElement | undefined;
57
+ resetWithForm(() => element, controlled, value.reset);
58
+ // What the person typed, which narrows the list. Choosing an option puts its label in the
59
+ // field without narrowing it, so the list opens on every option again.
60
+ const [query, setQuery] = createSignal("");
61
+ const shown = createMemo(() => matchOptions(props.options, query()));
62
+ const collection = createMemo(() =>
63
+ combobox.collection<SelectOption<Value>>({
64
+ items: shown(),
65
+ itemToValue: (option) => option.value,
66
+ itemToString: (option) => option.label,
67
+ }),
68
+ );
69
+ const service = useMachine(combobox.machine, () => ({
70
+ id,
71
+ // The app's id goes on the root, where Zag looks for it by this one.
72
+ ids: { root: props.id },
73
+ collection: collection(),
74
+ value: value.value() === undefined ? [] : [value.value() as Value],
75
+ onValueChange: (details: combobox.ValueChangeDetails<SelectOption<Value>>) => {
76
+ const next = details.value[0];
77
+ if (next !== undefined) value.set(next as Value);
78
+ },
79
+ onInputValueChange: (details: combobox.InputValueChangeDetails) => {
80
+ if (details.reason === "input-change") setQuery(details.inputValue);
81
+ },
82
+ onOpenChange: (details: combobox.OpenChangeDetails) => {
83
+ if (!details.open) setQuery("");
84
+ },
85
+ // The first match is highlighted as the person types, so Enter chooses it.
86
+ inputBehavior: "autohighlight" as const,
87
+ selectionBehavior: "replace" as const,
88
+ openOnClick: true,
89
+ disabled: props.disabled,
90
+ invalid: invalid(),
91
+ placeholder: props.placeholder,
92
+ positioning: {
93
+ placement: "bottom-start" as const,
94
+ gutter: readCssPx(null, "--xds-space-1", space[1]),
95
+ sameWidth: true,
96
+ overflowPadding: readCssPx(null, "--xds-space-3", space[3]),
97
+ },
98
+ }));
99
+ const api = createMemo(() => combobox.connect(service, normalizeProps));
100
+ // Zag puts the chosen label back only when the list closes by a press outside; after Escape,
101
+ // text that names no option would stay in a field that has left it.
102
+ const input = mergeProps(() => api().getInputProps(), {
103
+ onBlur: () => {
104
+ const chosen = props.options.find((option) => option.value === value.value())?.label ?? "";
105
+ const now = combobox.connect(service, normalizeProps);
106
+ if (now.inputValue !== chosen) now.setInputValue(chosen, "script");
107
+ },
108
+ });
109
+ const root = withStyle(
110
+ () => api().getRootProps(),
111
+ () => props.style,
112
+ rootAttributes(props),
113
+ );
114
+ return (
115
+ <div
116
+ {...root}
117
+ ref={(node) => (element = node)}
118
+ class={classes("{{prefix}}-combobox", props.class)}
119
+ >
120
+ <label {...api().getLabelProps()} class={PARTS.label}>
121
+ {props.label}
122
+ </label>
123
+ <div {...api().getControlProps()} class={PARTS.control}>
124
+ <input
125
+ {...input}
126
+ aria-describedby={invalid() ? errorId : props.description ? descriptionId : undefined}
127
+ class={PARTS.input}
128
+ />
129
+ <Icon name="chevrons-up-down" size="sm" class={PARTS.icon} />
130
+ </div>
131
+ <div class={PARTS.footer}>
132
+ <Show when={!invalid() && props.description}>
133
+ <span id={descriptionId} class={PARTS.description}>
134
+ {props.description}
135
+ </span>
136
+ </Show>
137
+ <span id={errorId} class={PARTS.error} aria-live="polite">
138
+ {props.error}
139
+ </span>
140
+ </div>
141
+ {/* What a form submits: the option's value, where the field holds its label. */}
142
+ <Show when={props.name !== undefined}>
143
+ <input type="hidden" name={props.name} value={value.value() ?? ""} />
144
+ </Show>
145
+ <Portal>
146
+ <div {...api().getPositionerProps()} class={PARTS.positioner}>
147
+ {/* Zag hides it while closed. It goes at once, with no animation out: it comes and
148
+ goes as the person types. */}
149
+ <div {...api().getContentProps()} class={PARTS.content}>
150
+ <Show
151
+ when={shown().length > 0}
152
+ fallback={
153
+ <div {...api().getEmptyProps()} class={PARTS.empty}>
154
+ {props.emptyLabel ?? labels().noMatches}
155
+ </div>
156
+ }
157
+ >
158
+ <div {...api().getListProps()} class={PARTS.list}>
159
+ <For each={shown()}>
160
+ {(option, index) => {
161
+ const ids = () => selectOptionIds(id, index());
162
+ const itemProps = createItemProps(() => api().getItemProps({ item: option }));
163
+ const textProps = createItemProps(() =>
164
+ api().getItemTextProps({ item: option }),
165
+ );
166
+ const selected = createMemo(
167
+ () => api().getItemState({ item: option }).selected,
168
+ );
169
+ return (
170
+ <div
171
+ {...itemProps()}
172
+ aria-labelledby={ids().label}
173
+ aria-describedby={option.description ? ids().description : undefined}
174
+ class={PARTS.item}
175
+ >
176
+ <span class={PARTS.itemWords}>
177
+ <span {...textProps()} id={ids().label} class={PARTS.itemLabel}>
178
+ {option.label}
179
+ </span>
180
+ <Show when={option.description}>
181
+ <span id={ids().description} class={PARTS.itemDescription}>
182
+ {option.description}
183
+ </span>
184
+ </Show>
185
+ </span>
186
+ <Show when={selected()}>
187
+ <Icon name="check" size="sm" />
188
+ </Show>
189
+ </div>
190
+ );
191
+ }}
192
+ </For>
193
+ </div>
194
+ </Show>
195
+ </div>
196
+ </div>
197
+ </Portal>
198
+ </div>
199
+ );
200
+ }
@@ -0,0 +1,55 @@
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 } from "@xds/solid/base";
5
+ import { children, type Element, Show } from "solid-js";
6
+ import {
7
+ type CountBadgeBaseProps,
8
+ countBadgeAnchorClass,
9
+ countBadgeClass,
10
+ countBadgeText,
11
+ } from "./count-badge.ts";
12
+ import { classes, rootPart } from "./parts.ts";
13
+
14
+ export type CountBadgeProps = CountBadgeBaseProps &
15
+ RootProps & {
16
+ /** What the count belongs to: an icon, an avatar, a button. The badge sits on its corner. */
17
+ children?: Element;
18
+ };
19
+
20
+ const ROOT = rootPart("CountBadge");
21
+
22
+ /**
23
+ * A count of something waiting: unread messages, items in a cart. On its own it is laid out
24
+ * inline; around a child it sits on the child's top end corner.
25
+ */
26
+ export function CountBadge(props: CountBadgeProps) {
27
+ // Read once: each read of a JSX prop creates its nodes again.
28
+ const child = children(() => props.children);
29
+ // The root is the anchor around a child, and the badge itself without one.
30
+ const badge = (onChild: boolean) => (
31
+ <Show when={props.count > 0}>
32
+ <span
33
+ {...(onChild ? {} : rootAttributes(props))}
34
+ role={props.label ? "img" : undefined}
35
+ aria-label={props.label || undefined}
36
+ class={classes(!onChild && ROOT, countBadgeClass(onChild), !onChild && props.class)}
37
+ style={onChild ? undefined : props.style}
38
+ >
39
+ {countBadgeText(props.count, props.max)}
40
+ </span>
41
+ </Show>
42
+ );
43
+ return (
44
+ <Show when={child() != null} fallback={badge(false)}>
45
+ <span
46
+ {...rootAttributes(props)}
47
+ class={classes(ROOT, countBadgeAnchorClass, props.class)}
48
+ style={props.style}
49
+ >
50
+ {child()}
51
+ {badge(true)}
52
+ </span>
53
+ </Show>
54
+ );
55
+ }
@@ -0,0 +1,225 @@
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 {
5
+ createPresence,
6
+ modalPopover,
7
+ Portal,
8
+ type RootProps,
9
+ readCssPx,
10
+ rootAttributes,
11
+ space,
12
+ underlayLayerStyle,
13
+ useLabels,
14
+ withStyle,
15
+ } from "@xds/solid/base";
16
+ import * as datePicker from "@zag-js/date-picker";
17
+ import { normalizeProps, useMachine } from "@zag-js/solid";
18
+ import { createEffect, createMemo, createUniqueId, For, Show } from "solid-js";
19
+ import {
20
+ DATE_PICKER_NAV_CLASS,
21
+ type DatePickerBaseProps,
22
+ datePickerContentAttrs,
23
+ datePickerIds,
24
+ datePickerLocale,
25
+ datePickerMachineProps,
26
+ datePickerTriggerAttrs,
27
+ focusOpeningDay,
28
+ formatDay,
29
+ type IsoDate,
30
+ keepCalendarFocus,
31
+ keepDayFocused,
32
+ } from "./date-picker.ts";
33
+ import { Icon } from "./Icon.tsx";
34
+ import { classes } from "./parts.ts";
35
+
36
+ export type { IsoDate } from "./date-picker.ts";
37
+
38
+ export type DatePickerProps = DatePickerBaseProps &
39
+ RootProps & {
40
+ onChange: (value: IsoDate) => void;
41
+ };
42
+
43
+ type ClickHandler = (event: MouseEvent) => void;
44
+
45
+ /**
46
+ * A field for choosing one day. Closed, it looks like a Select: the chosen day in the locale's
47
+ * medium form, or the placeholder. Pressed, it opens a calendar of one month under itself, on
48
+ * the chosen day, or on today while none is. A press on a day, or Enter on the focused one,
49
+ * calls `onChange` with the day as `YYYY-MM-DD` and closes the calendar; Escape or a press
50
+ * outside closes it without a choice.
51
+ *
52
+ * The field is a button that says it opens a dialog and whether it is open. In the calendar the
53
+ * arrow keys move a day or a week, Page Up and Page Down a month (a year with Shift), and Home
54
+ * and End to the first and the last day of the month, never past `min` or `max`. Tab goes round
55
+ * the month buttons and the focused day. The chosen day is selected for assistive technology,
56
+ * and today is the current date.
57
+ */
58
+ export function DatePicker(props: DatePickerProps) {
59
+ const id = createUniqueId();
60
+ const ids = datePickerIds(id);
61
+ const locale = () => datePickerLocale(props.locale);
62
+ const labels = useLabels();
63
+ const service = useMachine(datePicker.machine, () => ({
64
+ ...datePickerMachineProps(props, {
65
+ id,
66
+ locale: locale(),
67
+ onChange: (value) => props.onChange(value),
68
+ gutter: readCssPx(null, "--xds-space-1", space[1]),
69
+ labels: labels(),
70
+ }),
71
+ // The app's id goes on the root, where Zag looks for it by this one.
72
+ ids: { root: props.id },
73
+ }));
74
+ const api = createMemo(() => datePicker.connect(service, normalizeProps));
75
+ const root = withStyle(
76
+ () => api().getRootProps(),
77
+ () => props.style,
78
+ rootAttributes(props),
79
+ );
80
+ let positioner: HTMLDivElement | undefined;
81
+ let surface: HTMLDivElement | undefined;
82
+ modalPopover(
83
+ () => api().open,
84
+ () => positioner,
85
+ );
86
+ const present = createPresence(
87
+ () => api().open,
88
+ () => [surface],
89
+ );
90
+ // Memos, so that the effect runs only when one of them changes, not on every change of the
91
+ // machine.
92
+ const open = createMemo(() => api().open);
93
+ const focused = createMemo(() => api().focusedValue.toString());
94
+ const month = createMemo(() => api().visibleRange.start.toString());
95
+ createEffect(
96
+ () => [open(), focused(), month()] as const,
97
+ ([isOpen]) => keepDayFocused(isOpen, surface),
98
+ );
99
+ const invalid = () => props.error !== undefined;
100
+ return (
101
+ <div {...root} class={classes("{{prefix}}-date-picker", props.class)}>
102
+ {/* A span: the field is a button, which a <label> cannot point at. */}
103
+ <span id={ids.label} class="{{prefix}}-date-picker__label">
104
+ {props.label}
105
+ </span>
106
+ {/* What Zag places the calendar against. */}
107
+ <div {...api().getControlProps()} class="{{prefix}}-date-picker__control">
108
+ <button
109
+ {...api().getTriggerProps()}
110
+ {...datePickerTriggerAttrs(props, ids)}
111
+ type="button"
112
+ onClick={(event) => {
113
+ focusOpeningDay(api(), props);
114
+ (api().getTriggerProps().onClick as ClickHandler | undefined)?.(event);
115
+ }}
116
+ class="{{prefix}}-date-picker__trigger"
117
+ >
118
+ <span id={ids.value} class="{{prefix}}-date-picker__value">
119
+ {props.value === undefined ? props.placeholder : formatDay(props.value, locale())}
120
+ </span>
121
+ <Icon name="calendar" size="sm" class="text-xds-field-placeholder" />
122
+ </button>
123
+ </div>
124
+ {/* One line under the box: the help, or the error in its place. The error stays mounted as
125
+ a live region so assistive technology announces it when it appears. */}
126
+ <div class="{{prefix}}-date-picker__footer">
127
+ <Show when={!invalid() && props.description}>
128
+ <span id={ids.description} class="{{prefix}}-date-picker__description">
129
+ {props.description}
130
+ </span>
131
+ </Show>
132
+ <span id={ids.error} class="{{prefix}}-date-picker__error" aria-live="polite">
133
+ {props.error}
134
+ </span>
135
+ </div>
136
+ {/* What a form submits. Zag gives the name to its text input, which is not drawn. */}
137
+ <Show when={props.name !== undefined}>
138
+ <input type="hidden" name={props.name} value={props.value ?? ""} />
139
+ </Show>
140
+ <Portal>
141
+ <Show when={api().open}>
142
+ {/* Takes a press outside, which then only closes the calendar. The focus stays in
143
+ the calendar until it hands it back to the field. */}
144
+ {/* oxlint-disable-next-line jsx-a11y/no-static-element-interactions -- not a control: the handler only keeps the focus where it is */}
145
+ <div
146
+ class="{{prefix}}-date-picker__underlay"
147
+ style={underlayLayerStyle(api().getPositionerProps().style)}
148
+ onMouseDown={(event) => event.preventDefault()}
149
+ />
150
+ </Show>
151
+ <div
152
+ ref={(element) => (positioner = element)}
153
+ {...api().getPositionerProps()}
154
+ class="{{prefix}}-date-picker__positioner"
155
+ >
156
+ {/* Shown until its exit animation ends; Zag would hide it as it closes. */}
157
+ {/* oxlint-disable-next-line jsx-a11y/no-static-element-interactions -- a dialog: datePickerContentAttrs gives it the role */}
158
+ <div
159
+ {...api().getContentProps()}
160
+ {...datePickerContentAttrs(ids)}
161
+ ref={(element) => (surface = element)}
162
+ hidden={!present()}
163
+ onKeyDown={(event) => keepCalendarFocus(event, surface)}
164
+ class="{{prefix}}-date-picker__content"
165
+ >
166
+ <div class="{{prefix}}-date-picker__header">
167
+ <button
168
+ {...api().getPreviousTriggerProps()}
169
+ type="button"
170
+ class={DATE_PICKER_NAV_CLASS}
171
+ >
172
+ <Icon name="chevron-left" size="sm" />
173
+ </button>
174
+ <span {...api().getRangeTextProps()} class="{{prefix}}-date-picker__heading">
175
+ {api().visibleRangeText.start}
176
+ </span>
177
+ <button {...api().getNextTriggerProps()} type="button" class={DATE_PICKER_NAV_CLASS}>
178
+ <Icon name="chevron-right" size="sm" />
179
+ </button>
180
+ </div>
181
+ <table {...api().getTableProps({ view: "day" })} class="{{prefix}}-date-picker__grid">
182
+ <thead {...api().getTableHeadProps({ view: "day" })}>
183
+ <tr {...api().getTableRowProps({ view: "day" })}>
184
+ <For each={api().weekDays} keyed={false}>
185
+ {(weekDay) => (
186
+ <th scope="col" class="{{prefix}}-date-picker__weekday">
187
+ {weekDay().narrow}
188
+ </th>
189
+ )}
190
+ </For>
191
+ </tr>
192
+ </thead>
193
+ <tbody {...api().getTableBodyProps({ view: "day" })}>
194
+ {/* Kept by position, not by the object: Zag hands out new dates on every
195
+ change, and a cell made anew would drop the focus it holds when a move is
196
+ held at `min` or `max`. */}
197
+ <For each={api().weeks} keyed={false}>
198
+ {(week) => (
199
+ <tr {...api().getTableRowProps({ view: "day" })}>
200
+ <For each={week()} keyed={false}>
201
+ {(date) => (
202
+ <td
203
+ {...api().getDayTableCellProps({ value: date() })}
204
+ class="{{prefix}}-date-picker__cell"
205
+ >
206
+ <div
207
+ {...api().getDayTableCellTriggerProps({ value: date() })}
208
+ class="{{prefix}}-date-picker__day"
209
+ >
210
+ {date().day}
211
+ </div>
212
+ </td>
213
+ )}
214
+ </For>
215
+ </tr>
216
+ )}
217
+ </For>
218
+ </tbody>
219
+ </table>
220
+ </div>
221
+ </div>
222
+ </Portal>
223
+ </div>
224
+ );
225
+ }