@cdx-ui/primitives 0.3.3 → 0.3.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 (140) hide show
  1. package/lib/commonjs/select/SelectContent.js +89 -45
  2. package/lib/commonjs/select/SelectContent.js.map +1 -1
  3. package/lib/commonjs/select/SelectDismissButton.js +14 -0
  4. package/lib/commonjs/select/SelectDismissButton.js.map +1 -0
  5. package/lib/commonjs/select/SelectDismissButton.web.js +28 -0
  6. package/lib/commonjs/select/SelectDismissButton.web.js.map +1 -0
  7. package/lib/commonjs/select/SelectEmpty.js +53 -0
  8. package/lib/commonjs/select/SelectEmpty.js.map +1 -0
  9. package/lib/commonjs/select/SelectItem.js +30 -9
  10. package/lib/commonjs/select/SelectItem.js.map +1 -1
  11. package/lib/commonjs/select/SelectListbox.js +47 -0
  12. package/lib/commonjs/select/SelectListbox.js.map +1 -0
  13. package/lib/commonjs/select/SelectRoot.js +110 -21
  14. package/lib/commonjs/select/SelectRoot.js.map +1 -1
  15. package/lib/commonjs/select/SelectSearch.js +81 -0
  16. package/lib/commonjs/select/SelectSearch.js.map +1 -0
  17. package/lib/commonjs/select/SelectSearchStatus.js +14 -0
  18. package/lib/commonjs/select/SelectSearchStatus.js.map +1 -0
  19. package/lib/commonjs/select/SelectSearchStatus.web.js +24 -0
  20. package/lib/commonjs/select/SelectSearchStatus.web.js.map +1 -0
  21. package/lib/commonjs/select/SelectSheetContent.js +67 -0
  22. package/lib/commonjs/select/SelectSheetContent.js.map +1 -0
  23. package/lib/commonjs/select/context.js +5 -1
  24. package/lib/commonjs/select/context.js.map +1 -1
  25. package/lib/commonjs/select/filter.js +16 -0
  26. package/lib/commonjs/select/filter.js.map +1 -0
  27. package/lib/commonjs/select/index.js +34 -0
  28. package/lib/commonjs/select/index.js.map +1 -1
  29. package/lib/commonjs/select/popupRole.js +27 -0
  30. package/lib/commonjs/select/popupRole.js.map +1 -0
  31. package/lib/commonjs/select/useContentFocus.js +10 -21
  32. package/lib/commonjs/select/useContentFocus.js.map +1 -1
  33. package/lib/commonjs/select/useListboxNavigation.js +21 -8
  34. package/lib/commonjs/select/useListboxNavigation.js.map +1 -1
  35. package/lib/commonjs/select/useQueryHighlight.js +50 -0
  36. package/lib/commonjs/select/useQueryHighlight.js.map +1 -0
  37. package/lib/commonjs/select/useSelectTrigger.js +4 -1
  38. package/lib/commonjs/select/useSelectTrigger.js.map +1 -1
  39. package/lib/commonjs/select/useSelectTrigger.web.js +4 -1
  40. package/lib/commonjs/select/useSelectTrigger.web.js.map +1 -1
  41. package/lib/module/select/SelectContent.js +94 -48
  42. package/lib/module/select/SelectContent.js.map +1 -1
  43. package/lib/module/select/SelectDismissButton.js +10 -0
  44. package/lib/module/select/SelectDismissButton.js.map +1 -0
  45. package/lib/module/select/SelectDismissButton.web.js +24 -0
  46. package/lib/module/select/SelectDismissButton.web.js.map +1 -0
  47. package/lib/module/select/SelectEmpty.js +49 -0
  48. package/lib/module/select/SelectEmpty.js.map +1 -0
  49. package/lib/module/select/SelectItem.js +32 -11
  50. package/lib/module/select/SelectItem.js.map +1 -1
  51. package/lib/module/select/SelectListbox.js +43 -0
  52. package/lib/module/select/SelectListbox.js.map +1 -0
  53. package/lib/module/select/SelectRoot.js +111 -22
  54. package/lib/module/select/SelectRoot.js.map +1 -1
  55. package/lib/module/select/SelectSearch.js +77 -0
  56. package/lib/module/select/SelectSearch.js.map +1 -0
  57. package/lib/module/select/SelectSearchStatus.js +10 -0
  58. package/lib/module/select/SelectSearchStatus.js.map +1 -0
  59. package/lib/module/select/SelectSearchStatus.web.js +20 -0
  60. package/lib/module/select/SelectSearchStatus.web.js.map +1 -0
  61. package/lib/module/select/SelectSheetContent.js +63 -0
  62. package/lib/module/select/SelectSheetContent.js.map +1 -0
  63. package/lib/module/select/context.js +2 -0
  64. package/lib/module/select/context.js.map +1 -1
  65. package/lib/module/select/filter.js +11 -0
  66. package/lib/module/select/filter.js.map +1 -0
  67. package/lib/module/select/index.js +5 -1
  68. package/lib/module/select/index.js.map +1 -1
  69. package/lib/module/select/popupRole.js +23 -0
  70. package/lib/module/select/popupRole.js.map +1 -0
  71. package/lib/module/select/useContentFocus.js +11 -22
  72. package/lib/module/select/useContentFocus.js.map +1 -1
  73. package/lib/module/select/useListboxNavigation.js +21 -8
  74. package/lib/module/select/useListboxNavigation.js.map +1 -1
  75. package/lib/module/select/useQueryHighlight.js +46 -0
  76. package/lib/module/select/useQueryHighlight.js.map +1 -0
  77. package/lib/module/select/useSelectTrigger.js +4 -1
  78. package/lib/module/select/useSelectTrigger.js.map +1 -1
  79. package/lib/module/select/useSelectTrigger.web.js +4 -1
  80. package/lib/module/select/useSelectTrigger.web.js.map +1 -1
  81. package/lib/typescript/select/SelectContent.d.ts.map +1 -1
  82. package/lib/typescript/select/SelectDismissButton.d.ts +10 -0
  83. package/lib/typescript/select/SelectDismissButton.d.ts.map +1 -0
  84. package/lib/typescript/select/SelectDismissButton.web.d.ts +9 -0
  85. package/lib/typescript/select/SelectDismissButton.web.d.ts.map +1 -0
  86. package/lib/typescript/select/SelectEmpty.d.ts +12 -0
  87. package/lib/typescript/select/SelectEmpty.d.ts.map +1 -0
  88. package/lib/typescript/select/SelectItem.d.ts.map +1 -1
  89. package/lib/typescript/select/SelectListbox.d.ts +12 -0
  90. package/lib/typescript/select/SelectListbox.d.ts.map +1 -0
  91. package/lib/typescript/select/SelectRoot.d.ts +2 -2
  92. package/lib/typescript/select/SelectRoot.d.ts.map +1 -1
  93. package/lib/typescript/select/SelectSearch.d.ts +18 -0
  94. package/lib/typescript/select/SelectSearch.d.ts.map +1 -0
  95. package/lib/typescript/select/SelectSearchStatus.d.ts +9 -0
  96. package/lib/typescript/select/SelectSearchStatus.d.ts.map +1 -0
  97. package/lib/typescript/select/SelectSearchStatus.web.d.ts +8 -0
  98. package/lib/typescript/select/SelectSearchStatus.web.d.ts.map +1 -0
  99. package/lib/typescript/select/SelectSheetContent.d.ts +14 -0
  100. package/lib/typescript/select/SelectSheetContent.d.ts.map +1 -0
  101. package/lib/typescript/select/context.d.ts +9 -0
  102. package/lib/typescript/select/context.d.ts.map +1 -1
  103. package/lib/typescript/select/filter.d.ts +4 -0
  104. package/lib/typescript/select/filter.d.ts.map +1 -0
  105. package/lib/typescript/select/index.d.ts +6 -2
  106. package/lib/typescript/select/index.d.ts.map +1 -1
  107. package/lib/typescript/select/popupRole.d.ts +18 -0
  108. package/lib/typescript/select/popupRole.d.ts.map +1 -0
  109. package/lib/typescript/select/types.d.ts +129 -8
  110. package/lib/typescript/select/types.d.ts.map +1 -1
  111. package/lib/typescript/select/useContentFocus.d.ts +4 -7
  112. package/lib/typescript/select/useContentFocus.d.ts.map +1 -1
  113. package/lib/typescript/select/useListboxNavigation.d.ts +16 -3
  114. package/lib/typescript/select/useListboxNavigation.d.ts.map +1 -1
  115. package/lib/typescript/select/useQueryHighlight.d.ts +21 -0
  116. package/lib/typescript/select/useQueryHighlight.d.ts.map +1 -0
  117. package/lib/typescript/select/useSelectTrigger.d.ts.map +1 -1
  118. package/lib/typescript/select/useSelectTrigger.web.d.ts.map +1 -1
  119. package/package.json +3 -3
  120. package/src/select/SelectContent.tsx +89 -54
  121. package/src/select/SelectDismissButton.tsx +14 -0
  122. package/src/select/SelectDismissButton.web.tsx +26 -0
  123. package/src/select/SelectEmpty.tsx +61 -0
  124. package/src/select/SelectItem.tsx +42 -10
  125. package/src/select/SelectListbox.tsx +43 -0
  126. package/src/select/SelectRoot.tsx +184 -12
  127. package/src/select/SelectSearch.tsx +98 -0
  128. package/src/select/SelectSearchStatus.tsx +11 -0
  129. package/src/select/SelectSearchStatus.web.tsx +18 -0
  130. package/src/select/SelectSheetContent.tsx +54 -0
  131. package/src/select/context.tsx +9 -0
  132. package/src/select/filter.ts +12 -0
  133. package/src/select/index.ts +14 -1
  134. package/src/select/popupRole.ts +26 -0
  135. package/src/select/types.ts +142 -9
  136. package/src/select/useContentFocus.ts +12 -31
  137. package/src/select/useListboxNavigation.ts +41 -9
  138. package/src/select/useQueryHighlight.ts +61 -0
  139. package/src/select/useSelectTrigger.ts +5 -1
  140. package/src/select/useSelectTrigger.web.ts +5 -1
@@ -10,25 +10,38 @@ var _utils = require("@cdx-ui/utils");
10
10
  var _slot = require("../slot");
11
11
  var _dataAttributes = require("../utils/dataAttributes");
12
12
  var _context = require("./context");
13
+ var _filter = require("./filter");
13
14
  var _jsxRuntime = require("react/jsx-runtime");
14
- const SelectRoot = exports.SelectRoot = /*#__PURE__*/(0, _react.forwardRef)(({
15
- asChild,
16
- children,
17
- items,
18
- value: valueProp,
19
- defaultValue,
20
- onValueChange,
21
- isOpen: openProp,
22
- defaultOpen = false,
23
- onOpenChange,
24
- disabled = false,
25
- isRequired,
26
- isInvalid,
27
- isReadOnly,
28
- native = false,
29
- accessibilityLabel,
30
- ...props
31
- }, ref) => {
15
+ /**
16
+ * Internal widening of the public discriminated union: the runtime accepts either value
17
+ * shape and reads `type` to decide branch behavior. The public API stays narrow.
18
+ */
19
+
20
+ const EMPTY_VALUES = [];
21
+ const SelectRoot = exports.SelectRoot = /*#__PURE__*/(0, _react.forwardRef)((rootProps, ref) => {
22
+ const {
23
+ asChild,
24
+ children,
25
+ items,
26
+ type = 'single',
27
+ value: valueProp,
28
+ defaultValue,
29
+ onValueChange,
30
+ isOpen: openProp,
31
+ defaultOpen = false,
32
+ onOpenChange,
33
+ disabled = false,
34
+ isRequired,
35
+ isInvalid,
36
+ isReadOnly,
37
+ native = false,
38
+ accessibilityLabel,
39
+ inputValue: inputValueProp,
40
+ defaultInputValue = '',
41
+ onInputChange,
42
+ filter = _filter.defaultSelectFilter,
43
+ ...props
44
+ } = rootProps;
32
45
  const formControlProps = (0, _utils.useFormControl)({
33
46
  isDisabled: disabled,
34
47
  isRequired,
@@ -39,15 +52,23 @@ const SelectRoot = exports.SelectRoot = /*#__PURE__*/(0, _react.forwardRef)(({
39
52
  const isEffectivelyRequired = !!formControlProps.required;
40
53
  const isEffectivelyInvalid = !!formControlProps['aria-invalid'];
41
54
  const isEffectivelyReadOnly = !!formControlProps.readOnly;
55
+ const isMultiple = type === 'multiple';
42
56
  const [value, setValue] = (0, _utils.useControllableState)({
43
57
  prop: valueProp,
44
- defaultProp: defaultValue,
58
+ defaultProp: defaultValue ?? (isMultiple ? EMPTY_VALUES : undefined),
45
59
  onChange: newValue => {
46
60
  if (newValue !== undefined) {
47
61
  onValueChange?.(newValue);
48
62
  }
49
63
  }
50
64
  });
65
+ const selectedValues = (0, _react.useMemo)(() => {
66
+ if (isMultiple) {
67
+ return Array.isArray(value) ? value : EMPTY_VALUES;
68
+ }
69
+ return typeof value === 'string' ? [value] : EMPTY_VALUES;
70
+ }, [isMultiple, value]);
71
+ const isSelected = (0, _react.useCallback)(itemValue => selectedValues.includes(itemValue), [selectedValues]);
51
72
  const [open, setOpenState] = (0, _utils.useControllableState)({
52
73
  prop: openProp,
53
74
  defaultProp: defaultOpen,
@@ -60,18 +81,76 @@ const SelectRoot = exports.SelectRoot = /*#__PURE__*/(0, _react.forwardRef)(({
60
81
  setOpenState(newOpen);
61
82
  }, [isEffectivelyDisabled, isEffectivelyReadOnly, setOpenState]);
62
83
  const [activeValue, setActiveValue] = (0, _react.useState)(undefined);
84
+ const [inputValueState, setInputValueState] = (0, _utils.useControllableState)({
85
+ prop: inputValueProp,
86
+ defaultProp: defaultInputValue,
87
+ onChange: onInputChange
88
+ });
89
+ const inputValue = inputValueState ?? '';
90
+ const setInputValue = (0, _react.useCallback)(next => setInputValueState(next), [setInputValueState]);
91
+ const wasOpenRef = (0, _react.useRef)(!!open);
92
+ (0, _react.useEffect)(() => {
93
+ const wasOpen = wasOpenRef.current;
94
+ wasOpenRef.current = !!open;
95
+ if (wasOpen && !open) {
96
+ setInputValueState('');
97
+ }
98
+ }, [open, setInputValueState]);
99
+ const visibleItems = (0, _react.useMemo)(() => inputValue === '' ? items : items.filter(item => filter(item.label, inputValue)), [items, inputValue, filter]);
100
+ const visibleValues = (0, _react.useMemo)(() => new Set(visibleItems.map(item => item.value)), [visibleItems]);
101
+ const isItemVisible = (0, _react.useCallback)(itemValue => inputValue === '' || visibleValues.has(itemValue), [inputValue, visibleValues]);
102
+ const [searchCount, setSearchCount] = (0, _react.useState)(0);
103
+ const registerSearch = (0, _react.useCallback)(() => {
104
+ setSearchCount(count => count + 1);
105
+ return () => setSearchCount(count => count - 1);
106
+ }, []);
107
+ const [emptyText, setEmptyText] = (0, _react.useState)(undefined);
108
+ const toggleValue = (0, _react.useCallback)(itemValue => {
109
+ setValue(prev => {
110
+ const current = Array.isArray(prev) ? prev : EMPTY_VALUES;
111
+ return current.includes(itemValue) ? current.filter(v => v !== itemValue) : [...current, itemValue];
112
+ });
113
+ }, [setValue]);
114
+ const selectValueAndClose = (0, _react.useCallback)(itemValue => {
115
+ setValue(itemValue);
116
+ setOpen(false);
117
+ }, [setValue, setOpen]);
118
+ const commitValue = isMultiple ? toggleValue : selectValueAndClose;
119
+
120
+ /**
121
+ * `Select.Item disabled` lives on the rendered child, not in `items`, so mounted items
122
+ * register here for keyboard navigation. A ref keeps registration from re-rendering the root.
123
+ */
124
+ const disabledItemsRef = (0, _react.useRef)(new Set());
125
+ const registerDisabledItem = (0, _react.useCallback)(itemValue => {
126
+ disabledItemsRef.current.add(itemValue);
127
+ return () => {
128
+ disabledItemsRef.current.delete(itemValue);
129
+ };
130
+ }, []);
131
+ const isItemDisabled = (0, _react.useCallback)(itemValue => isEffectivelyDisabled || disabledItemsRef.current.has(itemValue) || items.some(item => item.value === itemValue && !!item.disabled), [isEffectivelyDisabled, items]);
63
132
  const triggerRef = (0, _react.useRef)(null);
64
133
  const reactId = (0, _react.useId)();
65
134
  /** Align with `useFormControl` default id (`${field.id}-input`) when inside `Form.Field`. */
66
135
  const triggerId = formControlProps.id ?? `select-trigger-${reactId}`;
67
136
  const contentId = `select-content-${reactId}`;
137
+ const listboxId = `${contentId}-listbox`;
68
138
  const ariaDescribedBy = formControlProps['aria-describedby'];
139
+ const labelId = formControlProps['aria-labelledby'];
140
+ const hasSearch = searchCount > 0;
69
141
  const contextValue = (0, _react.useMemo)(() => ({
70
142
  open: open ?? false,
71
143
  items,
72
144
  setOpen,
145
+ type,
73
146
  value,
74
- onValueChange: setValue,
147
+ selectedValues,
148
+ isSelected,
149
+ toggleValue,
150
+ selectValueAndClose,
151
+ commitValue,
152
+ isItemDisabled,
153
+ registerDisabledItem,
75
154
  disabled: isEffectivelyDisabled,
76
155
  required: isEffectivelyRequired,
77
156
  invalid: isEffectivelyInvalid,
@@ -80,11 +159,21 @@ const SelectRoot = exports.SelectRoot = /*#__PURE__*/(0, _react.forwardRef)(({
80
159
  triggerRef,
81
160
  contentId,
82
161
  triggerId,
162
+ inputValue,
163
+ setInputValue,
164
+ visibleItems,
165
+ isItemVisible,
166
+ hasSearch,
167
+ registerSearch,
168
+ emptyText,
169
+ setEmptyText,
170
+ listboxId,
171
+ labelId,
83
172
  activeValue,
84
173
  setActiveValue,
85
174
  accessibilityLabel,
86
175
  ariaDescribedBy
87
- }), [open, items, setOpen, value, setValue, isEffectivelyDisabled, isEffectivelyRequired, isEffectivelyInvalid, isEffectivelyReadOnly, native, contentId, triggerId, activeValue, accessibilityLabel, ariaDescribedBy]);
176
+ }), [open, items, setOpen, type, value, selectedValues, isSelected, toggleValue, selectValueAndClose, commitValue, isItemDisabled, registerDisabledItem, isEffectivelyDisabled, isEffectivelyRequired, isEffectivelyInvalid, isEffectivelyReadOnly, native, contentId, triggerId, inputValue, setInputValue, visibleItems, isItemVisible, hasSearch, registerSearch, emptyText, listboxId, labelId, activeValue, accessibilityLabel, ariaDescribedBy]);
88
177
  const Comp = asChild ? _slot.Slot : _reactNative.View;
89
178
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.SelectProvider, {
90
179
  value: contextValue,
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNative","_utils","_slot","_dataAttributes","_context","_jsxRuntime","SelectRoot","exports","forwardRef","asChild","children","items","value","valueProp","defaultValue","onValueChange","isOpen","openProp","defaultOpen","onOpenChange","disabled","isRequired","isInvalid","isReadOnly","native","accessibilityLabel","props","ref","formControlProps","useFormControl","isDisabled","isEffectivelyDisabled","isEffectivelyRequired","required","isEffectivelyInvalid","isEffectivelyReadOnly","readOnly","setValue","useControllableState","prop","defaultProp","onChange","newValue","undefined","open","setOpenState","setOpen","useCallback","newOpen","activeValue","setActiveValue","useState","triggerRef","useRef","reactId","useId","triggerId","id","contentId","ariaDescribedBy","contextValue","useMemo","invalid","Comp","Slot","View","jsx","SelectProvider","mergeDataAttributes","dataAttributes","readonly","displayName"],"sourceRoot":"../../../src","sources":["select/SelectRoot.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAA2C,IAAAM,WAAA,GAAAN,OAAA;AAQpC,MAAMO,UAAU,GAAAC,OAAA,CAAAD,UAAA,gBAAG,IAAAE,iBAAU,EAClC,CACE;EACEC,OAAO;EACPC,QAAQ;EACRC,KAAK;EACLC,KAAK,EAAEC,SAAS;EAChBC,YAAY;EACZC,aAAa;EACbC,MAAM,EAAEC,QAAQ;EAChBC,WAAW,GAAG,KAAK;EACnBC,YAAY;EACZC,QAAQ,GAAG,KAAK;EAChBC,UAAU;EACVC,SAAS;EACTC,UAAU;EACVC,MAAM,GAAG,KAAK;EACdC,kBAAkB;EAClB,GAAGC;AACL,CAAC,EACDC,GAAG,KACA;EACH,MAAMC,gBAAgB,GAAG,IAAAC,qBAAc,EAAC;IACtCC,UAAU,EAAEV,QAAQ;IACpBC,UAAU;IACVC,SAAS;IACTC;EACF,CAAC,CAAC;EAEF,MAAMQ,qBAAqB,GAAG,CAAC,CAACH,gBAAgB,CAACR,QAAQ;EACzD,MAAMY,qBAAqB,GAAG,CAAC,CAACJ,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","_utils","_slot","_dataAttributes","_context","_filter","_jsxRuntime","EMPTY_VALUES","SelectRoot","exports","forwardRef","rootProps","ref","asChild","children","items","type","value","valueProp","defaultValue","onValueChange","isOpen","openProp","defaultOpen","onOpenChange","disabled","isRequired","isInvalid","isReadOnly","native","accessibilityLabel","inputValue","inputValueProp","defaultInputValue","onInputChange","filter","defaultSelectFilter","props","formControlProps","useFormControl","isDisabled","isEffectivelyDisabled","isEffectivelyRequired","required","isEffectivelyInvalid","isEffectivelyReadOnly","readOnly","isMultiple","setValue","useControllableState","prop","defaultProp","undefined","onChange","newValue","selectedValues","useMemo","Array","isArray","isSelected","useCallback","itemValue","includes","open","setOpenState","setOpen","newOpen","activeValue","setActiveValue","useState","inputValueState","setInputValueState","setInputValue","next","wasOpenRef","useRef","useEffect","wasOpen","current","visibleItems","item","label","visibleValues","Set","map","isItemVisible","has","searchCount","setSearchCount","registerSearch","count","emptyText","setEmptyText","toggleValue","prev","v","selectValueAndClose","commitValue","disabledItemsRef","registerDisabledItem","add","delete","isItemDisabled","some","triggerRef","reactId","useId","triggerId","id","contentId","listboxId","ariaDescribedBy","labelId","hasSearch","contextValue","invalid","Comp","Slot","View","jsx","SelectProvider","mergeDataAttributes","dataAttributes","readonly","displayName"],"sourceRoot":"../../../src","sources":["select/SelectRoot.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAUA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAA+C,IAAAO,WAAA,GAAAP,OAAA;AAS/C;AACA;AACA;AACA;;AAyBA,MAAMQ,YAAsB,GAAG,EAAE;AAE1B,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,gBAAG,IAAAE,iBAAU,EAClC,CAACC,SAAS,EAAE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BAAkB;IAClBiF;EACF,CAAC,CAAC,EACF,CACEhD,IAAI,EACJhD,KAAK,EACLkD,OAAO,EACPjD,IAAI,EACJC,KAAK,EACLsC,cAAc,EACdI,UAAU,EACVkC,WAAW,EACXG,mBAAmB,EACnBC,WAAW,EACXK,cAAc,EACdH,oBAAoB,EACpB1D,qBAAqB,EACrBC,qBAAqB,EACrBE,oBAAoB,EACpBC,qBAAqB,EACrBhB,MAAM,EACNgF,SAAS,EACTF,SAAS,EACT5E,UAAU,EACVyC,aAAa,EACbO,YAAY,EACZM,aAAa,EACb4B,SAAS,EACTxB,cAAc,EACdE,SAAS,EACTmB,SAAS,EACTE,OAAO,EACP7C,WAAW,EACXrC,kBAAkB,EAClBiF,eAAe,CAEnB,CAAC;EAED,MAAMK,IAAI,GAAGvG,OAAO,GAAGwG,UAAI,GAAGC,iBAAI;EAElC,oBACE,IAAAhH,WAAA,CAAAiH,GAAA,EAACnH,QAAA,CAAAoH,cAAc;IAACvG,KAAK,EAAEiG,YAAa;IAAApG,QAAA,eAClC,IAAAR,WAAA,CAAAiH,GAAA,EAACH,IAAI;MACHxG,GAAG,EAAEA,GAAI;MAAA,GACLyB,KAAK;MAAA,GACL,IAAAoF,mCAAmB,EACrBpF,KAAK,EACL,IAAAqF,8BAAc,EAAC;QACbjG,QAAQ,EAAEgB,qBAAqB;QAC/BE,QAAQ,EAAED,qBAAqB;QAC/ByE,OAAO,EAAEvE,oBAAoB;QAC7B+E,QAAQ,EAAE9E;MACZ,CAAC,CACH,CAAC;MAAA/B,QAAA,EAEAA;IAAQ,CACL;EAAC,CACO,CAAC;AAErB,CACF,CAAC;AAEDN,UAAU,CAACoH,WAAW,GAAG,YAAY","ignoreList":[]}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SelectSearch = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _utils = require("@cdx-ui/utils");
10
+ var _slot = require("../slot");
11
+ var _context = require("./context");
12
+ var _SelectSearchStatus = require("./SelectSearchStatus");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ const defaultResultCountLabel = count => count === 1 ? '1 result' : `${String(count)} results`;
15
+
16
+ /**
17
+ * Search input for `Select.Content`. Its query filters the options through the root `filter`.
18
+ * Mounting it turns the popup into a dialog that contains this searchbox and the listbox.
19
+ *
20
+ * Web uses virtual focus: DOM focus stays here, arrow keys move the highlight, and
21
+ * `aria-activedescendant` points at it. Native renders the input without virtual focus.
22
+ */
23
+ const SelectSearch = exports.SelectSearch = /*#__PURE__*/(0, _react.forwardRef)(({
24
+ asChild,
25
+ children,
26
+ accessibilityLabel,
27
+ getResultCountLabel = defaultResultCountLabel,
28
+ onKeyPress,
29
+ ...props
30
+ }, ref) => {
31
+ const {
32
+ inputValue,
33
+ setInputValue,
34
+ registerSearch,
35
+ listboxId,
36
+ contentId,
37
+ activeValue,
38
+ isItemVisible,
39
+ visibleItems,
40
+ emptyText
41
+ } = (0, _context.useSelectContext)();
42
+ const {
43
+ handleKeyDown
44
+ } = (0, _context.useSelectContentContext)();
45
+ (0, _react.useLayoutEffect)(() => registerSearch(), [registerSearch]);
46
+ const activeDescendant = activeValue !== undefined && isItemVisible(activeValue) ? `${contentId}-option-${activeValue}` : undefined;
47
+
48
+ // RNW's TextInput stops keydown propagation, so the listbox keys are handled here.
49
+ const platformProps = _reactNative.Platform.OS === 'web' ? {
50
+ 'aria-controls': listboxId,
51
+ 'aria-autocomplete': 'list',
52
+ 'aria-activedescendant': activeDescendant,
53
+ onKeyPress: (0, _utils.composeEventHandlers)(onKeyPress, handleKeyDown)
54
+ } : {
55
+ onKeyPress
56
+ };
57
+ const count = visibleItems.length;
58
+ const statusMessage = count === 0 && emptyText ? emptyText : getResultCountLabel(count);
59
+ const Comp = asChild ? _slot.Slot : _reactNative.TextInput;
60
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
61
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, {
62
+ ref: ref,
63
+ role: "searchbox",
64
+ value: inputValue,
65
+ onChangeText: setInputValue,
66
+ autoCapitalize: "none",
67
+ autoComplete: "off",
68
+ autoCorrect: false,
69
+ spellCheck: false,
70
+ accessibilityLabel: accessibilityLabel,
71
+ "aria-label": accessibilityLabel,
72
+ ...platformProps,
73
+ ...props,
74
+ children: children
75
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectSearchStatus.SelectSearchStatus, {
76
+ message: statusMessage
77
+ })]
78
+ });
79
+ });
80
+ SelectSearch.displayName = 'SelectSearch';
81
+ //# sourceMappingURL=SelectSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_utils","_slot","_context","_SelectSearchStatus","_jsxRuntime","defaultResultCountLabel","count","String","SelectSearch","exports","forwardRef","asChild","children","accessibilityLabel","getResultCountLabel","onKeyPress","props","ref","inputValue","setInputValue","registerSearch","listboxId","contentId","activeValue","isItemVisible","visibleItems","emptyText","useSelectContext","handleKeyDown","useSelectContentContext","useLayoutEffect","activeDescendant","undefined","platformProps","Platform","OS","composeEventHandlers","length","statusMessage","Comp","Slot","TextInput","jsxs","Fragment","jsx","role","value","onChangeText","autoCapitalize","autoComplete","autoCorrect","spellCheck","SelectSearchStatus","message","displayName"],"sourceRoot":"../../../src","sources":["select/SelectSearch.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAL,OAAA;AAA0D,IAAAM,WAAA,GAAAN,OAAA;AAU1D,MAAMO,uBAAuB,GAAIC,KAAa,IAC5CA,KAAK,KAAK,CAAC,GAAG,UAAU,GAAG,GAAGC,MAAM,CAACD,KAAK,CAAC,UAAU;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,gBACE,IAAAR,WAAA,CAAAwC,GAAA,EAACL,IAAI;MACHtB,GAAG,EAAEA,GAAI;MACT4B,IAAI,EAAC,WAAW;MAChBC,KAAK,EAAE5B,UAAW;MAClB6B,YAAY,EAAE5B,aAAc;MAC5B6B,cAAc,EAAC,MAAM;MACrBC,YAAY,EAAC,KAAK;MAClBC,WAAW,EAAE,KAAM;MACnBC,UAAU,EAAE,KAAM;MAClBtC,kBAAkB,EAAEA,kBAAmB;MACvC,cAAYA,kBAAmB;MAAA,GAC3BoB,aAAa;MAAA,GACbjB,KAAK;MAAAJ,QAAA,EAERA;IAAQ,CACL,CAAC,eACP,IAAAR,WAAA,CAAAwC,GAAA,EAACzC,mBAAA,CAAAiD,kBAAkB;MAACC,OAAO,EAAEf;IAAc,CAAE,CAAC;EAAA,CAC9C,CAAC;AAEP,CACF,CAAC;AAED9B,YAAY,CAAC8C,WAAW,GAAG,cAAc","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SelectSearchStatus = SelectSearchStatus;
7
+ /**
8
+ * Web-only. On native, screen readers move through the rows directly, in the anchored popover
9
+ * or in `Select.BottomSheet`, instead of following an input-driven live region.
10
+ */
11
+ function SelectSearchStatus(_props) {
12
+ return null;
13
+ }
14
+ //# sourceMappingURL=SelectSearchStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SelectSearchStatus","_props"],"sourceRoot":"../../../src","sources":["select/SelectSearchStatus.tsx"],"mappings":";;;;;;AAIA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAACC,MAA+B,EAAE;EAClE,OAAO,IAAI;AACb","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SelectSearchStatus = SelectSearchStatus;
7
+ var _visuallyHidden = require("@react-aria/visually-hidden");
8
+ var _jsxRuntime = require("react/jsx-runtime");
9
+ /**
10
+ * Polite live region for the search results. It stays mounted while the search is, so each
11
+ * change to the count (or to the empty-state text) is announced.
12
+ */
13
+ function SelectSearchStatus({
14
+ message
15
+ }) {
16
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_visuallyHidden.VisuallyHidden, {
17
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
18
+ role: "status",
19
+ "aria-live": "polite",
20
+ children: message
21
+ })
22
+ });
23
+ }
24
+ //# sourceMappingURL=SelectSearchStatus.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_visuallyHidden","require","_jsxRuntime","SelectSearchStatus","message","jsx","VisuallyHidden","children","role"],"sourceRoot":"../../../src","sources":["select/SelectSearchStatus.web.tsx"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAA6D,IAAAC,WAAA,GAAAD,OAAA;AAK7D;AACA;AACA;AACA;AACO,SAASE,kBAAkBA,CAAC;EAAEC;AAAiC,CAAC,EAAE;EACvE,oBACE,IAAAF,WAAA,CAAAG,GAAA,EAACL,eAAA,CAAAM,cAAc;IAAAC,QAAA,eACb,IAAAL,WAAA,CAAAG,GAAA;MAAKG,IAAI,EAAC,QAAQ;MAAC,aAAU,QAAQ;MAAAD,QAAA,EAClCH;IAAO,CACL;EAAC,CACQ,CAAC;AAErB","ignoreList":[]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SelectSheetContent = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _utils = require("@cdx-ui/utils");
10
+ var _slot = require("../slot");
11
+ var _dataAttributes = require("../utils/dataAttributes");
12
+ var _context = require("./context");
13
+ var _popupRole = require("./popupRole");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ /**
16
+ * Native rows take screen-reader focus directly, so the sheet has no listbox keyboard model
17
+ * for `Select.Search` to drive.
18
+ */
19
+ const SHEET_CONTENT_CONTEXT = {
20
+ handleKeyDown: () => undefined
21
+ };
22
+
23
+ /**
24
+ * Body of a native sheet surface that presents the options in place of `SelectContent`. The
25
+ * styled layer owns presentation (open, swipe, backdrop, back) and renders this inside it.
26
+ * It carries the popup role and name, and closes on the VoiceOver escape gesture without
27
+ * changing the value.
28
+ */
29
+ const SelectSheetContent = exports.SelectSheetContent = /*#__PURE__*/(0, _react.forwardRef)(({
30
+ asChild,
31
+ children,
32
+ onAccessibilityEscape,
33
+ ...props
34
+ }, ref) => {
35
+ const {
36
+ setOpen,
37
+ hasSearch,
38
+ labelId,
39
+ accessibilityLabel,
40
+ triggerId,
41
+ contentId
42
+ } = (0, _context.useSelectContext)();
43
+ const dismiss = (0, _react.useCallback)(() => setOpen(false), [setOpen]);
44
+ const roleProps = (0, _popupRole.getPopupRoleProps)({
45
+ hasSearch,
46
+ labelId,
47
+ accessibilityLabel,
48
+ triggerId
49
+ });
50
+ const Comp = asChild ? _slot.Slot : _reactNative.View;
51
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.SelectContentProvider, {
52
+ value: SHEET_CONTENT_CONTEXT,
53
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, {
54
+ ref: ref,
55
+ id: contentId,
56
+ ...roleProps,
57
+ ...props,
58
+ ...(0, _dataAttributes.mergeDataAttributes)(props, (0, _dataAttributes.dataAttributes)({
59
+ state: 'open'
60
+ })),
61
+ onAccessibilityEscape: (0, _utils.composeEventHandlers)(onAccessibilityEscape, dismiss),
62
+ children: children
63
+ })
64
+ });
65
+ });
66
+ SelectSheetContent.displayName = 'SelectSheetContent';
67
+ //# sourceMappingURL=SelectSheetContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_utils","_slot","_dataAttributes","_context","_popupRole","_jsxRuntime","SHEET_CONTENT_CONTEXT","handleKeyDown","undefined","SelectSheetContent","exports","forwardRef","asChild","children","onAccessibilityEscape","props","ref","setOpen","hasSearch","labelId","accessibilityLabel","triggerId","contentId","useSelectContext","dismiss","useCallback","roleProps","getPopupRoleProps","Comp","Slot","View","jsx","SelectContentProvider","value","id","mergeDataAttributes","dataAttributes","state","composeEventHandlers","displayName"],"sourceRoot":"../../../src","sources":["select/SelectSheetContent.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAAgD,IAAAO,WAAA,GAAAP,OAAA;AAQhD;AACA;AACA;AACA;AACA,MAAMQ,qBAAgD,GAAG;EAAEC,aAAa,EAAEA,CAAA,KAAMC;AAAU,CAAC;;AAE3F;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,gBAAG,IAAAE,iBAAU,EAC1C,CAAC;EAAEC,OAAO;EAAEC,QAAQ;EAAEC,qBAAqB;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EAC/D,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC,OAAO;IAAEC,kBAAkB;IAAEC,SAAS;IAAEC;EAAU,CAAC,GAC7E,IAAAC,yBAAgB,EAAC,CAAC;EAEpB,MAAMC,OAAO,GAAG,IAAAC,kBAAW,EAAC,MAAMR,OAAO,CAAC,KAAK,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EAC5D,MAAMS,SAAS,GAAG,IAAAC,4BAAiB,EAAC;IAAET,SAAS;IAAEC,OAAO;IAAEC,kBAAkB;IAAEC;EAAU,CAAC,CAAC;EAE1F,MAAMO,IAAI,GAAGhB,OAAO,GAAGiB,UAAI,GAAGC,iBAAI;EAElC,oBACE,IAAAzB,WAAA,CAAA0B,GAAA,EAAC5B,QAAA,CAAA6B,qBAAqB;IAACC,KAAK,EAAE3B,qBAAsB;IAAAO,QAAA,eAClD,IAAAR,WAAA,CAAA0B,GAAA,EAACH,IAAI;MACHZ,GAAG,EAAEA,GAAI;MACTkB,EAAE,EAAEZ,SAAU;MAAA,GACVI,SAAS;MAAA,GACTX,KAAK;MAAA,GACL,IAAAoB,mCAAmB,EAACpB,KAAK,EAAE,IAAAqB,8BAAc,EAAC;QAAEC,KAAK,EAAE;MAAO,CAAC,CAAC,CAAC;MACjEvB,qBAAqB,EAAE,IAAAwB,2BAAoB,EAACxB,qBAAqB,EAAEU,OAAO,CAAE;MAAAX,QAAA,EAE3EA;IAAQ,CACL;EAAC,CACc,CAAC;AAE5B,CACF,CAAC;AAEDJ,kBAAkB,CAAC8B,WAAW,GAAG,oBAAoB","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useSelectItemContext = exports.useSelectContext = exports.SelectProvider = exports.SelectItemProvider = void 0;
6
+ exports.useSelectItemContext = exports.useSelectContext = exports.useSelectContentContext = exports.SelectProvider = exports.SelectItemProvider = exports.SelectContentProvider = void 0;
7
7
  var _utils = require("@cdx-ui/utils");
8
8
  const [SelectProvider, useSelectContext] = (0, _utils.createContext)('SelectContext');
9
9
 
@@ -16,4 +16,8 @@ exports.SelectProvider = SelectProvider;
16
16
  const [SelectItemProvider, useSelectItemContext] = (0, _utils.createContext)('SelectItemContext');
17
17
  exports.useSelectItemContext = useSelectItemContext;
18
18
  exports.SelectItemProvider = SelectItemProvider;
19
+ /** Internal: lets `Select.Search` drive the listbox from its input. */
20
+ const [SelectContentProvider, useSelectContentContext] = (0, _utils.createContext)('SelectContentContext');
21
+ exports.useSelectContentContext = useSelectContentContext;
22
+ exports.SelectContentProvider = SelectContentProvider;
19
23
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","SelectProvider","useSelectContext","createContext","exports","SelectItemProvider","useSelectItemContext"],"sourceRoot":"../../../src","sources":["select/context.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAM,CAACC,cAAc,EAAEC,gBAAgB,CAAC,GAC7C,IAAAC,oBAAa,EAAqB,eAAe,CAAC;;AAEpD;AACA;AACA;AACA;AAHAC,OAAA,CAAAF,gBAAA,GAAAA,gBAAA;AAAAE,OAAA,CAAAH,cAAA,GAAAA,cAAA;AAIO,MAAM,CAACI,kBAAkB,EAAEC,oBAAoB,CAAC,GACrD,IAAAH,oBAAa,EAA6B,mBAAmB,CAAC;AAACC,OAAA,CAAAE,oBAAA,GAAAA,oBAAA;AAAAF,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_utils","require","SelectProvider","useSelectContext","createContext","exports","SelectItemProvider","useSelectItemContext","SelectContentProvider","useSelectContentContext"],"sourceRoot":"../../../src","sources":["select/context.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAM,CAACC,cAAc,EAAEC,gBAAgB,CAAC,GAC7C,IAAAC,oBAAa,EAAqB,eAAe,CAAC;;AAEpD;AACA;AACA;AACA;AAHAC,OAAA,CAAAF,gBAAA,GAAAA,gBAAA;AAAAE,OAAA,CAAAH,cAAA,GAAAA,cAAA;AAIO,MAAM,CAACI,kBAAkB,EAAEC,oBAAoB,CAAC,GACrD,IAAAH,oBAAa,EAA6B,mBAAmB,CAAC;AAACC,OAAA,CAAAE,oBAAA,GAAAA,oBAAA;AAAAF,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AAOjE;AACO,MAAM,CAACE,qBAAqB,EAAEC,uBAAuB,CAAC,GAC3D,IAAAL,oBAAa,EAA4B,sBAAsB,CAAC;AAACC,OAAA,CAAAI,uBAAA,GAAAA,uBAAA;AAAAJ,OAAA,CAAAG,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defaultSelectFilter = void 0;
7
+ const COMBINING_MARKS = /[̀-ͯ]/g;
8
+ function normalize(text) {
9
+ const decomposed = typeof text.normalize === 'function' ? text.normalize('NFD') : text;
10
+ return decomposed.replace(COMBINING_MARKS, '').toLocaleLowerCase();
11
+ }
12
+
13
+ /** Case- and accent-insensitive `contains`: "cafe" matches "Café". */
14
+ const defaultSelectFilter = (textValue, inputValue) => normalize(textValue).includes(normalize(inputValue));
15
+ exports.defaultSelectFilter = defaultSelectFilter;
16
+ //# sourceMappingURL=filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["COMBINING_MARKS","normalize","text","decomposed","replace","toLocaleLowerCase","defaultSelectFilter","textValue","inputValue","includes","exports"],"sourceRoot":"../../../src","sources":["select/filter.ts"],"mappings":";;;;;;AAEA,MAAMA,eAAe,GAAG,QAAQ;AAEhC,SAASC,SAASA,CAACC,IAAY,EAAU;EACvC,MAAMC,UAAU,GAAG,OAAOD,IAAI,CAACD,SAAS,KAAK,UAAU,GAAGC,IAAI,CAACD,SAAS,CAAC,KAAK,CAAC,GAAGC,IAAI;EACtF,OAAOC,UAAU,CAACC,OAAO,CAACJ,eAAe,EAAE,EAAE,CAAC,CAACK,iBAAiB,CAAC,CAAC;AACpE;;AAEA;AACO,MAAMC,mBAAiC,GAAGA,CAACC,SAAS,EAAEC,UAAU,KACrEP,SAAS,CAACM,SAAS,CAAC,CAACE,QAAQ,CAACR,SAAS,CAACO,UAAU,CAAC,CAAC;AAACE,OAAA,CAAAJ,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -9,18 +9,48 @@ Object.defineProperty(exports, "SelectContent", {
9
9
  return _SelectContent.SelectContent;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "SelectEmpty", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _SelectEmpty.SelectEmpty;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "SelectItem", {
13
19
  enumerable: true,
14
20
  get: function () {
15
21
  return _SelectItem.SelectItem;
16
22
  }
17
23
  });
24
+ Object.defineProperty(exports, "SelectListbox", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _SelectListbox.SelectListbox;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "SelectProvider", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _context.SelectProvider;
34
+ }
35
+ });
18
36
  Object.defineProperty(exports, "SelectRoot", {
19
37
  enumerable: true,
20
38
  get: function () {
21
39
  return _SelectRoot.SelectRoot;
22
40
  }
23
41
  });
42
+ Object.defineProperty(exports, "SelectSearch", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _SelectSearch.SelectSearch;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "SelectSheetContent", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _SelectSheetContent.SelectSheetContent;
52
+ }
53
+ });
24
54
  Object.defineProperty(exports, "SelectTrigger", {
25
55
  enumerable: true,
26
56
  get: function () {
@@ -43,5 +73,9 @@ var _context = require("./context");
43
73
  var _SelectRoot = require("./SelectRoot");
44
74
  var _SelectTrigger = require("./SelectTrigger");
45
75
  var _SelectContent = require("./SelectContent");
76
+ var _SelectSheetContent = require("./SelectSheetContent");
77
+ var _SelectSearch = require("./SelectSearch");
78
+ var _SelectListbox = require("./SelectListbox");
79
+ var _SelectEmpty = require("./SelectEmpty");
46
80
  var _SelectItem = require("./SelectItem");
47
81
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_context","require","_SelectRoot","_SelectTrigger","_SelectContent","_SelectItem"],"sourceRoot":"../../../src","sources":["select/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_context","require","_SelectRoot","_SelectTrigger","_SelectContent","_SelectSheetContent","_SelectSearch","_SelectListbox","_SelectEmpty","_SelectItem"],"sourceRoot":"../../../src","sources":["select/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPopupRoleProps = getPopupRoleProps;
7
+ /**
8
+ * Role and name of the popup surface. With `Select.Search` the popup is a dialog holding a
9
+ * searchbox and a listbox (a listbox may only own options), named by the field label, then
10
+ * `accessibilityLabel`. Without it the popup is the listbox.
11
+ */
12
+ function getPopupRoleProps({
13
+ hasSearch,
14
+ labelId,
15
+ accessibilityLabel,
16
+ triggerId
17
+ }) {
18
+ return hasSearch ? {
19
+ role: 'dialog',
20
+ 'aria-labelledby': labelId ?? (accessibilityLabel ? undefined : triggerId),
21
+ 'aria-label': labelId ? undefined : accessibilityLabel
22
+ } : {
23
+ role: 'listbox',
24
+ 'aria-labelledby': triggerId
25
+ };
26
+ }
27
+ //# sourceMappingURL=popupRole.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getPopupRoleProps","hasSearch","labelId","accessibilityLabel","triggerId","role","undefined"],"sourceRoot":"../../../src","sources":["select/popupRole.ts"],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAiBA,CAAC;EAChCC,SAAS;EACTC,OAAO;EACPC,kBAAkB;EAClBC;AACe,CAAC,EAAE;EAClB,OAAOH,SAAS,GACZ;IACEI,IAAI,EAAE,QAAiB;IACvB,iBAAiB,EAAEH,OAAO,KAAKC,kBAAkB,GAAGG,SAAS,GAAGF,SAAS,CAAC;IAC1E,YAAY,EAAEF,OAAO,GAAGI,SAAS,GAAGH;EACtC,CAAC,GACD;IAAEE,IAAI,EAAE,SAAkB;IAAE,iBAAiB,EAAED;EAAU,CAAC;AAChE","ignoreList":[]}
@@ -10,38 +10,27 @@ var _reactNative = require("react-native");
10
10
 
11
11
  /**
12
12
  * Manages focus lifecycle for overlay content:
13
+ * - Clears `activeValue` when the overlay closes
13
14
  * - Restores focus to the trigger when the overlay closes (web)
14
- * - Initializes `activeValue` to the current value or first enabled item
15
15
  *
16
- * Initial focus on open is handled via a ref callback in SelectContent
17
- * to avoid timing issues with deferred portal rendering.
16
+ * Initial focus on open is handled by `FocusScope autoFocus` in SelectContent, and the
17
+ * highlight while open by `useQueryHighlight`.
18
18
  */
19
19
  function useContentFocus({
20
20
  open,
21
21
  triggerRef,
22
- items,
23
- value,
24
22
  setActiveValue
25
23
  }) {
26
- const prevOpenRef = (0, _react.useRef)(open);
27
- const getEnabledItems = (0, _react.useCallback)(() => items.filter(item => !item.disabled), [items]);
24
+ const prevOpenRef = (0, _react.useRef)(false);
28
25
  (0, _react.useEffect)(() => {
29
- if (prevOpenRef.current && !open && _reactNative.Platform.OS === 'web') {
30
- triggerRef.current?.focus?.();
31
- }
26
+ const wasOpen = prevOpenRef.current;
32
27
  prevOpenRef.current = open;
33
- }, [open, triggerRef]);
34
- (0, _react.useEffect)(() => {
35
- if (open) {
36
- const enabled = getEnabledItems();
37
- if (value && enabled.some(i => i.value === value)) {
38
- setActiveValue(value);
39
- } else if (enabled.length > 0) {
40
- setActiveValue(enabled[0].value);
41
- }
42
- } else {
28
+ if (!open) {
43
29
  setActiveValue(undefined);
30
+ if (wasOpen && _reactNative.Platform.OS === 'web') {
31
+ triggerRef.current?.focus?.();
32
+ }
44
33
  }
45
- }, [open, getEnabledItems, setActiveValue, value]);
34
+ }, [open, setActiveValue, triggerRef]);
46
35
  }
47
36
  //# sourceMappingURL=useContentFocus.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNative","useContentFocus","open","triggerRef","items","value","setActiveValue","prevOpenRef","useRef","getEnabledItems","useCallback","filter","item","disabled","useEffect","current","Platform","OS","focus","enabled","some","i","length","undefined"],"sourceRoot":"../../../src","sources":["select/useContentFocus.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAGA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,eAAeA,CAAC;EAC9BC,IAAI;EACJC,UAAU;EACVC,KAAK;EACLC,KAAK;EACLC;AACsB,CAAC,EAAE;EACzB,MAAMC,WAAW,GAAG,IAAAC,aAAM,EAACN,IAAI,CAAC;EAEhC,MAAMO,eAAe,GAAG,IAAAC,kBAAW,EAAC,MAAMN,KAAK,CAACO,MAAM,CAAEC,IAAI,IAAK,CAACA,IAAI,CAACC,QAAQ,CAAC,EAAE,CAACT,KAAK,CAAC,CAAC;EAE1F,IAAAU,gBAAS,EAAC,MAAM;IACd,IAAIP,WAAW,CAACQ,OAAO,IAAI,CAACb,IAAI,IAAIc,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;MACzDd,UAAU,CAACY,OAAO,EAAEG,KAAK,GAAG,CAAC;IAC/B;IACAX,WAAW,CAACQ,OAAO,GAAGb,IAAI;EAC5B,CAAC,EAAE,CAACA,IAAI,EAAEC,UAAU,CAAC,CAAC;EAEtB,IAAAW,gBAAS,EAAC,MAAM;IACd,IAAIZ,IAAI,EAAE;MACR,MAAMiB,OAAO,GAAGV,eAAe,CAAC,CAAC;MACjC,IAAIJ,KAAK,IAAIc,OAAO,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAAChB,KAAK,KAAKA,KAAK,CAAC,EAAE;QACnDC,cAAc,CAACD,KAAK,CAAC;MACvB,CAAC,MAAM,IAAIc,OAAO,CAACG,MAAM,GAAG,CAAC,EAAE;QAC7BhB,cAAc,CAACa,OAAO,CAAC,CAAC,CAAC,CAACd,KAAK,CAAC;MAClC;IACF,CAAC,MAAM;MACLC,cAAc,CAACiB,SAAS,CAAC;IAC3B;EACF,CAAC,EAAE,CAACrB,IAAI,EAAEO,eAAe,EAAEH,cAAc,EAAED,KAAK,CAAC,CAAC;AACpD","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNative","useContentFocus","open","triggerRef","setActiveValue","prevOpenRef","useRef","useEffect","wasOpen","current","undefined","Platform","OS","focus"],"sourceRoot":"../../../src","sources":["select/useContentFocus.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,eAAeA,CAAC;EAAEC,IAAI;EAAEC,UAAU;EAAEC;AAAuC,CAAC,EAAE;EAC5F,MAAMC,WAAW,GAAG,IAAAC,aAAM,EAAC,KAAK,CAAC;EAEjC,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,OAAO,GAAGH,WAAW,CAACI,OAAO;IACnCJ,WAAW,CAACI,OAAO,GAAGP,IAAI;IAE1B,IAAI,CAACA,IAAI,EAAE;MACTE,cAAc,CAACM,SAAS,CAAC;MACzB,IAAIF,OAAO,IAAIG,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;QACpCT,UAAU,CAACM,OAAO,EAAEI,KAAK,GAAG,CAAC;MAC/B;IACF;EACF,CAAC,EAAE,CAACX,IAAI,EAAEE,cAAc,EAAED,UAAU,CAAC,CAAC;AACxC","ignoreList":[]}