@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/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": "
|
|
6
|
-
"names": ["props"]
|
|
5
|
+
"mappings": "ukBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,sBAAAE,KAAA,eAAAC,GAAAH,IA+TI,IAAAI,EAAA,6BA/TJC,EAgBO,8BACPC,EAKO,yBACPC,EAAuB,qBACvBC,EAA0B,qBAE1BC,EAAuD,uBACvD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AC,kBACC,MAAOzB,EACN,GAAIK,EACL,aAAcQ,EACd,eAAgBe,EAChB,YAAaiB,EACb,gBAAiB,CAACW,EAAOC,IAAU,CACjCrD,EAAe,QAAQoD,CAAK,EAAIC,CAClC,EACA,SAAUhC,EACV,aAAcwB,GACd,gBAAiBN,EACjB,YAAajC,EACb,cAAe,CAAC,CAACqC,GACjB,YAAa,CAAC,CAACD,GACf,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": ["SelectImpl_exports", "__export", "SelectInlineImpl", "__toCommonJS", "import_jsx_runtime", "import_react", "import_core", "React", "import_react_dom", "import_constants", "import_context", "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
|
}
|
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var SelectImpl_native_exports = {};
|
|
20
|
-
__export(SelectImpl_native_exports, {
|
|
21
|
-
SelectInlineImpl: () => SelectInlineImpl
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(SelectImpl_native_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
const SelectInlineImpl = (props) => {
|
|
26
|
-
if (process.env.NODE_ENV === "development") {
|
|
27
|
-
console.warn("Sheet not implemented inline on native");
|
|
28
|
-
}
|
|
29
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: props.children });
|
|
30
|
-
};
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
SelectInlineImpl
|
|
34
|
-
});
|
|
1
|
+
"use strict";var t=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var s=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},I=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of m(n))!c.call(e,l)&&l!==o&&t(e,l,{get:()=>n[l],enumerable:!(r=i(n,l))||r.enumerable});return e};var S=e=>I(t({},"__esModule",{value:!0}),e);var v={};s(v,{SelectInlineImpl:()=>d});module.exports=S(v);var p=require("react/jsx-runtime");const d=e=>(process.env.NODE_ENV==="development"&&console.warn("Sheet not implemented inline on native"),(0,p.jsx)(p.Fragment,{children:e.children}));0&&(module.exports={SelectInlineImpl});
|
|
35
2
|
//# sourceMappingURL=SelectImpl.native.js.map
|
|
@@ -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": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAYS,IAAAI,EAAA,6BALF,MAAMF,EAAoBG,IAC3B,QAAQ,IAAI,WAAa,eAE3B,QAAQ,KAAK,wCAAwC,KAEhD,mBAAG,SAAAA,EAAM,SAAS",
|
|
6
|
+
"names": ["SelectImpl_native_exports", "__export", "SelectInlineImpl", "__toCommonJS", "import_jsx_runtime", "props"]
|
|
7
7
|
}
|
|
@@ -1,176 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var SelectScrollButton_exports = {};
|
|
30
|
-
__export(SelectScrollButton_exports, {
|
|
31
|
-
SelectScrollDownButton: () => SelectScrollDownButton,
|
|
32
|
-
SelectScrollUpButton: () => SelectScrollUpButton
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(SelectScrollButton_exports);
|
|
35
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
var import_react = require("@floating-ui/react");
|
|
37
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
38
|
-
var import_core = require("@tamagui/core");
|
|
39
|
-
var import_stacks = require("@tamagui/stacks");
|
|
40
|
-
var React = __toESM(require("react"));
|
|
41
|
-
var import_react_dom = require("react-dom");
|
|
42
|
-
var import_context = require("./context");
|
|
43
|
-
const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
44
|
-
const SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
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
|
-
);
|
|
54
|
-
});
|
|
55
|
-
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
56
|
-
const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
57
|
-
const SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
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
|
-
);
|
|
67
|
-
});
|
|
68
|
-
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
69
|
-
const SelectScrollButtonImpl = React.memo(
|
|
70
|
-
React.forwardRef(
|
|
71
|
-
(props, forwardedRef) => {
|
|
72
|
-
var _a;
|
|
73
|
-
const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props;
|
|
74
|
-
const {
|
|
75
|
-
floatingRef,
|
|
76
|
-
forceUpdate,
|
|
77
|
-
open,
|
|
78
|
-
fallback,
|
|
79
|
-
setScrollTop,
|
|
80
|
-
setInnerOffset,
|
|
81
|
-
...context
|
|
82
|
-
} = (0, import_context.useSelectContext)(componentName, __scopeSelect);
|
|
83
|
-
const [element, setElement] = React.useState(null);
|
|
84
|
-
const statusRef = React.useRef("idle");
|
|
85
|
-
const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
|
|
86
|
-
const frameRef = React.useRef();
|
|
87
|
-
const { x, y, reference, floating, strategy, update, refs } = (0, import_react.useFloating)({
|
|
88
|
-
open: open && isVisible,
|
|
89
|
-
strategy: "fixed",
|
|
90
|
-
placement: dir === "up" ? "top" : "bottom",
|
|
91
|
-
middleware: [(0, import_react.offset)(({ rects }) => -rects.floating.height)],
|
|
92
|
-
whileElementsMounted: (...args) => (0, import_react.autoUpdate)(...args, { animationFrame: true })
|
|
93
|
-
});
|
|
94
|
-
const composedRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, floating);
|
|
95
|
-
if (floatingRef) {
|
|
96
|
-
if (open) {
|
|
97
|
-
if (element !== floatingRef.current) {
|
|
98
|
-
setElement(floatingRef.current);
|
|
99
|
-
reference(floatingRef.current);
|
|
100
|
-
requestAnimationFrame(update);
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
cancelAnimationFrame(frameRef.current);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
107
|
-
return () => {
|
|
108
|
-
cancelAnimationFrame(frameRef.current);
|
|
109
|
-
};
|
|
110
|
-
}, []);
|
|
111
|
-
if (!(isVisible && floatingRef)) {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
const onScroll = (amount) => {
|
|
115
|
-
console.log("on scroll?");
|
|
116
|
-
if (fallback) {
|
|
117
|
-
if (refs.floating.current) {
|
|
118
|
-
refs.floating.current.scrollTop -= amount;
|
|
119
|
-
(0, import_react_dom.flushSync)(() => {
|
|
120
|
-
var _a2;
|
|
121
|
-
return setScrollTop(((_a2 = refs.floating.current) == null ? void 0 : _a2.scrollTop) ?? 0);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
(0, import_react_dom.flushSync)(() => setInnerOffset((value) => value - amount));
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
129
|
-
import_stacks.YStack,
|
|
130
|
-
{
|
|
131
|
-
ref: composedRef,
|
|
132
|
-
componentName,
|
|
133
|
-
"aria-hidden": true,
|
|
134
|
-
...scrollIndicatorProps,
|
|
135
|
-
zIndex: 1e3,
|
|
136
|
-
position: strategy,
|
|
137
|
-
left: x || 0,
|
|
138
|
-
top: y || 0,
|
|
139
|
-
width: `calc(${(((_a = floatingRef == null ? void 0 : floatingRef.current) == null ? void 0 : _a.offsetWidth) ?? 0) - 2}px)`,
|
|
140
|
-
onPointerEnter: () => {
|
|
141
|
-
statusRef.current = "active";
|
|
142
|
-
let prevNow = Date.now();
|
|
143
|
-
function frame() {
|
|
144
|
-
if (element) {
|
|
145
|
-
const currentNow = Date.now();
|
|
146
|
-
const msElapsed = currentNow - prevNow;
|
|
147
|
-
prevNow = currentNow;
|
|
148
|
-
const pixelsToScroll = msElapsed / 2;
|
|
149
|
-
const remainingPixels = dir === "up" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;
|
|
150
|
-
const scrollRemaining = dir === "up" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;
|
|
151
|
-
onScroll(
|
|
152
|
-
dir === "up" ? Math.min(pixelsToScroll, remainingPixels) : Math.max(-pixelsToScroll, -remainingPixels)
|
|
153
|
-
);
|
|
154
|
-
if (scrollRemaining) {
|
|
155
|
-
frameRef.current = requestAnimationFrame(frame);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
cancelAnimationFrame(frameRef.current);
|
|
160
|
-
frameRef.current = requestAnimationFrame(frame);
|
|
161
|
-
},
|
|
162
|
-
onPointerLeave: () => {
|
|
163
|
-
statusRef.current = "idle";
|
|
164
|
-
cancelAnimationFrame(frameRef.current);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
)
|
|
170
|
-
);
|
|
171
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
172
|
-
0 && (module.exports = {
|
|
173
|
-
SelectScrollDownButton,
|
|
174
|
-
SelectScrollUpButton
|
|
175
|
-
});
|
|
1
|
+
"use strict";var K=Object.create;var f=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var ee=(e,t)=>{for(var o in t)f(e,o,{get:t[o],enumerable:!0})},N=(e,t,o,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of X(t))!j.call(e,c)&&c!==o&&f(e,c,{get:()=>t[c],enumerable:!(l=Q(t,c))||l.enumerable});return e};var te=(e,t,o)=>(o=e!=null?K(Z(e)):{},N(t||!e||!e.__esModule?f(o,"default",{value:e,enumerable:!0}):o,e)),oe=e=>N(f({},"__esModule",{value:!0}),e);var re={};ee(re,{SelectScrollDownButton:()=>L,SelectScrollUpButton:()=>_});module.exports=oe(re);var S=require("react/jsx-runtime"),p=require("@floating-ui/react"),y=require("@tamagui/compose-refs"),A=require("@tamagui/core"),F=require("@tamagui/stacks"),a=te(require("react")),g=require("react-dom"),U=require("./context");const R="SelectScrollUpButton",_=a.forwardRef((e,t)=>(0,S.jsx)(I,{componentName:R,...e,dir:"up",ref:t}));_.displayName=R;const x="SelectScrollDownButton",L=a.forwardRef((e,t)=>(0,S.jsx)(I,{componentName:x,...e,dir:"down",ref:t}));L.displayName=x;const I=a.memo(a.forwardRef((e,t)=>{var w;const{__scopeSelect:o,dir:l,componentName:c,...D}=e,{floatingRef:s,forceUpdate:ne,open:B,fallback:M,setScrollTop:O,setInnerOffset:H,...b}=(0,U.useSelectContext)(c,o),[r,v]=a.useState(null),P=a.useRef("idle"),T=b[l==="down"?"canScrollDown":"canScrollUp"],m=a.useRef(),{x:C,y:q,reference:k,floating:W,strategy:z,update:V,refs:d}=(0,p.useFloating)({open:B&&T,strategy:"fixed",placement:l==="up"?"top":"bottom",middleware:[(0,p.offset)(({rects:n})=>-n.floating.height)],whileElementsMounted:(...n)=>(0,p.autoUpdate)(...n,{animationFrame:!0})}),Y=(0,y.useComposedRefs)(t,W);if(s&&(B?r!==s.current&&(v(s.current),k(s.current),requestAnimationFrame(V)):cancelAnimationFrame(m.current)),(0,A.useIsomorphicLayoutEffect)(()=>()=>{cancelAnimationFrame(m.current)},[]),!(T&&s))return null;const $=n=>{console.log("on scroll?"),M?d.floating.current&&(d.floating.current.scrollTop-=n,(0,g.flushSync)(()=>{var i;return O(((i=d.floating.current)==null?void 0:i.scrollTop)??0)})):(0,g.flushSync)(()=>H(i=>i-n))};return(0,S.jsx)(F.YStack,{ref:Y,componentName:c,"aria-hidden":!0,...D,zIndex:1e3,position:z,left:C||0,top:q||0,width:`calc(${(((w=s==null?void 0:s.current)==null?void 0:w.offsetWidth)??0)-2}px)`,onPointerEnter:()=>{P.current="active";let n=Date.now();function i(){if(r){const h=Date.now(),G=h-n;n=h;const u=G/2,E=l==="up"?r.scrollTop:r.scrollHeight-r.clientHeight-r.scrollTop,J=l==="up"?r.scrollTop-u>0:r.scrollTop+u<r.scrollHeight-r.clientHeight;$(l==="up"?Math.min(u,E):Math.max(-u,-E)),J&&(m.current=requestAnimationFrame(i))}}cancelAnimationFrame(m.current),m.current=requestAnimationFrame(i)},onPointerLeave:()=>{P.current="idle",cancelAnimationFrame(m.current)}})}));0&&(module.exports={SelectScrollDownButton,SelectScrollUpButton});
|
|
176
2
|
//# sourceMappingURL=SelectScrollButton.js.map
|
|
@@ -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'\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 console.log('on scroll?')\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": "
|
|
6
|
-
"names": ["_a"]
|
|
5
|
+
"mappings": "6jBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,4BAAAE,EAAA,yBAAAC,IAAA,eAAAC,GAAAJ,IAyBI,IAAAK,EAAA,6BAzBJC,EAAgD,8BAChDC,EAAgC,iCAChCC,EAA0D,yBAC1DC,EAAuB,2BACvBC,EAAuB,qBACvBC,EAA0B,qBAE1BC,EAAiC,qBAWjC,MAAMC,EAAwB,uBAEjBV,EAAuBO,EAAM,WAGxC,CAACI,EAA6CC,OAE5C,OAACC,EAAA,CACC,cAAeH,EACd,GAAGC,EACJ,IAAI,KACJ,IAAKC,EACP,CAEH,EAEDZ,EAAqB,YAAcU,EAMnC,MAAMI,EAA0B,yBAEnBf,EAAyBQ,EAAM,WAG1C,CAACI,EAA6CC,OAE5C,OAACC,EAAA,CACC,cAAeC,EACd,GAAGH,EACJ,IAAI,OACJ,IAAKC,EACP,CAEH,EAEDb,EAAuB,YAAce,EAIrC,MAAMD,EAAyBN,EAAM,KACnCA,EAAM,WACJ,CAACI,EAAiDC,IAAiB,CA9DvE,IAAAG,EA+DM,KAAM,CAAE,cAAAC,EAAe,IAAAC,EAAK,cAAAC,EAAe,GAAGC,CAAqB,EAAIR,EACjE,CACJ,YAAAS,EACA,YAAAC,GACA,KAAAC,EACA,SAAAC,EACA,aAAAC,EACA,eAAAC,EACA,GAAGC,CACL,KAAI,oBAAiBR,EAAeF,CAAa,EAE3C,CAACW,EAASC,CAAU,EAAIrB,EAAM,SAA6B,IAAI,EAC/DsB,EAAYtB,EAAM,OAA0B,MAAM,EAClDuB,EAAYJ,EAAQT,IAAQ,OAAS,gBAAkB,aAAa,E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AAIgB,EAAU,KAAK,IAAI,EAEvB,SAASC,GAAQ,CACf,GAAInB,EAAS,CACX,MAAMoB,EAAa,KAAK,IAAI,EACtBC,EAAYD,EAAaF,EAC/BA,EAAUE,EAEV,MAAME,EAAiBD,EAAY,EAE7BE,EACJjC,IAAQ,KACJU,EAAQ,UACRA,EAAQ,aAAeA,EAAQ,aAAeA,EAAQ,UAEtDwB,EACJlC,IAAQ,KACJU,EAAQ,UAAYsB,EAAiB,EACrCtB,EAAQ,UAAYsB,EACpBtB,EAAQ,aAAeA,EAAQ,aAErCe,EACEzB,IAAQ,KACJ,KAAK,IAAIgC,EAAgBC,CAAe,EACxC,KAAK,IAAI,CAACD,EAAgB,CAACC,CAAe,CAChD,EAEIC,IACFpB,EAAS,QAAU,sBAAsBe,CAAK,EAElD,CACF,CAEA,qBAAqBf,EAAS,OAAO,EACrCA,EAAS,QAAU,sBAAsBe,CAAK,CAChD,EACA,eAAgB,IAAM,CACpBjB,EAAU,QAAU,OACpB,qBAAqBE,EAAS,OAAO,CACvC,EACF,CAEJ,CACF,CACF",
|
|
6
|
+
"names": ["SelectScrollButton_exports", "__export", "SelectScrollDownButton", "SelectScrollUpButton", "__toCommonJS", "import_jsx_runtime", "import_react", "import_compose_refs", "import_core", "import_stacks", "React", "import_react_dom", "import_context", "SCROLL_UP_BUTTON_NAME", "props", "forwardedRef", "SelectScrollButtonImpl", "SCROLL_DOWN_BUTTON_NAME", "_a", "__scopeSelect", "dir", "componentName", "scrollIndicatorProps", "floatingRef", "forceUpdate", "open", "fallback", "setScrollTop", "setInnerOffset", "context", "element", "setElement", "statusRef", "isVisible", "frameRef", "x", "y", "reference", "floating", "strategy", "update", "refs", "rects", "args", "composedRef", "onScroll", "amount", "value", "prevNow", "frame", "currentNow", "msElapsed", "pixelsToScroll", "remainingPixels", "scrollRemaining"]
|
|
7
7
|
}
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var SelectScrollButton_native_exports = {};
|
|
20
|
-
__export(SelectScrollButton_native_exports, {
|
|
21
|
-
SelectScrollDownButton: () => SelectScrollDownButton,
|
|
22
|
-
SelectScrollUpButton: () => SelectScrollUpButton
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(SelectScrollButton_native_exports);
|
|
25
|
-
const SelectScrollUpButton = (_) => null;
|
|
26
|
-
const SelectScrollDownButton = (_) => null;
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
SelectScrollDownButton,
|
|
30
|
-
SelectScrollUpButton
|
|
31
|
-
});
|
|
1
|
+
"use strict";var e=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var s=(o,t)=>{for(var c in t)e(o,c,{get:t[c],enumerable:!0})},u=(o,t,c,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of S(t))!n.call(o,l)&&l!==c&&e(o,l,{get:()=>t[l],enumerable:!(r=p(t,l))||r.enumerable});return o};var P=o=>u(e({},"__esModule",{value:!0}),o);var m={};s(m,{SelectScrollDownButton:()=>d,SelectScrollUpButton:()=>B});module.exports=P(m);const B=o=>null,d=o=>null;0&&(module.exports={SelectScrollDownButton,SelectScrollUpButton});
|
|
32
2
|
//# sourceMappingURL=SelectScrollButton.native.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectScrollButton.native.tsx"],
|
|
4
4
|
"sourcesContent": ["import { ScopedProps, SelectScrollButtonProps } from './types'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const SelectScrollUpButton = (_: ScopedProps<SelectScrollButtonProps>) => null\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const SelectScrollDownButton = (_: ScopedProps<SelectScrollButtonProps>) =>\n null\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAGO,MAAMG,EAAwBE,GAA4C,KAGpEH,EAA0BG,GACrC",
|
|
6
|
+
"names": ["SelectScrollButton_native_exports", "__export", "SelectScrollDownButton", "SelectScrollUpButton", "__toCommonJS", "_"]
|
|
7
7
|
}
|
|
@@ -1,112 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var SelectViewport_exports = {};
|
|
30
|
-
__export(SelectViewport_exports, {
|
|
31
|
-
SelectViewport: () => SelectViewport,
|
|
32
|
-
SelectViewportFrame: () => SelectViewportFrame
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(SelectViewport_exports);
|
|
35
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
var import_react = require("@floating-ui/react");
|
|
37
|
-
var import_core = require("@tamagui/core");
|
|
38
|
-
var import_core2 = require("@tamagui/core");
|
|
39
|
-
var import_portal = require("@tamagui/portal");
|
|
40
|
-
var import_stacks = require("@tamagui/stacks");
|
|
41
|
-
var React = __toESM(require("react"));
|
|
42
|
-
var import_constants = require("./constants");
|
|
43
|
-
var import_context = require("./context");
|
|
44
|
-
var import_useSelectBreakpointActive = require("./useSelectBreakpointActive");
|
|
45
|
-
const SelectViewportFrame = (0, import_core2.styled)(import_stacks.ThemeableStack, {
|
|
46
|
-
name: import_constants.VIEWPORT_NAME,
|
|
47
|
-
backgroundColor: "$background",
|
|
48
|
-
elevate: true,
|
|
49
|
-
bordered: true,
|
|
50
|
-
userSelect: "none",
|
|
51
|
-
outlineWidth: 0,
|
|
52
|
-
variants: {
|
|
53
|
-
size: {
|
|
54
|
-
"...size": (val, { tokens }) => {
|
|
55
|
-
return {
|
|
56
|
-
borderRadius: tokens.radius[val] ?? val
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
defaultVariants: {
|
|
62
|
-
size: "$2"
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
const SelectViewport = React.forwardRef(
|
|
66
|
-
(props, forwardedRef) => {
|
|
67
|
-
const { __scopeSelect, children, disableScroll, ...viewportProps } = props;
|
|
68
|
-
const context = (0, import_context.useSelectContext)(import_constants.VIEWPORT_NAME, __scopeSelect);
|
|
69
|
-
const breakpointActive = (0, import_useSelectBreakpointActive.useSelectBreakpointActive)(context.sheetBreakpoint);
|
|
70
|
-
if (breakpointActive || !import_core.isWeb) {
|
|
71
|
-
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 }) });
|
|
72
|
-
}
|
|
73
|
-
if (!context.floatingContext) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
if (!context.open) {
|
|
77
|
-
return children;
|
|
78
|
-
}
|
|
79
|
-
const {
|
|
80
|
-
style: { scrollbarWidth, listStyleType, overflow, ...restStyle },
|
|
81
|
-
...floatingProps
|
|
82
|
-
} = context.interactions.getFloatingProps();
|
|
83
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
84
|
-
!disableScroll && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
|
-
"style",
|
|
86
|
-
{
|
|
87
|
-
dangerouslySetInnerHTML: {
|
|
88
|
-
__html: selectViewportCSS
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
),
|
|
92
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.FloatingFocusManager, { context: context.floatingContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
93
|
-
SelectViewportFrame,
|
|
94
|
-
{
|
|
95
|
-
size: context.size,
|
|
96
|
-
role: "presentation",
|
|
97
|
-
...viewportProps,
|
|
98
|
-
ref: forwardedRef,
|
|
99
|
-
...floatingProps,
|
|
100
|
-
...restStyle,
|
|
101
|
-
overflow: disableScroll ? void 0 : overflow ?? "scroll",
|
|
102
|
-
children
|
|
103
|
-
}
|
|
104
|
-
) })
|
|
105
|
-
] });
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
SelectViewport.displayName = import_constants.VIEWPORT_NAME;
|
|
109
|
-
const selectViewportCSS = `
|
|
1
|
+
"use strict";var y=Object.create;var s=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var o in t)s(e,o,{get:t[o],enumerable:!0})},p=(e,t,o,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of x(t))!C.call(e,i)&&i!==o&&s(e,i,{get:()=>t[i],enumerable:!(l=k(t,i))||l.enumerable});return e};var T=(e,t,o)=>(o=e!=null?y(F(e)):{},p(t||!e||!e.__esModule?s(o,"default",{value:e,enumerable:!0}):o,e)),z=e=>p(s({},"__esModule",{value:!0}),e);var I={};_(I,{SelectViewport:()=>b,SelectViewportFrame:()=>g});module.exports=z(I);var r=require("react/jsx-runtime"),m=require("@floating-ui/react"),d=require("@tamagui/core"),f=require("@tamagui/core"),S=require("@tamagui/portal"),u=require("@tamagui/stacks"),A=T(require("react")),a=require("./constants"),c=require("./context"),w=require("./useSelectBreakpointActive");const g=(0,f.styled)(u.ThemeableStack,{name:a.VIEWPORT_NAME,backgroundColor:"$background",elevate:!0,bordered:!0,userSelect:"none",outlineWidth:0,variants:{size:{"...size":(e,{tokens:t})=>({borderRadius:t.radius[e]??e})}},defaultVariants:{size:"$2"}}),b=A.forwardRef((e,t)=>{const{__scopeSelect:o,children:l,disableScroll:i,...h}=e,n=(0,c.useSelectContext)(a.VIEWPORT_NAME,o);if((0,w.useSelectBreakpointActive)(n.sheetBreakpoint)||!d.isWeb)return(0,r.jsx)(S.PortalItem,{hostName:`${n.scopeKey}SheetContents`,children:(0,r.jsx)(c.ForwardSelectContext,{context:n,children:l})});if(!n.floatingContext)return null;if(!n.open)return l;const{style:{scrollbarWidth:R,listStyleType:W,overflow:P,...V},...v}=n.interactions.getFloatingProps();return(0,r.jsxs)(r.Fragment,{children:[!i&&(0,r.jsx)("style",{dangerouslySetInnerHTML:{__html:E}}),(0,r.jsx)(m.FloatingFocusManager,{context:n.floatingContext,children:(0,r.jsx)(g,{size:n.size,role:"presentation",...h,ref:t,...v,...V,overflow:i?void 0:P??"scroll",children:l})})]})});b.displayName=a.VIEWPORT_NAME;const E=`
|
|
110
2
|
.is_SelectViewport {
|
|
111
3
|
scrollbar-width: none;
|
|
112
4
|
-webkit-overflow-scrolling: touch;
|
|
@@ -116,10 +8,5 @@ const selectViewportCSS = `
|
|
|
116
8
|
.is_SelectViewport::-webkit-scrollbar{
|
|
117
9
|
display:none
|
|
118
10
|
}
|
|
119
|
-
`;
|
|
120
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
121
|
-
0 && (module.exports = {
|
|
122
|
-
SelectViewport,
|
|
123
|
-
SelectViewportFrame
|
|
124
|
-
});
|
|
11
|
+
`;0&&(module.exports={SelectViewport,SelectViewportFrame});
|
|
125
12
|
//# sourceMappingURL=SelectViewport.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectViewport.tsx"],
|
|
4
4
|
"sourcesContent": ["import { FloatingFocusManager } from '@floating-ui/react'\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 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, disableScroll, ...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, overflow, ...restStyle },\n ...floatingProps\n } = context.interactions!.getFloatingProps()\n\n return (\n <>\n {!disableScroll && (\n <style\n dangerouslySetInnerHTML={{\n __html: selectViewportCSS,\n }}\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 overflow={disableScroll ? undefined : overflow ?? 'scroll'}\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": "
|
|
6
|
-
"names": ["import_core"]
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,wBAAAC,IAAA,eAAAC,EAAAJ,GAgDU,IAAAK,EAAA,6BAhDVC,EAAqC,8BACrCC,EAAsC,yBACtCA,EAAuB,yBACvBC,EAA2B,2BAC3BC,EAA+B,2BAC/BC,EAAuB,oBAEvBC,EAA8B,uBAC9BC,EAAuD,qBAEvDC,EAA0C,uCAMnC,MAAMV,KAAsB,UAAO,iBAAgB,CACxD,KAAM,gBACN,gBAAiB,cACjB,QAAS,GACT,SAAU,GACV,WAAY,OACZ,aAAc,EAEd,SAAU,CACR,KAAM,CACJ,UAAW,CAACW,EAAK,CAAE,OAAAC,CAAO,KACjB,CACL,aAAcA,EAAO,OAAOD,CAAG,GAAKA,CACtC,EAEJ,CACF,EAEA,gBAAiB,CACf,KAAM,IACR,CACF,CAAC,EAEYZ,EAAiBQ,EAAM,WAClC,CAACM,EAAyCC,IAAiB,CACzD,KAAM,CAAE,cAAAC,EAAe,SAAAC,EAAU,cAAAC,EAAe,GAAGC,CAAc,EAAIL,EAC/DM,KAAU,oBAAiB,gBAAeJ,CAAa,EAG7D,MAFyB,6BAA0BI,EAAQ,eAAe,GAElD,CAAC,QACvB,SACE,OAAC,cAAW,SAAU,GAAGA,EAAQ,wBAC/B,mBAAC,wBAAqB,QAASA,EAAU,SAAAH,EAAS,EACpD,EAIJ,GAAI,CAACG,EAAQ,gBACX,OAAO,KAGT,GAAI,CAACA,EAAQ,KACX,OAAOH,EAGT,KAAM,CACJ,MAAO,CAAE,eAAAI,EAAgB,cAAAC,EAAe,SAAAC,EAAU,GAAGC,CAAU,EAC/D,GAAGC,CACL,EAAIL,EAAQ,aAAc,iBAAiB,EAE3C,SACE,oBACG,WAACF,MACA,OAAC,SACC,wBAAyB,CACvB,OAAQQ,CACV,EACF,KAEF,OAAC,wBAAqB,QAASN,EAAQ,gBACrC,mBAACnB,EAAA,CACC,KAAMmB,EAAQ,KAEd,KAAK,eACJ,GAAGD,EACJ,IAAKJ,EACJ,GAAGU,EACH,GAAGD,EACJ,SAAUN,EAAgB,OAAYK,GAAY,SAEjD,SAAAN,EACH,EACF,GACF,CAEJ,CACF,EAEAjB,EAAe,YAAc,gBAE7B,MAAM0B,EAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": ["SelectViewport_exports", "__export", "SelectViewport", "SelectViewportFrame", "__toCommonJS", "import_jsx_runtime", "import_react", "import_core", "import_portal", "import_stacks", "React", "import_constants", "import_context", "import_useSelectBreakpointActive", "val", "tokens", "props", "forwardedRef", "__scopeSelect", "children", "disableScroll", "viewportProps", "context", "scrollbarWidth", "listStyleType", "overflow", "restStyle", "floatingProps", "selectViewportCSS"]
|
|
7
7
|
}
|