@tamagui/select 1.1.7 → 1.1.9
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 +4 -0
- package/dist/cjs/BubbleSelect.js.map +1 -1
- package/dist/cjs/Select.js +127 -112
- package/dist/cjs/Select.js.map +1 -1
- package/dist/cjs/SelectContent.js +3 -25
- package/dist/cjs/SelectContent.js.map +1 -1
- package/dist/cjs/SelectImpl.js +33 -26
- package/dist/cjs/SelectImpl.js.map +1 -1
- package/dist/cjs/SelectImpl.native.js +1 -3
- package/dist/cjs/SelectImpl.native.js.map +1 -1
- package/dist/cjs/SelectScrollButton.js +58 -45
- package/dist/cjs/SelectScrollButton.js.map +1 -1
- package/dist/cjs/SelectViewport.js +24 -25
- package/dist/cjs/SelectViewport.js.map +1 -1
- package/dist/cjs/SelectViewport.native.js +5 -14
- package/dist/cjs/SelectViewport.native.js.map +1 -1
- package/dist/cjs/context.js +1 -6
- package/dist/cjs/context.js.map +1 -1
- package/dist/cjs/useSelectBreakpointActive.js.map +1 -1
- package/dist/esm/BubbleSelect.js.map +1 -1
- package/dist/esm/Select.js +123 -112
- package/dist/esm/Select.js.map +1 -1
- package/dist/esm/SelectContent.js +3 -25
- package/dist/esm/SelectContent.js.map +1 -1
- package/dist/esm/SelectImpl.js +29 -26
- package/dist/esm/SelectImpl.js.map +1 -1
- package/dist/esm/SelectImpl.native.js +1 -3
- package/dist/esm/SelectImpl.native.js.map +1 -1
- package/dist/esm/SelectScrollButton.js +54 -45
- package/dist/esm/SelectScrollButton.js.map +1 -1
- package/dist/esm/SelectViewport.js +20 -25
- package/dist/esm/SelectViewport.js.map +1 -1
- package/dist/esm/SelectViewport.native.js +1 -14
- package/dist/esm/SelectViewport.native.js.map +1 -1
- package/dist/esm/context.js +1 -6
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/useSelectBreakpointActive.js.map +1 -1
- package/dist/jsx/BubbleSelect.js.map +1 -1
- package/dist/jsx/Select.js +121 -18
- package/dist/jsx/Select.js.map +1 -1
- package/dist/jsx/SelectContent.js.map +1 -1
- package/dist/jsx/SelectImpl.js +25 -3
- package/dist/jsx/SelectImpl.js.map +1 -1
- package/dist/jsx/SelectScrollButton.js +47 -25
- package/dist/jsx/SelectScrollButton.js.map +1 -1
- package/dist/jsx/SelectViewport.js +13 -4
- package/dist/jsx/SelectViewport.js.map +1 -1
- package/dist/jsx/useSelectBreakpointActive.js.map +1 -1
- package/package.json +15 -15
|
@@ -8,22 +8,28 @@ import { flushSync } from "react-dom";
|
|
|
8
8
|
import { useSelectContext } from "./context";
|
|
9
9
|
const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
10
10
|
const SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
11
|
-
return /* @__PURE__ */ jsx(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
SelectScrollButtonImpl,
|
|
13
|
+
{
|
|
14
|
+
componentName: SCROLL_UP_BUTTON_NAME,
|
|
15
|
+
...props,
|
|
16
|
+
dir: "up",
|
|
17
|
+
ref: forwardedRef
|
|
18
|
+
}
|
|
19
|
+
);
|
|
17
20
|
});
|
|
18
21
|
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
19
22
|
const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
20
23
|
const SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
21
|
-
return /* @__PURE__ */ jsx(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
SelectScrollButtonImpl,
|
|
26
|
+
{
|
|
27
|
+
componentName: SCROLL_DOWN_BUTTON_NAME,
|
|
28
|
+
...props,
|
|
29
|
+
dir: "down",
|
|
30
|
+
ref: forwardedRef
|
|
31
|
+
}
|
|
32
|
+
);
|
|
27
33
|
});
|
|
28
34
|
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
29
35
|
const SelectScrollButtonImpl = React.memo(
|
|
@@ -84,43 +90,46 @@ const SelectScrollButtonImpl = React.memo(
|
|
|
84
90
|
flushSync(() => setInnerOffset((value) => value - amount));
|
|
85
91
|
}
|
|
86
92
|
};
|
|
87
|
-
return /* @__PURE__ */ jsx(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
dir === "up" ?
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
93
|
+
return /* @__PURE__ */ jsx(
|
|
94
|
+
YStack,
|
|
95
|
+
{
|
|
96
|
+
ref: composedRef,
|
|
97
|
+
componentName,
|
|
98
|
+
"aria-hidden": true,
|
|
99
|
+
...scrollIndicatorProps,
|
|
100
|
+
zIndex: 1e3,
|
|
101
|
+
position: strategy,
|
|
102
|
+
left: x || 0,
|
|
103
|
+
top: y || 0,
|
|
104
|
+
width: `calc(${(((_a = floatingRef == null ? void 0 : floatingRef.current) == null ? void 0 : _a.offsetWidth) ?? 0) - 2}px)`,
|
|
105
|
+
onPointerEnter: () => {
|
|
106
|
+
statusRef.current = "active";
|
|
107
|
+
let prevNow = Date.now();
|
|
108
|
+
function frame() {
|
|
109
|
+
if (element) {
|
|
110
|
+
const currentNow = Date.now();
|
|
111
|
+
const msElapsed = currentNow - prevNow;
|
|
112
|
+
prevNow = currentNow;
|
|
113
|
+
const pixelsToScroll = msElapsed / 2;
|
|
114
|
+
const remainingPixels = dir === "up" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;
|
|
115
|
+
const scrollRemaining = dir === "up" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;
|
|
116
|
+
onScroll(
|
|
117
|
+
dir === "up" ? Math.min(pixelsToScroll, remainingPixels) : Math.max(-pixelsToScroll, -remainingPixels)
|
|
118
|
+
);
|
|
119
|
+
if (scrollRemaining) {
|
|
120
|
+
frameRef.current = requestAnimationFrame(frame);
|
|
121
|
+
}
|
|
113
122
|
}
|
|
114
123
|
}
|
|
124
|
+
cancelAnimationFrame(frameRef.current);
|
|
125
|
+
frameRef.current = requestAnimationFrame(frame);
|
|
126
|
+
},
|
|
127
|
+
onPointerLeave: () => {
|
|
128
|
+
statusRef.current = "idle";
|
|
129
|
+
cancelAnimationFrame(frameRef.current);
|
|
115
130
|
}
|
|
116
|
-
cancelAnimationFrame(frameRef.current);
|
|
117
|
-
frameRef.current = requestAnimationFrame(frame);
|
|
118
|
-
},
|
|
119
|
-
onPointerLeave: () => {
|
|
120
|
-
statusRef.current = "idle";
|
|
121
|
-
cancelAnimationFrame(frameRef.current);
|
|
122
131
|
}
|
|
123
|
-
|
|
132
|
+
);
|
|
124
133
|
}
|
|
125
134
|
)
|
|
126
135
|
);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectScrollButton.tsx"],
|
|
4
4
|
"sourcesContent": ["import { autoUpdate, offset, useFloating } from '@floating-ui/react-dom-interactions'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport { TamaguiElement, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { flushSync } from 'react-dom'\n\nimport { useSelectContext } from './context'\nimport {\n ScopedProps,\n SelectScrollButtonImplProps,\n SelectScrollButtonProps,\n} from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectScrollUpButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SCROLL_UP_BUTTON_NAME = 'SelectScrollUpButton'\n\nexport const SelectScrollUpButton = React.forwardRef<\n TamaguiElement,\n SelectScrollButtonProps\n>((props: ScopedProps<SelectScrollButtonProps>, forwardedRef) => {\n return (\n <SelectScrollButtonImpl\n componentName={SCROLL_UP_BUTTON_NAME}\n {...props}\n dir=\"up\"\n ref={forwardedRef}\n />\n )\n})\n\nSelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectScrollDownButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SCROLL_DOWN_BUTTON_NAME = 'SelectScrollDownButton'\n\nexport const SelectScrollDownButton = React.forwardRef<\n TamaguiElement,\n SelectScrollButtonProps\n>((props: ScopedProps<SelectScrollButtonProps>, forwardedRef) => {\n return (\n <SelectScrollButtonImpl\n componentName={SCROLL_DOWN_BUTTON_NAME}\n {...props}\n dir=\"down\"\n ref={forwardedRef}\n />\n )\n})\n\nSelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME\n\ntype SelectScrollButtonImplElement = TamaguiElement\n\nconst SelectScrollButtonImpl = React.memo(\n React.forwardRef<SelectScrollButtonImplElement, SelectScrollButtonImplProps>(\n (props: ScopedProps<SelectScrollButtonImplProps>, forwardedRef) => {\n const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props\n const {\n floatingRef,\n forceUpdate,\n open,\n fallback,\n setScrollTop,\n setInnerOffset,\n ...context\n } = useSelectContext(componentName, __scopeSelect)\n\n const [element, setElement] = React.useState<HTMLElement | null>(null)\n const statusRef = React.useRef<'idle' | 'active'>('idle')\n const isVisible = context[dir === 'down' ? 'canScrollDown' : 'canScrollUp']\n const frameRef = React.useRef<any>()\n\n const { x, y, reference, floating, strategy, update, refs } = useFloating({\n open: open && isVisible,\n strategy: 'fixed',\n placement: dir === 'up' ? 'top' : 'bottom',\n middleware: [offset(({ rects }) => -rects.floating.height)],\n whileElementsMounted: (...args) => autoUpdate(...args, { animationFrame: true }),\n })\n\n const composedRef = useComposedRefs(forwardedRef, floating)\n\n if (floatingRef) {\n if (open) {\n if (element !== floatingRef.current) {\n setElement(floatingRef.current)\n reference(floatingRef.current)\n requestAnimationFrame(update)\n }\n } else {\n cancelAnimationFrame(frameRef.current)\n }\n }\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n cancelAnimationFrame(frameRef.current)\n }\n }, [])\n\n if (!(isVisible && floatingRef)) {\n return null\n }\n\n const onScroll = (amount: number) => {\n if (fallback) {\n if (refs.floating.current) {\n refs.floating.current.scrollTop -= amount\n flushSync(() => setScrollTop!(refs.floating.current?.scrollTop ?? 0))\n }\n } else {\n flushSync(() => setInnerOffset!((value) => value - amount))\n }\n }\n\n return (\n <YStack\n ref={composedRef}\n componentName={componentName}\n aria-hidden\n {...scrollIndicatorProps}\n zIndex={1000}\n // @ts-expect-error\n position={strategy}\n left={x || 0}\n top={y || 0}\n width={`calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`}\n onPointerEnter={() => {\n statusRef.current = 'active'\n let prevNow = Date.now()\n\n function frame() {\n if (element) {\n const currentNow = Date.now()\n const msElapsed = currentNow - prevNow\n prevNow = currentNow\n\n const pixelsToScroll = msElapsed / 2\n\n const remainingPixels =\n dir === 'up'\n ? element.scrollTop\n : element.scrollHeight - element.clientHeight - element.scrollTop\n\n const scrollRemaining =\n dir === 'up'\n ? element.scrollTop - pixelsToScroll > 0\n : element.scrollTop + pixelsToScroll <\n element.scrollHeight - element.clientHeight\n\n onScroll(\n dir === 'up'\n ? Math.min(pixelsToScroll, remainingPixels)\n : Math.max(-pixelsToScroll, -remainingPixels)\n )\n\n if (scrollRemaining) {\n frameRef.current = requestAnimationFrame(frame)\n }\n }\n }\n\n cancelAnimationFrame(frameRef.current)\n frameRef.current = requestAnimationFrame(frame)\n }}\n onPointerLeave={() => {\n statusRef.current = 'idle'\n cancelAnimationFrame(frameRef.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;AAAA,QAC5D;AAAA,MACF;AAEA,aACE;AAAA,QAAC;AAAA;AAAA,UACC,KAAK;AAAA,UACL;AAAA,UACA,eAAW;AAAA,UACV,GAAG;AAAA,UACJ,QAAQ;AAAA,UAER,UAAU;AAAA,UACV,MAAM,KAAK;AAAA,UACX,KAAK,KAAK;AAAA,UACV,OAAO,WAAS,gDAAa,YAAb,mBAAsB,gBAAe,KAAK;AAAA,UAC1D,gBAAgB,MAAM;AACpB,sBAAU,UAAU;AACpB,gBAAI,UAAU,KAAK,IAAI;AAEvB,qBAAS,QAAQ;AACf,kBAAI,SAAS;AACX,sBAAM,aAAa,KAAK,IAAI;AAC5B,sBAAM,YAAY,aAAa;AAC/B,0BAAU;AAEV,sBAAM,iBAAiB,YAAY;AAEnC,sBAAM,kBACJ,QAAQ,OACJ,QAAQ,YACR,QAAQ,eAAe,QAAQ,eAAe,QAAQ;AAE5D,sBAAM,kBACJ,QAAQ,OACJ,QAAQ,YAAY,iBAAiB,IACrC,QAAQ,YAAY,iBACpB,QAAQ,eAAe,QAAQ;AAErC;AAAA,kBACE,QAAQ,OACJ,KAAK,IAAI,gBAAgB,eAAe,IACxC,KAAK,IAAI,CAAC,gBAAgB,CAAC,eAAe;AAAA,gBAChD;AAEA,oBAAI,iBAAiB;AACnB,2BAAS,UAAU,sBAAsB,KAAK;AAAA,gBAChD;AAAA,cACF;AAAA,YACF;AAEA,iCAAqB,SAAS,OAAO;AACrC,qBAAS,UAAU,sBAAsB,KAAK;AAAA,UAChD;AAAA,UACA,gBAAgB,MAAM;AACpB,sBAAU,UAAU;AACpB,iCAAqB,SAAS,OAAO;AAAA,UACvC;AAAA;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["_a"]
|
|
7
7
|
}
|
|
@@ -35,13 +35,7 @@ const SelectViewport = React.forwardRef(
|
|
|
35
35
|
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
36
36
|
const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
|
|
37
37
|
if (breakpointActive || !isWeb) {
|
|
38
|
-
return /* @__PURE__ */ jsx(PortalItem, {
|
|
39
|
-
hostName: `${context.scopeKey}SheetContents`,
|
|
40
|
-
children: /* @__PURE__ */ jsx(ForwardSelectContext, {
|
|
41
|
-
context,
|
|
42
|
-
children
|
|
43
|
-
})
|
|
44
|
-
});
|
|
38
|
+
return /* @__PURE__ */ jsx(PortalItem, { hostName: `${context.scopeKey}SheetContents`, children: /* @__PURE__ */ jsx(ForwardSelectContext, { context, children }) });
|
|
45
39
|
}
|
|
46
40
|
if (!context.floatingContext) {
|
|
47
41
|
return null;
|
|
@@ -53,27 +47,28 @@ const SelectViewport = React.forwardRef(
|
|
|
53
47
|
style: { scrollbarWidth, listStyleType, ...restStyle },
|
|
54
48
|
...floatingProps
|
|
55
49
|
} = context.interactions.getFloatingProps();
|
|
56
|
-
return /* @__PURE__ */ jsxs(Fragment, {
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
"style",
|
|
53
|
+
{
|
|
59
54
|
dangerouslySetInnerHTML: {
|
|
60
55
|
__html: selectViewportCSS
|
|
61
56
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
});
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ jsx(FloatingFocusManager, { context: context.floatingContext, children: /* @__PURE__ */ jsx(
|
|
60
|
+
SelectViewportFrame,
|
|
61
|
+
{
|
|
62
|
+
size: context.size,
|
|
63
|
+
role: "presentation",
|
|
64
|
+
...viewportProps,
|
|
65
|
+
ref: forwardedRef,
|
|
66
|
+
...floatingProps,
|
|
67
|
+
...restStyle,
|
|
68
|
+
children
|
|
69
|
+
}
|
|
70
|
+
) })
|
|
71
|
+
] });
|
|
77
72
|
}
|
|
78
73
|
);
|
|
79
74
|
SelectViewport.displayName = VIEWPORT_NAME;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectViewport.tsx"],
|
|
4
4
|
"sourcesContent": ["import { FloatingFocusManager } from '@floating-ui/react-dom-interactions'\nimport { TamaguiElement, isWeb } from '@tamagui/core'\nimport { styled } from '@tamagui/core'\nimport { PortalItem } from '@tamagui/portal'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport * as React from 'react'\n\nimport { VIEWPORT_NAME } from './constants'\nimport { ForwardSelectContext, useSelectContext } from './context'\nimport { ScopedProps, SelectViewportProps } from './types'\nimport { useSelectBreakpointActive } from './useSelectBreakpointActive'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectViewport\n * -----------------------------------------------------------------------------------------------*/\n\nexport const SelectViewportFrame = styled(ThemeableStack, {\n name: VIEWPORT_NAME,\n backgroundColor: '$background',\n elevate: true,\n bordered: true,\n overflow: 'scroll',\n userSelect: 'none',\n outlineWidth: 0,\n\n variants: {\n size: {\n '...size': (val, { tokens }) => {\n return {\n borderRadius: tokens.radius[val] ?? val,\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$2',\n },\n})\n\nexport const SelectViewport = React.forwardRef<TamaguiElement, SelectViewportProps>(\n (props: ScopedProps<SelectViewportProps>, forwardedRef) => {\n const { __scopeSelect, children, ...viewportProps } = props\n const context = useSelectContext(VIEWPORT_NAME, __scopeSelect)\n const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint)\n\n if (breakpointActive || !isWeb) {\n return (\n <PortalItem hostName={`${context.scopeKey}SheetContents`}>\n <ForwardSelectContext context={context}>{children}</ForwardSelectContext>\n </PortalItem>\n )\n }\n\n if (!context.floatingContext) {\n return null\n }\n\n if (!context.open) {\n return children\n }\n\n const {\n style: { scrollbarWidth, listStyleType, ...restStyle },\n ...floatingProps\n } = context.interactions!.getFloatingProps()\n\n return (\n <>\n <style\n dangerouslySetInnerHTML={{\n __html: selectViewportCSS,\n }}\n />\n <FloatingFocusManager context={context.floatingContext}>\n <SelectViewportFrame\n size={context.size}\n // @ts-ignore\n role=\"presentation\"\n {...viewportProps}\n ref={forwardedRef}\n {...floatingProps}\n {...restStyle}\n >\n {children}\n </SelectViewportFrame>\n </FloatingFocusManager>\n </>\n )\n }\n)\n\nSelectViewport.displayName = VIEWPORT_NAME\n\nconst selectViewportCSS = `\n.is_SelectViewport {\n scrollbar-width: none;\n -webkit-overflow-scrolling: touch;\n overscroll-behavior: contain;\n}\n\n.is_SelectViewport::-webkit-scrollbar{\n display:none\n}\n`\n"],
|
|
5
|
-
"mappings": "AAiDU,SAmBJ,UAnBI,KAmBJ,YAnBI;AAjDV,SAAS,4BAA4B;AACrC,SAAyB,aAAa;AACtC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB,wBAAwB;AAEvD,SAAS,iCAAiC;AAMnC,MAAM,sBAAsB,OAAO,gBAAgB;AAAA,EACxD,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,cAAc;AAAA,EAEd,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,KAAK,EAAE,OAAO,MAAM;AAC9B,eAAO;AAAA,UACL,cAAc,OAAO,OAAO,
|
|
5
|
+
"mappings": "AAiDU,SAmBJ,UAnBI,KAmBJ,YAnBI;AAjDV,SAAS,4BAA4B;AACrC,SAAyB,aAAa;AACtC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9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AAG;AAAA,UACJ,KAAK;AAAA,UACJ,GAAG;AAAA,UACH,GAAG;AAAA,UAEH;AAAA;AAAA,MACH,GACF;AAAA,OACF;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAE7B,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,20 +10,7 @@ const SelectViewport = (props) => {
|
|
|
10
10
|
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
11
11
|
const themeName = useThemeName();
|
|
12
12
|
const adaptContext = React.useContext(AdaptParentContext);
|
|
13
|
-
return /* @__PURE__ */ jsx(PortalItem, {
|
|
14
|
-
hostName: `${context.scopeKey}SheetContents`,
|
|
15
|
-
children: /* @__PURE__ */ jsx(Theme, {
|
|
16
|
-
name: themeName,
|
|
17
|
-
children: /* @__PURE__ */ jsx(SelectProvider, {
|
|
18
|
-
scope: __scopeSelect,
|
|
19
|
-
...context,
|
|
20
|
-
children: /* @__PURE__ */ jsx(AdaptParentContext.Provider, {
|
|
21
|
-
value: adaptContext,
|
|
22
|
-
children
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
});
|
|
13
|
+
return /* @__PURE__ */ jsx(PortalItem, { hostName: `${context.scopeKey}SheetContents`, children: /* @__PURE__ */ jsx(Theme, { name: themeName, children: /* @__PURE__ */ jsx(SelectProvider, { scope: __scopeSelect, ...context, children: /* @__PURE__ */ jsx(AdaptParentContext.Provider, { value: adaptContext, children }) }) }) });
|
|
27
14
|
};
|
|
28
15
|
SelectViewport.displayName = VIEWPORT_NAME;
|
|
29
16
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectViewport.native.tsx"],
|
|
4
4
|
"sourcesContent": ["import { AdaptParentContext } from '@tamagui/adapt'\nimport { Stack, Theme, useThemeName } from '@tamagui/core'\nimport { PortalItem } from '@tamagui/portal'\nimport * as React from 'react'\n\nimport { VIEWPORT_NAME } from './constants'\nimport { SelectProvider, 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 const themeName = useThemeName()\n const adaptContext = React.useContext(AdaptParentContext)\n\n // need to forward context...\n return (\n <PortalItem hostName={`${context.scopeKey}SheetContents`}>\n <Theme name={themeName}>\n <SelectProvider scope={__scopeSelect} {...context}>\n <AdaptParentContext.Provider value={adaptContext}>\n {children}\n </AdaptParentContext.Provider>\n </SelectProvider>\n </Theme>\n </PortalItem>\n )\n}\n\nSelectViewport.displayName = VIEWPORT_NAME\n"],
|
|
5
|
-
"mappings": "AAoBU;AApBV,SAAS,0BAA0B;AACnC,SAAgB,OAAO,oBAAoB;AAC3C,SAAS,kBAAkB;AAC3B,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,wBAAwB;AAG1C,MAAM,iBAAiB,CAAC,UAA4C;AACzE,QAAM,EAAE,eAAe,SAAS,IAAI;AACpC,QAAM,UAAU,iBAAiB,eAAe,aAAa;AAC7D,QAAM,YAAY,aAAa;AAC/B,QAAM,eAAe,MAAM,WAAW,kBAAkB;AAGxD,SACE,oBAAC
|
|
5
|
+
"mappings": "AAoBU;AApBV,SAAS,0BAA0B;AACnC,SAAgB,OAAO,oBAAoB;AAC3C,SAAS,kBAAkB;AAC3B,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,wBAAwB;AAG1C,MAAM,iBAAiB,CAAC,UAA4C;AACzE,QAAM,EAAE,eAAe,SAAS,IAAI;AACpC,QAAM,UAAU,iBAAiB,eAAe,aAAa;AAC7D,QAAM,YAAY,aAAa;AAC/B,QAAM,eAAe,MAAM,WAAW,kBAAkB;AAGxD,SACE,oBAAC,cAAW,UAAU,GAAG,QAAQ,yBAC/B,8BAAC,SAAM,MAAM,WACX,8BAAC,kBAAe,OAAO,eAAgB,GAAG,SACxC,8BAAC,mBAAmB,UAAnB,EAA4B,OAAO,cACjC,UACH,GACF,GACF,GACF;AAEJ;AAEA,eAAe,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/context.js
CHANGED
|
@@ -4,12 +4,7 @@ import { SELECT_NAME } from "./constants";
|
|
|
4
4
|
const [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME);
|
|
5
5
|
const [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
|
6
6
|
const ForwardSelectContext = (props) => {
|
|
7
|
-
return /* @__PURE__ */ jsx(SelectProvider, {
|
|
8
|
-
isInSheet: true,
|
|
9
|
-
scope: props.__scopeSelect,
|
|
10
|
-
...props.context,
|
|
11
|
-
children: props.children
|
|
12
|
-
});
|
|
7
|
+
return /* @__PURE__ */ jsx(SelectProvider, { isInSheet: true, scope: props.__scopeSelect, ...props.context, children: props.children });
|
|
13
8
|
};
|
|
14
9
|
export {
|
|
15
10
|
ForwardSelectContext,
|
package/dist/esm/context.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/context.tsx"],
|
|
4
4
|
"sourcesContent": ["import { createContextScope } from '@tamagui/create-context'\n\nimport { SELECT_NAME } from './constants'\nimport { ScopedProps, SelectContextValue } from './types'\n\nexport const [createSelectContext, createSelectScope] =\n createContextScope(SELECT_NAME)\n\nexport const [SelectProvider, useSelectContext] =\n createSelectContext<SelectContextValue>(SELECT_NAME)\n\nexport const ForwardSelectContext = (\n props: ScopedProps<{ children?: any; context: SelectContextValue }>,\n) => {\n return (\n <SelectProvider isInSheet scope={props.__scopeSelect} {...props.context}>\n {props.children}\n </SelectProvider>\n )\n}\n"],
|
|
5
|
-
"mappings": "AAeI;AAfJ,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAGrB,MAAM,CAAC,qBAAqB,iBAAiB,IAClD,mBAAmB,WAAW;AAEzB,MAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,WAAW;AAE9C,MAAM,uBAAuB,CAClC,UACG;AACH,SACE,oBAAC
|
|
5
|
+
"mappings": "AAeI;AAfJ,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAGrB,MAAM,CAAC,qBAAqB,iBAAiB,IAClD,mBAAmB,WAAW;AAEzB,MAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,WAAW;AAE9C,MAAM,uBAAuB,CAClC,UACG;AACH,SACE,oBAAC,kBAAe,WAAS,MAAC,OAAO,MAAM,eAAgB,GAAG,MAAM,SAC7D,gBAAM,UACT;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useSelectBreakpointActive.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useMedia } from '@tamagui/core'\n\nimport { SelectContextValue } from './types'\n\nexport const useSelectBreakpointActive = (\n sheetBreakpoint: SelectContextValue['sheetBreakpoint']\n) => {\n const media = useMedia()\n if (!sheetBreakpoint) return false\n if (sheetBreakpoint === true) return true\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"],
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB;AAIlB,MAAM,4BAA4B,CACvC,oBACG;AACH,QAAM,QAAQ,SAAS;AACvB,MAAI,CAAC;AAAiB,WAAO;AAC7B,MAAI,oBAAoB;AAAM,WAAO;AACrC,SAAO,kBAAkB,MAAM,
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AAIlB,MAAM,4BAA4B,CACvC,oBACG;AACH,QAAM,QAAQ,SAAS;AACvB,MAAI,CAAC;AAAiB,WAAO;AAC7B,MAAI,oBAAoB;AAAM,WAAO;AACrC,SAAO,kBAAkB,MAAM,eAAe,IAAI;AACpD;AAEO,MAAM,qBAAqB,CAAC,YAAgC;AACjE,QAAM,mBAAmB,0BAA0B,QAAQ,eAAe;AAC1E,SAAO,QAAQ,SAAS,QAAQ,QAAQ;AAC1C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/BubbleSelect.tsx"],
|
|
4
4
|
"sourcesContent": ["import { usePrevious } from '@radix-ui/react-use-previous'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\n/* -----------------------------------------------------------------------------------------------*/\nconst BubbleSelect = React.forwardRef<\n HTMLSelectElement,\n React.ComponentPropsWithoutRef<'select'>\n>((props, forwardedRef) => {\n const { value, ...selectProps } = props\n const ref = React.useRef<HTMLSelectElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref)\n const prevValue = usePrevious(value)\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const select = ref.current!\n const selectProto = window.HTMLSelectElement.prototype\n const descriptor = Object.getOwnPropertyDescriptor(\n selectProto,\n 'value',\n ) as PropertyDescriptor\n const setValue = descriptor.set\n if (prevValue !== value && setValue) {\n const event = new Event('change', { bubbles: true })\n setValue.call(select, value)\n select.dispatchEvent(event)\n }\n }, [prevValue, value])\n\n /**\n * We purposefully use a `select` here to support form autofill as much\n * as possible.\n *\n * We purposefully do not add the `value` attribute here to allow the value\n * to be set programatically and bubble to any parent form `onChange` event.\n * Adding the `value` will cause React to consider the programatic\n * dispatch a duplicate and it will get swallowed.\n *\n * We use `VisuallyHidden` rather than `display: \"none\"` because Safari autofill\n * won't work otherwise.\n */\n // TODO\n return null\n // return (\n // <VisuallyHidden asChild>\n // <select {...selectProps} ref={composedRefs} defaultValue={value} />\n // </VisuallyHidden>\n // )\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAGvB,MAAM,eAAe,MAAM,WAGzB,CAAC,OAAO,iBAAiB;AACzB,QAAM,EAAE,
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAGvB,MAAM,eAAe,MAAM,WAGzB,CAAC,OAAO,iBAAiB;AACzB,QAAM,EAAE,OAAO,GAAG,YAAY,IAAI;AAClC,QAAM,MAAM,MAAM,OAA0B,IAAI;AAChD,QAAM,eAAe,gBAAgB,cAAc,GAAG;AACtD,QAAM,YAAY,YAAY,KAAK;AAGnC,QAAM,UAAU,MAAM;AACpB,UAAM,SAAS,IAAI;AACnB,UAAM,cAAc,OAAO,kBAAkB;AAC7C,UAAM,aAAa,OAAO;AAAA,MACxB;AAAA,MACA;AAAA,IACF;AACA,UAAM,WAAW,WAAW;AAC5B,QAAI,cAAc,SAAS,UAAU;AACnC,YAAM,QAAQ,IAAI,MAAM,UAAU,EAAE,SAAS,KAAK,CAAC;AACnD,eAAS,KAAK,QAAQ,KAAK;AAC3B,aAAO,cAAc,KAAK;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,WAAW,KAAK,CAAC;AAerB,SAAO;AAMT,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/Select.js
CHANGED
|
@@ -32,16 +32,36 @@ const SelectTrigger = React.forwardRef(
|
|
|
32
32
|
const {
|
|
33
33
|
__scopeSelect,
|
|
34
34
|
disabled = false,
|
|
35
|
+
// @ts-ignore
|
|
35
36
|
"aria-labelledby": ariaLabelledby,
|
|
36
37
|
...triggerProps
|
|
37
38
|
} = props;
|
|
38
39
|
const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
|
|
39
40
|
const labelledBy = ariaLabelledby;
|
|
40
|
-
return <ListItem
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
return <ListItem
|
|
42
|
+
componentName={TRIGGER_NAME}
|
|
43
|
+
backgrounded
|
|
44
|
+
radiused
|
|
45
|
+
hoverTheme
|
|
46
|
+
pressTheme
|
|
47
|
+
focusTheme
|
|
48
|
+
focusable
|
|
49
|
+
borderWidth={1}
|
|
50
|
+
size={context.size}
|
|
51
|
+
aria-expanded={context.open}
|
|
52
|
+
aria-autocomplete="none"
|
|
53
|
+
aria-labelledby={labelledBy}
|
|
54
|
+
dir={context.dir}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
data-disabled={disabled ? "" : void 0}
|
|
57
|
+
{...triggerProps}
|
|
58
|
+
ref={forwardedRef}
|
|
59
|
+
{...process.env.TAMAGUI_TARGET === "web" && context.interactions ? context.interactions.getReferenceProps() : {
|
|
60
|
+
onPress() {
|
|
61
|
+
context.setOpen(!context.open);
|
|
62
|
+
}
|
|
63
|
+
}}
|
|
64
|
+
/>;
|
|
45
65
|
}
|
|
46
66
|
);
|
|
47
67
|
SelectTrigger.displayName = TRIGGER_NAME;
|
|
@@ -66,13 +86,18 @@ const SelectValue = SelectValueFrame.extractable(
|
|
|
66
86
|
useIsomorphicLayoutEffect(() => {
|
|
67
87
|
onValueNodeHasChildrenChange(hasChildren);
|
|
68
88
|
}, [onValueNodeHasChildrenChange, hasChildren]);
|
|
69
|
-
return <SelectValueFrame
|
|
89
|
+
return <SelectValueFrame
|
|
90
|
+
size={context.size}
|
|
91
|
+
ref={composedRefs}
|
|
92
|
+
pointerEvents="none"
|
|
93
|
+
>{selectValueChildren}</SelectValueFrame>;
|
|
70
94
|
}
|
|
71
95
|
)
|
|
72
96
|
);
|
|
73
97
|
SelectValue.displayName = VALUE_NAME;
|
|
74
98
|
const SelectIcon = styled(XStack, {
|
|
75
99
|
name: "SelectIcon",
|
|
100
|
+
// @ts-ignore
|
|
76
101
|
"aria-hidden": true,
|
|
77
102
|
children: <Paragraph>{"\u25BC"}</Paragraph>
|
|
78
103
|
});
|
|
@@ -156,7 +181,30 @@ const SelectItem = React.forwardRef(
|
|
|
156
181
|
}) : {
|
|
157
182
|
onPress: handleSelect
|
|
158
183
|
};
|
|
159
|
-
return <SelectItemContextProvider
|
|
184
|
+
return <SelectItemContextProvider
|
|
185
|
+
scope={__scopeSelect}
|
|
186
|
+
value={value}
|
|
187
|
+
textId={textId || ""}
|
|
188
|
+
isSelected={isSelected}
|
|
189
|
+
><ListItem
|
|
190
|
+
tag="div"
|
|
191
|
+
backgrounded
|
|
192
|
+
pressTheme
|
|
193
|
+
cursor=""
|
|
194
|
+
focusTheme
|
|
195
|
+
outlineWidth={0}
|
|
196
|
+
componentName={ITEM_NAME}
|
|
197
|
+
ref={composedRefs}
|
|
198
|
+
aria-labelledby={textId}
|
|
199
|
+
aria-selected={isSelected}
|
|
200
|
+
data-state={isSelected ? "active" : "inactive"}
|
|
201
|
+
aria-disabled={disabled || void 0}
|
|
202
|
+
data-disabled={disabled ? "" : void 0}
|
|
203
|
+
tabIndex={disabled ? void 0 : -1}
|
|
204
|
+
size={context.size}
|
|
205
|
+
{...itemProps}
|
|
206
|
+
{...selectItemProps}
|
|
207
|
+
/></SelectItemContextProvider>;
|
|
160
208
|
}
|
|
161
209
|
);
|
|
162
210
|
SelectItem.displayName = ITEM_NAME;
|
|
@@ -174,7 +222,14 @@ const SelectItemText = React.forwardRef(
|
|
|
174
222
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
175
223
|
const isSelected = Boolean(itemContext.isSelected && context.valueNode);
|
|
176
224
|
const contents = React.useMemo(
|
|
177
|
-
() => <SelectItemTextFrame
|
|
225
|
+
() => <SelectItemTextFrame
|
|
226
|
+
className={className}
|
|
227
|
+
size={context.size}
|
|
228
|
+
id={itemContext.textId}
|
|
229
|
+
{...itemTextProps}
|
|
230
|
+
ref={composedRefs}
|
|
231
|
+
/>,
|
|
232
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
178
233
|
[props, context.size, className, itemContext.textId]
|
|
179
234
|
);
|
|
180
235
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -208,7 +263,12 @@ const SelectGroup = React.forwardRef(
|
|
|
208
263
|
(props, forwardedRef) => {
|
|
209
264
|
const { __scopeSelect, ...groupProps } = props;
|
|
210
265
|
const groupId = useId();
|
|
211
|
-
return <SelectGroupContextProvider scope={__scopeSelect} id={groupId || ""}><SelectGroupFrame
|
|
266
|
+
return <SelectGroupContextProvider scope={__scopeSelect} id={groupId || ""}><SelectGroupFrame
|
|
267
|
+
role="group"
|
|
268
|
+
aria-labelledby={groupId}
|
|
269
|
+
{...groupProps}
|
|
270
|
+
ref={forwardedRef}
|
|
271
|
+
/></SelectGroupContextProvider>;
|
|
212
272
|
}
|
|
213
273
|
);
|
|
214
274
|
SelectGroup.displayName = GROUP_NAME;
|
|
@@ -218,7 +278,15 @@ const SelectLabel = React.forwardRef(
|
|
|
218
278
|
const { __scopeSelect, ...labelProps } = props;
|
|
219
279
|
const context = useSelectContext(LABEL_NAME, __scopeSelect);
|
|
220
280
|
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
221
|
-
return <ListItem
|
|
281
|
+
return <ListItem
|
|
282
|
+
tag="div"
|
|
283
|
+
componentName={LABEL_NAME}
|
|
284
|
+
fontWeight="800"
|
|
285
|
+
id={groupContext.id}
|
|
286
|
+
size={context.size}
|
|
287
|
+
{...labelProps}
|
|
288
|
+
ref={forwardedRef}
|
|
289
|
+
/>;
|
|
222
290
|
}
|
|
223
291
|
);
|
|
224
292
|
SelectLabel.displayName = LABEL_NAME;
|
|
@@ -230,11 +298,15 @@ const SelectSheetController = (props) => {
|
|
|
230
298
|
const showSheet = useShowSelectSheet(context);
|
|
231
299
|
const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
|
|
232
300
|
const getShowSheet = useGet(showSheet);
|
|
233
|
-
return <SheetController
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
301
|
+
return <SheetController
|
|
302
|
+
onOpenChange={(val) => {
|
|
303
|
+
if (getShowSheet()) {
|
|
304
|
+
props.onOpenChange(val);
|
|
305
|
+
}
|
|
306
|
+
}}
|
|
307
|
+
open={context.open}
|
|
308
|
+
hidden={breakpointActive === false}
|
|
309
|
+
>{props.children}</SheetController>;
|
|
238
310
|
};
|
|
239
311
|
const SelectSheetImpl = (props) => {
|
|
240
312
|
return <>{props.children}</>;
|
|
@@ -290,9 +362,40 @@ const Select = withStaticProperties(
|
|
|
290
362
|
selectedIndexRef.current = selectedIndex;
|
|
291
363
|
activeIndexRef.current = activeIndex;
|
|
292
364
|
});
|
|
293
|
-
return <AdaptProvider><SelectProvider
|
|
294
|
-
|
|
295
|
-
|
|
365
|
+
return <AdaptProvider><SelectProvider
|
|
366
|
+
dir={dir}
|
|
367
|
+
blockSelection={false}
|
|
368
|
+
size={sizeProp}
|
|
369
|
+
fallback={false}
|
|
370
|
+
selectedItem={selectedItem}
|
|
371
|
+
setSelectedItem={setSelectedItem}
|
|
372
|
+
forceUpdate={forceUpdate}
|
|
373
|
+
valueNode={valueNode}
|
|
374
|
+
onValueNodeChange={setValueNode}
|
|
375
|
+
onValueNodeHasChildrenChange={setValueNodeHasChildren}
|
|
376
|
+
valueNodeHasChildren={valueNodeHasChildren}
|
|
377
|
+
scopeKey={scopeKey}
|
|
378
|
+
sheetBreakpoint={sheetBreakpoint}
|
|
379
|
+
scope={__scopeSelect}
|
|
380
|
+
setValueAtIndex={(index, value2) => {
|
|
381
|
+
listContentRef.current[index] = value2;
|
|
382
|
+
}}
|
|
383
|
+
activeIndex={activeIndex}
|
|
384
|
+
onChange={setValue}
|
|
385
|
+
selectedIndex={selectedIndex}
|
|
386
|
+
setActiveIndex={setActiveIndex}
|
|
387
|
+
setOpen={setOpen}
|
|
388
|
+
setSelectedIndex={setSelectedIndex}
|
|
389
|
+
value={value}
|
|
390
|
+
open={open}
|
|
391
|
+
><SelectSheetController onOpenChange={setOpen} __scopeSelect={__scopeSelect}><SelectImpl
|
|
392
|
+
activeIndexRef={activeIndexRef}
|
|
393
|
+
listContentRef={listContentRef}
|
|
394
|
+
selectedIndexRef={selectedIndexRef}
|
|
395
|
+
{...props}
|
|
396
|
+
open={open}
|
|
397
|
+
value={value}
|
|
398
|
+
>{children}</SelectImpl></SelectSheetController></SelectProvider></AdaptProvider>;
|
|
296
399
|
},
|
|
297
400
|
{
|
|
298
401
|
Adapt,
|