@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
|
@@ -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": "AAyBI,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAyBI,OAUO,YAAAA,EAVP,OAAAC,MAAA,oBAzBJ,OAAS,mBAAAC,EAAiB,kBAAAC,MAAsB,qBAChD,OAAS,SAAAC,EAAO,oBAAAC,EAAkB,gBAAAC,MAAoB,gBACtD,OAAS,eAAAC,MAAmB,uBAC5B,OAAS,cAAAC,MAAmC,uBAE5C,OAAS,oBAAAC,MAAwB,YAEjC,OAAS,sBAAAC,MAA0B,8BAMnC,MAAMC,EAAe,gBAERC,EAAgB,CAAC,CAC5B,SAAAC,EACA,cAAAC,EACA,OAAAC,EAAS,IACT,GAAGC,CACL,IAA4C,CAC1C,MAAMC,EAAUR,EAAiBE,EAAcG,CAAa,EACtDI,EAAYZ,EAAa,EACzBa,EAAYT,EAAmBO,CAAO,EACtCG,EACJnB,EAACG,EAAA,CAAM,eAAc,GAAC,KAAMc,EACzB,SAAAL,EACH,EAEIQ,EAAQhB,EAAiB,EAE/B,OAAIc,EACGF,EAAQ,KAGNhB,EAAAD,EAAA,CAAG,SAAAoB,EAAS,EAFV,KAMTnB,EAACE,EAAA,CACE,SAAAc,EAAQ,KACPhB,EAACC,EAAA,CAAgB,MAAO,CAAE,OAAAa,CAAO,EAAG,WAAY,CAACM,EAC/C,SAAApB,EAACO,EAAA,CAAW,KAAI,GAAC,QAAO,GAAE,GAAGQ,EAC3B,SAAAf,EAACM,EAAA,CAAa,SAAAa,EAAS,EACzB,EACF,EAEAnB,EAAC,OAAI,MAAO,CAAE,QAAS,MAAO,EAAI,SAAAmB,EAAS,EAE/C,CAEJ",
|
|
6
|
+
"names": ["Fragment", "jsx", "FloatingOverlay", "FloatingPortal", "Theme", "useIsTouchDevice", "useThemeName", "Dismissable", "FocusScope", "useSelectContext", "useShowSelectSheet", "CONTENT_NAME", "SelectContent", "children", "__scopeSelect", "zIndex", "focusScopeProps", "context", "themeName", "showSheet", "contents", "touch"]
|
|
7
7
|
}
|
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FloatingOverlay, FloatingPortal } from "@floating-ui/react";
|
|
3
|
-
import { Theme, useIsTouchDevice, useThemeName } from "@tamagui/core";
|
|
4
|
-
import { Dismissable } from "@tamagui/dismissable";
|
|
5
|
-
import { FocusScope } from "@tamagui/focus-scope";
|
|
6
|
-
import { useSelectContext } from "./context";
|
|
7
|
-
import { useShowSelectSheet } from "./useSelectBreakpointActive";
|
|
8
|
-
const CONTENT_NAME = "SelectContent";
|
|
9
|
-
const SelectContent = ({
|
|
10
|
-
children,
|
|
11
|
-
__scopeSelect,
|
|
12
|
-
zIndex = 1e3,
|
|
13
|
-
...focusScopeProps
|
|
14
|
-
}) => {
|
|
15
|
-
const context = useSelectContext(CONTENT_NAME, __scopeSelect);
|
|
16
|
-
const themeName = useThemeName();
|
|
17
|
-
const showSheet = useShowSelectSheet(context);
|
|
18
|
-
const contents = /* @__PURE__ */ jsx(Theme, { forceClassName: true, name: themeName, children });
|
|
19
|
-
const touch = useIsTouchDevice();
|
|
20
|
-
if (showSheet) {
|
|
21
|
-
if (!context.open) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
return /* @__PURE__ */ jsx(Fragment, { children: contents });
|
|
25
|
-
}
|
|
26
|
-
return /* @__PURE__ */ jsx(FloatingPortal, { children: context.open ? /* @__PURE__ */ jsx(FloatingOverlay, { style: { zIndex }, lockScroll: !touch, children: /* @__PURE__ */ jsx(FocusScope, { loop: true, trapped: true, ...focusScopeProps, children: /* @__PURE__ */ jsx(Dismissable, { children: contents }) }) }) : /* @__PURE__ */ jsx("div", { style: { display: "none" }, children: contents }) });
|
|
27
|
-
};
|
|
28
|
-
export {
|
|
29
|
-
SelectContent
|
|
30
|
-
};
|
|
1
|
+
import{Fragment as T,jsx as o}from"react/jsx-runtime";import{FloatingOverlay as i,FloatingPortal as a}from"@floating-ui/react";import{Theme as S,useIsTouchDevice as u,useThemeName as f}from"@tamagui/core";import{Dismissable as h}from"@tamagui/dismissable";import{FocusScope as F}from"@tamagui/focus-scope";import{useSelectContext as C}from"./context";import{useShowSelectSheet as N}from"./useSelectBreakpointActive";const P="SelectContent",E=({children:s,__scopeSelect:n,zIndex:r=1e3,...c})=>{const e=C(P,n),l=f(),m=N(e),t=o(S,{forceClassName:!0,name:l,children:s}),p=u();return m?e.open?o(T,{children:t}):null:o(a,{children:e.open?o(i,{style:{zIndex:r},lockScroll:!p,children:o(F,{loop:!0,trapped:!0,...c,children:o(h,{children:t})})}):o("div",{style:{display:"none"},children:t})})};export{E as SelectContent};
|
|
31
2
|
//# sourceMappingURL=SelectContent.mjs.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": "AAyBI,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAyBI,OAUO,YAAAA,EAVP,OAAAC,MAAA,oBAzBJ,OAAS,mBAAAC,EAAiB,kBAAAC,MAAsB,qBAChD,OAAS,SAAAC,EAAO,oBAAAC,EAAkB,gBAAAC,MAAoB,gBACtD,OAAS,eAAAC,MAAmB,uBAC5B,OAAS,cAAAC,MAAmC,uBAE5C,OAAS,oBAAAC,MAAwB,YAEjC,OAAS,sBAAAC,MAA0B,8BAMnC,MAAMC,EAAe,gBAERC,EAAgB,CAAC,CAC5B,SAAAC,EACA,cAAAC,EACA,OAAAC,EAAS,IACT,GAAGC,CACL,IAA4C,CAC1C,MAAMC,EAAUR,EAAiBE,EAAcG,CAAa,EACtDI,EAAYZ,EAAa,EACzBa,EAAYT,EAAmBO,CAAO,EACtCG,EACJnB,EAACG,EAAA,CAAM,eAAc,GAAC,KAAMc,EACzB,SAAAL,EACH,EAEIQ,EAAQhB,EAAiB,EAE/B,OAAIc,EACGF,EAAQ,KAGNhB,EAAAD,EAAA,CAAG,SAAAoB,EAAS,EAFV,KAMTnB,EAACE,EAAA,CACE,SAAAc,EAAQ,KACPhB,EAACC,EAAA,CAAgB,MAAO,CAAE,OAAAa,CAAO,EAAG,WAAY,CAACM,EAC/C,SAAApB,EAACO,EAAA,CAAW,KAAI,GAAC,QAAO,GAAE,GAAGQ,EAC3B,SAAAf,EAACM,EAAA,CAAa,SAAAa,EAAS,EACzB,EACF,EAEAnB,EAAC,OAAI,MAAO,CAAE,QAAS,MAAO,EAAI,SAAAmB,EAAS,EAE/C,CAEJ",
|
|
6
|
+
"names": ["Fragment", "jsx", "FloatingOverlay", "FloatingPortal", "Theme", "useIsTouchDevice", "useThemeName", "Dismissable", "FocusScope", "useSelectContext", "useShowSelectSheet", "CONTENT_NAME", "SelectContent", "children", "__scopeSelect", "zIndex", "focusScopeProps", "context", "themeName", "showSheet", "contents", "touch"]
|
|
7
7
|
}
|
|
@@ -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": "AAEO,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAEO,MAAMA,EAAgB,CAAC,CAAE,SAAAC,CAAS,IAChCA",
|
|
6
|
+
"names": ["SelectContent", "children"]
|
|
7
7
|
}
|
|
@@ -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": "AAEO,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAEO,MAAMA,EAAgB,CAAC,CAAE,SAAAC,CAAS,IAChCA",
|
|
6
|
+
"names": ["SelectContent", "children"]
|
|
7
7
|
}
|
package/dist/esm/SelectImpl.js
CHANGED
|
@@ -1,295 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
autoUpdate,
|
|
4
|
-
flip,
|
|
5
|
-
inner,
|
|
6
|
-
offset,
|
|
7
|
-
shift,
|
|
8
|
-
size,
|
|
9
|
-
useClick,
|
|
10
|
-
useDismiss,
|
|
11
|
-
useFloating,
|
|
12
|
-
useInnerOffset,
|
|
13
|
-
useInteractions,
|
|
14
|
-
useListNavigation,
|
|
15
|
-
useRole,
|
|
16
|
-
useTypeahead
|
|
17
|
-
} from "@floating-ui/react";
|
|
18
|
-
import {
|
|
19
|
-
isClient,
|
|
20
|
-
isWeb,
|
|
21
|
-
useIsTouchDevice,
|
|
22
|
-
useIsomorphicLayoutEffect
|
|
23
|
-
} from "@tamagui/core";
|
|
24
|
-
import * as React from "react";
|
|
25
|
-
import { flushSync } from "react-dom";
|
|
26
|
-
import { SCROLL_ARROW_THRESHOLD, WINDOW_PADDING } from "./constants";
|
|
27
|
-
import { SelectProvider, useSelectContext } from "./context";
|
|
28
|
-
const SelectInlineImpl = (props) => {
|
|
29
|
-
const {
|
|
30
|
-
__scopeSelect,
|
|
31
|
-
children,
|
|
32
|
-
open = false,
|
|
33
|
-
selectedIndexRef,
|
|
34
|
-
listContentRef
|
|
35
|
-
} = props;
|
|
36
|
-
const selectContext = useSelectContext("SelectSheetImpl", __scopeSelect);
|
|
37
|
-
const {
|
|
38
|
-
setActiveIndex,
|
|
39
|
-
setOpen,
|
|
40
|
-
setSelectedIndex,
|
|
41
|
-
selectedIndex,
|
|
42
|
-
activeIndex,
|
|
43
|
-
forceUpdate
|
|
44
|
-
} = selectContext;
|
|
45
|
-
const [scrollTop, setScrollTop] = React.useState(0);
|
|
46
|
-
const touch = useIsTouchDevice();
|
|
47
|
-
const listItemsRef = React.useRef([]);
|
|
48
|
-
const overflowRef = React.useRef(null);
|
|
49
|
-
const upArrowRef = React.useRef(null);
|
|
50
|
-
const downArrowRef = React.useRef(null);
|
|
51
|
-
const allowSelectRef = React.useRef(false);
|
|
52
|
-
const allowMouseUpRef = React.useRef(true);
|
|
53
|
-
const selectTimeoutRef = React.useRef();
|
|
54
|
-
const state = React.useRef({
|
|
55
|
-
isMouseOutside: false
|
|
56
|
-
});
|
|
57
|
-
const [controlledScrolling, setControlledScrolling] = React.useState(false);
|
|
58
|
-
const [fallback, setFallback] = React.useState(false);
|
|
59
|
-
const [innerOffset, setInnerOffset] = React.useState(0);
|
|
60
|
-
const [blockSelection, setBlockSelection] = React.useState(false);
|
|
61
|
-
const floatingStyle = React.useRef({});
|
|
62
|
-
React.useEffect(() => {
|
|
63
|
-
const frame = requestAnimationFrame(() => {
|
|
64
|
-
if (!open) {
|
|
65
|
-
setScrollTop(0);
|
|
66
|
-
setFallback(false);
|
|
67
|
-
setActiveIndex(null);
|
|
68
|
-
setControlledScrolling(false);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return () => {
|
|
72
|
-
cancelAnimationFrame(frame);
|
|
73
|
-
};
|
|
74
|
-
}, [open, setActiveIndex]);
|
|
75
|
-
if (isWeb && isClient) {
|
|
76
|
-
React.useEffect(() => {
|
|
77
|
-
if (!open)
|
|
78
|
-
return;
|
|
79
|
-
const mouseUp = (e) => {
|
|
80
|
-
if (state.current.isMouseOutside) {
|
|
81
|
-
setOpen(false);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
document.addEventListener("mouseup", mouseUp);
|
|
85
|
-
return () => {
|
|
86
|
-
document.removeEventListener("mouseup", mouseUp);
|
|
87
|
-
};
|
|
88
|
-
}, [open]);
|
|
89
|
-
}
|
|
90
|
-
const updateFloatingSize = size({
|
|
91
|
-
apply({
|
|
92
|
-
availableHeight,
|
|
93
|
-
rects: {
|
|
94
|
-
reference: { width }
|
|
95
|
-
}
|
|
96
|
-
}) {
|
|
97
|
-
floatingStyle.current = {
|
|
98
|
-
width,
|
|
99
|
-
maxHeight: availableHeight
|
|
100
|
-
};
|
|
101
|
-
},
|
|
102
|
-
padding: WINDOW_PADDING
|
|
103
|
-
});
|
|
104
|
-
const { x, y, reference, floating, strategy, context, refs } = useFloating({
|
|
105
|
-
open,
|
|
106
|
-
onOpenChange: setOpen,
|
|
107
|
-
whileElementsMounted: autoUpdate,
|
|
108
|
-
placement: "bottom-start",
|
|
109
|
-
middleware: fallback ? [
|
|
110
|
-
offset(5),
|
|
111
|
-
...[
|
|
112
|
-
touch ? shift({ crossAxis: true, padding: WINDOW_PADDING }) : flip({ padding: WINDOW_PADDING })
|
|
113
|
-
],
|
|
114
|
-
updateFloatingSize
|
|
115
|
-
] : [
|
|
116
|
-
inner({
|
|
117
|
-
listRef: listItemsRef,
|
|
118
|
-
overflowRef,
|
|
119
|
-
index: selectedIndex,
|
|
120
|
-
offset: innerOffset,
|
|
121
|
-
onFallbackChange: setFallback,
|
|
122
|
-
padding: 10,
|
|
123
|
-
minItemsVisible: touch ? 10 : 4,
|
|
124
|
-
referenceOverflowThreshold: 20
|
|
125
|
-
}),
|
|
126
|
-
updateFloatingSize
|
|
127
|
-
]
|
|
128
|
-
});
|
|
129
|
-
const floatingRef = refs.floating;
|
|
130
|
-
const showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD;
|
|
131
|
-
const showDownArrow = open && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;
|
|
132
|
-
const interactions = useInteractions([
|
|
133
|
-
useClick(context, { event: "mousedown" }),
|
|
134
|
-
useDismiss(context, { outsidePress: true }),
|
|
135
|
-
useRole(context, { role: "listbox" }),
|
|
136
|
-
useInnerOffset(context, {
|
|
137
|
-
enabled: !fallback,
|
|
138
|
-
onChange: setInnerOffset,
|
|
139
|
-
overflowRef
|
|
140
|
-
}),
|
|
141
|
-
useListNavigation(context, {
|
|
142
|
-
listRef: listItemsRef,
|
|
143
|
-
activeIndex,
|
|
144
|
-
selectedIndex,
|
|
145
|
-
onNavigate: setActiveIndex
|
|
146
|
-
}),
|
|
147
|
-
useTypeahead(context, {
|
|
148
|
-
listRef: listContentRef,
|
|
149
|
-
onMatch: open ? setActiveIndex : setSelectedIndex,
|
|
150
|
-
selectedIndex,
|
|
151
|
-
activeIndex
|
|
152
|
-
})
|
|
153
|
-
]);
|
|
154
|
-
const interactionsContext = React.useMemo(() => {
|
|
155
|
-
return {
|
|
156
|
-
...interactions,
|
|
157
|
-
getReferenceProps() {
|
|
158
|
-
return interactions.getReferenceProps({
|
|
159
|
-
ref: reference,
|
|
160
|
-
className: "SelectTrigger",
|
|
161
|
-
onKeyDown(event) {
|
|
162
|
-
if (event.key === "Enter" || event.key === " " && !context.dataRef.current.typing) {
|
|
163
|
-
event.preventDefault();
|
|
164
|
-
setOpen(true);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
},
|
|
169
|
-
getFloatingProps(props2) {
|
|
170
|
-
return interactions.getFloatingProps({
|
|
171
|
-
ref: floating,
|
|
172
|
-
className: "Select",
|
|
173
|
-
...props2,
|
|
174
|
-
style: {
|
|
175
|
-
position: strategy,
|
|
176
|
-
top: y ?? "",
|
|
177
|
-
left: x ?? "",
|
|
178
|
-
outline: 0,
|
|
179
|
-
scrollbarWidth: "none",
|
|
180
|
-
...floatingStyle.current,
|
|
181
|
-
...props2 == null ? void 0 : props2.style
|
|
182
|
-
},
|
|
183
|
-
onPointerEnter() {
|
|
184
|
-
setControlledScrolling(false);
|
|
185
|
-
state.current.isMouseOutside = false;
|
|
186
|
-
},
|
|
187
|
-
onPointerLeave() {
|
|
188
|
-
state.current.isMouseOutside = true;
|
|
189
|
-
},
|
|
190
|
-
onPointerMove() {
|
|
191
|
-
state.current.isMouseOutside = false;
|
|
192
|
-
setControlledScrolling(false);
|
|
193
|
-
},
|
|
194
|
-
onKeyDown() {
|
|
195
|
-
setControlledScrolling(true);
|
|
196
|
-
},
|
|
197
|
-
onContextMenu(e) {
|
|
198
|
-
e.preventDefault();
|
|
199
|
-
},
|
|
200
|
-
onScroll(event) {
|
|
201
|
-
flushSync(() => setScrollTop(event.currentTarget.scrollTop));
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
}, [floating, y, x, interactions]);
|
|
207
|
-
useIsomorphicLayoutEffect(() => {
|
|
208
|
-
if (open) {
|
|
209
|
-
selectTimeoutRef.current = setTimeout(() => {
|
|
210
|
-
allowSelectRef.current = true;
|
|
211
|
-
}, 300);
|
|
212
|
-
return () => {
|
|
213
|
-
clearTimeout(selectTimeoutRef.current);
|
|
214
|
-
};
|
|
215
|
-
} else {
|
|
216
|
-
allowSelectRef.current = false;
|
|
217
|
-
allowMouseUpRef.current = true;
|
|
218
|
-
setInnerOffset(0);
|
|
219
|
-
setFallback(false);
|
|
220
|
-
setBlockSelection(false);
|
|
221
|
-
}
|
|
222
|
-
}, [open]);
|
|
223
|
-
useIsomorphicLayoutEffect(() => {
|
|
224
|
-
function onPointerDown(e) {
|
|
225
|
-
var _a, _b, _c;
|
|
226
|
-
const target = e.target;
|
|
227
|
-
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)))) {
|
|
228
|
-
setOpen(false);
|
|
229
|
-
setControlledScrolling(false);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
if (open) {
|
|
233
|
-
document.addEventListener("pointerdown", onPointerDown);
|
|
234
|
-
return () => {
|
|
235
|
-
document.removeEventListener("pointerdown", onPointerDown);
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
}, [open, refs, setOpen]);
|
|
239
|
-
useIsomorphicLayoutEffect(() => {
|
|
240
|
-
var _a, _b;
|
|
241
|
-
if (open && controlledScrolling) {
|
|
242
|
-
if (activeIndex != null) {
|
|
243
|
-
(_a = listItemsRef.current[activeIndex]) == null ? void 0 : _a.scrollIntoView({ block: "nearest" });
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
setScrollTop(((_b = refs.floating.current) == null ? void 0 : _b.scrollTop) ?? 0);
|
|
247
|
-
}, [open, refs, controlledScrolling, activeIndex]);
|
|
248
|
-
useIsomorphicLayoutEffect(() => {
|
|
249
|
-
var _a;
|
|
250
|
-
if (open && fallback) {
|
|
251
|
-
if (selectedIndex != null) {
|
|
252
|
-
(_a = listItemsRef.current[selectedIndex]) == null ? void 0 : _a.scrollIntoView({ block: "nearest" });
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}, [open, fallback, selectedIndex]);
|
|
256
|
-
useIsomorphicLayoutEffect(() => {
|
|
257
|
-
if (refs.floating.current && fallback) {
|
|
258
|
-
refs.floating.current.style.maxHeight = "";
|
|
259
|
-
}
|
|
260
|
-
}, [refs, fallback]);
|
|
261
|
-
return /* @__PURE__ */ jsx(
|
|
262
|
-
SelectProvider,
|
|
263
|
-
{
|
|
264
|
-
scope: __scopeSelect,
|
|
265
|
-
...selectContext,
|
|
266
|
-
setScrollTop,
|
|
267
|
-
setInnerOffset,
|
|
268
|
-
floatingRef,
|
|
269
|
-
setValueAtIndex: (index, value) => {
|
|
270
|
-
listContentRef.current[index] = value;
|
|
271
|
-
},
|
|
272
|
-
fallback,
|
|
273
|
-
interactions: interactionsContext,
|
|
274
|
-
floatingContext: context,
|
|
275
|
-
activeIndex,
|
|
276
|
-
canScrollDown: !!showDownArrow,
|
|
277
|
-
canScrollUp: !!showUpArrow,
|
|
278
|
-
controlledScrolling,
|
|
279
|
-
dataRef: context.dataRef,
|
|
280
|
-
listRef: listItemsRef,
|
|
281
|
-
blockSelection,
|
|
282
|
-
allowMouseUpRef,
|
|
283
|
-
upArrowRef,
|
|
284
|
-
downArrowRef,
|
|
285
|
-
selectTimeoutRef,
|
|
286
|
-
allowSelectRef,
|
|
287
|
-
children
|
|
288
|
-
}
|
|
289
|
-
);
|
|
290
|
-
};
|
|
291
|
-
const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
|
|
292
|
-
export {
|
|
293
|
-
SelectInlineImpl
|
|
294
|
-
};
|
|
1
|
+
import{jsx as Ie}from"react/jsx-runtime";import{autoUpdate as ee,flip as te,inner as ne,offset as oe,shift as se,size as re,useClick as le,useDismiss as ce,useFloating as ie,useInnerOffset as ue,useInteractions as ae,useListNavigation as fe,useRole as de,useTypeahead as me}from"@floating-ui/react";import{isClient as pe,isWeb as ge,useIsTouchDevice as Re,useIsomorphicLayoutEffect as d}from"@tamagui/core";import*as t from"react";import{flushSync as Se}from"react-dom";import{SCROLL_ARROW_THRESHOLD as q,WINDOW_PADDING as O}from"./constants";import{SelectProvider as we,useSelectContext as ve}from"./context";const Pe=z=>{const{__scopeSelect:T,children:K,open:n=!1,selectedIndexRef:he,listContentRef:b}=z,A=ve("SelectSheetImpl",T),{setActiveIndex:m,setOpen:u,setSelectedIndex:j,selectedIndex:c,activeIndex:i,forceUpdate:xe}=A,[E,p]=t.useState(0),M=Re(),a=t.useRef([]),D=t.useRef(null),P=t.useRef(null),C=t.useRef(null),w=t.useRef(!1),L=t.useRef(!0),v=t.useRef(),g=t.useRef({isMouseOutside:!1}),[I,f]=t.useState(!1),[l,h]=t.useState(!1),[B,x]=t.useState(0),[G,J]=t.useState(!1),k=t.useRef({});t.useEffect(()=>{const e=requestAnimationFrame(()=>{n||(p(0),h(!1),m(null),f(!1))});return()=>{cancelAnimationFrame(e)}},[n,m]),ge&&pe&&t.useEffect(()=>{if(!n)return;const e=o=>{g.current.isMouseOutside&&u(!1)};return document.addEventListener("mouseup",e),()=>{document.removeEventListener("mouseup",e)}},[n]);const H=re({apply({availableHeight:e,rects:{reference:{width:o}}}){k.current={width:o,maxHeight:e}},padding:O}),{x:F,y:N,reference:Q,floating:U,strategy:X,context:s,refs:r}=ie({open:n,onOpenChange:u,whileElementsMounted:ee,placement:"bottom-start",middleware:l?[oe(5),M?se({crossAxis:!0,padding:O}):te({padding:O}),H]:[ne({listRef:a,overflowRef:D,index:c,offset:B,onFallbackChange:h,padding:10,minItemsVisible:M?10:4,referenceOverflowThreshold:20}),H]}),R=r.floating,Y=n&&E>q,Z=n&&R.current&&E<R.current.scrollHeight-R.current.clientHeight-q,S=ae([le(s,{event:"mousedown"}),ce(s,{outsidePress:!0}),de(s,{role:"listbox"}),ue(s,{enabled:!l,onChange:x,overflowRef:D}),fe(s,{listRef:a,activeIndex:i,selectedIndex:c,onNavigate:m}),me(s,{listRef:b,onMatch:n?m:j,selectedIndex:c,activeIndex:i})]),$=t.useMemo(()=>({...S,getReferenceProps(){return S.getReferenceProps({ref:Q,className:"SelectTrigger",onKeyDown(e){(e.key==="Enter"||e.key===" "&&!s.dataRef.current.typing)&&(e.preventDefault(),u(!0))}})},getFloatingProps(e){return S.getFloatingProps({ref:U,className:"Select",...e,style:{position:X,top:N??"",left:F??"",outline:0,scrollbarWidth:"none",...k.current,...e==null?void 0:e.style},onPointerEnter(){f(!1),g.current.isMouseOutside=!1},onPointerLeave(){g.current.isMouseOutside=!0},onPointerMove(){g.current.isMouseOutside=!1,f(!1)},onKeyDown(){f(!0)},onContextMenu(o){o.preventDefault()},onScroll(o){Se(()=>p(o.currentTarget.scrollTop))}})}}),[U,N,F,S]);return d(()=>{if(n)return v.current=setTimeout(()=>{w.current=!0},300),()=>{clearTimeout(v.current)};w.current=!1,L.current=!0,x(0),h(!1),J(!1)},[n]),d(()=>{function e(o){var W,_,V;const y=o.target;(W=r.floating.current)!=null&&W.contains(y)||(_=P.current)!=null&&_.contains(y)||(V=C.current)!=null&&V.contains(y)||(u(!1),f(!1))}if(n)return document.addEventListener("pointerdown",e),()=>{document.removeEventListener("pointerdown",e)}},[n,r,u]),d(()=>{var e,o;n&&I&&i!=null&&((e=a.current[i])==null||e.scrollIntoView({block:"nearest"})),p(((o=r.floating.current)==null?void 0:o.scrollTop)??0)},[n,r,I,i]),d(()=>{var e;n&&l&&c!=null&&((e=a.current[c])==null||e.scrollIntoView({block:"nearest"}))},[n,l,c]),d(()=>{r.floating.current&&l&&(r.floating.current.style.maxHeight="")},[r,l]),Ie(we,{scope:T,...A,setScrollTop:p,setInnerOffset:x,floatingRef:R,setValueAtIndex:(e,o)=>{b.current[e]=o},fallback:l,interactions:$,floatingContext:s,activeIndex:i,canScrollDown:!!Z,canScrollUp:!!Y,controlledScrolling:I,dataRef:s.dataRef,listRef:a,blockSelection:G,allowMouseUpRef:L,upArrowRef:P,downArrowRef:C,selectTimeoutRef:v,allowSelectRef:w,children:K})},Ce=typeof navigator<"u"&&navigator.userAgent||"";export{Pe as SelectInlineImpl};
|
|
295
2
|
//# sourceMappingURL=SelectImpl.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectImpl.tsx"],
|
|
4
4
|
"sourcesContent": ["import {\n SideObject,\n autoUpdate,\n flip,\n inner,\n offset,\n shift,\n size,\n useClick,\n useDismiss,\n useFloating,\n useInnerOffset,\n useInteractions,\n useListNavigation,\n useRole,\n useTypeahead,\n} from '@floating-ui/react'\nimport {\n isClient,\n isWeb,\n useIsTouchDevice,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport * as React from 'react'\nimport { flushSync } from 'react-dom'\n\nimport { SCROLL_ARROW_THRESHOLD, WINDOW_PADDING } from './constants'\nimport { SelectProvider, useSelectContext } from './context'\nimport { SelectImplProps } from './types'\n\n// TODO use id for focusing from label\nexport const SelectInlineImpl = (props: SelectImplProps) => {\n const {\n __scopeSelect,\n children,\n open = false,\n selectedIndexRef,\n listContentRef,\n } = props\n\n const selectContext = useSelectContext('SelectSheetImpl', __scopeSelect)\n const {\n setActiveIndex,\n setOpen,\n setSelectedIndex,\n selectedIndex,\n activeIndex,\n forceUpdate,\n } = selectContext\n const [scrollTop, setScrollTop] = React.useState(0)\n const touch = useIsTouchDevice()\n\n const listItemsRef = React.useRef<Array<HTMLElement | null>>([])\n const overflowRef = React.useRef<null | SideObject>(null)\n const upArrowRef = React.useRef<HTMLDivElement | null>(null)\n const downArrowRef = React.useRef<HTMLDivElement | null>(null)\n const allowSelectRef = React.useRef(false)\n const allowMouseUpRef = React.useRef(true)\n const selectTimeoutRef = React.useRef<any>()\n const state = React.useRef({\n isMouseOutside: false,\n })\n\n const [controlledScrolling, setControlledScrolling] = React.useState(false)\n const [fallback, setFallback] = React.useState(false)\n const [innerOffset, setInnerOffset] = React.useState(0)\n const [blockSelection, setBlockSelection] = React.useState(false)\n const floatingStyle = React.useRef({})\n\n // Wait for scroll position to settle before showing arrows to prevent\n // interference with pointer events.\n React.useEffect(() => {\n const frame = requestAnimationFrame(() => {\n if (!open) {\n setScrollTop(0)\n setFallback(false)\n setActiveIndex(null)\n setControlledScrolling(false)\n }\n })\n return () => {\n cancelAnimationFrame(frame)\n }\n }, [open, setActiveIndex])\n\n // close when mouseup outside select\n if (isWeb && isClient) {\n React.useEffect(() => {\n if (!open) return\n const mouseUp = (e: MouseEvent) => {\n if (state.current.isMouseOutside) {\n setOpen(false)\n }\n }\n document.addEventListener('mouseup', mouseUp)\n return () => {\n document.removeEventListener('mouseup', mouseUp)\n }\n }, [open])\n }\n\n const updateFloatingSize = size({\n apply({\n availableHeight,\n rects: {\n reference: { width },\n },\n }) {\n floatingStyle.current = {\n width: width,\n maxHeight: availableHeight,\n }\n },\n padding: WINDOW_PADDING,\n })\n\n const { x, y, reference, floating, strategy, context, refs } = useFloating({\n open,\n onOpenChange: setOpen,\n whileElementsMounted: autoUpdate,\n placement: 'bottom-start',\n middleware: fallback\n ? [\n offset(5),\n ...[\n touch\n ? shift({ crossAxis: true, padding: WINDOW_PADDING })\n : flip({ padding: WINDOW_PADDING }),\n ],\n updateFloatingSize,\n ]\n : [\n inner({\n listRef: listItemsRef,\n overflowRef,\n index: selectedIndex,\n offset: innerOffset,\n onFallbackChange: setFallback,\n padding: 10,\n minItemsVisible: touch ? 10 : 4,\n referenceOverflowThreshold: 20,\n }),\n updateFloatingSize,\n ],\n })\n\n const floatingRef = refs.floating\n\n const showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD\n const showDownArrow =\n open &&\n floatingRef.current &&\n scrollTop <\n floatingRef.current.scrollHeight -\n floatingRef.current.clientHeight -\n SCROLL_ARROW_THRESHOLD\n\n const interactions = useInteractions([\n useClick(context, { event: 'mousedown' }),\n useDismiss(context, { outsidePress: true }),\n useRole(context, { role: 'listbox' }),\n useInnerOffset(context, {\n enabled: !fallback,\n onChange: setInnerOffset,\n overflowRef,\n }),\n useListNavigation(context, {\n listRef: listItemsRef,\n activeIndex,\n selectedIndex,\n onNavigate: setActiveIndex,\n }),\n useTypeahead(context, {\n listRef: listContentRef,\n onMatch: open ? setActiveIndex : setSelectedIndex,\n selectedIndex,\n activeIndex,\n }),\n ])\n\n const interactionsContext = React.useMemo(() => {\n return {\n ...interactions,\n getReferenceProps() {\n return interactions.getReferenceProps({\n ref: reference,\n className: 'SelectTrigger',\n onKeyDown(event) {\n if (\n event.key === 'Enter' ||\n (event.key === ' ' && !context.dataRef.current.typing)\n ) {\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 scrollbarWidth: 'none',\n ...floatingStyle.current,\n ...props?.style,\n },\n onPointerEnter() {\n setControlledScrolling(false)\n state.current.isMouseOutside = false\n },\n onPointerLeave() {\n state.current.isMouseOutside = true\n },\n onPointerMove() {\n state.current.isMouseOutside = false\n setControlledScrolling(false)\n },\n onKeyDown() {\n setControlledScrolling(true)\n },\n onContextMenu(e) {\n e.preventDefault()\n },\n onScroll(event) {\n // In React 18, the ScrollArrows need to synchronously know this value to prevent\n // painting at the wrong time.\n flushSync(() => setScrollTop(event.currentTarget.scrollTop))\n },\n })\n },\n }\n }, [floating, y, x, interactions])\n\n // effects\n\n useIsomorphicLayoutEffect(() => {\n if (open) {\n selectTimeoutRef.current = setTimeout(() => {\n allowSelectRef.current = true\n }, 300)\n\n return () => {\n clearTimeout(selectTimeoutRef.current)\n }\n } else {\n allowSelectRef.current = false\n allowMouseUpRef.current = true\n setInnerOffset(0)\n setFallback(false)\n setBlockSelection(false)\n }\n }, [open])\n\n // Replacement for `useDismiss` as the arrows are outside of the floating\n // element DOM tree.\n useIsomorphicLayoutEffect(() => {\n function onPointerDown(e: PointerEvent) {\n const target = e.target as Node\n if (\n !(\n refs.floating.current?.contains(target) ||\n upArrowRef.current?.contains(target) ||\n downArrowRef.current?.contains(target)\n )\n ) {\n setOpen(false)\n setControlledScrolling(false)\n }\n }\n\n if (open) {\n document.addEventListener('pointerdown', onPointerDown)\n return () => {\n document.removeEventListener('pointerdown', onPointerDown)\n }\n }\n }, [open, refs, setOpen])\n\n // Scroll the `activeIndex` item into view only in \"controlledScrolling\"\n // (keyboard nav) mode.\n useIsomorphicLayoutEffect(() => {\n if (open && controlledScrolling) {\n if (activeIndex != null) {\n listItemsRef.current[activeIndex]?.scrollIntoView({ block: 'nearest' })\n }\n }\n\n setScrollTop(refs.floating.current?.scrollTop ?? 0)\n }, [open, refs, controlledScrolling, activeIndex])\n\n // Scroll the `selectedIndex` into view upon opening the floating element.\n useIsomorphicLayoutEffect(() => {\n if (open && fallback) {\n if (selectedIndex != null) {\n listItemsRef.current[selectedIndex]?.scrollIntoView({ block: 'nearest' })\n }\n }\n }, [open, fallback, selectedIndex])\n\n // Unset the height limiting for fallback mode. This gets executed prior to\n // the positioning call.\n useIsomorphicLayoutEffect(() => {\n if (refs.floating.current && fallback) {\n refs.floating.current.style.maxHeight = ''\n }\n }, [refs, fallback])\n\n // We set this to true by default so that events bubble to forms without JS (SSR)\n // const isFormControl = trigger ? Boolean(trigger.closest('form')) : true\n // const [bubbleSelect, setBubbleSelect] = React.useState<HTMLSelectElement | null>(null)\n // const triggerPointerDownPosRef = React.useRef<{ x: number; y: number } | null>(null)\n\n return (\n <SelectProvider\n scope={__scopeSelect}\n {...(selectContext as Required<typeof selectContext>)}\n setScrollTop={setScrollTop}\n setInnerOffset={setInnerOffset}\n floatingRef={floatingRef}\n setValueAtIndex={(index, value) => {\n listContentRef.current[index] = value\n }}\n fallback={fallback}\n interactions={interactionsContext}\n floatingContext={context}\n activeIndex={activeIndex}\n canScrollDown={!!showDownArrow}\n canScrollUp={!!showUpArrow}\n controlledScrolling={controlledScrolling}\n dataRef={context.dataRef}\n listRef={listItemsRef}\n blockSelection={blockSelection}\n allowMouseUpRef={allowMouseUpRef}\n upArrowRef={upArrowRef}\n downArrowRef={downArrowRef}\n selectTimeoutRef={selectTimeoutRef}\n allowSelectRef={allowSelectRef}\n >\n {children}\n {/* {isFormControl ? (\n <BubbleSelect\n ref={setBubbleSelect}\n aria-hidden\n tabIndex={-1}\n name={name}\n autoComplete={autoComplete}\n value={value}\n // enable form autofill\n onChange={(event) => setValue(event.target.value)}\n />\n ) : null} */}\n </SelectProvider>\n )\n}\n\n// Cross browser fixes for pinch-zooming/backdrop-filter \uD83D\uDE44\nconst userAgent = (typeof navigator !== 'undefined' && navigator.userAgent) || ''\n"],
|
|
5
|
-
"mappings": "AA+TI
|
|
6
|
-
"names": ["props"]
|
|
5
|
+
"mappings": "AA+TI,cAAAA,OAAA,oBA/TJ,OAEE,cAAAC,GACA,QAAAC,GACA,SAAAC,GACA,UAAAC,GACA,SAAAC,GACA,QAAAC,GACA,YAAAC,GACA,cAAAC,GACA,eAAAC,GACA,kBAAAC,GACA,mBAAAC,GACA,qBAAAC,GACA,WAAAC,GACA,gBAAAC,OACK,qBACP,OACE,YAAAC,GACA,SAAAC,GACA,oBAAAC,GACA,6BAAAC,MACK,gBACP,UAAYC,MAAW,QACvB,OAAS,aAAAC,OAAiB,YAE1B,OAAS,0BAAAC,EAAwB,kBAAAC,MAAsB,cACvD,OAAS,kBAAAC,GAAgB,oBAAAC,OAAwB,YAI1C,MAAMC,GAAoBC,GAA2B,CAC1D,KAAM,CACJ,cAAAC,EACA,SAAAC,EACA,KAAAC,EAAO,GACP,iBAAAC,GACA,eAAAC,CACF,EAAIL,EAEEM,EAA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AACW,EAAOC,IAAU,CACjCrD,EAAe,QAAQoD,CAAK,EAAIC,CAClC,EACA,SAAUhC,EACV,aAAcwB,EACd,gBAAiBN,EACjB,YAAajC,EACb,cAAe,CAAC,CAACqC,EACjB,YAAa,CAAC,CAACD,EACf,oBAAqBvB,EACrB,QAASoB,EAAQ,QACjB,QAAS5B,EACT,eAAgBc,EAChB,gBAAiBT,EACjB,WAAYH,EACZ,aAAcC,EACd,iBAAkBG,EAClB,eAAgBF,EAEf,SAAAlB,EAaH,CAEJ,EAGMyD,GAAa,OAAO,UAAc,KAAe,UAAU,WAAc",
|
|
6
|
+
"names": ["jsx", "autoUpdate", "flip", "inner", "offset", "shift", "size", "useClick", "useDismiss", "useFloating", "useInnerOffset", "useInteractions", "useListNavigation", "useRole", "useTypeahead", "isClient", "isWeb", "useIsTouchDevice", "useIsomorphicLayoutEffect", "React", "flushSync", "SCROLL_ARROW_THRESHOLD", "WINDOW_PADDING", "SelectProvider", "useSelectContext", "SelectInlineImpl", "props", "__scopeSelect", "children", "open", "selectedIndexRef", "listContentRef", "selectContext", "setActiveIndex", "setOpen", "setSelectedIndex", "selectedIndex", "activeIndex", "forceUpdate", "scrollTop", "setScrollTop", "touch", "listItemsRef", "overflowRef", "upArrowRef", "downArrowRef", "allowSelectRef", "allowMouseUpRef", "selectTimeoutRef", "state", "controlledScrolling", "setControlledScrolling", "fallback", "setFallback", "innerOffset", "setInnerOffset", "blockSelection", "setBlockSelection", "floatingStyle", "frame", "mouseUp", "e", "updateFloatingSize", "availableHeight", "width", "x", "y", "reference", "floating", "strategy", "context", "refs", "floatingRef", "showUpArrow", "showDownArrow", "interactions", "interactionsContext", "event", "onPointerDown", "_a", "_b", "_c", "target", "index", "value", "userAgent"]
|
|
7
7
|
}
|