@hjmds/react 0.8.2

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 (135) hide show
  1. package/README.md +146 -0
  2. package/dist/actions.d.ts +61 -0
  3. package/dist/actions.d.ts.map +1 -0
  4. package/dist/actions.js +54 -0
  5. package/dist/actions.js.map +1 -0
  6. package/dist/advanced-display.d.ts +133 -0
  7. package/dist/advanced-display.d.ts.map +1 -0
  8. package/dist/advanced-display.js +201 -0
  9. package/dist/advanced-display.js.map +1 -0
  10. package/dist/advanced-forms.d.ts +116 -0
  11. package/dist/advanced-forms.d.ts.map +1 -0
  12. package/dist/advanced-forms.js +234 -0
  13. package/dist/advanced-forms.js.map +1 -0
  14. package/dist/advanced-navigation.d.ts +24 -0
  15. package/dist/advanced-navigation.d.ts.map +1 -0
  16. package/dist/advanced-navigation.js +25 -0
  17. package/dist/advanced-navigation.js.map +1 -0
  18. package/dist/bottom-navigation.d.ts +37 -0
  19. package/dist/bottom-navigation.d.ts.map +1 -0
  20. package/dist/bottom-navigation.js +132 -0
  21. package/dist/bottom-navigation.js.map +1 -0
  22. package/dist/date-picker.d.ts +24 -0
  23. package/dist/date-picker.d.ts.map +1 -0
  24. package/dist/date-picker.js +81 -0
  25. package/dist/date-picker.js.map +1 -0
  26. package/dist/display-public.d.ts +5 -0
  27. package/dist/display-public.d.ts.map +1 -0
  28. package/dist/display-public.js +5 -0
  29. package/dist/display-public.js.map +1 -0
  30. package/dist/display.d.ts +77 -0
  31. package/dist/display.d.ts.map +1 -0
  32. package/dist/display.js +51 -0
  33. package/dist/display.js.map +1 -0
  34. package/dist/evidence.d.ts +940 -0
  35. package/dist/evidence.d.ts.map +1 -0
  36. package/dist/evidence.js +98 -0
  37. package/dist/evidence.js.map +1 -0
  38. package/dist/feedback.d.ts +89 -0
  39. package/dist/feedback.d.ts.map +1 -0
  40. package/dist/feedback.js +41 -0
  41. package/dist/feedback.js.map +1 -0
  42. package/dist/file-picker.d.ts +30 -0
  43. package/dist/file-picker.d.ts.map +1 -0
  44. package/dist/file-picker.js +40 -0
  45. package/dist/file-picker.js.map +1 -0
  46. package/dist/forms-public.d.ts +8 -0
  47. package/dist/forms-public.d.ts.map +1 -0
  48. package/dist/forms-public.js +8 -0
  49. package/dist/forms-public.js.map +1 -0
  50. package/dist/forms.d.ts +160 -0
  51. package/dist/forms.d.ts.map +1 -0
  52. package/dist/forms.js +178 -0
  53. package/dist/forms.js.map +1 -0
  54. package/dist/index.d.ts +24 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +24 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/internal.d.ts +17 -0
  59. package/dist/internal.d.ts.map +1 -0
  60. package/dist/internal.js +68 -0
  61. package/dist/internal.js.map +1 -0
  62. package/dist/layout.d.ts +134 -0
  63. package/dist/layout.d.ts.map +1 -0
  64. package/dist/layout.js +167 -0
  65. package/dist/layout.js.map +1 -0
  66. package/dist/navigation-public.d.ts +6 -0
  67. package/dist/navigation-public.d.ts.map +1 -0
  68. package/dist/navigation-public.js +6 -0
  69. package/dist/navigation-public.js.map +1 -0
  70. package/dist/navigation.d.ts +65 -0
  71. package/dist/navigation.d.ts.map +1 -0
  72. package/dist/navigation.js +196 -0
  73. package/dist/navigation.js.map +1 -0
  74. package/dist/number-field.d.ts +55 -0
  75. package/dist/number-field.d.ts.map +1 -0
  76. package/dist/number-field.js +107 -0
  77. package/dist/number-field.js.map +1 -0
  78. package/dist/otp-field.d.ts +2 -0
  79. package/dist/otp-field.d.ts.map +1 -0
  80. package/dist/otp-field.js +2 -0
  81. package/dist/otp-field.js.map +1 -0
  82. package/dist/overlays.d.ts +192 -0
  83. package/dist/overlays.d.ts.map +1 -0
  84. package/dist/overlays.js +949 -0
  85. package/dist/overlays.js.map +1 -0
  86. package/dist/password-field.d.ts +2 -0
  87. package/dist/password-field.d.ts.map +1 -0
  88. package/dist/password-field.js +2 -0
  89. package/dist/password-field.js.map +1 -0
  90. package/dist/portal.d.ts +32 -0
  91. package/dist/portal.d.ts.map +1 -0
  92. package/dist/portal.js +264 -0
  93. package/dist/portal.js.map +1 -0
  94. package/dist/provider.d.ts +38 -0
  95. package/dist/provider.d.ts.map +1 -0
  96. package/dist/provider.js +87 -0
  97. package/dist/provider.js.map +1 -0
  98. package/dist/select.d.ts +72 -0
  99. package/dist/select.d.ts.map +1 -0
  100. package/dist/select.js +353 -0
  101. package/dist/select.js.map +1 -0
  102. package/dist/selection.d.ts +160 -0
  103. package/dist/selection.d.ts.map +1 -0
  104. package/dist/selection.js +225 -0
  105. package/dist/selection.js.map +1 -0
  106. package/dist/slider.d.ts +35 -0
  107. package/dist/slider.d.ts.map +1 -0
  108. package/dist/slider.js +150 -0
  109. package/dist/slider.js.map +1 -0
  110. package/dist/steps.d.ts +29 -0
  111. package/dist/steps.d.ts.map +1 -0
  112. package/dist/steps.js +10 -0
  113. package/dist/steps.js.map +1 -0
  114. package/dist/styles.css +1349 -0
  115. package/dist/supplemental-display.d.ts +59 -0
  116. package/dist/supplemental-display.d.ts.map +1 -0
  117. package/dist/supplemental-display.js +136 -0
  118. package/dist/supplemental-display.js.map +1 -0
  119. package/dist/supplemental-navigation.d.ts +28 -0
  120. package/dist/supplemental-navigation.d.ts.map +1 -0
  121. package/dist/supplemental-navigation.js +106 -0
  122. package/dist/supplemental-navigation.js.map +1 -0
  123. package/dist/theme.d.ts +5 -0
  124. package/dist/theme.d.ts.map +1 -0
  125. package/dist/theme.js +55 -0
  126. package/dist/theme.js.map +1 -0
  127. package/dist/toast.d.ts +41 -0
  128. package/dist/toast.d.ts.map +1 -0
  129. package/dist/toast.js +250 -0
  130. package/dist/toast.js.map +1 -0
  131. package/dist/upload-item.d.ts +18 -0
  132. package/dist/upload-item.d.ts.map +1 -0
  133. package/dist/upload-item.js +19 -0
  134. package/dist/upload-item.js.map +1 -0
  135. package/package.json +151 -0
package/dist/select.js ADDED
@@ -0,0 +1,353 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { getCollectionNavigationIntent, getCollectionNavigationTarget, getCollectionTypeaheadMatch, reconcileSelectSelection, resolveCollectionItem, resolveSelectSelectedItem, validateCollection, } from "@hjmds/design-contracts/components/collection";
3
+ import { resolveControlAccessibleName, selectBehaviorDefaults, } from "@hjmds/design-contracts/behaviors";
4
+ import { iconRecipe, selectRecipe, } from "@hjmds/design-contracts/recipes";
5
+ import { forwardRef, useCallback, useEffect, useId, useRef, useState, } from "react";
6
+ import { classNames, useControllableState } from "./internal.js";
7
+ import { AnchoredPortal, useAnchoredPopup, } from "./portal.js";
8
+ const emptySelectionKey = Symbol("hjm-select-empty-selection");
9
+ function SelectInner(props, forwardedRef) {
10
+ const { items, sections, label, accessibilityLabel, description, error, placeholder, emptySelectionLabel, asyncState = { status: "idle" }, selectedItem, disallowEmptySelection = selectBehaviorDefaults.disallowEmptySelection, loop = selectBehaviorDefaults.loop, busy = false, readOnly = false, size = selectRecipe.defaults.size, density = selectRecipe.defaults.density, align = "start", fieldClassName, portalContainer, locale, renderLeading, renderOptionLeading, className, id: idProp, name, disabled = false, required = false, selectedKey: selectedKeyProp, defaultSelectedKey, onSelectionChange, open: openProp, defaultOpen = false, onOpenChange, onClick, onFocus, onBlur, onKeyDown, ...buttonProps } = props;
11
+ const source = sections === undefined
12
+ ? { items: items ?? [] }
13
+ : { sections };
14
+ validateCollection(source);
15
+ const accessibleName = resolveControlAccessibleName(label, accessibilityLabel, "Select");
16
+ if (placeholder.trim().length === 0)
17
+ throw new TypeError("Select placeholder must not be empty");
18
+ if (emptySelectionLabel.trim().length === 0) {
19
+ throw new TypeError("Select emptySelectionLabel must not be empty");
20
+ }
21
+ const flatItems = source.sections
22
+ ? source.sections.flatMap((section) => section.items)
23
+ : source.items;
24
+ if (flatItems.length === 0 &&
25
+ (asyncState.status === "idle" || asyncState.status === "loadingMore")) {
26
+ throw new TypeError("Select requires options unless its async state is transient or empty");
27
+ }
28
+ const initialSelectionRef = useRef(null);
29
+ if (initialSelectionRef.current === null) {
30
+ initialSelectionRef.current = {
31
+ value: reconcileSelectSelection(source, selectedKeyProp ?? defaultSelectedKey ?? null, {
32
+ disallowEmptySelection,
33
+ asyncState,
34
+ ...(selectedItem === undefined ? {} : { selectedItem }),
35
+ }),
36
+ };
37
+ }
38
+ const [storedSelectedKey, setSelectedKey] = useControllableState({
39
+ ...(selectedKeyProp === undefined ? {} : { value: selectedKeyProp }),
40
+ defaultValue: initialSelectionRef.current.value,
41
+ ...(onSelectionChange === undefined ? {} : { onChange: onSelectionChange }),
42
+ });
43
+ const reconciledSelectedKey = reconcileSelectSelection(source, storedSelectedKey, {
44
+ disallowEmptySelection,
45
+ asyncState,
46
+ ...(selectedItem === undefined ? {} : { selectedItem }),
47
+ });
48
+ const reconciliationRequestRef = useRef(undefined);
49
+ useEffect(() => {
50
+ if (storedSelectedKey === reconciledSelectedKey) {
51
+ reconciliationRequestRef.current = undefined;
52
+ return;
53
+ }
54
+ const token = `${storedSelectedKey ?? "<empty>"}->${reconciledSelectedKey ?? "<empty>"}`;
55
+ if (reconciliationRequestRef.current === token)
56
+ return;
57
+ reconciliationRequestRef.current = token;
58
+ setSelectedKey(reconciledSelectedKey);
59
+ }, [reconciledSelectedKey, setSelectedKey, storedSelectedKey]);
60
+ const resolvedSelectedItem = resolveSelectSelectedItem(source, reconciledSelectedKey, selectedItem !== undefined && selectedItem.id === reconciledSelectedKey
61
+ ? selectedItem
62
+ : undefined);
63
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
64
+ const openControlled = openProp !== undefined;
65
+ const open = openControlled ? openProp : internalOpen;
66
+ const pendingOpenRequestRef = useRef(undefined);
67
+ useEffect(() => {
68
+ if (pendingOpenRequestRef.current === open)
69
+ pendingOpenRequestRef.current = undefined;
70
+ }, [open]);
71
+ const changeOpen = useCallback((nextOpen, reason) => {
72
+ if (nextOpen === open || pendingOpenRequestRef.current === nextOpen)
73
+ return;
74
+ pendingOpenRequestRef.current = nextOpen;
75
+ if (!openControlled)
76
+ setInternalOpen(nextOpen);
77
+ onOpenChange?.(nextOpen, reason);
78
+ if (openControlled && nextOpen) {
79
+ queueMicrotask(() => {
80
+ if (pendingOpenRequestRef.current === true) {
81
+ pendingOpenRequestRef.current = undefined;
82
+ }
83
+ });
84
+ }
85
+ }, [onOpenChange, open, openControlled]);
86
+ const generatedId = useId().replaceAll(":", "");
87
+ const controlId = idProp ?? `hjm-select-${generatedId}`;
88
+ const listboxId = `${controlId}-listbox`;
89
+ const descriptionId = `${controlId}-description`;
90
+ const errorId = `${controlId}-error`;
91
+ const optionId = (key) => `${controlId}-option-${flatItems.findIndex((item) => item.id === key)}`;
92
+ const rootRef = useRef(null);
93
+ const triggerRef = useRef(null);
94
+ const listboxRef = useRef(null);
95
+ const [listboxNode, setListboxNode] = useState(null);
96
+ const optionRefs = useRef(new Map());
97
+ const typeaheadRef = useRef({ value: "", time: 0 });
98
+ const restoreFocusRef = useRef(false);
99
+ const showOptions = asyncState.status === "idle" || asyncState.status === "loadingMore";
100
+ const emptySelectionAvailable = !disallowEmptySelection && showOptions;
101
+ const selectionItemInSource = resolveCollectionItem(source, reconciledSelectedKey);
102
+ const initialHighlight = selectionItemInSource && !selectionItemInSource.disabled
103
+ ? selectionItemInSource.id
104
+ : reconciledSelectedKey === null && emptySelectionAvailable
105
+ ? emptySelectionKey
106
+ : getCollectionNavigationTarget(source, null, "first", loop) ?? null;
107
+ const [highlightedKey, setHighlightedKey] = useState(initialHighlight);
108
+ const highlightedItem = showOptions && highlightedKey !== emptySelectionKey
109
+ ? resolveCollectionItem(source, highlightedKey)
110
+ : null;
111
+ const activeKey = highlightedItem && !highlightedItem.disabled
112
+ ? highlightedItem.id
113
+ : highlightedKey === emptySelectionKey && emptySelectionAvailable
114
+ ? emptySelectionKey
115
+ : null;
116
+ const activeOptionId = activeKey === emptySelectionKey
117
+ ? `${controlId}-option-empty`
118
+ : activeKey === null
119
+ ? undefined
120
+ : optionId(activeKey);
121
+ const popupPosition = useAnchoredPopup(triggerRef, listboxNode, {
122
+ align,
123
+ matchAnchorWidth: true,
124
+ zIndex: 800,
125
+ });
126
+ const setListboxRef = useCallback((node) => {
127
+ listboxRef.current = node;
128
+ setListboxNode(node);
129
+ }, []);
130
+ useEffect(() => {
131
+ if (!open) {
132
+ if (restoreFocusRef.current) {
133
+ restoreFocusRef.current = false;
134
+ queueMicrotask(() => triggerRef.current?.focus());
135
+ }
136
+ return;
137
+ }
138
+ if (activeKey === null && showOptions)
139
+ setHighlightedKey(initialHighlight);
140
+ }, [activeKey, initialHighlight, open, showOptions]);
141
+ useEffect(() => {
142
+ if (open && activeKey !== null) {
143
+ optionRefs.current.get(activeKey)?.scrollIntoView({ block: "nearest" });
144
+ }
145
+ }, [activeKey, open]);
146
+ useEffect(() => {
147
+ if (!open)
148
+ return;
149
+ const handlePointerDown = (event) => {
150
+ if (event.target instanceof Node &&
151
+ !rootRef.current?.contains(event.target) &&
152
+ !listboxRef.current?.contains(event.target)) {
153
+ changeOpen(false, "outside");
154
+ }
155
+ };
156
+ document.addEventListener("pointerdown", handlePointerDown);
157
+ return () => document.removeEventListener("pointerdown", handlePointerDown);
158
+ }, [changeOpen, open]);
159
+ const openWithIntent = (intent = "first") => {
160
+ if (disabled || busy || readOnly)
161
+ return;
162
+ const selectedInSource = resolveCollectionItem(source, reconciledSelectedKey);
163
+ const target = selectedInSource && !selectedInSource.disabled
164
+ ? selectedInSource.id
165
+ : reconciledSelectedKey === null && emptySelectionAvailable
166
+ ? emptySelectionKey
167
+ : intent === "last" && emptySelectionAvailable
168
+ ? emptySelectionKey
169
+ : getCollectionNavigationTarget(source, null, intent, loop) ?? null;
170
+ setHighlightedKey(target);
171
+ changeOpen(true, "keyboard");
172
+ };
173
+ const moveHighlight = (intent) => {
174
+ const enabledKeys = flatItems
175
+ .filter((item) => !item.disabled)
176
+ .map((item) => item.id);
177
+ const firstKey = enabledKeys[0];
178
+ const lastKey = enabledKeys.at(-1);
179
+ if (emptySelectionAvailable) {
180
+ if (intent === "last") {
181
+ setHighlightedKey(emptySelectionKey);
182
+ return;
183
+ }
184
+ if (activeKey === emptySelectionKey) {
185
+ if (intent === "previous" && lastKey !== undefined)
186
+ setHighlightedKey(lastKey);
187
+ else if (((intent === "next" && loop) || intent === "first") &&
188
+ firstKey !== undefined) {
189
+ setHighlightedKey(firstKey);
190
+ }
191
+ return;
192
+ }
193
+ if (intent === "next" && activeKey === lastKey) {
194
+ setHighlightedKey(emptySelectionKey);
195
+ return;
196
+ }
197
+ if (intent === "previous" && activeKey === firstKey && loop) {
198
+ setHighlightedKey(emptySelectionKey);
199
+ return;
200
+ }
201
+ }
202
+ const target = getCollectionNavigationTarget(source, activeKey === emptySelectionKey ? null : activeKey, intent, loop);
203
+ if (target !== undefined)
204
+ setHighlightedKey(target);
205
+ };
206
+ const commit = (key) => {
207
+ if (key === emptySelectionKey) {
208
+ if (disabled || readOnly || !emptySelectionAvailable)
209
+ return;
210
+ setSelectedKey(null);
211
+ restoreFocusRef.current = true;
212
+ changeOpen(false, "selection");
213
+ return;
214
+ }
215
+ const item = resolveCollectionItem(source, key);
216
+ if (!item ||
217
+ item.disabled ||
218
+ disabled ||
219
+ busy ||
220
+ readOnly ||
221
+ asyncState.status === "loading")
222
+ return;
223
+ setSelectedKey(key);
224
+ restoreFocusRef.current = true;
225
+ changeOpen(false, "selection");
226
+ };
227
+ const runTypeahead = (key) => {
228
+ const now = Date.now();
229
+ const previous = now - typeaheadRef.current.time < 500
230
+ ? typeaheadRef.current.value
231
+ : "";
232
+ const combined = `${previous}${key}`;
233
+ const query = new Set(combined.toLocaleLowerCase()).size === 1 ? key : combined;
234
+ typeaheadRef.current = { value: combined, time: now };
235
+ const match = getCollectionTypeaheadMatch(source, query, {
236
+ startsAfterKey: activeKey === emptySelectionKey
237
+ ? reconciledSelectedKey
238
+ : activeKey ?? reconciledSelectedKey,
239
+ ...(locale === undefined ? {} : { locale }),
240
+ });
241
+ if (match !== undefined) {
242
+ setHighlightedKey(match);
243
+ if (!open)
244
+ changeOpen(true, "keyboard");
245
+ }
246
+ };
247
+ const handleKeyDown = (event) => {
248
+ onKeyDown?.(event);
249
+ if (event.defaultPrevented || disabled || busy || readOnly)
250
+ return;
251
+ const navigationIntent = getCollectionNavigationIntent(event.key);
252
+ if (navigationIntent !== undefined) {
253
+ event.preventDefault();
254
+ if (!open) {
255
+ openWithIntent(navigationIntent === "previous" || navigationIntent === "last"
256
+ ? "last"
257
+ : "first");
258
+ }
259
+ else
260
+ moveHighlight(navigationIntent);
261
+ return;
262
+ }
263
+ if (event.key === "Enter" || event.key === " ") {
264
+ event.preventDefault();
265
+ if (!open)
266
+ openWithIntent();
267
+ else if (activeKey !== null)
268
+ commit(activeKey);
269
+ }
270
+ else if (event.key === "Escape" && open) {
271
+ event.preventDefault();
272
+ restoreFocusRef.current = true;
273
+ changeOpen(false, "escape");
274
+ }
275
+ else if (event.key === "Tab" && open) {
276
+ changeOpen(false, "blur");
277
+ }
278
+ else if (event.key.length === 1 &&
279
+ event.key !== " " &&
280
+ !event.altKey &&
281
+ !event.ctrlKey &&
282
+ !event.metaKey) {
283
+ event.preventDefault();
284
+ runTypeahead(event.key);
285
+ }
286
+ };
287
+ const handleBlur = (event) => {
288
+ onBlur?.(event);
289
+ if (event.defaultPrevented)
290
+ return;
291
+ queueMicrotask(() => {
292
+ if (open &&
293
+ document.activeElement instanceof Node &&
294
+ !rootRef.current?.contains(document.activeElement) &&
295
+ !listboxRef.current?.contains(document.activeElement))
296
+ changeOpen(false, "blur");
297
+ });
298
+ };
299
+ const describedBy = error ? errorId : description ? descriptionId : undefined;
300
+ const renderOption = (item) => {
301
+ const selected = item.id === reconciledSelectedKey;
302
+ const active = item.id === activeKey;
303
+ const leadingSize = iconRecipe.sizes[selectRecipe.optionLeading.glyph];
304
+ const leading = renderOptionLeading?.(item, {
305
+ selected,
306
+ highlighted: active,
307
+ disabled: item.disabled ?? false,
308
+ color: "currentColor",
309
+ size: leadingSize,
310
+ glyphSize: leadingSize,
311
+ });
312
+ return (_jsxs("div", { ref: (node) => {
313
+ if (node)
314
+ optionRefs.current.set(item.id, node);
315
+ else
316
+ optionRefs.current.delete(item.id);
317
+ }, id: optionId(item.id), role: "option", className: "hjm-select__option", "aria-selected": selected, "aria-disabled": item.disabled || undefined, "data-state": item.disabled ? "disabled" : selected ? "selected" : "idle", "data-active": active || undefined, onMouseDown: (event) => event.preventDefault(), onMouseMove: () => {
318
+ if (!item.disabled)
319
+ setHighlightedKey(item.id);
320
+ }, onClick: () => commit(item.id), children: [leading ? (_jsx("span", { className: "hjm-select__option-leading", "aria-hidden": "true", children: leading })) : null, _jsxs("span", { className: "hjm-select__option-copy", children: [_jsx("span", { children: item.label }), item.description ? (_jsx("span", { className: "hjm-select__option-description", children: item.description })) : null] }), selected ? _jsx("span", { className: "hjm-select__check", "aria-hidden": "true", children: "\u2713" }) : null] }, item.id));
321
+ };
322
+ const triggerLeadingSize = iconRecipe.sizes[selectRecipe.sizes[size].glyph];
323
+ const triggerLeading = renderLeading?.(resolvedSelectedItem, {
324
+ color: "currentColor",
325
+ size: triggerLeadingSize,
326
+ glyphSize: triggerLeadingSize,
327
+ });
328
+ return (_jsxs("div", { ref: rootRef, className: classNames("hjm-field hjm-select", fieldClassName), "data-state": disabled ? "disabled" : error ? "invalid" : open ? "focused" : "idle", "data-size": size, "data-density": density, "data-async-state": asyncState.status, "data-busy": busy || undefined, children: [label !== undefined ? (_jsxs("label", { className: "hjm-field__label", htmlFor: controlId, children: [label, required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] })) : null, _jsxs("div", { className: "hjm-select__anchor", children: [_jsxs("button", { ...buttonProps, ref: (node) => {
329
+ triggerRef.current = node;
330
+ if (typeof forwardedRef === "function")
331
+ forwardedRef(node);
332
+ else if (forwardedRef)
333
+ forwardedRef.current = node;
334
+ }, id: controlId, type: "button", role: "combobox", className: classNames("hjm-field__control hjm-select__trigger", className), disabled: disabled, "aria-disabled": busy || undefined, "aria-label": accessibilityLabel ?? (label === undefined ? accessibleName : undefined), "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "aria-activedescendant": open ? activeOptionId : undefined, "aria-busy": busy || asyncState.status === "loading" || asyncState.status === "loadingMore" || undefined, "aria-invalid": error ? true : undefined, "aria-describedby": describedBy, "aria-readonly": readOnly || undefined, "aria-required": required || undefined, onFocus: onFocus, onBlur: handleBlur, onKeyDown: handleKeyDown, onClick: (event) => {
335
+ onClick?.(event);
336
+ if (event.defaultPrevented || disabled || busy || readOnly)
337
+ return;
338
+ if (open)
339
+ changeOpen(false, "trigger");
340
+ else
341
+ openWithIntent();
342
+ }, children: [triggerLeading ? (_jsx("span", { className: "hjm-select__leading", "aria-hidden": "true", children: triggerLeading })) : null, _jsx("span", { className: "hjm-select__value", "data-state": resolvedSelectedItem ? "selected" : "placeholder", children: resolvedSelectedItem?.label ?? placeholder }), busy ? (_jsx("span", { className: "hjm-select__busy-indicator", "aria-hidden": "true" })) : (_jsx("span", { className: "hjm-select__indicator", "aria-hidden": "true", children: "\u2304" }))] }), open ? (_jsx(AnchoredPortal, { anchorRef: triggerRef, ssrFallback: "inline", ...(portalContainer === undefined ? {} : { container: portalContainer }), children: _jsxs("div", { ref: setListboxRef, id: listboxId, role: "listbox", "aria-label": accessibleName, className: "hjm-select__listbox", "data-density": density, "data-placement": popupPosition.placement, "data-align": popupPosition.align, style: popupPosition.style, children: [asyncState.status !== "idle" ? (_jsx("div", { className: "hjm-select__message", role: asyncState.status === "error" ? "alert" : "status", children: asyncState.message })) : null, showOptions ? (source.sections ? source.sections.map((section) => {
343
+ const sectionLabelId = `${controlId}-section-${section.id}`;
344
+ return (_jsxs("div", { role: "group", "aria-labelledby": section.label ? sectionLabelId : undefined, "aria-label": section.label ? undefined : section.accessibilityLabel, className: "hjm-select__section", children: [section.label ? (_jsx("div", { id: sectionLabelId, className: "hjm-select__section-label", children: section.label })) : null, section.items.map(renderOption)] }, section.id));
345
+ }) : source.items.map(renderOption)) : null, !disallowEmptySelection && showOptions ? (_jsx("div", { ref: (node) => {
346
+ if (node)
347
+ optionRefs.current.set(emptySelectionKey, node);
348
+ else
349
+ optionRefs.current.delete(emptySelectionKey);
350
+ }, id: `${controlId}-option-empty`, role: "option", className: "hjm-select__option hjm-select__option--empty", "aria-selected": reconciledSelectedKey === null, "data-state": reconciledSelectedKey === null ? "selected" : "idle", "data-active": activeKey === emptySelectionKey || undefined, onMouseDown: (event) => event.preventDefault(), onMouseMove: () => setHighlightedKey(emptySelectionKey), onClick: () => commit(emptySelectionKey), children: emptySelectionLabel })) : null] }) })) : null] }), description && !error ? (_jsx("div", { id: descriptionId, className: "hjm-field__description", children: description })) : null, error ? _jsx("div", { id: errorId, className: "hjm-field__error", children: error }) : null, name ? _jsx("input", { type: "hidden", name: name, value: reconciledSelectedKey ?? "" }) : null] }));
351
+ }
352
+ export const Select = forwardRef(SelectInner);
353
+ //# sourceMappingURL=select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.js","sourceRoot":"","sources":["../src/select.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,GAInB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,GAIvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,UAAU,EACV,YAAY,GAGb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,UAAU,EACV,WAAW,EACX,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,GAOT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EACL,cAAc,EACd,gBAAgB,GAEjB,MAAM,aAAa,CAAC;AAoBrB,MAAM,iBAAiB,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC;AAoF/D,SAAS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AAI,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,IAAI,EAAE,GAAI,CAAC,CAAC,CAAC,IAAI,IAClF,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CAKpB,CAAC","sourcesContent":["import {\n getCollectionNavigationIntent,\n getCollectionNavigationTarget,\n getCollectionTypeaheadMatch,\n reconcileSelectSelection,\n resolveCollectionItem,\n resolveSelectSelectedItem,\n validateCollection,\n type SelectCollectionSectionDescriptor,\n type SelectCollectionSource,\n type SelectOpenChangeReason,\n} from \"@hjmds/design-contracts/components/collection\";\nimport {\n resolveControlAccessibleName,\n selectBehaviorDefaults,\n type AsyncCollectionState,\n type SelectItemDescriptor,\n type WebKeyboardKey,\n} from \"@hjmds/design-contracts/behaviors\";\nimport {\n iconRecipe,\n selectRecipe,\n type SelectDensity,\n type SelectSize,\n} from \"@hjmds/design-contracts/recipes\";\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type FocusEvent,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n type RefAttributes,\n} from \"react\";\nimport { classNames, useControllableState } from \"./internal.js\";\nimport {\n AnchoredPortal,\n useAnchoredPopup,\n type AnchoredPopupAlign,\n} from \"./portal.js\";\n\nexport type SelectItem<Key extends string = string> = SelectItemDescriptor<Key>;\nexport type SelectSection<\n Key extends string = string,\n SectionKey extends string = string,\n> = SelectCollectionSectionDescriptor<Key, SectionKey>;\n\nexport type SelectLeadingRenderProps = Readonly<{\n color: \"currentColor\";\n size: number;\n glyphSize: number;\n}>;\n\nexport type SelectOptionLeadingRenderProps = SelectLeadingRenderProps & Readonly<{\n selected: boolean;\n highlighted: boolean;\n disabled: boolean;\n}>;\n\nconst emptySelectionKey = Symbol(\"hjm-select-empty-selection\");\ntype SelectHighlightKey<Key extends string> = Key | typeof emptySelectionKey;\n\ntype SelectSourceProps<Key extends string, SectionKey extends string> =\n SelectCollectionSource<Key, SectionKey>;\n\ntype SelectSelectionProps<Key extends string> =\n | Readonly<{\n selectedKey: Key | null;\n defaultSelectedKey?: never;\n onSelectionChange(key: Key | null): void;\n }>\n | Readonly<{\n selectedKey?: never;\n defaultSelectedKey?: Key | null;\n onSelectionChange?: (key: Key | null) => void;\n }>;\n\ntype SelectOpenProps =\n | Readonly<{\n open: boolean;\n defaultOpen?: never;\n onOpenChange(open: boolean, reason: SelectOpenChangeReason): void;\n }>\n | Readonly<{\n open?: never;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean, reason: SelectOpenChangeReason) => void;\n }>;\n\ntype SelectLabelProps =\n | Readonly<{ label: string; accessibilityLabel?: string }>\n | Readonly<{ label?: never; accessibilityLabel: string }>;\n\ntype SelectBaseProps<Key extends string> = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n | \"aria-label\"\n | \"children\"\n | \"defaultValue\"\n | \"onChange\"\n | \"role\"\n | \"value\"\n> &\n Readonly<{\n description?: ReactNode;\n error?: ReactNode;\n /** Localized text shown when no item is selected. */\n placeholder: string;\n /** Localized label for the nullable empty-selection option. */\n emptySelectionLabel: string;\n asyncState?: AsyncCollectionState;\n selectedItem?: SelectItemDescriptor<Key>;\n disallowEmptySelection?: boolean;\n loop?: boolean;\n /** Locks interaction without removing the trigger from the focus order. */\n busy?: boolean;\n readOnly?: boolean;\n required?: boolean;\n size?: SelectSize;\n density?: SelectDensity;\n /** Logical listbox alignment against the trigger; automatically mirrors in RTL. */\n align?: AnchoredPopupAlign;\n fieldClassName?: string;\n portalContainer?: HTMLElement;\n locale?: string | readonly string[];\n renderLeading?: (\n item: SelectItemDescriptor<Key> | null,\n appearance: SelectLeadingRenderProps,\n ) => ReactNode;\n renderOptionLeading?: (\n item: SelectItemDescriptor<Key>,\n appearance: SelectOptionLeadingRenderProps,\n ) => ReactNode;\n }>;\n\nexport type SelectProps<\n Key extends string = string,\n SectionKey extends string = string,\n> = SelectBaseProps<Key> &\n SelectSourceProps<Key, SectionKey> &\n SelectSelectionProps<Key> &\n SelectOpenProps &\n SelectLabelProps;\n\nfunction SelectInner<Key extends string, SectionKey extends string>(\n props: SelectProps<Key, SectionKey>,\n forwardedRef: React.ForwardedRef<HTMLButtonElement>,\n) {\n const {\n items,\n sections,\n label,\n accessibilityLabel,\n description,\n error,\n placeholder,\n emptySelectionLabel,\n asyncState = { status: \"idle\" },\n selectedItem,\n disallowEmptySelection = selectBehaviorDefaults.disallowEmptySelection,\n loop = selectBehaviorDefaults.loop,\n busy = false,\n readOnly = false,\n size = selectRecipe.defaults.size,\n density = selectRecipe.defaults.density,\n align = \"start\",\n fieldClassName,\n portalContainer,\n locale,\n renderLeading,\n renderOptionLeading,\n className,\n id: idProp,\n name,\n disabled = false,\n required = false,\n selectedKey: selectedKeyProp,\n defaultSelectedKey,\n onSelectionChange,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n onClick,\n onFocus,\n onBlur,\n onKeyDown,\n ...buttonProps\n } = props;\n const source: SelectCollectionSource<Key, SectionKey> = sections === undefined\n ? { items: items ?? [] }\n : { sections };\n validateCollection(source);\n const accessibleName = resolveControlAccessibleName(\n label,\n accessibilityLabel,\n \"Select\",\n );\n if (placeholder.trim().length === 0) throw new TypeError(\"Select placeholder must not be empty\");\n if (emptySelectionLabel.trim().length === 0) {\n throw new TypeError(\"Select emptySelectionLabel must not be empty\");\n }\n const flatItems = source.sections\n ? source.sections.flatMap((section) => section.items)\n : source.items;\n if (\n flatItems.length === 0 &&\n (asyncState.status === \"idle\" || asyncState.status === \"loadingMore\")\n ) {\n throw new TypeError(\"Select requires options unless its async state is transient or empty\");\n }\n const initialSelectionRef = useRef<Readonly<{ value: Key | null }> | null>(null);\n if (initialSelectionRef.current === null) {\n initialSelectionRef.current = {\n value: reconcileSelectSelection(\n source,\n selectedKeyProp ?? defaultSelectedKey ?? null,\n {\n disallowEmptySelection,\n asyncState,\n ...(selectedItem === undefined ? {} : { selectedItem }),\n },\n ),\n };\n }\n const [storedSelectedKey, setSelectedKey] = useControllableState<Key | null>({\n ...(selectedKeyProp === undefined ? {} : { value: selectedKeyProp }),\n defaultValue: initialSelectionRef.current.value,\n ...(onSelectionChange === undefined ? {} : { onChange: onSelectionChange }),\n });\n const reconciledSelectedKey = reconcileSelectSelection(source, storedSelectedKey, {\n disallowEmptySelection,\n asyncState,\n ...(selectedItem === undefined ? {} : { selectedItem }),\n });\n const reconciliationRequestRef = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (storedSelectedKey === reconciledSelectedKey) {\n reconciliationRequestRef.current = undefined;\n return;\n }\n const token = `${storedSelectedKey ?? \"<empty>\"}->${reconciledSelectedKey ?? \"<empty>\"}`;\n if (reconciliationRequestRef.current === token) return;\n reconciliationRequestRef.current = token;\n setSelectedKey(reconciledSelectedKey);\n }, [reconciledSelectedKey, setSelectedKey, storedSelectedKey]);\n const resolvedSelectedItem = resolveSelectSelectedItem(\n source,\n reconciledSelectedKey,\n selectedItem !== undefined && selectedItem.id === reconciledSelectedKey\n ? selectedItem\n : undefined,\n );\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const openControlled = openProp !== undefined;\n const open = openControlled ? openProp : internalOpen;\n const pendingOpenRequestRef = useRef<boolean | undefined>(undefined);\n useEffect(() => {\n if (pendingOpenRequestRef.current === open) pendingOpenRequestRef.current = undefined;\n }, [open]);\n const changeOpen = useCallback(\n (nextOpen: boolean, reason: SelectOpenChangeReason) => {\n if (nextOpen === open || pendingOpenRequestRef.current === nextOpen) return;\n pendingOpenRequestRef.current = nextOpen;\n if (!openControlled) setInternalOpen(nextOpen);\n onOpenChange?.(nextOpen, reason);\n if (openControlled && nextOpen) {\n queueMicrotask(() => {\n if (pendingOpenRequestRef.current === true) {\n pendingOpenRequestRef.current = undefined;\n }\n });\n }\n },\n [onOpenChange, open, openControlled],\n );\n\n const generatedId = useId().replaceAll(\":\", \"\");\n const controlId = idProp ?? `hjm-select-${generatedId}`;\n const listboxId = `${controlId}-listbox`;\n const descriptionId = `${controlId}-description`;\n const errorId = `${controlId}-error`;\n const optionId = (key: Key) =>\n `${controlId}-option-${flatItems.findIndex((item) => item.id === key)}`;\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const listboxRef = useRef<HTMLDivElement | null>(null);\n const [listboxNode, setListboxNode] = useState<HTMLDivElement | null>(null);\n const optionRefs = useRef(new Map<SelectHighlightKey<Key>, HTMLDivElement>());\n const typeaheadRef = useRef({ value: \"\", time: 0 });\n const restoreFocusRef = useRef(false);\n const showOptions = asyncState.status === \"idle\" || asyncState.status === \"loadingMore\";\n const emptySelectionAvailable = !disallowEmptySelection && showOptions;\n const selectionItemInSource = resolveCollectionItem(source, reconciledSelectedKey);\n const initialHighlight = selectionItemInSource && !selectionItemInSource.disabled\n ? selectionItemInSource.id\n : reconciledSelectedKey === null && emptySelectionAvailable\n ? emptySelectionKey\n : getCollectionNavigationTarget(source, null, \"first\", loop) ?? null;\n const [highlightedKey, setHighlightedKey] = useState<SelectHighlightKey<Key> | null>(\n initialHighlight,\n );\n const highlightedItem = showOptions && highlightedKey !== emptySelectionKey\n ? resolveCollectionItem(source, highlightedKey)\n : null;\n const activeKey: SelectHighlightKey<Key> | null = highlightedItem && !highlightedItem.disabled\n ? highlightedItem.id\n : highlightedKey === emptySelectionKey && emptySelectionAvailable\n ? emptySelectionKey\n : null;\n const activeOptionId = activeKey === emptySelectionKey\n ? `${controlId}-option-empty`\n : activeKey === null\n ? undefined\n : optionId(activeKey);\n const popupPosition = useAnchoredPopup(triggerRef, listboxNode, {\n align,\n matchAnchorWidth: true,\n zIndex: 800,\n });\n const setListboxRef = useCallback((node: HTMLDivElement | null) => {\n listboxRef.current = node;\n setListboxNode(node);\n }, []);\n\n useEffect(() => {\n if (!open) {\n if (restoreFocusRef.current) {\n restoreFocusRef.current = false;\n queueMicrotask(() => triggerRef.current?.focus());\n }\n return;\n }\n if (activeKey === null && showOptions) setHighlightedKey(initialHighlight);\n }, [activeKey, initialHighlight, open, showOptions]);\n useEffect(() => {\n if (open && activeKey !== null) {\n optionRefs.current.get(activeKey)?.scrollIntoView({ block: \"nearest\" });\n }\n }, [activeKey, open]);\n useEffect(() => {\n if (!open) return;\n const handlePointerDown = (event: PointerEvent) => {\n if (\n event.target instanceof Node &&\n !rootRef.current?.contains(event.target) &&\n !listboxRef.current?.contains(event.target)\n ) {\n changeOpen(false, \"outside\");\n }\n };\n document.addEventListener(\"pointerdown\", handlePointerDown);\n return () => document.removeEventListener(\"pointerdown\", handlePointerDown);\n }, [changeOpen, open]);\n\n const openWithIntent = (intent: \"first\" | \"last\" = \"first\") => {\n if (disabled || busy || readOnly) return;\n const selectedInSource = resolveCollectionItem(source, reconciledSelectedKey);\n const target = selectedInSource && !selectedInSource.disabled\n ? selectedInSource.id\n : reconciledSelectedKey === null && emptySelectionAvailable\n ? emptySelectionKey\n : intent === \"last\" && emptySelectionAvailable\n ? emptySelectionKey\n : getCollectionNavigationTarget(source, null, intent, loop) ?? null;\n setHighlightedKey(target);\n changeOpen(true, \"keyboard\");\n };\n const moveHighlight = (intent: \"next\" | \"previous\" | \"first\" | \"last\") => {\n const enabledKeys = flatItems\n .filter((item) => !item.disabled)\n .map((item) => item.id);\n const firstKey = enabledKeys[0];\n const lastKey = enabledKeys.at(-1);\n if (emptySelectionAvailable) {\n if (intent === \"last\") {\n setHighlightedKey(emptySelectionKey);\n return;\n }\n if (activeKey === emptySelectionKey) {\n if (intent === \"previous\" && lastKey !== undefined) setHighlightedKey(lastKey);\n else if (\n ((intent === \"next\" && loop) || intent === \"first\") &&\n firstKey !== undefined\n ) {\n setHighlightedKey(firstKey);\n }\n return;\n }\n if (intent === \"next\" && activeKey === lastKey) {\n setHighlightedKey(emptySelectionKey);\n return;\n }\n if (intent === \"previous\" && activeKey === firstKey && loop) {\n setHighlightedKey(emptySelectionKey);\n return;\n }\n }\n const target = getCollectionNavigationTarget(\n source,\n activeKey === emptySelectionKey ? null : activeKey,\n intent,\n loop,\n );\n if (target !== undefined) setHighlightedKey(target);\n };\n const commit = (key: SelectHighlightKey<Key>) => {\n if (key === emptySelectionKey) {\n if (disabled || readOnly || !emptySelectionAvailable) return;\n setSelectedKey(null);\n restoreFocusRef.current = true;\n changeOpen(false, \"selection\");\n return;\n }\n const item = resolveCollectionItem(source, key);\n if (\n !item ||\n item.disabled ||\n disabled ||\n busy ||\n readOnly ||\n asyncState.status === \"loading\"\n ) return;\n setSelectedKey(key);\n restoreFocusRef.current = true;\n changeOpen(false, \"selection\");\n };\n const runTypeahead = (key: string) => {\n const now = Date.now();\n const previous = now - typeaheadRef.current.time < 500\n ? typeaheadRef.current.value\n : \"\";\n const combined = `${previous}${key}`;\n const query = new Set(combined.toLocaleLowerCase()).size === 1 ? key : combined;\n typeaheadRef.current = { value: combined, time: now };\n const match = getCollectionTypeaheadMatch(source, query, {\n startsAfterKey: activeKey === emptySelectionKey\n ? reconciledSelectedKey\n : activeKey ?? reconciledSelectedKey,\n ...(locale === undefined ? {} : { locale }),\n });\n if (match !== undefined) {\n setHighlightedKey(match);\n if (!open) changeOpen(true, \"keyboard\");\n }\n };\n const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || disabled || busy || readOnly) return;\n const navigationIntent = getCollectionNavigationIntent(\n event.key as WebKeyboardKey,\n );\n if (navigationIntent !== undefined) {\n event.preventDefault();\n if (!open) {\n openWithIntent(\n navigationIntent === \"previous\" || navigationIntent === \"last\"\n ? \"last\"\n : \"first\",\n );\n }\n else moveHighlight(navigationIntent);\n return;\n }\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n if (!open) openWithIntent();\n else if (activeKey !== null) commit(activeKey);\n } else if (event.key === \"Escape\" && open) {\n event.preventDefault();\n restoreFocusRef.current = true;\n changeOpen(false, \"escape\");\n } else if (event.key === \"Tab\" && open) {\n changeOpen(false, \"blur\");\n } else if (\n event.key.length === 1 &&\n event.key !== \" \" &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey\n ) {\n event.preventDefault();\n runTypeahead(event.key);\n }\n };\n const handleBlur = (event: FocusEvent<HTMLButtonElement>) => {\n onBlur?.(event);\n if (event.defaultPrevented) return;\n queueMicrotask(() => {\n if (\n open &&\n document.activeElement instanceof Node &&\n !rootRef.current?.contains(document.activeElement) &&\n !listboxRef.current?.contains(document.activeElement)\n ) changeOpen(false, \"blur\");\n });\n };\n const describedBy = error ? errorId : description ? descriptionId : undefined;\n\n const renderOption = (item: SelectItemDescriptor<Key>) => {\n const selected = item.id === reconciledSelectedKey;\n const active = item.id === activeKey;\n const leadingSize = iconRecipe.sizes[selectRecipe.optionLeading.glyph];\n const leading = renderOptionLeading?.(item, {\n selected,\n highlighted: active,\n disabled: item.disabled ?? false,\n color: \"currentColor\",\n size: leadingSize,\n glyphSize: leadingSize,\n });\n return (\n <div\n key={item.id}\n ref={(node) => {\n if (node) optionRefs.current.set(item.id, node);\n else optionRefs.current.delete(item.id);\n }}\n id={optionId(item.id)}\n role=\"option\"\n className=\"hjm-select__option\"\n aria-selected={selected}\n aria-disabled={item.disabled || undefined}\n data-state={item.disabled ? \"disabled\" : selected ? \"selected\" : \"idle\"}\n data-active={active || undefined}\n onMouseDown={(event) => event.preventDefault()}\n onMouseMove={() => {\n if (!item.disabled) setHighlightedKey(item.id);\n }}\n onClick={() => commit(item.id)}\n >\n {leading ? (\n <span className=\"hjm-select__option-leading\" aria-hidden=\"true\">\n {leading}\n </span>\n ) : null}\n <span className=\"hjm-select__option-copy\">\n <span>{item.label}</span>\n {item.description ? (\n <span className=\"hjm-select__option-description\">{item.description}</span>\n ) : null}\n </span>\n {selected ? <span className=\"hjm-select__check\" aria-hidden=\"true\">✓</span> : null}\n </div>\n );\n };\n\n const triggerLeadingSize = iconRecipe.sizes[selectRecipe.sizes[size].glyph];\n const triggerLeading = renderLeading?.(resolvedSelectedItem, {\n color: \"currentColor\",\n size: triggerLeadingSize,\n glyphSize: triggerLeadingSize,\n });\n\n return (\n <div\n ref={rootRef}\n className={classNames(\"hjm-field hjm-select\", fieldClassName)}\n data-state={disabled ? \"disabled\" : error ? \"invalid\" : open ? \"focused\" : \"idle\"}\n data-size={size}\n data-density={density}\n data-async-state={asyncState.status}\n data-busy={busy || undefined}\n >\n {label !== undefined ? (\n <label className=\"hjm-field__label\" htmlFor={controlId}>\n {label}{required ? <span aria-hidden=\"true\"> *</span> : null}\n </label>\n ) : null}\n <div className=\"hjm-select__anchor\">\n <button\n {...buttonProps}\n ref={(node) => {\n triggerRef.current = node;\n if (typeof forwardedRef === \"function\") forwardedRef(node);\n else if (forwardedRef) forwardedRef.current = node;\n }}\n id={controlId}\n type=\"button\"\n role=\"combobox\"\n className={classNames(\"hjm-field__control hjm-select__trigger\", className)}\n disabled={disabled}\n aria-disabled={busy || undefined}\n aria-label={accessibilityLabel ?? (label === undefined ? accessibleName : undefined)}\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open ? activeOptionId : undefined}\n aria-busy={busy || asyncState.status === \"loading\" || asyncState.status === \"loadingMore\" || undefined}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-readonly={readOnly || undefined}\n aria-required={required || undefined}\n onFocus={onFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled || busy || readOnly) return;\n if (open) changeOpen(false, \"trigger\");\n else openWithIntent();\n }}\n >\n {triggerLeading ? (\n <span className=\"hjm-select__leading\" aria-hidden=\"true\">\n {triggerLeading}\n </span>\n ) : null}\n <span\n className=\"hjm-select__value\"\n data-state={resolvedSelectedItem ? \"selected\" : \"placeholder\"}\n >\n {resolvedSelectedItem?.label ?? placeholder}\n </span>\n {busy ? (\n <span className=\"hjm-select__busy-indicator\" aria-hidden=\"true\" />\n ) : (\n <span className=\"hjm-select__indicator\" aria-hidden=\"true\">⌄</span>\n )}\n </button>\n {open ? (\n <AnchoredPortal\n anchorRef={triggerRef}\n ssrFallback=\"inline\"\n {...(portalContainer === undefined ? {} : { container: portalContainer })}\n >\n <div\n ref={setListboxRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={accessibleName}\n className=\"hjm-select__listbox\"\n data-density={density}\n data-placement={popupPosition.placement}\n data-align={popupPosition.align}\n style={popupPosition.style}\n >\n {asyncState.status !== \"idle\" ? (\n <div\n className=\"hjm-select__message\"\n role={asyncState.status === \"error\" ? \"alert\" : \"status\"}\n >\n {asyncState.message}\n </div>\n ) : null}\n {showOptions ? (\n source.sections ? source.sections.map((section) => {\n const sectionLabelId = `${controlId}-section-${section.id}`;\n return (\n <div\n key={section.id}\n role=\"group\"\n aria-labelledby={section.label ? sectionLabelId : undefined}\n aria-label={section.label ? undefined : section.accessibilityLabel}\n className=\"hjm-select__section\"\n >\n {section.label ? (\n <div id={sectionLabelId} className=\"hjm-select__section-label\">\n {section.label}\n </div>\n ) : null}\n {section.items.map(renderOption)}\n </div>\n );\n }) : source.items.map(renderOption)\n ) : null}\n {!disallowEmptySelection && showOptions ? (\n <div\n ref={(node) => {\n if (node) optionRefs.current.set(emptySelectionKey, node);\n else optionRefs.current.delete(emptySelectionKey);\n }}\n id={`${controlId}-option-empty`}\n role=\"option\"\n className=\"hjm-select__option hjm-select__option--empty\"\n aria-selected={reconciledSelectedKey === null}\n data-state={reconciledSelectedKey === null ? \"selected\" : \"idle\"}\n data-active={activeKey === emptySelectionKey || undefined}\n onMouseDown={(event) => event.preventDefault()}\n onMouseMove={() => setHighlightedKey(emptySelectionKey)}\n onClick={() => commit(emptySelectionKey)}\n >\n {emptySelectionLabel}\n </div>\n ) : null}\n </div>\n </AnchoredPortal>\n ) : null}\n </div>\n {description && !error ? (\n <div id={descriptionId} className=\"hjm-field__description\">{description}</div>\n ) : null}\n {error ? <div id={errorId} className=\"hjm-field__error\">{error}</div> : null}\n {name ? <input type=\"hidden\" name={name} value={reconciledSelectedKey ?? \"\"} /> : null}\n </div>\n );\n}\n\nexport const Select = forwardRef(SelectInner) as <\n Key extends string = string,\n SectionKey extends string = string,\n>(\n props: SelectProps<Key, SectionKey> & RefAttributes<HTMLButtonElement>,\n) => ReactElement | null;\n"]}
@@ -0,0 +1,160 @@
1
+ import { chipRecipe, type SegmentedControlSize, type SelectionControlPresentation, type SelectionControlSize, type SelectionGroupOrientation, type SelectionGroupPresentation } from "@hjmds/design-contracts/recipes";
2
+ import { type CheckboxGroupSelection, type SelectionItemDescriptor } from "@hjmds/design-contracts/behaviors";
3
+ import { type ButtonHTMLAttributes, type ChangeEvent, type FieldsetHTMLAttributes, type InputHTMLAttributes, type MouseEvent, type ReactElement, type ReactNode, type RefAttributes } from "react";
4
+ export type ChoiceLeadingRenderProps = Readonly<{
5
+ selected: boolean;
6
+ color: "currentColor";
7
+ size: number;
8
+ }>;
9
+ type ChipBaseProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "onChange" | "onClick" | "size"> & Readonly<{
10
+ label: ReactNode;
11
+ size?: keyof typeof chipRecipe.sizes;
12
+ leading?: ReactNode;
13
+ trailing?: ReactNode;
14
+ renderSelectionIndicator?: (props: Readonly<{
15
+ selected: boolean;
16
+ color: "currentColor";
17
+ size: number;
18
+ }>) => ReactNode;
19
+ }>;
20
+ type ActionChipProps = Readonly<{
21
+ selectionMode?: "action";
22
+ selected?: never;
23
+ onPress?: (event: MouseEvent<HTMLButtonElement>) => void;
24
+ onSelectedChange?: never;
25
+ }>;
26
+ type SelectionChipProps = Readonly<{
27
+ selectionMode: "single" | "multiple";
28
+ selected: boolean;
29
+ onSelectedChange: (selected: boolean) => void;
30
+ onPress?: (event: MouseEvent<HTMLButtonElement>) => void;
31
+ }>;
32
+ export type ChipProps = ChipBaseProps & (ActionChipProps | SelectionChipProps);
33
+ /** Action/filter chip with explicit selection semantics and no hidden state. */
34
+ export declare const Chip: import("react").ForwardRefExoticComponent<ChipProps & RefAttributes<HTMLButtonElement>>;
35
+ export type CheckboxProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "checked" | "defaultChecked" | "onChange" | "children" | "size"> & Readonly<{
36
+ label: ReactNode;
37
+ description?: ReactNode;
38
+ checked?: boolean;
39
+ defaultChecked?: boolean;
40
+ indeterminate?: boolean;
41
+ onCheckedChange?: (checked: boolean) => void;
42
+ onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
43
+ presentation?: SelectionControlPresentation;
44
+ size?: SelectionControlSize;
45
+ renderLeading?: (appearance: ChoiceLeadingRenderProps) => ReactNode;
46
+ }>;
47
+ export declare const Checkbox: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "children" | "defaultChecked" | "type" | "size" | "checked"> & Readonly<{
48
+ label: ReactNode;
49
+ description?: ReactNode;
50
+ checked?: boolean;
51
+ defaultChecked?: boolean;
52
+ indeterminate?: boolean;
53
+ onCheckedChange?: (checked: boolean) => void;
54
+ onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
55
+ presentation?: SelectionControlPresentation;
56
+ size?: SelectionControlSize;
57
+ renderLeading?: (appearance: ChoiceLeadingRenderProps) => ReactNode;
58
+ }> & RefAttributes<HTMLInputElement>>;
59
+ type RadioState = Readonly<{
60
+ checked: boolean;
61
+ defaultChecked?: never;
62
+ onCheckedChange(checked: true): void;
63
+ }> | Readonly<{
64
+ checked?: never;
65
+ defaultChecked?: boolean;
66
+ onCheckedChange?: (checked: true) => void;
67
+ }>;
68
+ export type RadioProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "checked" | "defaultChecked" | "onChange" | "children" | "size"> & RadioState & Readonly<{
69
+ label: ReactNode;
70
+ description?: ReactNode;
71
+ onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
72
+ presentation?: SelectionControlPresentation;
73
+ size?: SelectionControlSize;
74
+ renderLeading?: (appearance: ChoiceLeadingRenderProps) => ReactNode;
75
+ }>;
76
+ /** Native radio item primitive. Use RadioGroup when the renderer owns group state. */
77
+ export declare const Radio: import("react").ForwardRefExoticComponent<RadioProps & RefAttributes<HTMLInputElement>>;
78
+ export type CheckboxGroupItem<Key extends string = string> = SelectionItemDescriptor<Key>;
79
+ type CheckboxGroupBaseProps<Key extends string> = Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "defaultValue" | "onChange" | "value"> & Readonly<{
80
+ items: readonly CheckboxGroupItem<Key>[];
81
+ label?: string;
82
+ accessibilityLabel?: string;
83
+ description?: ReactNode;
84
+ error?: ReactNode;
85
+ orientation?: SelectionGroupOrientation;
86
+ presentation?: SelectionGroupPresentation;
87
+ size?: SelectionControlSize;
88
+ name?: string;
89
+ required?: boolean;
90
+ readOnly?: boolean;
91
+ renderLeading?: (item: CheckboxGroupItem<Key>, appearance: ChoiceLeadingRenderProps) => ReactNode;
92
+ }>;
93
+ export type CheckboxGroupProps<Key extends string = string> = CheckboxGroupBaseProps<Key> & CheckboxGroupSelection<Key>;
94
+ export declare const CheckboxGroup: <Key extends string = string>(props: CheckboxGroupProps<Key> & RefAttributes<HTMLFieldSetElement>) => ReactElement;
95
+ export type RadioGroupItem = Readonly<{
96
+ value: string;
97
+ label: ReactNode;
98
+ description?: ReactNode;
99
+ disabled?: boolean;
100
+ }>;
101
+ type RadioGroupLabelProps = Readonly<{
102
+ label: ReactNode;
103
+ accessibilityLabel?: string;
104
+ }> | Readonly<{
105
+ label?: never;
106
+ accessibilityLabel: string;
107
+ }>;
108
+ export type RadioGroupProps = Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "defaultValue" | "onChange" | "value"> & RadioGroupLabelProps & Readonly<{
109
+ items: readonly RadioGroupItem[];
110
+ value?: string | null;
111
+ defaultValue?: string | null;
112
+ onValueChange?: (value: string) => void;
113
+ orientation?: SelectionGroupOrientation;
114
+ presentation?: SelectionGroupPresentation;
115
+ size?: SelectionControlSize;
116
+ description?: ReactNode;
117
+ error?: ReactNode;
118
+ name?: string;
119
+ required?: boolean;
120
+ readOnly?: boolean;
121
+ renderLeading?: (item: RadioGroupItem, appearance: ChoiceLeadingRenderProps) => ReactNode;
122
+ }>;
123
+ export declare const RadioGroup: import("react").ForwardRefExoticComponent<RadioGroupProps & RefAttributes<HTMLFieldSetElement>>;
124
+ export type SwitchProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "role" | "onChange" | "value"> & Readonly<{
125
+ label: ReactNode;
126
+ checked?: boolean;
127
+ defaultChecked?: boolean;
128
+ onCheckedChange?: (checked: boolean) => void;
129
+ }>;
130
+ export declare const Switch: import("react").ForwardRefExoticComponent<Omit<ButtonHTMLAttributes<HTMLButtonElement>, "value" | "onChange" | "role"> & Readonly<{
131
+ label: ReactNode;
132
+ checked?: boolean;
133
+ defaultChecked?: boolean;
134
+ onCheckedChange?: (checked: boolean) => void;
135
+ }> & RefAttributes<HTMLButtonElement>>;
136
+ export type SegmentedControlItem = Readonly<{
137
+ value: string;
138
+ label: ReactNode;
139
+ disabled?: boolean;
140
+ }>;
141
+ export type SegmentedControlProps = Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "defaultValue" | "onChange" | "value"> & Readonly<{
142
+ label: string;
143
+ items: readonly SegmentedControlItem[];
144
+ value?: string;
145
+ defaultValue?: string;
146
+ onValueChange?: (value: string) => void;
147
+ size?: SegmentedControlSize;
148
+ name?: string;
149
+ }>;
150
+ export declare const SegmentedControl: import("react").ForwardRefExoticComponent<Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "value" | "defaultValue" | "onChange"> & Readonly<{
151
+ label: string;
152
+ items: readonly SegmentedControlItem[];
153
+ value?: string;
154
+ defaultValue?: string;
155
+ onValueChange?: (value: string) => void;
156
+ size?: SegmentedControlSize;
157
+ name?: string;
158
+ }> & RefAttributes<HTMLFieldSetElement>>;
159
+ export {};
160
+ //# sourceMappingURL=selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../src/selection.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAKV,KAAK,oBAAoB,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