@tamagui/select 1.0.1-beta.21 → 1.0.1-beta.210

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/cjs/BubbleSelect.js +43 -0
  2. package/dist/cjs/BubbleSelect.js.map +7 -0
  3. package/dist/cjs/Select.js +412 -390
  4. package/dist/cjs/Select.js.map +3 -3
  5. package/dist/cjs/SelectContent.js +72 -0
  6. package/dist/cjs/SelectContent.js.map +7 -0
  7. package/dist/cjs/SelectContent.native.js +31 -0
  8. package/dist/cjs/SelectContent.native.js.map +7 -0
  9. package/dist/cjs/SelectImpl.js +286 -0
  10. package/dist/cjs/SelectImpl.js.map +7 -0
  11. package/dist/cjs/SelectScrollButton.js +157 -0
  12. package/dist/cjs/SelectScrollButton.js.map +7 -0
  13. package/dist/cjs/SelectScrollButton.native.js +32 -0
  14. package/dist/cjs/SelectScrollButton.native.js.map +7 -0
  15. package/dist/cjs/SelectViewport.js +126 -0
  16. package/dist/cjs/SelectViewport.js.map +7 -0
  17. package/dist/cjs/SelectViewport.native.js +41 -0
  18. package/dist/cjs/SelectViewport.native.js.map +7 -0
  19. package/dist/cjs/constants.js +47 -0
  20. package/dist/cjs/constants.js.map +7 -0
  21. package/dist/cjs/context.js +49 -0
  22. package/dist/cjs/context.js.map +7 -0
  23. package/dist/cjs/index.js +2 -0
  24. package/dist/cjs/index.js.map +2 -2
  25. package/dist/cjs/types.js +17 -0
  26. package/dist/cjs/types.js.map +7 -0
  27. package/dist/cjs/useSelectBreakpointActive.js +39 -0
  28. package/dist/cjs/useSelectBreakpointActive.js.map +7 -0
  29. package/dist/esm/BubbleSelect.js +24 -0
  30. package/dist/esm/BubbleSelect.js.map +7 -0
  31. package/dist/esm/Select.js +403 -358
  32. package/dist/esm/Select.js.map +3 -3
  33. package/dist/esm/SelectContent.js +48 -0
  34. package/dist/esm/SelectContent.js.map +7 -0
  35. package/dist/esm/SelectContent.native.js +7 -0
  36. package/dist/esm/SelectContent.native.js.map +7 -0
  37. package/dist/esm/SelectImpl.js +271 -0
  38. package/dist/esm/SelectImpl.js.map +7 -0
  39. package/dist/esm/SelectScrollButton.js +126 -0
  40. package/dist/esm/SelectScrollButton.js.map +7 -0
  41. package/dist/esm/SelectScrollButton.native.js +7 -0
  42. package/dist/esm/SelectScrollButton.native.js.map +7 -0
  43. package/dist/esm/SelectViewport.js +95 -0
  44. package/dist/esm/SelectViewport.js.map +7 -0
  45. package/dist/esm/SelectViewport.native.js +17 -0
  46. package/dist/esm/SelectViewport.native.js.map +7 -0
  47. package/dist/esm/constants.js +17 -0
  48. package/dist/esm/constants.js.map +7 -0
  49. package/dist/esm/context.js +21 -0
  50. package/dist/esm/context.js.map +7 -0
  51. package/dist/esm/index.js +1 -0
  52. package/dist/esm/index.js.map +2 -2
  53. package/dist/esm/types.js +1 -0
  54. package/dist/esm/types.js.map +7 -0
  55. package/dist/esm/useSelectBreakpointActive.js +14 -0
  56. package/dist/esm/useSelectBreakpointActive.js.map +7 -0
  57. package/dist/jsx/BubbleSelect.js +24 -0
  58. package/dist/jsx/BubbleSelect.js.map +7 -0
  59. package/dist/jsx/Select.js +283 -271
  60. package/dist/jsx/Select.js.map +7 -0
  61. package/dist/jsx/SelectContent.js +27 -0
  62. package/dist/jsx/SelectContent.js.map +7 -0
  63. package/dist/jsx/SelectContent.native.js +7 -0
  64. package/dist/jsx/SelectContent.native.js.map +7 -0
  65. package/dist/jsx/SelectImpl.js +244 -0
  66. package/dist/jsx/SelectImpl.js.map +7 -0
  67. package/dist/jsx/SelectScrollButton.js +99 -0
  68. package/dist/jsx/SelectScrollButton.js.map +7 -0
  69. package/dist/jsx/SelectScrollButton.native.js +7 -0
  70. package/dist/jsx/SelectScrollButton.native.js.map +7 -0
  71. package/dist/jsx/SelectViewport.js +72 -0
  72. package/dist/jsx/SelectViewport.js.map +7 -0
  73. package/dist/jsx/SelectViewport.native.js +13 -0
  74. package/dist/jsx/SelectViewport.native.js.map +7 -0
  75. package/dist/jsx/constants.js +17 -0
  76. package/dist/jsx/constants.js.map +7 -0
  77. package/dist/jsx/context.js +15 -0
  78. package/dist/jsx/context.js.map +7 -0
  79. package/dist/jsx/index.js +2 -0
  80. package/dist/jsx/index.js.map +7 -0
  81. package/dist/jsx/types.js +1 -0
  82. package/dist/jsx/types.js.map +7 -0
  83. package/dist/jsx/useSelectBreakpointActive.js +14 -0
  84. package/dist/jsx/useSelectBreakpointActive.js.map +7 -0
  85. package/package.json +26 -16
  86. package/src/BubbleSelect.tsx +46 -0
  87. package/src/Select.tsx +618 -0
  88. package/src/SelectContent.native.tsx +5 -0
  89. package/src/SelectContent.tsx +45 -0
  90. package/src/SelectImpl.tsx +342 -0
  91. package/src/SelectScrollButton.native.tsx +7 -0
  92. package/src/SelectScrollButton.tsx +168 -0
  93. package/src/SelectViewport.native.tsx +14 -0
  94. package/src/SelectViewport.tsx +104 -0
  95. package/src/constants.tsx +7 -0
  96. package/src/context.tsx +19 -0
  97. package/src/index.tsx +8 -0
  98. package/src/types.tsx +94 -0
  99. package/src/useSelectBreakpointActive.tsx +15 -0
  100. package/types/BubbleSelect.d.ts +2 -0
  101. package/types/Select.d.ts +753 -0
  102. package/types/SelectContent.d.ts +5 -0
  103. package/types/SelectContent.native.d.ts +4 -0
  104. package/types/SelectImpl.d.ts +9 -0
  105. package/types/SelectScrollButton.d.ts +6 -0
  106. package/types/SelectScrollButton.native.d.ts +4 -0
  107. package/types/SelectViewport.d.ts +127 -0
  108. package/types/SelectViewport.native.d.ts +7 -0
  109. package/types/constants.d.ts +8 -0
  110. package/types/context.d.ts +21 -0
  111. package/types/index.d.ts +2 -0
  112. package/types/types.d.ts +84 -0
  113. package/types/useSelectBreakpointActive.d.ts +4 -0
  114. package/types/index.d.ts.map +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Select.tsx"],
4
+ "sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\nimport { GetProps, TamaguiElement, isClient, isWeb } from '@tamagui/core'\nimport { styled, useGet, useIsomorphicLayoutEffect, withStaticProperties } from '@tamagui/core'\nimport { useId } from '@tamagui/core'\nimport { ListItem, ListItemProps } from '@tamagui/list-item'\nimport { PortalHost } from '@tamagui/portal'\nimport { Separator } from '@tamagui/separator'\nimport { ControlledSheet, SheetController } from '@tamagui/sheet'\nimport { XStack, YStack, YStackProps } from '@tamagui/stacks'\nimport { Paragraph } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\nimport * as ReactDOM from 'react-dom'\n\nimport { SELECT_NAME } from './constants'\nimport { SelectProvider, createSelectContext, useSelectContext } from './context'\nimport { SelectContent } from './SelectContent'\nimport { SelectImplProps, SelectInlineImpl } from './SelectImpl'\nimport { SelectScrollDownButton, SelectScrollUpButton } from './SelectScrollButton'\nimport { SelectViewport } from './SelectViewport'\nimport { ScopedProps, SelectProps } from './types'\nimport { useSelectBreakpointActive, useShowSelectSheet } from './useSelectBreakpointActive'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'SelectTrigger'\n\nexport type SelectTriggerProps = ListItemProps\n\nexport const SelectTrigger = React.forwardRef<TamaguiElement, SelectTriggerProps>(\n (props: ScopedProps<SelectTriggerProps>, forwardedRef) => {\n const {\n __scopeSelect,\n disabled = false,\n // @ts-ignore\n 'aria-labelledby': ariaLabelledby,\n ...triggerProps\n } = props\n const context = useSelectContext(TRIGGER_NAME, __scopeSelect)\n // const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange)\n // const getItems = useCollection(__scopeSelect)\n // const labelId = useLabelContext(context.trigger)\n const labelledBy = ariaLabelledby // || labelId\n\n return (\n <ListItem\n componentName={TRIGGER_NAME}\n backgrounded\n radiused\n hoverTheme\n pressTheme\n focusTheme\n focusable\n borderWidth={1}\n size={context.size}\n // aria-controls={context.contentId}\n aria-expanded={context.open}\n aria-autocomplete=\"none\"\n aria-labelledby={labelledBy}\n dir={context.dir}\n disabled={disabled}\n data-disabled={disabled ? '' : undefined}\n {...triggerProps}\n ref={forwardedRef}\n {...(process.env.TAMAGUI_TARGET === 'web' && context.interactions\n ? context.interactions.getReferenceProps()\n : {\n onPress() {\n context.setOpen(!context.open)\n },\n })}\n />\n )\n }\n)\n\nSelectTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectValue\n * -----------------------------------------------------------------------------------------------*/\n\nconst VALUE_NAME = 'SelectValue'\n\nconst SelectValueFrame = styled(Paragraph, {\n name: VALUE_NAME,\n selectable: false,\n})\n\ntype SelectValueProps = GetProps<typeof SelectValueFrame> & {\n placeholder?: React.ReactNode\n}\n\nconst SelectValue = SelectValueFrame.extractable(\n React.forwardRef<TamaguiElement, SelectValueProps>(\n (\n { __scopeSelect, children: childrenProp, placeholder }: ScopedProps<SelectValueProps>,\n forwardedRef\n ) => {\n // We ignore `className` and `style` as this part shouldn't be styled.\n const context = useSelectContext(VALUE_NAME, __scopeSelect)\n const { onValueNodeHasChildrenChange } = context\n const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange)\n\n const children = childrenProp ?? context.selectedItem\n const hasChildren = !!children\n const selectValueChildren =\n context.value === undefined && placeholder !== undefined ? placeholder : children\n\n useIsomorphicLayoutEffect(() => {\n onValueNodeHasChildrenChange(hasChildren)\n }, [onValueNodeHasChildrenChange, hasChildren])\n\n return (\n <SelectValueFrame\n size={context.size}\n ref={composedRefs}\n // we don't want events from the portalled `SelectValue` children to bubble\n // through the item they came from\n pointerEvents=\"none\"\n >\n {selectValueChildren}\n </SelectValueFrame>\n )\n }\n )\n)\n\nSelectValue.displayName = VALUE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectIcon\n * -----------------------------------------------------------------------------------------------*/\n\nexport const SelectIcon = styled(XStack, {\n name: 'SelectIcon',\n // @ts-ignore\n 'aria-hidden': true,\n children: <Paragraph>\u25BC</Paragraph>,\n})\n\n/* -------------------------------------------------------------------------------------------------\n * SelectItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'SelectItem'\n\ntype SelectItemContextValue = {\n value: string\n textId: string\n isSelected: boolean\n}\n\nconst [SelectItemContextProvider, useSelectItemContext] =\n createSelectContext<SelectItemContextValue>(ITEM_NAME)\n\nexport interface SelectItemProps extends YStackProps {\n value: string\n index: number\n disabled?: boolean\n textValue?: string\n}\n\nexport const SelectItem = React.forwardRef<TamaguiElement, SelectItemProps>(\n (props: ScopedProps<SelectItemProps>, forwardedRef) => {\n const {\n __scopeSelect,\n value,\n disabled = false,\n textValue: textValueProp,\n index,\n ...itemProps\n } = props\n const context = useSelectContext(ITEM_NAME, __scopeSelect)\n const isSelected = context.value === value\n const textId = useId()\n\n const {\n selectedIndex,\n setSelectedIndex,\n listRef,\n open,\n setOpen,\n onChange,\n setActiveIndex,\n allowMouseUpRef,\n allowSelectRef,\n setValueAtIndex,\n selectTimeoutRef,\n dataRef,\n } = context\n\n const composedRefs = useComposedRefs(forwardedRef, (node) => {\n if (!isWeb) return\n if (node instanceof HTMLElement) {\n if (listRef) {\n listRef.current[index] = node\n }\n }\n })\n\n React.useEffect(() => {\n setValueAtIndex(index, value)\n }, [index, setValueAtIndex, value])\n\n function handleSelect() {\n setSelectedIndex(index)\n onChange(value)\n setOpen(false)\n }\n\n const selectItemProps = context.interactions\n ? context.interactions.getItemProps({\n onTouchStart() {\n allowSelectRef!.current = true\n allowMouseUpRef!.current = false\n },\n onKeyDown(event) {\n if (event.key === 'Enter' || (event.key === ' ' && !dataRef?.current.typing)) {\n event.preventDefault()\n handleSelect()\n } else {\n allowSelectRef!.current = true\n }\n },\n onClick() {\n if (allowSelectRef!.current) {\n setSelectedIndex(index)\n setOpen(false)\n }\n },\n onMouseUp() {\n if (!allowMouseUpRef!.current) {\n return\n }\n\n if (allowSelectRef!.current) {\n handleSelect()\n }\n\n // On touch devices, prevent the element from\n // immediately closing `onClick` by deferring it\n clearTimeout(selectTimeoutRef!.current)\n selectTimeoutRef!.current = setTimeout(() => {\n allowSelectRef!.current = true\n })\n },\n })\n : {\n onPress: handleSelect,\n }\n\n return (\n <SelectItemContextProvider\n scope={__scopeSelect}\n value={value}\n textId={textId || ''}\n isSelected={isSelected}\n >\n <ListItem\n backgrounded\n pressTheme\n cursor=\"\"\n focusTheme\n componentName={ITEM_NAME}\n ref={composedRefs}\n aria-labelledby={textId}\n aria-selected={isSelected}\n data-state={isSelected ? 'active' : 'inactive'}\n aria-disabled={disabled || undefined}\n data-disabled={disabled ? '' : undefined}\n tabIndex={disabled ? undefined : -1}\n size={context.size}\n {...itemProps}\n {...selectItemProps}\n />\n </SelectItemContextProvider>\n )\n }\n)\n\nSelectItem.displayName = ITEM_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectItemText\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_TEXT_NAME = 'SelectItemText'\n\nexport const SelectItemTextFrame = styled(Paragraph, {\n name: ITEM_TEXT_NAME,\n selectable: false,\n})\n\ntype SelectItemTextProps = GetProps<typeof SelectItemTextFrame>\n\nconst SelectItemText = React.forwardRef<TamaguiElement, SelectItemTextProps>(\n (props: ScopedProps<SelectItemTextProps>, forwardedRef) => {\n const { __scopeSelect, className, ...itemTextProps } = props\n const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect)\n const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect)\n const ref = React.useRef<TamaguiElement | null>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref)\n const isSelected = Boolean(itemContext.isSelected && context.valueNode)\n\n const contents = React.useMemo(\n () => (\n <SelectItemTextFrame\n className={className}\n size={context.size}\n id={itemContext.textId}\n {...itemTextProps}\n ref={composedRefs}\n />\n ),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [props, context.size, className, itemContext.textId]\n )\n\n // until portals work in sub-trees on RN, use this just for native:\n React.useEffect(() => {\n if (isSelected) {\n context.setSelectedItem(contents)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isSelected, contents])\n\n return (\n <>\n {contents}\n\n {/* Portal the select item text into the trigger value node */}\n {/* this needs some extra stability between renders */}\n {/* {isWeb && isSelected\n ? ReactDOM.createPortal(itemTextProps.children, context.valueNode!)\n : null} */}\n\n {/* Portal an option in the bubble select */}\n {/* {context.bubbleSelect\n ? ReactDOM.createPortal(\n // we use `.textContent` because `option` only support `string` or `number`\n <option value={itemContext.value}>{ref.current?.textContent}</option>,\n context.bubbleSelect\n )\n : null} */}\n </>\n )\n }\n)\n\nSelectItemText.displayName = ITEM_TEXT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectItemIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_INDICATOR_NAME = 'SelectItemIndicator'\n\nconst SelectItemIndicatorFrame = styled(XStack, {\n name: ITEM_TEXT_NAME,\n})\n\ntype SelectItemIndicatorProps = GetProps<typeof SelectItemIndicatorFrame>\n\nconst SelectItemIndicator = React.forwardRef<TamaguiElement, SelectItemIndicatorProps>(\n (props: ScopedProps<SelectItemIndicatorProps>, forwardedRef) => {\n const { __scopeSelect, ...itemIndicatorProps } = props\n const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect)\n return itemContext.isSelected ? (\n <SelectItemIndicatorFrame aria-hidden {...itemIndicatorProps} ref={forwardedRef} />\n ) : null\n }\n)\n\nSelectItemIndicator.displayName = ITEM_INDICATOR_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst GROUP_NAME = 'SelectGroup'\n\ntype SelectGroupContextValue = { id: string }\n\nconst [SelectGroupContextProvider, useSelectGroupContext] =\n createSelectContext<SelectGroupContextValue>(GROUP_NAME)\n\nexport const SelectGroupFrame = styled(YStack, {\n name: GROUP_NAME,\n width: '100%',\n})\n\ntype SelectGroupProps = GetProps<typeof SelectGroupFrame>\n\nconst SelectGroup = React.forwardRef<TamaguiElement, SelectGroupProps>(\n (props: ScopedProps<SelectGroupProps>, forwardedRef) => {\n const { __scopeSelect, ...groupProps } = props\n const groupId = useId()\n return (\n <SelectGroupContextProvider scope={__scopeSelect} id={groupId || ''}>\n <SelectGroupFrame\n // @ts-ignore\n role=\"group\"\n aria-labelledby={groupId}\n {...groupProps}\n ref={forwardedRef}\n />\n </SelectGroupContextProvider>\n )\n }\n)\n\nSelectGroup.displayName = GROUP_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectLabel\n * -----------------------------------------------------------------------------------------------*/\n\nconst LABEL_NAME = 'SelectLabel'\n\nexport type SelectLabelProps = ListItemProps\n\nconst SelectLabel = React.forwardRef<TamaguiElement, SelectLabelProps>(\n (props: ScopedProps<SelectLabelProps>, forwardedRef) => {\n const { __scopeSelect, ...labelProps } = props\n const context = useSelectContext(LABEL_NAME, __scopeSelect)\n const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect)\n return (\n <ListItem\n componentName={LABEL_NAME}\n fontWeight=\"800\"\n id={groupContext.id}\n size={context.size}\n {...labelProps}\n ref={forwardedRef}\n />\n )\n }\n)\n\nSelectLabel.displayName = LABEL_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectSeparator\n * -----------------------------------------------------------------------------------------------*/\n\nexport const SelectSeparator = styled(Separator, {\n name: 'SelectSeparator',\n})\n\nconst SelectSheetController = (\n props: ScopedProps<{}> & {\n children: React.ReactNode\n onOpenChange: React.Dispatch<React.SetStateAction<boolean>>\n }\n) => {\n const context = useSelectContext('SelectSheetController', props.__scopeSelect)\n const showSheet = useShowSelectSheet(context)\n const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint)\n const getShowSheet = useGet(showSheet)\n\n return (\n <SheetController\n onOpenChange={(val) => {\n if (getShowSheet()) {\n props.onOpenChange(val)\n }\n }}\n open={context.open}\n hidden={breakpointActive === false}\n >\n {props.children}\n </SheetController>\n )\n}\n\n/* -------------------------------------------------------------------------------------------------\n * SelectSheetContents\n * -----------------------------------------------------------------------------------------------*/\n\nconst SHEET_CONTENTS_NAME = 'SelectSheetContents'\n\nexport const SelectSheetContents = ({ __scopeSelect }: ScopedProps<{}>) => {\n const context = useSelectContext(SHEET_CONTENTS_NAME, __scopeSelect)\n return <PortalHost name={`${context.scopeKey}SheetContents`} />\n}\n\nSelectSheetContents.displayName = SHEET_CONTENTS_NAME\n\nconst SelectSheetImpl = (props: SelectImplProps) => {\n return <>{props.children}</>\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Select\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Select = withStaticProperties(\n (props: ScopedProps<SelectProps>) => {\n const {\n __scopeSelect,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n value: valueProp,\n defaultValue,\n onValueChange,\n size: sizeProp = '$4',\n sheetBreakpoint = false,\n dir,\n } = props\n\n const isSheet = useSelectBreakpointActive(sheetBreakpoint)\n const SelectImpl = isSheet ? SelectSheetImpl : SelectInlineImpl\n const forceUpdate = React.useReducer(() => ({}), {})[1]\n const [selectedItem, setSelectedItem] = React.useState<React.ReactNode>(null)\n\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen || false,\n onChange: onOpenChange,\n strategy: 'most-recent-wins',\n })\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue || '',\n onChange: onValueChange,\n strategy: 'most-recent-wins',\n })\n\n const [activeIndex, setActiveIndex] = React.useState<number | null>(null)\n const selectedIndexRef = React.useRef<number | null>(null)\n const activeIndexRef = React.useRef<number | null>(null)\n\n const listContentRef = React.useRef<string[]>([])\n\n const [selectedIndex, setSelectedIndex] = React.useState(\n Math.max(0, listContentRef.current.indexOf(value))\n )\n\n const [valueNode, setValueNode] = React.useState<HTMLElement | null>(null)\n const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false)\n\n useIsomorphicLayoutEffect(() => {\n selectedIndexRef.current = selectedIndex\n activeIndexRef.current = activeIndex\n })\n\n const id = useId()\n const scopeKey = __scopeSelect ? Object.keys(__scopeSelect)[0] ?? id : id\n\n return (\n <SelectProvider\n dir={dir}\n blockSelection={false}\n size={sizeProp}\n fallback={false}\n selectedItem={selectedItem}\n setSelectedItem={setSelectedItem}\n forceUpdate={forceUpdate}\n valueNode={valueNode}\n onValueNodeChange={setValueNode}\n onValueNodeHasChildrenChange={setValueNodeHasChildren}\n valueNodeHasChildren={valueNodeHasChildren}\n scopeKey={scopeKey}\n sheetBreakpoint={sheetBreakpoint}\n scope={__scopeSelect}\n setValueAtIndex={(index, value) => {\n listContentRef.current[index] = value\n }}\n activeIndex={activeIndex}\n onChange={setValue}\n selectedIndex={selectedIndex}\n setActiveIndex={setActiveIndex}\n setOpen={setOpen}\n setSelectedIndex={setSelectedIndex}\n value={value}\n open={open}\n >\n <SelectSheetController onOpenChange={setOpen} __scopeSelect={__scopeSelect}>\n <SelectImpl\n activeIndexRef={activeIndexRef}\n listContentRef={listContentRef}\n selectedIndexRef={selectedIndexRef}\n {...props}\n open={open}\n value={value}\n >\n {children}\n </SelectImpl>\n </SelectSheetController>\n </SelectProvider>\n )\n },\n {\n Content: SelectContent,\n Group: SelectGroup,\n Icon: SelectIcon,\n Item: SelectItem,\n ItemIndicator: SelectItemIndicator,\n ItemText: SelectItemText,\n Label: SelectLabel,\n ScrollDownButton: SelectScrollDownButton,\n ScrollUpButton: SelectScrollUpButton,\n Trigger: SelectTrigger,\n Value: SelectValue,\n Viewport: SelectViewport,\n SheetContents: SelectSheetContents,\n Sheet: ControlledSheet,\n }\n)\n\n// @ts-ignore\nSelect.displayName = SELECT_NAME\n"],
5
+ "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAA6C,aAAa;AAC1D,SAAS,QAAQ,QAAQ,2BAA2B,4BAA4B;AAChF,SAAS,aAAa;AACtB,SAAS,gBAA+B;AACxC,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,QAAQ,cAA2B;AAC5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M,KAAK;AAEvE,WACE,CAAC,eACC,KAAK,KACL,gBAAgB,OAChB,MAAM,UACN,UAAU,OACV,cAAc,cACd,iBAAiB,iBACjB,aAAa,aACb,WAAW,WACX,mBAAmB,cACnB,8BAA8B,yBAC9B,sBAAsB,sBACtB,UAAU,UACV,iBAAiB,iBACjB,OAAO,eACP,iBAAiB,CAAC,OAAOA,WAAU;AACjC,qBAAe,QAAQ,SAASA;AAAA,IAClC,GACA,aAAa,aACb,UAAU,UACV,eAAe,eACf,gBAAgB,gBAChB,SAAS,SACT,kBAAkB,kBAClB,OAAO,OACP,MAAM,MAEN,CAAC,sBAAsB,cAAc,SAAS,eAAe,eAC3D,CAAC,WACC,gBAAgB,gBAChB,gBAAgB,gBAChB,kBAAkB,sBACd,OACJ,MAAM,MACN,OAAO,QAEN,SACH,EATC,WAUH,EAXC,sBAYH,EAvCC;AAAA,EAyCL;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,OAAO;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,IACN,eAAe;AAAA,IACf,UAAU;AAAA,IACV,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,SAAS;AAAA,IACT,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,IACf,OAAO;AAAA,EACT;AACF;AAGA,OAAO,cAAc;",
6
+ "names": ["value"]
7
+ }
@@ -0,0 +1,27 @@
1
+ import { FloatingOverlay, FloatingPortal } from "@floating-ui/react-dom-interactions";
2
+ import { Theme, useIsTouchDevice, useThemeName } from "@tamagui/core";
3
+ import { Dismissable } from "@tamagui/dismissable";
4
+ import { FocusScope } from "@tamagui/focus-scope";
5
+ import { useSelectContext } from "./context";
6
+ import { useShowSelectSheet } from "./useSelectBreakpointActive";
7
+ const CONTENT_NAME = "SelectContent";
8
+ const SelectContent = ({
9
+ children,
10
+ __scopeSelect,
11
+ zIndex = 1e3,
12
+ ...focusScopeProps
13
+ }) => {
14
+ const context = useSelectContext(CONTENT_NAME, __scopeSelect);
15
+ const themeName = useThemeName();
16
+ const showSheet = useShowSelectSheet(context);
17
+ const contents = <Theme name={themeName}>{children}</Theme>;
18
+ const touch = useIsTouchDevice();
19
+ if (showSheet && context.open) {
20
+ return contents;
21
+ }
22
+ return <FloatingPortal>{context.open ? <FloatingOverlay style={{ zIndex }} lockScroll={!touch}><FocusScope loop trapped {...focusScopeProps}><Dismissable disableOutsidePointerEvents>{contents}</Dismissable></FocusScope></FloatingOverlay> : <div style={{ display: "none" }}>{contents}</div>}</FloatingPortal>;
23
+ };
24
+ export {
25
+ SelectContent
26
+ };
27
+ //# sourceMappingURL=SelectContent.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/SelectContent.tsx"],
4
+ "sourcesContent": ["import { FloatingOverlay, FloatingPortal } from '@floating-ui/react-dom-interactions'\nimport { Theme, useIsTouchDevice, useThemeName } from '@tamagui/core'\nimport { Dismissable } from '@tamagui/dismissable'\nimport { FocusScope, FocusScopeProps } from '@tamagui/focus-scope'\n\nimport { useSelectContext } from './context'\nimport { SelectContentProps } from './types'\nimport { useShowSelectSheet } from './useSelectBreakpointActive'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'SelectContent'\n\nexport const SelectContent = ({\n children,\n __scopeSelect,\n zIndex = 1000,\n ...focusScopeProps\n}: SelectContentProps & FocusScopeProps) => {\n const context = useSelectContext(CONTENT_NAME, __scopeSelect)\n const themeName = useThemeName()\n const showSheet = useShowSelectSheet(context)\n const contents = <Theme name={themeName}>{children}</Theme>\n const touch = useIsTouchDevice()\n\n if (showSheet && context.open) {\n return contents\n }\n\n return (\n <FloatingPortal>\n {context.open ? (\n <FloatingOverlay style={{ zIndex }} lockScroll={!touch}>\n <FocusScope loop trapped {...focusScopeProps}>\n <Dismissable disableOutsidePointerEvents>{contents}</Dismissable>\n </FocusScope>\n </FloatingOverlay>\n ) : (\n <div style={{ display: 'none' }}>{contents}</div>\n )}\n </FloatingPortal>\n )\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,OAAO,kBAAkB,oBAAoB;AACtD,SAAS,mBAAmB;AAC5B,SAAS,kBAAmC;AAE5C,SAAS,wBAAwB;AAEjC,SAAS,0BAA0B;AAMnC,MAAM,eAAe;AAEd,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,SAAS;AAAA,KACN;AACL,MAA4C;AAC1C,QAAM,UAAU,iBAAiB,cAAc,aAAa;AAC5D,QAAM,YAAY,aAAa;AAC/B,QAAM,YAAY,mBAAmB,OAAO;AAC5C,QAAM,WAAW,CAAC,MAAM,MAAM,YAAY,SAAS,EAAjC;AAClB,QAAM,QAAQ,iBAAiB;AAE/B,MAAI,aAAa,QAAQ,MAAM;AAC7B,WAAO;AAAA,EACT;AAEA,SACE,CAAC,gBACE,QAAQ,OACP,CAAC,gBAAgB,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,OAC/C,CAAC,WAAW,KAAK,YAAY,iBAC3B,CAAC,YAAY,6BAA6B,SAAS,EAAlD,YACH,EAFC,WAGH,EAJC,mBAMD,CAAC,IAAI,OAAO,EAAE,SAAS,OAAO,IAAI,SAAS,EAA1C,KAEL,EAVC;AAYL;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ const SelectContent = ({ children }) => {
2
+ return children;
3
+ };
4
+ export {
5
+ SelectContent
6
+ };
7
+ //# sourceMappingURL=SelectContent.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/SelectContent.native.tsx"],
4
+ "sourcesContent": ["import { SelectContentProps } from './types'\n\nexport const SelectContent = ({ children }: SelectContentProps) => {\n return children\n}\n"],
5
+ "mappings": "AAEO,MAAM,gBAAgB,CAAC,EAAE,SAAS,MAA0B;AACjE,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,244 @@
1
+ import {
2
+ autoUpdate,
3
+ flip,
4
+ inner,
5
+ offset,
6
+ shift,
7
+ size,
8
+ useClick,
9
+ useDismiss,
10
+ useFloating,
11
+ useInnerOffset,
12
+ useInteractions,
13
+ useListNavigation,
14
+ useRole,
15
+ useTypeahead
16
+ } from "@floating-ui/react-dom-interactions";
17
+ import { useIsTouchDevice, useIsomorphicLayoutEffect } from "@tamagui/core";
18
+ import * as React from "react";
19
+ import { flushSync } from "react-dom";
20
+ import { SCROLL_ARROW_THRESHOLD, WINDOW_PADDING } from "./constants";
21
+ import { SelectProvider, useSelectContext } from "./context";
22
+ const SelectInlineImpl = (props) => {
23
+ const { __scopeSelect, children, open = false, selectedIndexRef, listContentRef } = props;
24
+ const selectContext = useSelectContext("SelectSheetImpl", __scopeSelect);
25
+ const { setActiveIndex, setOpen, setSelectedIndex, selectedIndex, activeIndex, forceUpdate } = selectContext;
26
+ const [scrollTop, setScrollTop] = React.useState(0);
27
+ const touch = useIsTouchDevice();
28
+ const listItemsRef = React.useRef([]);
29
+ const overflowRef = React.useRef(null);
30
+ const upArrowRef = React.useRef(null);
31
+ const downArrowRef = React.useRef(null);
32
+ const allowSelectRef = React.useRef(false);
33
+ const allowMouseUpRef = React.useRef(true);
34
+ const selectTimeoutRef = React.useRef();
35
+ const state = React.useRef({
36
+ isMouseOutside: false
37
+ });
38
+ const [controlledScrolling, setControlledScrolling] = React.useState(false);
39
+ const [fallback, setFallback] = React.useState(false);
40
+ const [innerOffset, setInnerOffset] = React.useState(0);
41
+ const [blockSelection, setBlockSelection] = React.useState(false);
42
+ const floatingStyle = React.useRef({});
43
+ React.useEffect(() => {
44
+ const frame = requestAnimationFrame(() => {
45
+ if (!open) {
46
+ setScrollTop(0);
47
+ setFallback(false);
48
+ setActiveIndex(null);
49
+ setControlledScrolling(false);
50
+ }
51
+ });
52
+ return () => {
53
+ cancelAnimationFrame(frame);
54
+ };
55
+ }, [open, setActiveIndex]);
56
+ React.useEffect(() => {
57
+ if (!open)
58
+ return;
59
+ const mouseUp = (e) => {
60
+ if (state.current.isMouseOutside) {
61
+ setOpen(false);
62
+ }
63
+ };
64
+ document.addEventListener("mouseup", mouseUp);
65
+ return () => {
66
+ document.removeEventListener("mouseup", mouseUp);
67
+ };
68
+ }, [open]);
69
+ const updateFloatingSize = size({
70
+ apply({
71
+ availableHeight,
72
+ rects: {
73
+ reference: { width }
74
+ }
75
+ }) {
76
+ floatingStyle.current = {
77
+ width,
78
+ maxHeight: availableHeight
79
+ };
80
+ },
81
+ padding: WINDOW_PADDING
82
+ });
83
+ const { x, y, reference, floating, strategy, context, refs } = useFloating({
84
+ open,
85
+ onOpenChange: setOpen,
86
+ whileElementsMounted: autoUpdate,
87
+ placement: "bottom-start",
88
+ middleware: fallback ? [
89
+ offset(5),
90
+ ...[
91
+ touch ? shift({ crossAxis: true, padding: WINDOW_PADDING }) : flip({ padding: WINDOW_PADDING })
92
+ ],
93
+ updateFloatingSize
94
+ ] : [
95
+ inner({
96
+ listRef: listItemsRef,
97
+ overflowRef,
98
+ index: selectedIndex,
99
+ offset: innerOffset,
100
+ onFallbackChange: setFallback,
101
+ padding: 10,
102
+ minItemsVisible: touch ? 10 : 4,
103
+ referenceOverflowThreshold: 20
104
+ }),
105
+ updateFloatingSize
106
+ ]
107
+ });
108
+ const floatingRef = refs.floating;
109
+ const showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD;
110
+ const showDownArrow = open && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;
111
+ const interactions = useInteractions([
112
+ useClick(context, { pointerDown: true }),
113
+ useDismiss(context, { outsidePointerDown: false }),
114
+ useRole(context, { role: "listbox" }),
115
+ useInnerOffset(context, {
116
+ enabled: !fallback,
117
+ onChange: setInnerOffset,
118
+ overflowRef
119
+ }),
120
+ useListNavigation(context, {
121
+ listRef: listItemsRef,
122
+ activeIndex,
123
+ selectedIndex,
124
+ onNavigate: setActiveIndex
125
+ }),
126
+ useTypeahead(context, {
127
+ listRef: listContentRef,
128
+ onMatch: open ? setActiveIndex : setSelectedIndex,
129
+ selectedIndex,
130
+ activeIndex
131
+ })
132
+ ]);
133
+ const interactionsContext = {
134
+ ...interactions,
135
+ getReferenceProps() {
136
+ return interactions.getReferenceProps({
137
+ ref: reference,
138
+ className: "SelectTrigger",
139
+ onKeyDown(event) {
140
+ if (event.key === "Enter" || event.key === " " && !context.dataRef.current.typing) {
141
+ event.preventDefault();
142
+ setOpen(true);
143
+ }
144
+ }
145
+ });
146
+ },
147
+ getFloatingProps(props2) {
148
+ return interactions.getFloatingProps({
149
+ ref: floating,
150
+ className: "Select",
151
+ ...props2,
152
+ style: {
153
+ position: strategy,
154
+ top: y ?? "",
155
+ left: x ?? "",
156
+ outline: 0,
157
+ listStyleType: "none",
158
+ scrollbarWidth: "none",
159
+ ...floatingStyle.current,
160
+ ...props2?.style
161
+ },
162
+ onPointerEnter() {
163
+ setControlledScrolling(false);
164
+ state.current.isMouseOutside = false;
165
+ },
166
+ onPointerLeave() {
167
+ state.current.isMouseOutside = true;
168
+ },
169
+ onPointerMove() {
170
+ state.current.isMouseOutside = false;
171
+ setControlledScrolling(false);
172
+ },
173
+ onKeyDown() {
174
+ setControlledScrolling(true);
175
+ },
176
+ onContextMenu(e) {
177
+ e.preventDefault();
178
+ },
179
+ onScroll(event) {
180
+ flushSync(() => setScrollTop(event.currentTarget.scrollTop));
181
+ }
182
+ });
183
+ }
184
+ };
185
+ useIsomorphicLayoutEffect(() => {
186
+ if (open) {
187
+ selectTimeoutRef.current = setTimeout(() => {
188
+ allowSelectRef.current = true;
189
+ }, 300);
190
+ return () => {
191
+ clearTimeout(selectTimeoutRef.current);
192
+ };
193
+ } else {
194
+ allowSelectRef.current = false;
195
+ allowMouseUpRef.current = true;
196
+ setInnerOffset(0);
197
+ setFallback(false);
198
+ setBlockSelection(false);
199
+ }
200
+ }, [open]);
201
+ useIsomorphicLayoutEffect(() => {
202
+ function onPointerDown(e) {
203
+ const target = e.target;
204
+ if (!refs.floating.current?.contains(target) && !upArrowRef.current?.contains(target) && !downArrowRef.current?.contains(target)) {
205
+ setOpen(false);
206
+ setControlledScrolling(false);
207
+ }
208
+ }
209
+ if (open) {
210
+ document.addEventListener("pointerdown", onPointerDown);
211
+ return () => {
212
+ document.removeEventListener("pointerdown", onPointerDown);
213
+ };
214
+ }
215
+ }, [open, refs, setOpen]);
216
+ useIsomorphicLayoutEffect(() => {
217
+ if (open && controlledScrolling) {
218
+ if (activeIndex != null) {
219
+ listItemsRef.current[activeIndex]?.scrollIntoView({ block: "nearest" });
220
+ }
221
+ }
222
+ setScrollTop(refs.floating.current?.scrollTop ?? 0);
223
+ }, [open, refs, controlledScrolling, activeIndex]);
224
+ useIsomorphicLayoutEffect(() => {
225
+ if (open && fallback) {
226
+ if (selectedIndex != null) {
227
+ listItemsRef.current[selectedIndex]?.scrollIntoView({ block: "nearest" });
228
+ }
229
+ }
230
+ }, [open, fallback, selectedIndex]);
231
+ useIsomorphicLayoutEffect(() => {
232
+ if (refs.floating.current && fallback) {
233
+ refs.floating.current.style.maxHeight = "";
234
+ }
235
+ }, [refs, fallback]);
236
+ return <SelectProvider scope={__scopeSelect} {...selectContext} setScrollTop={setScrollTop} setInnerOffset={setInnerOffset} floatingRef={floatingRef} setValueAtIndex={(index, value) => {
237
+ listContentRef.current[index] = value;
238
+ }} fallback={fallback} interactions={interactionsContext} floatingContext={context} activeIndex={activeIndex} canScrollDown={!!showDownArrow} canScrollUp={!!showUpArrow} controlledScrolling dataRef={context.dataRef} listRef={listItemsRef} blockSelection={blockSelection} allowMouseUpRef={allowMouseUpRef} upArrowRef={upArrowRef} downArrowRef={downArrowRef} selectTimeoutRef={selectTimeoutRef} allowSelectRef={allowSelectRef}>{children}</SelectProvider>;
239
+ };
240
+ const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
241
+ export {
242
+ SelectInlineImpl
243
+ };
244
+ //# sourceMappingURL=SelectImpl.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/SelectImpl.tsx"],
4
+ "sourcesContent": ["import {\n SideObject,\n autoUpdate,\n flip,\n inner,\n offset,\n shift,\n size,\n useClick,\n useDismiss,\n useFloating,\n useInnerOffset,\n useInteractions,\n useListNavigation,\n useRole,\n useTypeahead,\n} from '@floating-ui/react-dom-interactions'\nimport { useIsTouchDevice, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport * as React from 'react'\nimport { flushSync } from 'react-dom'\n\nimport { SCROLL_ARROW_THRESHOLD, WINDOW_PADDING } from './constants'\nimport { SelectProvider, useSelectContext } from './context'\nimport { ScopedProps, SelectProps } from './types'\n\nexport type SelectImplProps = ScopedProps<SelectProps> & {\n activeIndexRef: any\n selectedIndexRef: any\n listContentRef: any\n}\n\n// TODO use id for focusing from label\nexport const SelectInlineImpl = (props: SelectImplProps) => {\n const { __scopeSelect, children, open = false, selectedIndexRef, listContentRef } = props\n\n const selectContext = useSelectContext('SelectSheetImpl', __scopeSelect)\n const { setActiveIndex, setOpen, setSelectedIndex, selectedIndex, activeIndex, forceUpdate } =\n selectContext\n const [scrollTop, setScrollTop] = React.useState(0)\n const touch = useIsTouchDevice()\n\n const listItemsRef = React.useRef<Array<HTMLElement | null>>([])\n const overflowRef = React.useRef<null | SideObject>(null)\n const upArrowRef = React.useRef<HTMLDivElement | null>(null)\n const downArrowRef = React.useRef<HTMLDivElement | null>(null)\n const allowSelectRef = React.useRef(false)\n const allowMouseUpRef = React.useRef(true)\n const selectTimeoutRef = React.useRef<any>()\n const state = React.useRef({\n isMouseOutside: false,\n })\n\n const [controlledScrolling, setControlledScrolling] = React.useState(false)\n const [fallback, setFallback] = React.useState(false)\n const [innerOffset, setInnerOffset] = React.useState(0)\n const [blockSelection, setBlockSelection] = React.useState(false)\n const floatingStyle = React.useRef({})\n\n // Wait for scroll position to settle before showing arrows to prevent\n // interference with pointer events.\n React.useEffect(() => {\n const frame = requestAnimationFrame(() => {\n if (!open) {\n setScrollTop(0)\n setFallback(false)\n setActiveIndex(null)\n setControlledScrolling(false)\n }\n })\n return () => {\n cancelAnimationFrame(frame)\n }\n }, [open, setActiveIndex])\n\n // close when mouseup outside select\n React.useEffect(() => {\n if (!open) return\n const mouseUp = (e: MouseEvent) => {\n if (state.current.isMouseOutside) {\n setOpen(false)\n }\n }\n document.addEventListener('mouseup', mouseUp)\n return () => {\n document.removeEventListener('mouseup', mouseUp)\n }\n }, [open])\n\n const updateFloatingSize = size({\n apply({\n availableHeight,\n rects: {\n reference: { width },\n },\n }) {\n floatingStyle.current = {\n width: width,\n maxHeight: availableHeight,\n }\n },\n padding: WINDOW_PADDING,\n })\n\n const { x, y, reference, floating, strategy, context, refs } = useFloating({\n open,\n onOpenChange: setOpen,\n whileElementsMounted: autoUpdate,\n placement: 'bottom-start',\n middleware: fallback\n ? [\n offset(5),\n ...[\n touch\n ? shift({ crossAxis: true, padding: WINDOW_PADDING })\n : flip({ padding: WINDOW_PADDING }),\n ],\n updateFloatingSize,\n ]\n : [\n inner({\n listRef: listItemsRef,\n overflowRef,\n index: selectedIndex,\n offset: innerOffset,\n onFallbackChange: setFallback,\n padding: 10,\n minItemsVisible: touch ? 10 : 4,\n referenceOverflowThreshold: 20,\n }),\n updateFloatingSize,\n ],\n })\n\n const floatingRef = refs.floating\n\n const showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD\n const showDownArrow =\n open &&\n floatingRef.current &&\n scrollTop <\n floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD\n\n const interactions = useInteractions([\n useClick(context, { pointerDown: true }),\n useDismiss(context, { outsidePointerDown: false }),\n useRole(context, { role: 'listbox' }),\n useInnerOffset(context, {\n enabled: !fallback,\n onChange: setInnerOffset,\n overflowRef,\n }),\n useListNavigation(context, {\n listRef: listItemsRef,\n activeIndex,\n selectedIndex,\n onNavigate: setActiveIndex,\n }),\n useTypeahead(context, {\n listRef: listContentRef,\n onMatch: open ? setActiveIndex : setSelectedIndex,\n selectedIndex,\n activeIndex,\n }),\n ])\n\n const interactionsContext = {\n ...interactions,\n getReferenceProps() {\n return interactions.getReferenceProps({\n ref: reference,\n className: 'SelectTrigger',\n onKeyDown(event) {\n if (event.key === 'Enter' || (event.key === ' ' && !context.dataRef.current.typing)) {\n event.preventDefault()\n setOpen(true)\n }\n },\n })\n },\n getFloatingProps(props) {\n return interactions.getFloatingProps({\n ref: floating,\n className: 'Select',\n ...props,\n style: {\n position: strategy,\n top: y ?? '',\n left: x ?? '',\n outline: 0,\n listStyleType: 'none',\n scrollbarWidth: 'none',\n ...floatingStyle.current,\n ...props?.style,\n },\n onPointerEnter() {\n setControlledScrolling(false)\n state.current.isMouseOutside = false\n },\n onPointerLeave() {\n state.current.isMouseOutside = true\n },\n onPointerMove() {\n state.current.isMouseOutside = false\n setControlledScrolling(false)\n },\n onKeyDown() {\n setControlledScrolling(true)\n },\n onContextMenu(e) {\n e.preventDefault()\n },\n onScroll(event) {\n // In React 18, the ScrollArrows need to synchronously know this value to prevent\n // painting at the wrong time.\n flushSync(() => setScrollTop(event.currentTarget.scrollTop))\n },\n })\n },\n }\n\n // effects\n\n useIsomorphicLayoutEffect(() => {\n if (open) {\n selectTimeoutRef.current = setTimeout(() => {\n allowSelectRef.current = true\n }, 300)\n\n return () => {\n clearTimeout(selectTimeoutRef.current)\n }\n } else {\n allowSelectRef.current = false\n allowMouseUpRef.current = true\n setInnerOffset(0)\n setFallback(false)\n setBlockSelection(false)\n }\n }, [open])\n\n // Replacement for `useDismiss` as the arrows are outside of the floating\n // element DOM tree.\n useIsomorphicLayoutEffect(() => {\n function onPointerDown(e: PointerEvent) {\n const target = e.target as Node\n if (\n !refs.floating.current?.contains(target) &&\n !upArrowRef.current?.contains(target) &&\n !downArrowRef.current?.contains(target)\n ) {\n setOpen(false)\n setControlledScrolling(false)\n }\n }\n\n if (open) {\n document.addEventListener('pointerdown', onPointerDown)\n return () => {\n document.removeEventListener('pointerdown', onPointerDown)\n }\n }\n }, [open, refs, setOpen])\n\n // Scroll the `activeIndex` item into view only in \"controlledScrolling\"\n // (keyboard nav) mode.\n useIsomorphicLayoutEffect(() => {\n if (open && controlledScrolling) {\n if (activeIndex != null) {\n listItemsRef.current[activeIndex]?.scrollIntoView({ block: 'nearest' })\n }\n }\n\n setScrollTop(refs.floating.current?.scrollTop ?? 0)\n }, [open, refs, controlledScrolling, activeIndex])\n\n // Scroll the `selectedIndex` into view upon opening the floating element.\n useIsomorphicLayoutEffect(() => {\n if (open && fallback) {\n if (selectedIndex != null) {\n listItemsRef.current[selectedIndex]?.scrollIntoView({ block: 'nearest' })\n }\n }\n }, [open, fallback, selectedIndex])\n\n // Unset the height limiting for fallback mode. This gets executed prior to\n // the positioning call.\n useIsomorphicLayoutEffect(() => {\n if (refs.floating.current && fallback) {\n refs.floating.current.style.maxHeight = ''\n }\n }, [refs, fallback])\n\n // We set this to true by default so that events bubble to forms without JS (SSR)\n // const isFormControl = trigger ? Boolean(trigger.closest('form')) : true\n // const [bubbleSelect, setBubbleSelect] = React.useState<HTMLSelectElement | null>(null)\n // const triggerPointerDownPosRef = React.useRef<{ x: number; y: number } | null>(null)\n\n return (\n <SelectProvider\n scope={__scopeSelect}\n {...(selectContext as Required<typeof selectContext>)}\n setScrollTop={setScrollTop}\n setInnerOffset={setInnerOffset}\n floatingRef={floatingRef}\n setValueAtIndex={(index, value) => {\n listContentRef.current[index] = value\n }}\n fallback={fallback}\n interactions={interactionsContext}\n floatingContext={context}\n activeIndex={activeIndex}\n canScrollDown={!!showDownArrow}\n canScrollUp={!!showUpArrow}\n controlledScrolling\n dataRef={context.dataRef}\n listRef={listItemsRef}\n blockSelection={blockSelection}\n allowMouseUpRef={allowMouseUpRef}\n upArrowRef={upArrowRef}\n downArrowRef={downArrowRef}\n selectTimeoutRef={selectTimeoutRef}\n allowSelectRef={allowSelectRef}\n >\n {children}\n {/* {isFormControl ? (\n <BubbleSelect\n ref={setBubbleSelect}\n aria-hidden\n tabIndex={-1}\n name={name}\n autoComplete={autoComplete}\n value={value}\n // enable form autofill\n onChange={(event) => setValue(event.target.value)}\n />\n ) : null} */}\n </SelectProvider>\n )\n}\n\n// Cross browser fixes for pinch-zooming/backdrop-filter \uD83D\uDE44\nconst userAgent = (typeof navigator !== 'undefined' && navigator.userAgent) || ''\n"],
5
+ "mappings": "AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB,iCAAiC;AAC5D,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAE1B,SAAS,wBAAwB,sBAAsB;AACvD,SAAS,gBAAgB,wBAAwB;AAU1C,MAAM,mBAAmB,CAAC,UAA2B;AAC1D,QAAM,EAAE,eAAe,UAAU,OAAO,OAAO,kBAAkB,eAAe,IAAI;AAEpF,QAAM,gBAAgB,iBAAiB,mBAAmB,aAAa;AACvE,QAAM,EAAE,gBAAgB,SAAS,kBAAkB,eAAe,aAAa,YAAY,IACzF;AACF,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,CAAC;AAClD,QAAM,QAAQ,iBAAiB;AAE/B,QAAM,eAAe,MAAM,OAAkC,CAAC,CAAC;AAC/D,QAAM,cAAc,MAAM,OAA0B,IAAI;AACxD,QAAM,aAAa,MAAM,OAA8B,IAAI;AAC3D,QAAM,eAAe,MAAM,OAA8B,IAAI;AAC7D,QAAM,iBAAiB,MAAM,OAAO,KAAK;AACzC,QAAM,kBAAkB,MAAM,OAAO,IAAI;AACzC,QAAM,mBAAmB,MAAM,OAAY;AAC3C,QAAM,QAAQ,MAAM,OAAO;AAAA,IACzB,gBAAgB;AAAA,EAClB,CAAC;AAED,QAAM,CAAC,qBAAqB,sBAAsB,IAAI,MAAM,SAAS,KAAK;AAC1E,QAA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iBACjB,YAAY,YACZ,cAAc,cACd,kBAAkB,kBAClB,gBAAgB,iBAEf,SAaH,EAtCC;AAwCL;AAGA,MAAM,YAAa,OAAO,cAAc,eAAe,UAAU,aAAc;",
6
+ "names": ["props"]
7
+ }
@@ -0,0 +1,99 @@
1
+ import { autoUpdate, offset, useFloating } from "@floating-ui/react-dom-interactions";
2
+ import { useComposedRefs } from "@tamagui/compose-refs";
3
+ import { useIsomorphicLayoutEffect } from "@tamagui/core";
4
+ import { YStack } from "@tamagui/stacks";
5
+ import * as React from "react";
6
+ import { flushSync } from "react-dom";
7
+ import { useSelectContext } from "./context";
8
+ const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
9
+ const SelectScrollUpButton = React.forwardRef(
10
+ (props, forwardedRef) => {
11
+ return <SelectScrollButtonImpl componentName={SCROLL_UP_BUTTON_NAME} {...props} dir="up" ref={forwardedRef} />;
12
+ }
13
+ );
14
+ SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
15
+ const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
16
+ const SelectScrollDownButton = React.forwardRef(
17
+ (props, forwardedRef) => {
18
+ return <SelectScrollButtonImpl componentName={SCROLL_DOWN_BUTTON_NAME} {...props} dir="down" ref={forwardedRef} />;
19
+ }
20
+ );
21
+ SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
22
+ const SelectScrollButtonImpl = React.memo(
23
+ React.forwardRef(
24
+ (props, forwardedRef) => {
25
+ const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props;
26
+ const { floatingRef, forceUpdate, open, fallback, setScrollTop, setInnerOffset, ...context } = useSelectContext(componentName, __scopeSelect);
27
+ const [element, setElement] = React.useState(null);
28
+ const statusRef = React.useRef("idle");
29
+ const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
30
+ const frameRef = React.useRef();
31
+ const { x, y, reference, floating, strategy, update, refs } = useFloating({
32
+ strategy: "fixed",
33
+ placement: dir === "up" ? "top" : "bottom",
34
+ middleware: [offset(({ rects }) => -rects.floating.height)],
35
+ whileElementsMounted: (...args) => autoUpdate(...args, { animationFrame: true })
36
+ });
37
+ const composedRef = useComposedRefs(forwardedRef, floating);
38
+ if (floatingRef) {
39
+ if (open) {
40
+ if (element !== floatingRef.current) {
41
+ setElement(floatingRef.current);
42
+ reference(floatingRef.current);
43
+ requestAnimationFrame(update);
44
+ }
45
+ } else {
46
+ cancelAnimationFrame(frameRef.current);
47
+ }
48
+ }
49
+ useIsomorphicLayoutEffect(() => {
50
+ return () => {
51
+ cancelAnimationFrame(frameRef.current);
52
+ };
53
+ }, []);
54
+ if (!isVisible || !floatingRef) {
55
+ return null;
56
+ }
57
+ const onScroll = (amount) => {
58
+ if (fallback) {
59
+ if (refs.floating.current) {
60
+ refs.floating.current.scrollTop -= amount;
61
+ flushSync(() => setScrollTop(refs.floating.current?.scrollTop ?? 0));
62
+ }
63
+ } else {
64
+ flushSync(() => setInnerOffset((value) => value - amount));
65
+ }
66
+ };
67
+ return <YStack ref={composedRef} componentName={componentName} aria-hidden {...scrollIndicatorProps} zIndex={1e3} position={strategy} left={x || 0} top={y || 0} width={`calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`} onPointerEnter={() => {
68
+ statusRef.current = "active";
69
+ let prevNow = Date.now();
70
+ function frame() {
71
+ if (element) {
72
+ const currentNow = Date.now();
73
+ const msElapsed = currentNow - prevNow;
74
+ prevNow = currentNow;
75
+ const pixelsToScroll = msElapsed / 2;
76
+ const remainingPixels = dir === "up" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;
77
+ const scrollRemaining = dir === "up" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;
78
+ onScroll(
79
+ dir === "up" ? Math.min(pixelsToScroll, remainingPixels) : Math.max(-pixelsToScroll, -remainingPixels)
80
+ );
81
+ if (scrollRemaining) {
82
+ frameRef.current = requestAnimationFrame(frame);
83
+ }
84
+ }
85
+ }
86
+ cancelAnimationFrame(frameRef.current);
87
+ frameRef.current = requestAnimationFrame(frame);
88
+ }} onPointerLeave={() => {
89
+ statusRef.current = "idle";
90
+ cancelAnimationFrame(frameRef.current);
91
+ }} />;
92
+ }
93
+ )
94
+ );
95
+ export {
96
+ SelectScrollDownButton,
97
+ SelectScrollUpButton
98
+ };
99
+ //# sourceMappingURL=SelectScrollButton.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/SelectScrollButton.tsx"],
4
+ "sourcesContent": ["import { autoUpdate, offset, useFloating } from '@floating-ui/react-dom-interactions'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport { TamaguiElement, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { flushSync } from 'react-dom'\n\nimport { useSelectContext } from './context'\nimport { ScopedProps, SelectScrollButtonImplProps, SelectScrollButtonProps } from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectScrollUpButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SCROLL_UP_BUTTON_NAME = 'SelectScrollUpButton'\n\nexport const SelectScrollUpButton = React.forwardRef<TamaguiElement, SelectScrollButtonProps>(\n (props: ScopedProps<SelectScrollButtonProps>, forwardedRef) => {\n return (\n <SelectScrollButtonImpl\n componentName={SCROLL_UP_BUTTON_NAME}\n {...props}\n dir=\"up\"\n ref={forwardedRef}\n />\n )\n }\n)\n\nSelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectScrollDownButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SCROLL_DOWN_BUTTON_NAME = 'SelectScrollDownButton'\n\nexport const SelectScrollDownButton = React.forwardRef<TamaguiElement, SelectScrollButtonProps>(\n (props: ScopedProps<SelectScrollButtonProps>, forwardedRef) => {\n return (\n <SelectScrollButtonImpl\n componentName={SCROLL_DOWN_BUTTON_NAME}\n {...props}\n dir=\"down\"\n ref={forwardedRef}\n />\n )\n }\n)\n\nSelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME\n\ntype SelectScrollButtonImplElement = TamaguiElement\n\nconst SelectScrollButtonImpl = React.memo(\n React.forwardRef<SelectScrollButtonImplElement, SelectScrollButtonImplProps>(\n (props: ScopedProps<SelectScrollButtonImplProps>, forwardedRef) => {\n const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props\n const { floatingRef, forceUpdate, open, fallback, setScrollTop, setInnerOffset, ...context } =\n useSelectContext(componentName, __scopeSelect)\n\n const [element, setElement] = React.useState<HTMLElement | null>(null)\n const statusRef = React.useRef<'idle' | 'active'>('idle')\n const isVisible = context[dir === 'down' ? 'canScrollDown' : 'canScrollUp']\n const frameRef = React.useRef<any>()\n\n const { x, y, reference, floating, strategy, update, refs } = useFloating({\n strategy: 'fixed',\n placement: dir === 'up' ? 'top' : 'bottom',\n middleware: [offset(({ rects }) => -rects.floating.height)],\n whileElementsMounted: (...args) => autoUpdate(...args, { animationFrame: true }),\n })\n\n const composedRef = useComposedRefs(forwardedRef, floating)\n\n if (floatingRef) {\n if (open) {\n if (element !== floatingRef.current) {\n setElement(floatingRef.current)\n reference(floatingRef.current)\n requestAnimationFrame(update)\n }\n } else {\n cancelAnimationFrame(frameRef.current)\n }\n }\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n cancelAnimationFrame(frameRef.current)\n }\n }, [])\n\n if (!isVisible || !floatingRef) {\n return null\n }\n\n const onScroll = (amount: number) => {\n if (fallback) {\n if (refs.floating.current) {\n refs.floating.current.scrollTop -= amount\n flushSync(() => setScrollTop!(refs.floating.current?.scrollTop ?? 0))\n }\n } else {\n flushSync(() => setInnerOffset!((value) => value - amount))\n }\n }\n\n return (\n <YStack\n ref={composedRef}\n componentName={componentName}\n aria-hidden\n {...scrollIndicatorProps}\n zIndex={1000}\n // @ts-expect-error\n position={strategy}\n left={x || 0}\n top={y || 0}\n width={`calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`}\n onPointerEnter={() => {\n statusRef.current = 'active'\n let prevNow = Date.now()\n\n function frame() {\n if (element) {\n const currentNow = Date.now()\n const msElapsed = currentNow - prevNow\n prevNow = currentNow\n\n const pixelsToScroll = msElapsed / 2\n\n const remainingPixels =\n dir === 'up'\n ? element.scrollTop\n : element.scrollHeight - element.clientHeight - element.scrollTop\n\n const scrollRemaining =\n dir === 'up'\n ? element.scrollTop - pixelsToScroll > 0\n : element.scrollTop + pixelsToScroll <\n element.scrollHeight - element.clientHeight\n\n onScroll(\n dir === 'up'\n ? Math.min(pixelsToScroll, remainingPixels)\n : Math.max(-pixelsToScroll, -remainingPixels)\n )\n\n if (scrollRemaining) {\n frameRef.current = requestAnimationFrame(frame)\n }\n }\n }\n\n cancelAnimationFrame(frameRef.current)\n frameRef.current = requestAnimationFrame(frame)\n }}\n onPointerLeave={() => {\n statusRef.current = 'idle'\n cancelAnimationFrame(frameRef.current)\n }}\n />\n )\n }\n )\n)\n"],
5
+ "mappings": "AAAA,SAAS,YAAY,QAAQ,mBAAmB;AAChD,SAAS,uBAAuB;AAChC,SAAyB,iCAAiC;AAC1D,SAAS,cAAc;AACvB,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAE1B,SAAS,wBAAwB;AAOjC,MAAM,wBAAwB;AAEvB,MAAM,uBAAuB,MAAM;AAAA,EACxC,CAAC,OAA6C,iBAAiB;AAC7D,WACE,CAAC,uBACC,eAAe,2BACX,OACJ,IAAI,KACJ,KAAK,cACP;AAAA,EAEJ;AACF;AAEA,qBAAqB,cAAc;AAMnC,MAAM,0BAA0B;AAEzB,MAAM,yBAAyB,MAAM;AAAA,EAC1C,CAAC,OAA6C,iBAAiB;AAC7D,WACE,CAAC,uBACC,eAAe,6BACX,OACJ,IAAI,OACJ,KAAK,cACP;AAAA,EAEJ;AACF;AAEA,uBAAuB,cAAc;AAIrC,MAAM,yBAAyB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MAAM,aAAc,KAAK,SAAS,SAAS,aAAa,CAAC,CAAC;AAAA,UACtE;AAAA,QACF,OAAO;AACL,oBAAU,MAAM,eAAgB,CAAC,UAAU,QAAQ,MAAM,CAAC;AAAA,QAC5D;AAAA,MACF;AAEA,aACE,CAAC,OACC,KAAK,aACL,eAAe,eACf,gBACI,sBACJ,QAAQ,KAER,UAAU,UACV,MAAM,KAAK,GACX,KAAK,KAAK,GACV,OAAO,SAAS,aAAa,SAAS,eAAe,KAAK,QAC1D,gBAAgB,MAAM;AACpB,kBAAU,UAAU;AACpB,YAAI,UAAU,KAAK,IAAI;AAEvB,iBAAS,QAAQ;AACf,cAAI,SAAS;AACX,kBAAM,aAAa,KAAK,IAAI;AAC5B,kBAAM,YAAY,aAAa;AAC/B,sBAAU;AAEV,kBAAM,iBAAiB,YAAY;AAEnC,kBAAM,kBACJ,QAAQ,OACJ,QAAQ,YACR,QAAQ,eAAe,QAAQ,eAAe,QAAQ;AAE5D,kBAAM,kBACJ,QAAQ,OACJ,QAAQ,YAAY,iBAAiB,IACrC,QAAQ,YAAY,iBACpB,QAAQ,eAAe,QAAQ;AAErC;AAAA,cACE,QAAQ,OACJ,KAAK,IAAI,gBAAgB,eAAe,IACxC,KAAK,IAAI,CAAC,gBAAgB,CAAC,eAAe;AAAA,YAChD;AAEA,gBAAI,iBAAiB;AACnB,uBAAS,UAAU,sBAAsB,KAAK;AAAA,YAChD;AAAA,UACF;AAAA,QACF;AAEA,6BAAqB,SAAS,OAAO;AACrC,iBAAS,UAAU,sBAAsB,KAAK;AAAA,MAChD,GACA,gBAAgB,MAAM;AACpB,kBAAU,UAAU;AACpB,6BAAqB,SAAS,OAAO;AAAA,MACvC,GACF;AAAA,IAEJ;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ const SelectScrollUpButton = (_) => null;
2
+ const SelectScrollDownButton = (_) => null;
3
+ export {
4
+ SelectScrollDownButton,
5
+ SelectScrollUpButton
6
+ };
7
+ //# sourceMappingURL=SelectScrollButton.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/SelectScrollButton.native.tsx"],
4
+ "sourcesContent": ["import { ScopedProps, SelectScrollButtonProps } from './types'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const SelectScrollUpButton = (_: ScopedProps<SelectScrollButtonProps>) => null\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const SelectScrollDownButton = (_: ScopedProps<SelectScrollButtonProps>) => null\n"],
5
+ "mappings": "AAGO,MAAM,uBAAuB,CAAC,MAA4C;AAG1E,MAAM,yBAAyB,CAAC,MAA4C;",
6
+ "names": []
7
+ }
@@ -0,0 +1,72 @@
1
+ import { FloatingFocusManager } from "@floating-ui/react-dom-interactions";
2
+ import { isWeb } from "@tamagui/core";
3
+ import { styled } from "@tamagui/core";
4
+ import { PortalItem } from "@tamagui/portal";
5
+ import { ThemeableStack } from "@tamagui/stacks";
6
+ import * as React from "react";
7
+ import { VIEWPORT_NAME } from "./constants";
8
+ import { ForwardSelectContext, useSelectContext } from "./context";
9
+ import { useSelectBreakpointActive } from "./useSelectBreakpointActive";
10
+ const SelectViewportFrame = styled(ThemeableStack, {
11
+ name: VIEWPORT_NAME,
12
+ backgroundColor: "$background",
13
+ elevate: true,
14
+ bordered: true,
15
+ overflow: "scroll",
16
+ userSelect: "none",
17
+ variants: {
18
+ size: {
19
+ "...size": (val, { tokens }) => {
20
+ return {
21
+ borderRadius: tokens.radius[val] ?? val
22
+ };
23
+ }
24
+ }
25
+ },
26
+ defaultVariants: {
27
+ size: "$2"
28
+ }
29
+ });
30
+ const SelectViewport = React.forwardRef(
31
+ (props, forwardedRef) => {
32
+ const { __scopeSelect, children, ...viewportProps } = props;
33
+ const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
34
+ const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
35
+ if (breakpointActive || !isWeb) {
36
+ return <PortalItem hostName={`${context.scopeKey}SheetContents`}><ForwardSelectContext context={context}>{children}</ForwardSelectContext></PortalItem>;
37
+ }
38
+ if (!context.floatingContext) {
39
+ return null;
40
+ }
41
+ if (!context.open) {
42
+ return children;
43
+ }
44
+ const {
45
+ style: { scrollbarWidth, listStyleType, ...restStyle },
46
+ ...floatingProps
47
+ } = context.interactions.getFloatingProps();
48
+ return <>
49
+ <style dangerouslySetInnerHTML={{
50
+ __html: selectViewportCSS
51
+ }} />
52
+ <FloatingFocusManager context={context.floatingContext} preventTabbing><SelectViewportFrame size={context.size} role="presentation" {...viewportProps} ref={forwardedRef} {...floatingProps} {...restStyle}>{children}</SelectViewportFrame></FloatingFocusManager>
53
+ </>;
54
+ }
55
+ );
56
+ SelectViewport.displayName = VIEWPORT_NAME;
57
+ const selectViewportCSS = `
58
+ .is_SelectViewport {
59
+ scrollbar-width: none;
60
+ -webkit-overflow-scrolling: touch;
61
+ overscroll-behavior: contain;
62
+ }
63
+
64
+ .is_SelectViewport::-webkit-scrollbar{
65
+ display:none
66
+ }
67
+ `;
68
+ export {
69
+ SelectViewport,
70
+ SelectViewportFrame
71
+ };
72
+ //# sourceMappingURL=SelectViewport.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/SelectViewport.tsx"],
4
+ "sourcesContent": ["import { FloatingFocusManager } from '@floating-ui/react-dom-interactions'\nimport { TamaguiElement, isWeb } from '@tamagui/core'\nimport { styled } from '@tamagui/core'\nimport { PortalItem } from '@tamagui/portal'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport * as React from 'react'\n\nimport { VIEWPORT_NAME } from './constants'\nimport { ForwardSelectContext, useSelectContext } from './context'\nimport { ScopedProps, SelectViewportProps } from './types'\nimport { useSelectBreakpointActive } from './useSelectBreakpointActive'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectViewport\n * -----------------------------------------------------------------------------------------------*/\n\nexport const SelectViewportFrame = styled(ThemeableStack, {\n name: VIEWPORT_NAME,\n backgroundColor: '$background',\n elevate: true,\n bordered: true,\n overflow: 'scroll',\n userSelect: 'none',\n\n variants: {\n size: {\n '...size': (val, { tokens }) => {\n return {\n borderRadius: tokens.radius[val] ?? val,\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$2',\n },\n})\n\nexport const SelectViewport = React.forwardRef<TamaguiElement, SelectViewportProps>(\n (props: ScopedProps<SelectViewportProps>, forwardedRef) => {\n const { __scopeSelect, children, ...viewportProps } = props\n const context = useSelectContext(VIEWPORT_NAME, __scopeSelect)\n const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint)\n\n if (breakpointActive || !isWeb) {\n return (\n <PortalItem hostName={`${context.scopeKey}SheetContents`}>\n <ForwardSelectContext context={context}>{children}</ForwardSelectContext>\n </PortalItem>\n )\n }\n\n if (!context.floatingContext) {\n return null\n }\n\n if (!context.open) {\n return children\n }\n\n const {\n style: { scrollbarWidth, listStyleType, ...restStyle },\n ...floatingProps\n } = context.interactions!.getFloatingProps()\n\n return (\n <>\n <style\n dangerouslySetInnerHTML={{\n __html: selectViewportCSS,\n }}\n />\n <FloatingFocusManager context={context.floatingContext} preventTabbing>\n <SelectViewportFrame\n size={context.size}\n // @ts-ignore\n role=\"presentation\"\n {...viewportProps}\n ref={forwardedRef}\n {...floatingProps}\n {...restStyle}\n >\n {children}\n </SelectViewportFrame>\n </FloatingFocusManager>\n </>\n )\n }\n)\n\nSelectViewport.displayName = VIEWPORT_NAME\n\nconst selectViewportCSS = `\n.is_SelectViewport {\n scrollbar-width: none;\n -webkit-overflow-scrolling: touch;\n overscroll-behavior: contain;\n}\n\n.is_SelectViewport::-webkit-scrollbar{\n display:none\n}\n`\n"],
5
+ "mappings": "AAAA,SAAS,4BAA4B;AACrC,SAAyB,aAAa;AACtC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB,wBAAwB;AAEvD,S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