@tamagui/select 3.0.0-beta.924.1 → 3.0.1

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 (106) hide show
  1. package/dist/cjs/Select.cjs +23 -25
  2. package/dist/cjs/Select.native.cjs +27 -26
  3. package/dist/cjs/Select.native.js +27 -26
  4. package/dist/cjs/Select.native.js.map +1 -1
  5. package/dist/cjs/SelectImpl.cjs +67 -63
  6. package/dist/cjs/SelectItem.cjs +49 -60
  7. package/dist/cjs/SelectItem.native.cjs +51 -79
  8. package/dist/cjs/SelectItem.native.js +51 -79
  9. package/dist/cjs/SelectItem.native.js.map +1 -1
  10. package/dist/cjs/SelectScrollButton.cjs +9 -25
  11. package/dist/cjs/SelectTrigger.cjs +22 -5
  12. package/dist/cjs/SelectTrigger.native.cjs +15 -5
  13. package/dist/cjs/SelectTrigger.native.js +15 -5
  14. package/dist/cjs/SelectTrigger.native.js.map +1 -1
  15. package/dist/cjs/SelectViewport.cjs +29 -32
  16. package/dist/cjs/SelectViewport.native.cjs +2 -2
  17. package/dist/cjs/SelectViewport.native.js +2 -2
  18. package/dist/cjs/SelectViewport.native.js.map +1 -1
  19. package/dist/cjs/selectionController.cjs +15 -5
  20. package/dist/cjs/selectionController.native.cjs +20 -15
  21. package/dist/cjs/selectionController.native.js +20 -15
  22. package/dist/cjs/selectionController.native.js.map +1 -1
  23. package/dist/esm/Select.mjs +27 -28
  24. package/dist/esm/Select.mjs.map +1 -1
  25. package/dist/esm/Select.native.js +31 -29
  26. package/dist/esm/Select.native.js.map +1 -1
  27. package/dist/esm/SelectImpl.mjs +68 -64
  28. package/dist/esm/SelectImpl.mjs.map +1 -1
  29. package/dist/esm/SelectItem.mjs +50 -61
  30. package/dist/esm/SelectItem.mjs.map +1 -1
  31. package/dist/esm/SelectItem.native.js +52 -80
  32. package/dist/esm/SelectItem.native.js.map +1 -1
  33. package/dist/esm/SelectScrollButton.mjs +10 -26
  34. package/dist/esm/SelectScrollButton.mjs.map +1 -1
  35. package/dist/esm/SelectTrigger.mjs +16 -5
  36. package/dist/esm/SelectTrigger.mjs.map +1 -1
  37. package/dist/esm/SelectTrigger.native.js +15 -4
  38. package/dist/esm/SelectTrigger.native.js.map +1 -1
  39. package/dist/esm/SelectViewport.mjs +30 -33
  40. package/dist/esm/SelectViewport.mjs.map +1 -1
  41. package/dist/esm/SelectViewport.native.js +3 -3
  42. package/dist/esm/SelectViewport.native.js.map +1 -1
  43. package/dist/esm/selectionController.mjs +15 -5
  44. package/dist/esm/selectionController.mjs.map +1 -1
  45. package/dist/esm/selectionController.native.js +20 -15
  46. package/dist/esm/selectionController.native.js.map +1 -1
  47. package/dist/jsx/Select.mjs +27 -28
  48. package/dist/jsx/Select.mjs.map +1 -1
  49. package/dist/jsx/Select.native.cjs +27 -26
  50. package/dist/jsx/Select.native.js +27 -26
  51. package/dist/jsx/Select.native.js.map +1 -1
  52. package/dist/jsx/SelectImpl.mjs +68 -64
  53. package/dist/jsx/SelectImpl.mjs.map +1 -1
  54. package/dist/jsx/SelectItem.mjs +50 -61
  55. package/dist/jsx/SelectItem.mjs.map +1 -1
  56. package/dist/jsx/SelectItem.native.cjs +51 -79
  57. package/dist/jsx/SelectItem.native.js +51 -79
  58. package/dist/jsx/SelectItem.native.js.map +1 -1
  59. package/dist/jsx/SelectScrollButton.mjs +10 -26
  60. package/dist/jsx/SelectScrollButton.mjs.map +1 -1
  61. package/dist/jsx/SelectTrigger.mjs +16 -5
  62. package/dist/jsx/SelectTrigger.mjs.map +1 -1
  63. package/dist/jsx/SelectTrigger.native.cjs +15 -5
  64. package/dist/jsx/SelectTrigger.native.js +15 -5
  65. package/dist/jsx/SelectTrigger.native.js.map +1 -1
  66. package/dist/jsx/SelectViewport.mjs +30 -33
  67. package/dist/jsx/SelectViewport.mjs.map +1 -1
  68. package/dist/jsx/SelectViewport.native.cjs +2 -2
  69. package/dist/jsx/SelectViewport.native.js +2 -2
  70. package/dist/jsx/SelectViewport.native.js.map +1 -1
  71. package/dist/jsx/selectionController.mjs +15 -5
  72. package/dist/jsx/selectionController.mjs.map +1 -1
  73. package/dist/jsx/selectionController.native.cjs +20 -15
  74. package/dist/jsx/selectionController.native.js +20 -15
  75. package/dist/jsx/selectionController.native.js.map +1 -1
  76. package/package.json +30 -29
  77. package/src/Select.tsx +41 -41
  78. package/src/SelectImpl.tsx +107 -95
  79. package/src/SelectItem.tsx +66 -91
  80. package/src/SelectScrollButton.tsx +14 -32
  81. package/src/SelectTrigger.tsx +19 -2
  82. package/src/SelectViewport.native.tsx +4 -4
  83. package/src/SelectViewport.tsx +34 -30
  84. package/src/selectionController.ts +20 -5
  85. package/src/types.tsx +26 -22
  86. package/types/Select.d.ts +42 -81
  87. package/types/Select.d.ts.map +1 -1
  88. package/types/SelectImpl.d.ts.map +1 -1
  89. package/types/SelectItem.d.ts +3 -5
  90. package/types/SelectItem.d.ts.map +1 -1
  91. package/types/SelectItemText.d.ts +3 -5
  92. package/types/SelectItemText.d.ts.map +1 -1
  93. package/types/SelectScrollButton.d.ts +5 -9
  94. package/types/SelectScrollButton.d.ts.map +1 -1
  95. package/types/SelectScrollButton.native.d.ts +5 -9
  96. package/types/SelectScrollButton.native.d.ts.map +1 -1
  97. package/types/SelectTrigger.d.ts +3 -5
  98. package/types/SelectTrigger.d.ts.map +1 -1
  99. package/types/SelectViewport.d.ts +4 -9
  100. package/types/SelectViewport.d.ts.map +1 -1
  101. package/types/SelectViewport.native.d.ts +4 -9
  102. package/types/SelectViewport.native.d.ts.map +1 -1
  103. package/types/selectionController.d.ts +2 -0
  104. package/types/selectionController.d.ts.map +1 -1
  105. package/types/types.d.ts +30 -22
  106. package/types/types.d.ts.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"selectionController.native.js","names":[],"sources":["cjs/selectionController.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar selectionController_exports = {};\n__export(selectionController_exports, {\n createSelectItemRegistry: () => createSelectItemRegistry,\n createSelectSelectionController: () => createSelectSelectionController,\n getSelectLabelText: () => getSelectLabelText,\n getSelectListboxProps: () => getSelectListboxProps,\n getSelectOptionProps: () => getSelectOptionProps,\n normalizeSelectSelection: () => normalizeSelectSelection,\n selectedValuesFromSelection: () => selectedValuesFromSelection\n});\nmodule.exports = __toCommonJS(selectionController_exports);\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nfunction getSelectLabelText(label) {\n if (typeof label === \"string\" || typeof label === \"number\") {\n return String(label);\n }\n if (Array.isArray(label)) {\n return label.map(getSelectLabelText).join(\"\");\n }\n if (label && (typeof label === \"undefined\" ? \"undefined\" : _type_of(label)) === \"object\" && \"props\" in label) {\n var _label_props;\n return getSelectLabelText((_label_props = label.props) === null || _label_props === void 0 ? void 0 : _label_props.children);\n }\n return \"\";\n}\nfunction createSelectItemRegistry(onChange) {\n var items = [];\n var labelRegistrations = /* @__PURE__ */ new Map();\n var explicitTextValues = /* @__PURE__ */ new Map();\n var itemNodes = /* @__PURE__ */ new Map();\n var listeners = /* @__PURE__ */ new Set();\n var notify = function() {\n onChange === null || onChange === void 0 ? void 0 : onChange();\n listeners.forEach(function(listener) {\n return listener();\n });\n };\n var getItems = function() {\n return items;\n };\n var getItem = function(value) {\n return items.find(function(item) {\n return item.value === value;\n });\n };\n var getIndex = function(value) {\n return items.findIndex(function(item) {\n return item.value === value;\n });\n };\n var getRegisteredLabel = function(value) {\n var registrations = labelRegistrations.get(value);\n if (!(registrations === null || registrations === void 0 ? void 0 : registrations.size)) return void 0;\n var values = Array.from(registrations.values());\n return values[values.length - 1];\n };\n var applyRegisteredLabel = function(value) {\n var registeredLabel = getRegisteredLabel(value);\n var changed = false;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var item = _step.value;\n if (item.value !== value) continue;\n var nextLabel = registeredLabel === null || registeredLabel === void 0 ? void 0 : registeredLabel.label;\n var nextTextValue = explicitTextValues.get(item.id) || (registeredLabel === null || registeredLabel === void 0 ? void 0 : registeredLabel.textValue);\n if (item.label !== nextLabel || item.textValue !== nextTextValue) {\n item.label = nextLabel;\n item.textValue = nextTextValue;\n changed = true;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (changed) notify();\n };\n var syncNodeOrder = function() {\n var previousOrder = items.map(function(item) {\n return item.id;\n });\n items.sort(function(a, b) {\n var aNode = itemNodes.get(a.id);\n var bNode = itemNodes.get(b.id);\n if (!aNode || !bNode || typeof aNode.compareDocumentPosition !== \"function\") {\n return 0;\n }\n var position = aNode.compareDocumentPosition(bNode);\n if (position & 4) return -1;\n if (position & 2) return 1;\n return 0;\n });\n if (items.some(function(item, index) {\n return item.id !== previousOrder[index];\n })) {\n notify();\n }\n };\n var registerItem = function(item) {\n var id = Symbol(item.value);\n var registeredLabel = getRegisteredLabel(item.value);\n var _item_textValue;\n var registeredItem = {\n ...item,\n ...registeredLabel,\n textValue: (_item_textValue = item.textValue) !== null && _item_textValue !== void 0 ? _item_textValue : registeredLabel === null || registeredLabel === void 0 ? void 0 : registeredLabel.textValue,\n id\n };\n explicitTextValues.set(id, item.textValue);\n items.push(registeredItem);\n notify();\n return {\n id,\n update(next) {\n var index = items.findIndex(function(current2) {\n return current2.id === id;\n });\n if (index < 0) return;\n var current = items[index];\n if (\"textValue\" in next) {\n explicitTextValues.set(id, next.textValue);\n }\n var nextItem = {\n ...current,\n ...next\n };\n if (next.value !== void 0 && next.value !== current.value) {\n var nextLabel = getRegisteredLabel(next.value);\n nextItem.label = nextLabel === null || nextLabel === void 0 ? void 0 : nextLabel.label;\n }\n var explicitTextValue = explicitTextValues.get(id);\n nextItem.textValue = explicitTextValue || getSelectLabelText(nextItem.label) || (nextItem.label ? nextItem.value : void 0);\n var changed = Object.entries(next).some(function(param) {\n var [key, value] = param;\n return current[key] !== value;\n });\n var textValueChanged = current.textValue !== nextItem.textValue;\n if (!changed && !textValueChanged) return;\n items[index] = nextItem;\n notify();\n },\n setNode(node) {\n if (node) {\n itemNodes.set(id, node);\n syncNodeOrder();\n } else {\n itemNodes.delete(id);\n }\n },\n unregister() {\n var index = items.findIndex(function(current) {\n return current.id === id;\n });\n if (index < 0) return;\n items.splice(index, 1);\n explicitTextValues.delete(id);\n itemNodes.delete(id);\n notify();\n }\n };\n };\n var registerLabel = function(value, label, textValue) {\n var id = Symbol(value);\n var normalizedTextValue = textValue || getSelectLabelText(label) || value;\n var _labelRegistrations_get;\n var registrations = (_labelRegistrations_get = labelRegistrations.get(value)) !== null && _labelRegistrations_get !== void 0 ? _labelRegistrations_get : (function() {\n var next = /* @__PURE__ */ new Map();\n labelRegistrations.set(value, next);\n return next;\n })();\n registrations.set(id, {\n label,\n textValue: normalizedTextValue\n });\n applyRegisteredLabel(value);\n return function() {\n registrations.delete(id);\n if (!registrations.size) {\n labelRegistrations.delete(value);\n }\n applyRegisteredLabel(value);\n };\n };\n var firstEnabledIndex = function() {\n return items.findIndex(function(item) {\n return !item.disabled;\n });\n };\n var nextEnabledIndex = function(fromIndex, direction) {\n if (!items.length) return -1;\n if (fromIndex == null || fromIndex < 0 || fromIndex >= items.length) {\n if (direction === 1) return firstEnabledIndex();\n for (var index = items.length - 1; index >= 0; index--) {\n if (!items[index].disabled) return index;\n }\n return -1;\n }\n for (var offset = 1; offset <= items.length; offset++) {\n var _items_index;\n var index1 = (fromIndex + direction * offset + items.length) % items.length;\n if (!((_items_index = items[index1]) === null || _items_index === void 0 ? void 0 : _items_index.disabled)) return index1;\n }\n return -1;\n };\n var findTypeaheadIndex = function(search, fromIndex) {\n var normalizedSearch = search.trim().toLocaleLowerCase();\n if (!normalizedSearch) return -1;\n var start = fromIndex == null || fromIndex < 0 ? -1 : fromIndex;\n for (var offset = 1; offset <= items.length; offset++) {\n var index = (start + offset) % items.length;\n var item = items[index];\n var label = item.textValue || getSelectLabelText(item.label) || item.value;\n if (!item.disabled && label.toLocaleLowerCase().startsWith(normalizedSearch)) {\n return index;\n }\n }\n return -1;\n };\n return {\n subscribe(listener) {\n listeners.add(listener);\n return function() {\n listeners.delete(listener);\n };\n },\n registerItem,\n registerLabel,\n getItems,\n getItem,\n getIndex,\n firstEnabledIndex,\n nextEnabledIndex,\n findTypeaheadIndex,\n getDisabledIndices: function() {\n return items.flatMap(function(item, index) {\n return item.disabled ? [\n index\n ] : [];\n });\n },\n getTypeaheadLabels: function() {\n return items.map(function(item) {\n return item.textValue || getSelectLabelText(item.label) || item.value;\n });\n }\n };\n}\nfunction normalizeSelectSelection(mode, value) {\n if (mode === \"single\") {\n return typeof value === \"string\" ? value : \"\";\n }\n var values = Array.isArray(value) ? value : [];\n return [\n ...new Set(values)\n ];\n}\nfunction selectedValuesFromSelection(mode, value) {\n var normalized = normalizeSelectSelection(mode, value);\n return mode === \"multiple\" ? normalized : normalized ? [\n normalized\n ] : [];\n}\nfunction createSelectSelectionController(param) {\n var { mode: initialMode, value: initialValue, registry } = param;\n var mode = initialMode;\n var value = normalizeSelectSelection(mode, initialValue);\n var activeIndex = null;\n var selectedValues = function() {\n return selectedValuesFromSelection(mode, value);\n };\n var setMode = function(nextMode) {\n if (mode === nextMode) return value;\n mode = nextMode;\n value = normalizeSelectSelection(mode, value);\n return value;\n };\n var setValue = function(nextValue) {\n value = normalizeSelectSelection(mode, nextValue);\n return value;\n };\n var isSelected = function(itemValue) {\n return selectedValues().includes(itemValue);\n };\n var toggle = function(itemValue) {\n var item = registry.getItem(itemValue);\n if (!item || item.disabled) return value;\n if (mode === \"single\") {\n value = itemValue;\n return value;\n }\n var current = selectedValues();\n value = current.includes(itemValue) ? current.filter(function(currentValue) {\n return currentValue !== itemValue;\n }) : [\n ...current,\n itemValue\n ];\n return value;\n };\n var selectionAnchor = function() {\n var values = selectedValues();\n for (var index = values.length - 1; index >= 0; index--) {\n var item = registry.getItem(values[index]);\n if (item) return item;\n }\n var firstEnabledIndex = registry.firstEnabledIndex();\n return firstEnabledIndex < 0 ? void 0 : registry.getItems()[firstEnabledIndex];\n };\n var selectionAnchorIndex = function() {\n var anchor = selectionAnchor();\n return anchor ? registry.getIndex(anchor.value) : -1;\n };\n var initialActiveIndex = function() {\n var anchorIndex = selectionAnchorIndex();\n var anchor = anchorIndex < 0 ? void 0 : registry.getItems()[anchorIndex];\n return anchor && !anchor.disabled ? anchorIndex : registry.firstEnabledIndex();\n };\n var moveActive = function(direction) {\n var nextIndex = registry.nextEnabledIndex(activeIndex, direction);\n activeIndex = nextIndex < 0 ? null : nextIndex;\n return activeIndex == null ? void 0 : registry.getItems()[activeIndex];\n };\n return {\n registry,\n get mode() {\n return mode;\n },\n get value() {\n return value;\n },\n get activeIndex() {\n return activeIndex;\n },\n get activeItem() {\n return activeIndex == null ? void 0 : registry.getItems()[activeIndex];\n },\n get shouldCloseOnSelect() {\n return mode === \"single\";\n },\n setMode,\n setValue,\n isSelected,\n toggle,\n selectionAnchor,\n selectionAnchorIndex,\n initialActiveIndex,\n setActiveIndex(index) {\n activeIndex = index;\n },\n moveActive\n };\n}\nfunction getSelectListboxProps(mode) {\n return {\n role: \"listbox\",\n \"aria-multiselectable\": mode === \"multiple\" ? true : void 0\n };\n}\nfunction getSelectOptionProps(mode, selected, disabled, platform) {\n if (platform === \"native\") {\n return {\n accessibilityRole: mode === \"multiple\" ? \"checkbox\" : \"button\",\n accessibilityState: {\n selected: mode === \"single\" ? selected : void 0,\n checked: mode === \"multiple\" ? selected : void 0,\n disabled\n }\n };\n }\n return {\n role: \"option\",\n \"aria-selected\": selected,\n \"aria-disabled\": disabled || void 0\n };\n}\n//# sourceMappingURL=selectionController.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,8BAA8B,CAAC;AACnC,SAAS,6BAA6B;CACpC,gCAAgC;CAChC,uCAAuC;CACvC,0BAA0B;CAC1B,6BAA6B;CAC7B,4BAA4B;CAC5B,gCAAgC;CAChC,mCAAmC;AACrC,CAAC;AACD,OAAO,UAA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AACF;AACA,SAAS,sBAAsB,MAAM;CACnC,OAAO;EACL,MAAM;EACN,wBAAwB,SAAS,aAAa,OAAO,KAAK;CAC5D;AACF;AACA,SAAS,qBAAqB,MAAM,UAAU,UAAU,UAAU;CAChE,IAAI,aAAa,UAAU;EACzB,OAAO;GACL,mBAAmB,SAAS,aAAa,aAAa;GACtD,oBAAoB;IAClB,UAAU,SAAS,WAAW,WAAW,KAAK;IAC9C,SAAS,SAAS,aAAa,WAAW,KAAK;IAC/C;GACF;EACF;CACF;CACA,OAAO;EACL,MAAM;EACN,iBAAiB;EACjB,iBAAiB,YAAY,KAAK;CACpC;AACF"}
1
+ {"version":3,"file":"selectionController.native.js","names":[],"sources":["cjs/selectionController.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar selectionController_exports = {};\n__export(selectionController_exports, {\n createSelectItemRegistry: () => createSelectItemRegistry,\n createSelectSelectionController: () => createSelectSelectionController,\n getSelectLabelText: () => getSelectLabelText,\n getSelectListboxProps: () => getSelectListboxProps,\n getSelectOptionProps: () => getSelectOptionProps,\n normalizeSelectSelection: () => normalizeSelectSelection,\n selectedValuesFromSelection: () => selectedValuesFromSelection\n});\nmodule.exports = __toCommonJS(selectionController_exports);\nfunction getSelectLabelText(label) {\n if (typeof label === \"string\" || typeof label === \"number\") {\n return String(label);\n }\n if (Array.isArray(label)) {\n return label.map(getSelectLabelText).join(\"\");\n }\n if (label && typeof label === \"object\" && \"props\" in label) {\n var _label_props;\n return getSelectLabelText((_label_props = label.props) === null || _label_props === void 0 ? void 0 : _label_props.children);\n }\n return \"\";\n}\nfunction createSelectItemRegistry(onChange) {\n var items = [];\n var labelRegistrations = /* @__PURE__ */ new Map();\n var explicitTextValues = /* @__PURE__ */ new Map();\n var itemNodes = /* @__PURE__ */ new Map();\n var listeners = /* @__PURE__ */ new Set();\n var indexByValue = null;\n var notify = function() {\n indexByValue = null;\n onChange === null || onChange === void 0 ? void 0 : onChange();\n listeners.forEach(function(listener) {\n return listener();\n });\n };\n var getItems = function() {\n return items;\n };\n var getItem = function(value) {\n return items.find(function(item) {\n return item.value === value;\n });\n };\n var getIndex = function(value) {\n if (!indexByValue) {\n indexByValue = /* @__PURE__ */ new Map();\n items.forEach(function(item, index) {\n if (!indexByValue.has(item.value)) indexByValue.set(item.value, index);\n });\n }\n var _indexByValue_get;\n return (_indexByValue_get = indexByValue.get(value)) !== null && _indexByValue_get !== void 0 ? _indexByValue_get : -1;\n };\n var getNodes = function() {\n return items.map(function(item) {\n var _itemNodes_get;\n return (_itemNodes_get = itemNodes.get(item.id)) !== null && _itemNodes_get !== void 0 ? _itemNodes_get : null;\n });\n };\n var getRegisteredLabel = function(value) {\n var registrations = labelRegistrations.get(value);\n if (!(registrations === null || registrations === void 0 ? void 0 : registrations.size)) return void 0;\n var values = Array.from(registrations.values());\n return values[values.length - 1];\n };\n var applyRegisteredLabel = function(value) {\n var registeredLabel = getRegisteredLabel(value);\n var changed = false;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var item = _step.value;\n if (item.value !== value) continue;\n var nextLabel = registeredLabel === null || registeredLabel === void 0 ? void 0 : registeredLabel.label;\n var nextTextValue = explicitTextValues.get(item.id) || (registeredLabel === null || registeredLabel === void 0 ? void 0 : registeredLabel.textValue);\n if (item.label !== nextLabel || item.textValue !== nextTextValue) {\n item.label = nextLabel;\n item.textValue = nextTextValue;\n changed = true;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (changed) notify();\n };\n var syncNodeOrder = function() {\n items.sort(function(a, b) {\n var aNode = itemNodes.get(a.id);\n var bNode = itemNodes.get(b.id);\n if (!aNode || !bNode || typeof aNode.compareDocumentPosition !== \"function\") {\n return 0;\n }\n var position = aNode.compareDocumentPosition(bNode);\n if (position & 4) return -1;\n if (position & 2) return 1;\n return 0;\n });\n };\n var registerItem = function(item) {\n var id = Symbol(item.value);\n var registeredLabel = getRegisteredLabel(item.value);\n var _item_textValue;\n var registeredItem = {\n ...item,\n ...registeredLabel,\n textValue: (_item_textValue = item.textValue) !== null && _item_textValue !== void 0 ? _item_textValue : registeredLabel === null || registeredLabel === void 0 ? void 0 : registeredLabel.textValue,\n id\n };\n explicitTextValues.set(id, item.textValue);\n items.push(registeredItem);\n notify();\n return {\n id,\n update(next) {\n var index = items.findIndex(function(current2) {\n return current2.id === id;\n });\n if (index < 0) return;\n var current = items[index];\n if (\"textValue\" in next) {\n explicitTextValues.set(id, next.textValue);\n }\n var nextItem = {\n ...current,\n ...next\n };\n if (next.value !== void 0 && next.value !== current.value) {\n var nextLabel = getRegisteredLabel(next.value);\n nextItem.label = nextLabel === null || nextLabel === void 0 ? void 0 : nextLabel.label;\n }\n var explicitTextValue = explicitTextValues.get(id);\n nextItem.textValue = explicitTextValue || getSelectLabelText(nextItem.label) || (nextItem.label ? nextItem.value : void 0);\n var changed = Object.entries(next).some(function(param) {\n var [key, value] = param;\n return current[key] !== value;\n });\n var textValueChanged = current.textValue !== nextItem.textValue;\n if (!changed && !textValueChanged) return;\n items[index] = nextItem;\n notify();\n },\n setNode(node) {\n var _itemNodes_get;\n if (((_itemNodes_get = itemNodes.get(id)) !== null && _itemNodes_get !== void 0 ? _itemNodes_get : null) === (node !== null && node !== void 0 ? node : null)) return;\n if (node) {\n itemNodes.set(id, node);\n syncNodeOrder();\n } else {\n itemNodes.delete(id);\n }\n notify();\n },\n unregister() {\n var index = items.findIndex(function(current) {\n return current.id === id;\n });\n if (index < 0) return;\n items.splice(index, 1);\n explicitTextValues.delete(id);\n itemNodes.delete(id);\n notify();\n }\n };\n };\n var registerLabel = function(value, label, textValue) {\n var id = Symbol(value);\n var normalizedTextValue = textValue || getSelectLabelText(label) || value;\n var _labelRegistrations_get;\n var registrations = (_labelRegistrations_get = labelRegistrations.get(value)) !== null && _labelRegistrations_get !== void 0 ? _labelRegistrations_get : (function() {\n var next = /* @__PURE__ */ new Map();\n labelRegistrations.set(value, next);\n return next;\n })();\n registrations.set(id, {\n label,\n textValue: normalizedTextValue\n });\n applyRegisteredLabel(value);\n return function() {\n registrations.delete(id);\n if (!registrations.size) {\n labelRegistrations.delete(value);\n }\n applyRegisteredLabel(value);\n };\n };\n var firstEnabledIndex = function() {\n return items.findIndex(function(item) {\n return !item.disabled;\n });\n };\n var nextEnabledIndex = function(fromIndex, direction) {\n if (!items.length) return -1;\n if (fromIndex == null || fromIndex < 0 || fromIndex >= items.length) {\n if (direction === 1) return firstEnabledIndex();\n for (var index = items.length - 1; index >= 0; index--) {\n if (!items[index].disabled) return index;\n }\n return -1;\n }\n for (var offset = 1; offset <= items.length; offset++) {\n var _items_index;\n var index1 = (fromIndex + direction * offset + items.length) % items.length;\n if (!((_items_index = items[index1]) === null || _items_index === void 0 ? void 0 : _items_index.disabled)) return index1;\n }\n return -1;\n };\n var findTypeaheadIndex = function(search, fromIndex) {\n var normalizedSearch = search.trim().toLocaleLowerCase();\n if (!normalizedSearch) return -1;\n var start = fromIndex == null || fromIndex < 0 ? -1 : fromIndex;\n for (var offset = 1; offset <= items.length; offset++) {\n var index = (start + offset) % items.length;\n var item = items[index];\n var label = item.textValue || getSelectLabelText(item.label) || item.value;\n if (!item.disabled && label.toLocaleLowerCase().startsWith(normalizedSearch)) {\n return index;\n }\n }\n return -1;\n };\n return {\n subscribe(listener) {\n listeners.add(listener);\n return function() {\n listeners.delete(listener);\n };\n },\n registerItem,\n registerLabel,\n getItems,\n getItem,\n getIndex,\n getNodes,\n firstEnabledIndex,\n nextEnabledIndex,\n findTypeaheadIndex,\n getDisabledIndices: function() {\n return items.flatMap(function(item, index) {\n return item.disabled ? [\n index\n ] : [];\n });\n },\n getTypeaheadLabels: function() {\n return items.map(function(item) {\n return item.textValue || getSelectLabelText(item.label) || item.value;\n });\n }\n };\n}\nfunction normalizeSelectSelection(mode, value) {\n if (mode === \"single\") {\n return typeof value === \"string\" ? value : \"\";\n }\n var values = Array.isArray(value) ? value : [];\n return [\n ...new Set(values)\n ];\n}\nfunction selectedValuesFromSelection(mode, value) {\n var normalized = normalizeSelectSelection(mode, value);\n return mode === \"multiple\" ? normalized : normalized ? [\n normalized\n ] : [];\n}\nfunction createSelectSelectionController(param) {\n var { mode: initialMode, value: initialValue, registry } = param;\n var mode = initialMode;\n var value = normalizeSelectSelection(mode, initialValue);\n var activeIndex = null;\n var selectedValues = function() {\n return selectedValuesFromSelection(mode, value);\n };\n var setMode = function(nextMode) {\n if (mode === nextMode) return value;\n mode = nextMode;\n value = normalizeSelectSelection(mode, value);\n return value;\n };\n var setValue = function(nextValue) {\n value = normalizeSelectSelection(mode, nextValue);\n return value;\n };\n var isSelected = function(itemValue) {\n return selectedValues().includes(itemValue);\n };\n var toggle = function(itemValue) {\n var item = registry.getItem(itemValue);\n if (!item || item.disabled) return value;\n if (mode === \"single\") {\n value = itemValue;\n return value;\n }\n var current = selectedValues();\n value = current.includes(itemValue) ? current.filter(function(currentValue) {\n return currentValue !== itemValue;\n }) : [\n ...current,\n itemValue\n ];\n return value;\n };\n var selectionAnchor = function() {\n var values = selectedValues();\n for (var index = values.length - 1; index >= 0; index--) {\n var item = registry.getItem(values[index]);\n if (item) return item;\n }\n var firstEnabledIndex = registry.firstEnabledIndex();\n return firstEnabledIndex < 0 ? void 0 : registry.getItems()[firstEnabledIndex];\n };\n var selectionAnchorIndex = function() {\n var anchor = selectionAnchor();\n return anchor ? registry.getIndex(anchor.value) : -1;\n };\n var initialActiveIndex = function() {\n var anchorIndex = selectionAnchorIndex();\n var anchor = anchorIndex < 0 ? void 0 : registry.getItems()[anchorIndex];\n return anchor && !anchor.disabled ? anchorIndex : registry.firstEnabledIndex();\n };\n var moveActive = function(direction) {\n var nextIndex = registry.nextEnabledIndex(activeIndex, direction);\n activeIndex = nextIndex < 0 ? null : nextIndex;\n return activeIndex == null ? void 0 : registry.getItems()[activeIndex];\n };\n return {\n registry,\n get mode() {\n return mode;\n },\n get value() {\n return value;\n },\n get activeIndex() {\n return activeIndex;\n },\n get activeItem() {\n return activeIndex == null ? void 0 : registry.getItems()[activeIndex];\n },\n get shouldCloseOnSelect() {\n return mode === \"single\";\n },\n setMode,\n setValue,\n isSelected,\n toggle,\n selectionAnchor,\n selectionAnchorIndex,\n initialActiveIndex,\n setActiveIndex(index) {\n activeIndex = index;\n },\n moveActive\n };\n}\nfunction getSelectListboxProps(mode) {\n return {\n role: \"listbox\",\n \"aria-multiselectable\": mode === \"multiple\" ? true : void 0\n };\n}\nfunction getSelectOptionProps(mode, selected, disabled, platform) {\n if (platform === \"native\") {\n return {\n accessibilityRole: mode === \"multiple\" ? \"checkbox\" : \"button\",\n accessibilityState: {\n selected: mode === \"single\" ? selected : void 0,\n checked: mode === \"multiple\" ? selected : void 0,\n disabled\n }\n };\n }\n return {\n role: \"option\",\n \"aria-selected\": selected,\n \"aria-disabled\": disabled || void 0\n };\n}\n//# sourceMappingURL=selectionController.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO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aAAa;GACtD,oBAAoB;IAClB,UAAU,SAAS,WAAW,WAAW,KAAK;IAC9C,SAAS,SAAS,aAAa,WAAW,KAAK;IAC/C;GACF;EACF;CACF;CACA,OAAO;EACL,MAAM;EACN,iBAAiB;EACjB,iBAAiB,YAAY,KAAK;CACpC;AACF"}
@@ -23,6 +23,8 @@ const SelectValue = createStyledHOC(SelectValueFrame, function SelectValue2({ sc
23
23
  const itemParentContext = useSelectItemParentContext(scope);
24
24
  const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
25
25
  const isEmptyValue = context.selectedValues.length === 0;
26
+ const [, rerender] = React.useReducer((version) => version + 1, 0);
27
+ useIsomorphicLayoutEffect(() => itemParentContext.registry.subscribe(rerender), [itemParentContext.registry]);
26
28
  const registeredValue = context.mode === "multiple" ? context.selectedValues.map((value, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [index > 0 ? ", " : null, itemParentContext.registry.getItem(value)?.label ?? value] }, value)) : itemParentContext.registry.getItem(context.selectedValues[0])?.label ?? context.value;
27
29
  const children = childrenProp !== void 0 ? childrenProp : context.renderValue ? context.renderValue(context.value) : registeredValue;
28
30
  const selectValueChildren = isEmptyValue ? placeholder ?? children : children;
@@ -62,7 +64,7 @@ const SelectIndicator = createStyledHOC(SelectIndicatorFrame, function SelectInd
62
64
  const context = useSelectContext(scope);
63
65
  const [layout, setLayout] = React.useState(null);
64
66
  const rafRef = React.useRef(0);
65
- React.useLayoutEffect(() => {
67
+ useIsomorphicLayoutEffect(() => {
66
68
  const update = (index) => {
67
69
  if (typeof index !== "number") return;
68
70
  cancelAnimationFrame(rafRef.current);
@@ -161,12 +163,14 @@ function SelectRoot(props) {
161
163
  defaultProp: props.defaultOpen || false,
162
164
  onChange: props.onOpenChange
163
165
  });
166
+ const handleAdaptOpenChange = React.useCallback((nextOpen) => {
167
+ requestOpenChange(nextOpen, createChangeEventDetails(nextOpen ? "trigger-press" : "outside-press"));
168
+ }, [requestOpenChange]);
164
169
  return /* @__PURE__ */ jsx(AdaptParent, {
165
170
  scope: adaptScope,
171
+ adaptChildren: props.children,
166
172
  open,
167
- onOpenChange: React.useCallback((nextOpen) => {
168
- requestOpenChange(nextOpen, createChangeEventDetails(nextOpen ? "trigger-press" : "outside-press"));
169
- }, [requestOpenChange]),
173
+ onOpenChange: handleAdaptOpenChange,
170
174
  children: /* @__PURE__ */ jsx(SelectInner, {
171
175
  ...props,
172
176
  scope: props.scope,
@@ -233,28 +237,32 @@ function SelectInner(props) {
233
237
  controller.setValue(value);
234
238
  React.useEffect(() => {}, [props.id, requestOpenChange]);
235
239
  const activeIndexRef = React.useRef(null);
236
- const [activeIndex, setActiveIndexState] = React.useState(null);
237
240
  const [emitActiveIndex, activeIndexSubscribe] = useEmitter();
238
241
  const selectedIndexRef = React.useRef(null);
242
+ const lastPointerRef = React.useRef({
243
+ x: -1,
244
+ y: -1
245
+ });
239
246
  const listContentRef = React.useRef([]);
240
247
  const listRef = React.useRef([]);
241
248
  const [valueNode, setValueNode] = React.useState(null);
242
249
  const selectedIndex = Math.max(0, controller.selectionAnchorIndex());
243
250
  listContentRef.current = registry.getTypeaheadLabels();
244
- listRef.current.length = registry.getItems().length;
251
+ const itemNodes = registry.getNodes();
252
+ listRef.current.length = itemNodes.length;
253
+ for (let i = 0; i < itemNodes.length; i++) listRef.current[i] = itemNodes[i];
245
254
  useIsomorphicLayoutEffect(() => {
246
255
  selectedIndexRef.current = selectedIndex;
247
256
  });
248
257
  const shouldRenderWebNative = isWeb && (native === true || native === "web" || Array.isArray(native) && native.includes("web"));
249
- const setActiveIndexFast = React.useCallback((index, details) => {
250
- if (activeIndexRef.current !== index) {
251
- activeIndexRef.current = index;
252
- controller.setActiveIndex(index);
253
- if (typeof index === "number") {
254
- emitActiveIndex(index);
255
- const item = registry.getItems()[index];
256
- if (item && details) onActiveChange?.(item.value, details);
257
- }
258
+ const setActiveIndex = React.useCallback((index, details) => {
259
+ if (activeIndexRef.current === index) return;
260
+ activeIndexRef.current = index;
261
+ controller.setActiveIndex(index);
262
+ emitActiveIndex(index);
263
+ if (typeof index === "number") {
264
+ const item = registry.getItems()[index];
265
+ if (item && details) onActiveChange?.(item.value, details);
258
266
  }
259
267
  }, [
260
268
  controller,
@@ -262,10 +270,6 @@ function SelectInner(props) {
262
270
  onActiveChange,
263
271
  registry
264
272
  ]);
265
- const setActiveIndex = React.useCallback((index, details) => {
266
- setActiveIndexFast(index, details);
267
- setActiveIndexState(index);
268
- }, [setActiveIndexFast]);
269
273
  const activeDetails = React.useCallback((reason, index, event) => ({
270
274
  reason,
271
275
  event,
@@ -308,10 +312,7 @@ function SelectInner(props) {
308
312
  if (open) {
309
313
  const nextIndex = controller.initialActiveIndex();
310
314
  if (nextIndex >= 0) setActiveIndex(nextIndex, activeDetails("list-navigation", nextIndex));
311
- } else {
312
- setActiveIndexFast(null);
313
- setActiveIndexState(null);
314
- }
315
+ } else setActiveIndex(null);
315
316
  }, [
316
317
  open,
317
318
  selectedIndex,
@@ -357,7 +358,9 @@ function SelectInner(props) {
357
358
  if (!details.isCanceled) controller.setValue(nextValue);
358
359
  }, [controller, requestValueChange]),
359
360
  shouldRenderWebNative,
360
- setActiveIndexFast,
361
+ setActiveIndex,
362
+ selectedIndex,
363
+ lastPointerRef,
361
364
  listRef,
362
365
  moveActive,
363
366
  search,
@@ -371,15 +374,12 @@ function SelectInner(props) {
371
374
  fallback: false,
372
375
  valueNode,
373
376
  onValueNodeChange: setValueNode,
374
- activeIndex,
375
377
  activeIndexRef,
376
378
  selectedIndex,
377
379
  setActiveIndex,
378
380
  value,
379
381
  mode,
380
382
  selectedValues,
381
- activeItem: activeIndex == null ? void 0 : registry.getItems()[activeIndex]?.value,
382
- selectionAnchor: controller.selectionAnchor()?.value,
383
383
  open,
384
384
  native,
385
385
  renderValue,
@@ -388,7 +388,6 @@ function SelectInner(props) {
388
388
  activeIndexRef,
389
389
  listContentRef,
390
390
  selectedIndexRef,
391
- setActiveIndexFast,
392
391
  ...props,
393
392
  open,
394
393
  value,
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","names":[],"sources":["esm/Select.js"],"sourcesContent":["import { Adapt, AdaptParent, useAdaptIsActive } from \"@tamagui/adapt\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { Text, View, createChangeEventDetails, createStyledContext, createStyledHOC, styled } from \"@tamagui/core\";\nimport { FocusScopeController } from \"@tamagui/focus-scope\";\nimport { withStaticProperties } from \"@tamagui/helpers\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport * as React from \"react\";\nimport { SelectItemParentProvider, SelectNativeComponentContext, SelectProvider, SelectZIndexContext, useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { SelectContent } from \"./SelectContent\";\nimport { SelectInlineImpl } from \"./SelectImpl\";\nimport { SelectItem, useSelectItemContext } from \"./SelectItem\";\nimport { SelectItemText } from \"./SelectItemText\";\nimport { SelectScrollDownButton, SelectScrollUpButton } from \"./SelectScrollButton\";\nimport { SelectTrigger } from \"./SelectTrigger\";\nimport { SelectViewport } from \"./SelectViewport\";\nimport { createSelectItemRegistry, createSelectSelectionController, selectedValuesFromSelection } from \"./selectionController\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\n\nconst SelectValueFrame = styled(Text, { displayName: \"SelectValue\" });\nconst SelectValue = createStyledHOC(SelectValueFrame, function SelectValue2({ scope, children: childrenProp, placeholder, ...props }, forwardedRef) {\n\tconst context = useSelectContext(scope);\n\tconst itemParentContext = useSelectItemParentContext(scope);\n\tconst composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);\n\tconst isEmptyValue = context.selectedValues.length === 0;\n\tconst registeredValue = context.mode === \"multiple\" ? context.selectedValues.map((value, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [index > 0 ? \", \" : null, itemParentContext.registry.getItem(value)?.label ?? value] }, value)) : itemParentContext.registry.getItem(context.selectedValues[0])?.label ?? context.value;\n\tconst children = childrenProp !== void 0 ? childrenProp : context.renderValue ? context.renderValue(context.value) : registeredValue;\n\tconst selectValueChildren = isEmptyValue ? placeholder ?? children : children;\n\treturn /* @__PURE__ */ jsx(SelectValueFrame, {\n\t\tpointerEvents: \"none\",\n\t\tref: composedRefs,\n\t\t...props,\n\t\tchildren: selectValueChildren\n\t});\n});\nconst SelectIcon = styled(View, {\n\tdisplayName: \"SelectIcon\",\n\t\"aria-hidden\": true\n});\nconst SelectItemIndicatorFrame = styled(View, { displayName: \"SelectItemIndicator\" });\nconst SelectItemIndicator = createStyledHOC(SelectItemIndicatorFrame, function SelectItemIndicator2(props, forwardedRef) {\n\tconst { scope, ...itemIndicatorProps } = props;\n\tconst context = useSelectItemParentContext(scope);\n\tconst itemContext = useSelectItemContext(scope);\n\tif (context.shouldRenderWebNative) return null;\n\treturn itemContext.isSelected ? /* @__PURE__ */ jsx(SelectItemIndicatorFrame, {\n\t\t\"aria-hidden\": true,\n\t\t...itemIndicatorProps,\n\t\tref: forwardedRef\n\t}) : null;\n});\nconst SelectIndicatorFrame = styled(View, {\n\tdisplayName: \"SelectIndicator\",\n\tposition: \"absolute\",\n\ttop: 0,\n\tleft: 0,\n\tpointerEvents: \"none\",\n\tzIndex: 10\n});\nconst SelectIndicator = createStyledHOC(SelectIndicatorFrame, function SelectIndicator2({ scope, ...props }, forwardedRef) {\n\tconst itemContext = useSelectItemParentContext(scope);\n\tconst context = useSelectContext(scope);\n\tconst [layout, setLayout] = React.useState(null);\n\tconst rafRef = React.useRef(0);\n\tReact.useLayoutEffect(() => {\n\t\tconst update = (index) => {\n\t\t\tif (typeof index !== \"number\") return;\n\t\t\tcancelAnimationFrame(rafRef.current);\n\t\t\trafRef.current = requestAnimationFrame(() => {\n\t\t\t\tconst node = itemContext.listRef?.current?.[index];\n\t\t\t\tif (node) setLayout({\n\t\t\t\t\twidth: Math.round(node.offsetWidth),\n\t\t\t\t\theight: Math.round(node.offsetHeight),\n\t\t\t\t\tx: Math.round(node.offsetLeft),\n\t\t\t\t\ty: Math.round(node.offsetTop)\n\t\t\t\t});\n\t\t\t});\n\t\t};\n\t\tif (context.open && context.activeIndexRef.current !== null) update(context.activeIndexRef.current);\n\t\treturn itemContext.activeIndexSubscribe(update);\n\t}, [context.open, itemContext.listRef]);\n\tif (!layout) return null;\n\treturn /* @__PURE__ */ jsx(SelectIndicatorFrame, {\n\t\tref: forwardedRef,\n\t\t...props,\n\t\twidth: layout.width,\n\t\theight: layout.height,\n\t\tx: layout.x,\n\t\ty: layout.y\n\t});\n});\nconst GROUP_NAME = \"SelectGroup\";\nconst { Provider: SelectGroupContextProvider, useStyledContext: useSelectGroupContext } = createStyledContext({ id: \"\" }, \"SelectGroup\");\nconst SelectGroupFrame = styled(View, { displayName: GROUP_NAME });\nconst NativeSelect = styled(Text, {\n\tdisplayName: \"NativeSelect\",\n\trender: \"select\"\n});\nconst SelectGroup = createStyledHOC(SelectGroupFrame, (props, forwardedRef) => {\n\tconst { scope, ...groupProps } = props;\n\tconst groupId = React.useId();\n\tconst context = useSelectContext(scope);\n\tconst itemParentContext = useSelectItemParentContext(scope);\n\tconst StyledNativeSelect = React.useContext(SelectNativeComponentContext);\n\tconst nativeSelectRef = React.useRef(null);\n\tconst content = (() => {\n\t\tif (itemParentContext.shouldRenderWebNative) return /* @__PURE__ */ jsx(NativeSelect, {\n\t\t\t...StyledNativeSelect && {\n\t\t\t\trender: StyledNativeSelect,\n\t\t\t\tsize: itemParentContext.size,\n\t\t\t\tstyle: { appearance: \"none\" }\n\t\t\t},\n\t\t\t...groupProps,\n\t\t\tvalue: context.value,\n\t\t\tmultiple: context.mode === \"multiple\",\n\t\t\tname: itemParentContext.name,\n\t\t\tform: itemParentContext.form,\n\t\t\tid: itemParentContext.id,\n\t\t\tonChange: ((event) => {\n\t\t\t\tconst value = context.mode === \"multiple\" ? Array.from(event.currentTarget.selectedOptions, (option) => option.value) : event.currentTarget.value;\n\t\t\t\titemParentContext.changeNativeValue(value, event.nativeEvent);\n\t\t\t}),\n\t\t\tref: nativeSelectRef,\n\t\t\tchildren: props.children\n\t\t});\n\t\treturn /* @__PURE__ */ jsx(SelectGroupFrame, {\n\t\t\trole: \"group\",\n\t\t\t\"aria-labelledby\": groupId,\n\t\t\t...groupProps,\n\t\t\tref: forwardedRef\n\t\t});\n\t})();\n\treturn /* @__PURE__ */ jsx(SelectGroupContextProvider, {\n\t\tscope,\n\t\tid: groupId || \"\",\n\t\tchildren: content\n\t});\n});\nSelectGroup.displayName = GROUP_NAME;\nconst SelectLabelFrame = styled(Text, { displayName: \"SelectLabel\" });\nconst SelectLabel = createStyledHOC(SelectLabelFrame, (props, forwardedRef) => {\n\tconst { scope, ...labelProps } = props;\n\tconst context = useSelectItemParentContext(scope);\n\tconst groupContext = useSelectGroupContext(scope);\n\tif (context.shouldRenderWebNative) return null;\n\treturn /* @__PURE__ */ jsx(SelectLabelFrame, {\n\t\trender: \"div\",\n\t\tid: groupContext.id,\n\t\t...labelProps,\n\t\tref: forwardedRef\n\t});\n});\nconst SelectSeparator = styled(View, { displayName: \"SelectSeparator\" });\nconst SelectSheetImpl = (props) => {\n\treturn /* @__PURE__ */ jsx(Fragment, { children: props.children });\n};\nfunction SelectRoot(props) {\n\tconst adaptScope = `AdaptSelect${props.scope || \"\"}`;\n\tconst [open, requestOpenChange] = useControllableState({\n\t\tprop: props.open,\n\t\tdefaultProp: props.defaultOpen || false,\n\t\tonChange: props.onOpenChange\n\t});\n\treturn /* @__PURE__ */ jsx(AdaptParent, {\n\t\tscope: adaptScope,\n\t\topen,\n\t\tonOpenChange: React.useCallback((nextOpen) => {\n\t\t\trequestOpenChange(nextOpen, createChangeEventDetails(nextOpen ? \"trigger-press\" : \"outside-press\"));\n\t\t}, [requestOpenChange]),\n\t\tchildren: /* @__PURE__ */ jsx(SelectInner, {\n\t\t\t...props,\n\t\t\tscope: props.scope,\n\t\t\tadaptScope,\n\t\t\topen,\n\t\t\trequestOpenChange\n\t\t})\n\t});\n}\nconst Select = withStaticProperties(SelectRoot, {\n\tRoot: SelectRoot,\n\tAdapt,\n\tContent: SelectContent,\n\tGroup: SelectGroup,\n\tIcon: SelectIcon,\n\tItem: SelectItem,\n\tItemIndicator: SelectItemIndicator,\n\tItemText: SelectItemText,\n\tLabel: SelectLabel,\n\tScrollDownButton: SelectScrollDownButton,\n\tScrollUpButton: SelectScrollUpButton,\n\tSeparator: SelectSeparator,\n\tTrigger: SelectTrigger,\n\tValue: SelectValue,\n\tViewport: SelectViewport,\n\tIndicator: SelectIndicator,\n\tFocusScope: FocusScopeController\n});\nfunction useEmitter() {\n\tconst listenersRef = React.useRef(/* @__PURE__ */ new Set());\n\treturn [React.useCallback((value) => {\n\t\tlistenersRef.current.forEach((l) => l(value));\n\t}, []), React.useCallback((listener) => {\n\t\tlistenersRef.current.add(listener);\n\t\treturn () => {\n\t\t\tlistenersRef.current.delete(listener);\n\t\t};\n\t}, [])];\n}\nfunction SelectInner(props) {\n\tconst { scope = \"\", adaptScope, native, children, open, requestOpenChange, defaultOpen: _defaultOpen, onOpenChange: _onOpenChange, value: valueProp, defaultValue, onValueChange, multiple = false, name, form, disablePreventBodyScroll, size: sizeProp = true, onActiveChange, dir, id, renderValue, lazyMount, zIndex } = props;\n\tconst SelectImpl = useAdaptIsActive(adaptScope) ? SelectSheetImpl : SelectInlineImpl;\n\tconst mode = multiple ? \"multiple\" : \"single\";\n\tconst [valueState, requestValueChange] = useControllableState({\n\t\tprop: valueProp,\n\t\tdefaultProp: defaultValue ?? (mode === \"multiple\" ? [] : \"\"),\n\t\tonChange: onValueChange,\n\t\ttransition: true\n\t});\n\tconst value = React.useMemo(() => mode === \"multiple\" ? selectedValuesFromSelection(mode, valueState) : typeof valueState === \"string\" ? valueState : \"\", [mode, valueState]);\n\tconst selectedValues = React.useMemo(() => selectedValuesFromSelection(mode, value), [mode, value]);\n\tconst [, rerenderRegistry] = React.useReducer((version) => version + 1, 0);\n\tconst registryRef = React.useRef(null);\n\tif (!registryRef.current) registryRef.current = createSelectItemRegistry(rerenderRegistry);\n\tconst registry = registryRef.current;\n\tconst controllerRef = React.useRef(null);\n\tif (!controllerRef.current) controllerRef.current = createSelectSelectionController({\n\t\tmode,\n\t\tvalue,\n\t\tregistry\n\t});\n\tconst controller = controllerRef.current;\n\tcontroller.setMode(mode);\n\tcontroller.setValue(value);\n\tReact.useEffect(() => {}, [props.id, requestOpenChange]);\n\tconst activeIndexRef = React.useRef(null);\n\tconst [activeIndex, setActiveIndexState] = React.useState(null);\n\tconst [emitActiveIndex, activeIndexSubscribe] = useEmitter();\n\tconst selectedIndexRef = React.useRef(null);\n\tconst listContentRef = React.useRef([]);\n\tconst listRef = React.useRef([]);\n\tconst [valueNode, setValueNode] = React.useState(null);\n\tconst selectedIndex = Math.max(0, controller.selectionAnchorIndex());\n\tlistContentRef.current = registry.getTypeaheadLabels();\n\tlistRef.current.length = registry.getItems().length;\n\tuseIsomorphicLayoutEffect(() => {\n\t\tselectedIndexRef.current = selectedIndex;\n\t});\n\tconst shouldRenderWebNative = isWeb && (native === true || native === \"web\" || Array.isArray(native) && native.includes(\"web\"));\n\tconst setActiveIndexFast = React.useCallback((index, details) => {\n\t\tif (activeIndexRef.current !== index) {\n\t\t\tactiveIndexRef.current = index;\n\t\t\tcontroller.setActiveIndex(index);\n\t\t\tif (typeof index === \"number\") {\n\t\t\t\temitActiveIndex(index);\n\t\t\t\tconst item = registry.getItems()[index];\n\t\t\t\tif (item && details) onActiveChange?.(item.value, details);\n\t\t\t}\n\t\t}\n\t}, [\n\t\tcontroller,\n\t\temitActiveIndex,\n\t\tonActiveChange,\n\t\tregistry\n\t]);\n\tconst setActiveIndex = React.useCallback((index, details) => {\n\t\tsetActiveIndexFast(index, details);\n\t\tsetActiveIndexState(index);\n\t}, [setActiveIndexFast]);\n\tconst activeDetails = React.useCallback((reason, index, event) => ({\n\t\treason,\n\t\tevent,\n\t\ttrigger: void 0,\n\t\tindex\n\t}), []);\n\tconst moveActive = React.useCallback((direction, event) => {\n\t\tconst nextIndex = registry.nextEnabledIndex(activeIndexRef.current, direction);\n\t\tif (nextIndex >= 0) setActiveIndex(nextIndex, activeDetails(\"keyboard\", nextIndex, event));\n\t}, [\n\t\tactiveDetails,\n\t\tregistry,\n\t\tsetActiveIndex\n\t]);\n\tconst typeaheadRef = React.useRef({\n\t\ttext: \"\",\n\t\ttimeout: null\n\t});\n\tconst search = React.useCallback((text, event) => {\n\t\tclearTimeout(typeaheadRef.current.timeout);\n\t\ttypeaheadRef.current.text += text;\n\t\tlet nextIndex = registry.findTypeaheadIndex(typeaheadRef.current.text, activeIndexRef.current);\n\t\tif (nextIndex < 0 && typeaheadRef.current.text.length > 1) {\n\t\t\ttypeaheadRef.current.text = text;\n\t\t\tnextIndex = registry.findTypeaheadIndex(text, activeIndexRef.current);\n\t\t}\n\t\ttypeaheadRef.current.timeout = setTimeout(() => {\n\t\t\ttypeaheadRef.current.text = \"\";\n\t\t}, 750);\n\t\tif (nextIndex >= 0) setActiveIndex(nextIndex, activeDetails(\"keyboard\", nextIndex, event));\n\t}, [\n\t\tactiveDetails,\n\t\tregistry,\n\t\tsetActiveIndex\n\t]);\n\tReact.useEffect(() => {\n\t\treturn () => clearTimeout(typeaheadRef.current.timeout);\n\t}, []);\n\tReact.useEffect(() => {\n\t\tif (open) {\n\t\t\tconst nextIndex = controller.initialActiveIndex();\n\t\t\tif (nextIndex >= 0) setActiveIndex(nextIndex, activeDetails(\"list-navigation\", nextIndex));\n\t\t} else {\n\t\t\tsetActiveIndexFast(null);\n\t\t\tsetActiveIndexState(null);\n\t\t}\n\t}, [\n\t\topen,\n\t\tselectedIndex,\n\t\tregistry.getItems().length\n\t]);\n\tconst content = /* @__PURE__ */ jsxs(SelectItemParentProvider, {\n\t\tscopeName: scope,\n\t\tscope,\n\t\tadaptScope,\n\t\tmode,\n\t\tselectedValues,\n\t\tregistry,\n\t\tsize: sizeProp,\n\t\tactiveIndexSubscribe,\n\t\tactiveIndexRef,\n\t\trequestOpenChange,\n\t\tid,\n\t\tname,\n\t\tform,\n\t\tselectValue: React.useCallback((nextItemValue, details) => {\n\t\t\tconst item = registry.getItem(nextItemValue);\n\t\t\tif (!item || item.disabled) return;\n\t\t\tcontroller.setMode(mode);\n\t\t\tcontroller.setValue(value);\n\t\t\tconst previousValue = controller.value;\n\t\t\trequestValueChange(controller.toggle(nextItemValue), details);\n\t\t\tif (details.isCanceled) {\n\t\t\t\tcontroller.setValue(previousValue);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (controller.shouldCloseOnSelect) requestOpenChange(false, createChangeEventDetails(details.reason === \"keyboard\" ? \"keyboard\" : \"item-press\", details.event, details.trigger));\n\t\t}, [\n\t\t\tcontroller,\n\t\t\tmode,\n\t\t\tregistry,\n\t\t\trequestOpenChange,\n\t\t\trequestValueChange,\n\t\t\tvalue\n\t\t]),\n\t\tchangeNativeValue: React.useCallback((nextValue, event) => {\n\t\t\tconst details = createChangeEventDetails(\"native-change\", event);\n\t\t\trequestValueChange(nextValue, details);\n\t\t\tif (!details.isCanceled) controller.setValue(nextValue);\n\t\t}, [controller, requestValueChange]),\n\t\tshouldRenderWebNative,\n\t\tsetActiveIndexFast,\n\t\tlistRef,\n\t\tmoveActive,\n\t\tsearch,\n\t\tchildren: [/* @__PURE__ */ jsx(SelectProvider, {\n\t\t\tscope,\n\t\t\tscopeName: scope,\n\t\t\tadaptScope,\n\t\t\tdisablePreventBodyScroll,\n\t\t\tdir,\n\t\t\tblockSelection: false,\n\t\t\tfallback: false,\n\t\t\tvalueNode,\n\t\t\tonValueNodeChange: setValueNode,\n\t\t\tactiveIndex,\n\t\t\tactiveIndexRef,\n\t\t\tselectedIndex,\n\t\t\tsetActiveIndex,\n\t\t\tvalue,\n\t\t\tmode,\n\t\t\tselectedValues,\n\t\t\tactiveItem: activeIndex == null ? void 0 : registry.getItems()[activeIndex]?.value,\n\t\t\tselectionAnchor: controller.selectionAnchor()?.value,\n\t\t\topen,\n\t\t\tnative,\n\t\t\trenderValue,\n\t\t\tlazyMount,\n\t\t\tchildren: shouldRenderWebNative ? children : /* @__PURE__ */ jsx(SelectImpl, {\n\t\t\t\tactiveIndexRef,\n\t\t\t\tlistContentRef,\n\t\t\t\tselectedIndexRef,\n\t\t\t\tsetActiveIndexFast,\n\t\t\t\t...props,\n\t\t\t\topen,\n\t\t\t\tvalue,\n\t\t\t\tchildren\n\t\t\t})\n\t\t}), isWeb && !shouldRenderWebNative && name ? (mode === \"multiple\" ? selectedValues : [value]).map((inputValue) => /* @__PURE__ */ jsx(\"input\", {\n\t\t\ttype: \"hidden\",\n\t\t\tname,\n\t\t\tform,\n\t\t\tvalue: inputValue\n\t\t}, inputValue)) : null]\n\t});\n\tif (zIndex !== void 0) return /* @__PURE__ */ jsx(SelectZIndexContext.Provider, {\n\t\tvalue: zIndex,\n\t\tchildren: content\n\t});\n\treturn content;\n}\n\nexport { Select, SelectGroup, SelectGroupFrame, SelectIcon, SelectIndicator, SelectIndicatorFrame, SelectItemIndicator, SelectItemIndicatorFrame, SelectLabel, SelectLabelFrame, SelectRoot, SelectSeparator, SelectValue, SelectValueFrame };"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,mBAAmB,OAAO,MAAM,EAAE,aAAa,cAAc,CAAC;AACpE,MAAM,cAAc,gBAAgB,kBAAkB,SAAS,aAAa,EAAE,OAAO,UAAU,cAAc,aAAa,GAAG,SAAS,cAAc;CACnJ,MAAM,UAAU,iBAAiB,KAAK;CACtC,MAAM,oBAAoB,2BAA2B,KAAK;CAC1D,MAAM,eAAe,gBAAgB,cAAc,QAAQ,iBAAiB;CAC5E,MAAM,eAAe,QAAQ,eAAe,WAAW;CACvD,MAAM,kBAAkB,QAAQ,SAAS,aAAa,QAAQ,eAAe,KAAK,OAAO,UAA0B,qBAAK,MAAM,UAAU,EAAE,UAAU,CAAC,QAAQ,IAAI,OAAO,MAAM,kBAAkB,SAAS,QAAQ,KAAK,CAAC,EAAE,SAAS,KAAK,EAAE,GAAG,KAAK,CAAC,IAAI,kB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B;GACA;GACA;GACA;GACA;GACA;GACA;GACA,YAAY,eAAe,OAAO,KAAK,IAAI,SAAS,SAAS,CAAC,CAAC,YAAY,EAAE;GAC7E,iBAAiB,WAAW,gBAAgB,CAAC,EAAE;GAC/C;GACA;GACA;GACA;GACA,UAAU,wBAAwB,WAA2B,oBAAI,YAAY;IAC5E;IACA;IACA;IACA;IACA,GAAG;IACH;IACA;IACA;GACD,CAAC;EACF,CAAC,GAAG,SAAS,CAAC,yBAAyB,QAAQ,SAAS,aAAa,iBAAiB,CAAC,KAAK,EAAC,CAAE,KAAK,eAA+B,oBAAI,SAAS;GAC/I,MAAM;GACN;GACA;GACA,OAAO;EACR,GAAG,UAAU,CAAC,IAAI,IAAI;CACvB,CAAC;CACD,IAAI,WAAW,KAAK,GAAG,OAAuB,oBAAI,oBAAoB,UAAU;EAC/E,OAAO;EACP,UAAU;CACX,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"Select.js","names":[],"sources":["esm/Select.js"],"sourcesContent":["import { Adapt, AdaptParent, useAdaptIsActive } from \"@tamagui/adapt\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { Text, View, createChangeEventDetails, createStyledContext, createStyledHOC, styled } from \"@tamagui/core\";\nimport { FocusScopeController } from \"@tamagui/focus-scope\";\nimport { withStaticProperties } from \"@tamagui/helpers\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport * as React from \"react\";\nimport { SelectItemParentProvider, SelectNativeComponentContext, SelectProvider, SelectZIndexContext, useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { SelectContent } from \"./SelectContent\";\nimport { SelectInlineImpl } from \"./SelectImpl\";\nimport { SelectItem, useSelectItemContext } from \"./SelectItem\";\nimport { SelectItemText } from \"./SelectItemText\";\nimport { SelectScrollDownButton, SelectScrollUpButton } from \"./SelectScrollButton\";\nimport { SelectTrigger } from \"./SelectTrigger\";\nimport { SelectViewport } from \"./SelectViewport\";\nimport { createSelectItemRegistry, createSelectSelectionController, selectedValuesFromSelection } from \"./selectionController\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\n\nconst SelectValueFrame = styled(Text, { displayName: \"SelectValue\" });\nconst SelectValue = createStyledHOC(SelectValueFrame, function SelectValue2({ scope, children: childrenProp, placeholder, ...props }, forwardedRef) {\n\tconst context = useSelectContext(scope);\n\tconst itemParentContext = useSelectItemParentContext(scope);\n\tconst composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);\n\tconst isEmptyValue = context.selectedValues.length === 0;\n\tconst [, rerender] = React.useReducer((version) => version + 1, 0);\n\tuseIsomorphicLayoutEffect(() => itemParentContext.registry.subscribe(rerender), [itemParentContext.registry]);\n\tconst registeredValue = context.mode === \"multiple\" ? context.selectedValues.map((value, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [index > 0 ? \", \" : null, itemParentContext.registry.getItem(value)?.label ?? value] }, value)) : itemParentContext.registry.getItem(context.selectedValues[0])?.label ?? context.value;\n\tconst children = childrenProp !== void 0 ? childrenProp : context.renderValue ? context.renderValue(context.value) : registeredValue;\n\tconst selectValueChildren = isEmptyValue ? placeholder ?? children : children;\n\treturn /* @__PURE__ */ jsx(SelectValueFrame, {\n\t\tpointerEvents: \"none\",\n\t\tref: composedRefs,\n\t\t...props,\n\t\tchildren: selectValueChildren\n\t});\n});\nconst SelectIcon = styled(View, {\n\tdisplayName: \"SelectIcon\",\n\t\"aria-hidden\": true\n});\nconst SelectItemIndicatorFrame = styled(View, { displayName: \"SelectItemIndicator\" });\nconst SelectItemIndicator = createStyledHOC(SelectItemIndicatorFrame, function SelectItemIndicator2(props, forwardedRef) {\n\tconst { scope, ...itemIndicatorProps } = props;\n\tconst context = useSelectItemParentContext(scope);\n\tconst itemContext = useSelectItemContext(scope);\n\tif (context.shouldRenderWebNative) return null;\n\treturn itemContext.isSelected ? /* @__PURE__ */ jsx(SelectItemIndicatorFrame, {\n\t\t\"aria-hidden\": true,\n\t\t...itemIndicatorProps,\n\t\tref: forwardedRef\n\t}) : null;\n});\nconst SelectIndicatorFrame = styled(View, {\n\tdisplayName: \"SelectIndicator\",\n\tposition: \"absolute\",\n\ttop: 0,\n\tleft: 0,\n\tpointerEvents: \"none\",\n\tzIndex: 10\n});\nconst SelectIndicator = createStyledHOC(SelectIndicatorFrame, function SelectIndicator2({ scope, ...props }, forwardedRef) {\n\tconst itemContext = useSelectItemParentContext(scope);\n\tconst context = useSelectContext(scope);\n\tconst [layout, setLayout] = React.useState(null);\n\tconst rafRef = React.useRef(0);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tconst update = (index) => {\n\t\t\tif (typeof index !== \"number\") return;\n\t\t\tcancelAnimationFrame(rafRef.current);\n\t\t\trafRef.current = requestAnimationFrame(() => {\n\t\t\t\tconst node = itemContext.listRef?.current?.[index];\n\t\t\t\tif (node) setLayout({\n\t\t\t\t\twidth: Math.round(node.offsetWidth),\n\t\t\t\t\theight: Math.round(node.offsetHeight),\n\t\t\t\t\tx: Math.round(node.offsetLeft),\n\t\t\t\t\ty: Math.round(node.offsetTop)\n\t\t\t\t});\n\t\t\t});\n\t\t};\n\t\tif (context.open && context.activeIndexRef.current !== null) update(context.activeIndexRef.current);\n\t\treturn itemContext.activeIndexSubscribe(update);\n\t}, [context.open, itemContext.listRef]);\n\tif (!layout) return null;\n\treturn /* @__PURE__ */ jsx(SelectIndicatorFrame, {\n\t\tref: forwardedRef,\n\t\t...props,\n\t\twidth: layout.width,\n\t\theight: layout.height,\n\t\tx: layout.x,\n\t\ty: layout.y\n\t});\n});\nconst GROUP_NAME = \"SelectGroup\";\nconst { Provider: SelectGroupContextProvider, useStyledContext: useSelectGroupContext } = createStyledContext({ id: \"\" }, \"SelectGroup\");\nconst SelectGroupFrame = styled(View, { displayName: GROUP_NAME });\nconst NativeSelect = styled(Text, {\n\tdisplayName: \"NativeSelect\",\n\trender: \"select\"\n});\nconst SelectGroup = createStyledHOC(SelectGroupFrame, (props, forwardedRef) => {\n\tconst { scope, ...groupProps } = props;\n\tconst groupId = React.useId();\n\tconst context = useSelectContext(scope);\n\tconst itemParentContext = useSelectItemParentContext(scope);\n\tconst StyledNativeSelect = React.useContext(SelectNativeComponentContext);\n\tconst nativeSelectRef = React.useRef(null);\n\tconst content = (() => {\n\t\tif (itemParentContext.shouldRenderWebNative) return /* @__PURE__ */ jsx(NativeSelect, {\n\t\t\t...StyledNativeSelect && {\n\t\t\t\trender: StyledNativeSelect,\n\t\t\t\tsize: itemParentContext.size,\n\t\t\t\tstyle: { appearance: \"none\" }\n\t\t\t},\n\t\t\t...groupProps,\n\t\t\tvalue: context.value,\n\t\t\tmultiple: context.mode === \"multiple\",\n\t\t\tname: itemParentContext.name,\n\t\t\tform: itemParentContext.form,\n\t\t\tid: itemParentContext.id,\n\t\t\tonChange: ((event) => {\n\t\t\t\tconst value = context.mode === \"multiple\" ? Array.from(event.currentTarget.selectedOptions, (option) => option.value) : event.currentTarget.value;\n\t\t\t\titemParentContext.changeNativeValue(value, event.nativeEvent);\n\t\t\t}),\n\t\t\tref: nativeSelectRef,\n\t\t\tchildren: props.children\n\t\t});\n\t\treturn /* @__PURE__ */ jsx(SelectGroupFrame, {\n\t\t\trole: \"group\",\n\t\t\t\"aria-labelledby\": groupId,\n\t\t\t...groupProps,\n\t\t\tref: forwardedRef\n\t\t});\n\t})();\n\treturn /* @__PURE__ */ jsx(SelectGroupContextProvider, {\n\t\tscope,\n\t\tid: groupId || \"\",\n\t\tchildren: content\n\t});\n});\nSelectGroup.displayName = GROUP_NAME;\nconst SelectLabelFrame = styled(Text, { displayName: \"SelectLabel\" });\nconst SelectLabel = createStyledHOC(SelectLabelFrame, (props, forwardedRef) => {\n\tconst { scope, ...labelProps } = props;\n\tconst context = useSelectItemParentContext(scope);\n\tconst groupContext = useSelectGroupContext(scope);\n\tif (context.shouldRenderWebNative) return null;\n\treturn /* @__PURE__ */ jsx(SelectLabelFrame, {\n\t\trender: \"div\",\n\t\tid: groupContext.id,\n\t\t...labelProps,\n\t\tref: forwardedRef\n\t});\n});\nconst SelectSeparator = styled(View, { displayName: \"SelectSeparator\" });\nconst SelectSheetImpl = (props) => {\n\treturn /* @__PURE__ */ jsx(Fragment, { children: props.children });\n};\nfunction SelectRoot(props) {\n\tconst adaptScope = `AdaptSelect${props.scope || \"\"}`;\n\tconst [open, requestOpenChange] = useControllableState({\n\t\tprop: props.open,\n\t\tdefaultProp: props.defaultOpen || false,\n\t\tonChange: props.onOpenChange\n\t});\n\tconst handleAdaptOpenChange = React.useCallback((nextOpen) => {\n\t\trequestOpenChange(nextOpen, createChangeEventDetails(nextOpen ? \"trigger-press\" : \"outside-press\"));\n\t}, [requestOpenChange]);\n\treturn /* @__PURE__ */ jsx(AdaptParent, {\n\t\tscope: adaptScope,\n\t\tadaptChildren: props.children,\n\t\topen,\n\t\tonOpenChange: handleAdaptOpenChange,\n\t\tchildren: /* @__PURE__ */ jsx(SelectInner, {\n\t\t\t...props,\n\t\t\tscope: props.scope,\n\t\t\tadaptScope,\n\t\t\topen,\n\t\t\trequestOpenChange\n\t\t})\n\t});\n}\nconst Select = withStaticProperties(SelectRoot, {\n\tRoot: SelectRoot,\n\tAdapt,\n\tContent: SelectContent,\n\tGroup: SelectGroup,\n\tIcon: SelectIcon,\n\tItem: SelectItem,\n\tItemIndicator: SelectItemIndicator,\n\tItemText: SelectItemText,\n\tLabel: SelectLabel,\n\tScrollDownButton: SelectScrollDownButton,\n\tScrollUpButton: SelectScrollUpButton,\n\tSeparator: SelectSeparator,\n\tTrigger: SelectTrigger,\n\tValue: SelectValue,\n\tViewport: SelectViewport,\n\tIndicator: SelectIndicator,\n\tFocusScope: FocusScopeController\n});\nfunction useEmitter() {\n\tconst listenersRef = React.useRef(/* @__PURE__ */ new Set());\n\treturn [React.useCallback((value) => {\n\t\tlistenersRef.current.forEach((l) => l(value));\n\t}, []), React.useCallback((listener) => {\n\t\tlistenersRef.current.add(listener);\n\t\treturn () => {\n\t\t\tlistenersRef.current.delete(listener);\n\t\t};\n\t}, [])];\n}\nfunction SelectInner(props) {\n\tconst { scope = \"\", adaptScope, native, children, open, requestOpenChange, defaultOpen: _defaultOpen, onOpenChange: _onOpenChange, value: valueProp, defaultValue, onValueChange, multiple = false, name, form, disablePreventBodyScroll, size: sizeProp = true, onActiveChange, dir, id, renderValue, lazyMount, zIndex } = props;\n\tconst SelectImpl = useAdaptIsActive(adaptScope) ? SelectSheetImpl : SelectInlineImpl;\n\tconst mode = multiple ? \"multiple\" : \"single\";\n\tconst [valueState, requestValueChange] = useControllableState({\n\t\tprop: valueProp,\n\t\tdefaultProp: defaultValue ?? (mode === \"multiple\" ? [] : \"\"),\n\t\tonChange: onValueChange,\n\t\ttransition: true\n\t});\n\tconst value = React.useMemo(() => mode === \"multiple\" ? selectedValuesFromSelection(mode, valueState) : typeof valueState === \"string\" ? valueState : \"\", [mode, valueState]);\n\tconst selectedValues = React.useMemo(() => selectedValuesFromSelection(mode, value), [mode, value]);\n\tconst [, rerenderRegistry] = React.useReducer((version) => version + 1, 0);\n\tconst registryRef = React.useRef(null);\n\tif (!registryRef.current) registryRef.current = createSelectItemRegistry(rerenderRegistry);\n\tconst registry = registryRef.current;\n\tconst controllerRef = React.useRef(null);\n\tif (!controllerRef.current) controllerRef.current = createSelectSelectionController({\n\t\tmode,\n\t\tvalue,\n\t\tregistry\n\t});\n\tconst controller = controllerRef.current;\n\tcontroller.setMode(mode);\n\tcontroller.setValue(value);\n\tReact.useEffect(() => {}, [props.id, requestOpenChange]);\n\tconst activeIndexRef = React.useRef(null);\n\tconst [emitActiveIndex, activeIndexSubscribe] = useEmitter();\n\tconst selectedIndexRef = React.useRef(null);\n\tconst lastPointerRef = React.useRef({\n\t\tx: -1,\n\t\ty: -1\n\t});\n\tconst listContentRef = React.useRef([]);\n\tconst listRef = React.useRef([]);\n\tconst [valueNode, setValueNode] = React.useState(null);\n\tconst selectedIndex = Math.max(0, controller.selectionAnchorIndex());\n\tlistContentRef.current = registry.getTypeaheadLabels();\n\tconst itemNodes = registry.getNodes();\n\tlistRef.current.length = itemNodes.length;\n\tfor (let i = 0; i < itemNodes.length; i++) listRef.current[i] = itemNodes[i];\n\tuseIsomorphicLayoutEffect(() => {\n\t\tselectedIndexRef.current = selectedIndex;\n\t});\n\tconst shouldRenderWebNative = isWeb && (native === true || native === \"web\" || Array.isArray(native) && native.includes(\"web\"));\n\tconst setActiveIndex = React.useCallback((index, details) => {\n\t\tif (activeIndexRef.current === index) return;\n\t\tactiveIndexRef.current = index;\n\t\tcontroller.setActiveIndex(index);\n\t\temitActiveIndex(index);\n\t\tif (typeof index === \"number\") {\n\t\t\tconst item = registry.getItems()[index];\n\t\t\tif (item && details) onActiveChange?.(item.value, details);\n\t\t}\n\t}, [\n\t\tcontroller,\n\t\temitActiveIndex,\n\t\tonActiveChange,\n\t\tregistry\n\t]);\n\tconst activeDetails = React.useCallback((reason, index, event) => ({\n\t\treason,\n\t\tevent,\n\t\ttrigger: void 0,\n\t\tindex\n\t}), []);\n\tconst moveActive = React.useCallback((direction, event) => {\n\t\tconst nextIndex = registry.nextEnabledIndex(activeIndexRef.current, direction);\n\t\tif (nextIndex >= 0) setActiveIndex(nextIndex, activeDetails(\"keyboard\", nextIndex, event));\n\t}, [\n\t\tactiveDetails,\n\t\tregistry,\n\t\tsetActiveIndex\n\t]);\n\tconst typeaheadRef = React.useRef({\n\t\ttext: \"\",\n\t\ttimeout: null\n\t});\n\tconst search = React.useCallback((text, event) => {\n\t\tclearTimeout(typeaheadRef.current.timeout);\n\t\ttypeaheadRef.current.text += text;\n\t\tlet nextIndex = registry.findTypeaheadIndex(typeaheadRef.current.text, activeIndexRef.current);\n\t\tif (nextIndex < 0 && typeaheadRef.current.text.length > 1) {\n\t\t\ttypeaheadRef.current.text = text;\n\t\t\tnextIndex = registry.findTypeaheadIndex(text, activeIndexRef.current);\n\t\t}\n\t\ttypeaheadRef.current.timeout = setTimeout(() => {\n\t\t\ttypeaheadRef.current.text = \"\";\n\t\t}, 750);\n\t\tif (nextIndex >= 0) setActiveIndex(nextIndex, activeDetails(\"keyboard\", nextIndex, event));\n\t}, [\n\t\tactiveDetails,\n\t\tregistry,\n\t\tsetActiveIndex\n\t]);\n\tReact.useEffect(() => {\n\t\treturn () => clearTimeout(typeaheadRef.current.timeout);\n\t}, []);\n\tReact.useEffect(() => {\n\t\tif (open) {\n\t\t\tconst nextIndex = controller.initialActiveIndex();\n\t\t\tif (nextIndex >= 0) setActiveIndex(nextIndex, activeDetails(\"list-navigation\", nextIndex));\n\t\t} else setActiveIndex(null);\n\t}, [\n\t\topen,\n\t\tselectedIndex,\n\t\tregistry.getItems().length\n\t]);\n\tconst content = /* @__PURE__ */ jsxs(SelectItemParentProvider, {\n\t\tscopeName: scope,\n\t\tscope,\n\t\tadaptScope,\n\t\tmode,\n\t\tselectedValues,\n\t\tregistry,\n\t\tsize: sizeProp,\n\t\tactiveIndexSubscribe,\n\t\tactiveIndexRef,\n\t\trequestOpenChange,\n\t\tid,\n\t\tname,\n\t\tform,\n\t\tselectValue: React.useCallback((nextItemValue, details) => {\n\t\t\tconst item = registry.getItem(nextItemValue);\n\t\t\tif (!item || item.disabled) return;\n\t\t\tcontroller.setMode(mode);\n\t\t\tcontroller.setValue(value);\n\t\t\tconst previousValue = controller.value;\n\t\t\trequestValueChange(controller.toggle(nextItemValue), details);\n\t\t\tif (details.isCanceled) {\n\t\t\t\tcontroller.setValue(previousValue);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (controller.shouldCloseOnSelect) requestOpenChange(false, createChangeEventDetails(details.reason === \"keyboard\" ? \"keyboard\" : \"item-press\", details.event, details.trigger));\n\t\t}, [\n\t\t\tcontroller,\n\t\t\tmode,\n\t\t\tregistry,\n\t\t\trequestOpenChange,\n\t\t\trequestValueChange,\n\t\t\tvalue\n\t\t]),\n\t\tchangeNativeValue: React.useCallback((nextValue, event) => {\n\t\t\tconst details = createChangeEventDetails(\"native-change\", event);\n\t\t\trequestValueChange(nextValue, details);\n\t\t\tif (!details.isCanceled) controller.setValue(nextValue);\n\t\t}, [controller, requestValueChange]),\n\t\tshouldRenderWebNative,\n\t\tsetActiveIndex,\n\t\tselectedIndex,\n\t\tlastPointerRef,\n\t\tlistRef,\n\t\tmoveActive,\n\t\tsearch,\n\t\tchildren: [/* @__PURE__ */ jsx(SelectProvider, {\n\t\t\tscope,\n\t\t\tscopeName: scope,\n\t\t\tadaptScope,\n\t\t\tdisablePreventBodyScroll,\n\t\t\tdir,\n\t\t\tblockSelection: false,\n\t\t\tfallback: false,\n\t\t\tvalueNode,\n\t\t\tonValueNodeChange: setValueNode,\n\t\t\tactiveIndexRef,\n\t\t\tselectedIndex,\n\t\t\tsetActiveIndex,\n\t\t\tvalue,\n\t\t\tmode,\n\t\t\tselectedValues,\n\t\t\topen,\n\t\t\tnative,\n\t\t\trenderValue,\n\t\t\tlazyMount,\n\t\t\tchildren: shouldRenderWebNative ? children : /* @__PURE__ */ jsx(SelectImpl, {\n\t\t\t\tactiveIndexRef,\n\t\t\t\tlistContentRef,\n\t\t\t\tselectedIndexRef,\n\t\t\t\t...props,\n\t\t\t\topen,\n\t\t\t\tvalue,\n\t\t\t\tchildren\n\t\t\t})\n\t\t}), isWeb && !shouldRenderWebNative && name ? (mode === \"multiple\" ? selectedValues : [value]).map((inputValue) => /* @__PURE__ */ jsx(\"input\", {\n\t\t\ttype: \"hidden\",\n\t\t\tname,\n\t\t\tform,\n\t\t\tvalue: inputValue\n\t\t}, inputValue)) : null]\n\t});\n\tif (zIndex !== void 0) return /* @__PURE__ */ jsx(SelectZIndexContext.Provider, {\n\t\tvalue: zIndex,\n\t\tchildren: content\n\t});\n\treturn content;\n}\n\nexport { Select, SelectGroup, SelectGroupFrame, SelectIcon, SelectIndicator, SelectIndicatorFrame, SelectItemIndicator, SelectItemIndicatorFrame, SelectLabel, SelectLabelFrame, SelectRoot, SelectSeparator, SelectValue, SelectValueFrame };"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,MA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AAW,SAAS,KAAK;GACzB,MAAM,gBAAgB,WAAW;GACjC,mBAAmB,WAAW,OAAO,aAAa,GAAG,OAAO;GAC5D,IAAI,QAAQ,YAAY;IACvB,WAAW,SAAS,aAAa;IACjC;GACD;GACA,IAAI,WAAW,qBAAqB,kBAAkB,OAAO,yBAAyB,QAAQ,WAAW,aAAa,aAAa,cAAc,QAAQ,OAAO,QAAQ,OAAO,CAAC;EACjL,GAAG;GACF;GACA;GACA;GACA;GACA;GACA;EACD,CAAC;EACD,mBAAmB,MAAM,aAAa,WAAW,UAAU;GAC1D,MAAM,UAAU,yBAAyB,iBAAiB,KAAK;GAC/D,mBAAmB,WAAW,OAAO;GACrC,IAAI,CAAC,QAAQ,YAAY,WAAW,SAAS,SAAS;EACvD,GAAG,CAAC,YAAY,kBAAkB,CAAC;EACnC;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU,CAAiB,oBAAI,gBAAgB;GAC9C;GACA,WAAW;GACX;GACA;GACA;GACA,gBAAgB;GAChB,UAAU;GACV;GACA,mBAAmB;GACnB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,UAAU,wBAAwB,WAA2B,oBAAI,YAAY;IAC5E;IACA;IACA;IACA,GAAG;IACH;IACA;IACA;GACD,CAAC;EACF,CAAC,GAAG,SAAS,CAAC,yBAAyB,QAAQ,SAAS,aAAa,iBAAiB,CAAC,KAAK,EAAC,CAAE,KAAK,eAA+B,oBAAI,SAAS;GAC/I,MAAM;GACN;GACA;GACA,OAAO;EACR,GAAG,UAAU,CAAC,IAAI,IAAI;CACvB,CAAC;CACD,IAAI,WAAW,KAAK,GAAG,OAAuB,oBAAI,oBAAoB,UAAU;EAC/E,OAAO;EACP,UAAU;CACX,CAAC;CACD,OAAO;AACR"}
@@ -26,6 +26,12 @@ var SelectValue = createStyledHOC(SelectValueFrame, function SelectValue2(param,
26
26
  var itemParentContext = useSelectItemParentContext(scope);
27
27
  var composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
28
28
  var isEmptyValue = context.selectedValues.length === 0;
29
+ var [, rerender] = React.useReducer(function(version) {
30
+ return version + 1;
31
+ }, 0);
32
+ useIsomorphicLayoutEffect(function() {
33
+ return itemParentContext.registry.subscribe(rerender);
34
+ }, [itemParentContext.registry]);
29
35
  var _itemParentContext_registry_getItem_label;
30
36
  var registeredValue = context.mode === "multiple" ? context.selectedValues.map(function(value, index) {
31
37
  var _itemParentContext_registry_getItem2;
@@ -71,7 +77,7 @@ var SelectIndicator = createStyledHOC(SelectIndicatorFrame, function SelectIndic
71
77
  var context = useSelectContext(scope);
72
78
  var [layout, setLayout] = React.useState(null);
73
79
  var rafRef = React.useRef(0);
74
- React.useLayoutEffect(function() {
80
+ useIsomorphicLayoutEffect(function() {
75
81
  var update = function(index) {
76
82
  if (typeof index !== "number") return;
77
83
  cancelAnimationFrame(rafRef.current);
@@ -173,12 +179,14 @@ function SelectRoot(props) {
173
179
  defaultProp: props.defaultOpen || false,
174
180
  onChange: props.onOpenChange
175
181
  });
182
+ var handleAdaptOpenChange = React.useCallback(function(nextOpen) {
183
+ requestOpenChange(nextOpen, createChangeEventDetails(nextOpen ? "trigger-press" : "outside-press"));
184
+ }, [requestOpenChange]);
176
185
  return /* @__PURE__ */ jsx(AdaptParent, {
177
186
  scope: adaptScope,
187
+ adaptChildren: props.children,
178
188
  open,
179
- onOpenChange: React.useCallback(function(nextOpen) {
180
- requestOpenChange(nextOpen, createChangeEventDetails(nextOpen ? "trigger-press" : "outside-press"));
181
- }, [requestOpenChange]),
189
+ onOpenChange: handleAdaptOpenChange,
182
190
  children: /* @__PURE__ */ jsx(SelectInner, {
183
191
  ...props,
184
192
  scope: props.scope,
@@ -221,7 +229,6 @@ function useEmitter() {
221
229
  }, [])];
222
230
  }
223
231
  function SelectInner(props) {
224
- var _registry_getItems_activeIndex, _controller_selectionAnchor;
225
232
  var { scope = "", adaptScope, native, children, open, requestOpenChange, defaultOpen: _defaultOpen, onOpenChange: _onOpenChange, value: valueProp, defaultValue, onValueChange, multiple = false, name, form, disablePreventBodyScroll, size: sizeProp = true, onActiveChange, dir, id, renderValue, lazyMount, zIndex } = props;
226
233
  var SelectImpl = useAdaptIsActive(adaptScope) ? SelectSheetImpl : SelectInlineImpl;
227
234
  var mode = multiple ? "multiple" : "single";
@@ -264,28 +271,32 @@ function SelectInner(props) {
264
271
  });
265
272
  }, [props.id, requestOpenChange]);
266
273
  var activeIndexRef = React.useRef(null);
267
- var [activeIndex, setActiveIndexState] = React.useState(null);
268
274
  var [emitActiveIndex, activeIndexSubscribe] = useEmitter();
269
275
  var selectedIndexRef = React.useRef(null);
276
+ var lastPointerRef = React.useRef({
277
+ x: -1,
278
+ y: -1
279
+ });
270
280
  var listContentRef = React.useRef([]);
271
281
  var listRef = React.useRef([]);
272
282
  var [valueNode, setValueNode] = React.useState(null);
273
283
  var selectedIndex = Math.max(0, controller.selectionAnchorIndex());
274
284
  listContentRef.current = registry.getTypeaheadLabels();
275
- listRef.current.length = registry.getItems().length;
285
+ var itemNodes = registry.getNodes();
286
+ listRef.current.length = itemNodes.length;
287
+ for (var i = 0; i < itemNodes.length; i++) listRef.current[i] = itemNodes[i];
276
288
  useIsomorphicLayoutEffect(function() {
277
289
  selectedIndexRef.current = selectedIndex;
278
290
  });
279
291
  var shouldRenderWebNative = isWeb && (native === true || native === "web" || Array.isArray(native) && native.includes("web"));
280
- var setActiveIndexFast = React.useCallback(function(index, details) {
281
- if (activeIndexRef.current !== index) {
282
- activeIndexRef.current = index;
283
- controller.setActiveIndex(index);
284
- if (typeof index === "number") {
285
- emitActiveIndex(index);
286
- var item = registry.getItems()[index];
287
- if (item && details) onActiveChange === null || onActiveChange === void 0 || onActiveChange(item.value, details);
288
- }
292
+ var setActiveIndex = React.useCallback(function(index, details) {
293
+ if (activeIndexRef.current === index) return;
294
+ activeIndexRef.current = index;
295
+ controller.setActiveIndex(index);
296
+ emitActiveIndex(index);
297
+ if (typeof index === "number") {
298
+ var item = registry.getItems()[index];
299
+ if (item && details) onActiveChange === null || onActiveChange === void 0 || onActiveChange(item.value, details);
289
300
  }
290
301
  }, [
291
302
  controller,
@@ -293,10 +304,6 @@ function SelectInner(props) {
293
304
  onActiveChange,
294
305
  registry
295
306
  ]);
296
- var setActiveIndex = React.useCallback(function(index, details) {
297
- setActiveIndexFast(index, details);
298
- setActiveIndexState(index);
299
- }, [setActiveIndexFast]);
300
307
  var activeDetails = React.useCallback(function(reason, index, event) {
301
308
  return {
302
309
  reason,
@@ -343,10 +350,7 @@ function SelectInner(props) {
343
350
  if (open) {
344
351
  var nextIndex = controller.initialActiveIndex();
345
352
  if (nextIndex >= 0) setActiveIndex(nextIndex, activeDetails("list-navigation", nextIndex));
346
- } else {
347
- setActiveIndexFast(null);
348
- setActiveIndexState(null);
349
- }
353
+ } else setActiveIndex(null);
350
354
  }, [
351
355
  open,
352
356
  selectedIndex,
@@ -392,7 +396,9 @@ function SelectInner(props) {
392
396
  if (!details.isCanceled) controller.setValue(nextValue);
393
397
  }, [controller, requestValueChange]),
394
398
  shouldRenderWebNative,
395
- setActiveIndexFast,
399
+ setActiveIndex,
400
+ selectedIndex,
401
+ lastPointerRef,
396
402
  listRef,
397
403
  moveActive,
398
404
  search,
@@ -406,15 +412,12 @@ function SelectInner(props) {
406
412
  fallback: false,
407
413
  valueNode,
408
414
  onValueNodeChange: setValueNode,
409
- activeIndex,
410
415
  activeIndexRef,
411
416
  selectedIndex,
412
417
  setActiveIndex,
413
418
  value,
414
419
  mode,
415
420
  selectedValues,
416
- activeItem: activeIndex == null ? void 0 : (_registry_getItems_activeIndex = registry.getItems()[activeIndex]) === null || _registry_getItems_activeIndex === void 0 ? void 0 : _registry_getItems_activeIndex.value,
417
- selectionAnchor: (_controller_selectionAnchor = controller.selectionAnchor()) === null || _controller_selectionAnchor === void 0 ? void 0 : _controller_selectionAnchor.value,
418
421
  open,
419
422
  native,
420
423
  renderValue,
@@ -423,7 +426,6 @@ function SelectInner(props) {
423
426
  activeIndexRef,
424
427
  listContentRef,
425
428
  selectedIndexRef,
426
- setActiveIndexFast,
427
429
  ...props,
428
430
  open,
429
431
  value,