@xds/solid 0.0.0-stage → 0.1.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 (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -2
  3. package/dist/dom/Accordion.js +139 -0
  4. package/dist/dom/Avatar.js +59 -0
  5. package/dist/dom/AvatarStack.js +74 -0
  6. package/dist/dom/Badge.js +58 -0
  7. package/dist/dom/Banner.js +102 -0
  8. package/dist/dom/Button.js +107 -0
  9. package/dist/dom/Card.js +164 -0
  10. package/dist/dom/Checkbox.js +64 -0
  11. package/dist/dom/Chip.js +52 -0
  12. package/dist/dom/ChipBar.js +28 -0
  13. package/dist/dom/CountBadge.js +67 -0
  14. package/dist/dom/DatePicker.js +300 -0
  15. package/dist/dom/DateRangePicker.js +404 -0
  16. package/dist/dom/Defaults.js +29 -0
  17. package/dist/dom/Dialog.js +136 -0
  18. package/dist/dom/Divider.js +20 -0
  19. package/dist/dom/EmptyState.js +70 -0
  20. package/dist/dom/Icon.js +46 -0
  21. package/dist/dom/IconButton.js +72 -0
  22. package/dist/dom/ListRow.js +126 -0
  23. package/dist/dom/MediaCard.js +178 -0
  24. package/dist/dom/Menu.js +176 -0
  25. package/dist/dom/ProgressBar.js +33 -0
  26. package/dist/dom/RadioGroup.js +123 -0
  27. package/dist/dom/SearchField.js +94 -0
  28. package/dist/dom/SectionHeader.js +104 -0
  29. package/dist/dom/SegmentedControl.js +69 -0
  30. package/dist/dom/Select.js +271 -0
  31. package/dist/dom/Sidebar.js +233 -0
  32. package/dist/dom/Skeleton.js +34 -0
  33. package/dist/dom/Slider.js +115 -0
  34. package/dist/dom/Spinner.js +35 -0
  35. package/dist/dom/Switch.js +65 -0
  36. package/dist/dom/Tabs.js +80 -0
  37. package/dist/dom/Text.js +24 -0
  38. package/dist/dom/TextField.js +172 -0
  39. package/dist/dom/Thumbnail.js +119 -0
  40. package/dist/dom/Toast.js +99 -0
  41. package/dist/dom/Tooltip.js +128 -0
  42. package/dist/dom/controlled.js +13 -0
  43. package/dist/dom/index.js +40 -0
  44. package/dist/dom/modal-popover.js +22 -0
  45. package/dist/dom/picture.js +29 -0
  46. package/dist/dom/presence.js +20 -0
  47. package/dist/dom/preview.js +139 -0
  48. package/dist/dom/root.js +26 -0
  49. package/dist/dom/trigger.js +31 -0
  50. package/dist/source/Accordion.d.ts +21 -0
  51. package/dist/source/Accordion.jsx +57 -0
  52. package/dist/source/Avatar.d.ts +9 -0
  53. package/dist/source/Avatar.jsx +16 -0
  54. package/dist/source/AvatarStack.d.ts +8 -0
  55. package/dist/source/AvatarStack.jsx +22 -0
  56. package/dist/source/Badge.d.ts +13 -0
  57. package/dist/source/Badge.jsx +15 -0
  58. package/dist/source/Banner.d.ts +23 -0
  59. package/dist/source/Banner.jsx +32 -0
  60. package/dist/source/Button.d.ts +15 -0
  61. package/dist/source/Button.jsx +48 -0
  62. package/dist/source/Card.d.ts +18 -0
  63. package/dist/source/Card.jsx +46 -0
  64. package/dist/source/Checkbox.d.ts +10 -0
  65. package/dist/source/Checkbox.jsx +20 -0
  66. package/dist/source/Chip.d.ts +12 -0
  67. package/dist/source/Chip.jsx +12 -0
  68. package/dist/source/ChipBar.d.ts +12 -0
  69. package/dist/source/ChipBar.jsx +7 -0
  70. package/dist/source/CountBadge.d.ts +12 -0
  71. package/dist/source/CountBadge.jsx +17 -0
  72. package/dist/source/DatePicker.d.ts +20 -0
  73. package/dist/source/DatePicker.jsx +109 -0
  74. package/dist/source/DateRangePicker.d.ts +24 -0
  75. package/dist/source/DateRangePicker.jsx +150 -0
  76. package/dist/source/Defaults.d.ts +23 -0
  77. package/dist/source/Defaults.jsx +12 -0
  78. package/dist/source/Dialog.d.ts +21 -0
  79. package/dist/source/Dialog.jsx +58 -0
  80. package/dist/source/Divider.d.ts +4 -0
  81. package/dist/source/Divider.jsx +5 -0
  82. package/dist/source/EmptyState.d.ts +12 -0
  83. package/dist/source/EmptyState.jsx +16 -0
  84. package/dist/source/Icon.d.ts +8 -0
  85. package/dist/source/Icon.jsx +11 -0
  86. package/dist/source/IconButton.d.ts +13 -0
  87. package/dist/source/IconButton.jsx +36 -0
  88. package/dist/source/ListRow.d.ts +21 -0
  89. package/dist/source/ListRow.jsx +38 -0
  90. package/dist/source/MediaCard.d.ts +20 -0
  91. package/dist/source/MediaCard.jsx +47 -0
  92. package/dist/source/Menu.d.ts +19 -0
  93. package/dist/source/Menu.jsx +99 -0
  94. package/dist/source/ProgressBar.d.ts +8 -0
  95. package/dist/source/ProgressBar.jsx +8 -0
  96. package/dist/source/RadioGroup.d.ts +15 -0
  97. package/dist/source/RadioGroup.jsx +57 -0
  98. package/dist/source/SearchField.d.ts +15 -0
  99. package/dist/source/SearchField.jsx +39 -0
  100. package/dist/source/SectionHeader.d.ts +14 -0
  101. package/dist/source/SectionHeader.jsx +32 -0
  102. package/dist/source/SegmentedControl.d.ts +12 -0
  103. package/dist/source/SegmentedControl.jsx +21 -0
  104. package/dist/source/Select.d.ts +18 -0
  105. package/dist/source/Select.jsx +139 -0
  106. package/dist/source/Sidebar.d.ts +22 -0
  107. package/dist/source/Sidebar.jsx +65 -0
  108. package/dist/source/Skeleton.d.ts +11 -0
  109. package/dist/source/Skeleton.jsx +9 -0
  110. package/dist/source/Slider.d.ts +13 -0
  111. package/dist/source/Slider.jsx +69 -0
  112. package/dist/source/Spinner.d.ts +9 -0
  113. package/dist/source/Spinner.jsx +12 -0
  114. package/dist/source/Switch.d.ts +13 -0
  115. package/dist/source/Switch.jsx +18 -0
  116. package/dist/source/Tabs.d.ts +14 -0
  117. package/dist/source/Tabs.jsx +31 -0
  118. package/dist/source/Text.d.ts +10 -0
  119. package/dist/source/Text.jsx +14 -0
  120. package/dist/source/TextField.d.ts +22 -0
  121. package/dist/source/TextField.jsx +73 -0
  122. package/dist/source/Thumbnail.d.ts +9 -0
  123. package/dist/source/Thumbnail.jsx +34 -0
  124. package/dist/source/Toast.d.ts +16 -0
  125. package/dist/source/Toast.jsx +42 -0
  126. package/dist/source/Tooltip.d.ts +28 -0
  127. package/dist/source/Tooltip.jsx +52 -0
  128. package/dist/source/controlled.d.ts +4 -0
  129. package/dist/source/controlled.js +11 -0
  130. package/dist/source/index.d.ts +40 -0
  131. package/dist/source/index.js +39 -0
  132. package/dist/source/modal-popover.d.ts +7 -0
  133. package/dist/source/modal-popover.js +15 -0
  134. package/dist/source/picture.d.ts +20 -0
  135. package/dist/source/picture.js +13 -0
  136. package/dist/source/presence.d.ts +7 -0
  137. package/dist/source/presence.js +13 -0
  138. package/dist/source/preview.d.ts +6 -0
  139. package/dist/source/preview.jsx +110 -0
  140. package/dist/source/root.d.ts +25 -0
  141. package/dist/source/root.js +19 -0
  142. package/dist/source/trigger.d.ts +18 -0
  143. package/dist/source/trigger.js +18 -0
  144. package/package.json +63 -4
  145. package/page.css +20 -0
  146. package/styles.css +3353 -0
  147. package/tailwind.css +2665 -0
@@ -0,0 +1,164 @@
1
+ import { className, createComponent, delegateEvents, dynamic, effect, insert, memo, readShallow, setAttribute, style, template } from "@solidjs/web";
2
+ import { CARD_PARTS, cardClass, cardMediaClass, classes, rootPart } from "@xds/core";
3
+ import { Show, children } from "solid-js";
4
+ // packages/ui-solid/src/Card.tsx
5
+ var _tmpl$ = /* @__PURE__ */ template(`<div>`);
6
+ var _tmpl$2 = /* @__PURE__ */ template(`<button type=button>`);
7
+ var _tmpl$3 = /* @__PURE__ */ template(`<section>`);
8
+ var ROOT = rootPart("Card");
9
+ /**
10
+ * A surface that groups related content. A hairline outline and a trace of shadow lift it off
11
+ * the page; in dark mode, where shadows barely show, the lighter fill does that. `title`
12
+ * renders as a heading; `actions` sit across from it.
13
+ */
14
+ function Card(props) {
15
+ const media = children(() => props.media);
16
+ const actions = children(() => props.actions);
17
+ const body = children(() => props.children);
18
+ const pressable = () => props.onPress !== void 0;
19
+ const Header = dynamic(() => pressable() ? "span" : "header");
20
+ const Box = dynamic(() => pressable() ? "span" : "div");
21
+ const Title = dynamic(() => pressable() ? "span" : "h2");
22
+ const Line = dynamic(() => pressable() ? "span" : "p");
23
+ const surface = () => classes(ROOT, cardClass({
24
+ selected: props.selected,
25
+ flush: props.flush,
26
+ pressable: pressable()
27
+ }), props.class);
28
+ const parts = () => [
29
+ createComponent(Show, {
30
+ get when() {
31
+ return media() != null;
32
+ },
33
+ get children() {
34
+ return createComponent(Box, {
35
+ get "class"() {
36
+ return cardMediaClass(props.flush);
37
+ },
38
+ get children() {
39
+ return media();
40
+ }
41
+ });
42
+ }
43
+ }),
44
+ createComponent(Show, {
45
+ get when() {
46
+ return props.title || actions() != null && !pressable();
47
+ },
48
+ get children() {
49
+ return createComponent(Header, {
50
+ get "class"() {
51
+ return CARD_PARTS.header;
52
+ },
53
+ get children() {
54
+ return [createComponent(Box, {
55
+ get "class"() {
56
+ return CARD_PARTS.heading;
57
+ },
58
+ get children() {
59
+ return [createComponent(Show, {
60
+ get when() {
61
+ return props.title;
62
+ },
63
+ children: (title) => createComponent(Title, {
64
+ get "class"() {
65
+ return CARD_PARTS.title;
66
+ },
67
+ get children() {
68
+ return title();
69
+ }
70
+ })
71
+ }), createComponent(Show, {
72
+ get when() {
73
+ return props.description;
74
+ },
75
+ children: (description) => createComponent(Line, {
76
+ get "class"() {
77
+ return CARD_PARTS.description;
78
+ },
79
+ get children() {
80
+ return description();
81
+ }
82
+ })
83
+ })];
84
+ }
85
+ }), createComponent(Show, {
86
+ get when() {
87
+ return memo(() => {
88
+ return actions() != null;
89
+ })() && !pressable();
90
+ },
91
+ get children() {
92
+ var _el$ = _tmpl$();
93
+ insert(_el$, actions);
94
+ effect(() => readShallow(CARD_PARTS.actions), (_v$, _$p) => {
95
+ className(_el$, _v$, _$p);
96
+ });
97
+ return _el$;
98
+ }
99
+ })];
100
+ }
101
+ });
102
+ }
103
+ }),
104
+ memo(body)
105
+ ];
106
+ const content = () => createComponent(Show, {
107
+ get when() {
108
+ return props.flush;
109
+ },
110
+ get fallback() {
111
+ return parts();
112
+ },
113
+ get children() {
114
+ return createComponent(Box, {
115
+ get "class"() {
116
+ return CARD_PARTS.flush;
117
+ },
118
+ get children() {
119
+ return parts();
120
+ }
121
+ });
122
+ }
123
+ });
124
+ return createComponent(Show, {
125
+ get when() {
126
+ return pressable();
127
+ },
128
+ get fallback() {
129
+ var _el$3 = _tmpl$3();
130
+ insert(_el$3, content);
131
+ effect(() => {
132
+ return {
133
+ e: props.selected ? "true" : void 0,
134
+ t: readShallow(surface()),
135
+ a: readShallow(props.style)
136
+ };
137
+ }, ({ e, t, a }, _p$) => {
138
+ e !== _p$?.e && setAttribute(_el$3, "aria-current", e);
139
+ className(_el$3, t, _p$?.t);
140
+ style(_el$3, a, _p$?.a);
141
+ });
142
+ return _el$3;
143
+ },
144
+ get children() {
145
+ var _el$2 = _tmpl$2();
146
+ _el$2._$$click = () => props.onPress?.();
147
+ insert(_el$2, content);
148
+ effect(() => {
149
+ return {
150
+ e: props.selected === void 0 ? void 0 : props.selected ? "true" : "false",
151
+ t: readShallow(surface()),
152
+ a: readShallow(props.style)
153
+ };
154
+ }, ({ e, t, a }, _p$) => {
155
+ e !== _p$?.e && setAttribute(_el$2, "aria-pressed", e);
156
+ className(_el$2, t, _p$?.t);
157
+ style(_el$2, a, _p$?.a);
158
+ });
159
+ return _el$2;
160
+ }
161
+ });
162
+ }
163
+ delegateEvents(["click"]);
164
+ export { Card };
@@ -0,0 +1,64 @@
1
+ import { keepChecked } from "./controlled.js";
2
+ import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
3
+ import { CHECKBOX_MARK, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMarkClass, classes, rootPart } from "@xds/core";
4
+ import { Show } from "solid-js";
5
+ // packages/ui-solid/src/Checkbox.tsx
6
+ var _tmpl$ = /* @__PURE__ */ template(`<span>`);
7
+ var _tmpl$2 = /* @__PURE__ */ template(`<label><input type=checkbox class="peer sr-only"><span><svg viewBox="0 0 16 16"fill=none aria-hidden=true><path stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>`);
8
+ var ROOT = rootPart("Checkbox");
9
+ /**
10
+ * A choice that is applied later, with the form it belongs to. A native checkbox: the input is
11
+ * hidden and the box is drawn beside it.
12
+ */
13
+ function Checkbox(props) {
14
+ var _el$ = _tmpl$2();
15
+ var _el$2 = _el$.firstChild;
16
+ var _el$3 = _el$2.nextSibling;
17
+ var _el$4 = _el$3.firstChild;
18
+ var _el$5 = _el$4.firstChild;
19
+ _el$2.addEventListener("change", (event) => {
20
+ props.onChange(event.currentTarget.checked);
21
+ keepChecked(event.currentTarget, () => props.checked);
22
+ });
23
+ setAttribute(_el$5, "d", CHECKBOX_MARK);
24
+ insert(_el$, createComponent(Show, {
25
+ get when() {
26
+ return props.label;
27
+ },
28
+ get children() {
29
+ var _el$6 = _tmpl$();
30
+ insert(_el$6, () => {
31
+ return props.label;
32
+ });
33
+ effect(() => readShallow(checkboxLabelClass), (_v$, _$p) => {
34
+ className(_el$6, _v$, _$p);
35
+ });
36
+ return _el$6;
37
+ }
38
+ }), null);
39
+ effect(() => {
40
+ return {
41
+ e: readShallow(classes(ROOT, checkboxClass, props.class)),
42
+ t: readShallow(props.style),
43
+ a: props["aria-label"],
44
+ o: props.checked,
45
+ i: props.checked,
46
+ n: props.disabled,
47
+ s: props.name || void 0,
48
+ h: readShallow(checkboxBoxClass),
49
+ r: readShallow(checkboxMarkClass)
50
+ };
51
+ }, ({ e, t, a, o, i, n, s, h, r }, _p$) => {
52
+ className(_el$, e, _p$?.e);
53
+ style(_el$, t, _p$?.t);
54
+ a !== _p$?.a && setAttribute(_el$2, "aria-label", a);
55
+ _el$2.checked = o;
56
+ i !== _p$?.i && (_el$2.defaultChecked = i);
57
+ n !== _p$?.n && setAttribute(_el$2, "disabled", n);
58
+ s !== _p$?.s && setAttribute(_el$2, "name", s);
59
+ className(_el$3, h, _p$?.h);
60
+ className(_el$4, r, _p$?.r);
61
+ });
62
+ return _el$;
63
+ }
64
+ export { Checkbox };
@@ -0,0 +1,52 @@
1
+ import { Icon } from "./Icon.js";
2
+ import { className, createComponent, delegateEvents, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
3
+ import { chipClass, chipIcon, classes, rootPart } from "@xds/core";
4
+ import { Show } from "solid-js";
5
+ // packages/ui-solid/src/Chip.tsx
6
+ var _tmpl$ = /* @__PURE__ */ template(`<button type=button><!><!>`);
7
+ var ROOT = rootPart("Chip");
8
+ /**
9
+ * A choice that filters what is shown. Unlike a Badge it is pressed. A selected chip is tinted,
10
+ * outlined and marked with a check, so the state does not depend on color.
11
+ *
12
+ * It is a toggle button: assistive technology hears whether it is pressed.
13
+ */
14
+ function Chip(props) {
15
+ var _el$ = _tmpl$();
16
+ var _el$2 = _el$.firstChild;
17
+ var _el$3 = _el$2.nextSibling;
18
+ _el$._$$click = () => props.onPress?.();
19
+ insert(_el$, createComponent(Show, {
20
+ get when() {
21
+ return chipIcon({
22
+ selected: props.selected,
23
+ iconStart: props.iconStart
24
+ });
25
+ },
26
+ children: (name) => createComponent(Icon, {
27
+ get name() {
28
+ return name();
29
+ },
30
+ size: "sm"
31
+ })
32
+ }), _el$2);
33
+ insert(_el$, () => {
34
+ return props.label;
35
+ }, _el$3);
36
+ effect(() => {
37
+ return {
38
+ e: props.selected ? "true" : "false",
39
+ t: props.disabled,
40
+ a: readShallow(classes(ROOT, chipClass(props.selected), props.class)),
41
+ o: readShallow(props.style)
42
+ };
43
+ }, ({ e, t, a, o }, _p$) => {
44
+ e !== _p$?.e && setAttribute(_el$, "aria-pressed", e);
45
+ t !== _p$?.t && setAttribute(_el$, "disabled", t);
46
+ className(_el$, a, _p$?.a);
47
+ style(_el$, o, _p$?.o);
48
+ });
49
+ return _el$;
50
+ }
51
+ delegateEvents(["click"]);
52
+ export { Chip };
@@ -0,0 +1,28 @@
1
+ import { className, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
2
+ import { chipBarClass, classes, rootPart } from "@xds/core";
3
+ // packages/ui-solid/src/ChipBar.tsx
4
+ var _tmpl$ = /* @__PURE__ */ template(`<div role=group>`);
5
+ var ROOT = rootPart("ChipBar");
6
+ /**
7
+ * One row of chips. It scrolls sideways when the chips do not fit and never wraps, so the
8
+ * content under it stays where it is.
9
+ */
10
+ function ChipBar(props) {
11
+ var _el$ = _tmpl$();
12
+ insert(_el$, () => {
13
+ return props.children;
14
+ });
15
+ effect(() => {
16
+ return {
17
+ e: props.label,
18
+ t: readShallow(classes(ROOT, chipBarClass, props.class)),
19
+ a: readShallow(props.style)
20
+ };
21
+ }, ({ e, t, a }, _p$) => {
22
+ e !== _p$?.e && setAttribute(_el$, "aria-label", e);
23
+ className(_el$, t, _p$?.t);
24
+ style(_el$, a, _p$?.a);
25
+ });
26
+ return _el$;
27
+ }
28
+ export { ChipBar };
@@ -0,0 +1,67 @@
1
+ import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
2
+ import { classes, countBadgeAnchorClass, countBadgeClass, countBadgeText, rootPart } from "@xds/core";
3
+ import { Show, children } from "solid-js";
4
+ // packages/ui-solid/src/CountBadge.tsx
5
+ var _tmpl$ = /* @__PURE__ */ template(`<span>`);
6
+ var _tmpl$2 = /* @__PURE__ */ template(`<span><!><!>`);
7
+ var ROOT = rootPart("CountBadge");
8
+ /**
9
+ * A count of something waiting: unread messages, items in a cart. On its own it is laid out
10
+ * inline; around a child it sits on the child's top end corner.
11
+ */
12
+ function CountBadge(props) {
13
+ const child = children(() => props.children);
14
+ const badge = (onChild) => createComponent(Show, {
15
+ get when() {
16
+ return props.count > 0;
17
+ },
18
+ get children() {
19
+ var _el$ = _tmpl$();
20
+ insert(_el$, () => {
21
+ return countBadgeText(props.count, props.max);
22
+ });
23
+ effect(() => {
24
+ return {
25
+ e: props.label ? "img" : void 0,
26
+ t: props.label || void 0,
27
+ a: readShallow(classes(!onChild && ROOT, countBadgeClass(onChild), !onChild && props.class)),
28
+ o: readShallow(onChild ? void 0 : props.style)
29
+ };
30
+ }, ({ e, t, a, o }, _p$) => {
31
+ e !== _p$?.e && setAttribute(_el$, "role", e);
32
+ t !== _p$?.t && setAttribute(_el$, "aria-label", t);
33
+ className(_el$, a, _p$?.a);
34
+ style(_el$, o, _p$?.o);
35
+ });
36
+ return _el$;
37
+ }
38
+ });
39
+ return createComponent(Show, {
40
+ get when() {
41
+ return child() != null;
42
+ },
43
+ get fallback() {
44
+ return badge(false);
45
+ },
46
+ get children() {
47
+ var _el$2 = _tmpl$2();
48
+ var _el$3 = _el$2.firstChild;
49
+ var _el$4 = _el$3.nextSibling;
50
+ insert(_el$2, child, _el$3);
51
+ insert(_el$2, () => {
52
+ return badge(true);
53
+ }, _el$4);
54
+ effect(() => {
55
+ return {
56
+ e: readShallow(classes(ROOT, countBadgeAnchorClass, props.class)),
57
+ t: readShallow(props.style)
58
+ };
59
+ }, ({ e, t }, _p$) => {
60
+ className(_el$2, e, _p$?.e);
61
+ style(_el$2, t, _p$?.t);
62
+ });
63
+ return _el$2;
64
+ }
65
+ });
66
+ }
67
+ export { CountBadge };
@@ -0,0 +1,300 @@
1
+ import { Icon } from "./Icon.js";
2
+ import { modalPopover } from "./modal-popover.js";
3
+ import { createPresence } from "./presence.js";
4
+ import { withStyle } from "./root.js";
5
+ import { Portal, createComponent, delegateEvents, effect, insert, memo, ref, setAttribute, spread, template } from "@solidjs/web";
6
+ import { DATE_PICKER_NAV_CLASS, classes, datePickerContentAttrs, datePickerIds, datePickerLocale, datePickerMachineProps, datePickerTriggerAttrs, focusOpeningDay, formatDay, keepCalendarFocus, keepDayFocused } from "@xds/core";
7
+ import { normalizeProps, useMachine } from "@zag-js/solid";
8
+ import { For, Show, createEffect, createMemo, createUniqueId } from "solid-js";
9
+ import * as datePicker from "@zag-js/date-picker";
10
+ // packages/ui-solid/src/DatePicker.tsx
11
+ var _tmpl$ = /* @__PURE__ */ template(`<span class=xds-date-picker__error>`);
12
+ var _tmpl$2 = /* @__PURE__ */ template(`<div class=xds-date-picker__footer>`);
13
+ var _tmpl$3 = /* @__PURE__ */ template(`<input type=hidden>`);
14
+ var _tmpl$4 = /* @__PURE__ */ template(`<div class=xds-date-picker__underlay>`);
15
+ var _tmpl$5 = /* @__PURE__ */ template(`<div><div><div class=xds-date-picker__header><button></button><span></span><button></button></div><table><thead><tr></tr></thead><tbody>`);
16
+ var _tmpl$6 = /* @__PURE__ */ template(`<div><span class=xds-date-picker__label></span><div><button><span class=xds-date-picker__value></span></button></div><!><!><!>`);
17
+ var _tmpl$7 = /* @__PURE__ */ template(`<span class=xds-date-picker__description>`);
18
+ var _tmpl$8 = /* @__PURE__ */ template(`<th scope=col class=xds-date-picker__weekday>`);
19
+ var _tmpl$9 = /* @__PURE__ */ template(`<tr>`);
20
+ var _tmpl$10 = /* @__PURE__ */ template(`<td><div>`);
21
+ /**
22
+ * A field for choosing one day. Closed, it looks like a Select: the chosen day in the locale's
23
+ * medium form, or the placeholder. Pressed, it opens a calendar of one month under itself, on
24
+ * the chosen day, or on today while none is. A press on a day, or Enter on the focused one,
25
+ * calls `onChange` with the day as `YYYY-MM-DD` and closes the calendar; Escape or a press
26
+ * outside closes it without a choice.
27
+ *
28
+ * The field is a button that says it opens a dialog and whether it is open. In the calendar the
29
+ * arrow keys move a day or a week, Page Up and Page Down a month (a year with Shift), and Home
30
+ * and End to the first and the last day of the month, never past `min` or `max`. Tab goes round
31
+ * the month buttons and the focused day. The chosen day is selected for assistive technology,
32
+ * and today is the current date.
33
+ */
34
+ function DatePicker(props) {
35
+ const id = createUniqueId();
36
+ const ids = datePickerIds(id);
37
+ const locale = datePickerLocale();
38
+ const service = useMachine(datePicker.machine, () => datePickerMachineProps(props, {
39
+ id,
40
+ locale,
41
+ onChange: (value) => props.onChange(value)
42
+ }));
43
+ const api = createMemo(() => datePicker.connect(service, normalizeProps));
44
+ const root = withStyle(() => api().getRootProps(), () => props.style);
45
+ let positioner;
46
+ let surface;
47
+ modalPopover(() => api().open, () => positioner);
48
+ const present = createPresence(() => api().open, () => [surface]);
49
+ const open = createMemo(() => api().open);
50
+ const focused = createMemo(() => api().focusedValue.toString());
51
+ const month = createMemo(() => api().visibleRange.start.toString());
52
+ createEffect(() => [
53
+ open(),
54
+ focused(),
55
+ month()
56
+ ], ([isOpen]) => keepDayFocused(isOpen, surface));
57
+ const invalid = () => props.error !== void 0;
58
+ var _el$ = _tmpl$6();
59
+ var _el$2 = _el$.firstChild;
60
+ var _el$3 = _el$2.nextSibling;
61
+ var _el$4 = _el$3.firstChild;
62
+ var _el$5 = _el$4.firstChild;
63
+ var _el$8 = _el$3.nextSibling;
64
+ var _el$10 = _el$8.nextSibling;
65
+ var _el$22 = _el$10.nextSibling;
66
+ spread(_el$, [root, { get "class"() {
67
+ return classes("xds-date-picker", props.class);
68
+ } }], true);
69
+ insert(_el$2, () => {
70
+ return props.label;
71
+ });
72
+ spread(_el$3, [() => {
73
+ return api().getControlProps();
74
+ }, { class: "xds-date-picker__control" }], true);
75
+ spread(_el$4, [
76
+ () => {
77
+ return api().getTriggerProps();
78
+ },
79
+ () => {
80
+ return datePickerTriggerAttrs(props, ids);
81
+ },
82
+ {
83
+ type: "button",
84
+ onClick: (event) => {
85
+ focusOpeningDay(api(), props);
86
+ api().getTriggerProps().onClick?.(event);
87
+ },
88
+ class: "xds-date-picker__trigger"
89
+ }
90
+ ], true);
91
+ insert(_el$5, (() => {
92
+ var _c$ = memo(() => {
93
+ return props.value === void 0;
94
+ });
95
+ return () => {
96
+ return _c$() ? props.placeholder : formatDay(props.value, locale);
97
+ };
98
+ })());
99
+ insert(_el$4, createComponent(Icon, {
100
+ name: "calendar",
101
+ size: "sm",
102
+ class: "text-xds-field-placeholder"
103
+ }), null);
104
+ insert(_el$, createComponent(Show, {
105
+ get when() {
106
+ return invalid() || props.description;
107
+ },
108
+ get children() {
109
+ var _el$6 = _tmpl$2();
110
+ insert(_el$6, createComponent(Show, {
111
+ get when() {
112
+ return invalid();
113
+ },
114
+ get fallback() {
115
+ var _el$23 = _tmpl$7();
116
+ insert(_el$23, () => {
117
+ return props.description;
118
+ });
119
+ effect(() => ids.description, (_v$) => {
120
+ setAttribute(_el$23, "id", _v$);
121
+ });
122
+ return _el$23;
123
+ },
124
+ get children() {
125
+ var _el$7 = _tmpl$();
126
+ insert(_el$7, () => {
127
+ return props.error;
128
+ });
129
+ effect(() => ids.error, (_v$) => {
130
+ setAttribute(_el$7, "id", _v$);
131
+ });
132
+ return _el$7;
133
+ }
134
+ }));
135
+ return _el$6;
136
+ }
137
+ }), _el$8);
138
+ insert(_el$, createComponent(Show, {
139
+ get when() {
140
+ return props.name !== void 0;
141
+ },
142
+ get children() {
143
+ var _el$9 = _tmpl$3();
144
+ effect(() => {
145
+ return {
146
+ e: props.name,
147
+ t: props.value ?? ""
148
+ };
149
+ }, ({ e, t }, _p$) => {
150
+ e !== _p$?.e && setAttribute(_el$9, "name", e);
151
+ _el$9.value = t ?? "";
152
+ });
153
+ return _el$9;
154
+ }
155
+ }), _el$10);
156
+ insert(_el$, createComponent(Portal, { get children() {
157
+ return [createComponent(Show, {
158
+ get when() {
159
+ return api().open;
160
+ },
161
+ get children() {
162
+ var _el$11 = _tmpl$4();
163
+ _el$11._$$mousedown = (event) => event.preventDefault();
164
+ return _el$11;
165
+ }
166
+ }), (() => {
167
+ var _el$12 = _tmpl$5();
168
+ var _el$13 = _el$12.firstChild;
169
+ var _el$14 = _el$13.firstChild;
170
+ var _el$15 = _el$14.firstChild;
171
+ var _el$16 = _el$15.nextSibling;
172
+ var _el$17 = _el$16.nextSibling;
173
+ var _el$18 = _el$14.nextSibling;
174
+ var _el$19 = _el$18.firstChild;
175
+ var _el$20 = _el$19.firstChild;
176
+ var _el$21 = _el$19.nextSibling;
177
+ spread(_el$12, [() => {
178
+ return api().getPositionerProps();
179
+ }, { class: "xds-date-picker__positioner" }], true);
180
+ ref(() => {
181
+ return (element) => positioner = element;
182
+ }, _el$12);
183
+ spread(_el$13, [
184
+ () => {
185
+ return api().getContentProps();
186
+ },
187
+ () => {
188
+ return datePickerContentAttrs(ids);
189
+ },
190
+ {
191
+ get hidden() {
192
+ return !present();
193
+ },
194
+ onKeyDown: (event) => keepCalendarFocus(event, surface),
195
+ class: "xds-date-picker__content"
196
+ }
197
+ ], true);
198
+ ref(() => {
199
+ return (element) => surface = element;
200
+ }, _el$13);
201
+ spread(_el$15, [() => {
202
+ return api().getPreviousTriggerProps();
203
+ }, {
204
+ type: "button",
205
+ class: DATE_PICKER_NAV_CLASS
206
+ }], true);
207
+ insert(_el$15, createComponent(Icon, {
208
+ name: "chevron-left",
209
+ size: "sm"
210
+ }));
211
+ spread(_el$16, [() => {
212
+ return api().getRangeTextProps();
213
+ }, { class: "xds-date-picker__heading" }], true);
214
+ insert(_el$16, () => {
215
+ return api().visibleRangeText.start;
216
+ });
217
+ spread(_el$17, [() => {
218
+ return api().getNextTriggerProps();
219
+ }, {
220
+ type: "button",
221
+ class: DATE_PICKER_NAV_CLASS
222
+ }], true);
223
+ insert(_el$17, createComponent(Icon, {
224
+ name: "chevron-right",
225
+ size: "sm"
226
+ }));
227
+ spread(_el$18, [() => {
228
+ return api().getTableProps({ view: "day" });
229
+ }, { class: "xds-date-picker__grid" }], true);
230
+ spread(_el$19, () => {
231
+ return api().getTableHeadProps({ view: "day" });
232
+ }, true);
233
+ spread(_el$20, () => {
234
+ return api().getTableRowProps({ view: "day" });
235
+ }, true);
236
+ insert(_el$20, createComponent(For, {
237
+ get each() {
238
+ return api().weekDays;
239
+ },
240
+ keyed: false,
241
+ children: (weekDay) => (() => {
242
+ var _el$24 = _tmpl$8();
243
+ insert(_el$24, () => {
244
+ return weekDay().narrow;
245
+ });
246
+ return _el$24;
247
+ })()
248
+ }));
249
+ spread(_el$21, () => {
250
+ return api().getTableBodyProps({ view: "day" });
251
+ }, true);
252
+ insert(_el$21, createComponent(For, {
253
+ get each() {
254
+ return api().weeks;
255
+ },
256
+ keyed: false,
257
+ children: (week) => (() => {
258
+ var _el$25 = _tmpl$9();
259
+ spread(_el$25, () => {
260
+ return api().getTableRowProps({ view: "day" });
261
+ }, true);
262
+ insert(_el$25, createComponent(For, {
263
+ get each() {
264
+ return week();
265
+ },
266
+ keyed: false,
267
+ children: (date) => (() => {
268
+ var _el$26 = _tmpl$10();
269
+ var _el$27 = _el$26.firstChild;
270
+ spread(_el$26, [() => {
271
+ return api().getDayTableCellProps({ value: date() });
272
+ }, { class: "xds-date-picker__cell" }], true);
273
+ spread(_el$27, [() => {
274
+ return api().getDayTableCellTriggerProps({ value: date() });
275
+ }, { class: "xds-date-picker__day" }], true);
276
+ insert(_el$27, () => {
277
+ return date().day;
278
+ });
279
+ return _el$26;
280
+ })()
281
+ }));
282
+ return _el$25;
283
+ })()
284
+ }));
285
+ return _el$12;
286
+ })()];
287
+ } }), _el$22);
288
+ effect(() => {
289
+ return {
290
+ e: ids.label,
291
+ t: ids.value
292
+ };
293
+ }, ({ e, t }, _p$) => {
294
+ e !== _p$?.e && setAttribute(_el$2, "id", e);
295
+ t !== _p$?.t && setAttribute(_el$5, "id", t);
296
+ });
297
+ return _el$;
298
+ }
299
+ delegateEvents(["mousedown"]);
300
+ export { DatePicker };