@tamagui/select 3.0.0-beta.669.1 → 3.0.0-beta.728.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.
- package/dist/cjs/Select.cjs +0 -1
- package/dist/cjs/Select.native.cjs +0 -1
- package/dist/cjs/Select.native.js +0 -1
- package/dist/cjs/Select.native.js.map +1 -1
- package/dist/cjs/SelectContent.cjs +0 -1
- package/dist/cjs/SelectContent.native.cjs +0 -1
- package/dist/cjs/SelectContent.native.js +0 -1
- package/dist/cjs/SelectContent.native.js.map +1 -1
- package/dist/cjs/SelectImpl.cjs +0 -1
- package/dist/cjs/SelectImpl.native.cjs +0 -1
- package/dist/cjs/SelectImpl.native.js +0 -1
- package/dist/cjs/SelectImpl.native.js.map +1 -1
- package/dist/cjs/SelectItem.cjs +0 -1
- package/dist/cjs/SelectItem.native.cjs +0 -1
- package/dist/cjs/SelectItem.native.js +0 -1
- package/dist/cjs/SelectItem.native.js.map +1 -1
- package/dist/cjs/SelectItemText.cjs +0 -1
- package/dist/cjs/SelectItemText.native.cjs +0 -1
- package/dist/cjs/SelectItemText.native.js +0 -1
- package/dist/cjs/SelectItemText.native.js.map +1 -1
- package/dist/cjs/SelectScrollButton.cjs +0 -1
- package/dist/cjs/SelectScrollButton.native.cjs +0 -1
- package/dist/cjs/SelectScrollButton.native.js +0 -1
- package/dist/cjs/SelectScrollButton.native.js.map +1 -1
- package/dist/cjs/SelectTrigger.cjs +0 -1
- package/dist/cjs/SelectTrigger.native.cjs +0 -1
- package/dist/cjs/SelectTrigger.native.js +0 -1
- package/dist/cjs/SelectTrigger.native.js.map +1 -1
- package/dist/cjs/SelectViewport.cjs +0 -1
- package/dist/cjs/SelectViewport.native.cjs +0 -1
- package/dist/cjs/SelectViewport.native.js +0 -1
- package/dist/cjs/SelectViewport.native.js.map +1 -1
- package/dist/cjs/constants.cjs +0 -1
- package/dist/cjs/constants.native.cjs +0 -1
- package/dist/cjs/constants.native.js +0 -1
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/context.cjs +0 -1
- package/dist/cjs/context.native.cjs +0 -1
- package/dist/cjs/context.native.js +0 -1
- package/dist/cjs/context.native.js.map +1 -1
- package/dist/cjs/index.cjs +0 -1
- package/dist/cjs/index.native.cjs +0 -1
- package/dist/cjs/index.native.js +0 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/selectionController.cjs +0 -1
- package/dist/cjs/selectionController.native.cjs +0 -1
- package/dist/cjs/selectionController.native.js +0 -1
- package/dist/cjs/selectionController.native.js.map +1 -1
- package/dist/cjs/types.cjs +0 -1
- package/dist/cjs/types.native.cjs +0 -1
- package/dist/cjs/types.native.js +0 -1
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/Select.mjs.map +1 -1
- package/dist/esm/Select.native.js.map +1 -1
- package/dist/esm/SelectImpl.mjs.map +1 -1
- package/dist/esm/SelectItem.mjs.map +1 -1
- package/dist/esm/SelectItem.native.js.map +1 -1
- package/dist/esm/SelectViewport.mjs.map +1 -1
- package/dist/esm/context.mjs.map +1 -1
- package/dist/esm/context.native.js.map +1 -1
- package/dist/esm/selectionController.mjs.map +1 -1
- package/dist/esm/selectionController.native.js.map +1 -1
- package/dist/jsx/Select.mjs.map +1 -1
- package/dist/jsx/Select.native.cjs +0 -1
- package/dist/jsx/Select.native.js +0 -1
- package/dist/jsx/Select.native.js.map +1 -1
- package/dist/jsx/SelectContent.native.cjs +0 -1
- package/dist/jsx/SelectContent.native.js +0 -1
- package/dist/jsx/SelectContent.native.js.map +1 -1
- package/dist/jsx/SelectImpl.mjs.map +1 -1
- package/dist/jsx/SelectImpl.native.cjs +0 -1
- package/dist/jsx/SelectImpl.native.js +0 -1
- package/dist/jsx/SelectImpl.native.js.map +1 -1
- package/dist/jsx/SelectItem.mjs.map +1 -1
- package/dist/jsx/SelectItem.native.cjs +0 -1
- package/dist/jsx/SelectItem.native.js +0 -1
- package/dist/jsx/SelectItem.native.js.map +1 -1
- package/dist/jsx/SelectItemText.native.cjs +0 -1
- package/dist/jsx/SelectItemText.native.js +0 -1
- package/dist/jsx/SelectItemText.native.js.map +1 -1
- package/dist/jsx/SelectScrollButton.native.cjs +0 -1
- package/dist/jsx/SelectScrollButton.native.js +0 -1
- package/dist/jsx/SelectScrollButton.native.js.map +1 -1
- package/dist/jsx/SelectTrigger.native.cjs +0 -1
- package/dist/jsx/SelectTrigger.native.js +0 -1
- package/dist/jsx/SelectTrigger.native.js.map +1 -1
- package/dist/jsx/SelectViewport.mjs.map +1 -1
- package/dist/jsx/SelectViewport.native.cjs +0 -1
- package/dist/jsx/SelectViewport.native.js +0 -1
- package/dist/jsx/SelectViewport.native.js.map +1 -1
- package/dist/jsx/constants.native.cjs +0 -1
- package/dist/jsx/constants.native.js +0 -1
- package/dist/jsx/constants.native.js.map +1 -1
- package/dist/jsx/context.mjs.map +1 -1
- package/dist/jsx/context.native.cjs +0 -1
- package/dist/jsx/context.native.js +0 -1
- package/dist/jsx/context.native.js.map +1 -1
- package/dist/jsx/index.native.cjs +0 -1
- package/dist/jsx/index.native.js +0 -1
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/selectionController.mjs.map +1 -1
- package/dist/jsx/selectionController.native.cjs +0 -1
- package/dist/jsx/selectionController.native.js +0 -1
- package/dist/jsx/selectionController.native.js.map +1 -1
- package/dist/jsx/types.native.cjs +0 -1
- package/dist/jsx/types.native.js +0 -1
- package/dist/jsx/types.native.js.map +1 -1
- package/package.json +29 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectImpl.js","names":[],"sources":["esm/SelectImpl.js"],"sourcesContent":["import { autoUpdate, inner, offset, size, useClick, useFloatingRaw, useInnerOffset, useInteractions, useListNavigation, useRole, useTypeahead } from \"@tamagui/floating\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createChangeEventDetails, useEvent, useIsTouchDevice } from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { SCROLL_ARROW_THRESHOLD } from \"./constants\";\nimport { SelectItemParentProvider, SelectProvider, useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { jsx } from \"react/jsx-runtime\";\n\nconst SelectInlineImpl = (props) => {\n\tconst { scope, children, open = false, listContentRef } = props;\n\tconst selectContext = useSelectContext(scope);\n\tconst selectItemParentContext = useSelectItemParentContext(scope);\n\tconst { setActiveIndex, selectedIndex, activeIndexRef } = selectContext;\n\tconst { requestOpenChange, registry } = selectItemParentContext;\n\tconst [scrollTop, setScrollTop] = React.useState(0);\n\tconst touch = useIsTouchDevice();\n\tconst listItemsRef = selectItemParentContext.listRef;\n\tconst overflowRef = React.useRef(null);\n\tconst upArrowRef = React.useRef(null);\n\tconst downArrowRef = React.useRef(null);\n\tconst allowSelectRef = React.useRef(false);\n\tconst allowMouseUpRef = React.useRef(true);\n\tconst selectTimeoutRef = React.useRef(null);\n\tconst latestKeyboardEventRef = React.useRef(void 0);\n\tconst state = React.useRef({\n\t\tisMouseOutside: false,\n\t\tisTyping: false\n\t});\n\tconst [controlledScrolling, setControlledScrolling] = React.useState(false);\n\tconst [fallback, setFallback] = React.useState(false);\n\tconst [innerOffset, setInnerOffset] = React.useState(0);\n\tconst [blockSelection, setBlockSelection] = React.useState(false);\n\tconst floatingStyle = React.useRef({});\n\tReact.useEffect(() => {\n\t\tif (!open) {\n\t\t\tsetScrollTop(0);\n\t\t\tsetFallback(false);\n\t\t\tsetControlledScrolling(false);\n\t\t}\n\t}, [open]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!open) return;\n\t\tconst mouseUp = (e) => {\n\t\t\tif (state.current.isMouseOutside) requestOpenChange(false, createChangeEventDetails(\"outside-press\", e));\n\t\t};\n\t\tdocument.addEventListener(\"mouseup\", mouseUp);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(\"mouseup\", mouseUp);\n\t\t};\n\t}, [open]);\n\tconst { x, y, strategy, refs, update, placement: computedPlacement } = useFloatingRaw({\n\t\topen,\n\t\tplacement: \"bottom-start\",\n\t\twhileElementsMounted: autoUpdate,\n\t\tmiddleware: [\n\t\t\tsize({ apply({ rects: { reference: { width } } }) {\n\t\t\t\tObject.assign(floatingStyle.current, { minWidth: width + 8 });\n\t\t\t\tif (refs.floating.current) Object.assign(refs.floating.current.style, floatingStyle.current);\n\t\t\t} }),\n\t\t\tinner({\n\t\t\t\tlistRef: listItemsRef,\n\t\t\t\toverflowRef,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\toffset: innerOffset,\n\t\t\t\tonFallbackChange: setFallback,\n\t\t\t\tpadding: 10,\n\t\t\t\tminItemsVisible: touch ? 10 : 4,\n\t\t\t\treferenceOverflowThreshold: 20\n\t\t\t}),\n\t\t\toffset({ crossAxis: -5 })\n\t\t]\n\t});\n\tconst floatingRef = refs.floating;\n\tconst showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD;\n\tconst showDownArrow = open && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;\n\tconst isScrollable = showDownArrow || showUpArrow;\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\t\twindow.addEventListener(\"resize\", update);\n\t\tif (open) update();\n\t\treturn () => window.removeEventListener(\"resize\", update);\n\t}, [update, open]);\n\tconst onMatch = useEvent((index) => {\n\t\tif (!open) return;\n\t\tsetActiveIndex(index, {\n\t\t\treason: \"keyboard\",\n\t\t\tevent: latestKeyboardEventRef.current,\n\t\t\ttrigger: void 0,\n\t\t\tindex\n\t\t});\n\t});\n\tconst dataRef = React.useRef({});\n\tdataRef.current.placement = computedPlacement;\n\tconst interactionContext = {\n\t\topen,\n\t\tonOpenChange: (nextOpen, event, reason) => {\n\t\t\trequestOpenChange(nextOpen, createChangeEventDetails(reason === \"list-navigation\" ? \"keyboard\" : \"trigger-press\", event, refs.reference.current));\n\t\t},\n\t\trefs: {\n\t\t\treference: refs.reference,\n\t\t\tfloating: refs.floating,\n\t\t\tdomReference: refs.reference\n\t\t},\n\t\telements: {\n\t\t\treference: refs.reference?.current || null,\n\t\t\tfloating: refs.floating?.current || null,\n\t\t\tdomReference: refs.reference?.current || null\n\t\t},\n\t\tdataRef\n\t};\n\tconst interactionsProps = [\n\t\tuseClick(interactionContext, {\n\t\t\tevent: \"mousedown\",\n\t\t\tkeyboardHandlers: false\n\t\t}),\n\t\tuseRole(interactionContext, { role: \"listbox\" }),\n\t\tuseInnerOffset(interactionContext, {\n\t\t\tenabled: !fallback && isScrollable,\n\t\t\tonChange: setInnerOffset,\n\t\t\toverflowRef,\n\t\t\tscrollRef: refs.floating\n\t\t}),\n\t\tuseListNavigation(interactionContext, {\n\t\t\tlistRef: listItemsRef,\n\t\t\tactiveIndex: selectContext.activeIndex ?? 0,\n\t\t\tselectedIndex,\n\t\t\tonNavigate: (index) => {\n\t\t\t\tif (index !== null) setActiveIndex(index, {\n\t\t\t\t\treason: \"list-navigation\",\n\t\t\t\t\tevent: latestKeyboardEventRef.current,\n\t\t\t\t\ttrigger: void 0,\n\t\t\t\t\tindex\n\t\t\t\t});\n\t\t\t},\n\t\t\tdisabledIndices: registry.getDisabledIndices(),\n\t\t\tscrollItemIntoView: false\n\t\t}),\n\t\tuseTypeahead(interactionContext, {\n\t\t\tlistRef: listContentRef,\n\t\t\tonMatch,\n\t\t\tselectedIndex,\n\t\t\tactiveIndex: selectContext.activeIndex,\n\t\t\tonTypingChange: (e) => {\n\t\t\t\tstate.current.isTyping = e;\n\t\t\t}\n\t\t})\n\t];\n\tconst interactions = useInteractions(React.useMemo(() => {\n\t\treturn interactionsProps;\n\t}, interactionsProps));\n\tconst interactionsContext = React.useMemo(() => {\n\t\treturn {\n\t\t\t...interactions,\n\t\t\tgetReferenceProps(props2 = {}) {\n\t\t\t\treturn interactions.getReferenceProps({\n\t\t\t\t\t...props2,\n\t\t\t\t\tonKeyDown: composeEventHandlers(props2.onKeyDown, (event) => {\n\t\t\t\t\t\tlatestKeyboardEventRef.current = event.nativeEvent || event;\n\t\t\t\t\t\tif (event.key === \"Enter\" || event.code === \"Space\" || event.key === \" \" && !state.current.isTyping) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\trequestOpenChange(true, createChangeEventDetails(\"keyboard\", event.nativeEvent || event, refs.reference.current));\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetFloatingProps(props2) {\n\t\t\t\treturn interactions.getFloatingProps({\n\t\t\t\t\tref: refs.floating,\n\t\t\t\t\tclassName: \"Select\",\n\t\t\t\t\t...props2,\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\tposition: strategy,\n\t\t\t\t\t\ttop: y ?? \"\",\n\t\t\t\t\t\tleft: x ?? \"\",\n\t\t\t\t\t\toutline: 0,\n\t\t\t\t\t\tscrollbarWidth: \"none\",\n\t\t\t\t\t\t...floatingStyle.current,\n\t\t\t\t\t\t...props2?.style\n\t\t\t\t\t},\n\t\t\t\t\tonPointerEnter() {\n\t\t\t\t\t\tsetControlledScrolling(false);\n\t\t\t\t\t\tstate.current.isMouseOutside = false;\n\t\t\t\t\t},\n\t\t\t\t\tonPointerLeave() {\n\t\t\t\t\t\tstate.current.isMouseOutside = true;\n\t\t\t\t\t},\n\t\t\t\t\tonPointerMove() {\n\t\t\t\t\t\tstate.current.isMouseOutside = false;\n\t\t\t\t\t\tsetControlledScrolling(false);\n\t\t\t\t\t},\n\t\t\t\t\tonKeyDown(event) {\n\t\t\t\t\t\tlatestKeyboardEventRef.current = event.nativeEvent || event;\n\t\t\t\t\t\tsetControlledScrolling(true);\n\t\t\t\t\t},\n\t\t\t\t\tonContextMenu(e) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t},\n\t\t\t\t\tonScroll(event) {\n\t\t\t\t\t\tflushSync(() => {\n\t\t\t\t\t\t\tsetScrollTop(event.currentTarget.scrollTop);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t}, [\n\t\trefs.reference.current,\n\t\tx,\n\t\ty,\n\t\trefs.floating.current,\n\t\tinteractions\n\t]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (open) {\n\t\t\tallowMouseUpRef.current = false;\n\t\t\tselectTimeoutRef.current = setTimeout(() => {\n\t\t\t\tallowSelectRef.current = true;\n\t\t\t\tallowMouseUpRef.current = true;\n\t\t\t}, 300);\n\t\t\treturn () => {\n\t\t\t\tclearTimeout(selectTimeoutRef.current);\n\t\t\t};\n\t\t}\n\t\tallowSelectRef.current = false;\n\t\tallowMouseUpRef.current = true;\n\t\tsetInnerOffset(0);\n\t\tsetFallback(false);\n\t\tsetBlockSelection(false);\n\t}, [open]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!open && state.current.isMouseOutside) state.current.isMouseOutside = false;\n\t}, [open]);\n\tReact.useEffect(() => {\n\t\tif (!open) return;\n\t\tconst scrollActiveIntoView = (index) => {\n\t\t\tif (controlledScrolling && index != null) listItemsRef.current[index]?.scrollIntoView({ block: \"nearest\" });\n\t\t\tsetScrollTop(refs.floating.current?.scrollTop ?? 0);\n\t\t};\n\t\tscrollActiveIntoView(activeIndexRef.current);\n\t\treturn selectItemParentContext.activeIndexSubscribe(scrollActiveIntoView);\n\t}, [\n\t\topen,\n\t\trefs,\n\t\tcontrolledScrolling,\n\t\tselectItemParentContext.activeIndexSubscribe\n\t]);\n\tReact.useEffect(() => {\n\t\tif (open && fallback) {\n\t\t\tif (selectedIndex != null) listItemsRef.current[selectedIndex]?.scrollIntoView({ block: \"nearest\" });\n\t\t}\n\t}, [\n\t\topen,\n\t\tfallback,\n\t\tselectedIndex\n\t]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (refs.floating.current && fallback) refs.floating.current.style.maxHeight = \"\";\n\t}, [refs, fallback]);\n\tconst floatingContext = React.useMemo(() => ({\n\t\trefs,\n\t\tdataRef\n\t}), [refs]);\n\treturn /* @__PURE__ */ jsx(SelectProvider, {\n\t\tscope,\n\t\t...selectContext,\n\t\tsetScrollTop,\n\t\tsetInnerOffset,\n\t\tfallback,\n\t\tfloatingContext,\n\t\tcanScrollDown: !!showDownArrow,\n\t\tcanScrollUp: !!showUpArrow,\n\t\tcontrolledScrolling,\n\t\tblockSelection,\n\t\tupArrowRef,\n\t\tdownArrowRef,\n\t\tupdate,\n\t\tchildren: /* @__PURE__ */ jsx(SelectItemParentProvider, {\n\t\t\tscope,\n\t\t\t...selectItemParentContext,\n\t\t\tallowMouseUpRef,\n\t\t\tallowSelectRef,\n\t\t\tdataRef,\n\t\t\tinteractions: interactionsContext,\n\t\t\tlistRef: listItemsRef,\n\t\t\tselectTimeoutRef,\n\t\t\tchildren\n\t\t})\n\t});\n};\n\nexport { SelectInlineImpl };"],"mappings":";;;;;;;;;;;AAUA,MAAM,oBAAoB,UAAU;CACnC,MAAM,EAAE,OAAO,UAAU,OAAO,OAAO,mBAAmB;CAC1D,MAAM,gBAAgB,iBAAiB,KAAK;CAC5C,MAAM,0BAA0B,2BAA2B,KAAK;CAChE,MAAM,EAAE,gBAAgB,eAAe,mBAAmB;CAC1D,MAAM,EAAE,mBAAmB,aAAa;CACxC,MAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,CAAC;CAClD,MAAM,QAAQ,iBAAiB;CAC/B,MAAM,eAAe,wBAAwB;CAC7C,MAAM,cAAc,MAAM,OAAO,IAAI;CACrC,MAAM,aAAa,MAAM,OAAO,IAAI;CACpC,MAAM,eAAe,MAAM,OAAO,IAAI;CACtC,MAAM,iBAAiB,MAAM,OAAO,KAAK;CACzC,MAAM,kBAAkB,MAAM,OAAO,IAAI;CACzC,MAAM,mBAAmB,MAAM,OAAO,IAAI;CAC1C,MAAM,yBAAyB,MAAM,OAAO,KAAK,CAAC;CAClD,MAAM,QAAQ,MAAM,OAAO;EAC1B,gBAAgB;EAChB,UAAU;CACX,CAAC;CACD,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BAAI,gBAAgB;EAC1C;EACA,GAAG;EACH;EACA;EACA;EACA;EACA,eAAe,CAAC,CAAC;EACjB,aAAa,CAAC,CAAC;EACf;EACA;EACA;EACA;EACA;EACA,UAA0B,oBAAI,0BAA0B;GACvD;GACA,GAAG;GACH;GACA;GACA;GACA,cAAc;GACd,SAAS;GACT;GACA;EACD,CAAC;CACF,CAAC;AACF"}
|
|
1
|
+
{"version":3,"file":"SelectImpl.js","names":[],"sources":["esm/SelectImpl.js"],"sourcesContent":["import { autoUpdate, inner, offset, size, useClick, useFloatingRaw, useInnerOffset, useInteractions, useListNavigation, useRole, useTypeahead } from \"@tamagui/floating\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createChangeEventDetails, useEvent, useIsTouchDevice } from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { SCROLL_ARROW_THRESHOLD } from \"./constants\";\nimport { SelectItemParentProvider, SelectProvider, useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { jsx } from \"react/jsx-runtime\";\n\nconst SelectInlineImpl = (props) => {\n\tconst { scope, children, open = false, listContentRef } = props;\n\tconst selectContext = useSelectContext(scope);\n\tconst selectItemParentContext = useSelectItemParentContext(scope);\n\tconst { setActiveIndex, selectedIndex, activeIndexRef } = selectContext;\n\tconst { requestOpenChange, registry } = selectItemParentContext;\n\tconst [scrollTop, setScrollTop] = React.useState(0);\n\tconst touch = useIsTouchDevice();\n\tconst listItemsRef = selectItemParentContext.listRef;\n\tconst overflowRef = React.useRef(null);\n\tconst upArrowRef = React.useRef(null);\n\tconst downArrowRef = React.useRef(null);\n\tconst allowSelectRef = React.useRef(false);\n\tconst allowMouseUpRef = React.useRef(true);\n\tconst selectTimeoutRef = React.useRef(null);\n\tconst latestKeyboardEventRef = React.useRef(void 0);\n\tconst state = React.useRef({\n\t\tisMouseOutside: false,\n\t\tisTyping: false\n\t});\n\tconst [controlledScrolling, setControlledScrolling] = React.useState(false);\n\tconst [fallback, setFallback] = React.useState(false);\n\tconst [innerOffset, setInnerOffset] = React.useState(0);\n\tconst [blockSelection, setBlockSelection] = React.useState(false);\n\tconst floatingStyle = React.useRef({});\n\tReact.useEffect(() => {\n\t\tif (!open) {\n\t\t\tsetScrollTop(0);\n\t\t\tsetFallback(false);\n\t\t\tsetControlledScrolling(false);\n\t\t}\n\t}, [open]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!open) return;\n\t\tconst mouseUp = (e) => {\n\t\t\tif (state.current.isMouseOutside) requestOpenChange(false, createChangeEventDetails(\"outside-press\", e));\n\t\t};\n\t\tdocument.addEventListener(\"mouseup\", mouseUp);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(\"mouseup\", mouseUp);\n\t\t};\n\t}, [open]);\n\tconst { x, y, strategy, refs, update, placement: computedPlacement } = useFloatingRaw({\n\t\topen,\n\t\tplacement: \"bottom-start\",\n\t\twhileElementsMounted: autoUpdate,\n\t\tmiddleware: [\n\t\t\tsize({ apply({ rects: { reference: { width } } }) {\n\t\t\t\tObject.assign(floatingStyle.current, { minWidth: width + 8 });\n\t\t\t\tif (refs.floating.current) Object.assign(refs.floating.current.style, floatingStyle.current);\n\t\t\t} }),\n\t\t\tinner({\n\t\t\t\tlistRef: listItemsRef,\n\t\t\t\toverflowRef,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\toffset: innerOffset,\n\t\t\t\tonFallbackChange: setFallback,\n\t\t\t\tpadding: 10,\n\t\t\t\tminItemsVisible: touch ? 10 : 4,\n\t\t\t\treferenceOverflowThreshold: 20\n\t\t\t}),\n\t\t\toffset({ crossAxis: -5 })\n\t\t]\n\t});\n\tconst floatingRef = refs.floating;\n\tconst showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD;\n\tconst showDownArrow = open && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;\n\tconst isScrollable = showDownArrow || showUpArrow;\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\t\twindow.addEventListener(\"resize\", update);\n\t\tif (open) update();\n\t\treturn () => window.removeEventListener(\"resize\", update);\n\t}, [update, open]);\n\tconst onMatch = useEvent((index) => {\n\t\tif (!open) return;\n\t\tsetActiveIndex(index, {\n\t\t\treason: \"keyboard\",\n\t\t\tevent: latestKeyboardEventRef.current,\n\t\t\ttrigger: void 0,\n\t\t\tindex\n\t\t});\n\t});\n\tconst dataRef = React.useRef({});\n\tdataRef.current.placement = computedPlacement;\n\tconst interactionContext = {\n\t\topen,\n\t\tonOpenChange: (nextOpen, event, reason) => {\n\t\t\trequestOpenChange(nextOpen, createChangeEventDetails(reason === \"list-navigation\" ? \"keyboard\" : \"trigger-press\", event, refs.reference.current));\n\t\t},\n\t\trefs: {\n\t\t\treference: refs.reference,\n\t\t\tfloating: refs.floating,\n\t\t\tdomReference: refs.reference\n\t\t},\n\t\telements: {\n\t\t\treference: refs.reference?.current || null,\n\t\t\tfloating: refs.floating?.current || null,\n\t\t\tdomReference: refs.reference?.current || null\n\t\t},\n\t\tdataRef\n\t};\n\tconst interactionsProps = [\n\t\tuseClick(interactionContext, {\n\t\t\tevent: \"mousedown\",\n\t\t\tkeyboardHandlers: false\n\t\t}),\n\t\tuseRole(interactionContext, { role: \"listbox\" }),\n\t\tuseInnerOffset(interactionContext, {\n\t\t\tenabled: !fallback && isScrollable,\n\t\t\tonChange: setInnerOffset,\n\t\t\toverflowRef,\n\t\t\tscrollRef: refs.floating\n\t\t}),\n\t\tuseListNavigation(interactionContext, {\n\t\t\tlistRef: listItemsRef,\n\t\t\tactiveIndex: selectContext.activeIndex ?? 0,\n\t\t\tselectedIndex,\n\t\t\tonNavigate: (index) => {\n\t\t\t\tif (index !== null) setActiveIndex(index, {\n\t\t\t\t\treason: \"list-navigation\",\n\t\t\t\t\tevent: latestKeyboardEventRef.current,\n\t\t\t\t\ttrigger: void 0,\n\t\t\t\t\tindex\n\t\t\t\t});\n\t\t\t},\n\t\t\tdisabledIndices: registry.getDisabledIndices(),\n\t\t\tscrollItemIntoView: false\n\t\t}),\n\t\tuseTypeahead(interactionContext, {\n\t\t\tlistRef: listContentRef,\n\t\t\tonMatch,\n\t\t\tselectedIndex,\n\t\t\tactiveIndex: selectContext.activeIndex,\n\t\t\tonTypingChange: (e) => {\n\t\t\t\tstate.current.isTyping = e;\n\t\t\t}\n\t\t})\n\t];\n\tconst interactions = useInteractions(React.useMemo(() => {\n\t\treturn interactionsProps;\n\t}, interactionsProps));\n\tconst interactionsContext = React.useMemo(() => {\n\t\treturn {\n\t\t\t...interactions,\n\t\t\tgetReferenceProps(props2 = {}) {\n\t\t\t\treturn interactions.getReferenceProps({\n\t\t\t\t\t...props2,\n\t\t\t\t\tonKeyDown: composeEventHandlers(props2.onKeyDown, (event) => {\n\t\t\t\t\t\tlatestKeyboardEventRef.current = event.nativeEvent || event;\n\t\t\t\t\t\tif (event.key === \"Enter\" || event.code === \"Space\" || event.key === \" \" && !state.current.isTyping) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\trequestOpenChange(true, createChangeEventDetails(\"keyboard\", event.nativeEvent || event, refs.reference.current));\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetFloatingProps(props2) {\n\t\t\t\treturn interactions.getFloatingProps({\n\t\t\t\t\tref: refs.floating,\n\t\t\t\t\tclassName: \"Select\",\n\t\t\t\t\t...props2,\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\tposition: strategy,\n\t\t\t\t\t\ttop: y ?? \"\",\n\t\t\t\t\t\tleft: x ?? \"\",\n\t\t\t\t\t\toutline: 0,\n\t\t\t\t\t\tscrollbarWidth: \"none\",\n\t\t\t\t\t\t...floatingStyle.current,\n\t\t\t\t\t\t...props2?.style\n\t\t\t\t\t},\n\t\t\t\t\tonPointerEnter() {\n\t\t\t\t\t\tsetControlledScrolling(false);\n\t\t\t\t\t\tstate.current.isMouseOutside = false;\n\t\t\t\t\t},\n\t\t\t\t\tonPointerLeave() {\n\t\t\t\t\t\tstate.current.isMouseOutside = true;\n\t\t\t\t\t},\n\t\t\t\t\tonPointerMove() {\n\t\t\t\t\t\tstate.current.isMouseOutside = false;\n\t\t\t\t\t\tsetControlledScrolling(false);\n\t\t\t\t\t},\n\t\t\t\t\tonKeyDown(event) {\n\t\t\t\t\t\tlatestKeyboardEventRef.current = event.nativeEvent || event;\n\t\t\t\t\t\tsetControlledScrolling(true);\n\t\t\t\t\t},\n\t\t\t\t\tonContextMenu(e) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t},\n\t\t\t\t\tonScroll(event) {\n\t\t\t\t\t\tflushSync(() => {\n\t\t\t\t\t\t\tsetScrollTop(event.currentTarget.scrollTop);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t}, [\n\t\trefs.reference.current,\n\t\tx,\n\t\ty,\n\t\trefs.floating.current,\n\t\tinteractions\n\t]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (open) {\n\t\t\tallowMouseUpRef.current = false;\n\t\t\tselectTimeoutRef.current = setTimeout(() => {\n\t\t\t\tallowSelectRef.current = true;\n\t\t\t\tallowMouseUpRef.current = true;\n\t\t\t}, 300);\n\t\t\treturn () => {\n\t\t\t\tclearTimeout(selectTimeoutRef.current);\n\t\t\t};\n\t\t}\n\t\tallowSelectRef.current = false;\n\t\tallowMouseUpRef.current = true;\n\t\tsetInnerOffset(0);\n\t\tsetFallback(false);\n\t\tsetBlockSelection(false);\n\t}, [open]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!open && state.current.isMouseOutside) state.current.isMouseOutside = false;\n\t}, [open]);\n\tReact.useEffect(() => {\n\t\tif (!open) return;\n\t\tconst scrollActiveIntoView = (index) => {\n\t\t\tif (controlledScrolling && index != null) listItemsRef.current[index]?.scrollIntoView({ block: \"nearest\" });\n\t\t\tsetScrollTop(refs.floating.current?.scrollTop ?? 0);\n\t\t};\n\t\tscrollActiveIntoView(activeIndexRef.current);\n\t\treturn selectItemParentContext.activeIndexSubscribe(scrollActiveIntoView);\n\t}, [\n\t\topen,\n\t\trefs,\n\t\tcontrolledScrolling,\n\t\tselectItemParentContext.activeIndexSubscribe\n\t]);\n\tReact.useEffect(() => {\n\t\tif (open && fallback) {\n\t\t\tif (selectedIndex != null) listItemsRef.current[selectedIndex]?.scrollIntoView({ block: \"nearest\" });\n\t\t}\n\t}, [\n\t\topen,\n\t\tfallback,\n\t\tselectedIndex\n\t]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (refs.floating.current && fallback) refs.floating.current.style.maxHeight = \"\";\n\t}, [refs, fallback]);\n\tconst floatingContext = React.useMemo(() => ({\n\t\trefs,\n\t\tdataRef\n\t}), [refs]);\n\treturn /* @__PURE__ */ jsx(SelectProvider, {\n\t\tscope,\n\t\t...selectContext,\n\t\tsetScrollTop,\n\t\tsetInnerOffset,\n\t\tfallback,\n\t\tfloatingContext,\n\t\tcanScrollDown: !!showDownArrow,\n\t\tcanScrollUp: !!showUpArrow,\n\t\tcontrolledScrolling,\n\t\tblockSelection,\n\t\tupArrowRef,\n\t\tdownArrowRef,\n\t\tupdate,\n\t\tchildren: /* @__PURE__ */ jsx(SelectItemParentProvider, {\n\t\t\tscope,\n\t\t\t...selectItemParentContext,\n\t\t\tallowMouseUpRef,\n\t\t\tallowSelectRef,\n\t\t\tdataRef,\n\t\t\tinteractions: interactionsContext,\n\t\t\tlistRef: listItemsRef,\n\t\t\tselectTimeoutRef,\n\t\t\tchildren\n\t\t})\n\t});\n};\n\nexport { SelectInlineImpl };"],"mappings":";;;;;;;;;;;AAUA,MAAM,oBAAoB,UAAU;CACnC,MAAM,EAAE,OAAO,UAAU,OAAO,OAAO,mBAAmB;CAC1D,MAAM,gBAAgB,iBAAiB,KAAK;CAC5C,MAAM,0BAA0B,2BAA2B,KAAK;C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,aAAa,KAAK,SAAS,SAAS,aAAa,CAAC;EACnD;EACA,qBAAqB,eAAe,OAAO;EAC3C,OAAO,wBAAwB,qBAAqB,oBAAoB;CACzE,GAAG;EACF;EACA;EACA;EACA,wBAAwB;CACzB,CAAC;CACD,MAAM,gBAAgB;EACrB,IAAI,QAAQ,UAAU;GACrB,IAAI,iBAAiB,MAAM,aAAa,QAAQ,cAAc,EAAE,eAAe,EAAE,OAAO,UAAU,CAAC;EACpG;CACD,GAAG;EACF;EACA;EACA;CACD,CAAC;CACD,gCAAgC;EAC/B,IAAI,KAAK,SAAS,WAAW,UAAU,KAAK,SAAS,QAAQ,MAAM,YAAY;CAChF,GAAG,CAAC,MAAM,QAAQ,CAAC;CACnB,MAAM,kBAAkB,MAAM,eAAe;EAC5C;EACA;CACD,IAAI,CAAC,IAAI,CAAC;CACV,OAAuB,oBAAI,gBAAgB;EAC1C;EACA,GAAG;EACH;EACA;EACA;EACA;EACA,eAAe,CAAC,CAAC;EACjB,aAAa,CAAC,CAAC;EACf;EACA;EACA;EACA;EACA;EACA,UAA0B,oBAAI,0BAA0B;GACvD;GACA,GAAG;GACH;GACA;GACA;GACA,cAAc;GACd,SAAS;GACT;GACA;EACD,CAAC;CACF,CAAC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectItem.js","names":[],"sources":["esm/SelectItem.js"],"sourcesContent":["import { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { useAdaptIsActive } from \"@tamagui/adapt\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport {\n createChangeEventDetails,\n createStyledHOC,\n createStyledContext,\n styled,\n View\n} from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { getSelectOptionProps } from \"./selectionController\";\nimport { jsx } from \"react/jsx-runtime\";\nconst ITEM_NAME = \"SelectItem\";\nconst {\n Provider: SelectItemContextProvider,\n useStyledContext: useSelectItemContext\n} = createStyledContext(null, ITEM_NAME);\nconst SelectItemFrame = styled(View, {\n displayName: ITEM_NAME,\n alignItems: \"center\",\n flexDirection: \"row\"\n});\nconst SelectItem = createStyledHOC(\n SelectItemFrame,\n function SelectItem2(props, forwardedRef) {\n const {\n scope,\n value,\n disabled: disabledProp,\n \"aria-disabled\": ariaDisabled,\n textValue: textValueProp,\n ...restProps\n } = props;\n const disabled = disabledProp ?? ariaDisabled === true;\n const context = useSelectItemParentContext(scope);\n const selectContext = useSelectContext(scope);\n const isAdapted = useAdaptIsActive(selectContext.adaptScope);\n const {\n listRef,\n registry,\n mode,\n selectedValues,\n selectValue,\n activeIndexSubscribe,\n activeIndexRef,\n allowMouseUpRef,\n allowSelectRef,\n selectTimeoutRef,\n interactions,\n shouldRenderWebNative,\n setActiveIndexFast,\n moveActive,\n search\n } = context;\n const isSelected = selectedValues.includes(value);\n const pendingMouseUpSelectionRef = React.useRef(false);\n const itemNodeRef = React.useRef(null);\n const [, rerenderRegistry] = React.useReducer((version) => version + 1, 0);\n const registrationRef = React.useRef(\n null\n );\n const initialRegistration = React.useRef({\n value,\n disabled,\n textValue: textValueProp\n });\n useIsomorphicLayoutEffect(\n () => registry.subscribe(() => rerenderRegistry()),\n [registry]\n );\n useIsomorphicLayoutEffect(() => {\n const registration = registry.registerItem(initialRegistration.current);\n registrationRef.current = registration;\n const registeredNode = itemNodeRef.current;\n registration.setNode(registeredNode);\n const registeredIndex = registry.getItems().findIndex((item) => item.id === registration.id);\n if (isWeb && listRef && registeredIndex >= 0 && registeredNode instanceof HTMLElement) {\n listRef.current[registeredIndex] = registeredNode;\n }\n return () => {\n const currentIndex = registry.getItems().findIndex((item) => item.id === registration.id);\n if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {\n listRef.current[currentIndex] = null;\n }\n registrationRef.current = null;\n registration.unregister();\n };\n }, [registry]);\n useIsomorphicLayoutEffect(() => {\n registrationRef.current?.update({ value, disabled, textValue: textValueProp });\n }, [disabled, textValueProp, value]);\n useIsomorphicLayoutEffect(() => {\n registrationRef.current?.setNode(itemNodeRef.current);\n });\n const index = registry.getIndex(value);\n React.useEffect(() => {\n const handleActiveIndex = (i) => {\n if (index === i) {\n if (isWeb) {\n requestAnimationFrame(() => {\n listRef?.current[index]?.focus();\n });\n }\n }\n };\n const currentActiveIndex = activeIndexRef?.current;\n if (currentActiveIndex !== null && currentActiveIndex !== void 0) {\n handleActiveIndex(currentActiveIndex);\n }\n return activeIndexSubscribe(handleActiveIndex);\n }, [activeIndexRef, activeIndexSubscribe, index, listRef]);\n const textId = React.useId();\n const refCallback = React.useCallback(\n (node) => {\n itemNodeRef.current = node;\n registrationRef.current?.setNode(node);\n if (!isWeb) return;\n if (listRef && index >= 0) {\n listRef.current[index] = node instanceof HTMLElement ? node : null;\n }\n },\n [index, listRef]\n );\n const composedRefs = useComposedRefs(forwardedRef, refCallback);\n const handleSelect = React.useCallback(\n (event, reason = \"item-press\") => {\n if (disabled) return;\n const nativeEvent = event?.nativeEvent || event;\n selectValue(\n value,\n createChangeEventDetails(\n reason,\n nativeEvent,\n event?.currentTarget\n )\n );\n },\n [disabled, selectValue, value]\n );\n const handleKeyDown = React.useCallback(\n (event) => {\n if (disabled) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n handleSelect(event, \"keyboard\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n event.stopPropagation();\n moveActive(event.key === \"ArrowDown\" ? 1 : -1, event.nativeEvent || event);\n return;\n }\n if (!interactions && event.key?.length === 1 && !event.metaKey && !event.ctrlKey) {\n search(event.key, event.nativeEvent || event);\n }\n if (allowSelectRef) {\n allowSelectRef.current = true;\n }\n },\n [allowSelectRef, disabled, handleSelect, interactions, moveActive, search]\n );\n const selectItemProps = React.useMemo(() => {\n if (interactions) {\n const {\n onTouchMove,\n onTouchEnd,\n onKeyDown,\n onClick,\n onMouseUp,\n onMouseMove,\n onPress,\n ...itemProps\n } = restProps;\n const interactionProps = interactions.getItemProps({\n ...itemProps,\n onTouchMove() {\n allowSelectRef.current = true;\n allowMouseUpRef.current = false;\n },\n onTouchEnd() {\n allowSelectRef.current = false;\n allowMouseUpRef.current = true;\n },\n onMouseMove(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast?.(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n },\n onKeyDown: handleKeyDown,\n onClick(event) {\n if (disabled) return;\n const shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n if (shouldSelect) {\n handleSelect(event);\n }\n },\n onMouseUp(event) {\n if (disabled) return;\n if (!allowMouseUpRef.current) {\n allowMouseUpRef.current = true;\n allowSelectRef.current = true;\n return;\n }\n pendingMouseUpSelectionRef.current = allowSelectRef.current;\n clearTimeout(selectTimeoutRef.current);\n selectTimeoutRef.current = setTimeout(() => {\n allowSelectRef.current = true;\n if (pendingMouseUpSelectionRef.current) {\n pendingMouseUpSelectionRef.current = false;\n handleSelect(event);\n }\n });\n }\n });\n return {\n ...interactionProps,\n onTouchMove: composeEventHandlers(\n onTouchMove,\n interactionProps.onTouchMove\n ),\n onTouchEnd: composeEventHandlers(\n onTouchEnd,\n interactionProps.onTouchEnd\n ),\n onKeyDown: composeEventHandlers(onKeyDown, interactionProps.onKeyDown),\n onClick(event) {\n onClick?.(event);\n if (event.defaultPrevented) {\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n return;\n }\n interactionProps.onClick?.(event);\n },\n onMouseUp: composeEventHandlers(onMouseUp, interactionProps.onMouseUp),\n onMouseMove: composeEventHandlers(\n onMouseMove,\n interactionProps.onMouseMove\n ),\n onPress\n };\n }\n return {\n ...restProps,\n onKeyDown: composeEventHandlers(restProps.onKeyDown, handleKeyDown),\n onMouseMove: composeEventHandlers(restProps.onMouseMove, (event) => {\n if (disabled || index < 0) return;\n setActiveIndexFast?.(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n }),\n onPress: composeEventHandlers(restProps.onPress, handleSelect)\n };\n }, [\n allowMouseUpRef,\n allowSelectRef,\n disabled,\n handleKeyDown,\n handleSelect,\n index,\n interactions,\n restProps,\n selectTimeoutRef,\n setActiveIndexFast\n ]);\n const accessibilityProps = getSelectOptionProps(\n mode,\n isSelected,\n disabled,\n isWeb ? \"web\" : \"native\"\n );\n return /* @__PURE__ */ jsx(\n SelectItemContextProvider,\n {\n scope,\n value,\n textId: textId || \"\",\n textValue: textValueProp,\n isSelected,\n children: shouldRenderWebNative ? /* @__PURE__ */ jsx(\"option\", { value, disabled, children: props.children }) : /* @__PURE__ */ jsx(\n SelectItemFrame,\n {\n render: \"div\",\n ref: composedRefs,\n \"aria-labelledby\": textId,\n \"data-state\": isSelected ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : void 0,\n tabIndex: disabled ? void 0 : isWeb && isAdapted ? index === (selectContext.activeIndex ?? selectContext.selectedIndex) ? 0 : -1 : -1,\n zIndex: 100,\n ...selectItemProps,\n ...accessibilityProps\n }\n )\n }\n );\n },\n {\n disableTheme: true\n }\n);\nexport {\n SelectItem,\n SelectItemContextProvider,\n SelectItemFrame,\n useSelectItemContext\n};\n//# sourceMappingURL=SelectItem.js.map\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,YAAY;AAClB,MAAM,EACJ,UAAU,2BACV,kBAAkB,yBAChB,oBAAoB,MAAM,SAAS;AACvC,MAAM,kBAAkB,OAAO,MAAM;CACnC,aAAa;CACb,YAAY;CACZ,eAAe;AACjB,CAAC;AACD,MAAM,aAAa,gBACjB,iBACA,SAAS,YAAY,OAAO,cAAc;CACxC,MAAM,EACJ,OACA,OACA,UAAU,cACV,iBAAiB,cACjB,WAAW,eACX,GA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ChB,CACF"}
|
|
1
|
+
{"version":3,"file":"SelectItem.js","names":[],"sources":["esm/SelectItem.js"],"sourcesContent":["import { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { useAdaptIsActive } from \"@tamagui/adapt\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport {\n createChangeEventDetails,\n createStyledHOC,\n createStyledContext,\n styled,\n View\n} from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { getSelectOptionProps } from \"./selectionController\";\nimport { jsx } from \"react/jsx-runtime\";\nconst ITEM_NAME = \"SelectItem\";\nconst {\n Provider: SelectItemContextProvider,\n useStyledContext: useSelectItemContext\n} = createStyledContext(null, ITEM_NAME);\nconst SelectItemFrame = styled(View, {\n displayName: ITEM_NAME,\n alignItems: \"center\",\n flexDirection: \"row\"\n});\nconst SelectItem = createStyledHOC(\n SelectItemFrame,\n function SelectItem2(props, forwardedRef) {\n const {\n scope,\n value,\n disabled: disabledProp,\n \"aria-disabled\": ariaDisabled,\n textValue: textValueProp,\n ...restProps\n } = props;\n const disabled = disabledProp ?? ariaDisabled === true;\n const context = useSelectItemParentContext(scope);\n const selectContext = useSelectContext(scope);\n const isAdapted = useAdaptIsActive(selectContext.adaptScope);\n const {\n listRef,\n registry,\n mode,\n selectedValues,\n selectValue,\n activeIndexSubscribe,\n activeIndexRef,\n allowMouseUpRef,\n allowSelectRef,\n selectTimeoutRef,\n interactions,\n shouldRenderWebNative,\n setActiveIndexFast,\n moveActive,\n search\n } = context;\n const isSelected = selectedValues.includes(value);\n const pendingMouseUpSelectionRef = React.useRef(false);\n const itemNodeRef = React.useRef(null);\n const [, rerenderRegistry] = React.useReducer((version) => version + 1, 0);\n const registrationRef = React.useRef(\n null\n );\n const initialRegistration = React.useRef({\n value,\n disabled,\n textValue: textValueProp\n });\n useIsomorphicLayoutEffect(\n () => registry.subscribe(() => rerenderRegistry()),\n [registry]\n );\n useIsomorphicLayoutEffect(() => {\n const registration = registry.registerItem(initialRegistration.current);\n registrationRef.current = registration;\n const registeredNode = itemNodeRef.current;\n registration.setNode(registeredNode);\n const registeredIndex = registry.getItems().findIndex((item) => item.id === registration.id);\n if (isWeb && listRef && registeredIndex >= 0 && registeredNode instanceof HTMLElement) {\n listRef.current[registeredIndex] = registeredNode;\n }\n return () => {\n const currentIndex = registry.getItems().findIndex((item) => item.id === registration.id);\n if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {\n listRef.current[currentIndex] = null;\n }\n registrationRef.current = null;\n registration.unregister();\n };\n }, [registry]);\n useIsomorphicLayoutEffect(() => {\n registrationRef.current?.update({ value, disabled, textValue: textValueProp });\n }, [disabled, textValueProp, value]);\n useIsomorphicLayoutEffect(() => {\n registrationRef.current?.setNode(itemNodeRef.current);\n });\n const index = registry.getIndex(value);\n React.useEffect(() => {\n const handleActiveIndex = (i) => {\n if (index === i) {\n if (isWeb) {\n requestAnimationFrame(() => {\n listRef?.current[index]?.focus();\n });\n }\n }\n };\n const currentActiveIndex = activeIndexRef?.current;\n if (currentActiveIndex !== null && currentActiveIndex !== void 0) {\n handleActiveIndex(currentActiveIndex);\n }\n return activeIndexSubscribe(handleActiveIndex);\n }, [activeIndexRef, activeIndexSubscribe, index, listRef]);\n const textId = React.useId();\n const refCallback = React.useCallback(\n (node) => {\n itemNodeRef.current = node;\n registrationRef.current?.setNode(node);\n if (!isWeb) return;\n if (listRef && index >= 0) {\n listRef.current[index] = node instanceof HTMLElement ? node : null;\n }\n },\n [index, listRef]\n );\n const composedRefs = useComposedRefs(forwardedRef, refCallback);\n const handleSelect = React.useCallback(\n (event, reason = \"item-press\") => {\n if (disabled) return;\n const nativeEvent = event?.nativeEvent || event;\n selectValue(\n value,\n createChangeEventDetails(\n reason,\n nativeEvent,\n event?.currentTarget\n )\n );\n },\n [disabled, selectValue, value]\n );\n const handleKeyDown = React.useCallback(\n (event) => {\n if (disabled) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n handleSelect(event, \"keyboard\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n event.stopPropagation();\n moveActive(event.key === \"ArrowDown\" ? 1 : -1, event.nativeEvent || event);\n return;\n }\n if (!interactions && event.key?.length === 1 && !event.metaKey && !event.ctrlKey) {\n search(event.key, event.nativeEvent || event);\n }\n if (allowSelectRef) {\n allowSelectRef.current = true;\n }\n },\n [allowSelectRef, disabled, handleSelect, interactions, moveActive, search]\n );\n const selectItemProps = React.useMemo(() => {\n if (interactions) {\n const {\n onTouchMove,\n onTouchEnd,\n onKeyDown,\n onClick,\n onMouseUp,\n onMouseMove,\n onPress,\n ...itemProps\n } = restProps;\n const interactionProps = interactions.getItemProps({\n ...itemProps,\n onTouchMove() {\n allowSelectRef.current = true;\n allowMouseUpRef.current = false;\n },\n onTouchEnd() {\n allowSelectRef.current = false;\n allowMouseUpRef.current = true;\n },\n onMouseMove(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast?.(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n },\n onKeyDown: handleKeyDown,\n onClick(event) {\n if (disabled) return;\n const shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n if (shouldSelect) {\n handleSelect(event);\n }\n },\n onMouseUp(event) {\n if (disabled) return;\n if (!allowMouseUpRef.current) {\n allowMouseUpRef.current = true;\n allowSelectRef.current = true;\n return;\n }\n pendingMouseUpSelectionRef.current = allowSelectRef.current;\n clearTimeout(selectTimeoutRef.current);\n selectTimeoutRef.current = setTimeout(() => {\n allowSelectRef.current = true;\n if (pendingMouseUpSelectionRef.current) {\n pendingMouseUpSelectionRef.current = false;\n handleSelect(event);\n }\n });\n }\n });\n return {\n ...interactionProps,\n onTouchMove: composeEventHandlers(\n onTouchMove,\n interactionProps.onTouchMove\n ),\n onTouchEnd: composeEventHandlers(\n onTouchEnd,\n interactionProps.onTouchEnd\n ),\n onKeyDown: composeEventHandlers(onKeyDown, interactionProps.onKeyDown),\n onClick(event) {\n onClick?.(event);\n if (event.defaultPrevented) {\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n return;\n }\n interactionProps.onClick?.(event);\n },\n onMouseUp: composeEventHandlers(onMouseUp, interactionProps.onMouseUp),\n onMouseMove: composeEventHandlers(\n onMouseMove,\n interactionProps.onMouseMove\n ),\n onPress\n };\n }\n return {\n ...restProps,\n onKeyDown: composeEventHandlers(restProps.onKeyDown, handleKeyDown),\n onMouseMove: composeEventHandlers(restProps.onMouseMove, (event) => {\n if (disabled || index < 0) return;\n setActiveIndexFast?.(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n }),\n onPress: composeEventHandlers(restProps.onPress, handleSelect)\n };\n }, [\n allowMouseUpRef,\n allowSelectRef,\n disabled,\n handleKeyDown,\n handleSelect,\n index,\n interactions,\n restProps,\n selectTimeoutRef,\n setActiveIndexFast\n ]);\n const accessibilityProps = getSelectOptionProps(\n mode,\n isSelected,\n disabled,\n isWeb ? \"web\" : \"native\"\n );\n return /* @__PURE__ */ jsx(\n SelectItemContextProvider,\n {\n scope,\n value,\n textId: textId || \"\",\n textValue: textValueProp,\n isSelected,\n children: shouldRenderWebNative ? /* @__PURE__ */ jsx(\"option\", { value, disabled, children: props.children }) : /* @__PURE__ */ jsx(\n SelectItemFrame,\n {\n render: \"div\",\n ref: composedRefs,\n \"aria-labelledby\": textId,\n \"data-state\": isSelected ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : void 0,\n tabIndex: disabled ? void 0 : isWeb && isAdapted ? index === (selectContext.activeIndex ?? selectContext.selectedIndex) ? 0 : -1 : -1,\n zIndex: 100,\n ...selectItemProps,\n ...accessibilityProps\n }\n )\n }\n );\n },\n {\n disableTheme: true\n }\n);\nexport {\n SelectItem,\n SelectItemContextProvider,\n SelectItemFrame,\n useSelectItemContext\n};\n//# sourceMappingURL=SelectItem.js.map\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,YAAY;AAClB,MAAM,EACJ,UAAU,2BACV,kBAAkB,yBAChB,oBAAoB,MAAM,SAAS;AACvC,MAAM,kBAAkB,OAAO,MAAM;CACnC,aAAa;CACb,YAAY;CACZ,eAAe;AACjB,CAAC;AACD,MAAM,aAAa,gBACjB,iBACA,SAAS,YAAY,OAAO,cAAc;CACxC,MAAM,EACJ,OACA,OACA,UAAU,cACV,iBAAiB,cACjB,WAAW,eACX,GAAG,cACD;CACJ,MAAM,WAAW,gBAAgB,iBAAiB;CAClD,MAAM,UAAU,2BAA2B,KAAK;CAChD,MAAM,gBAAgB,iBAAiB,KAAK;CAC5C,MAAM,YAAY,iBAAiB,cAAc,UAAU;CAC3D,MAAM,EACJ,SACA,UACA,MACA,gBACA,aACA,sBACA,gBACA,iBACA,gBACA,kBACA,cACA,uBACA,oBACA,YACA,WACE;CACJ,MAAM,aAAa,eAAe,SAAS,KAAK;CAChD,MAAM,6BAA6B,MAAM,OAAO,KAAK;CACrD,MAAM,cAAc,MAAM,OAAO,IAAI;CACrC,MAAM,GAAG,oBAAoB,MAAM,YAAY,YAAY,UAAU,GAAG,CAAC;CACzE,MAAM,kBAAkB,MAAM,OAC5B,IACF;CACA,MAAM,sBAAsB,MAAM,OAAO;EACvC;EACA;EACA,WAAW;CACb,CAAC;CACD,gCACQ,SAAS,gBAAgB,iBAAiB,CAAC,GACjD,CAAC,QAAQ,CACX;CACA,gCAAgC;EAC9B,MAAM,eAAe,SAAS,aAAa,oBAAoB,OAAO;EACtE,gBAAgB,UAAU;EAC1B,MAAM,iBAAiB,YAAY;EACnC,aAAa,QAAQ,cAAc;EACnC,MAAM,kBAAkB,SAAS,SAAS,CAAC,CAAC,WAAW,SAAS,KAAK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ACA,UACA,QAAQ,QAAQ,QAClB;CACA,OAAuB,oBACrB,2BACA;EACE;EACA;EACA,QAAQ,UAAU;EAClB,WAAW;EACX;EACA,UAAU,wBAAwC,oBAAI,UAAU;GAAE;GAAO;GAAU,UAAU,MAAM;EAAS,CAAC,IAAoB,oBAC/H,iBACA;GACE,QAAQ;GACR,KAAK;GACL,mBAAmB;GACnB,cAAc,aAAa,WAAW;GACtC,iBAAiB,WAAW,KAAK,KAAK;GACtC,UAAU,WAAW,KAAK,IAAI,SAAS,YAAY,WAAW,cAAc,eAAe,cAAc,iBAAiB,IAAI,CAAC,IAAI,CAAC;GACpI,QAAQ;GACR,GAAG;GACH,GAAG;EACL,CACF;CACF,CACF;AACF,GACA,EACE,cAAc,KAChB,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectItem.native.js","names":[],"sources":["esm/SelectItem.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { useAdaptIsActive } from \"@tamagui/adapt\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createChangeEventDetails, createStyledHOC, createStyledContext, styled, View } from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { getSelectOptionProps } from \"./selectionController\";\nfunction _instanceof(left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return !!right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n}\nvar ITEM_NAME = \"SelectItem\";\nvar { Provider: SelectItemContextProvider, useStyledContext: useSelectItemContext } = createStyledContext(null, ITEM_NAME);\nvar SelectItemFrame = styled(View, {\n displayName: ITEM_NAME,\n alignItems: \"center\",\n flexDirection: \"row\"\n});\nvar SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, forwardedRef) {\n var { scope, value, disabled: disabledProp, \"aria-disabled\": ariaDisabled, textValue: textValueProp, ...restProps } = props;\n var disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : ariaDisabled === true;\n var context = useSelectItemParentContext(scope);\n var selectContext = useSelectContext(scope);\n var isAdapted = useAdaptIsActive(selectContext.adaptScope);\n var { listRef, registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, interactions, shouldRenderWebNative, setActiveIndexFast, moveActive, search } = context;\n var isSelected = selectedValues.includes(value);\n var pendingMouseUpSelectionRef = React.useRef(false);\n var itemNodeRef = React.useRef(null);\n var [, rerenderRegistry] = React.useReducer(function(version) {\n return version + 1;\n }, 0);\n var registrationRef = React.useRef(null);\n var initialRegistration = React.useRef({\n value,\n disabled,\n textValue: textValueProp\n });\n useIsomorphicLayoutEffect(function() {\n return registry.subscribe(function() {\n return rerenderRegistry();\n });\n }, [\n registry\n ]);\n useIsomorphicLayoutEffect(function() {\n var registration = registry.registerItem(initialRegistration.current);\n registrationRef.current = registration;\n var registeredNode = itemNodeRef.current;\n registration.setNode(registeredNode);\n var registeredIndex = registry.getItems().findIndex(function(item) {\n return item.id === registration.id;\n });\n if (isWeb && listRef && registeredIndex >= 0 && _instanceof(registeredNode, HTMLElement)) {\n listRef.current[registeredIndex] = registeredNode;\n }\n return function() {\n var currentIndex = registry.getItems().findIndex(function(item) {\n return item.id === registration.id;\n });\n if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {\n listRef.current[currentIndex] = null;\n }\n registrationRef.current = null;\n registration.unregister();\n };\n }, [\n registry\n ]);\n useIsomorphicLayoutEffect(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.update({\n value,\n disabled,\n textValue: textValueProp\n });\n }, [\n disabled,\n textValueProp,\n value\n ]);\n useIsomorphicLayoutEffect(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(itemNodeRef.current);\n });\n var index = registry.getIndex(value);\n React.useEffect(function() {\n var handleActiveIndex = function(i) {\n if (index === i) {\n if (isWeb) {\n requestAnimationFrame(function() {\n var _listRef_current_index;\n listRef === null || listRef === void 0 ? void 0 : (_listRef_current_index = listRef.current[index]) === null || _listRef_current_index === void 0 ? void 0 : _listRef_current_index.focus();\n });\n }\n }\n };\n var currentActiveIndex = activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current;\n if (currentActiveIndex !== null && currentActiveIndex !== void 0) {\n handleActiveIndex(currentActiveIndex);\n }\n return activeIndexSubscribe(handleActiveIndex);\n }, [\n activeIndexRef,\n activeIndexSubscribe,\n index,\n listRef\n ]);\n var textId = React.useId();\n var refCallback = React.useCallback(function(node) {\n var _registrationRef_current;\n itemNodeRef.current = node;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(node);\n if (!isWeb) return;\n if (listRef && index >= 0) {\n listRef.current[index] = _instanceof(node, HTMLElement) ? node : null;\n }\n }, [\n index,\n listRef\n ]);\n var composedRefs = useComposedRefs(forwardedRef, refCallback);\n var handleSelect = React.useCallback(function(event) {\n var reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : \"item-press\";\n if (disabled) return;\n var nativeEvent = (event === null || event === void 0 ? void 0 : event.nativeEvent) || event;\n selectValue(value, createChangeEventDetails(reason, nativeEvent, event === null || event === void 0 ? void 0 : event.currentTarget));\n }, [\n disabled,\n selectValue,\n value\n ]);\n var handleKeyDown = React.useCallback(function(event) {\n var _event_key;\n if (disabled) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n handleSelect(event, \"keyboard\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n event.stopPropagation();\n moveActive(event.key === \"ArrowDown\" ? 1 : -1, event.nativeEvent || event);\n return;\n }\n if (!interactions && ((_event_key = event.key) === null || _event_key === void 0 ? void 0 : _event_key.length) === 1 && !event.metaKey && !event.ctrlKey) {\n search(event.key, event.nativeEvent || event);\n }\n if (allowSelectRef) {\n allowSelectRef.current = true;\n }\n }, [\n allowSelectRef,\n disabled,\n handleSelect,\n interactions,\n moveActive,\n search\n ]);\n var selectItemProps = React.useMemo(function() {\n if (interactions) {\n var { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;\n var interactionProps = interactions.getItemProps({\n ...itemProps,\n onTouchMove() {\n allowSelectRef.current = true;\n allowMouseUpRef.current = false;\n },\n onTouchEnd() {\n allowSelectRef.current = false;\n allowMouseUpRef.current = true;\n },\n onMouseMove(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n },\n onKeyDown: handleKeyDown,\n onClick(event) {\n if (disabled) return;\n var shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n if (shouldSelect) {\n handleSelect(event);\n }\n },\n onMouseUp(event) {\n if (disabled) return;\n if (!allowMouseUpRef.current) {\n allowMouseUpRef.current = true;\n allowSelectRef.current = true;\n return;\n }\n pendingMouseUpSelectionRef.current = allowSelectRef.current;\n clearTimeout(selectTimeoutRef.current);\n selectTimeoutRef.current = setTimeout(function() {\n allowSelectRef.current = true;\n if (pendingMouseUpSelectionRef.current) {\n pendingMouseUpSelectionRef.current = false;\n handleSelect(event);\n }\n });\n }\n });\n return {\n ...interactionProps,\n onTouchMove: composeEventHandlers(onTouchMove, interactionProps.onTouchMove),\n onTouchEnd: composeEventHandlers(onTouchEnd, interactionProps.onTouchEnd),\n onKeyDown: composeEventHandlers(onKeyDown, interactionProps.onKeyDown),\n onClick(event) {\n var _interactionProps_onClick;\n onClick === null || onClick === void 0 ? void 0 : onClick(event);\n if (event.defaultPrevented) {\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n return;\n }\n (_interactionProps_onClick = interactionProps.onClick) === null || _interactionProps_onClick === void 0 ? void 0 : _interactionProps_onClick.call(interactionProps, event);\n },\n onMouseUp: composeEventHandlers(onMouseUp, interactionProps.onMouseUp),\n onMouseMove: composeEventHandlers(onMouseMove, interactionProps.onMouseMove),\n onPress\n };\n }\n return {\n ...restProps,\n onKeyDown: composeEventHandlers(restProps.onKeyDown, handleKeyDown),\n onMouseMove: composeEventHandlers(restProps.onMouseMove, function(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n }),\n onPress: composeEventHandlers(restProps.onPress, handleSelect)\n };\n }, [\n allowMouseUpRef,\n allowSelectRef,\n disabled,\n handleKeyDown,\n handleSelect,\n index,\n interactions,\n restProps,\n selectTimeoutRef,\n setActiveIndexFast\n ]);\n var accessibilityProps = getSelectOptionProps(mode, isSelected, disabled, isWeb ? \"web\" : \"native\");\n var _selectContext_activeIndex;\n return /* @__PURE__ */ _jsx(SelectItemContextProvider, {\n scope,\n value,\n textId: textId || \"\",\n textValue: textValueProp,\n isSelected,\n children: shouldRenderWebNative ? /* @__PURE__ */ _jsx(\"option\", {\n value,\n disabled,\n children: props.children\n }) : /* @__PURE__ */ _jsx(SelectItemFrame, {\n render: \"div\",\n ref: composedRefs,\n \"aria-labelledby\": textId,\n \"data-state\": isSelected ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : void 0,\n tabIndex: disabled ? void 0 : isWeb && isAdapted ? index === ((_selectContext_activeIndex = selectContext.activeIndex) !== null && _selectContext_activeIndex !== void 0 ? _selectContext_activeIndex : selectContext.selectedIndex) ? 0 : -1 : -1,\n zIndex: 100,\n ...selectItemProps,\n ...accessibilityProps\n })\n });\n}, {\n disableTheme: true\n});\nexport {\n SelectItem,\n SelectItemContextProvider,\n SelectItemFrame,\n useSelectItemContext\n};\n//# sourceMappingURL=SelectItem.js.map\n"],"mappings":";;;;;;;;;;;AASA,SAAS,YAAY,MAAM,OAAO;CAChC,IAAI,SAAS,QAAQ,OAAO,WAAW,eAAe,MAAM,OAAO,cAAc;EAC/E,OAAO,CAAC,CAAC,MAAM,OAAO,aAAa,IAAI;CACzC,OAAO;EACL,OAAO,gBAAgB;CACzB;AACF;AACA,IAAI,YAAY;AAChB,IAAI,EAAE,UAAU,2BAA2B,kBAAkB,yBAAyB,oBAAoB,MAAM,SAAS;AACzH,IAAI,kBAAkB,OAAO,MAAM;CACjC,aAAa;CACb,YAAY;CACZ,eAAe;AACjB,CAAC;AACD,IAAI,aAAa,gBAAgB,iBAAiB,SAAS,YAAY,OAAO,cAAc;CAC1F,IAAI,EAAE,OAAO,OAAO,UAAU,cAAc,iBAAiB,cAAc,WAAW,eAAe,GAAG,cAAc;CACtH,IAAI,WAAW,iBAAiB,QAAQ,iBAAiB,KAAK,IAAI,eAAe,iBAAiB;CAClG,IAAI,UAAU,2BAA2B,KAAK;CAC9C,IAAI,gBAAgB,iBAAiB,KAAK;CAC1C,IAAI,YAAY,iBAAiB,cAAc,UAAU;CACzD,IAAI,EAAE,SAAS,UAAU,MAAM,gBAAgB,aAAa,sBAAsB,gBAAgB,iBAAiB,gBAAgB,kBAAkB,cAAc,uBAAuB,oBAAoB,YAAY,WAAW;CACrO,IAAI,aAAa,eAAe,SAAS,KAAK;CAC9C,IAAI,6BAA6B,MAAM,OAAO,KAAK;CACnD,IAAI,cAAc,MAAM,OAAO,IAAI;CACnC,IAAI,GAAG,oBAAoB,MAAM,WAAW,SAAS,SAAS;EAC5D,OAAO,UAAU;CACnB,GAAG,CAAC;CACJ,IAAI,kBAAkB,MAAM,OAAO,IAAI;C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;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,IAAI,qBAAqB,qBAAqB,MAAM,YAAY,UAAU,QAAQ,QAAQ,QAAQ;CAClG,IAAI;CACJ,OAAuB,oBAAK,2BAA2B;EACrD;EACA;EACA,QAAQ,UAAU;EAClB,WAAW;EACX;EACA,UAAU,wBAAwC,oBAAK,UAAU;GAC/D;GACA;GACA,UAAU,MAAM;EAClB,CAAC,IAAoB,oBAAK,iBAAiB;GACzC,QAAQ;GACR,KAAK;GACL,mBAAmB;GACnB,cAAc,aAAa,WAAW;GACtC,iBAAiB,WAAW,KAAK,KAAK;GACtC,UAAU,WAAW,KAAK,IAAI,SAAS,YAAY,YAAY,6BAA6B,cAAc,iBAAiB,QAAQ,+BAA+B,KAAK,IAAI,6BAA6B,cAAc,iBAAiB,IAAI,CAAC,IAAI,CAAC;GACjP,QAAQ;GACR,GAAG;GACH,GAAG;EACL,CAAC;CACH,CAAC;AACH,GAAG,EACD,cAAc,KAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"SelectItem.native.js","names":[],"sources":["esm/SelectItem.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { useAdaptIsActive } from \"@tamagui/adapt\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createChangeEventDetails, createStyledHOC, createStyledContext, styled, View } from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { getSelectOptionProps } from \"./selectionController\";\nfunction _instanceof(left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return !!right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n}\nvar ITEM_NAME = \"SelectItem\";\nvar { Provider: SelectItemContextProvider, useStyledContext: useSelectItemContext } = createStyledContext(null, ITEM_NAME);\nvar SelectItemFrame = styled(View, {\n displayName: ITEM_NAME,\n alignItems: \"center\",\n flexDirection: \"row\"\n});\nvar SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, forwardedRef) {\n var { scope, value, disabled: disabledProp, \"aria-disabled\": ariaDisabled, textValue: textValueProp, ...restProps } = props;\n var disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : ariaDisabled === true;\n var context = useSelectItemParentContext(scope);\n var selectContext = useSelectContext(scope);\n var isAdapted = useAdaptIsActive(selectContext.adaptScope);\n var { listRef, registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, interactions, shouldRenderWebNative, setActiveIndexFast, moveActive, search } = context;\n var isSelected = selectedValues.includes(value);\n var pendingMouseUpSelectionRef = React.useRef(false);\n var itemNodeRef = React.useRef(null);\n var [, rerenderRegistry] = React.useReducer(function(version) {\n return version + 1;\n }, 0);\n var registrationRef = React.useRef(null);\n var initialRegistration = React.useRef({\n value,\n disabled,\n textValue: textValueProp\n });\n useIsomorphicLayoutEffect(function() {\n return registry.subscribe(function() {\n return rerenderRegistry();\n });\n }, [\n registry\n ]);\n useIsomorphicLayoutEffect(function() {\n var registration = registry.registerItem(initialRegistration.current);\n registrationRef.current = registration;\n var registeredNode = itemNodeRef.current;\n registration.setNode(registeredNode);\n var registeredIndex = registry.getItems().findIndex(function(item) {\n return item.id === registration.id;\n });\n if (isWeb && listRef && registeredIndex >= 0 && _instanceof(registeredNode, HTMLElement)) {\n listRef.current[registeredIndex] = registeredNode;\n }\n return function() {\n var currentIndex = registry.getItems().findIndex(function(item) {\n return item.id === registration.id;\n });\n if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {\n listRef.current[currentIndex] = null;\n }\n registrationRef.current = null;\n registration.unregister();\n };\n }, [\n registry\n ]);\n useIsomorphicLayoutEffect(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.update({\n value,\n disabled,\n textValue: textValueProp\n });\n }, [\n disabled,\n textValueProp,\n value\n ]);\n useIsomorphicLayoutEffect(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(itemNodeRef.current);\n });\n var index = registry.getIndex(value);\n React.useEffect(function() {\n var handleActiveIndex = function(i) {\n if (index === i) {\n if (isWeb) {\n requestAnimationFrame(function() {\n var _listRef_current_index;\n listRef === null || listRef === void 0 ? void 0 : (_listRef_current_index = listRef.current[index]) === null || _listRef_current_index === void 0 ? void 0 : _listRef_current_index.focus();\n });\n }\n }\n };\n var currentActiveIndex = activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current;\n if (currentActiveIndex !== null && currentActiveIndex !== void 0) {\n handleActiveIndex(currentActiveIndex);\n }\n return activeIndexSubscribe(handleActiveIndex);\n }, [\n activeIndexRef,\n activeIndexSubscribe,\n index,\n listRef\n ]);\n var textId = React.useId();\n var refCallback = React.useCallback(function(node) {\n var _registrationRef_current;\n itemNodeRef.current = node;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(node);\n if (!isWeb) return;\n if (listRef && index >= 0) {\n listRef.current[index] = _instanceof(node, HTMLElement) ? node : null;\n }\n }, [\n index,\n listRef\n ]);\n var composedRefs = useComposedRefs(forwardedRef, refCallback);\n var handleSelect = React.useCallback(function(event) {\n var reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : \"item-press\";\n if (disabled) return;\n var nativeEvent = (event === null || event === void 0 ? void 0 : event.nativeEvent) || event;\n selectValue(value, createChangeEventDetails(reason, nativeEvent, event === null || event === void 0 ? void 0 : event.currentTarget));\n }, [\n disabled,\n selectValue,\n value\n ]);\n var handleKeyDown = React.useCallback(function(event) {\n var _event_key;\n if (disabled) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n handleSelect(event, \"keyboard\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n event.stopPropagation();\n moveActive(event.key === \"ArrowDown\" ? 1 : -1, event.nativeEvent || event);\n return;\n }\n if (!interactions && ((_event_key = event.key) === null || _event_key === void 0 ? void 0 : _event_key.length) === 1 && !event.metaKey && !event.ctrlKey) {\n search(event.key, event.nativeEvent || event);\n }\n if (allowSelectRef) {\n allowSelectRef.current = true;\n }\n }, [\n allowSelectRef,\n disabled,\n handleSelect,\n interactions,\n moveActive,\n search\n ]);\n var selectItemProps = React.useMemo(function() {\n if (interactions) {\n var { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;\n var interactionProps = interactions.getItemProps({\n ...itemProps,\n onTouchMove() {\n allowSelectRef.current = true;\n allowMouseUpRef.current = false;\n },\n onTouchEnd() {\n allowSelectRef.current = false;\n allowMouseUpRef.current = true;\n },\n onMouseMove(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n },\n onKeyDown: handleKeyDown,\n onClick(event) {\n if (disabled) return;\n var shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n if (shouldSelect) {\n handleSelect(event);\n }\n },\n onMouseUp(event) {\n if (disabled) return;\n if (!allowMouseUpRef.current) {\n allowMouseUpRef.current = true;\n allowSelectRef.current = true;\n return;\n }\n pendingMouseUpSelectionRef.current = allowSelectRef.current;\n clearTimeout(selectTimeoutRef.current);\n selectTimeoutRef.current = setTimeout(function() {\n allowSelectRef.current = true;\n if (pendingMouseUpSelectionRef.current) {\n pendingMouseUpSelectionRef.current = false;\n handleSelect(event);\n }\n });\n }\n });\n return {\n ...interactionProps,\n onTouchMove: composeEventHandlers(onTouchMove, interactionProps.onTouchMove),\n onTouchEnd: composeEventHandlers(onTouchEnd, interactionProps.onTouchEnd),\n onKeyDown: composeEventHandlers(onKeyDown, interactionProps.onKeyDown),\n onClick(event) {\n var _interactionProps_onClick;\n onClick === null || onClick === void 0 ? void 0 : onClick(event);\n if (event.defaultPrevented) {\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n return;\n }\n (_interactionProps_onClick = interactionProps.onClick) === null || _interactionProps_onClick === void 0 ? void 0 : _interactionProps_onClick.call(interactionProps, event);\n },\n onMouseUp: composeEventHandlers(onMouseUp, interactionProps.onMouseUp),\n onMouseMove: composeEventHandlers(onMouseMove, interactionProps.onMouseMove),\n onPress\n };\n }\n return {\n ...restProps,\n onKeyDown: composeEventHandlers(restProps.onKeyDown, handleKeyDown),\n onMouseMove: composeEventHandlers(restProps.onMouseMove, function(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n }),\n onPress: composeEventHandlers(restProps.onPress, handleSelect)\n };\n }, [\n allowMouseUpRef,\n allowSelectRef,\n disabled,\n handleKeyDown,\n handleSelect,\n index,\n interactions,\n restProps,\n selectTimeoutRef,\n setActiveIndexFast\n ]);\n var accessibilityProps = getSelectOptionProps(mode, isSelected, disabled, isWeb ? \"web\" : \"native\");\n var _selectContext_activeIndex;\n return /* @__PURE__ */ _jsx(SelectItemContextProvider, {\n scope,\n value,\n textId: textId || \"\",\n textValue: textValueProp,\n isSelected,\n children: shouldRenderWebNative ? /* @__PURE__ */ _jsx(\"option\", {\n value,\n disabled,\n children: props.children\n }) : /* @__PURE__ */ _jsx(SelectItemFrame, {\n render: \"div\",\n ref: composedRefs,\n \"aria-labelledby\": textId,\n \"data-state\": isSelected ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : void 0,\n tabIndex: disabled ? void 0 : isWeb && isAdapted ? index === ((_selectContext_activeIndex = selectContext.activeIndex) !== null && _selectContext_activeIndex !== void 0 ? _selectContext_activeIndex : selectContext.selectedIndex) ? 0 : -1 : -1,\n zIndex: 100,\n ...selectItemProps,\n ...accessibilityProps\n })\n });\n}, {\n disableTheme: true\n});\nexport {\n SelectItem,\n SelectItemContextProvider,\n SelectItemFrame,\n useSelectItemContext\n};\n//# sourceMappingURL=SelectItem.js.map\n"],"mappings":";;;;;;;;;;;AASA,SAAS,YAAY,MAAM,OAAO;CAChC,IAAI,SAAS,QAAQ,OAAO,WAAW,eAAe,MAAM,OAAO,cAAc;EAC/E,OAAO,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,IAAI;CACzC,OAAO;EACL,OAAO,gBAAgB;CACzB;AACF;AACA,IAAI,YAAY;AAChB,IAAI,EAAE,UAAU,2BAA2B,kBAAkB,yBAAyB,oBAAoB,MAAM,SAAS;AACzH,IAAI,kBAAkB,OAAO,MAAM;CACjC,aAAa;CACb,YAAY;CACZ,eAAe;AACjB,CAAC;AACD,IAAI,aAAa,gBAAgB,iBAAiB,SAAS,YAAY,OAAO,cAAc;CAC1F,IAAI,EAAE,OAAO,OAAO,UAAU,cAAc,iBAAiB,cAAc,WAAW,eAAe,GAAG,cAAc;CACtH,IAAI,WAAW,iBAAiB,QAAQ,iBAAiB,KAAK,IAAI,eAAe,iBAAiB;CAClG,IAAI,UAAU,2BAA2B,KAAK;CAC9C,IAAI,gBAAgB,iBAAiB,KAAK;CAC1C,IAAI,YAAY,iBAAiB,cAAc,UAAU;CACzD,IAAI,EAAE,SAAS,UAAU,MAAM,gBAAgB,aAAa,sBAAsB,gBAAgB,iBAAiB,gBAAgB,kBAAkB,cAAc,uBAAuB,oBAAoB,YAAY,WAAW;CACrO,IAAI,aAAa,eAAe,SAAS,KAAK;CAC9C,IAAI,6BAA6B,MAAM,OAAO,KAAK;CACnD,IAAI,cAAc,MAAM,O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KAChG,QAAQ;KACR,OAAO,MAAM,eAAe;KAC5B,SAAS,MAAM;KACf;IACF,CAAC;GACH,CAAC;GACD,SAAS,qBAAqB,UAAU,SAAS,YAAY;EAC/D;CACF,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,IAAI,qBAAqB,qBAAqB,MAAM,YAAY,UAAU,QAAQ,QAAQ,QAAQ;CAClG,IAAI;CACJ,OAAuB,oBAAK,2BAA2B;EACrD;EACA;EACA,QAAQ,UAAU;EAClB,WAAW;EACX;EACA,UAAU,wBAAwC,oBAAK,UAAU;GAC/D;GACA;GACA,UAAU,MAAM;EAClB,CAAC,IAAoB,oBAAK,iBAAiB;GACzC,QAAQ;GACR,KAAK;GACL,mBAAmB;GACnB,cAAc,aAAa,WAAW;GACtC,iBAAiB,WAAW,KAAK,KAAK;GACtC,UAAU,WAAW,KAAK,IAAI,SAAS,YAAY,YAAY,6BAA6B,cAAc,iBAAiB,QAAQ,+BAA+B,KAAK,IAAI,6BAA6B,cAAc,iBAAiB,IAAI,CAAC,IAAI,CAAC;GACjP,QAAQ;GACR,GAAG;GACH,GAAG;EACL,CAAC;CACH,CAAC;AACH,GAAG,EACD,cAAc,KAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectViewport.js","names":[],"sources":["esm/SelectViewport.js"],"sourcesContent":["import { AdaptPortalContents, useAdaptIsActive } from \"@tamagui/adapt\";\nimport { AnimatePresence } from \"@tamagui/animate-presence\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createStyledHOC, styled, View } from \"@tamagui/core\";\nimport { needsPortalRepropagation } from \"@tamagui/portal\";\nimport { YStack } from \"@tamagui/stacks\";\nimport { startTransition } from \"@tamagui/start-transition\";\nimport * as React from \"react\";\nimport { VIEWPORT_NAME } from \"./constants\";\nimport {\n ForwardSelectContext,\n useSelectContext,\n useSelectItemParentContext\n} from \"./context\";\nimport { getSelectListboxProps } from \"./selectionController\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\nconst SelectViewportFrame = styled(View, {\n displayName: VIEWPORT_NAME,\n position: \"relative\"\n});\nconst needsRepropagation = needsPortalRepropagation();\nconst SelectViewport = createStyledHOC(\n SelectViewportFrame,\n function SelectViewport2(props, forwardedRef) {\n const { scope, children, disableScroll, ...viewportProps } = props;\n const context = useSelectContext(scope);\n const itemContext = useSelectItemParentContext(scope);\n const isAdapted = useAdaptIsActive(context.adaptScope);\n const viewportRef = React.useRef(null);\n const registeredItemCount = itemContext.registry.getItems().length;\n const [lazyMounted, setLazyMounted] = React.useState(context.lazyMount ? false : true);\n React.useEffect(() => {\n if (!context.lazyMount) return;\n if (!context.open) return;\n if (lazyMounted) return;\n startTransition(() => {\n setLazyMounted(true);\n });\n }, [context.lazyMount, context.open, lazyMounted]);\n React.useEffect(() => {\n if (!isWeb || !isAdapted || !context.open) return;\n const frame = requestAnimationFrame(() => {\n const index = context.activeIndexRef.current ?? itemContext.registry.firstEnabledIndex();\n const activeItem = viewportRef.current?.querySelector(\n '[role=\"option\"][tabindex=\"0\"]'\n ) ?? (index >= 0 ? itemContext.listRef?.current[index] : null);\n activeItem?.focus();\n });\n return () => cancelAnimationFrame(frame);\n }, [context.activeIndex, context.open, isAdapted, registeredItemCount]);\n const composedRefs = useComposedRefs(\n // @ts-ignore react 19 ref type mismatch\n forwardedRef,\n viewportRef,\n context.floatingContext?.refs.setFloating\n );\n useIsomorphicLayoutEffect(() => {\n if (context.update) {\n context.update();\n }\n }, [isAdapted]);\n React.useEffect(() => {\n if (context.lazyMount && lazyMounted && context.open && context.update) {\n const frame = requestAnimationFrame(context.update);\n return () => cancelAnimationFrame(frame);\n }\n }, [lazyMounted, registeredItemCount]);\n if (itemContext.shouldRenderWebNative) {\n return /* @__PURE__ */ jsx(YStack, { position: \"relative\", children });\n }\n if (isAdapted || !isWeb) {\n let content = /* @__PURE__ */ jsx(\n SelectViewportFrame,\n {\n ...viewportProps,\n ...isWeb ? getSelectListboxProps(itemContext.mode) : {},\n \"data-select-viewport\": \"\",\n ref: composedRefs,\n children: lazyMounted ? children : null\n }\n );\n if (needsRepropagation) {\n content = /* @__PURE__ */ jsx(ForwardSelectContext, { itemContext, context, children: content });\n }\n return /* @__PURE__ */ jsx(AdaptPortalContents, { scope: context.adaptScope, children: content });\n }\n if (!itemContext.interactions) {\n return null;\n }\n const {\n style,\n // remove this, it was set to \"Select\" always\n className,\n ...floatingProps\n } = itemContext.interactions.getFloatingProps();\n return /* @__PURE__ */ jsxs(Fragment, { children: [\n !disableScroll && /* @__PURE__ */ jsx(\n \"style\",\n {\n dangerouslySetInnerHTML: {\n __html: selectViewportCSS\n }\n }\n ),\n /* @__PURE__ */ jsx(AnimatePresence, { children: context.open ? /* @__PURE__ */ jsx(\n SelectViewportFrame,\n {\n \"data-select-viewport\": \"\",\n ...isWeb && {\n \"data-state\": context.open ? \"open\" : \"closed\"\n },\n ...viewportProps,\n ...style,\n ...floatingProps,\n ...getSelectListboxProps(itemContext.mode),\n overflowY: disableScroll ? void 0 : style.overflow ?? \"auto\",\n ref: composedRefs,\n children: lazyMounted ? children : null\n },\n \"select-viewport\"\n ) : null }),\n !context.open && !(context.lazyMount && context.renderValue) && lazyMounted && /* @__PURE__ */ jsx(\"div\", { style: { display: \"none\" }, children })\n ] });\n }\n);\nconst selectViewportCSS = `\n[data-select-viewport] {\n scrollbar-width: none;\n -webkit-overflow-scrolling: touch;\n overscroll-behavior: contain;\n}\n\n[data-select-viewport]::-webkit-scrollbar{\n display:none\n}\n`;\nexport {\n SelectViewport,\n SelectViewportFrame\n};\n//# sourceMappingURL=SelectViewport.js.map\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,sBAAsB,OAAO,MAAM;CACvC,aAAa;CACb,UAAU;AACZ,CAAC;AACD,MAAM,qBAAqB,yBAAyB;AACpD,MAAM,iBAAiB,gBACrB,qBACA,SAAS,gBAAgB,OAAO,cAAc;CAC5C,MAAM,EAAE,OAAO,UAAU,eAAe,GAAG,kBAAkB;CAC7D,MAAM,UAAU,iBAAiB,KAAK;CACtC,MAAM,cAAc,2BAA2B,KAAK;CACpD,MAAM,YAAY,iBAAiB,QAAQ,UAAU;CACrD,MAAM,cAAc,MAAM,OAAO,IAAI;CACrC,MAAM,sBAAsB,YAAY,SAAS,SAAS,
|
|
1
|
+
{"version":3,"file":"SelectViewport.js","names":[],"sources":["esm/SelectViewport.js"],"sourcesContent":["import { AdaptPortalContents, useAdaptIsActive } from \"@tamagui/adapt\";\nimport { AnimatePresence } from \"@tamagui/animate-presence\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createStyledHOC, styled, View } from \"@tamagui/core\";\nimport { needsPortalRepropagation } from \"@tamagui/portal\";\nimport { YStack } from \"@tamagui/stacks\";\nimport { startTransition } from \"@tamagui/start-transition\";\nimport * as React from \"react\";\nimport { VIEWPORT_NAME } from \"./constants\";\nimport {\n ForwardSelectContext,\n useSelectContext,\n useSelectItemParentContext\n} from \"./context\";\nimport { getSelectListboxProps } from \"./selectionController\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\nconst SelectViewportFrame = styled(View, {\n displayName: VIEWPORT_NAME,\n position: \"relative\"\n});\nconst needsRepropagation = needsPortalRepropagation();\nconst SelectViewport = createStyledHOC(\n SelectViewportFrame,\n function SelectViewport2(props, forwardedRef) {\n const { scope, children, disableScroll, ...viewportProps } = props;\n const context = useSelectContext(scope);\n const itemContext = useSelectItemParentContext(scope);\n const isAdapted = useAdaptIsActive(context.adaptScope);\n const viewportRef = React.useRef(null);\n const registeredItemCount = itemContext.registry.getItems().length;\n const [lazyMounted, setLazyMounted] = React.useState(context.lazyMount ? false : true);\n React.useEffect(() => {\n if (!context.lazyMount) return;\n if (!context.open) return;\n if (lazyMounted) return;\n startTransition(() => {\n setLazyMounted(true);\n });\n }, [context.lazyMount, context.open, lazyMounted]);\n React.useEffect(() => {\n if (!isWeb || !isAdapted || !context.open) return;\n const frame = requestAnimationFrame(() => {\n const index = context.activeIndexRef.current ?? itemContext.registry.firstEnabledIndex();\n const activeItem = viewportRef.current?.querySelector(\n '[role=\"option\"][tabindex=\"0\"]'\n ) ?? (index >= 0 ? itemContext.listRef?.current[index] : null);\n activeItem?.focus();\n });\n return () => cancelAnimationFrame(frame);\n }, [context.activeIndex, context.open, isAdapted, registeredItemCount]);\n const composedRefs = useComposedRefs(\n // @ts-ignore react 19 ref type mismatch\n forwardedRef,\n viewportRef,\n context.floatingContext?.refs.setFloating\n );\n useIsomorphicLayoutEffect(() => {\n if (context.update) {\n context.update();\n }\n }, [isAdapted]);\n React.useEffect(() => {\n if (context.lazyMount && lazyMounted && context.open && context.update) {\n const frame = requestAnimationFrame(context.update);\n return () => cancelAnimationFrame(frame);\n }\n }, [lazyMounted, registeredItemCount]);\n if (itemContext.shouldRenderWebNative) {\n return /* @__PURE__ */ jsx(YStack, { position: \"relative\", children });\n }\n if (isAdapted || !isWeb) {\n let content = /* @__PURE__ */ jsx(\n SelectViewportFrame,\n {\n ...viewportProps,\n ...isWeb ? getSelectListboxProps(itemContext.mode) : {},\n \"data-select-viewport\": \"\",\n ref: composedRefs,\n children: lazyMounted ? children : null\n }\n );\n if (needsRepropagation) {\n content = /* @__PURE__ */ jsx(ForwardSelectContext, { itemContext, context, children: content });\n }\n return /* @__PURE__ */ jsx(AdaptPortalContents, { scope: context.adaptScope, children: content });\n }\n if (!itemContext.interactions) {\n return null;\n }\n const {\n style,\n // remove this, it was set to \"Select\" always\n className,\n ...floatingProps\n } = itemContext.interactions.getFloatingProps();\n return /* @__PURE__ */ jsxs(Fragment, { children: [\n !disableScroll && /* @__PURE__ */ jsx(\n \"style\",\n {\n dangerouslySetInnerHTML: {\n __html: selectViewportCSS\n }\n }\n ),\n /* @__PURE__ */ jsx(AnimatePresence, { children: context.open ? /* @__PURE__ */ jsx(\n SelectViewportFrame,\n {\n \"data-select-viewport\": \"\",\n ...isWeb && {\n \"data-state\": context.open ? \"open\" : \"closed\"\n },\n ...viewportProps,\n ...style,\n ...floatingProps,\n ...getSelectListboxProps(itemContext.mode),\n overflowY: disableScroll ? void 0 : style.overflow ?? \"auto\",\n ref: composedRefs,\n children: lazyMounted ? children : null\n },\n \"select-viewport\"\n ) : null }),\n !context.open && !(context.lazyMount && context.renderValue) && lazyMounted && /* @__PURE__ */ jsx(\"div\", { style: { display: \"none\" }, children })\n ] });\n }\n);\nconst selectViewportCSS = `\n[data-select-viewport] {\n scrollbar-width: none;\n -webkit-overflow-scrolling: touch;\n overscroll-behavior: contain;\n}\n\n[data-select-viewport]::-webkit-scrollbar{\n display:none\n}\n`;\nexport {\n SelectViewport,\n SelectViewportFrame\n};\n//# sourceMappingURL=SelectViewport.js.map\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,sBAAsB,OAAO,MAAM;CACvC,aAAa;CACb,UAAU;AACZ,CAAC;AACD,MAAM,qBAAqB,yBAAyB;AACpD,MAAM,iBAAiB,gBACrB,qBACA,SAAS,gBAAgB,OAAO,cAAc;CAC5C,MAAM,EAAE,OAAO,UAAU,eAAe,GAAG,kBAAkB;CAC7D,MAAM,UAAU,iBAAiB,KAAK;CACtC,MAAM,cAAc,2BAA2B,KAAK;CACpD,MAAM,YAAY,iBAAiB,QAAQ,UAAU;CACrD,MAAM,cAAc,MAAM,OAAO,IAAI;CACrC,MAAM,sBAAsB,YAAY,SAAS,SAAS,CAAC,CAAC;CAC5D,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAS,QAAQ,YAAY,QAAQ,IAAI;CACrF,MAAM,gBAAgB;EACpB,IAAI,CAAC,QAAQ,WAAW;EACxB,IAAI,CAAC,QAAQ,MAAM;EACnB,IAAI,aAAa;EACjB,sBAAsB;GACpB,eAAe,IAAI;EACrB,CAAC;CACH,GAAG;EAAC,QAAQ;EAAW,QAAQ;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AAM,EACJ,OAEA,WACA,GAAG,kBACD,YAAY,aAAa,iBAAiB;CAC9C,OAAuB,qBAAK,UAAU,EAAE,UAAU;EAChD,CAAC,iBAAiC,oBAChC,SACA,EACE,yBAAyB,EACvB,QAAQ,kBACV,EACF,CACF;EACgB,oBAAI,iBAAiB,EAAE,UAAU,QAAQ,OAAuB,oBAC9E,qBACA;GACE,wBAAwB;GACxB,GAAG,SAAS,EACV,cAAc,QAAQ,OAAO,SAAS,SACxC;GACA,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG,sBAAsB,YAAY,IAAI;GACzC,WAAW,gBAAgB,KAAK,IAAI,MAAM,YAAY;GACtD,KAAK;GACL,UAAU,cAAc,WAAW;EACrC,GACA,iBACF,IAAI,KAAK,CAAC;EACV,CAAC,QAAQ,QAAQ,EAAE,QAAQ,aAAa,QAAQ,gBAAgB,eAA+B,oBAAI,OAAO;GAAE,OAAO,EAAE,SAAS,OAAO;GAAG;EAAS,CAAC;CACpJ,EAAE,CAAC;AACL,CACF;AACA,MAAM,oBAAoB"}
|
package/dist/esm/context.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["esm/context.js"],"sourcesContent":["import { createStyledContext } from \"@tamagui/core\";\nimport { getPortal } from \"@tamagui/native\";\nimport { createContext } from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nconst SelectZIndexContext = createContext(void 0);\nconst SelectNativeComponentContext = createContext(null);\nconst { Provider: SelectProvider, useStyledContext: useSelectContext } = createStyledContext(null, \"Select\");\nconst {\n Provider: SelectItemParentProvider,\n useStyledContext: useSelectItemParentContext\n} = createStyledContext(null, \"SelectItem\");\nconst ForwardSelectContext = ({\n context,\n itemContext,\n children\n}) => {\n const portalState = getPortal().state;\n if (portalState.type === \"teleport\") {\n return children;\n }\n return /* @__PURE__ */ jsx(SelectProvider, { scope: context.scopeName, ...context, children: /* @__PURE__ */ jsx(SelectItemParentProvider, { scope: context.scopeName, ...itemContext, children }) });\n};\nexport {\n ForwardSelectContext,\n SelectItemParentProvider,\n SelectNativeComponentContext,\n SelectProvider,\n SelectZIndexContext,\n useSelectContext,\n useSelectItemParentContext\n};\n//# sourceMappingURL=context.js.map\n"],"mappings":";;;;;;AAIA,MAAM,sBAAsB,cAAc,KAAK,CAAC;AAChD,MAAM,+BAA+B,cAAc,IAAI;AACvD,MAAM,EAAE,UAAU,gBAAgB,kBAAkB,qBAAqB,oBAAoB,MAAM,QAAQ;AAC3G,MAAM,EACJ,UAAU,0BACV,kBAAkB,+BAChB,oBAAoB,MAAM,YAAY;AAC1C,MAAM,wBAAwB,EAC5B,SACA,aACA,eACI;CACJ,MAAM,cAAc,UAAU,
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["esm/context.js"],"sourcesContent":["import { createStyledContext } from \"@tamagui/core\";\nimport { getPortal } from \"@tamagui/native\";\nimport { createContext } from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nconst SelectZIndexContext = createContext(void 0);\nconst SelectNativeComponentContext = createContext(null);\nconst { Provider: SelectProvider, useStyledContext: useSelectContext } = createStyledContext(null, \"Select\");\nconst {\n Provider: SelectItemParentProvider,\n useStyledContext: useSelectItemParentContext\n} = createStyledContext(null, \"SelectItem\");\nconst ForwardSelectContext = ({\n context,\n itemContext,\n children\n}) => {\n const portalState = getPortal().state;\n if (portalState.type === \"teleport\") {\n return children;\n }\n return /* @__PURE__ */ jsx(SelectProvider, { scope: context.scopeName, ...context, children: /* @__PURE__ */ jsx(SelectItemParentProvider, { scope: context.scopeName, ...itemContext, children }) });\n};\nexport {\n ForwardSelectContext,\n SelectItemParentProvider,\n SelectNativeComponentContext,\n SelectProvider,\n SelectZIndexContext,\n useSelectContext,\n useSelectItemParentContext\n};\n//# sourceMappingURL=context.js.map\n"],"mappings":";;;;;;AAIA,MAAM,sBAAsB,cAAc,KAAK,CAAC;AAChD,MAAM,+BAA+B,cAAc,IAAI;AACvD,MAAM,EAAE,UAAU,gBAAgB,kBAAkB,qBAAqB,oBAAoB,MAAM,QAAQ;AAC3G,MAAM,EACJ,UAAU,0BACV,kBAAkB,+BAChB,oBAAoB,MAAM,YAAY;AAC1C,MAAM,wBAAwB,EAC5B,SACA,aACA,eACI;CACJ,MAAM,cAAc,UAAU,CAAC,CAAC;CAChC,IAAI,YAAY,SAAS,YAAY;EACnC,OAAO;CACT;CACA,OAAuB,oBAAI,gBAAgB;EAAE,OAAO,QAAQ;EAAW,GAAG;EAAS,UAA0B,oBAAI,0BAA0B;GAAE,OAAO,QAAQ;GAAW,GAAG;GAAa;EAAS,CAAC;CAAE,CAAC;AACtM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.native.js","names":[],"sources":["esm/context.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { createStyledContext } from \"@tamagui/core\";\nimport { getPortal } from \"@tamagui/native\";\nimport { createContext } from \"react\";\nvar SelectZIndexContext = /* @__PURE__ */ createContext(void 0);\nvar SelectNativeComponentContext = /* @__PURE__ */ createContext(null);\nvar { Provider: SelectProvider, useStyledContext: useSelectContext } = createStyledContext(null, \"Select\");\nvar { Provider: SelectItemParentProvider, useStyledContext: useSelectItemParentContext } = createStyledContext(null, \"SelectItem\");\nvar ForwardSelectContext = function(param) {\n var { context, itemContext, children } = param;\n var portalState = getPortal().state;\n if (portalState.type === \"teleport\") {\n return children;\n }\n return /* @__PURE__ */ _jsx(SelectProvider, {\n scope: context.scopeName,\n ...context,\n children: /* @__PURE__ */ _jsx(SelectItemParentProvider, {\n scope: context.scopeName,\n ...itemContext,\n children\n })\n });\n};\nexport {\n ForwardSelectContext,\n SelectItemParentProvider,\n SelectNativeComponentContext,\n SelectProvider,\n SelectZIndexContext,\n useSelectContext,\n useSelectItemParentContext\n};\n//# sourceMappingURL=context.js.map\n"],"mappings":";;;;;;AAIA,IAAI,sBAAsC,8BAAc,KAAK,CAAC;AAC9D,IAAI,+BAA+C,8BAAc,IAAI;AACrE,IAAI,EAAE,UAAU,gBAAgB,kBAAkB,qBAAqB,oBAAoB,MAAM,QAAQ;AACzG,IAAI,EAAE,UAAU,0BAA0B,kBAAkB,+BAA+B,oBAAoB,MAAM,YAAY;AACjI,IAAI,uBAAuB,SAAS,OAAO;CACzC,IAAI,EAAE,SAAS,aAAa,aAAa;CACzC,IAAI,cAAc,UAAU,
|
|
1
|
+
{"version":3,"file":"context.native.js","names":[],"sources":["esm/context.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { createStyledContext } from \"@tamagui/core\";\nimport { getPortal } from \"@tamagui/native\";\nimport { createContext } from \"react\";\nvar SelectZIndexContext = /* @__PURE__ */ createContext(void 0);\nvar SelectNativeComponentContext = /* @__PURE__ */ createContext(null);\nvar { Provider: SelectProvider, useStyledContext: useSelectContext } = createStyledContext(null, \"Select\");\nvar { Provider: SelectItemParentProvider, useStyledContext: useSelectItemParentContext } = createStyledContext(null, \"SelectItem\");\nvar ForwardSelectContext = function(param) {\n var { context, itemContext, children } = param;\n var portalState = getPortal().state;\n if (portalState.type === \"teleport\") {\n return children;\n }\n return /* @__PURE__ */ _jsx(SelectProvider, {\n scope: context.scopeName,\n ...context,\n children: /* @__PURE__ */ _jsx(SelectItemParentProvider, {\n scope: context.scopeName,\n ...itemContext,\n children\n })\n });\n};\nexport {\n ForwardSelectContext,\n SelectItemParentProvider,\n SelectNativeComponentContext,\n SelectProvider,\n SelectZIndexContext,\n useSelectContext,\n useSelectItemParentContext\n};\n//# sourceMappingURL=context.js.map\n"],"mappings":";;;;;;AAIA,IAAI,sBAAsC,8BAAc,KAAK,CAAC;AAC9D,IAAI,+BAA+C,8BAAc,IAAI;AACrE,IAAI,EAAE,UAAU,gBAAgB,kBAAkB,qBAAqB,oBAAoB,MAAM,QAAQ;AACzG,IAAI,EAAE,UAAU,0BAA0B,kBAAkB,+BAA+B,oBAAoB,MAAM,YAAY;AACjI,IAAI,uBAAuB,SAAS,OAAO;CACzC,IAAI,EAAE,SAAS,aAAa,aAAa;CACzC,IAAI,cAAc,UAAU,CAAC,CAAC;CAC9B,IAAI,YAAY,SAAS,YAAY;EACnC,OAAO;CACT;CACA,OAAuB,oBAAK,gBAAgB;EAC1C,OAAO,QAAQ;EACf,GAAG;EACH,UAA0B,oBAAK,0BAA0B;GACvD,OAAO,QAAQ;GACf,GAAG;GACH;EACF,CAAC;CACH,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectionController.js","names":[],"sources":["esm/selectionController.js"],"sourcesContent":["function 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 return getSelectLabelText(label.props?.children);\n }\n return \"\";\n}\nfunction createSelectItemRegistry(onChange) {\n const items = [];\n const labelRegistrations = /* @__PURE__ */ new Map();\n const explicitTextValues = /* @__PURE__ */ new Map();\n const itemNodes = /* @__PURE__ */ new Map();\n const listeners = /* @__PURE__ */ new Set();\n const notify = () => {\n onChange?.();\n listeners.forEach((listener) => listener());\n };\n const getItems = () => items;\n const getItem = (value) => items.find((item) => item.value === value);\n const getIndex = (value) => items.findIndex((item) => item.value === value);\n const getRegisteredLabel = (value) => {\n const registrations = labelRegistrations.get(value);\n if (!registrations?.size) return void 0;\n const values = Array.from(registrations.values());\n return values[values.length - 1];\n };\n const applyRegisteredLabel = (value) => {\n const registeredLabel = getRegisteredLabel(value);\n let changed = false;\n for (const item of items) {\n if (item.value !== value) continue;\n const nextLabel = registeredLabel?.label;\n const nextTextValue = explicitTextValues.get(item.id) || registeredLabel?.textValue;\n if (item.label !== nextLabel || item.textValue !== nextTextValue) {\n item.label = nextLabel;\n item.textValue = nextTextValue;\n changed = true;\n }\n }\n if (changed) notify();\n };\n const syncNodeOrder = () => {\n const previousOrder = items.map((item) => item.id);\n items.sort((a, b) => {\n const aNode = itemNodes.get(a.id);\n const bNode = itemNodes.get(b.id);\n if (!aNode || !bNode || typeof aNode.compareDocumentPosition !== \"function\") {\n return 0;\n }\n const position = aNode.compareDocumentPosition(bNode);\n if (position & 4) return -1;\n if (position & 2) return 1;\n return 0;\n });\n if (items.some((item, index) => item.id !== previousOrder[index])) {\n notify();\n }\n };\n const registerItem = (item) => {\n const id = Symbol(item.value);\n const registeredLabel = getRegisteredLabel(item.value);\n const registeredItem = {\n ...item,\n ...registeredLabel,\n textValue: item.textValue ?? 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 const index = items.findIndex((current2) => current2.id === id);\n if (index < 0) return;\n const current = items[index];\n if (\"textValue\" in next) {\n explicitTextValues.set(id, next.textValue);\n }\n const nextItem = { ...current, ...next };\n if (next.value !== void 0 && next.value !== current.value) {\n const nextLabel = getRegisteredLabel(next.value);\n nextItem.label = nextLabel?.label;\n }\n const explicitTextValue = explicitTextValues.get(id);\n nextItem.textValue = explicitTextValue || getSelectLabelText(nextItem.label) || (nextItem.label ? nextItem.value : void 0);\n const changed = Object.entries(next).some(\n ([key, value]) => current[key] !== value\n );\n const 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 const index = items.findIndex((current) => current.id === id);\n if (index < 0) return;\n items.splice(index, 1);\n explicitTextValues.delete(id);\n itemNodes.delete(id);\n notify();\n }\n };\n };\n const registerLabel = (value, label, textValue) => {\n const id = Symbol(value);\n const normalizedTextValue = textValue || getSelectLabelText(label) || value;\n const registrations = labelRegistrations.get(value) ?? (() => {\n const next = /* @__PURE__ */ new Map();\n labelRegistrations.set(value, next);\n return next;\n })();\n registrations.set(id, { label, textValue: normalizedTextValue });\n applyRegisteredLabel(value);\n return () => {\n registrations.delete(id);\n if (!registrations.size) {\n labelRegistrations.delete(value);\n }\n applyRegisteredLabel(value);\n };\n };\n const firstEnabledIndex = () => items.findIndex((item) => !item.disabled);\n const nextEnabledIndex = (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 (let index = items.length - 1; index >= 0; index--) {\n if (!items[index].disabled) return index;\n }\n return -1;\n }\n for (let offset = 1; offset <= items.length; offset++) {\n const index = (fromIndex + direction * offset + items.length) % items.length;\n if (!items[index]?.disabled) return index;\n }\n return -1;\n };\n const findTypeaheadIndex = (search, fromIndex) => {\n const normalizedSearch = search.trim().toLocaleLowerCase();\n if (!normalizedSearch) return -1;\n const start = fromIndex == null || fromIndex < 0 ? -1 : fromIndex;\n for (let offset = 1; offset <= items.length; offset++) {\n const index = (start + offset) % items.length;\n const item = items[index];\n const 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 () => {\n listeners.delete(listener);\n };\n },\n registerItem,\n registerLabel,\n getItems,\n getItem,\n getIndex,\n firstEnabledIndex,\n nextEnabledIndex,\n findTypeaheadIndex,\n getDisabledIndices: () => items.flatMap((item, index) => item.disabled ? [index] : []),\n getTypeaheadLabels: () => items.map((item) => item.textValue || getSelectLabelText(item.label) || item.value)\n };\n}\nfunction normalizeSelectSelection(mode, value) {\n if (mode === \"single\") {\n return typeof value === \"string\" ? value : \"\";\n }\n const values = Array.isArray(value) ? value : [];\n return [...new Set(values)];\n}\nfunction selectedValuesFromSelection(mode, value) {\n const normalized = normalizeSelectSelection(mode, value);\n return mode === \"multiple\" ? normalized : normalized ? [normalized] : [];\n}\nfunction createSelectSelectionController({\n mode: initialMode,\n value: initialValue,\n registry\n}) {\n let mode = initialMode;\n let value = normalizeSelectSelection(mode, initialValue);\n let activeIndex = null;\n const selectedValues = () => selectedValuesFromSelection(mode, value);\n const setMode = (nextMode) => {\n if (mode === nextMode) return value;\n mode = nextMode;\n value = normalizeSelectSelection(mode, value);\n return value;\n };\n const setValue = (nextValue) => {\n value = normalizeSelectSelection(mode, nextValue);\n return value;\n };\n const isSelected = (itemValue) => selectedValues().includes(itemValue);\n const toggle = (itemValue) => {\n const item = registry.getItem(itemValue);\n if (!item || item.disabled) return value;\n if (mode === \"single\") {\n value = itemValue;\n return value;\n }\n const current = selectedValues();\n value = current.includes(itemValue) ? current.filter((currentValue) => currentValue !== itemValue) : [...current, itemValue];\n return value;\n };\n const selectionAnchor = () => {\n const values = selectedValues();\n for (let index = values.length - 1; index >= 0; index--) {\n const item = registry.getItem(values[index]);\n if (item) return item;\n }\n const firstEnabledIndex = registry.firstEnabledIndex();\n return firstEnabledIndex < 0 ? void 0 : registry.getItems()[firstEnabledIndex];\n };\n const selectionAnchorIndex = () => {\n const anchor = selectionAnchor();\n return anchor ? registry.getIndex(anchor.value) : -1;\n };\n const initialActiveIndex = () => {\n const anchorIndex = selectionAnchorIndex();\n const anchor = anchorIndex < 0 ? void 0 : registry.getItems()[anchorIndex];\n return anchor && !anchor.disabled ? anchorIndex : registry.firstEnabledIndex();\n };\n const moveActive = (direction) => {\n const 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}\nexport {\n createSelectItemRegistry,\n createSelectSelectionController,\n getSelectLabelText,\n getSelectListboxProps,\n getSelectOptionProps,\n normalizeSelectSelection,\n selectedValuesFromSelection\n};\n//# sourceMappingURL=selectionController.js.map\n"],"mappings":";AAAA,SAAS,mBAAmB,OAAO;CACjC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;EAC1D,OAAO,OAAO,KAAK;CACrB;CACA,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,OAAO,MAAM,IAAI,kBAAkB,EAAE,KAAK,EAAE;CAC9C;CACA,IAAI,SAAS,OAAO,UAAU,YAAY,WAAW,OAAO;EAC1D,OAAO,mBAAmB,MAAM,OAAO,QAAQ;CACjD;CACA,OAAO;AACT;AACA,SAAS,yBAAyB,UAAU;CAC1C,MAAM,QAAQ,CAAC;CACf,MAAM,qCAAqC,IAAI,IAAI;CACnD,MAAM,qCAAqC,IAAI,IAAI;CACnD,MAAM,4BAA4B,IAAI,IAAI;CAC1C,MAAM,4BAA4B,IAAI,IAAI;CAC1C,MAAM,eAAe;EACnB,WAAW;EACX,UAAU,SAAS,aAAa,SAAS,CAAC;CAC5C;CACA,MAAM,iBAAiB;CACvB,MAAM,WAAW,UAAU,MAAM,MAAM,SAAS,KAAK,UAAU,KAAK;CACpE,MAAM,YAAY,UAAU,MAAM,WAAW,SAAS,KAAK,UAAU,KAAK;CAC1E,MAAM,sBAAsB,UAAU;EACpC,MAAM,gBAAgB,mBAAmB,IAAI,KAAK;EAClD,IAAI,CAAC,eAAe,MAAM,OAAO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M;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.js","names":[],"sources":["esm/selectionController.js"],"sourcesContent":["function 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 return getSelectLabelText(label.props?.children);\n }\n return \"\";\n}\nfunction createSelectItemRegistry(onChange) {\n const items = [];\n const labelRegistrations = /* @__PURE__ */ new Map();\n const explicitTextValues = /* @__PURE__ */ new Map();\n const itemNodes = /* @__PURE__ */ new Map();\n const listeners = /* @__PURE__ */ new Set();\n const notify = () => {\n onChange?.();\n listeners.forEach((listener) => listener());\n };\n const getItems = () => items;\n const getItem = (value) => items.find((item) => item.value === value);\n const getIndex = (value) => items.findIndex((item) => item.value === value);\n const getRegisteredLabel = (value) => {\n const registrations = labelRegistrations.get(value);\n if (!registrations?.size) return void 0;\n const values = Array.from(registrations.values());\n return values[values.length - 1];\n };\n const applyRegisteredLabel = (value) => {\n const registeredLabel = getRegisteredLabel(value);\n let changed = false;\n for (const item of items) {\n if (item.value !== value) continue;\n const nextLabel = registeredLabel?.label;\n const nextTextValue = explicitTextValues.get(item.id) || registeredLabel?.textValue;\n if (item.label !== nextLabel || item.textValue !== nextTextValue) {\n item.label = nextLabel;\n item.textValue = nextTextValue;\n changed = true;\n }\n }\n if (changed) notify();\n };\n const syncNodeOrder = () => {\n const previousOrder = items.map((item) => item.id);\n items.sort((a, b) => {\n const aNode = itemNodes.get(a.id);\n const bNode = itemNodes.get(b.id);\n if (!aNode || !bNode || typeof aNode.compareDocumentPosition !== \"function\") {\n return 0;\n }\n const position = aNode.compareDocumentPosition(bNode);\n if (position & 4) return -1;\n if (position & 2) return 1;\n return 0;\n });\n if (items.some((item, index) => item.id !== previousOrder[index])) {\n notify();\n }\n };\n const registerItem = (item) => {\n const id = Symbol(item.value);\n const registeredLabel = getRegisteredLabel(item.value);\n const registeredItem = {\n ...item,\n ...registeredLabel,\n textValue: item.textValue ?? 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 const index = items.findIndex((current2) => current2.id === id);\n if (index < 0) return;\n const current = items[index];\n if (\"textValue\" in next) {\n explicitTextValues.set(id, next.textValue);\n }\n const nextItem = { ...current, ...next };\n if (next.value !== void 0 && next.value !== current.value) {\n const nextLabel = getRegisteredLabel(next.value);\n nextItem.label = nextLabel?.label;\n }\n const explicitTextValue = explicitTextValues.get(id);\n nextItem.textValue = explicitTextValue || getSelectLabelText(nextItem.label) || (nextItem.label ? nextItem.value : void 0);\n const changed = Object.entries(next).some(\n ([key, value]) => current[key] !== value\n );\n const 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 const index = items.findIndex((current) => current.id === id);\n if (index < 0) return;\n items.splice(index, 1);\n explicitTextValues.delete(id);\n itemNodes.delete(id);\n notify();\n }\n };\n };\n const registerLabel = (value, label, textValue) => {\n const id = Symbol(value);\n const normalizedTextValue = textValue || getSelectLabelText(label) || value;\n const registrations = labelRegistrations.get(value) ?? (() => {\n const next = /* @__PURE__ */ new Map();\n labelRegistrations.set(value, next);\n return next;\n })();\n registrations.set(id, { label, textValue: normalizedTextValue });\n applyRegisteredLabel(value);\n return () => {\n registrations.delete(id);\n if (!registrations.size) {\n labelRegistrations.delete(value);\n }\n applyRegisteredLabel(value);\n };\n };\n const firstEnabledIndex = () => items.findIndex((item) => !item.disabled);\n const nextEnabledIndex = (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 (let index = items.length - 1; index >= 0; index--) {\n if (!items[index].disabled) return index;\n }\n return -1;\n }\n for (let offset = 1; offset <= items.length; offset++) {\n const index = (fromIndex + direction * offset + items.length) % items.length;\n if (!items[index]?.disabled) return index;\n }\n return -1;\n };\n const findTypeaheadIndex = (search, fromIndex) => {\n const normalizedSearch = search.trim().toLocaleLowerCase();\n if (!normalizedSearch) return -1;\n const start = fromIndex == null || fromIndex < 0 ? -1 : fromIndex;\n for (let offset = 1; offset <= items.length; offset++) {\n const index = (start + offset) % items.length;\n const item = items[index];\n const 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 () => {\n listeners.delete(listener);\n };\n },\n registerItem,\n registerLabel,\n getItems,\n getItem,\n getIndex,\n firstEnabledIndex,\n nextEnabledIndex,\n findTypeaheadIndex,\n getDisabledIndices: () => items.flatMap((item, index) => item.disabled ? [index] : []),\n getTypeaheadLabels: () => items.map((item) => item.textValue || getSelectLabelText(item.label) || item.value)\n };\n}\nfunction normalizeSelectSelection(mode, value) {\n if (mode === \"single\") {\n return typeof value === \"string\" ? value : \"\";\n }\n const values = Array.isArray(value) ? value : [];\n return [...new Set(values)];\n}\nfunction selectedValuesFromSelection(mode, value) {\n const normalized = normalizeSelectSelection(mode, value);\n return mode === \"multiple\" ? normalized : normalized ? [normalized] : [];\n}\nfunction createSelectSelectionController({\n mode: initialMode,\n value: initialValue,\n registry\n}) {\n let mode = initialMode;\n let value = normalizeSelectSelection(mode, initialValue);\n let activeIndex = null;\n const selectedValues = () => selectedValuesFromSelection(mode, value);\n const setMode = (nextMode) => {\n if (mode === nextMode) return value;\n mode = nextMode;\n value = normalizeSelectSelection(mode, value);\n return value;\n };\n const setValue = (nextValue) => {\n value = normalizeSelectSelection(mode, nextValue);\n return value;\n };\n const isSelected = (itemValue) => selectedValues().includes(itemValue);\n const toggle = (itemValue) => {\n const item = registry.getItem(itemValue);\n if (!item || item.disabled) return value;\n if (mode === \"single\") {\n value = itemValue;\n return value;\n }\n const current = selectedValues();\n value = current.includes(itemValue) ? current.filter((currentValue) => currentValue !== itemValue) : [...current, itemValue];\n return value;\n };\n const selectionAnchor = () => {\n const values = selectedValues();\n for (let index = values.length - 1; index >= 0; index--) {\n const item = registry.getItem(values[index]);\n if (item) return item;\n }\n const firstEnabledIndex = registry.firstEnabledIndex();\n return firstEnabledIndex < 0 ? void 0 : registry.getItems()[firstEnabledIndex];\n };\n const selectionAnchorIndex = () => {\n const anchor = selectionAnchor();\n return anchor ? registry.getIndex(anchor.value) : -1;\n };\n const initialActiveIndex = () => {\n const anchorIndex = selectionAnchorIndex();\n const anchor = anchorIndex < 0 ? void 0 : registry.getItems()[anchorIndex];\n return anchor && !anchor.disabled ? anchorIndex : registry.firstEnabledIndex();\n };\n const moveActive = (direction) => {\n const 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}\nexport {\n createSelectItemRegistry,\n createSelectSelectionController,\n getSelectLabelText,\n getSelectListboxProps,\n getSelectOptionProps,\n normalizeSelectSelection,\n selectedValuesFromSelection\n};\n//# sourceMappingURL=selectionController.js.map\n"],"mappings":";AAAA,SAAS,mBAAmB,OAAO;CACjC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;EAC1D,OAAO,OAAO,KAAK;CACrB;CACA,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,OAAO,MAAM,IAAI,kBAAkB,CAAC,CAAC,KAAK,EAAE;CAC9C;CACA,IAAI,SAAS,OAAO,UAAU,YAAY,WAAW,OAAO;EAC1D,OAAO,mBAAmB,MAAM,OAAO,QAAQ;CACjD;CACA,OAAO;AACT;AACA,SAAS,yBAAyB,UAAU;CAC1C,MAAM,QAAQ,CAAC;CACf,MAAM,qCAAqC,IAAI,IAAI;CACnD,MAAM,qCAAqC,IAAI,IAAI;CACnD,MAAM,4BAA4B,IAAI,IAAI;CAC1C,MAAM,4BAA4B,IAAI,IAAI;CAC1C,MAAM,eAAe;EACnB,WAAW;EACX,UAAU,SAAS,aAAa,SAAS,CAAC;CAC5C;CACA,MAAM,iBAAiB;CACvB,MAAM,WAAW,UAAU,MAAM,MAAM,SAAS,KAAK,UAAU,KAAK;CACpE,MAAM,YAAY,UAAU,MAAM,WAAW,SAAS,KAAK,UAAU,KAAK;CAC1E,MAAM,sBAAsB,UAAU;EACpC,M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AClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe,OAAO;GACpB,cAAc;EAChB;EACA;CACF;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectionController.native.js","names":[],"sources":["esm/selectionController.native.js"],"sourcesContent":["function _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}\nexport {\n createSelectItemRegistry,\n createSelectSelectionController,\n getSelectLabelText,\n getSelectListboxProps,\n getSelectOptionProps,\n normalizeSelectSelection,\n selectedValuesFromSelection\n};\n//# sourceMappingURL=selectionController.js.map\n"],"mappings":";AAAA,SAAS,SAAS,KAAK;CACrB;CACA,OAAO,OAAO,OAAO,WAAW,eAAe,IAAI,gBAAgB,SAAS,WAAW,OAAO;AAChG;AACA,SAAS,mBAAmB,OAAO;CACjC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;EAC1D,OAAO,OAAO,KAAK;CACrB;CACA,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,OAAO,MAAM,IAAI,kBAAkB,EAAE,KAAK,EAAE;CAC9C;CACA,IAAI,UAAU,OAAO,UAAU,cAAc,cAAc,SAAS,KAAK,OAAO,YAAY,WAAW,OAAO;EAC5G,IAAI;EACJ,OAAO,oBAAoB,eAAe,MAAM,WAAW,QAAQ,iBAAiB,KAAK,IAAI,KAAK,IAAI,aAAa,QAAQ;CAC7H;CACA,OAAO;AACT;AACA,SAAS,yBAAyB,UAAU;CAC1C,IAAI,QAAQ,CAAC;CACb,IAAI,qCAAqC,IAAI,IAAI;CACjD,IAAI,qCAAqC,IAAI,IAAI;CACjD,IAAI,4BAA4B,IAAI,IAAI;CACxC,IAAI,4BAA4B,IAAI,IAAI;CACxC,IAAI,SAAS,WAAW;EACtB,aAAa,QAAQ,aAAa,KAAK,IAAI,KAAK,IAAI,SAAS;EAC7D,UAAU,QAAQ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KAAK,IAAI,SAAS,SAAS,EAAE;CAC5D;CACA,OAAO;EACL;EACA,IAAI,OAAO;GACT,OAAO;EACT;EACA,IAAI,QAAQ;GACV,OAAO;EACT;EACA,IAAI,cAAc;GAChB,OAAO;EACT;EACA,IAAI,aAAa;GACf,OAAO,eAAe,OAAO,KAAK,IAAI,SAAS,SAAS,EAAE;EAC5D;EACA,IAAI,sBAAsB;GACxB,OAAO,SAAS;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe,OAAO;GACpB,cAAc;EAChB;EACA;CACF;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":["esm/selectionController.native.js"],"sourcesContent":["function _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}\nexport {\n createSelectItemRegistry,\n createSelectSelectionController,\n getSelectLabelText,\n getSelectListboxProps,\n getSelectOptionProps,\n normalizeSelectSelection,\n selectedValuesFromSelection\n};\n//# sourceMappingURL=selectionController.js.map\n"],"mappings":";AAAA,SAAS,SAAS,KAAK;CACrB;CACA,OAAO,OAAO,OAAO,WAAW,eAAe,IAAI,gBAAgB,SAAS,WAAW,OAAO;AAChG;AACA,SAAS,mBAAmB,OAAO;CACjC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;EAC1D,OAAO,OAAO,KAAK;CACrB;CACA,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,OAAO,MAAM,IAAI,kBAAkB,CAAC,CAAC,KAAK,EAAE;CAC9C;CACA,IAAI,UAAU,OAAO,UAAU,cAAc,cAAc,SAAS,KAAK,OAAO,YAAY,WAAW,OAAO;EAC5G,IAAI;EACJ,OAAO,oBAAoB,eAAe,MAAM,WAAW,QAAQ,iBAAiB,KAAK,IAAI,KAAK,IAAI,aAAa,QAAQ;CAC7H;CACA,OAAO;AACT;AACA,SAAS,yBAAyB,UAAU;C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