@tamagui/select 1.13.2 → 1.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BubbleSelect.js +1 -47
- package/dist/cjs/BubbleSelect.js.map +2 -2
- package/dist/cjs/Select.js +1 -494
- package/dist/cjs/Select.js.map +2 -2
- package/dist/cjs/SelectContent.js +1 -54
- package/dist/cjs/SelectContent.js.map +2 -2
- package/dist/cjs/SelectContent.native.js +1 -30
- package/dist/cjs/SelectContent.native.js.map +2 -2
- package/dist/cjs/SelectImpl.js +1 -308
- package/dist/cjs/SelectImpl.js.map +2 -2
- package/dist/cjs/SelectImpl.native.js +1 -34
- package/dist/cjs/SelectImpl.native.js.map +2 -2
- package/dist/cjs/SelectScrollButton.js +1 -175
- package/dist/cjs/SelectScrollButton.js.map +2 -2
- package/dist/cjs/SelectScrollButton.native.js +1 -31
- package/dist/cjs/SelectScrollButton.native.js.map +2 -2
- package/dist/cjs/SelectViewport.js +2 -115
- package/dist/cjs/SelectViewport.js.map +2 -2
- package/dist/cjs/SelectViewport.native.js +1 -52
- package/dist/cjs/SelectViewport.native.js.map +2 -2
- package/dist/cjs/constants.js +1 -46
- package/dist/cjs/constants.js.map +2 -2
- package/dist/cjs/context.js +1 -43
- package/dist/cjs/context.js.map +2 -2
- package/dist/cjs/index.js +1 -19
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js +1 -16
- package/dist/cjs/types.js.map +2 -2
- package/dist/cjs/useSelectBreakpointActive.js +1 -42
- package/dist/cjs/useSelectBreakpointActive.js.map +2 -2
- package/dist/esm/BubbleSelect.js +1 -24
- package/dist/esm/BubbleSelect.js.map +2 -2
- package/dist/esm/BubbleSelect.mjs +1 -24
- package/dist/esm/BubbleSelect.mjs.map +2 -2
- package/dist/esm/Select.js +1 -464
- package/dist/esm/Select.js.map +2 -2
- package/dist/esm/Select.mjs +1 -464
- package/dist/esm/Select.mjs.map +2 -2
- package/dist/esm/SelectContent.js +1 -30
- package/dist/esm/SelectContent.js.map +2 -2
- package/dist/esm/SelectContent.mjs +1 -30
- package/dist/esm/SelectContent.mjs.map +2 -2
- package/dist/esm/SelectContent.native.js +1 -6
- package/dist/esm/SelectContent.native.js.map +2 -2
- package/dist/esm/SelectContent.native.mjs +1 -6
- package/dist/esm/SelectContent.native.mjs.map +2 -2
- package/dist/esm/SelectImpl.js +1 -294
- package/dist/esm/SelectImpl.js.map +2 -2
- package/dist/esm/SelectImpl.mjs +1 -294
- package/dist/esm/SelectImpl.mjs.map +2 -2
- package/dist/esm/SelectImpl.native.js +1 -10
- package/dist/esm/SelectImpl.native.js.map +2 -2
- package/dist/esm/SelectImpl.native.mjs +1 -10
- package/dist/esm/SelectImpl.native.mjs.map +2 -2
- package/dist/esm/SelectScrollButton.js +1 -140
- package/dist/esm/SelectScrollButton.js.map +2 -2
- package/dist/esm/SelectScrollButton.mjs +1 -140
- package/dist/esm/SelectScrollButton.mjs.map +2 -2
- package/dist/esm/SelectScrollButton.native.js +1 -6
- package/dist/esm/SelectScrollButton.native.js.map +2 -2
- package/dist/esm/SelectScrollButton.native.mjs +1 -6
- package/dist/esm/SelectScrollButton.native.mjs.map +2 -2
- package/dist/esm/SelectViewport.js +2 -80
- package/dist/esm/SelectViewport.js.map +2 -2
- package/dist/esm/SelectViewport.mjs +2 -80
- package/dist/esm/SelectViewport.mjs.map +2 -2
- package/dist/esm/SelectViewport.native.js +1 -18
- package/dist/esm/SelectViewport.native.js.map +2 -2
- package/dist/esm/SelectViewport.native.mjs +1 -18
- package/dist/esm/SelectViewport.native.mjs.map +2 -2
- package/dist/esm/constants.js +1 -16
- package/dist/esm/constants.js.map +2 -2
- package/dist/esm/constants.mjs +1 -16
- package/dist/esm/constants.mjs.map +2 -2
- package/dist/esm/context.js +1 -15
- package/dist/esm/context.js.map +2 -2
- package/dist/esm/context.mjs +1 -15
- package/dist/esm/context.mjs.map +2 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/useSelectBreakpointActive.js +1 -17
- package/dist/esm/useSelectBreakpointActive.js.map +2 -2
- package/dist/esm/useSelectBreakpointActive.mjs +1 -17
- package/dist/esm/useSelectBreakpointActive.mjs.map +2 -2
- package/dist/jsx/BubbleSelect.js +1 -24
- package/dist/jsx/BubbleSelect.js.map +2 -2
- package/dist/jsx/BubbleSelect.mjs +1 -24
- package/dist/jsx/BubbleSelect.mjs.map +2 -2
- package/dist/jsx/Select.js +1 -428
- package/dist/jsx/Select.js.map +2 -2
- package/dist/jsx/Select.mjs +1 -428
- package/dist/jsx/Select.mjs.map +2 -2
- package/dist/jsx/SelectContent.js +1 -29
- package/dist/jsx/SelectContent.js.map +2 -2
- package/dist/jsx/SelectContent.mjs +1 -29
- package/dist/jsx/SelectContent.mjs.map +2 -2
- package/dist/jsx/SelectContent.native.js +1 -6
- package/dist/jsx/SelectContent.native.js.map +2 -2
- package/dist/jsx/SelectContent.native.mjs +1 -6
- package/dist/jsx/SelectContent.native.mjs.map +2 -2
- package/dist/jsx/SelectImpl.js +1 -286
- package/dist/jsx/SelectImpl.js.map +2 -2
- package/dist/jsx/SelectImpl.mjs +1 -286
- package/dist/jsx/SelectImpl.mjs.map +2 -2
- package/dist/jsx/SelectImpl.native.js +1 -9
- package/dist/jsx/SelectImpl.native.js.map +2 -2
- package/dist/jsx/SelectImpl.native.mjs +1 -9
- package/dist/jsx/SelectImpl.native.mjs.map +2 -2
- package/dist/jsx/SelectScrollButton.js +1 -126
- package/dist/jsx/SelectScrollButton.js.map +2 -2
- package/dist/jsx/SelectScrollButton.mjs +1 -126
- package/dist/jsx/SelectScrollButton.mjs.map +2 -2
- package/dist/jsx/SelectScrollButton.native.js +1 -6
- package/dist/jsx/SelectScrollButton.native.js.map +2 -2
- package/dist/jsx/SelectScrollButton.native.mjs +1 -6
- package/dist/jsx/SelectScrollButton.native.mjs.map +2 -2
- package/dist/jsx/SelectViewport.js +2 -72
- package/dist/jsx/SelectViewport.js.map +2 -2
- package/dist/jsx/SelectViewport.mjs +2 -72
- package/dist/jsx/SelectViewport.mjs.map +2 -2
- package/dist/jsx/SelectViewport.native.js +1 -17
- package/dist/jsx/SelectViewport.native.js.map +2 -2
- package/dist/jsx/SelectViewport.native.mjs +1 -17
- package/dist/jsx/SelectViewport.native.mjs.map +2 -2
- package/dist/jsx/constants.js +1 -16
- package/dist/jsx/constants.js.map +2 -2
- package/dist/jsx/constants.mjs +1 -16
- package/dist/jsx/constants.mjs.map +2 -2
- package/dist/jsx/context.js +1 -14
- package/dist/jsx/context.js.map +2 -2
- package/dist/jsx/context.mjs +1 -14
- package/dist/jsx/context.mjs.map +2 -2
- package/dist/jsx/index.js +1 -2
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +1 -2
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/useSelectBreakpointActive.js +1 -17
- package/dist/jsx/useSelectBreakpointActive.js.map +2 -2
- package/dist/jsx/useSelectBreakpointActive.mjs +1 -17
- package/dist/jsx/useSelectBreakpointActive.mjs.map +2 -2
- package/package.json +16 -16
package/dist/cjs/Select.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Select.tsx"],
|
|
4
4
|
"sourcesContent": ["import { Adapt, useAdaptParent } from '@tamagui/adapt'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n GetProps,\n TamaguiElement,\n isWeb,\n styled,\n useGet,\n useId,\n useIsomorphicLayoutEffect,\n withStaticProperties,\n} 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 } from '@tamagui/stacks'\nimport { Paragraph, SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { SELECT_NAME } from './constants'\nimport { SelectProvider, createSelectContext, useSelectContext } from './context'\nimport { SelectContent } from './SelectContent'\nimport { SelectInlineImpl } from './SelectImpl'\nimport { SelectScrollDownButton, SelectScrollUpButton } from './SelectScrollButton'\nimport { SelectViewport } from './SelectViewport'\nimport { ScopedProps, SelectImplProps, SelectProps } from './types'\nimport {\n useSelectBreakpointActive,\n useShowSelectSheet,\n} 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 userSelect: 'none',\n})\n\ntype SelectValueProps = GetProps<typeof SelectValueFrame> & {\n placeholder?: React.ReactNode\n}\n\nconst SelectValue = SelectValueFrame.extractable(\n React.forwardRef<TamaguiElement, SelectValueProps>(\n (\n {\n __scopeSelect,\n children: childrenProp,\n placeholder,\n }: 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 isEmptyValue = context.value == null || context.value === ''\n const selectValueChildren = isEmptyValue ? placeholder ?? children : 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 ListItemProps {\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 (\n event.key === 'Enter' ||\n (event.key === ' ' && !dataRef?.current.typing)\n ) {\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 tag=\"div\"\n backgrounded\n pressTheme\n hoverTheme\n cursor=\"default\"\n outlineWidth={0}\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 focusStyle={{\n backgroundColor: '$backgroundHover',\n }}\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(SizableText, {\n name: ITEM_TEXT_NAME,\n userSelect: 'none',\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 useIsomorphicLayoutEffect(() => {\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 tag=\"div\"\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\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 = '$true',\n dir,\n } = props\n\n const id = useId()\n const scopeKey = __scopeSelect ? Object.keys(__scopeSelect)[0] ?? id : id\n\n const { when, AdaptProvider } = useAdaptParent({\n Contents: React.useCallback(\n () => <PortalHost name={`${scopeKey}SheetContents`} />,\n [scopeKey]\n ),\n })\n const sheetBreakpoint = when\n const isSheet = useSelectBreakpointActive(sheetBreakpoint)\n const SelectImpl = isSheet || !isWeb ? 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 })\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue || '',\n onChange: onValueChange,\n transition: true,\n })\n\n const [activeIndex, setActiveIndex] = React.useState<number | null>(0)\n const selectedIndexRef = React.useRef<number | null>(null)\n const activeIndexRef = React.useRef<number | null>(null)\n const listContentRef = React.useRef<string[]>([])\n const [selectedIndex, setSelectedIndex] = React.useState(0)\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 return (\n <AdaptProvider>\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 </AdaptProvider>\n )\n },\n {\n Adapt,\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 Sheet: ControlledSheet,\n }\n)\n\n// @ts-ignore\nSelect.displayName = SELECT_NAME\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["value"]
|
|
5
|
+
"mappings": "ukBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,YAAAE,GAAA,qBAAAC,GAAA,eAAAC,GAAA,eAAAC,EAAA,wBAAAC,GAAA,oBAAAC,GAAA,kBAAAC,IAAA,eAAAC,GAAAT,IAyDM,IAAAU,EAAA,6BAzDNC,EAAsC,0BACtCC,EAAgC,iCAChCC,EASO,yBACPC,EAAwC,8BACxCC,GAA2B,2BAC3BC,GAA0B,8BAC1BC,EAAiD,0BACjDC,EAA+B,2BAC/BC,EAAuC,yBACvCC,EAAqC,2CACrCC,EAAuB,qBAEvBC,GAA4B,uBAC5BC,EAAsE,qBACtEC,GAA8B,2BAC9BC,GAAiC,wBACjCC,EAA6D,gCAC7DC,GAA+B,4BAE/BC,EAGO,uCAMP,MAAMC,EAAe,gBAIRrB,EAAgBa,EAAM,WACjC,CAACS,EAAwCC,IAAiB,CACxD,KAAM,CACJ,cAAAC,EACA,SAAAC,EAAW,GAEX,kBAAmBC,EACnB,GAAG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F,EAGAtC,GAAO,YAAc",
|
|
6
|
+
"names": ["Select_exports", "__export", "Select", "SelectGroupFrame", "SelectIcon", "SelectItem", "SelectItemTextFrame", "SelectSeparator", "SelectTrigger", "__toCommonJS", "import_jsx_runtime", "import_adapt", "import_compose_refs", "import_core", "import_list_item", "import_portal", "import_separator", "import_sheet", "import_stacks", "import_text", "import_use_controllable_state", "React", "import_constants", "import_context", "import_SelectContent", "import_SelectImpl", "import_SelectScrollButton", "import_SelectViewport", "import_useSelectBreakpointActive", "TRIGGER_NAME", "props", "forwardedRef", "__scopeSelect", "disabled", "ariaLabelledby", "triggerProps", "context", "labelledBy", "VALUE_NAME", "SelectValueFrame", "SelectValue", "childrenProp", "placeholder", "onValueNodeHasChildrenChange", "composedRefs", "children", "hasChildren", "selectValueChildren", "ITEM_NAME", "SelectItemContextProvider", "useSelectItemContext", "value", "textValueProp", "index", "itemProps", "isSelected", "textId", "selectedIndex", "setSelectedIndex", "listRef", "open", "setOpen", "onChange", "setActiveIndex", "allowMouseUpRef", "allowSelectRef", "setValueAtIndex", "selectTimeoutRef", "dataRef", "node", "handleSelect", "selectItemProps", "event", "ITEM_TEXT_NAME", "SelectItemText", "className", "itemTextProps", "itemContext", "ref", "contents", "ITEM_INDICATOR_NAME", "SelectItemIndicatorFrame", "SelectItemIndicator", "itemIndicatorProps", "GROUP_NAME", "SelectGroupContextProvider", "useSelectGroupContext", "SelectGroup", "groupProps", "groupId", "LABEL_NAME", "SelectLabel", "labelProps", "groupContext", "SelectSheetController", "showSheet", "breakpointActive", "getShowSheet", "val", "SelectSheetImpl", "openProp", "defaultOpen", "onOpenChange", "valueProp", "defaultValue", "onValueChange", "sizeProp", "dir", "id", "scopeKey", "when", "AdaptProvider", "sheetBreakpoint", "SelectImpl", "forceUpdate", "selectedItem", "setSelectedItem", "setValue", "activeIndex", "selectedIndexRef", "activeIndexRef", "listContentRef", "valueNode", "setValueNode", "valueNodeHasChildren", "setValueNodeHasChildren"]
|
|
7
7
|
}
|
|
@@ -1,55 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var SelectContent_exports = {};
|
|
20
|
-
__export(SelectContent_exports, {
|
|
21
|
-
SelectContent: () => SelectContent
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(SelectContent_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
var import_react = require("@floating-ui/react");
|
|
26
|
-
var import_core = require("@tamagui/core");
|
|
27
|
-
var import_dismissable = require("@tamagui/dismissable");
|
|
28
|
-
var import_focus_scope = require("@tamagui/focus-scope");
|
|
29
|
-
var import_context = require("./context");
|
|
30
|
-
var import_useSelectBreakpointActive = require("./useSelectBreakpointActive");
|
|
31
|
-
const CONTENT_NAME = "SelectContent";
|
|
32
|
-
const SelectContent = ({
|
|
33
|
-
children,
|
|
34
|
-
__scopeSelect,
|
|
35
|
-
zIndex = 1e3,
|
|
36
|
-
...focusScopeProps
|
|
37
|
-
}) => {
|
|
38
|
-
const context = (0, import_context.useSelectContext)(CONTENT_NAME, __scopeSelect);
|
|
39
|
-
const themeName = (0, import_core.useThemeName)();
|
|
40
|
-
const showSheet = (0, import_useSelectBreakpointActive.useShowSelectSheet)(context);
|
|
41
|
-
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { forceClassName: true, name: themeName, children });
|
|
42
|
-
const touch = (0, import_core.useIsTouchDevice)();
|
|
43
|
-
if (showSheet) {
|
|
44
|
-
if (!context.open) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: contents });
|
|
48
|
-
}
|
|
49
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.FloatingPortal, { children: context.open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.FloatingOverlay, { style: { zIndex }, lockScroll: !touch, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_focus_scope.FocusScope, { loop: true, trapped: true, ...focusScopeProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dismissable.Dismissable, { children: contents }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "none" }, children: contents }) });
|
|
50
|
-
};
|
|
51
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
-
0 && (module.exports = {
|
|
53
|
-
SelectContent
|
|
54
|
-
});
|
|
1
|
+
"use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var T=(t,o)=>{for(var n in o)p(t,n,{get:o[n],enumerable:!0})},v=(t,o,n,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of N(o))!P.call(t,s)&&s!==n&&p(t,s,{get:()=>o[s],enumerable:!(c=C(o,s))||c.enumerable});return t};var y=t=>v(p({},"__esModule",{value:!0}),t);var D={};T(D,{SelectContent:()=>g});module.exports=y(D);var e=require("react/jsx-runtime"),l=require("@floating-ui/react"),r=require("@tamagui/core"),i=require("@tamagui/dismissable"),a=require("@tamagui/focus-scope"),S=require("./context"),u=require("./useSelectBreakpointActive");const d="SelectContent",g=({children:t,__scopeSelect:o,zIndex:n=1e3,...c})=>{const s=(0,S.useSelectContext)(d,o),f=(0,r.useThemeName)(),h=(0,u.useShowSelectSheet)(s),m=(0,e.jsx)(r.Theme,{forceClassName:!0,name:f,children:t}),F=(0,r.useIsTouchDevice)();return h?s.open?(0,e.jsx)(e.Fragment,{children:m}):null:(0,e.jsx)(l.FloatingPortal,{children:s.open?(0,e.jsx)(l.FloatingOverlay,{style:{zIndex:n},lockScroll:!F,children:(0,e.jsx)(a.FocusScope,{loop:!0,trapped:!0,...c,children:(0,e.jsx)(i.Dismissable,{children:m})})}):(0,e.jsx)("div",{style:{display:"none"},children:m})})};0&&(module.exports={SelectContent});
|
|
55
2
|
//# sourceMappingURL=SelectContent.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectContent.tsx"],
|
|
4
4
|
"sourcesContent": ["import { FloatingOverlay, FloatingPortal } from '@floating-ui/react'\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 = (\n <Theme forceClassName name={themeName}>\n {children}\n </Theme>\n )\n const touch = useIsTouchDevice()\n\n if (showSheet) {\n if (!context.open) {\n return null\n }\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>{contents}</Dismissable>\n </FocusScope>\n </FloatingOverlay>\n ) : (\n <div style={{ display: 'none' }}>{contents}</div>\n )}\n </FloatingPortal>\n )\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAyBI,IAAAI,EAAA,6BAzBJC,EAAgD,8BAChDC,EAAsD,yBACtDC,EAA4B,gCAC5BC,EAA4C,gCAE5CC,EAAiC,qBAEjCC,EAAmC,uCAMnC,MAAMC,EAAe,gBAERT,EAAgB,CAAC,CAC5B,SAAAU,EACA,cAAAC,EACA,OAAAC,EAAS,IACT,GAAGC,CACL,IAA4C,CAC1C,MAAMC,KAAU,oBAAiBL,EAAcE,CAAa,EACtDI,KAAY,gBAAa,EACzBC,KAAY,sBAAmBF,CAAO,EACtCG,KACJ,OAAC,SAAM,eAAc,GAAC,KAAMF,EACzB,SAAAL,EACH,EAEIQ,KAAQ,oBAAiB,EAE/B,OAAIF,EACGF,EAAQ,QAGN,mBAAG,SAAAG,EAAS,EAFV,QAMT,OAAC,kBACE,SAAAH,EAAQ,QACP,OAAC,mBAAgB,MAAO,CAAE,OAAAF,CAAO,EAAG,WAAY,CAACM,EAC/C,mBAAC,cAAW,KAAI,GAAC,QAAO,GAAE,GAAGL,EAC3B,mBAAC,eAAa,SAAAI,EAAS,EACzB,EACF,KAEA,OAAC,OAAI,MAAO,CAAE,QAAS,MAAO,EAAI,SAAAA,EAAS,EAE/C,CAEJ",
|
|
6
|
+
"names": ["SelectContent_exports", "__export", "SelectContent", "__toCommonJS", "import_jsx_runtime", "import_react", "import_core", "import_dismissable", "import_focus_scope", "import_context", "import_useSelectBreakpointActive", "CONTENT_NAME", "children", "__scopeSelect", "zIndex", "focusScopeProps", "context", "themeName", "showSheet", "contents", "touch"]
|
|
7
7
|
}
|
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var SelectContent_native_exports = {};
|
|
20
|
-
__export(SelectContent_native_exports, {
|
|
21
|
-
SelectContent: () => SelectContent
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(SelectContent_native_exports);
|
|
24
|
-
const SelectContent = ({ children }) => {
|
|
25
|
-
return children;
|
|
26
|
-
};
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
SelectContent
|
|
30
|
-
});
|
|
1
|
+
"use strict";var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var n in e)r(t,n,{get:e[n],enumerable:!0})},S=(t,e,n,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of l(e))!s.call(t,o)&&o!==n&&r(t,o,{get:()=>e[o],enumerable:!(c=p(e,o))||c.enumerable});return t};var m=t=>S(r({},"__esModule",{value:!0}),t);var f={};C(f,{SelectContent:()=>P});module.exports=m(f);const P=({children:t})=>t;0&&(module.exports={SelectContent});
|
|
31
2
|
//# sourceMappingURL=SelectContent.native.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectContent.native.tsx"],
|
|
4
4
|
"sourcesContent": ["import { SelectContentProps } from './types'\n\nexport const SelectContent = ({ children }: SelectContentProps) => {\n return children\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAEO,MAAME,EAAgB,CAAC,CAAE,SAAAE,CAAS,IAChCA",
|
|
6
|
+
"names": ["SelectContent_native_exports", "__export", "SelectContent", "__toCommonJS", "children"]
|
|
7
7
|
}
|
package/dist/cjs/SelectImpl.js
CHANGED
|
@@ -1,309 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var SelectImpl_exports = {};
|
|
30
|
-
__export(SelectImpl_exports, {
|
|
31
|
-
SelectInlineImpl: () => SelectInlineImpl
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(SelectImpl_exports);
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
var import_react = require("@floating-ui/react");
|
|
36
|
-
var import_core = require("@tamagui/core");
|
|
37
|
-
var React = __toESM(require("react"));
|
|
38
|
-
var import_react_dom = require("react-dom");
|
|
39
|
-
var import_constants = require("./constants");
|
|
40
|
-
var import_context = require("./context");
|
|
41
|
-
const SelectInlineImpl = (props) => {
|
|
42
|
-
const {
|
|
43
|
-
__scopeSelect,
|
|
44
|
-
children,
|
|
45
|
-
open = false,
|
|
46
|
-
selectedIndexRef,
|
|
47
|
-
listContentRef
|
|
48
|
-
} = props;
|
|
49
|
-
const selectContext = (0, import_context.useSelectContext)("SelectSheetImpl", __scopeSelect);
|
|
50
|
-
const {
|
|
51
|
-
setActiveIndex,
|
|
52
|
-
setOpen,
|
|
53
|
-
setSelectedIndex,
|
|
54
|
-
selectedIndex,
|
|
55
|
-
activeIndex,
|
|
56
|
-
forceUpdate
|
|
57
|
-
} = selectContext;
|
|
58
|
-
const [scrollTop, setScrollTop] = React.useState(0);
|
|
59
|
-
const touch = (0, import_core.useIsTouchDevice)();
|
|
60
|
-
const listItemsRef = React.useRef([]);
|
|
61
|
-
const overflowRef = React.useRef(null);
|
|
62
|
-
const upArrowRef = React.useRef(null);
|
|
63
|
-
const downArrowRef = React.useRef(null);
|
|
64
|
-
const allowSelectRef = React.useRef(false);
|
|
65
|
-
const allowMouseUpRef = React.useRef(true);
|
|
66
|
-
const selectTimeoutRef = React.useRef();
|
|
67
|
-
const state = React.useRef({
|
|
68
|
-
isMouseOutside: false
|
|
69
|
-
});
|
|
70
|
-
const [controlledScrolling, setControlledScrolling] = React.useState(false);
|
|
71
|
-
const [fallback, setFallback] = React.useState(false);
|
|
72
|
-
const [innerOffset, setInnerOffset] = React.useState(0);
|
|
73
|
-
const [blockSelection, setBlockSelection] = React.useState(false);
|
|
74
|
-
const floatingStyle = React.useRef({});
|
|
75
|
-
React.useEffect(() => {
|
|
76
|
-
const frame = requestAnimationFrame(() => {
|
|
77
|
-
if (!open) {
|
|
78
|
-
setScrollTop(0);
|
|
79
|
-
setFallback(false);
|
|
80
|
-
setActiveIndex(null);
|
|
81
|
-
setControlledScrolling(false);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
return () => {
|
|
85
|
-
cancelAnimationFrame(frame);
|
|
86
|
-
};
|
|
87
|
-
}, [open, setActiveIndex]);
|
|
88
|
-
if (import_core.isWeb && import_core.isClient) {
|
|
89
|
-
React.useEffect(() => {
|
|
90
|
-
if (!open)
|
|
91
|
-
return;
|
|
92
|
-
const mouseUp = (e) => {
|
|
93
|
-
if (state.current.isMouseOutside) {
|
|
94
|
-
setOpen(false);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
document.addEventListener("mouseup", mouseUp);
|
|
98
|
-
return () => {
|
|
99
|
-
document.removeEventListener("mouseup", mouseUp);
|
|
100
|
-
};
|
|
101
|
-
}, [open]);
|
|
102
|
-
}
|
|
103
|
-
const updateFloatingSize = (0, import_react.size)({
|
|
104
|
-
apply({
|
|
105
|
-
availableHeight,
|
|
106
|
-
rects: {
|
|
107
|
-
reference: { width }
|
|
108
|
-
}
|
|
109
|
-
}) {
|
|
110
|
-
floatingStyle.current = {
|
|
111
|
-
width,
|
|
112
|
-
maxHeight: availableHeight
|
|
113
|
-
};
|
|
114
|
-
},
|
|
115
|
-
padding: import_constants.WINDOW_PADDING
|
|
116
|
-
});
|
|
117
|
-
const { x, y, reference, floating, strategy, context, refs } = (0, import_react.useFloating)({
|
|
118
|
-
open,
|
|
119
|
-
onOpenChange: setOpen,
|
|
120
|
-
whileElementsMounted: import_react.autoUpdate,
|
|
121
|
-
placement: "bottom-start",
|
|
122
|
-
middleware: fallback ? [
|
|
123
|
-
(0, import_react.offset)(5),
|
|
124
|
-
...[
|
|
125
|
-
touch ? (0, import_react.shift)({ crossAxis: true, padding: import_constants.WINDOW_PADDING }) : (0, import_react.flip)({ padding: import_constants.WINDOW_PADDING })
|
|
126
|
-
],
|
|
127
|
-
updateFloatingSize
|
|
128
|
-
] : [
|
|
129
|
-
(0, import_react.inner)({
|
|
130
|
-
listRef: listItemsRef,
|
|
131
|
-
overflowRef,
|
|
132
|
-
index: selectedIndex,
|
|
133
|
-
offset: innerOffset,
|
|
134
|
-
onFallbackChange: setFallback,
|
|
135
|
-
padding: 10,
|
|
136
|
-
minItemsVisible: touch ? 10 : 4,
|
|
137
|
-
referenceOverflowThreshold: 20
|
|
138
|
-
}),
|
|
139
|
-
updateFloatingSize
|
|
140
|
-
]
|
|
141
|
-
});
|
|
142
|
-
const floatingRef = refs.floating;
|
|
143
|
-
const showUpArrow = open && scrollTop > import_constants.SCROLL_ARROW_THRESHOLD;
|
|
144
|
-
const showDownArrow = open && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - import_constants.SCROLL_ARROW_THRESHOLD;
|
|
145
|
-
const interactions = (0, import_react.useInteractions)([
|
|
146
|
-
(0, import_react.useClick)(context, { event: "mousedown" }),
|
|
147
|
-
(0, import_react.useDismiss)(context, { outsidePress: true }),
|
|
148
|
-
(0, import_react.useRole)(context, { role: "listbox" }),
|
|
149
|
-
(0, import_react.useInnerOffset)(context, {
|
|
150
|
-
enabled: !fallback,
|
|
151
|
-
onChange: setInnerOffset,
|
|
152
|
-
overflowRef
|
|
153
|
-
}),
|
|
154
|
-
(0, import_react.useListNavigation)(context, {
|
|
155
|
-
listRef: listItemsRef,
|
|
156
|
-
activeIndex,
|
|
157
|
-
selectedIndex,
|
|
158
|
-
onNavigate: setActiveIndex
|
|
159
|
-
}),
|
|
160
|
-
(0, import_react.useTypeahead)(context, {
|
|
161
|
-
listRef: listContentRef,
|
|
162
|
-
onMatch: open ? setActiveIndex : setSelectedIndex,
|
|
163
|
-
selectedIndex,
|
|
164
|
-
activeIndex
|
|
165
|
-
})
|
|
166
|
-
]);
|
|
167
|
-
const interactionsContext = React.useMemo(() => {
|
|
168
|
-
return {
|
|
169
|
-
...interactions,
|
|
170
|
-
getReferenceProps() {
|
|
171
|
-
return interactions.getReferenceProps({
|
|
172
|
-
ref: reference,
|
|
173
|
-
className: "SelectTrigger",
|
|
174
|
-
onKeyDown(event) {
|
|
175
|
-
if (event.key === "Enter" || event.key === " " && !context.dataRef.current.typing) {
|
|
176
|
-
event.preventDefault();
|
|
177
|
-
setOpen(true);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
},
|
|
182
|
-
getFloatingProps(props2) {
|
|
183
|
-
return interactions.getFloatingProps({
|
|
184
|
-
ref: floating,
|
|
185
|
-
className: "Select",
|
|
186
|
-
...props2,
|
|
187
|
-
style: {
|
|
188
|
-
position: strategy,
|
|
189
|
-
top: y ?? "",
|
|
190
|
-
left: x ?? "",
|
|
191
|
-
outline: 0,
|
|
192
|
-
scrollbarWidth: "none",
|
|
193
|
-
...floatingStyle.current,
|
|
194
|
-
...props2 == null ? void 0 : props2.style
|
|
195
|
-
},
|
|
196
|
-
onPointerEnter() {
|
|
197
|
-
setControlledScrolling(false);
|
|
198
|
-
state.current.isMouseOutside = false;
|
|
199
|
-
},
|
|
200
|
-
onPointerLeave() {
|
|
201
|
-
state.current.isMouseOutside = true;
|
|
202
|
-
},
|
|
203
|
-
onPointerMove() {
|
|
204
|
-
state.current.isMouseOutside = false;
|
|
205
|
-
setControlledScrolling(false);
|
|
206
|
-
},
|
|
207
|
-
onKeyDown() {
|
|
208
|
-
setControlledScrolling(true);
|
|
209
|
-
},
|
|
210
|
-
onContextMenu(e) {
|
|
211
|
-
e.preventDefault();
|
|
212
|
-
},
|
|
213
|
-
onScroll(event) {
|
|
214
|
-
(0, import_react_dom.flushSync)(() => setScrollTop(event.currentTarget.scrollTop));
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
}, [floating, y, x, interactions]);
|
|
220
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
221
|
-
if (open) {
|
|
222
|
-
selectTimeoutRef.current = setTimeout(() => {
|
|
223
|
-
allowSelectRef.current = true;
|
|
224
|
-
}, 300);
|
|
225
|
-
return () => {
|
|
226
|
-
clearTimeout(selectTimeoutRef.current);
|
|
227
|
-
};
|
|
228
|
-
} else {
|
|
229
|
-
allowSelectRef.current = false;
|
|
230
|
-
allowMouseUpRef.current = true;
|
|
231
|
-
setInnerOffset(0);
|
|
232
|
-
setFallback(false);
|
|
233
|
-
setBlockSelection(false);
|
|
234
|
-
}
|
|
235
|
-
}, [open]);
|
|
236
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
237
|
-
function onPointerDown(e) {
|
|
238
|
-
var _a, _b, _c;
|
|
239
|
-
const target = e.target;
|
|
240
|
-
if (!(((_a = refs.floating.current) == null ? void 0 : _a.contains(target)) || ((_b = upArrowRef.current) == null ? void 0 : _b.contains(target)) || ((_c = downArrowRef.current) == null ? void 0 : _c.contains(target)))) {
|
|
241
|
-
setOpen(false);
|
|
242
|
-
setControlledScrolling(false);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (open) {
|
|
246
|
-
document.addEventListener("pointerdown", onPointerDown);
|
|
247
|
-
return () => {
|
|
248
|
-
document.removeEventListener("pointerdown", onPointerDown);
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
}, [open, refs, setOpen]);
|
|
252
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
253
|
-
var _a, _b;
|
|
254
|
-
if (open && controlledScrolling) {
|
|
255
|
-
if (activeIndex != null) {
|
|
256
|
-
(_a = listItemsRef.current[activeIndex]) == null ? void 0 : _a.scrollIntoView({ block: "nearest" });
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
setScrollTop(((_b = refs.floating.current) == null ? void 0 : _b.scrollTop) ?? 0);
|
|
260
|
-
}, [open, refs, controlledScrolling, activeIndex]);
|
|
261
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
262
|
-
var _a;
|
|
263
|
-
if (open && fallback) {
|
|
264
|
-
if (selectedIndex != null) {
|
|
265
|
-
(_a = listItemsRef.current[selectedIndex]) == null ? void 0 : _a.scrollIntoView({ block: "nearest" });
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}, [open, fallback, selectedIndex]);
|
|
269
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
270
|
-
if (refs.floating.current && fallback) {
|
|
271
|
-
refs.floating.current.style.maxHeight = "";
|
|
272
|
-
}
|
|
273
|
-
}, [refs, fallback]);
|
|
274
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
275
|
-
import_context.SelectProvider,
|
|
276
|
-
{
|
|
277
|
-
scope: __scopeSelect,
|
|
278
|
-
...selectContext,
|
|
279
|
-
setScrollTop,
|
|
280
|
-
setInnerOffset,
|
|
281
|
-
floatingRef,
|
|
282
|
-
setValueAtIndex: (index, value) => {
|
|
283
|
-
listContentRef.current[index] = value;
|
|
284
|
-
},
|
|
285
|
-
fallback,
|
|
286
|
-
interactions: interactionsContext,
|
|
287
|
-
floatingContext: context,
|
|
288
|
-
activeIndex,
|
|
289
|
-
canScrollDown: !!showDownArrow,
|
|
290
|
-
canScrollUp: !!showUpArrow,
|
|
291
|
-
controlledScrolling,
|
|
292
|
-
dataRef: context.dataRef,
|
|
293
|
-
listRef: listItemsRef,
|
|
294
|
-
blockSelection,
|
|
295
|
-
allowMouseUpRef,
|
|
296
|
-
upArrowRef,
|
|
297
|
-
downArrowRef,
|
|
298
|
-
selectTimeoutRef,
|
|
299
|
-
allowSelectRef,
|
|
300
|
-
children
|
|
301
|
-
}
|
|
302
|
-
);
|
|
303
|
-
};
|
|
304
|
-
const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
|
|
305
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
306
|
-
0 && (module.exports = {
|
|
307
|
-
SelectInlineImpl
|
|
308
|
-
});
|
|
1
|
+
"use strict";var le=Object.create;var O=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var fe=(s,r)=>{for(var i in r)O(s,i,{get:r[i],enumerable:!0})},J=(s,r,i,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of ie(r))!ae.call(s,m)&&m!==i&&O(s,m,{get:()=>r[m],enumerable:!(n=ce(r,m))||n.enumerable});return s};var de=(s,r,i)=>(i=s!=null?le(ue(s)):{},J(r||!s||!s.__esModule?O(i,"default",{value:s,enumerable:!0}):i,s)),me=s=>J(O({},"__esModule",{value:!0}),s);var ge={};fe(ge,{SelectInlineImpl:()=>pe});module.exports=me(ge);var X=require("react/jsx-runtime"),e=require("@floating-ui/react"),c=require("@tamagui/core"),o=de(require("react")),Q=require("react-dom"),d=require("./constants"),T=require("./context");const pe=s=>{const{__scopeSelect:r,children:i,open:n=!1,selectedIndexRef:m,listContentRef:C}=s,L=(0,T.useSelectContext)("SelectSheetImpl",r),{setActiveIndex:v,setOpen:R,setSelectedIndex:Y,selectedIndex:p,activeIndex:g,forceUpdate:Re}=L,[k,I]=o.useState(0),H=(0,c.useIsTouchDevice)(),S=o.useRef([]),F=o.useRef(null),N=o.useRef(null),U=o.useRef(null),b=o.useRef(!1),W=o.useRef(!0),A=o.useRef(),h=o.useRef({isMouseOutside:!1}),[E,w]=o.useState(!1),[f,M]=o.useState(!1),[Z,D]=o.useState(0),[$,ee]=o.useState(!1),_=o.useRef({});o.useEffect(()=>{const t=requestAnimationFrame(()=>{n||(I(0),M(!1),v(null),w(!1))});return()=>{cancelAnimationFrame(t)}},[n,v]),c.isWeb&&c.isClient&&o.useEffect(()=>{if(!n)return;const t=l=>{h.current.isMouseOutside&&R(!1)};return document.addEventListener("mouseup",t),()=>{document.removeEventListener("mouseup",t)}},[n]);const V=(0,e.size)({apply({availableHeight:t,rects:{reference:{width:l}}}){_.current={width:l,maxHeight:t}},padding:d.WINDOW_PADDING}),{x:q,y:z,reference:te,floating:K,strategy:ne,context:u,refs:a}=(0,e.useFloating)({open:n,onOpenChange:R,whileElementsMounted:e.autoUpdate,placement:"bottom-start",middleware:f?[(0,e.offset)(5),H?(0,e.shift)({crossAxis:!0,padding:d.WINDOW_PADDING}):(0,e.flip)({padding:d.WINDOW_PADDING}),V]:[(0,e.inner)({listRef:S,overflowRef:F,index:p,offset:Z,onFallbackChange:M,padding:10,minItemsVisible:H?10:4,referenceOverflowThreshold:20}),V]}),x=a.floating,oe=n&&k>d.SCROLL_ARROW_THRESHOLD,se=n&&x.current&&k<x.current.scrollHeight-x.current.clientHeight-d.SCROLL_ARROW_THRESHOLD,y=(0,e.useInteractions)([(0,e.useClick)(u,{event:"mousedown"}),(0,e.useDismiss)(u,{outsidePress:!0}),(0,e.useRole)(u,{role:"listbox"}),(0,e.useInnerOffset)(u,{enabled:!f,onChange:D,overflowRef:F}),(0,e.useListNavigation)(u,{listRef:S,activeIndex:g,selectedIndex:p,onNavigate:v}),(0,e.useTypeahead)(u,{listRef:C,onMatch:n?v:Y,selectedIndex:p,activeIndex:g})]),re=o.useMemo(()=>({...y,getReferenceProps(){return y.getReferenceProps({ref:te,className:"SelectTrigger",onKeyDown(t){(t.key==="Enter"||t.key===" "&&!u.dataRef.current.typing)&&(t.preventDefault(),R(!0))}})},getFloatingProps(t){return y.getFloatingProps({ref:K,className:"Select",...t,style:{position:ne,top:z??"",left:q??"",outline:0,scrollbarWidth:"none",..._.current,...t==null?void 0:t.style},onPointerEnter(){w(!1),h.current.isMouseOutside=!1},onPointerLeave(){h.current.isMouseOutside=!0},onPointerMove(){h.current.isMouseOutside=!1,w(!1)},onKeyDown(){w(!0)},onContextMenu(l){l.preventDefault()},onScroll(l){(0,Q.flushSync)(()=>I(l.currentTarget.scrollTop))}})}}),[K,z,q,y]);return(0,c.useIsomorphicLayoutEffect)(()=>{if(n)return A.current=setTimeout(()=>{b.current=!0},300),()=>{clearTimeout(A.current)};b.current=!1,W.current=!0,D(0),M(!1),ee(!1)},[n]),(0,c.useIsomorphicLayoutEffect)(()=>{function t(l){var j,B,G;const P=l.target;(j=a.floating.current)!=null&&j.contains(P)||(B=N.current)!=null&&B.contains(P)||(G=U.current)!=null&&G.contains(P)||(R(!1),w(!1))}if(n)return document.addEventListener("pointerdown",t),()=>{document.removeEventListener("pointerdown",t)}},[n,a,R]),(0,c.useIsomorphicLayoutEffect)(()=>{var t,l;n&&E&&g!=null&&((t=S.current[g])==null||t.scrollIntoView({block:"nearest"})),I(((l=a.floating.current)==null?void 0:l.scrollTop)??0)},[n,a,E,g]),(0,c.useIsomorphicLayoutEffect)(()=>{var t;n&&f&&p!=null&&((t=S.current[p])==null||t.scrollIntoView({block:"nearest"}))},[n,f,p]),(0,c.useIsomorphicLayoutEffect)(()=>{a.floating.current&&f&&(a.floating.current.style.maxHeight="")},[a,f]),(0,X.jsx)(T.SelectProvider,{scope:r,...L,setScrollTop:I,setInnerOffset:D,floatingRef:x,setValueAtIndex:(t,l)=>{C.current[t]=l},fallback:f,interactions:re,floatingContext:u,activeIndex:g,canScrollDown:!!se,canScrollUp:!!oe,controlledScrolling:E,dataRef:u.dataRef,listRef:S,blockSelection:$,allowMouseUpRef:W,upArrowRef:N,downArrowRef:U,selectTimeoutRef:A,allowSelectRef:b,children:i})},he=typeof navigator<"u"&&navigator.userAgent||"";0&&(module.exports={SelectInlineImpl});
|
|
309
2
|
//# sourceMappingURL=SelectImpl.js.map
|