@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
|
@@ -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-dom-interactions'\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, { pointerDown: true }),\n useDismiss(context, { outsidePointerDown: 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": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+TI;AA/TJ,oCAgBO;AACP,kBAKO;AACP,YAAuB;AACvB,uBAA0B;AAE1B,uBAAuD;AACvD,qBAAiD;AAI1C,MAAM,mBAAmB,CAAC,UAA2B;AAC1D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,oBAAgB,iCAAiB,mBAAmB,aAAa;AACvE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,CAAC;AAClD,QAAM,YAAQ,8BAAiB;AAE/B,QAAM,eAAe,MAAM,OAAkC,CAAC,CAAC;AAC/D,QAAM,cAAc,MAAM,OAA0B,IAAI;AACxD,QAAM,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AAAA,EACF,GAAG,CAAC,MAAM,UAAU,aAAa,CAAC;AAIlC,6CAA0B,MAAM;AAC9B,QAAI,KAAK,SAAS,WAAW,UAAU;AACrC,WAAK,SAAS,QAAQ,MAAM,YAAY;AAAA,IAC1C;AAAA,EACF,GAAG,CAAC,MAAM,QAAQ,CAAC;AAOnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACN,GAAI;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB,CAAC,OAAO,UAAU;AACjC,uBAAe,QAAQ,KAAK,IAAI;AAAA,MAClC;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,iBAAiB;AAAA,MACjB;AAAA,MACA,eAAe,CAAC,CAAC;AAAA,MACjB,aAAa,CAAC,CAAC;AAAA,MACf;AAAA,MACA,SAAS,QAAQ;AAAA,MACjB,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EAaH;AAEJ;AAGA,MAAM,YAAa,OAAO,cAAc,eAAe,UAAU,aAAc;",
|
|
6
6
|
"names": ["props"]
|
|
7
7
|
}
|
|
@@ -26,9 +26,7 @@ const SelectInlineImpl = (props) => {
|
|
|
26
26
|
if (process.env.NODE_ENV === "development") {
|
|
27
27
|
console.warn("Sheet not implemented inline on native");
|
|
28
28
|
}
|
|
29
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
30
|
-
children: props.children
|
|
31
|
-
});
|
|
29
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: props.children });
|
|
32
30
|
};
|
|
33
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
32
|
0 && (module.exports = {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectImpl.native.tsx"],
|
|
4
4
|
"sourcesContent": ["import { SelectImplProps } from './types'\n\n/**\n * TODO can just make it a sheet for native\n * later on can have `native` prop\n */\n\nexport const SelectInlineImpl = (props: SelectImplProps) => {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('Sheet not implemented inline on native')\n }\n return <>{props.children}</>\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYS;AALF,MAAM,mBAAmB,CAAC,UAA2B;AAC1D,MAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,YAAQ,KAAK,wCAAwC;AAAA,EACvD;AACA,SAAO
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYS;AALF,MAAM,mBAAmB,CAAC,UAA2B;AAC1D,MAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,YAAQ,KAAK,wCAAwC;AAAA,EACvD;AACA,SAAO,2EAAG,gBAAM,UAAS;AAC3B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -38,22 +42,28 @@ var import_react_dom = require("react-dom");
|
|
|
38
42
|
var import_context = require("./context");
|
|
39
43
|
const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
40
44
|
const SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
41
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
46
|
+
SelectScrollButtonImpl,
|
|
47
|
+
{
|
|
48
|
+
componentName: SCROLL_UP_BUTTON_NAME,
|
|
49
|
+
...props,
|
|
50
|
+
dir: "up",
|
|
51
|
+
ref: forwardedRef
|
|
52
|
+
}
|
|
53
|
+
);
|
|
47
54
|
});
|
|
48
55
|
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
49
56
|
const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
50
57
|
const SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
51
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
+
SelectScrollButtonImpl,
|
|
60
|
+
{
|
|
61
|
+
componentName: SCROLL_DOWN_BUTTON_NAME,
|
|
62
|
+
...props,
|
|
63
|
+
dir: "down",
|
|
64
|
+
ref: forwardedRef
|
|
65
|
+
}
|
|
66
|
+
);
|
|
57
67
|
});
|
|
58
68
|
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
59
69
|
const SelectScrollButtonImpl = React.memo(
|
|
@@ -114,43 +124,46 @@ const SelectScrollButtonImpl = React.memo(
|
|
|
114
124
|
(0, import_react_dom.flushSync)(() => setInnerOffset((value) => value - amount));
|
|
115
125
|
}
|
|
116
126
|
};
|
|
117
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
dir === "up" ?
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
128
|
+
import_stacks.YStack,
|
|
129
|
+
{
|
|
130
|
+
ref: composedRef,
|
|
131
|
+
componentName,
|
|
132
|
+
"aria-hidden": true,
|
|
133
|
+
...scrollIndicatorProps,
|
|
134
|
+
zIndex: 1e3,
|
|
135
|
+
position: strategy,
|
|
136
|
+
left: x || 0,
|
|
137
|
+
top: y || 0,
|
|
138
|
+
width: `calc(${(((_a = floatingRef == null ? void 0 : floatingRef.current) == null ? void 0 : _a.offsetWidth) ?? 0) - 2}px)`,
|
|
139
|
+
onPointerEnter: () => {
|
|
140
|
+
statusRef.current = "active";
|
|
141
|
+
let prevNow = Date.now();
|
|
142
|
+
function frame() {
|
|
143
|
+
if (element) {
|
|
144
|
+
const currentNow = Date.now();
|
|
145
|
+
const msElapsed = currentNow - prevNow;
|
|
146
|
+
prevNow = currentNow;
|
|
147
|
+
const pixelsToScroll = msElapsed / 2;
|
|
148
|
+
const remainingPixels = dir === "up" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;
|
|
149
|
+
const scrollRemaining = dir === "up" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;
|
|
150
|
+
onScroll(
|
|
151
|
+
dir === "up" ? Math.min(pixelsToScroll, remainingPixels) : Math.max(-pixelsToScroll, -remainingPixels)
|
|
152
|
+
);
|
|
153
|
+
if (scrollRemaining) {
|
|
154
|
+
frameRef.current = requestAnimationFrame(frame);
|
|
155
|
+
}
|
|
143
156
|
}
|
|
144
157
|
}
|
|
158
|
+
cancelAnimationFrame(frameRef.current);
|
|
159
|
+
frameRef.current = requestAnimationFrame(frame);
|
|
160
|
+
},
|
|
161
|
+
onPointerLeave: () => {
|
|
162
|
+
statusRef.current = "idle";
|
|
163
|
+
cancelAnimationFrame(frameRef.current);
|
|
145
164
|
}
|
|
146
|
-
cancelAnimationFrame(frameRef.current);
|
|
147
|
-
frameRef.current = requestAnimationFrame(frame);
|
|
148
|
-
},
|
|
149
|
-
onPointerLeave: () => {
|
|
150
|
-
statusRef.current = "idle";
|
|
151
|
-
cancelAnimationFrame(frameRef.current);
|
|
152
165
|
}
|
|
153
|
-
|
|
166
|
+
);
|
|
154
167
|
}
|
|
155
168
|
)
|
|
156
169
|
);
|
|
@@ -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.current)\n }}\n />\n )\n }\n )\n)\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBI;AAzBJ,oCAAgD;AAChD,0BAAgC;AAChC,kBAA0D;AAC1D,oBAAuB;AACvB,YAAuB;AACvB,uBAA0B;AAE1B,qBAAiC;AAWjC,MAAM,wBAAwB;AAEvB,MAAM,uBAAuB,MAAM,WAGxC,CAAC,OAA6C,iBAAiB;AAC/D,SACE;AA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,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
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -65,13 +69,7 @@ const SelectViewport = React.forwardRef(
|
|
|
65
69
|
const context = (0, import_context.useSelectContext)(import_constants.VIEWPORT_NAME, __scopeSelect);
|
|
66
70
|
const breakpointActive = (0, import_useSelectBreakpointActive.useSelectBreakpointActive)(context.sheetBreakpoint);
|
|
67
71
|
if (breakpointActive || !import_core.isWeb) {
|
|
68
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, {
|
|
69
|
-
hostName: `${context.scopeKey}SheetContents`,
|
|
70
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.ForwardSelectContext, {
|
|
71
|
-
context,
|
|
72
|
-
children
|
|
73
|
-
})
|
|
74
|
-
});
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { hostName: `${context.scopeKey}SheetContents`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.ForwardSelectContext, { context, children }) });
|
|
75
73
|
}
|
|
76
74
|
if (!context.floatingContext) {
|
|
77
75
|
return null;
|
|
@@ -83,27 +81,28 @@ const SelectViewport = React.forwardRef(
|
|
|
83
81
|
style: { scrollbarWidth, listStyleType, ...restStyle },
|
|
84
82
|
...floatingProps
|
|
85
83
|
} = context.interactions.getFloatingProps();
|
|
86
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
85
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
|
+
"style",
|
|
87
|
+
{
|
|
89
88
|
dangerouslySetInnerHTML: {
|
|
90
89
|
__html: selectViewportCSS
|
|
91
90
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
});
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_dom_interactions.FloatingFocusManager, { context: context.floatingContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
94
|
+
SelectViewportFrame,
|
|
95
|
+
{
|
|
96
|
+
size: context.size,
|
|
97
|
+
role: "presentation",
|
|
98
|
+
...viewportProps,
|
|
99
|
+
ref: forwardedRef,
|
|
100
|
+
...floatingProps,
|
|
101
|
+
...restStyle,
|
|
102
|
+
children
|
|
103
|
+
}
|
|
104
|
+
) })
|
|
105
|
+
] });
|
|
107
106
|
}
|
|
108
107
|
);
|
|
109
108
|
SelectViewport.displayName = import_constants.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": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiDU;AAjDV,oCAAqC;AACrC,kBAAsC;AACtC,IAAAA,eAAuB;AACvB,oBAA2B;AAC3B,oBAA+B;AAC/B,YAAuB;AAEvB,uBAA8B;AAC9B,qBAAuD;AAEvD,uCAA0C;AAMnC,MAAM,0BAAsB,qBAAO,8BAAgB;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,GAAG,KAAK;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AAEM,MAAM,iBAAiB,MAAM;AAAA,EAClC,CAAC,OAAyC,iBAAiB;AACzD,UAAM,EAAE,eAAe,UAAU,GAAG,cAAc,IAAI;AACtD,UAAM,cAAU,iCAAiB,gCAAe,aAAa;AAC7D,UAAM,uBAAmB,4DAA0B,QAAQ,eAAe;AAE1E,QAAI,oBAAoB,CAAC,mBAAO;AAC9B,aACE,4CAAC,4BAAW,UAAU,GAAG,QAAQ,yBAC/B,sDAAC,uCAAqB,SAAmB,UAAS,GACpD;AAAA,IAEJ;AAEA,QAAI,CAAC,QAAQ,iBAAiB;AAC5B,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,QAAQ,MAAM;AACjB,aAAO;AAAA,IACT;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,gBAAgB,eAAe,GAAG,UAAU;AAAA,MACrD,GAAG;AAAA,IACL,IAAI,QAAQ,aAAc,iBAAiB;AAE3C,WACE,4EACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,yBAAyB;AAAA,YACvB,QAAQ;AAAA,UACV;AAAA;AAAA,MACF;AAAA,MACA,4CAAC,sDAAqB,SAAS,QAAQ,iBACrC;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,QAAQ;AAAA,UAEd,MAAK;AAAA,UACJ,GAAG;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": ["import_core"]
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -39,20 +43,7 @@ const SelectViewport = (props) => {
|
|
|
39
43
|
const context = (0, import_context.useSelectContext)(import_constants.VIEWPORT_NAME, __scopeSelect);
|
|
40
44
|
const themeName = (0, import_core.useThemeName)();
|
|
41
45
|
const adaptContext = React.useContext(import_adapt.AdaptParentContext);
|
|
42
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, {
|
|
43
|
-
hostName: `${context.scopeKey}SheetContents`,
|
|
44
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
45
|
-
name: themeName,
|
|
46
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.SelectProvider, {
|
|
47
|
-
scope: __scopeSelect,
|
|
48
|
-
...context,
|
|
49
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.AdaptParentContext.Provider, {
|
|
50
|
-
value: adaptContext,
|
|
51
|
-
children
|
|
52
|
-
})
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
});
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { hostName: `${context.scopeKey}SheetContents`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { name: themeName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.SelectProvider, { scope: __scopeSelect, ...context, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.AdaptParentContext.Provider, { value: adaptContext, children }) }) }) });
|
|
56
47
|
};
|
|
57
48
|
SelectViewport.displayName = import_constants.VIEWPORT_NAME;
|
|
58
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -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": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBU;AApBV,mBAAmC;AACnC,kBAA2C;AAC3C,oBAA2B;AAC3B,YAAuB;AAEvB,uBAA8B;AAC9B,qBAAiD;AAG1C,MAAM,iBAAiB,CAAC,UAA4C;AACzE,QAAM,EAAE,eAAe,SAAS,IAAI;AACpC,QAAM,cAAU,iCAAiB,gCAAe,aAAa;AAC7D,QAAM,gBAAY,0BAAa;AAC/B,QAAM,eAAe,MAAM,WAAW,+BAAkB;AAGxD,SACE,4CAAC,4BAAW,UAAU,GAAG,QAAQ,yBAC/B,sDAAC,qBAAM,MAAM,WACX,sDAAC,iCAAe,OAAO,eAAgB,GAAG,SACxC,sDAAC,gCAAmB,UAAnB,EAA4B,OAAO,cACjC,UACH,GACF,GACF,GACF;AAEJ;AAEA,eAAe,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/context.js
CHANGED
|
@@ -31,12 +31,7 @@ var import_constants = require("./constants");
|
|
|
31
31
|
const [createSelectContext, createSelectScope] = (0, import_create_context.createContextScope)(import_constants.SELECT_NAME);
|
|
32
32
|
const [SelectProvider, useSelectContext] = createSelectContext(import_constants.SELECT_NAME);
|
|
33
33
|
const ForwardSelectContext = (props) => {
|
|
34
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectProvider, {
|
|
35
|
-
isInSheet: true,
|
|
36
|
-
scope: props.__scopeSelect,
|
|
37
|
-
...props.context,
|
|
38
|
-
children: props.children
|
|
39
|
-
});
|
|
34
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectProvider, { isInSheet: true, scope: props.__scopeSelect, ...props.context, children: props.children });
|
|
40
35
|
};
|
|
41
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
37
|
0 && (module.exports = {
|
package/dist/cjs/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": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeI;AAfJ,4BAAmC;AAEnC,uBAA4B;AAGrB,MAAM,CAAC,qBAAqB,iBAAiB,QAClD,0CAAmB,4BAAW;AAEzB,MAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,4BAAW;AAE9C,MAAM,uBAAuB,CAClC,UACG;AACH,SACE,4CAAC
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeI;AAfJ,4BAAmC;AAEnC,uBAA4B;AAGrB,MAAM,CAAC,qBAAqB,iBAAiB,QAClD,0CAAmB,4BAAW;AAEzB,MAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,4BAAW;AAE9C,MAAM,uBAAuB,CAClC,UACG;AACH,SACE,4CAAC,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AAIlB,MAAM,4BAA4B,CACvC,oBACG;AACH,QAAM,YAAQ,sBAAS;AACvB,MAAI,CAAC;AAAiB,WAAO;AAC7B,MAAI,oBAAoB;AAAM,WAAO;AACrC,SAAO,kBAAkB,MAAM,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AAIlB,MAAM,4BAA4B,CACvC,oBACG;AACH,QAAM,YAAQ,sBAAS;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
|
}
|