@tamagui/select 1.0.1-beta.115 → 1.0.1-beta.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Select.js +9 -20
- package/dist/cjs/Select.js.map +2 -2
- package/dist/cjs/SelectImpl.js +11 -7
- package/dist/cjs/SelectImpl.js.map +2 -2
- package/dist/cjs/SelectViewport.native.js +2 -2
- package/dist/cjs/SelectViewport.native.js.map +2 -2
- package/dist/esm/Select.js +9 -18
- package/dist/esm/Select.js.map +2 -2
- package/dist/esm/SelectImpl.js +5 -1
- package/dist/esm/SelectImpl.js.map +2 -2
- package/dist/esm/SelectViewport.native.js +2 -2
- package/dist/esm/SelectViewport.native.js.map +2 -2
- package/dist/jsx/Select.js +1 -19
- package/dist/jsx/Select.js.map +2 -2
- package/dist/jsx/SelectImpl.js +6 -1
- package/dist/jsx/SelectImpl.js.map +2 -2
- package/dist/jsx/SelectViewport.native.js +2 -3
- package/dist/jsx/SelectViewport.native.js.map +2 -2
- package/package.json +12 -12
- package/src/Select.tsx +9 -20
- package/src/SelectImpl.tsx +8 -1
- package/src/SelectViewport.native.tsx +5 -8
- package/types/Select.d.ts +12 -14
- package/types/Select.d.ts.map +1 -1
- package/types/SelectImpl.d.ts.map +1 -1
- package/types/SelectViewport.d.ts +3 -3
- package/types/SelectViewport.native.d.ts +6 -53
- package/types/SelectViewport.native.d.ts.map +1 -1
- package/types/BubbleSelect.d.ts +0 -2
- package/types/BubbleSelect.d.ts.map +0 -1
package/dist/cjs/Select.js
CHANGED
|
@@ -29,8 +29,6 @@ __export(Select_exports, {
|
|
|
29
29
|
SelectSeparator: () => SelectSeparator,
|
|
30
30
|
SelectSheetContents: () => SelectSheetContents,
|
|
31
31
|
SelectTrigger: () => SelectTrigger,
|
|
32
|
-
getVisualOffsetTop: () => getVisualOffsetTop,
|
|
33
|
-
isFirefox: () => isFirefox,
|
|
34
32
|
useSelectBreakpointActive: () => useSelectBreakpointActive,
|
|
35
33
|
useShowSelectSheet: () => useShowSelectSheet
|
|
36
34
|
});
|
|
@@ -54,22 +52,7 @@ var import_SelectContent = require("./SelectContent");
|
|
|
54
52
|
var import_SelectImpl = require("./SelectImpl");
|
|
55
53
|
var import_SelectScrollButton = require("./SelectScrollButton");
|
|
56
54
|
var import_SelectViewport = require("./SelectViewport");
|
|
57
|
-
const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
|
|
58
|
-
const isFirefox = userAgent.toLowerCase().includes("firefox");
|
|
59
|
-
function getVisualOffsetTop() {
|
|
60
|
-
return !/^((?!chrome|android).)*safari/i.test(userAgent) ? (visualViewport == null ? void 0 : visualViewport.offsetTop) ?? 0 : 0;
|
|
61
|
-
}
|
|
62
55
|
const TRIGGER_NAME = "SelectTrigger";
|
|
63
|
-
const SelectTriggerFrame = (0, import_core2.styled)(import_list_item.ListItem, {
|
|
64
|
-
componentName: TRIGGER_NAME,
|
|
65
|
-
backgrounded: true,
|
|
66
|
-
radiused: true,
|
|
67
|
-
hoverTheme: true,
|
|
68
|
-
pressTheme: true,
|
|
69
|
-
focusTheme: true,
|
|
70
|
-
focusable: false,
|
|
71
|
-
borderWidth: 1
|
|
72
|
-
});
|
|
73
56
|
const SelectTrigger = React.forwardRef((props, forwardedRef) => {
|
|
74
57
|
const {
|
|
75
58
|
__scopeSelect,
|
|
@@ -79,7 +62,15 @@ const SelectTrigger = React.forwardRef((props, forwardedRef) => {
|
|
|
79
62
|
} = props;
|
|
80
63
|
const context = (0, import_context.useSelectContext)(TRIGGER_NAME, __scopeSelect);
|
|
81
64
|
const labelledBy = ariaLabelledby;
|
|
82
|
-
return /* @__PURE__ */ React.createElement(
|
|
65
|
+
return /* @__PURE__ */ React.createElement(import_list_item.ListItem, {
|
|
66
|
+
componentName: TRIGGER_NAME,
|
|
67
|
+
backgrounded: true,
|
|
68
|
+
radiused: true,
|
|
69
|
+
hoverTheme: true,
|
|
70
|
+
pressTheme: true,
|
|
71
|
+
focusTheme: true,
|
|
72
|
+
focusable: true,
|
|
73
|
+
borderWidth: 1,
|
|
83
74
|
size: context.size,
|
|
84
75
|
"aria-expanded": context.open,
|
|
85
76
|
"aria-autocomplete": "none",
|
|
@@ -439,8 +430,6 @@ Select.displayName = import_constants.SELECT_NAME;
|
|
|
439
430
|
SelectSeparator,
|
|
440
431
|
SelectSheetContents,
|
|
441
432
|
SelectTrigger,
|
|
442
|
-
getVisualOffsetTop,
|
|
443
|
-
isFirefox,
|
|
444
433
|
useSelectBreakpointActive,
|
|
445
434
|
useShowSelectSheet
|
|
446
435
|
});
|
package/dist/cjs/Select.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Select.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\nimport { GetProps, TamaguiElement, isWeb, useMedia } 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 { Sheet, 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, SelectContextValue, SelectProps } from './types'\n\n// Cross browser fixes for pinch-zooming/backdrop-filter \uD83D\uDE44\nconst userAgent = (typeof navigator !== 'undefined' && navigator.userAgent) || ''\nexport const isFirefox = userAgent.toLowerCase().includes('firefox')\nexport function getVisualOffsetTop() {\n return !/^((?!chrome|android).)*safari/i.test(userAgent) ? visualViewport?.offsetTop ?? 0 : 0\n}\n\n/* -------------------------------------------------------------------------------------------------\n * SelectTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'SelectTrigger'\n\nexport type SelectTriggerProps = ListItemProps\n\nconst SelectTriggerFrame = styled(ListItem, {\n componentName: TRIGGER_NAME,\n backgrounded: true,\n radiused: true,\n hoverTheme: true,\n pressTheme: true,\n focusTheme: true,\n focusable: false,\n borderWidth: 1,\n})\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 <SelectTriggerFrame\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 {...(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 hasChildren = childrenProp !== undefined\n const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange)\n\n React.useLayoutEffect(() => {\n onValueNodeHasChildrenChange(hasChildren)\n }, [onValueNodeHasChildrenChange, hasChildren])\n\n const children = childrenProp ?? context.selectedItem\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 {context.value === undefined && placeholder !== undefined ? placeholder : children}\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 onItemTextChange(node: TamaguiElement | null): void\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 [textValue, setTextValue] = React.useState(textValueProp ?? '')\n const [isFocused, setIsFocused] = React.useState(false)\n const textId = useId()\n\n const {\n selectedIndex,\n setSelectedIndex,\n listRef,\n open,\n setOpen,\n onChange,\n activeIndex,\n setActiveIndex,\n setValueAtIndex,\n dataRef,\n } = context\n\n const composedRefs = useComposedRefs(\n forwardedRef,\n (node) => {\n if (!isWeb) return\n if (node instanceof HTMLElement) {\n if (listRef) {\n listRef.current[index] = node\n }\n }\n }\n // isSelected ? context.onSelectedItemChange : undefined\n )\n\n React.useEffect(() => {\n setValueAtIndex(index, value)\n }, [index, setValueAtIndex, value])\n\n const timeoutRef = React.useRef<any>()\n const [allowMouseUp, setAllowMouseUp] = React.useState(false)\n\n function handleSelect() {\n setSelectedIndex(index)\n onChange(value)\n setOpen(false)\n }\n\n React.useLayoutEffect(() => {\n clearTimeout(timeoutRef.current)\n if (open) {\n if (selectedIndex !== index) {\n setAllowMouseUp(true)\n } else {\n timeoutRef.current = setTimeout(() => {\n setAllowMouseUp(true)\n }, 300)\n }\n } else {\n setAllowMouseUp(false)\n }\n }, [open, index, setActiveIndex, selectedIndex])\n\n function handleKeyDown(event: React.KeyboardEvent) {\n if (event.key === 'Enter' || (event.key === ' ' && !dataRef?.current.typing)) {\n event.preventDefault()\n handleSelect()\n }\n }\n\n const selectItemProps = context.interactions\n ? context.interactions.getItemProps({\n onClick: allowMouseUp ? handleSelect : undefined,\n onMouseUp: allowMouseUp ? handleSelect : undefined,\n onKeyDown: handleKeyDown,\n })\n : {\n onPress: handleSelect,\n }\n\n return (\n <SelectItemContextProvider\n scope={__scopeSelect}\n value={value}\n textId={textId || ''}\n isSelected={isSelected}\n onItemTextChange={React.useCallback((node) => {\n // @ts-ignore\n setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? '').trim())\n }, [])}\n >\n <ListItem\n backgrounded\n pressTheme\n focusTheme\n componentName={ITEM_NAME}\n ref={composedRefs}\n aria-labelledby={textId}\n // `isFocused` caveat fixes stuttering in VoiceOver\n aria-selected={isSelected && isFocused}\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, itemContext.onItemTextChange)\n const isSelected = itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren\n\n const contents = (\n <SelectItemTextFrame\n className={className}\n size={context.size}\n id={itemContext.textId}\n {...itemTextProps}\n ref={composedRefs}\n />\n )\n\n // until portals work in sub-trees on RN, use this just for native:\n if (!isWeb) {\n React.useEffect(() => {\n if (isSelected) {\n context.setSelectedItem(contents)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isSelected])\n }\n\n return (\n <>\n {contents}\n\n {/* Portal the select item text into the trigger value node */}\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 // @ts-expect-error\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\nexport const useSelectBreakpointActive = (\n sheetBreakpoint: SelectContextValue['sheetBreakpoint']\n) => {\n const media = useMedia()\n return sheetBreakpoint ? media[sheetBreakpoint] : false\n}\n\nexport const useShowSelectSheet = (context: SelectContextValue) => {\n const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint)\n return context.open === false ? false : breakpointActive\n}\n\nconst SelectSheetController = (\n props: ScopedProps<{}> & {\n children: React.ReactNode\n onChangeOpen: 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 onChangeOpen={(val) => {\n if (getShowSheet()) {\n props.onChangeOpen(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 })\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue || '',\n onChange: onValueChange,\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 return (\n <SelectProvider\n dir={dir}\n size={sizeProp}\n selectedItem={selectedItem}\n setSelectedItem={setSelectedItem}\n forceUpdate={forceUpdate}\n valueNode={valueNode}\n onValueNodeChange={setValueNode}\n onValueNodeHasChildrenChange={setValueNodeHasChildren}\n valueNodeHasChildren={valueNodeHasChildren}\n scopeKey={__scopeSelect ? Object.keys(__scopeSelect)[0] : ''}\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 onChangeOpen={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,\n }\n)\n\n// @ts-ignore\nSelect.displayName = SELECT_NAME\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\nimport { GetProps, TamaguiElement, isWeb, useMedia } 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 { Sheet, 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, SelectContextValue, SelectProps } from './types'\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 {...(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 hasChildren = childrenProp !== undefined\n const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange)\n\n React.useLayoutEffect(() => {\n onValueNodeHasChildrenChange(hasChildren)\n }, [onValueNodeHasChildrenChange, hasChildren])\n\n const children = childrenProp ?? context.selectedItem\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 {context.value === undefined && placeholder !== undefined ? placeholder : children}\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 onItemTextChange(node: TamaguiElement | null): void\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 [textValue, setTextValue] = React.useState(textValueProp ?? '')\n const [isFocused, setIsFocused] = React.useState(false)\n const textId = useId()\n\n const {\n selectedIndex,\n setSelectedIndex,\n listRef,\n open,\n setOpen,\n onChange,\n activeIndex,\n setActiveIndex,\n setValueAtIndex,\n dataRef,\n } = context\n\n const composedRefs = useComposedRefs(\n forwardedRef,\n (node) => {\n if (!isWeb) return\n if (node instanceof HTMLElement) {\n if (listRef) {\n listRef.current[index] = node\n }\n }\n }\n // isSelected ? context.onSelectedItemChange : undefined\n )\n\n React.useEffect(() => {\n setValueAtIndex(index, value)\n }, [index, setValueAtIndex, value])\n\n const timeoutRef = React.useRef<any>()\n const [allowMouseUp, setAllowMouseUp] = React.useState(false)\n\n function handleSelect() {\n setSelectedIndex(index)\n onChange(value)\n setOpen(false)\n }\n\n React.useLayoutEffect(() => {\n clearTimeout(timeoutRef.current)\n if (open) {\n if (selectedIndex !== index) {\n setAllowMouseUp(true)\n } else {\n timeoutRef.current = setTimeout(() => {\n setAllowMouseUp(true)\n }, 300)\n }\n } else {\n setAllowMouseUp(false)\n }\n }, [open, index, setActiveIndex, selectedIndex])\n\n function handleKeyDown(event: React.KeyboardEvent) {\n if (event.key === 'Enter' || (event.key === ' ' && !dataRef?.current.typing)) {\n event.preventDefault()\n handleSelect()\n }\n }\n\n const selectItemProps = context.interactions\n ? context.interactions.getItemProps({\n onClick: allowMouseUp ? handleSelect : undefined,\n onMouseUp: allowMouseUp ? handleSelect : undefined,\n onKeyDown: handleKeyDown,\n })\n : {\n onPress: handleSelect,\n }\n\n return (\n <SelectItemContextProvider\n scope={__scopeSelect}\n value={value}\n textId={textId || ''}\n isSelected={isSelected}\n onItemTextChange={React.useCallback((node) => {\n // @ts-ignore\n setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? '').trim())\n }, [])}\n >\n <ListItem\n backgrounded\n pressTheme\n focusTheme\n componentName={ITEM_NAME}\n ref={composedRefs}\n aria-labelledby={textId}\n // `isFocused` caveat fixes stuttering in VoiceOver\n aria-selected={isSelected && isFocused}\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, itemContext.onItemTextChange)\n const isSelected = itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren\n\n const contents = (\n <SelectItemTextFrame\n className={className}\n size={context.size}\n id={itemContext.textId}\n {...itemTextProps}\n ref={composedRefs}\n />\n )\n\n // until portals work in sub-trees on RN, use this just for native:\n if (!isWeb) {\n React.useEffect(() => {\n if (isSelected) {\n context.setSelectedItem(contents)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isSelected])\n }\n\n return (\n <>\n {contents}\n\n {/* Portal the select item text into the trigger value node */}\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\nexport const useSelectBreakpointActive = (\n sheetBreakpoint: SelectContextValue['sheetBreakpoint']\n) => {\n const media = useMedia()\n return sheetBreakpoint ? media[sheetBreakpoint] : false\n}\n\nexport const useShowSelectSheet = (context: SelectContextValue) => {\n const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint)\n return context.open === false ? false : breakpointActive\n}\n\nconst SelectSheetController = (\n props: ScopedProps<{}> & {\n children: React.ReactNode\n onChangeOpen: 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 onChangeOpen={(val) => {\n if (getShowSheet()) {\n props.onChangeOpen(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 })\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue || '',\n onChange: onValueChange,\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 return (\n <SelectProvider\n dir={dir}\n size={sizeProp}\n selectedItem={selectedItem}\n setSelectedItem={setSelectedItem}\n forceUpdate={forceUpdate}\n valueNode={valueNode}\n onValueNodeChange={setValueNode}\n onValueNodeHasChildrenChange={setValueNodeHasChildren}\n valueNodeHasChildren={valueNodeHasChildren}\n scopeKey={__scopeSelect ? Object.keys(__scopeSelect)[0] : ''}\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 onChangeOpen={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,\n }\n)\n\n// @ts-ignore\nSelect.displayName = SELECT_NAME\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC;AAChC,kBAA0D;AAC1D,mBAAgF;AAChF,mBAAsB;AACtB,uBAAwC;AACxC,oBAA2B;AAC3B,uBAA0B;AAC1B,mBAAuC;AACvC,o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AAe;AAAA,EACf,UAAU;AAAA,EACV,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AAAA,EACV,eAAe;AAAA,EACf;AACF,CACF;AAGA,OAAO,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/SelectImpl.js
CHANGED
|
@@ -29,7 +29,6 @@ var import_react_use_previous = require("@radix-ui/react-use-previous");
|
|
|
29
29
|
var React = __toESM(require("react"));
|
|
30
30
|
var import_constants = require("./constants");
|
|
31
31
|
var import_context = require("./context");
|
|
32
|
-
var import_Select = require("./Select");
|
|
33
32
|
const SelectInlineImpl = (props) => {
|
|
34
33
|
const {
|
|
35
34
|
__scopeSelect,
|
|
@@ -171,17 +170,17 @@ const SelectInlineImpl = (props) => {
|
|
|
171
170
|
const rectBottom = rect.bottom;
|
|
172
171
|
const viewportHeight = (visualViewport == null ? void 0 : visualViewport.height) ?? 0;
|
|
173
172
|
const visualMaxHeight = viewportHeight - import_constants.WINDOW_PADDING * 2;
|
|
174
|
-
if (amount < 0 && selectedIndexRef.current != null && Math.round(rectBottom) < Math.round(viewportHeight +
|
|
173
|
+
if (amount < 0 && selectedIndexRef.current != null && Math.round(rectBottom) < Math.round(viewportHeight + getVisualOffsetTop() - import_constants.WINDOW_PADDING)) {
|
|
175
174
|
floating2.style.maxHeight = `${Math.min(visualMaxHeight, currentMaxHeight - amount)}px`;
|
|
176
175
|
}
|
|
177
|
-
if (amount > 0 && Math.round(rectTop) > Math.round(import_constants.WINDOW_PADDING -
|
|
178
|
-
const nextTop = Math.max(import_constants.WINDOW_PADDING +
|
|
176
|
+
if (amount > 0 && Math.round(rectTop) > Math.round(import_constants.WINDOW_PADDING - getVisualOffsetTop()) && floating2.scrollHeight > floating2.offsetHeight) {
|
|
177
|
+
const nextTop = Math.max(import_constants.WINDOW_PADDING + getVisualOffsetTop(), currentTop - amount);
|
|
179
178
|
const nextMaxHeight = Math.min(visualMaxHeight, currentMaxHeight + amount);
|
|
180
179
|
Object.assign(floating2.style, {
|
|
181
180
|
maxHeight: `${nextMaxHeight}px`,
|
|
182
181
|
top: `${nextTop}px`
|
|
183
182
|
});
|
|
184
|
-
if (nextTop - import_constants.WINDOW_PADDING >
|
|
183
|
+
if (nextTop - import_constants.WINDOW_PADDING > getVisualOffsetTop()) {
|
|
185
184
|
floating2.scrollTop -= nextMaxHeight - currentMaxHeight + getFloatingPadding(floating2);
|
|
186
185
|
}
|
|
187
186
|
return currentTop - nextTop;
|
|
@@ -200,7 +199,7 @@ const SelectInlineImpl = (props) => {
|
|
|
200
199
|
}
|
|
201
200
|
if (Math.abs(((currentTarget == null ? void 0 : currentTarget.offsetHeight) ?? 0) - (((visualViewport == null ? void 0 : visualViewport.height) ?? 0) - import_constants.WINDOW_PADDING * 2)) > 1 && !pinching) {
|
|
202
201
|
event.preventDefault();
|
|
203
|
-
} else if (isWheelEvent(event) &&
|
|
202
|
+
} else if (isWheelEvent(event) && isFirefox) {
|
|
204
203
|
currentTarget.scrollTop += event.deltaY;
|
|
205
204
|
}
|
|
206
205
|
if (!pinching) {
|
|
@@ -290,7 +289,7 @@ const SelectInlineImpl = (props) => {
|
|
|
290
289
|
return;
|
|
291
290
|
}
|
|
292
291
|
floating2.scrollTop = (_a = middlewareData.size) == null ? void 0 : _a.y;
|
|
293
|
-
const closeToBottom = ((visualViewport == null ? void 0 : visualViewport.height) ?? 0) +
|
|
292
|
+
const closeToBottom = ((visualViewport == null ? void 0 : visualViewport.height) ?? 0) + getVisualOffsetTop() - referenceRect.bottom < import_constants.FALLBACK_THRESHOLD;
|
|
294
293
|
const closeToTop = referenceRect.top < import_constants.FALLBACK_THRESHOLD;
|
|
295
294
|
if (floating2.offsetHeight < import_constants.MIN_HEIGHT || closeToTop || closeToBottom) {
|
|
296
295
|
setMiddlewareType("fallback");
|
|
@@ -386,6 +385,11 @@ const SelectInlineImpl = (props) => {
|
|
|
386
385
|
listRef: listItemsRef
|
|
387
386
|
}, children);
|
|
388
387
|
};
|
|
388
|
+
const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
|
|
389
|
+
const isFirefox = userAgent.toLowerCase().includes("firefox");
|
|
390
|
+
function getVisualOffsetTop() {
|
|
391
|
+
return !/^((?!chrome|android).)*safari/i.test(userAgent) ? (visualViewport == null ? void 0 : visualViewport.offsetTop) ?? 0 : 0;
|
|
392
|
+
}
|
|
389
393
|
// Annotate the CommonJS export names for ESM import in node:
|
|
390
394
|
0 && (module.exports = {
|
|
391
395
|
SelectInlineImpl
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectImpl.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n detectOverflow,\n flip,\n offset,\n size,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n useListNavigation,\n useRole,\n useTypeahead,\n} from '@floating-ui/react-dom-interactions'\nimport { usePrevious } from '@radix-ui/react-use-previous'\nimport * as React from 'react'\n\nimport { FALLBACK_THRESHOLD, MIN_HEIGHT, SCROLL_ARROW_THRESHOLD, WINDOW_PADDING } from './constants'\nimport { SelectProvider, useSelectContext } from './context'\nimport { getVisualOffsetTop, isFirefox } from './Select'\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 {\n __scopeSelect,\n children,\n open = false,\n activeIndexRef,\n selectedIndexRef,\n listContentRef,\n } = props\n\n const selectContext = useSelectContext('SelectSheetImpl', __scopeSelect)\n const { setActiveIndex, setOpen, setSelectedIndex, selectedIndex, activeIndex, forceUpdate } =\n selectContext\n const [showArrows, setShowArrows] = React.useState(false)\n const [scrollTop, setScrollTop] = React.useState(0)\n const prevActiveIndex = usePrevious<number | null>(activeIndex)\n\n const listItemsRef = React.useRef<Array<HTMLElement | null>>([])\n\n const [controlledScrolling, setControlledScrolling] = React.useState(false)\n const [middlewareType, setMiddlewareType] = React.useState<'align' | 'fallback'>('align')\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 setShowArrows(open)\n\n if (!open) {\n setScrollTop(0)\n setMiddlewareType('align')\n setActiveIndex(null)\n setControlledScrolling(false)\n }\n })\n return () => {\n cancelAnimationFrame(frame)\n }\n }, [open, setActiveIndex])\n\n function getFloatingPadding(floating: HTMLElement | null) {\n if (!floating) {\n return 0\n }\n return Number(getComputedStyle(floating).paddingLeft?.replace('px', ''))\n }\n\n const { x, y, reference, floating, strategy, context, refs, middlewareData, update } =\n useFloating({\n open,\n onOpenChange: setOpen,\n placement: 'bottom',\n middleware:\n middlewareType === 'align'\n ? [\n offset(({ rects }) => {\n const index = activeIndexRef.current ?? selectedIndexRef.current\n\n if (index == null) {\n return 0\n }\n\n const item = listItemsRef.current[index]\n\n if (item == null) {\n return 0\n }\n\n const offsetTop = item.offsetTop\n const itemHeight = item.offsetHeight\n const height = rects.reference.height\n\n return -offsetTop - height - (itemHeight - height) / 2\n }),\n // Custom `size` that can handle the opposite direction of the placement\n {\n name: 'size',\n async fn(args) {\n const {\n elements: { floating },\n rects: { reference },\n middlewareData,\n } = args\n\n const overflow = await detectOverflow(args, {\n padding: WINDOW_PADDING,\n })\n\n const top = Math.max(0, overflow.top)\n const bottom = Math.max(0, overflow.bottom)\n const nextY = args.y + top\n\n if (middlewareData.size?.skip) {\n return {\n y: nextY,\n data: {\n y: middlewareData.size.y,\n },\n }\n }\n\n Object.assign(floating.style, {\n maxHeight: `${floating.scrollHeight - Math.abs(top + bottom)}px`,\n minWidth: `${reference.width + getFloatingPadding(floating) * 2}px`,\n })\n\n return {\n y: nextY,\n data: {\n y: top,\n skip: true,\n },\n reset: {\n rects: true,\n },\n }\n },\n },\n ]\n : [\n offset(5),\n flip(),\n size({\n apply({ rects, availableHeight, elements }) {\n Object.assign(elements.floating.style, {\n width: `${rects.reference.width}px`,\n maxHeight: `${availableHeight}px`,\n })\n },\n padding: WINDOW_PADDING,\n }),\n ],\n })\n\n const floatingRef = refs.floating\n\n const showUpArrow = showArrows && scrollTop > SCROLL_ARROW_THRESHOLD\n const showDownArrow =\n showArrows &&\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 useRole(context, { role: 'listbox' }),\n useDismiss(context),\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 increaseHeight = React.useCallback(\n (floating: HTMLElement, amount = 0) => {\n if (middlewareType === 'fallback') {\n return\n }\n\n const currentMaxHeight = Number(floating.style.maxHeight.replace('px', ''))\n const currentTop = Number(floating.style.top.replace('px', ''))\n const rect = floating.getBoundingClientRect()\n const rectTop = rect.top\n const rectBottom = rect.bottom\n const viewportHeight = visualViewport?.height ?? 0\n const visualMaxHeight = viewportHeight - WINDOW_PADDING * 2\n\n if (\n amount < 0 &&\n selectedIndexRef.current != null &&\n Math.round(rectBottom) < Math.round(viewportHeight + getVisualOffsetTop() - WINDOW_PADDING)\n ) {\n floating.style.maxHeight = `${Math.min(visualMaxHeight, currentMaxHeight - amount)}px`\n }\n\n if (\n amount > 0 &&\n Math.round(rectTop) > Math.round(WINDOW_PADDING - getVisualOffsetTop()) &&\n floating.scrollHeight > floating.offsetHeight\n ) {\n const nextTop = Math.max(WINDOW_PADDING + getVisualOffsetTop(), currentTop - amount)\n\n const nextMaxHeight = Math.min(visualMaxHeight, currentMaxHeight + amount)\n\n Object.assign(floating.style, {\n maxHeight: `${nextMaxHeight}px`,\n top: `${nextTop}px`,\n })\n\n if (nextTop - WINDOW_PADDING > getVisualOffsetTop()) {\n floating.scrollTop -= nextMaxHeight - currentMaxHeight + getFloatingPadding(floating)\n }\n\n return currentTop - nextTop\n }\n },\n [middlewareType, selectedIndexRef]\n )\n\n const touchPageYRef = React.useRef<number | null>(null)\n\n const handleWheel = React.useCallback(\n (event: WheelEvent | TouchEvent) => {\n const pinching = event.ctrlKey\n\n const currentTarget = event.currentTarget as HTMLElement\n\n function isWheelEvent(event: any): event is WheelEvent {\n return typeof event.deltaY === 'number'\n }\n\n function isTouchEvent(event: any): event is TouchEvent {\n return event.touches != null\n }\n\n if (\n Math.abs(\n (currentTarget?.offsetHeight ?? 0) - ((visualViewport?.height ?? 0) - WINDOW_PADDING * 2)\n ) > 1 &&\n !pinching\n ) {\n event.preventDefault()\n } else if (isWheelEvent(event) && isFirefox) {\n // Firefox needs this to propagate scrolling\n // during momentum scrolling phase if the\n // height reached its maximum (at boundaries)\n currentTarget.scrollTop += event.deltaY\n }\n\n if (!pinching) {\n let delta = 5\n\n if (isTouchEvent(event)) {\n const currentPageY = touchPageYRef.current\n const pageY = event.touches[0]?.pageY\n\n if (pageY != null) {\n touchPageYRef.current = pageY\n\n if (currentPageY != null) {\n delta = currentPageY - pageY\n }\n }\n }\n\n increaseHeight(currentTarget, isWheelEvent(event) ? event.deltaY : delta)\n setScrollTop(currentTarget.scrollTop)\n // Ensure derived data (scroll arrows) is fresh\n forceUpdate()\n }\n },\n [forceUpdate, increaseHeight]\n )\n\n // Handle `onWheel` event in an effect to remove the `passive` option so we\n // can .preventDefault() it\n React.useEffect(() => {\n function onTouchEnd() {\n touchPageYRef.current = null\n }\n\n const floating = floatingRef.current\n if (open && floating && middlewareType === 'align') {\n floating.addEventListener('wheel', handleWheel)\n floating.addEventListener('touchmove', handleWheel)\n floating.addEventListener('touchend', onTouchEnd, { passive: true })\n return () => {\n floating.removeEventListener('wheel', handleWheel)\n floating.removeEventListener('touchmove', handleWheel)\n floating.removeEventListener('touchend', onTouchEnd)\n }\n }\n }, [open, floatingRef, handleWheel, middlewareType])\n\n // Ensure the menu remains attached to the reference element when resizing.\n React.useEffect(() => {\n window.addEventListener('resize', update)\n return () => {\n window.removeEventListener('resize', update)\n }\n }, [update])\n\n // Scroll the active or selected item into view when in `controlledScrolling`\n // mode (i.e. arrow key nav).\n React.useLayoutEffect(() => {\n const floating = floatingRef.current\n\n if (open && controlledScrolling && floating) {\n const item =\n activeIndex != null\n ? listItemsRef.current[activeIndex]\n : selectedIndex != null\n ? listItemsRef.current[selectedIndex]\n : null\n\n if (item && prevActiveIndex != null) {\n const itemHeight = listItemsRef.current[prevActiveIndex]?.offsetHeight ?? 0\n\n const floatingHeight = floating.offsetHeight\n const top = item.offsetTop\n const bottom = top + itemHeight\n\n if (top < floating.scrollTop + 20) {\n const diff = floating.scrollTop - top + 20\n floating.scrollTop -= diff\n\n if (activeIndex != selectedIndex && activeIndex != null) {\n increaseHeight(floating, -diff)\n }\n } else if (bottom > floatingHeight + floating.scrollTop - 20) {\n const diff = bottom - floatingHeight - floating.scrollTop + 20\n\n floating.scrollTop += diff\n\n if (activeIndex != selectedIndex && activeIndex != null) {\n floating.scrollTop -= increaseHeight(floating, diff) ?? 0\n }\n }\n }\n }\n }, [\n open,\n controlledScrolling,\n prevActiveIndex,\n activeIndex,\n selectedIndex,\n floatingRef,\n increaseHeight,\n ])\n\n // Sync the height and the scrollTop values and device whether to use fallback\n // positioning.\n React.useLayoutEffect(() => {\n const floating = refs.floating.current\n const reference = refs.reference.current\n\n if (open && floating && reference && floating.offsetHeight < floating.scrollHeight) {\n const referenceRect = reference.getBoundingClientRect()\n\n if (middlewareType === 'fallback') {\n const item = listItemsRef.current[selectedIndex]\n if (item) {\n floating.scrollTop = item.offsetTop - floating.clientHeight + referenceRect.height\n }\n return\n }\n\n floating.scrollTop = middlewareData.size?.y\n\n const closeToBottom =\n (visualViewport?.height ?? 0) + getVisualOffsetTop() - referenceRect.bottom <\n FALLBACK_THRESHOLD\n const closeToTop = referenceRect.top < FALLBACK_THRESHOLD\n\n if (floating.offsetHeight < MIN_HEIGHT || closeToTop || closeToBottom) {\n setMiddlewareType('fallback')\n }\n }\n }, [\n open,\n increaseHeight,\n selectedIndex,\n middlewareType,\n refs.floating,\n refs.reference,\n // Always re-run this effect when the position has been computed so the\n // .scrollTop change works with fresh sizing.\n middlewareData,\n ])\n\n React.useLayoutEffect(() => {\n if (open && selectedIndex != null) {\n requestAnimationFrame(() => {\n listItemsRef.current[selectedIndex]?.focus({ preventScroll: true })\n })\n }\n }, [listItemsRef, selectedIndex, open])\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 setShowArrows(open)\n\n if (!open) {\n setScrollTop(0)\n setMiddlewareType('align')\n setActiveIndex(null)\n setControlledScrolling(false)\n }\n })\n return () => cancelAnimationFrame(frame)\n }, [open, setActiveIndex])\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 return (\n <SelectProvider\n scope={__scopeSelect}\n {...(selectContext as Required<typeof selectContext>)}\n increaseHeight={increaseHeight}\n floatingRef={floatingRef}\n setValueAtIndex={(index, value) => {\n listContentRef.current[index] = value\n }}\n interactions={{\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 userSelect: 'none',\n ...props?.style,\n },\n onPointerEnter() {\n setControlledScrolling(false)\n },\n onPointerMove() {\n setControlledScrolling(false)\n },\n onKeyDown() {\n setControlledScrolling(true)\n },\n onScroll(event) {\n setScrollTop(event.currentTarget.scrollTop)\n },\n })\n },\n }}\n floatingContext={context}\n activeIndex={activeIndex}\n canScrollDown={!!showDownArrow}\n canScrollUp={!!showUpArrow}\n controlledScrolling\n dataRef={context.dataRef}\n listRef={listItemsRef}\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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAYO;AACP,gCAA4B;AAC5B,YAAuB;AAEvB,uBAAuF;AACvF,qBAAiD;
|
|
4
|
+
"sourcesContent": ["import {\n detectOverflow,\n flip,\n offset,\n size,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n useListNavigation,\n useRole,\n useTypeahead,\n} from '@floating-ui/react-dom-interactions'\nimport { usePrevious } from '@radix-ui/react-use-previous'\nimport * as React from 'react'\n\nimport { FALLBACK_THRESHOLD, MIN_HEIGHT, 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 {\n __scopeSelect,\n children,\n open = false,\n activeIndexRef,\n selectedIndexRef,\n listContentRef,\n } = props\n\n const selectContext = useSelectContext('SelectSheetImpl', __scopeSelect)\n const { setActiveIndex, setOpen, setSelectedIndex, selectedIndex, activeIndex, forceUpdate } =\n selectContext\n const [showArrows, setShowArrows] = React.useState(false)\n const [scrollTop, setScrollTop] = React.useState(0)\n const prevActiveIndex = usePrevious<number | null>(activeIndex)\n\n const listItemsRef = React.useRef<Array<HTMLElement | null>>([])\n\n const [controlledScrolling, setControlledScrolling] = React.useState(false)\n const [middlewareType, setMiddlewareType] = React.useState<'align' | 'fallback'>('align')\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 setShowArrows(open)\n\n if (!open) {\n setScrollTop(0)\n setMiddlewareType('align')\n setActiveIndex(null)\n setControlledScrolling(false)\n }\n })\n return () => {\n cancelAnimationFrame(frame)\n }\n }, [open, setActiveIndex])\n\n function getFloatingPadding(floating: HTMLElement | null) {\n if (!floating) {\n return 0\n }\n return Number(getComputedStyle(floating).paddingLeft?.replace('px', ''))\n }\n\n const { x, y, reference, floating, strategy, context, refs, middlewareData, update } =\n useFloating({\n open,\n onOpenChange: setOpen,\n placement: 'bottom',\n middleware:\n middlewareType === 'align'\n ? [\n offset(({ rects }) => {\n const index = activeIndexRef.current ?? selectedIndexRef.current\n\n if (index == null) {\n return 0\n }\n\n const item = listItemsRef.current[index]\n\n if (item == null) {\n return 0\n }\n\n const offsetTop = item.offsetTop\n const itemHeight = item.offsetHeight\n const height = rects.reference.height\n\n return -offsetTop - height - (itemHeight - height) / 2\n }),\n // Custom `size` that can handle the opposite direction of the placement\n {\n name: 'size',\n async fn(args) {\n const {\n elements: { floating },\n rects: { reference },\n middlewareData,\n } = args\n\n const overflow = await detectOverflow(args, {\n padding: WINDOW_PADDING,\n })\n\n const top = Math.max(0, overflow.top)\n const bottom = Math.max(0, overflow.bottom)\n const nextY = args.y + top\n\n if (middlewareData.size?.skip) {\n return {\n y: nextY,\n data: {\n y: middlewareData.size.y,\n },\n }\n }\n\n Object.assign(floating.style, {\n maxHeight: `${floating.scrollHeight - Math.abs(top + bottom)}px`,\n minWidth: `${reference.width + getFloatingPadding(floating) * 2}px`,\n })\n\n return {\n y: nextY,\n data: {\n y: top,\n skip: true,\n },\n reset: {\n rects: true,\n },\n }\n },\n },\n ]\n : [\n offset(5),\n flip(),\n size({\n apply({ rects, availableHeight, elements }) {\n Object.assign(elements.floating.style, {\n width: `${rects.reference.width}px`,\n maxHeight: `${availableHeight}px`,\n })\n },\n padding: WINDOW_PADDING,\n }),\n ],\n })\n\n const floatingRef = refs.floating\n\n const showUpArrow = showArrows && scrollTop > SCROLL_ARROW_THRESHOLD\n const showDownArrow =\n showArrows &&\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 useRole(context, { role: 'listbox' }),\n useDismiss(context),\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 increaseHeight = React.useCallback(\n (floating: HTMLElement, amount = 0) => {\n if (middlewareType === 'fallback') {\n return\n }\n\n const currentMaxHeight = Number(floating.style.maxHeight.replace('px', ''))\n const currentTop = Number(floating.style.top.replace('px', ''))\n const rect = floating.getBoundingClientRect()\n const rectTop = rect.top\n const rectBottom = rect.bottom\n const viewportHeight = visualViewport?.height ?? 0\n const visualMaxHeight = viewportHeight - WINDOW_PADDING * 2\n\n if (\n amount < 0 &&\n selectedIndexRef.current != null &&\n Math.round(rectBottom) < Math.round(viewportHeight + getVisualOffsetTop() - WINDOW_PADDING)\n ) {\n floating.style.maxHeight = `${Math.min(visualMaxHeight, currentMaxHeight - amount)}px`\n }\n\n if (\n amount > 0 &&\n Math.round(rectTop) > Math.round(WINDOW_PADDING - getVisualOffsetTop()) &&\n floating.scrollHeight > floating.offsetHeight\n ) {\n const nextTop = Math.max(WINDOW_PADDING + getVisualOffsetTop(), currentTop - amount)\n\n const nextMaxHeight = Math.min(visualMaxHeight, currentMaxHeight + amount)\n\n Object.assign(floating.style, {\n maxHeight: `${nextMaxHeight}px`,\n top: `${nextTop}px`,\n })\n\n if (nextTop - WINDOW_PADDING > getVisualOffsetTop()) {\n floating.scrollTop -= nextMaxHeight - currentMaxHeight + getFloatingPadding(floating)\n }\n\n return currentTop - nextTop\n }\n },\n [middlewareType, selectedIndexRef]\n )\n\n const touchPageYRef = React.useRef<number | null>(null)\n\n const handleWheel = React.useCallback(\n (event: WheelEvent | TouchEvent) => {\n const pinching = event.ctrlKey\n\n const currentTarget = event.currentTarget as HTMLElement\n\n function isWheelEvent(event: any): event is WheelEvent {\n return typeof event.deltaY === 'number'\n }\n\n function isTouchEvent(event: any): event is TouchEvent {\n return event.touches != null\n }\n\n if (\n Math.abs(\n (currentTarget?.offsetHeight ?? 0) - ((visualViewport?.height ?? 0) - WINDOW_PADDING * 2)\n ) > 1 &&\n !pinching\n ) {\n event.preventDefault()\n } else if (isWheelEvent(event) && isFirefox) {\n // Firefox needs this to propagate scrolling\n // during momentum scrolling phase if the\n // height reached its maximum (at boundaries)\n currentTarget.scrollTop += event.deltaY\n }\n\n if (!pinching) {\n let delta = 5\n\n if (isTouchEvent(event)) {\n const currentPageY = touchPageYRef.current\n const pageY = event.touches[0]?.pageY\n\n if (pageY != null) {\n touchPageYRef.current = pageY\n\n if (currentPageY != null) {\n delta = currentPageY - pageY\n }\n }\n }\n\n increaseHeight(currentTarget, isWheelEvent(event) ? event.deltaY : delta)\n setScrollTop(currentTarget.scrollTop)\n // Ensure derived data (scroll arrows) is fresh\n forceUpdate()\n }\n },\n [forceUpdate, increaseHeight]\n )\n\n // Handle `onWheel` event in an effect to remove the `passive` option so we\n // can .preventDefault() it\n React.useEffect(() => {\n function onTouchEnd() {\n touchPageYRef.current = null\n }\n\n const floating = floatingRef.current\n if (open && floating && middlewareType === 'align') {\n floating.addEventListener('wheel', handleWheel)\n floating.addEventListener('touchmove', handleWheel)\n floating.addEventListener('touchend', onTouchEnd, { passive: true })\n return () => {\n floating.removeEventListener('wheel', handleWheel)\n floating.removeEventListener('touchmove', handleWheel)\n floating.removeEventListener('touchend', onTouchEnd)\n }\n }\n }, [open, floatingRef, handleWheel, middlewareType])\n\n // Ensure the menu remains attached to the reference element when resizing.\n React.useEffect(() => {\n window.addEventListener('resize', update)\n return () => {\n window.removeEventListener('resize', update)\n }\n }, [update])\n\n // Scroll the active or selected item into view when in `controlledScrolling`\n // mode (i.e. arrow key nav).\n React.useLayoutEffect(() => {\n const floating = floatingRef.current\n\n if (open && controlledScrolling && floating) {\n const item =\n activeIndex != null\n ? listItemsRef.current[activeIndex]\n : selectedIndex != null\n ? listItemsRef.current[selectedIndex]\n : null\n\n if (item && prevActiveIndex != null) {\n const itemHeight = listItemsRef.current[prevActiveIndex]?.offsetHeight ?? 0\n\n const floatingHeight = floating.offsetHeight\n const top = item.offsetTop\n const bottom = top + itemHeight\n\n if (top < floating.scrollTop + 20) {\n const diff = floating.scrollTop - top + 20\n floating.scrollTop -= diff\n\n if (activeIndex != selectedIndex && activeIndex != null) {\n increaseHeight(floating, -diff)\n }\n } else if (bottom > floatingHeight + floating.scrollTop - 20) {\n const diff = bottom - floatingHeight - floating.scrollTop + 20\n\n floating.scrollTop += diff\n\n if (activeIndex != selectedIndex && activeIndex != null) {\n floating.scrollTop -= increaseHeight(floating, diff) ?? 0\n }\n }\n }\n }\n }, [\n open,\n controlledScrolling,\n prevActiveIndex,\n activeIndex,\n selectedIndex,\n floatingRef,\n increaseHeight,\n ])\n\n // Sync the height and the scrollTop values and device whether to use fallback\n // positioning.\n React.useLayoutEffect(() => {\n const floating = refs.floating.current\n const reference = refs.reference.current\n\n if (open && floating && reference && floating.offsetHeight < floating.scrollHeight) {\n const referenceRect = reference.getBoundingClientRect()\n\n if (middlewareType === 'fallback') {\n const item = listItemsRef.current[selectedIndex]\n if (item) {\n floating.scrollTop = item.offsetTop - floating.clientHeight + referenceRect.height\n }\n return\n }\n\n floating.scrollTop = middlewareData.size?.y\n\n const closeToBottom =\n (visualViewport?.height ?? 0) + getVisualOffsetTop() - referenceRect.bottom <\n FALLBACK_THRESHOLD\n const closeToTop = referenceRect.top < FALLBACK_THRESHOLD\n\n if (floating.offsetHeight < MIN_HEIGHT || closeToTop || closeToBottom) {\n setMiddlewareType('fallback')\n }\n }\n }, [\n open,\n increaseHeight,\n selectedIndex,\n middlewareType,\n refs.floating,\n refs.reference,\n // Always re-run this effect when the position has been computed so the\n // .scrollTop change works with fresh sizing.\n middlewareData,\n ])\n\n React.useLayoutEffect(() => {\n if (open && selectedIndex != null) {\n requestAnimationFrame(() => {\n listItemsRef.current[selectedIndex]?.focus({ preventScroll: true })\n })\n }\n }, [listItemsRef, selectedIndex, open])\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 setShowArrows(open)\n\n if (!open) {\n setScrollTop(0)\n setMiddlewareType('align')\n setActiveIndex(null)\n setControlledScrolling(false)\n }\n })\n return () => cancelAnimationFrame(frame)\n }, [open, setActiveIndex])\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 return (\n <SelectProvider\n scope={__scopeSelect}\n {...(selectContext as Required<typeof selectContext>)}\n increaseHeight={increaseHeight}\n floatingRef={floatingRef}\n setValueAtIndex={(index, value) => {\n listContentRef.current[index] = value\n }}\n interactions={{\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 userSelect: 'none',\n ...props?.style,\n },\n onPointerEnter() {\n setControlledScrolling(false)\n },\n onPointerMove() {\n setControlledScrolling(false)\n },\n onKeyDown() {\n setControlledScrolling(true)\n },\n onScroll(event) {\n setScrollTop(event.currentTarget.scrollTop)\n },\n })\n },\n }}\n floatingContext={context}\n activeIndex={activeIndex}\n canScrollDown={!!showDownArrow}\n canScrollUp={!!showUpArrow}\n controlledScrolling\n dataRef={context.dataRef}\n listRef={listItemsRef}\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) || ''\nconst isFirefox = userAgent.toLowerCase().includes('firefox')\n\nfunction getVisualOffsetTop() {\n return !/^((?!chrome|android).)*safari/i.test(userAgent) ? visualViewport?.offsetTop ?? 0 : 0\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAYO;AACP,gCAA4B;AAC5B,YAAuB;AAEvB,uBAAuF;AACvF,qBAAiD;AAU1C,MAAM,mBAAmB,CAAC,UAA2B;AAC1D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,MACE;AAEJ,QAAM,gBAAgB,qCAAiB,mBAAmB,aAAa;AACvE,QAAM,EAAE,gBAAgB,SAAS,kBAAkB,eAAe,aAAa,gBAC7E;AACF,QAAM,CAAC,YAAY,iBAAiB,MAAM,SAAS,KAAK;AACxD,QAAM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Aa,CAAC,CAAC;AAAA,IACf,qBAAmB;AAAA,IACnB,SAAS,QAAQ;AAAA,IACjB,SAAS;AAAA,KAER,QAaH;AAEJ;AAGA,MAAM,YAAa,OAAO,cAAc,eAAe,UAAU,aAAc;AAC/E,MAAM,YAAY,UAAU,YAAY,EAAE,SAAS,SAAS;AAE5D,8BAA8B;AAC5B,SAAO,CAAC,iCAAiC,KAAK,SAAS,IAAI,kDAAgB,cAAa,IAAI;AAC9F;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -28,13 +28,13 @@ var import_portal = require("@tamagui/portal");
|
|
|
28
28
|
var React = __toESM(require("react"));
|
|
29
29
|
var import_constants = require("./constants");
|
|
30
30
|
var import_context = require("./context");
|
|
31
|
-
const SelectViewport =
|
|
31
|
+
const SelectViewport = (props) => {
|
|
32
32
|
const { __scopeSelect, children } = props;
|
|
33
33
|
const context = (0, import_context.useSelectContext)(import_constants.VIEWPORT_NAME, __scopeSelect);
|
|
34
34
|
return /* @__PURE__ */ React.createElement(import_portal.PortalItem, {
|
|
35
35
|
hostName: `${context.scopeKey}SheetContents`
|
|
36
36
|
}, children);
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
38
|
SelectViewport.displayName = import_constants.VIEWPORT_NAME;
|
|
39
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
40
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectViewport.native.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { PortalItem } from '@tamagui/portal'\nimport * as React from 'react'\n\nimport { VIEWPORT_NAME } from './constants'\nimport { useSelectContext } from './context'\nimport { ScopedProps, SelectViewportProps } from './types'\n\nexport const SelectViewport = (props: ScopedProps<SelectViewportProps>) => {\n const { __scopeSelect, children } = props\n const context = useSelectContext(VIEWPORT_NAME, __scopeSelect)\n return <PortalItem hostName={`${context.scopeKey}SheetContents`}>{children}</PortalItem>\n}\n\nSelectViewport.displayName = VIEWPORT_NAME\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,YAAuB;AAEvB,uBAA8B;AAC9B,qBAAiC;AAG1B,MAAM,iBAAiB,CAAC,UAA4C;AACzE,QAAM,EAAE,eAAe,aAAa;AACpC,QAAM,UAAU,qCAAiB,gCAAe,aAAa;AAC7D,SAAO,oCAAC;AAAA,IAAW,UAAU,GAAG,QAAQ;AAAA,KAA0B,QAAS;AAC7E;AAEA,eAAe,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/Select.js
CHANGED
|
@@ -17,22 +17,7 @@ import { SelectContent } from "./SelectContent";
|
|
|
17
17
|
import { SelectInlineImpl } from "./SelectImpl";
|
|
18
18
|
import { SelectScrollDownButton, SelectScrollUpButton } from "./SelectScrollButton";
|
|
19
19
|
import { SelectViewport } from "./SelectViewport";
|
|
20
|
-
const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
|
|
21
|
-
const isFirefox = userAgent.toLowerCase().includes("firefox");
|
|
22
|
-
function getVisualOffsetTop() {
|
|
23
|
-
return !/^((?!chrome|android).)*safari/i.test(userAgent) ? (visualViewport == null ? void 0 : visualViewport.offsetTop) ?? 0 : 0;
|
|
24
|
-
}
|
|
25
20
|
const TRIGGER_NAME = "SelectTrigger";
|
|
26
|
-
const SelectTriggerFrame = styled(ListItem, {
|
|
27
|
-
componentName: TRIGGER_NAME,
|
|
28
|
-
backgrounded: true,
|
|
29
|
-
radiused: true,
|
|
30
|
-
hoverTheme: true,
|
|
31
|
-
pressTheme: true,
|
|
32
|
-
focusTheme: true,
|
|
33
|
-
focusable: false,
|
|
34
|
-
borderWidth: 1
|
|
35
|
-
});
|
|
36
21
|
const SelectTrigger = React.forwardRef((props, forwardedRef) => {
|
|
37
22
|
const {
|
|
38
23
|
__scopeSelect,
|
|
@@ -42,7 +27,15 @@ const SelectTrigger = React.forwardRef((props, forwardedRef) => {
|
|
|
42
27
|
} = props;
|
|
43
28
|
const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
|
|
44
29
|
const labelledBy = ariaLabelledby;
|
|
45
|
-
return /* @__PURE__ */ React.createElement(
|
|
30
|
+
return /* @__PURE__ */ React.createElement(ListItem, {
|
|
31
|
+
componentName: TRIGGER_NAME,
|
|
32
|
+
backgrounded: true,
|
|
33
|
+
radiused: true,
|
|
34
|
+
hoverTheme: true,
|
|
35
|
+
pressTheme: true,
|
|
36
|
+
focusTheme: true,
|
|
37
|
+
focusable: true,
|
|
38
|
+
borderWidth: 1,
|
|
46
39
|
size: context.size,
|
|
47
40
|
"aria-expanded": context.open,
|
|
48
41
|
"aria-autocomplete": "none",
|
|
@@ -401,8 +394,6 @@ export {
|
|
|
401
394
|
SelectSeparator,
|
|
402
395
|
SelectSheetContents,
|
|
403
396
|
SelectTrigger,
|
|
404
|
-
getVisualOffsetTop,
|
|
405
|
-
isFirefox,
|
|
406
397
|
useSelectBreakpointActive,
|
|
407
398
|
useShowSelectSheet
|
|
408
399
|
};
|