@pixum/combobox 5.10.4-alpha.9 → 5.10.4

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 (45) hide show
  1. package/lib/ComboBox.d.ts +6 -32
  2. package/lib/ComboBox.js +77 -217
  3. package/lib/ComboBox.js.map +1 -1
  4. package/lib/hooks/index.d.ts +0 -2
  5. package/lib/hooks/index.js +0 -2
  6. package/lib/hooks/index.js.map +1 -1
  7. package/lib/hooks/useIsDesktopScreenWidth.d.ts +0 -5
  8. package/lib/hooks/useIsDesktopScreenWidth.js +24 -34
  9. package/lib/hooks/useIsDesktopScreenWidth.js.map +1 -1
  10. package/lib/index.d.ts +4 -4
  11. package/lib/index.js +3 -2
  12. package/lib/index.js.map +1 -1
  13. package/lib/partials/ComboBoxOptions.d.ts +5 -16
  14. package/lib/partials/ComboBoxOptions.js +21 -25
  15. package/lib/partials/ComboBoxOptions.js.map +1 -1
  16. package/lib/partials/ComboBoxOptionsItems.d.ts +17 -32
  17. package/lib/partials/ComboBoxOptionsItems.js +14 -46
  18. package/lib/partials/ComboBoxOptionsItems.js.map +1 -1
  19. package/lib/partials/ComboBoxOptionsSlot.d.ts +16 -17
  20. package/lib/partials/ComboBoxOptionsSlot.js +11 -26
  21. package/lib/partials/ComboBoxOptionsSlot.js.map +1 -1
  22. package/lib/partials/index.d.ts +1 -2
  23. package/lib/partials/index.js +1 -2
  24. package/lib/partials/index.js.map +1 -1
  25. package/lib/types.d.ts +45 -183
  26. package/lib/utils/index.d.ts +2 -1
  27. package/lib/utils/index.js +2 -1
  28. package/lib/utils/index.js.map +1 -1
  29. package/package.json +8 -8
  30. package/lib/ComboBox.module.css +0 -1
  31. package/lib/hooks/useComboBox.d.ts +0 -60
  32. package/lib/hooks/useComboBox.js +0 -226
  33. package/lib/hooks/useComboBox.js.map +0 -1
  34. package/lib/hooks/useComboBoxFocus.d.ts +0 -35
  35. package/lib/hooks/useComboBoxFocus.js +0 -49
  36. package/lib/hooks/useComboBoxFocus.js.map +0 -1
  37. package/lib/partials/ComboBoxNoResults.d.ts +0 -14
  38. package/lib/partials/ComboBoxNoResults.js +0 -18
  39. package/lib/partials/ComboBoxNoResults.js.map +0 -1
  40. package/lib/partials/ComboBoxOptionsGroup.d.ts +0 -15
  41. package/lib/partials/ComboBoxOptionsGroup.js +0 -31
  42. package/lib/partials/ComboBoxOptionsGroup.js.map +0 -1
  43. package/lib/utils/options.d.ts +0 -77
  44. package/lib/utils/options.js +0 -145
  45. package/lib/utils/options.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA"}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@pixum/combobox",
3
- "version": "5.10.4-alpha.9+641f65217",
3
+ "version": "5.10.4",
4
4
  "main": "lib/index.js",
5
5
  "module": "lib/index.js",
6
6
  "license": "UNLICENSED",
7
7
  "peerDependencies": {
8
- "@pixum/bottom-sheet": "4.9.0",
9
- "@pixum/menu": "4.4.2",
10
- "@pixum/menu-item": "3.4.3",
11
- "@pixum/text": "3.7.0",
12
- "@pixum/theme-provider": "^6.0.0",
13
- "@pixum/web-input": "2.5.6"
8
+ "@pixum/bottom-sheet": "3.0.18",
9
+ "@pixum/menu": "3.0.14",
10
+ "@pixum/menu-item": "2.0.14",
11
+ "@pixum/text": ">=3.7.0",
12
+ "@pixum/theme-provider": "4.2.20",
13
+ "@pixum/web-input": "2.1.0"
14
14
  },
15
15
  "files": [
16
16
  "lib"
@@ -18,5 +18,5 @@
18
18
  "sideEffects": [
19
19
  "*.css"
20
20
  ],
21
- "gitHead": "641f652171b36ce0d96b656e7c722d7844b4a20f"
21
+ "gitHead": "c35ea45674d22f8c3d61a4dee262649498c425a3"
22
22
  }
@@ -1 +0,0 @@
1
- .comboBox{position:relative;width:100%}.comboBox .headline[class*=text--]+*{margin-top:var(--spacing)}:is(.comboBox,.sheet) :is(.panel,.optionsSlot,.header){position:relative;width:100%}:is(.comboBox,.sheet) .panel{display:flex;flex-direction:column;max-height:inherit;overflow:hidden}:is(.sheet) .panel{box-shadow:none}:is(.comboBox,.sheet) :is(.options,.optionsSlot){display:flex;flex:1 1 auto;flex-direction:column;min-height:0;overflow:auto;scroll-padding-block-start:var(--combobox-sticky-offset,2.75rem)}.sheet .header{align-items:flex-start;height:auto;margin:var(--spacing-5) auto var(--spacing-2);padding:0 var(--spacing-2)}:is(.comboBox,.sheet) ul.optionsSlot{list-style:none;padding:0}:is(.comboBox,.sheet) .option{cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}:is(.comboBox,.sheet) .optionCheckbox[data-selected=true] :global(.menu-item){background-color:initial}:is(.comboBox,.sheet) .option.optionActive :global(.menu-item),:is(.comboBox,.sheet) .optionCheckbox.optionActive :global(.menu-item){background-color:var(--color-canvas--hover)}:is(.comboBox,.sheet) .option[data-selected=true]:not(.optionCheckbox) :global(.menu-item){background-color:var(--color-accent);color:var(--color-surface)}:is(.comboBox,.sheet) .option[aria-disabled=true]{cursor:not-allowed;opacity:.5}@media (forced-colors:active){:is(.comboBox,.sheet) .option.optionActive :global(.menu-item){outline:2px solid Highlight;outline-offset:-2px}}:is(.comboBox,.sheet) .stickyHeader{background-color:var(--color-surface);border-bottom:1px solid var(--color-dim);padding:var(--spacing-1_25) var(--spacing-2);position:-webkit-sticky;position:sticky;top:0}:is(.comboBox,.sheet) .options :global(.text--caption){color:var(--color-on-secondary)}:is(.comboBox,.sheet) .option[data-selected=true]:not(.optionCheckbox) :global(.menu-item .text--caption){color:var(--color-surface)}:is(.comboBox,.sheet) .options :global(.item-header){display:flex;justify-content:space-between}:is(.comboBox,.sheet) .optionDetails{background-color:var(--color-surface);border-top:1px solid var(--color-dim);flex:0 0 auto;padding:var(--spacing-1_25) var(--spacing)}:is(.comboBox,.sheet) .noResults{padding:var(--spacing-2) var(--spacing);text-align:center}@media screen and (min-width:960px){.comboBox :is(.panel,.optionsSlot){border-radius:var(--border-radius-3);margin-top:var(--spacing);max-height:330px;position:absolute}}
@@ -1,60 +0,0 @@
1
- import type { ComboBoxAriaProps, ComboBoxOption, ListboxAriaProps } from '../types';
2
- export interface UseComboBoxOptions {
3
- /** Normalised options in render order. */
4
- options: ComboBoxOption[];
5
- /** Whether the list is currently open. */
6
- isOpen: boolean;
7
- /** Opens the list. */
8
- open: () => void;
9
- /**
10
- * Closes the list. `restoreFocus` is `false` when the focus must stay where
11
- * the user put it (Tab).
12
- */
13
- close: (restoreFocus?: boolean) => void;
14
- /** Values that are currently selected. */
15
- selectedValues: string[];
16
- /** Called with the value of the option that was activated by the keyboard. */
17
- onSelect: (value: string) => void;
18
- /** Id of the listbox element. */
19
- listboxId: string;
20
- /** Whether the open list offers a freely typeable search field. */
21
- searchable?: boolean;
22
- /** Multi select keeps the list open after a selection. */
23
- multiple?: boolean;
24
- /** Enter opens the closed list (APG select-only). */
25
- openOnEnter?: boolean;
26
- }
27
- export interface UseComboBoxResult {
28
- /** ARIA props for the element that owns the `combobox` role. */
29
- comboboxAriaProps: ComboBoxAriaProps;
30
- /** ARIA props for the element that owns the `listbox` role. */
31
- listboxAriaProps: ListboxAriaProps;
32
- /** Keyboard handler for the combobox element. */
33
- onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
34
- /** DOM id of the active option, `undefined` while closed. */
35
- activeOptionId: string | undefined;
36
- /** Index of the active option, `null` while closed or empty. */
37
- activeIndex: number | null;
38
- }
39
- /**
40
- * Headless controller for the WAI-ARIA combobox pattern.
41
- *
42
- * The focus never moves into the list: the active option is communicated
43
- * exclusively via `aria-activedescendant`, which keeps the search field
44
- * typeable while the user navigates.
45
- *
46
- * Keyboard (APG combobox with listbox popup):
47
- * - closed: ArrowUp/ArrowDown/Alt+ArrowDown, Enter, Space open the list
48
- * - open: ArrowUp/ArrowDown navigate (skipping disabled options),
49
- * Home/End jump to the first/last option, Enter selects,
50
- * Escape and Alt+ArrowUp close, Tab closes and lets the focus move on
51
- * - Space selects while the field is not typeable; as soon as a search field
52
- * is open it types a space character instead, as APG requires
53
- *
54
- * On open the starting point is always the selected option, so ArrowDown moves
55
- * to the option right after it.
56
- *
57
- * @param options - Configuration of the combobox
58
- * @returns ARIA props, the keyboard handler and the active option
59
- */
60
- export declare function useComboBox({ options, isOpen, open, close, selectedValues, onSelect, listboxId, searchable, multiple, openOnEnter, }: UseComboBoxOptions): UseComboBoxResult;
@@ -1,226 +0,0 @@
1
- 'use client';
2
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
- import { findEnabledIndex } from '../utils';
4
- /**
5
- * Headless controller for the WAI-ARIA combobox pattern.
6
- *
7
- * The focus never moves into the list: the active option is communicated
8
- * exclusively via `aria-activedescendant`, which keeps the search field
9
- * typeable while the user navigates.
10
- *
11
- * Keyboard (APG combobox with listbox popup):
12
- * - closed: ArrowUp/ArrowDown/Alt+ArrowDown, Enter, Space open the list
13
- * - open: ArrowUp/ArrowDown navigate (skipping disabled options),
14
- * Home/End jump to the first/last option, Enter selects,
15
- * Escape and Alt+ArrowUp close, Tab closes and lets the focus move on
16
- * - Space selects while the field is not typeable; as soon as a search field
17
- * is open it types a space character instead, as APG requires
18
- *
19
- * On open the starting point is always the selected option, so ArrowDown moves
20
- * to the option right after it.
21
- *
22
- * @param options - Configuration of the combobox
23
- * @returns ARIA props, the keyboard handler and the active option
24
- */
25
- export function useComboBox({ options, isOpen, open, close, selectedValues, onSelect, listboxId, searchable = true, multiple = false, openOnEnter = true, }) {
26
- var _a;
27
- const [activeIndex, setActiveIndex] = useState(null);
28
- /**
29
- * Read inside effects only. Keeping the selection in a ref avoids re-running
30
- * the "open" effect when a consumer passes a new array instance per render.
31
- */
32
- const selectedValuesRef = useRef(selectedValues);
33
- selectedValuesRef.current = selectedValues;
34
- /** Tracks the closed -> open edge so navigation is not reset while open. */
35
- const wasOpen = useRef(false);
36
- /**
37
- * Active option requested while the list was still closed (Home/End). The
38
- * open effect consumes it instead of falling back to the selected option.
39
- */
40
- const pendingActiveIndex = useRef(null);
41
- /** Typing is only possible while an open search field is rendered. */
42
- const canType = isOpen && searchable;
43
- /**
44
- * Sets the starting point when the list opens: the selected option, or the
45
- * first enabled one as a fallback.
46
- */
47
- useEffect(() => {
48
- if (!isOpen) {
49
- wasOpen.current = false;
50
- setActiveIndex(null);
51
- return;
52
- }
53
- if (wasOpen.current)
54
- return;
55
- wasOpen.current = true;
56
- const pending = pendingActiveIndex.current;
57
- pendingActiveIndex.current = null;
58
- if (pending !== null) {
59
- setActiveIndex(pending);
60
- return;
61
- }
62
- const selectedIndex = options.findIndex(option => !option.disabled && selectedValuesRef.current.includes(option.value));
63
- setActiveIndex(selectedIndex !== -1 ? selectedIndex : findEnabledIndex(options, -1, 1));
64
- }, [isOpen, options]);
65
- /**
66
- * Keeps the active index valid while the list is filtered down.
67
- */
68
- useEffect(() => {
69
- if (!isOpen)
70
- return;
71
- setActiveIndex(previous => {
72
- const isStillValid = previous !== null &&
73
- previous < options.length &&
74
- !options[previous].disabled;
75
- if (isStillValid)
76
- return previous;
77
- return findEnabledIndex(options, -1, 1);
78
- });
79
- }, [isOpen, options]);
80
- /**
81
- * Moves the active option by `delta` positions, wrapping around and skipping
82
- * disabled options.
83
- *
84
- * @param delta - Number of positions to move; negative moves backwards
85
- */
86
- const move = useCallback((delta) => setActiveIndex(previous => findEnabledIndex(options, previous !== null && previous !== void 0 ? previous : (delta > 0 ? -1 : 0), delta)), [options]);
87
- /**
88
- * Selects the active option. In single select the list closes afterwards,
89
- * in multi select it stays open so further options can be toggled.
90
- */
91
- const selectActiveOption = useCallback(() => {
92
- if (activeIndex === null)
93
- return;
94
- const option = options[activeIndex];
95
- if (!option || option.disabled)
96
- return;
97
- onSelect(option.value);
98
- }, [activeIndex, options, onSelect]);
99
- const onKeyDown = useCallback(event => {
100
- switch (event.key) {
101
- case 'ArrowDown':
102
- case 'ArrowUp': {
103
- event.preventDefault();
104
- if (!isOpen) {
105
- open();
106
- break;
107
- }
108
- // Alt+ArrowUp closes and keeps the current selection.
109
- if (event.key === 'ArrowUp' && event.altKey) {
110
- close();
111
- break;
112
- }
113
- // Alt+ArrowDown only opens, it never moves the active option.
114
- if (event.altKey)
115
- break;
116
- move(event.key === 'ArrowDown' ? 1 : -1);
117
- break;
118
- }
119
- case 'Enter': {
120
- if (!isOpen) {
121
- if (!openOnEnter)
122
- break;
123
- // preventDefault stops an implicit form submit.
124
- event.preventDefault();
125
- open();
126
- break;
127
- }
128
- if (activeIndex === null)
129
- break;
130
- event.preventDefault();
131
- selectActiveOption();
132
- break;
133
- }
134
- case ' ': {
135
- // An open search field must receive a real space character.
136
- if (canType)
137
- break;
138
- event.preventDefault();
139
- if (isOpen && activeIndex !== null) {
140
- selectActiveOption();
141
- break;
142
- }
143
- open();
144
- break;
145
- }
146
- case 'Escape': {
147
- if (!isOpen)
148
- break;
149
- event.preventDefault();
150
- close();
151
- break;
152
- }
153
- case 'Tab': {
154
- // No preventDefault: the focus moves on, the popup just closes.
155
- if (isOpen)
156
- close(false);
157
- break;
158
- }
159
- case 'Home':
160
- case 'End': {
161
- if (options.length === 0)
162
- break;
163
- event.preventDefault();
164
- const targetIndex = event.key === 'Home'
165
- ? findEnabledIndex(options, -1, 1)
166
- : findEnabledIndex(options, options.length, -1);
167
- // Closed: open first, the effect picks the index up from the ref.
168
- if (!isOpen) {
169
- pendingActiveIndex.current = targetIndex;
170
- open();
171
- break;
172
- }
173
- setActiveIndex(targetIndex);
174
- break;
175
- }
176
- default:
177
- break;
178
- }
179
- }, [
180
- isOpen,
181
- open,
182
- close,
183
- move,
184
- activeIndex,
185
- selectActiveOption,
186
- canType,
187
- openOnEnter,
188
- options,
189
- ]);
190
- const activeOptionId = isOpen && activeIndex !== null ? (_a = options[activeIndex]) === null || _a === void 0 ? void 0 : _a.id : undefined;
191
- /**
192
- * Scrolls the active option into view. Purely DOM based, so it works for the
193
- * desktop popover and the bottom sheet alike.
194
- */
195
- useEffect(() => {
196
- if (!activeOptionId)
197
- return;
198
- const frameId = requestAnimationFrame(() => {
199
- var _a;
200
- (_a = document
201
- .getElementById(activeOptionId)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: 'nearest' });
202
- });
203
- return () => cancelAnimationFrame(frameId);
204
- }, [activeOptionId]);
205
- const comboboxAriaProps = useMemo(() => ({
206
- role: 'combobox',
207
- 'aria-expanded': isOpen,
208
- 'aria-haspopup': 'listbox',
209
- 'aria-controls': isOpen ? listboxId : undefined,
210
- 'aria-activedescendant': activeOptionId,
211
- 'aria-autocomplete': searchable ? 'list' : 'none',
212
- }), [isOpen, listboxId, activeOptionId, searchable]);
213
- const listboxAriaProps = useMemo(() => ({
214
- role: 'listbox',
215
- id: listboxId,
216
- 'aria-multiselectable': multiple || undefined,
217
- }), [listboxId, multiple]);
218
- return {
219
- comboboxAriaProps,
220
- listboxAriaProps,
221
- onKeyDown,
222
- activeOptionId,
223
- activeIndex,
224
- };
225
- }
226
- //# sourceMappingURL=useComboBox.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useComboBox.js","sourceRoot":"","sources":["../../src/hooks/useComboBox.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AA8C3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACL,cAAc,EACd,QAAQ,EACR,SAAS,EACT,UAAU,GAAG,IAAI,EACjB,QAAQ,GAAG,KAAK,E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E,OAAM;QAE3B,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,EAAE;;YACzC,MAAA,QAAQ;iBACL,cAAc,CAAC,cAAc,CAAC,0CAC7B,cAAc,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAA;QAEF,OAAO,GAAG,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAA;IAEpB,MAAM,iBAAiB,GAAG,OAAO,CAC/B,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,eAAe,EAAE,SAAS;QAC1B,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC/C,uBAAuB,EAAE,cAAc;QACvC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;KAClD,CAAC,EACF,CAAC,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,CAAC,CAChD,CAAA;IAED,MAAM,gBAAgB,GAAG,OAAO,CAC9B,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,SAAS;QACb,sBAAsB,EAAE,QAAQ,IAAI,SAAS;KAC9C,CAAC,EACF,CAAC,SAAS,EAAE,QAAQ,CAAC,CACtB,CAAA;IAED,OAAO;QACL,iBAAiB;QACjB,gBAAgB;QAChB,SAAS;QACT,cAAc;QACd,WAAW;KACZ,CAAA;AACH,CAAC"}
@@ -1,35 +0,0 @@
1
- export interface UseComboBoxFocusResult {
2
- /**
3
- * Ref for the trigger field (SelectInput).
4
- *
5
- * `| null` is part of the type parameter: since React 19 `useRef<T>(null)`
6
- * returns `RefObject<T | null>` instead of the old `RefObject<T>`.
7
- */
8
- triggerRef: React.RefObject<HTMLInputElement | null>;
9
- /**
10
- * Callback ref for the search field. Focuses it the moment it is mounted -
11
- * in the desktop popover as well as in the bottom sheet.
12
- */
13
- searchInputRef: (input: HTMLInputElement | null) => void;
14
- /** Moves the focus back to the trigger without re-opening the list. */
15
- returnFocusToTrigger: () => void;
16
- /**
17
- * Whether the current focus event on the trigger was caused by
18
- * `returnFocusToTrigger` and must therefore not open the list.
19
- */
20
- isReturningFocus: () => boolean;
21
- }
22
- /**
23
- * Bundles the focus choreography of the ComboBox:
24
- *
25
- * - opening moves the focus into the search field as soon as it mounts,
26
- * - closing moves it back to the trigger,
27
- * - the focus handler of the trigger can tell a returning focus from a real
28
- * user focus and therefore does not re-open the list it just closed.
29
- *
30
- * The search field is wired up with a callback ref, so both the popover and the
31
- * bottom sheet share one implementation and no polling is needed.
32
- *
33
- * @returns Refs and helpers for the focus handling
34
- */
35
- export declare function useComboBoxFocus(): UseComboBoxFocusResult;
@@ -1,49 +0,0 @@
1
- 'use client';
2
- import { useCallback, useEffect, useRef } from 'react';
3
- /**
4
- * Bundles the focus choreography of the ComboBox:
5
- *
6
- * - opening moves the focus into the search field as soon as it mounts,
7
- * - closing moves it back to the trigger,
8
- * - the focus handler of the trigger can tell a returning focus from a real
9
- * user focus and therefore does not re-open the list it just closed.
10
- *
11
- * The search field is wired up with a callback ref, so both the popover and the
12
- * bottom sheet share one implementation and no polling is needed.
13
- *
14
- * @returns Refs and helpers for the focus handling
15
- */
16
- export function useComboBoxFocus() {
17
- const triggerRef = useRef(null);
18
- const returningFocus = useRef(false);
19
- const frameRef = useRef(null);
20
- useEffect(() => () => {
21
- if (frameRef.current !== null)
22
- cancelAnimationFrame(frameRef.current);
23
- }, []);
24
- const searchInputRef = useCallback((input) => {
25
- if (!input)
26
- return;
27
- input.focus();
28
- // One frame later, so Safari does not drop the selection again when
29
- // `readOnly` changes within the same render.
30
- requestAnimationFrame(() => {
31
- var _a;
32
- (_a = input.setSelectionRange) === null || _a === void 0 ? void 0 : _a.call(input, 0, input.value.length);
33
- });
34
- }, []);
35
- const returnFocusToTrigger = useCallback(() => {
36
- returningFocus.current = true;
37
- // Wait for the commit that unmounts the popover / bottom sheet, otherwise
38
- // the focus would end up on `<body>`.
39
- frameRef.current = requestAnimationFrame(() => {
40
- var _a;
41
- (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
42
- // `focus()` dispatches synchronously, so the flag has served its purpose.
43
- returningFocus.current = false;
44
- });
45
- }, []);
46
- const isReturningFocus = useCallback(() => returningFocus.current, []);
47
- return { triggerRef, searchInputRef, returnFocusToTrigger, isReturningFocus };
48
- }
49
- //# sourceMappingURL=useComboBoxFocus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useComboBoxFocus.js","sourceRoot":"","sources":["../../src/hooks/useComboBoxFocus.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAwBtD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,UAAU,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAA;IACjD,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACpC,MAAM,QAAQ,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAA;IAE5C,SAAS,CACP,GAAG,EAAE,CAAC,GAAG,EAAE;QACT,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI;YAAE,oBAAoB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IACvE,CAAC,EACD,EAAE,CACH,CAAA;IAED,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,KAA8B,EAAE,EAAE;QACpE,IAAI,CAAC,KAAK;YAAE,OAAM;QAElB,KAAK,CAAC,KAAK,EAAE,CAAA;QAEb,oEAAoE;QACpE,6CAA6C;QAC7C,qBAAqB,CAAC,GAAG,EAAE;;YACzB,MAAA,KAAK,CAAC,iBAAiB,sDAAG,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAClD,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC5C,cAAc,CAAC,OAAO,GAAG,IAAI,CAAA;QAE7B,0EAA0E;QAC1E,sCAAsC;QACtC,QAAQ,CAAC,OAAO,GAAG,qBAAqB,CAAC,GAAG,EAAE;;YAC5C,MAAA,UAAU,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAA;YAC3B,0EAA0E;YAC1E,cAAc,CAAC,OAAO,GAAG,KAAK,CAAA;QAChC,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,gBAAgB,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IAEtE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAA;AAC/E,CAAC"}
@@ -1,14 +0,0 @@
1
- export interface ComboBoxNoResultsProps {
2
- /** Message shown when no option matches the search. */
3
- text?: string;
4
- }
5
- /**
6
- * Empty state of the options list.
7
- *
8
- * `role="status"` makes screen readers announce the message when the list is
9
- * filtered down to nothing.
10
- *
11
- * @param props - The props for the ComboBoxNoResults component
12
- * @returns The no-results message
13
- */
14
- export declare function ComboBoxNoResults({ text }: ComboBoxNoResultsProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,18 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import Text, { TEXT_VARIANT } from '@pixum/text';
3
- import styles from '../ComboBox.module.css';
4
- /**
5
- * Empty state of the options list.
6
- *
7
- * `role="status"` makes screen readers announce the message when the list is
8
- * filtered down to nothing.
9
- *
10
- * @param props - The props for the ComboBoxNoResults component
11
- * @returns The no-results message
12
- */
13
- export function ComboBoxNoResults({ text }) {
14
- if (!text)
15
- return null;
16
- return (_jsx(Text, { variant: TEXT_VARIANT.SUBHEADLINE, className: styles.noResults, children: text }));
17
- }
18
- //# sourceMappingURL=ComboBoxNoResults.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComboBoxNoResults.js","sourceRoot":"","sources":["../../src/partials/ComboBoxNoResults.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAO3C;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,IAAI,EAA0B;IAChE,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,OAAO,CACL,KAAC,IAAI,IAAC,OAAO,EAAE,YAAY,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,YACjE,IAAI,GACA,CACR,CAAA;AACH,CAAC"}
@@ -1,15 +0,0 @@
1
- import type { ComboBoxOptionsItemsProps } from './ComboBoxOptionsItems';
2
- export interface ComboBoxOptionsGroupProps extends ComboBoxOptionsItemsProps {
3
- /** Group headline. Without it the options are rendered without a header. */
4
- group?: string;
5
- }
6
- /**
7
- * Renders one group of options with an optional sticky headline.
8
- *
9
- * Flat lists use the same component with `group` left undefined, so there is
10
- * only one place that renders options.
11
- *
12
- * @param props - The props for the ComboBoxOptionsGroup component
13
- * @returns A group container with an optional header and its options
14
- */
15
- export declare function ComboBoxOptionsGroup({ group, ...itemProps }: ComboBoxOptionsGroupProps): import("react/jsx-runtime").JSX.Element;
@@ -1,31 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import Text, { TEXT_VARIANT } from '@pixum/text';
14
- import { ComboBoxOptionsItems } from './ComboBoxOptionsItems';
15
- import styles from '../ComboBox.module.css';
16
- /**
17
- * Renders one group of options with an optional sticky headline.
18
- *
19
- * Flat lists use the same component with `group` left undefined, so there is
20
- * only one place that renders options.
21
- *
22
- * @param props - The props for the ComboBoxOptionsGroup component
23
- * @returns A group container with an optional header and its options
24
- */
25
- export function ComboBoxOptionsGroup(_a) {
26
- var { group } = _a, itemProps = __rest(_a, ["group"]);
27
- if (!group)
28
- return _jsx(ComboBoxOptionsItems, Object.assign({}, itemProps));
29
- return (_jsxs("div", { role: "group", "aria-label": group, children: [_jsx(Text, { variant: TEXT_VARIANT.HEADLINE, className: styles.stickyHeader, children: group }), _jsx(ComboBoxOptionsItems, Object.assign({}, itemProps))] }));
30
- }
31
- //# sourceMappingURL=ComboBoxOptionsGroup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComboBoxOptionsGroup.js","sourceRoot":"","sources":["../../src/partials/ComboBoxOptionsGroup.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAQ3C;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAGT;QAHS,EACnC,KAAK,OAEqB,EADvB,SAAS,cAFuB,SAGpC,CADa;IAEZ,IAAI,CAAC,KAAK;QAAE,OAAO,KAAC,oBAAoB,oBAAK,SAAS,EAAI,CAAA;IAE1D,OAAO,CACL,eAAK,IAAI,EAAC,OAAO,gBAAa,KAAK,aACjC,KAAC,IAAI,IAAC,OAAO,EAAE,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,YAAY,YACjE,KAAK,GACD,EACP,KAAC,oBAAoB,oBAAK,SAAS,EAAI,IACnC,CACP,CAAA;AACH,CAAC"}
@@ -1,77 +0,0 @@
1
- import type { MenuItemProps } from '@pixum/menu-item';
2
- import type { ComboBoxOption, ComboBoxOptionGroup, ComboBoxOptionItemProps, ComboBoxOptionsInput } from '../types';
3
- /**
4
- * Resolves the stable value of an option.
5
- *
6
- * `MenuItemProps` does not guarantee a plain string `text`, so the value is
7
- * resolved in three steps: the visible label first - that is the value existing
8
- * consumers pass in as `value` and get back from `onOptionItemClick` -, then
9
- * the explicit `key`, and finally the render index as a last resort so that
10
- * options without a label still get a unique value.
11
- *
12
- * @param item - The option as handed in by the consumer
13
- * @param index - Position of the option in render order
14
- * @returns The stable value of the option
15
- */
16
- export declare function resolveOptionValue(item: ComboBoxOptionItemProps, index: number): string;
17
- /**
18
- * Returns the label of an option for the trigger field.
19
- *
20
- * Falls back to the resolved value when the option renders a custom node
21
- * instead of a plain string.
22
- *
23
- * @param option - A normalised option
24
- * @returns The label to display in the trigger field
25
- */
26
- export declare function getOptionLabel(option: ComboBoxOption): string;
27
- /**
28
- * Strips the ComboBox specific props from an option so the rest can be spread
29
- * onto the `MenuItem`.
30
- *
31
- * `key` is a reserved React prop and `disabled` is handled by the option
32
- * wrapper (`aria-disabled` plus the click guard); everything else belongs to
33
- * `MenuItem` and is forwarded untouched.
34
- *
35
- * @param item - The option as handed in by the consumer
36
- * @returns The props meant for the `MenuItem`
37
- */
38
- export declare function toMenuItemProps({ key, disabled, ...menuItemProps }: ComboBoxOptionItemProps): MenuItemProps;
39
- /**
40
- * Normalises flat and grouped options into one list in render order.
41
- *
42
- * The index of an entry is identical for both input shapes and is therefore
43
- * used as the option DOM id that `aria-activedescendant` points at. Doing this
44
- * once removes the offset arithmetic that grouped rendering used to need.
45
- *
46
- * @param options - Flat or grouped options as passed in by the consumer
47
- * @param listboxId - Id of the listbox, used as prefix for the option ids
48
- * @returns The normalised options in render order
49
- */
50
- export declare function normaliseOptions(options: ComboBoxOptionsInput, listboxId: string): ComboBoxOption[];
51
- /**
52
- * Splits normalised options back into their render groups while keeping the
53
- * global indices intact, so that the list can be rendered with a single code
54
- * path for flat and grouped options.
55
- *
56
- * @param options - Normalised options in render order
57
- * @returns One entry per consecutive group
58
- */
59
- export declare function groupOptions(options: ComboBoxOption[]): ComboBoxOptionGroup[];
60
- /**
61
- * Normalises the `value` prop to an array, so that single and multi select
62
- * share the same selection logic.
63
- *
64
- * @param value - Selected value(s) or `undefined`
65
- * @returns The selected values as an array
66
- */
67
- export declare function toValueArray(value: string | string[] | undefined): string[];
68
- /**
69
- * Finds the first option that can be activated, starting at `start` and moving
70
- * by `delta` with wrap-around. Disabled options are skipped.
71
- *
72
- * @param options - Normalised options
73
- * @param start - Index to start from; use `-1` to start before the first option
74
- * @param delta - Step width, negative values move backwards
75
- * @returns The index of the next enabled option, or `null` when there is none
76
- */
77
- export declare function findEnabledIndex(options: ComboBoxOption[], start: number, delta: number): number | null;