@gemologic/sheen 0.1.0-rc.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 (271) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +32 -0
  3. package/dist/core.d.ts +52 -0
  4. package/dist/core.js +29 -0
  5. package/dist/formisch.d.ts +5 -0
  6. package/dist/formisch.js +22 -0
  7. package/dist/forms.d.ts +34 -0
  8. package/dist/forms.js +18 -0
  9. package/dist/index.d.ts +144 -0
  10. package/dist/index.js +75 -0
  11. package/dist/layout/Layout.d.ts +28 -0
  12. package/dist/layout/Layout.js +121 -0
  13. package/dist/metadata.d.ts +46 -0
  14. package/dist/metadata.js +47 -0
  15. package/dist/navigation.d.ts +30 -0
  16. package/dist/navigation.js +16 -0
  17. package/dist/overlays.d.ts +28 -0
  18. package/dist/overlays.js +15 -0
  19. package/dist/primitives/Accordion.d.ts +16 -0
  20. package/dist/primitives/Accordion.js +223 -0
  21. package/dist/primitives/ActivityTimeline.d.ts +20 -0
  22. package/dist/primitives/ActivityTimeline.js +104 -0
  23. package/dist/primitives/AlertDialog.d.ts +7 -0
  24. package/dist/primitives/AlertDialog.js +8 -0
  25. package/dist/primitives/Avatar.d.ts +22 -0
  26. package/dist/primitives/Avatar.js +115 -0
  27. package/dist/primitives/Breadcrumb.d.ts +11 -0
  28. package/dist/primitives/Breadcrumb.js +66 -0
  29. package/dist/primitives/Button.d.ts +11 -0
  30. package/dist/primitives/Button.js +59 -0
  31. package/dist/primitives/ButtonGroup.d.ts +7 -0
  32. package/dist/primitives/ButtonGroup.js +33 -0
  33. package/dist/primitives/Checkbox.d.ts +22 -0
  34. package/dist/primitives/Checkbox.js +93 -0
  35. package/dist/primitives/CheckboxGroup.d.ts +18 -0
  36. package/dist/primitives/CheckboxGroup.js +122 -0
  37. package/dist/primitives/Collapsible.d.ts +9 -0
  38. package/dist/primitives/Collapsible.js +72 -0
  39. package/dist/primitives/Combobox.d.ts +41 -0
  40. package/dist/primitives/Combobox.js +684 -0
  41. package/dist/primitives/CommandPalette.d.ts +42 -0
  42. package/dist/primitives/CommandPalette.js +319 -0
  43. package/dist/primitives/ConfirmDialog.d.ts +11 -0
  44. package/dist/primitives/ConfirmDialog.js +42 -0
  45. package/dist/primitives/ContextMenu.d.ts +16 -0
  46. package/dist/primitives/ContextMenu.js +132 -0
  47. package/dist/primitives/DescriptionList.d.ts +11 -0
  48. package/dist/primitives/DescriptionList.js +44 -0
  49. package/dist/primitives/Dialog.d.ts +21 -0
  50. package/dist/primitives/Dialog.js +141 -0
  51. package/dist/primitives/Drawer.d.ts +9 -0
  52. package/dist/primitives/Drawer.js +21 -0
  53. package/dist/primitives/DropdownMenu.d.ts +59 -0
  54. package/dist/primitives/DropdownMenu.js +441 -0
  55. package/dist/primitives/EditableTextField.d.ts +11 -0
  56. package/dist/primitives/EditableTextField.js +126 -0
  57. package/dist/primitives/EmptyState.d.ts +7 -0
  58. package/dist/primitives/EmptyState.js +45 -0
  59. package/dist/primitives/Field.d.ts +18 -0
  60. package/dist/primitives/Field.js +72 -0
  61. package/dist/primitives/FileDropzone.d.ts +40 -0
  62. package/dist/primitives/FileDropzone.js +261 -0
  63. package/dist/primitives/IconButton.d.ts +8 -0
  64. package/dist/primitives/IconButton.js +34 -0
  65. package/dist/primitives/Input.d.ts +7 -0
  66. package/dist/primitives/Input.js +55 -0
  67. package/dist/primitives/InputGroup.d.ts +7 -0
  68. package/dist/primitives/InputGroup.js +73 -0
  69. package/dist/primitives/Link.d.ts +7 -0
  70. package/dist/primitives/Link.js +35 -0
  71. package/dist/primitives/LinkTooltip.d.ts +11 -0
  72. package/dist/primitives/LinkTooltip.js +88 -0
  73. package/dist/primitives/NavList.d.ts +17 -0
  74. package/dist/primitives/NavList.js +143 -0
  75. package/dist/primitives/Notice.d.ts +8 -0
  76. package/dist/primitives/Notice.js +64 -0
  77. package/dist/primitives/NumberField.d.ts +22 -0
  78. package/dist/primitives/NumberField.js +177 -0
  79. package/dist/primitives/Pagination.d.ts +12 -0
  80. package/dist/primitives/Pagination.js +127 -0
  81. package/dist/primitives/Popover.d.ts +12 -0
  82. package/dist/primitives/Popover.js +103 -0
  83. package/dist/primitives/Progress.d.ts +17 -0
  84. package/dist/primitives/Progress.js +98 -0
  85. package/dist/primitives/RadioGroup.d.ts +19 -0
  86. package/dist/primitives/RadioGroup.js +173 -0
  87. package/dist/primitives/Resizable.d.ts +36 -0
  88. package/dist/primitives/Resizable.js +196 -0
  89. package/dist/primitives/ScrollArea.d.ts +6 -0
  90. package/dist/primitives/ScrollArea.js +178 -0
  91. package/dist/primitives/SearchInput.d.ts +12 -0
  92. package/dist/primitives/SearchInput.js +89 -0
  93. package/dist/primitives/SegmentedControl.d.ts +25 -0
  94. package/dist/primitives/SegmentedControl.js +188 -0
  95. package/dist/primitives/Select.d.ts +24 -0
  96. package/dist/primitives/Select.js +320 -0
  97. package/dist/primitives/Separator.d.ts +6 -0
  98. package/dist/primitives/Separator.js +31 -0
  99. package/dist/primitives/ShortcutPending.d.ts +6 -0
  100. package/dist/primitives/ShortcutPending.js +40 -0
  101. package/dist/primitives/ShortcutProvider.d.ts +32 -0
  102. package/dist/primitives/ShortcutProvider.js +172 -0
  103. package/dist/primitives/ShortcutScope.d.ts +6 -0
  104. package/dist/primitives/ShortcutScope.js +29 -0
  105. package/dist/primitives/ShortcutSheet.d.ts +5 -0
  106. package/dist/primitives/ShortcutSheet.js +87 -0
  107. package/dist/primitives/Skeleton.d.ts +5 -0
  108. package/dist/primitives/Skeleton.js +23 -0
  109. package/dist/primitives/Slider.d.ts +35 -0
  110. package/dist/primitives/Slider.js +210 -0
  111. package/dist/primitives/Spinner.d.ts +7 -0
  112. package/dist/primitives/Spinner.js +44 -0
  113. package/dist/primitives/Status.d.ts +15 -0
  114. package/dist/primitives/Status.js +78 -0
  115. package/dist/primitives/Stepper.d.ts +32 -0
  116. package/dist/primitives/Stepper.js +147 -0
  117. package/dist/primitives/Surface.d.ts +11 -0
  118. package/dist/primitives/Surface.js +58 -0
  119. package/dist/primitives/Switch.d.ts +4 -0
  120. package/dist/primitives/Switch.js +7 -0
  121. package/dist/primitives/Table.d.ts +23 -0
  122. package/dist/primitives/Table.js +101 -0
  123. package/dist/primitives/Tabs.d.ts +17 -0
  124. package/dist/primitives/Tabs.js +157 -0
  125. package/dist/primitives/TagInput.d.ts +33 -0
  126. package/dist/primitives/TagInput.js +288 -0
  127. package/dist/primitives/Textarea.d.ts +8 -0
  128. package/dist/primitives/Textarea.js +106 -0
  129. package/dist/primitives/Toast.d.ts +10 -0
  130. package/dist/primitives/Toast.js +78 -0
  131. package/dist/primitives/Toaster.d.ts +9 -0
  132. package/dist/primitives/Toaster.js +183 -0
  133. package/dist/primitives/Tooltip.d.ts +13 -0
  134. package/dist/primitives/Tooltip.js +84 -0
  135. package/dist/primitives/Tree.d.ts +23 -0
  136. package/dist/primitives/Tree.js +275 -0
  137. package/dist/primitives/Typography.d.ts +16 -0
  138. package/dist/primitives/Typography.js +82 -0
  139. package/dist/primitives/boolean-input-state.d.ts +14 -0
  140. package/dist/primitives/boolean-input-state.js +39 -0
  141. package/dist/primitives/button-variants.d.ts +9 -0
  142. package/dist/primitives/button-variants.js +7 -0
  143. package/dist/primitives/choice-options.d.ts +7 -0
  144. package/dist/primitives/choice-options.js +35 -0
  145. package/dist/primitives/create-confirm.d.ts +15 -0
  146. package/dist/primitives/create-confirm.js +49 -0
  147. package/dist/primitives/create-toaster.d.ts +51 -0
  148. package/dist/primitives/create-toaster.js +87 -0
  149. package/dist/primitives/link-focus.d.ts +2 -0
  150. package/dist/primitives/link-focus.js +38 -0
  151. package/dist/primitives/menu-focus.d.ts +3 -0
  152. package/dist/primitives/menu-focus.js +32 -0
  153. package/dist/primitives/tooltip-layer.d.ts +14 -0
  154. package/dist/primitives/tooltip-layer.js +84 -0
  155. package/dist/theme/ThemeProvider.d.ts +59 -0
  156. package/dist/theme/ThemeProvider.js +239 -0
  157. package/dist/theme/intl.d.ts +6 -0
  158. package/dist/theme/intl.js +13 -0
  159. package/dist/theme/keyboard-script.d.ts +2 -0
  160. package/dist/theme/keyboard-script.js +6 -0
  161. package/dist/theme/layers.d.ts +7 -0
  162. package/dist/theme/layers.js +23 -0
  163. package/dist/theme/messages.d.ts +235 -0
  164. package/dist/theme/messages.js +115 -0
  165. package/dist/theme/script.d.ts +9 -0
  166. package/dist/theme/script.js +49 -0
  167. package/dist/theme/state.d.ts +27 -0
  168. package/dist/theme/state.js +55 -0
  169. package/dist/utils/browser-status.d.ts +5 -0
  170. package/dist/utils/browser-status.js +22 -0
  171. package/dist/utils/cn.d.ts +3 -0
  172. package/dist/utils/cn.js +7 -0
  173. package/dist/utils/optimistic.d.ts +6 -0
  174. package/dist/utils/optimistic.js +16 -0
  175. package/dist/utils/polymorphic.d.ts +1 -0
  176. package/dist/utils/shortcut-platform.d.ts +2 -0
  177. package/dist/utils/shortcut-platform.js +10 -0
  178. package/dist/utils/shortcut-registry.d.ts +61 -0
  179. package/dist/utils/shortcut-registry.js +186 -0
  180. package/package.json +100 -0
  181. package/src/core.ts +55 -0
  182. package/src/formisch.ts +28 -0
  183. package/src/forms.ts +34 -0
  184. package/src/index.ts +144 -0
  185. package/src/layout/Layout.tsx +43 -0
  186. package/src/metadata.d.ts +46 -0
  187. package/src/metadata.ts +66 -0
  188. package/src/navigation.ts +30 -0
  189. package/src/overlays.ts +28 -0
  190. package/src/primitives/Accordion.tsx +145 -0
  191. package/src/primitives/ActivityTimeline.tsx +72 -0
  192. package/src/primitives/AlertDialog.tsx +8 -0
  193. package/src/primitives/Avatar.tsx +85 -0
  194. package/src/primitives/Breadcrumb.tsx +41 -0
  195. package/src/primitives/Button.tsx +27 -0
  196. package/src/primitives/ButtonGroup.tsx +18 -0
  197. package/src/primitives/Checkbox.tsx +51 -0
  198. package/src/primitives/CheckboxGroup.tsx +73 -0
  199. package/src/primitives/Collapsible.tsx +43 -0
  200. package/src/primitives/Combobox.tsx +402 -0
  201. package/src/primitives/CommandPalette.tsx +234 -0
  202. package/src/primitives/ConfirmDialog.tsx +25 -0
  203. package/src/primitives/ContextMenu.tsx +100 -0
  204. package/src/primitives/DescriptionList.tsx +26 -0
  205. package/src/primitives/Dialog.tsx +81 -0
  206. package/src/primitives/Drawer.tsx +26 -0
  207. package/src/primitives/DropdownMenu.tsx +221 -0
  208. package/src/primitives/EditableTextField.tsx +91 -0
  209. package/src/primitives/EmptyState.tsx +21 -0
  210. package/src/primitives/Field.tsx +38 -0
  211. package/src/primitives/FileDropzone.tsx +189 -0
  212. package/src/primitives/IconButton.tsx +22 -0
  213. package/src/primitives/Input.tsx +17 -0
  214. package/src/primitives/InputGroup.tsx +23 -0
  215. package/src/primitives/Link.tsx +19 -0
  216. package/src/primitives/LinkTooltip.tsx +31 -0
  217. package/src/primitives/NavList.tsx +58 -0
  218. package/src/primitives/Notice.tsx +25 -0
  219. package/src/primitives/NumberField.tsx +168 -0
  220. package/src/primitives/Pagination.tsx +64 -0
  221. package/src/primitives/Popover.tsx +44 -0
  222. package/src/primitives/Progress.tsx +62 -0
  223. package/src/primitives/RadioGroup.tsx +104 -0
  224. package/src/primitives/Resizable.tsx +170 -0
  225. package/src/primitives/ScrollArea.tsx +115 -0
  226. package/src/primitives/SearchInput.tsx +98 -0
  227. package/src/primitives/SegmentedControl.tsx +140 -0
  228. package/src/primitives/Select.tsx +171 -0
  229. package/src/primitives/Separator.tsx +13 -0
  230. package/src/primitives/ShortcutPending.tsx +21 -0
  231. package/src/primitives/ShortcutProvider.tsx +179 -0
  232. package/src/primitives/ShortcutScope.tsx +17 -0
  233. package/src/primitives/ShortcutSheet.tsx +35 -0
  234. package/src/primitives/Skeleton.tsx +12 -0
  235. package/src/primitives/Slider.tsx +153 -0
  236. package/src/primitives/Spinner.tsx +19 -0
  237. package/src/primitives/Status.tsx +33 -0
  238. package/src/primitives/Stepper.tsx +106 -0
  239. package/src/primitives/Surface.tsx +21 -0
  240. package/src/primitives/Switch.tsx +9 -0
  241. package/src/primitives/Table.tsx +57 -0
  242. package/src/primitives/Tabs.tsx +96 -0
  243. package/src/primitives/TagInput.tsx +282 -0
  244. package/src/primitives/Textarea.tsx +77 -0
  245. package/src/primitives/Toast.tsx +36 -0
  246. package/src/primitives/Toaster.tsx +175 -0
  247. package/src/primitives/Tooltip.tsx +41 -0
  248. package/src/primitives/Tree.tsx +256 -0
  249. package/src/primitives/Typography.tsx +39 -0
  250. package/src/primitives/boolean-input-state.ts +65 -0
  251. package/src/primitives/button-variants.ts +20 -0
  252. package/src/primitives/choice-options.ts +39 -0
  253. package/src/primitives/create-confirm.tsx +56 -0
  254. package/src/primitives/create-toaster.ts +128 -0
  255. package/src/primitives/link-focus.ts +38 -0
  256. package/src/primitives/menu-focus.ts +43 -0
  257. package/src/primitives/tooltip-layer.tsx +53 -0
  258. package/src/styles.css +655 -0
  259. package/src/theme/ThemeProvider.tsx +215 -0
  260. package/src/theme/intl.ts +14 -0
  261. package/src/theme/keyboard-script.ts +4 -0
  262. package/src/theme/layers.ts +16 -0
  263. package/src/theme/messages.ts +157 -0
  264. package/src/theme/script.ts +70 -0
  265. package/src/theme/state.ts +48 -0
  266. package/src/utils/browser-status.ts +36 -0
  267. package/src/utils/cn.ts +5 -0
  268. package/src/utils/optimistic.ts +22 -0
  269. package/src/utils/polymorphic.ts +1 -0
  270. package/src/utils/shortcut-platform.ts +4 -0
  271. package/src/utils/shortcut-registry.ts +216 -0
@@ -0,0 +1,41 @@
1
+ import type { JSX } from "solid-js";
2
+ export interface ComboboxOption {
3
+ readonly value: string;
4
+ readonly label: string;
5
+ readonly description?: string;
6
+ readonly disabled?: boolean;
7
+ }
8
+ export type ComboboxFilter = "contains" | "startsWith" | "endsWith" | false;
9
+ interface ComboboxCommonProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> {
10
+ label: string;
11
+ options: readonly ComboboxOption[];
12
+ name?: string;
13
+ form?: string;
14
+ placeholder?: string;
15
+ description?: string;
16
+ error?: string;
17
+ disabled?: boolean;
18
+ readOnly?: boolean;
19
+ required?: boolean;
20
+ filter?: ComboboxFilter;
21
+ onInputChange?: (value: string) => void;
22
+ pending?: boolean;
23
+ resultsError?: string;
24
+ onRetry?: () => void;
25
+ inputRef?: (element: HTMLInputElement) => void;
26
+ }
27
+ export interface ComboboxProps extends ComboboxCommonProps {
28
+ value?: string | null;
29
+ defaultValue?: string | null;
30
+ onValueChange?: (value: string | null) => void;
31
+ }
32
+ export interface MultiComboboxProps extends ComboboxCommonProps {
33
+ value?: readonly string[];
34
+ defaultValue?: readonly string[];
35
+ onValueChange?: (value: readonly string[]) => void;
36
+ }
37
+ /** Editable single selection with app-owned async results and accepted-result continuity. */
38
+ export declare function Combobox(props: ComboboxProps): JSX.Element;
39
+ /** Editable multiple selection with removable tags and app-owned async results. */
40
+ export declare function MultiCombobox(props: MultiComboboxProps): JSX.Element;
41
+ export {};
@@ -0,0 +1,684 @@
1
+ import { useTheme as e } from "../theme/ThemeProvider.js";
2
+ import { cn as t } from "../utils/cn.js";
3
+ import { useShortcutKeyboardOwner as n } from "./ShortcutProvider.js";
4
+ import { Button as r } from "./Button.js";
5
+ import { Tag as i } from "./Status.js";
6
+ import { createComponent as a, effect as o, insert as s, memo as c, mergeProps as l, setAttribute as u, template as d, use as f } from "solid-js/web";
7
+ import { For as p, Show as m, createEffect as h, createMemo as g, createSignal as _, createUniqueId as v, onCleanup as y, onMount as b, splitProps as x } from "solid-js";
8
+ import * as S from "@kobalte/core/combobox";
9
+ //#region src/primitives/Combobox.tsx
10
+ var C = /*#__PURE__*/ d("<p class=sheen-combobox-status role=status aria-live=polite>"), w = /*#__PURE__*/ d("<p class=sheen-select-empty>"), T = /*#__PURE__*/ d("<div class=sheen-combobox-results-error role=alert><span>"), E = /*#__PURE__*/ d("<span aria-hidden=true> *"), D = /*#__PURE__*/ d("<label class=sheen-field-label>"), O = /*#__PURE__*/ d("<select class=sheen-select-native aria-hidden=true tabindex=-1><option value>"), k = /*#__PURE__*/ d("<option>"), A = /*#__PURE__*/ d("<select class=sheen-select-native aria-hidden=true tabindex=-1 multiple>");
11
+ function j(e, t) {
12
+ let n = /* @__PURE__ */ new Map();
13
+ for (let r of e) {
14
+ if (!r.value) throw Error(`${t}: option values must be nonempty`);
15
+ if (!r.label.trim()) throw Error(`${t}: option labels must be nonempty`);
16
+ if (n.has(r.value)) throw Error(`${t}: duplicate option value ${JSON.stringify(r.value)}`);
17
+ n.set(r.value, r);
18
+ }
19
+ return {
20
+ list: [...n.values()],
21
+ map: n
22
+ };
23
+ }
24
+ function M(e, t, n) {
25
+ let r, i = /* @__PURE__ */ new Map(), a = g(() => {
26
+ let a = j(e(), n);
27
+ if (t() && r) return {
28
+ snapshot: r,
29
+ retained: !0
30
+ };
31
+ r = a;
32
+ for (let e of a.list) i.set(e.value, e);
33
+ return {
34
+ snapshot: a,
35
+ retained: !1
36
+ };
37
+ }), o = g(() => a().snapshot), s = (e, t) => {
38
+ o();
39
+ let n = i.get(e);
40
+ if (!n) throw Error(`${t}: selected value ${JSON.stringify(e)} has not appeared in options`);
41
+ return n;
42
+ };
43
+ return {
44
+ state: a,
45
+ resolve: s,
46
+ includesAccepted: (e) => o().map.has(e),
47
+ rootOptions(e) {
48
+ let t = o(), r = [...t.list];
49
+ for (let i of e) t.map.has(i) || r.push(s(i, n));
50
+ return r;
51
+ }
52
+ };
53
+ }
54
+ function N(e, t) {
55
+ let n = /* @__PURE__ */ new Set();
56
+ for (let r of e) {
57
+ if (!r) throw Error(`${t}: selected values must be nonempty`);
58
+ if (n.has(r)) throw Error(`${t}: duplicate selected value ${JSON.stringify(r)}`);
59
+ n.add(r);
60
+ }
61
+ }
62
+ function P(e, t) {
63
+ return e.normalize("NFKD").replaceAll(/\p{M}/gu, "").toLocaleLowerCase(t);
64
+ }
65
+ function F(e, t, n) {
66
+ return (r, i) => {
67
+ if (!e.includesAccepted(r.value)) return !1;
68
+ if (t() === !1) return !0;
69
+ let a = P(r.label, n()), o = P(i, n());
70
+ return t() === "startsWith" ? a.startsWith(o) : t() === "endsWith" ? a.endsWith(o) : a.includes(o);
71
+ };
72
+ }
73
+ function ee(e) {
74
+ return a(S.Item, {
75
+ get item() {
76
+ return e.item;
77
+ },
78
+ class: "sheen-select-option sheen-combobox-option",
79
+ onPointerDown: (e) => {
80
+ e.pointerType === "mouse" && e.preventDefault();
81
+ },
82
+ get children() {
83
+ return [
84
+ a(S.ItemLabel, { get children() {
85
+ return e.item.rawValue.label;
86
+ } }),
87
+ a(m, {
88
+ get when() {
89
+ return e.item.rawValue.description;
90
+ },
91
+ children: (e) => a(S.ItemDescription, {
92
+ class: "sheen-select-option-description",
93
+ get children() {
94
+ return e();
95
+ }
96
+ })
97
+ }),
98
+ a(S.ItemIndicator, {
99
+ class: "sheen-select-indicator",
100
+ "aria-hidden": "true",
101
+ children: "✓"
102
+ })
103
+ ];
104
+ }
105
+ });
106
+ }
107
+ function te(t) {
108
+ let n = e();
109
+ return a(m, {
110
+ get when() {
111
+ return n.portal();
112
+ },
113
+ children: (e) => a(S.Portal, {
114
+ get mount() {
115
+ return e();
116
+ },
117
+ get children() {
118
+ return a(S.Content, {
119
+ ref(e) {
120
+ var n = t.setContent;
121
+ typeof n == "function" ? n(e) : t.setContent = e;
122
+ },
123
+ "data-kb-top-layer": "true",
124
+ get "aria-hidden"() {
125
+ return !t.open() || void 0;
126
+ },
127
+ get inert() {
128
+ return !t.open();
129
+ },
130
+ class: "sheen-select-content sheen-combobox-content",
131
+ get style() {
132
+ return { "z-index": n.layers.zIndex(t.id) };
133
+ },
134
+ get children() {
135
+ return [
136
+ a(S.Listbox, {
137
+ class: "sheen-select-listbox sheen-combobox-listbox",
138
+ get "aria-label"() {
139
+ return `${t.label} Suggestions`;
140
+ },
141
+ get inert() {
142
+ return t.pending();
143
+ },
144
+ get "aria-disabled"() {
145
+ return t.pending() || void 0;
146
+ }
147
+ }),
148
+ a(m, {
149
+ get when() {
150
+ return t.pending();
151
+ },
152
+ get children() {
153
+ var e = C();
154
+ return s(e, (() => {
155
+ var e = c(() => !!t.state().retained);
156
+ return () => e() ? n.messages().refreshing ?? n.messages().loading : n.messages().loading;
157
+ })()), e;
158
+ }
159
+ }),
160
+ a(m, {
161
+ get when() {
162
+ return c(() => !(t.pending() || t.state().snapshot.list.length))() && !t.resultsError();
163
+ },
164
+ get children() {
165
+ var e = w();
166
+ return s(e, () => n.messages().noResults), e;
167
+ }
168
+ }),
169
+ a(m, {
170
+ get when() {
171
+ return t.resultsError();
172
+ },
173
+ children: (e) => (() => {
174
+ var i = T(), o = i.firstChild;
175
+ return s(o, e), s(i, a(m, {
176
+ get when() {
177
+ return t.onRetry();
178
+ },
179
+ children: (e) => a(r, {
180
+ size: "sm",
181
+ onClick: () => e()(),
182
+ get children() {
183
+ return n.messages().retry;
184
+ }
185
+ })
186
+ }), null), i;
187
+ })()
188
+ })
189
+ ];
190
+ }
191
+ });
192
+ }
193
+ })
194
+ });
195
+ }
196
+ function I(e) {
197
+ let t = S.useComboboxContext(), n = !1;
198
+ return h(() => {
199
+ if (e.snapshot(), !n) {
200
+ n = !0;
201
+ return;
202
+ }
203
+ if (!e.active()) return;
204
+ let r = e.inputValue();
205
+ queueMicrotask(() => {
206
+ e.active() && t.setInputValue(r);
207
+ });
208
+ }), null;
209
+ }
210
+ function L(e) {
211
+ return [a(m, {
212
+ get when() {
213
+ return e.description;
214
+ },
215
+ get children() {
216
+ return a(S.Description, {
217
+ get id() {
218
+ return `${e.id}-description`;
219
+ },
220
+ class: "sheen-field-description",
221
+ get children() {
222
+ return e.description;
223
+ }
224
+ });
225
+ }
226
+ }), a(m, {
227
+ get when() {
228
+ return e.error;
229
+ },
230
+ get children() {
231
+ return a(S.ErrorMessage, {
232
+ get id() {
233
+ return `${e.id}-error`;
234
+ },
235
+ class: "sheen-field-error",
236
+ get children() {
237
+ return e.error;
238
+ }
239
+ });
240
+ }
241
+ })];
242
+ }
243
+ function R(e, t, n) {
244
+ return [t ? `${e}-description` : "", n ? `${e}-error` : ""].filter(Boolean).join(" ") || void 0;
245
+ }
246
+ function z(r) {
247
+ let [i, c] = x(r, [
248
+ "id",
249
+ "class",
250
+ "label",
251
+ "options",
252
+ "value",
253
+ "defaultValue",
254
+ "onValueChange",
255
+ "name",
256
+ "form",
257
+ "placeholder",
258
+ "description",
259
+ "error",
260
+ "disabled",
261
+ "readOnly",
262
+ "required",
263
+ "filter",
264
+ "onInputChange",
265
+ "pending",
266
+ "resultsError",
267
+ "onRetry",
268
+ "inputRef"
269
+ ]), d = e(), C = v(), w = i.defaultValue ?? null, [T, A] = _(w), [j, N] = _(!1), [P, z] = _(), [B, V] = _(), [H, U] = _(""), [W, G] = _(!1), K, q = () => i.value === void 0 ? T() : i.value, J = M(() => i.options, () => i.pending ?? !1, "Combobox"), Y = () => {
270
+ let e = q();
271
+ if (e === "") throw Error("Combobox: selected values must be nonempty");
272
+ return e === null ? [] : [e];
273
+ }, X = () => {
274
+ let e = q();
275
+ if (e === "") throw Error("Combobox: selected values must be nonempty");
276
+ return e === null ? null : J.resolve(e, "Combobox");
277
+ }, Z = g(() => J.rootOptions(Y())), ne = F(J, () => i.filter ?? "contains", () => d.state().locale);
278
+ n(P, () => !0), n(B, j);
279
+ let Q = (e) => {
280
+ if (i.disabled || i.readOnly || i.pending) return;
281
+ let t = e?.value ?? null;
282
+ t !== q() && (G(!1), i.value === void 0 && A(t), i.onValueChange?.(t));
283
+ }, $ = () => {
284
+ K && (K.value = q() ?? "");
285
+ };
286
+ return h(() => {
287
+ q(), Z(), $();
288
+ }), b(() => {
289
+ let e = K?.ownerDocument, t = e?.defaultView;
290
+ if (!e || !t) return;
291
+ let n = /* @__PURE__ */ new Set(), r = (e) => {
292
+ if (e.target !== K?.form) return;
293
+ let r = t.setTimeout(() => {
294
+ n.delete(r), !e.defaultPrevented && (i.value === void 0 && Q(w === null ? null : J.resolve(w, "Combobox defaultValue")), $());
295
+ }, 0);
296
+ n.add(r);
297
+ };
298
+ e.addEventListener("reset", r, !0), y(() => {
299
+ e.removeEventListener("reset", r, !0);
300
+ for (let e of n) t.clearTimeout(e);
301
+ });
302
+ }), h(() => {
303
+ j() && y(d.layers.register(C));
304
+ }), a(S.Root, l(c, {
305
+ get id() {
306
+ return i.id ?? `${C}-root`;
307
+ },
308
+ "aria-labelledby": `${C}-label`,
309
+ multiple: !1,
310
+ get class() {
311
+ return t("sheen-field sheen-combobox", i.class);
312
+ },
313
+ get "data-previous-results"() {
314
+ return i.pending && J.state().retained ? "" : void 0;
315
+ },
316
+ get options() {
317
+ return Z();
318
+ },
319
+ optionValue: (e) => e.value,
320
+ optionTextValue: (e) => e.label,
321
+ optionLabel: (e) => e.label,
322
+ optionDisabled: (e) => !!e.disabled,
323
+ itemComponent: ee,
324
+ get value() {
325
+ return X();
326
+ }
327
+ }, () => w ? { defaultValue: J.resolve(w, "Combobox defaultValue") } : {}, {
328
+ onChange: Q,
329
+ defaultFilter: ne,
330
+ allowsEmptyCollection: !0,
331
+ closeOnSelection: !0,
332
+ disallowEmptySelection: !1,
333
+ get open() {
334
+ return j();
335
+ },
336
+ onOpenChange: (e) => {
337
+ N(e && !i.disabled), e || G(!1);
338
+ },
339
+ get disabled() {
340
+ return i.disabled ?? !1;
341
+ },
342
+ get readOnly() {
343
+ return i.readOnly ?? !1;
344
+ },
345
+ get required() {
346
+ return i.required ?? !1;
347
+ },
348
+ get validationState() {
349
+ return i.error ? "invalid" : "valid";
350
+ },
351
+ placement: "bottom-start",
352
+ sameWidth: !0,
353
+ gutter: 4,
354
+ get children() {
355
+ return [
356
+ (() => {
357
+ var e = D();
358
+ return u(e, "id", `${C}-label`), u(e, "for", `${C}-input`), s(e, () => i.label, null), s(e, a(m, {
359
+ get when() {
360
+ return i.required;
361
+ },
362
+ get children() {
363
+ return E();
364
+ }
365
+ }), null), e;
366
+ })(),
367
+ a(S.Control, {
368
+ class: "sheen-combobox-control",
369
+ get children() {
370
+ return a(S.Input, {
371
+ id: `${C}-input`,
372
+ "aria-labelledby": `${C}-label`,
373
+ get "aria-describedby"() {
374
+ return R(C, i.description, i.error);
375
+ },
376
+ ref: (e) => {
377
+ z(e), i.inputRef?.(e);
378
+ },
379
+ class: "sheen-input sheen-combobox-input",
380
+ get placeholder() {
381
+ return i.placeholder;
382
+ },
383
+ get "aria-busy"() {
384
+ return i.pending || void 0;
385
+ },
386
+ onInput: () => {
387
+ let e = P()?.value ?? "";
388
+ U(e), G(!0), i.onInputChange?.(e);
389
+ }
390
+ });
391
+ }
392
+ }),
393
+ (() => {
394
+ var e = O();
395
+ e.firstChild, e.addEventListener("change", (e) => {
396
+ let t = e.currentTarget.value;
397
+ Q(t === "" ? null : J.resolve(t, "Combobox native value")), $();
398
+ }), e.addEventListener("invalid", (e) => {
399
+ e.preventDefault(), P()?.focus();
400
+ });
401
+ var t = K;
402
+ return typeof t == "function" ? f(t, e) : K = e, u(e, "id", `${C}-native`), s(e, a(p, {
403
+ get each() {
404
+ return Z();
405
+ },
406
+ children: (e) => (() => {
407
+ var t = k();
408
+ return s(t, () => e.label), o((n) => {
409
+ var r = e.disabled, i = q() === e.value;
410
+ return r !== n.e && (t.disabled = n.e = r), i !== n.t && (t.selected = n.t = i), n;
411
+ }, {
412
+ e: void 0,
413
+ t: void 0
414
+ }), o(() => t.value = e.value), t;
415
+ })()
416
+ }), null), o((t) => {
417
+ var n = i.name, r = i.form, a = i.required, o = !!(i.disabled || q() === null && !i.required), s = i.label;
418
+ return n !== t.e && u(e, "name", t.e = n), r !== t.t && u(e, "form", t.t = r), a !== t.a && (e.required = t.a = a), o !== t.o && (e.disabled = t.o = o), s !== t.i && u(e, "aria-label", t.i = s), t;
419
+ }, {
420
+ e: void 0,
421
+ t: void 0,
422
+ a: void 0,
423
+ o: void 0,
424
+ i: void 0
425
+ }), e;
426
+ })(),
427
+ a(I, {
428
+ snapshot: () => J.state().snapshot,
429
+ active: () => j() && W() && P()?.ownerDocument.activeElement === P(),
430
+ inputValue: H
431
+ }),
432
+ a(L, {
433
+ id: C,
434
+ get description() {
435
+ return i.description;
436
+ },
437
+ get error() {
438
+ return i.error;
439
+ }
440
+ }),
441
+ a(te, {
442
+ id: C,
443
+ get label() {
444
+ return i.label;
445
+ },
446
+ open: j,
447
+ get state() {
448
+ return J.state;
449
+ },
450
+ pending: () => i.pending ?? !1,
451
+ resultsError: () => i.resultsError,
452
+ onRetry: () => i.onRetry,
453
+ setContent: V
454
+ })
455
+ ];
456
+ }
457
+ }));
458
+ }
459
+ function B(r) {
460
+ let [d, C] = x(r, [
461
+ "id",
462
+ "class",
463
+ "label",
464
+ "options",
465
+ "value",
466
+ "defaultValue",
467
+ "onValueChange",
468
+ "name",
469
+ "form",
470
+ "placeholder",
471
+ "description",
472
+ "error",
473
+ "disabled",
474
+ "readOnly",
475
+ "required",
476
+ "filter",
477
+ "onInputChange",
478
+ "pending",
479
+ "resultsError",
480
+ "onRetry",
481
+ "inputRef"
482
+ ]), w = e(), T = v(), O = [...d.defaultValue ?? []];
483
+ N(O, "MultiCombobox defaultValue");
484
+ let [j, P] = _(O), [I, z] = _(!1), [B, V] = _(), [H, U] = _(), W, G = () => {
485
+ let e = d.value === void 0 ? j() : d.value;
486
+ return N(e, "MultiCombobox value"), e;
487
+ }, K = M(() => d.options, () => d.pending ?? !1, "MultiCombobox"), q = g(() => G().map((e) => K.resolve(e, "MultiCombobox"))), J = g(() => K.rootOptions(G())), Y = F(K, () => d.filter ?? "contains", () => w.state().locale);
488
+ n(B, () => !0), n(H, I);
489
+ let X = (e) => {
490
+ if (d.disabled || d.readOnly) return;
491
+ N(e, "MultiCombobox value");
492
+ let t = G();
493
+ t.length === e.length && t.every((t, n) => t === e[n]) || (d.value === void 0 && P([...e]), d.onValueChange?.([...e]));
494
+ }, Z = (e) => {
495
+ d.pending || X(e.map((e) => e.value));
496
+ }, ne = (e) => X(G().filter((t) => t !== e)), Q = () => {
497
+ if (!W) return;
498
+ let e = new Set(G());
499
+ for (let t of W.options) t.selected = e.has(t.value);
500
+ };
501
+ return h(() => {
502
+ G(), J(), Q();
503
+ }), b(() => {
504
+ let e = W?.ownerDocument, t = e?.defaultView;
505
+ if (!e || !t) return;
506
+ let n = /* @__PURE__ */ new Set(), r = (e) => {
507
+ if (e.target !== W?.form) return;
508
+ let r = t.setTimeout(() => {
509
+ n.delete(r), !e.defaultPrevented && (d.value === void 0 && X(O), Q());
510
+ }, 0);
511
+ n.add(r);
512
+ };
513
+ e.addEventListener("reset", r, !0), y(() => {
514
+ e.removeEventListener("reset", r, !0);
515
+ for (let e of n) t.clearTimeout(e);
516
+ });
517
+ }), h(() => {
518
+ I() && y(w.layers.register(T));
519
+ }), a(S.Root, l(C, {
520
+ get id() {
521
+ return d.id ?? `${T}-root`;
522
+ },
523
+ "aria-labelledby": `${T}-label`,
524
+ multiple: !0,
525
+ get class() {
526
+ return t("sheen-field sheen-combobox sheen-multi-combobox", d.class);
527
+ },
528
+ get "data-previous-results"() {
529
+ return d.pending && K.state().retained ? "" : void 0;
530
+ },
531
+ get options() {
532
+ return J();
533
+ },
534
+ optionValue: (e) => e.value,
535
+ optionTextValue: (e) => e.label,
536
+ optionLabel: (e) => e.label,
537
+ optionDisabled: (e) => !!(d.pending || e.disabled),
538
+ itemComponent: ee,
539
+ get value() {
540
+ return q();
541
+ },
542
+ get defaultValue() {
543
+ return O.map((e) => K.resolve(e, "MultiCombobox defaultValue"));
544
+ },
545
+ onChange: Z,
546
+ defaultFilter: Y,
547
+ allowsEmptyCollection: !0,
548
+ closeOnSelection: !1,
549
+ removeOnBackspace: !0,
550
+ selectionBehavior: "toggle",
551
+ get open() {
552
+ return I();
553
+ },
554
+ onOpenChange: (e) => z(e && !d.disabled),
555
+ get disabled() {
556
+ return d.disabled ?? !1;
557
+ },
558
+ get readOnly() {
559
+ return d.readOnly ?? !1;
560
+ },
561
+ get required() {
562
+ return d.required ?? !1;
563
+ },
564
+ get validationState() {
565
+ return d.error ? "invalid" : "valid";
566
+ },
567
+ placement: "bottom-start",
568
+ sameWidth: !0,
569
+ gutter: 4,
570
+ get children() {
571
+ return [
572
+ (() => {
573
+ var e = D();
574
+ return u(e, "id", `${T}-label`), u(e, "for", `${T}-input`), s(e, () => d.label, null), s(e, a(m, {
575
+ get when() {
576
+ return d.required;
577
+ },
578
+ get children() {
579
+ return E();
580
+ }
581
+ }), null), e;
582
+ })(),
583
+ a(S.Control, {
584
+ class: "sheen-input sheen-combobox-control sheen-multi-combobox-control",
585
+ get children() {
586
+ return [a(p, {
587
+ get each() {
588
+ return q();
589
+ },
590
+ children: (e) => a(i, {
591
+ get label() {
592
+ return e.label;
593
+ },
594
+ get disabled() {
595
+ return !!(d.disabled || d.readOnly);
596
+ },
597
+ onRemove: () => ne(e.value)
598
+ })
599
+ }), a(S.Input, {
600
+ id: `${T}-input`,
601
+ "aria-labelledby": `${T}-label`,
602
+ get "aria-describedby"() {
603
+ return R(T, d.description, d.error);
604
+ },
605
+ get "aria-required"() {
606
+ return d.required || void 0;
607
+ },
608
+ required: !1,
609
+ ref: (e) => {
610
+ V(e), d.inputRef?.(e);
611
+ },
612
+ class: "sheen-combobox-input sheen-multi-combobox-input",
613
+ get placeholder() {
614
+ return c(() => !q().length)() ? d.placeholder : void 0;
615
+ },
616
+ get "aria-busy"() {
617
+ return d.pending || void 0;
618
+ },
619
+ onInput: () => d.onInputChange?.(B()?.value ?? "")
620
+ })];
621
+ }
622
+ }),
623
+ (() => {
624
+ var e = A();
625
+ e.addEventListener("change", (e) => {
626
+ X([...e.currentTarget.selectedOptions].map((e) => e.value)), Q();
627
+ }), e.addEventListener("invalid", (e) => {
628
+ e.preventDefault(), B()?.focus();
629
+ });
630
+ var t = W;
631
+ return typeof t == "function" ? f(t, e) : W = e, s(e, a(p, {
632
+ get each() {
633
+ return J();
634
+ },
635
+ children: (e) => (() => {
636
+ var t = k();
637
+ return s(t, () => e.label), o((n) => {
638
+ var r = e.disabled, i = G().includes(e.value);
639
+ return r !== n.e && (t.disabled = n.e = r), i !== n.t && (t.selected = n.t = i), n;
640
+ }, {
641
+ e: void 0,
642
+ t: void 0
643
+ }), o(() => t.value = e.value), t;
644
+ })()
645
+ })), o((t) => {
646
+ var n = d.name, r = d.form, i = d.required, a = d.disabled, o = d.label;
647
+ return n !== t.e && u(e, "name", t.e = n), r !== t.t && u(e, "form", t.t = r), i !== t.a && (e.required = t.a = i), a !== t.o && (e.disabled = t.o = a), o !== t.i && u(e, "aria-label", t.i = o), t;
648
+ }, {
649
+ e: void 0,
650
+ t: void 0,
651
+ a: void 0,
652
+ o: void 0,
653
+ i: void 0
654
+ }), e;
655
+ })(),
656
+ a(L, {
657
+ id: T,
658
+ get description() {
659
+ return d.description;
660
+ },
661
+ get error() {
662
+ return d.error;
663
+ }
664
+ }),
665
+ a(te, {
666
+ id: T,
667
+ get label() {
668
+ return d.label;
669
+ },
670
+ open: I,
671
+ get state() {
672
+ return K.state;
673
+ },
674
+ pending: () => d.pending ?? !1,
675
+ resultsError: () => d.resultsError,
676
+ onRetry: () => d.onRetry,
677
+ setContent: U
678
+ })
679
+ ];
680
+ }
681
+ }));
682
+ }
683
+ //#endregion
684
+ export { z as Combobox, B as MultiCombobox };