@tamagui/select 1.0.1-beta.149 → 1.0.1-beta.152
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 +24 -19
- package/dist/cjs/BubbleSelect.js.map +1 -1
- package/dist/cjs/Select.js +342 -301
- package/dist/cjs/Select.js.map +3 -3
- package/dist/cjs/SelectContent.js +18 -15
- package/dist/cjs/SelectContent.js.map +1 -1
- package/dist/cjs/SelectContent.native.js.map +1 -1
- package/dist/cjs/SelectImpl.js +9 -4
- package/dist/cjs/SelectImpl.js.map +2 -2
- package/dist/cjs/SelectScrollButton.js +109 -95
- package/dist/cjs/SelectScrollButton.js.map +2 -2
- package/dist/cjs/SelectViewport.js +49 -35
- package/dist/cjs/SelectViewport.js.map +2 -2
- package/dist/cjs/SelectViewport.native.js +5 -7
- package/dist/cjs/SelectViewport.native.js.map +1 -1
- package/dist/cjs/context.js.map +1 -1
- package/dist/esm/BubbleSelect.js +20 -18
- package/dist/esm/BubbleSelect.js.map +1 -1
- package/dist/esm/Select.js +338 -300
- package/dist/esm/Select.js.map +3 -3
- package/dist/esm/SelectContent.js +18 -12
- package/dist/esm/SelectContent.js.map +1 -1
- package/dist/esm/SelectContent.native.js.map +1 -1
- package/dist/esm/SelectImpl.js +5 -3
- package/dist/esm/SelectImpl.js.map +2 -2
- package/dist/esm/SelectScrollButton.js +105 -94
- package/dist/esm/SelectScrollButton.js.map +2 -2
- package/dist/esm/SelectViewport.js +45 -34
- package/dist/esm/SelectViewport.js.map +1 -1
- package/dist/esm/SelectViewport.native.js +5 -4
- package/dist/esm/SelectViewport.native.js.map +1 -1
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/jsx/BubbleSelect.js +20 -18
- package/dist/jsx/BubbleSelect.js.map +1 -1
- package/dist/jsx/Select.js +217 -196
- package/dist/jsx/Select.js.map +3 -3
- package/dist/jsx/SelectContent.js.map +1 -1
- package/dist/jsx/SelectContent.native.js.map +1 -1
- package/dist/jsx/SelectImpl.js.map +2 -2
- package/dist/jsx/SelectScrollButton.js +79 -69
- package/dist/jsx/SelectScrollButton.js.map +1 -1
- package/dist/jsx/SelectViewport.js +25 -23
- package/dist/jsx/SelectViewport.js.map +1 -1
- package/dist/jsx/SelectViewport.native.js.map +1 -1
- package/dist/jsx/context.js.map +1 -1
- package/dist/jsx/index.js.map +1 -1
- package/package.json +12 -12
- package/src/Select.tsx +1 -1
|
@@ -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 { ScopedProps, SelectScrollButtonImplProps, SelectScrollButtonProps } from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectScrollUpButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SCROLL_UP_BUTTON_NAME = 'SelectScrollUpButton'\n\nexport const SelectScrollUpButton = React.forwardRef<TamaguiElement, 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)\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<TamaguiElement, 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)\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 { floatingRef, forceUpdate, open, fallback, setScrollTop, setInnerOffset, ...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 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": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBM;AAnBN,oCAAgD;AAChD,0BAAgC;AAChC,kBAA0D;AAC1D,oBAAuB;AACvB,YAAuB;AACvB,uBAA0B;AAE1B,qBAAiC;AAOjC,MAAM,wBAAwB;AAEvB,MAAM,uBAAuB,MAAM;AAAA,EACxC,CAAC,OAA6C,iBAAiB;AAC7D,WACE,4CAAC;AAAA,MACC,eAAe;AAAA,MACd,GAAG;AAAA,MACJ,KAAI;AAAA,MACJ,KAAK;AAAA,KACP;AAAA,EAEJ;AACF;AAEA,qBAAqB,cAAc;AAMnC,MAAM,0BAA0B;AAEzB,MAAM,yBAAyB,MAAM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;AAAA,UACF;AAEA,+BAAqB,SAAS,OAAO;AACrC,mBAAS,UAAU,sBAAsB,KAAK;AAAA,QAChD;AAAA,QACA,gBAAgB,MAAM;AACpB,oBAAU,UAAU;AACpB,+BAAqB,SAAS,OAAO;AAAA,QACvC;AAAA,OACF;AAAA,IAEJ;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["_a"]
|
|
7
7
|
}
|
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var SelectViewport_exports = {};
|
|
23
26
|
__export(SelectViewport_exports, {
|
|
@@ -25,6 +28,7 @@ __export(SelectViewport_exports, {
|
|
|
25
28
|
SelectViewportFrame: () => SelectViewportFrame
|
|
26
29
|
});
|
|
27
30
|
module.exports = __toCommonJS(SelectViewport_exports);
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
32
|
var import_react_dom_interactions = require("@floating-ui/react-dom-interactions");
|
|
29
33
|
var import_core = require("@tamagui/core");
|
|
30
34
|
var import_core2 = require("@tamagui/core");
|
|
@@ -54,41 +58,51 @@ const SelectViewportFrame = (0, import_core2.styled)(import_stacks.ThemeableStac
|
|
|
54
58
|
size: "$2"
|
|
55
59
|
}
|
|
56
60
|
});
|
|
57
|
-
const SelectViewport = React.forwardRef(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
if (!context.open) {
|
|
70
|
-
return children;
|
|
71
|
-
}
|
|
72
|
-
const {
|
|
73
|
-
style: { scrollbarWidth, listStyleType, ...restStyle },
|
|
74
|
-
...floatingProps
|
|
75
|
-
} = context.interactions.getFloatingProps();
|
|
76
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("style", {
|
|
77
|
-
dangerouslySetInnerHTML: {
|
|
78
|
-
__html: selectViewportCSS
|
|
61
|
+
const SelectViewport = React.forwardRef(
|
|
62
|
+
(props, forwardedRef) => {
|
|
63
|
+
const { __scopeSelect, children, ...viewportProps } = props;
|
|
64
|
+
const context = (0, import_context.useSelectContext)(import_constants.VIEWPORT_NAME, __scopeSelect);
|
|
65
|
+
const breakpointActive = (0, import_Select.useSelectBreakpointActive)(context.sheetBreakpoint);
|
|
66
|
+
if (breakpointActive || !import_core.isWeb) {
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, {
|
|
68
|
+
hostName: `${context.scopeKey}SheetContents`,
|
|
69
|
+
children
|
|
70
|
+
});
|
|
79
71
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
72
|
+
if (!context.floatingContext) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
if (!context.open) {
|
|
76
|
+
return children;
|
|
77
|
+
}
|
|
78
|
+
const {
|
|
79
|
+
style: { scrollbarWidth, listStyleType, ...restStyle },
|
|
80
|
+
...floatingProps
|
|
81
|
+
} = context.interactions.getFloatingProps();
|
|
82
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", {
|
|
85
|
+
dangerouslySetInnerHTML: {
|
|
86
|
+
__html: selectViewportCSS
|
|
87
|
+
}
|
|
88
|
+
}),
|
|
89
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_dom_interactions.FloatingFocusManager, {
|
|
90
|
+
context: context.floatingContext,
|
|
91
|
+
preventTabbing: true,
|
|
92
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectViewportFrame, {
|
|
93
|
+
size: context.size,
|
|
94
|
+
role: "presentation",
|
|
95
|
+
...viewportProps,
|
|
96
|
+
ref: forwardedRef,
|
|
97
|
+
...floatingProps,
|
|
98
|
+
...restStyle,
|
|
99
|
+
children
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
);
|
|
92
106
|
SelectViewport.displayName = import_constants.VIEWPORT_NAME;
|
|
93
107
|
const selectViewportCSS = `
|
|
94
108
|
.is_SelectViewport {
|
|
@@ -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 { useSelectContext } from './context'\nimport { useSelectBreakpointActive } from './Select'\nimport { ScopedProps, SelectViewportProps } from './types'\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\n variants: {\n size: {\n '...size': (val, { tokens }) => {\n return {\n borderRadius: tokens.radius[val] ?? val,\n }\n },\n },\n },\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 <PortalItem hostName={`${context.scopeKey}SheetContents`}>{children}</PortalItem>\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} preventTabbing>\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": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8Ca;AA9Cb,oCAAqC;AACrC,kBAAsC;AACtC,IAAAA,eAAuB;AACvB,oBAA2B;AAC3B,oBAA+B;AAC/B,YAAuB;AAEvB,uBAA8B;AAC9B,qBAAiC;AACjC,oBAA0C;AAOnC,MAAM,0BAAsB,qBAAO,8BAA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J;AACF;AAEA,eAAe,cAAc;AAE7B,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": ["import_core"]
|
|
7
7
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,23 +15,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
19
|
var SelectViewport_native_exports = {};
|
|
23
20
|
__export(SelectViewport_native_exports, {
|
|
24
21
|
SelectViewport: () => SelectViewport
|
|
25
22
|
});
|
|
26
23
|
module.exports = __toCommonJS(SelectViewport_native_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
25
|
var import_portal = require("@tamagui/portal");
|
|
28
|
-
var React = __toESM(require("react"));
|
|
29
26
|
var import_constants = require("./constants");
|
|
30
27
|
var import_context = require("./context");
|
|
31
28
|
const SelectViewport = (props) => {
|
|
32
29
|
const { __scopeSelect, children } = props;
|
|
33
30
|
const context = (0, import_context.useSelectContext)(import_constants.VIEWPORT_NAME, __scopeSelect);
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
-
hostName: `${context.scopeKey}SheetContents
|
|
36
|
-
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, {
|
|
32
|
+
hostName: `${context.scopeKey}SheetContents`,
|
|
33
|
+
children
|
|
34
|
+
});
|
|
37
35
|
};
|
|
38
36
|
SelectViewport.displayName = import_constants.VIEWPORT_NAME;
|
|
39
37
|
// 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 { PortalItem } from '@tamagui/portal'\nimport * as React from 'react'\n\nimport { VIEWPORT_NAME } from './constants'\nimport { useSelectContext } from './context'\nimport { ScopedProps, SelectViewportProps } from './types'\n\nexport const SelectViewport = (props: ScopedProps<SelectViewportProps>) => {\n const { __scopeSelect, children } = props\n const context = useSelectContext(VIEWPORT_NAME, __scopeSelect)\n return <PortalItem hostName={`${context.scopeKey}SheetContents`}>{children}</PortalItem>\n}\n\nSelectViewport.displayName = VIEWPORT_NAME\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUS;AAVT,oBAA2B;AAG3B,uBAA8B;AAC9B,qBAAiC;AAG1B,MAAM,iBAAiB,CAAC,UAA4C;AACzE,QAAM,EAAE,eAAe,SAAS,IAAI;AACpC,QAAM,cAAU,iCAAiB,gCAAe,aAAa;AAC7D,SAAO,4CAAC;AAAA,IAAW,UAAU,GAAG,QAAQ;AAAA,IAA0B;AAAA,GAAS;AAC7E;AAEA,eAAe,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
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 { SelectContextValue } from './types'\n\nexport const [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME)\n\nexport const [SelectProvider, useSelectContext] =\n createSelectContext<SelectContextValue>(SELECT_NAME)\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAmC;AAEnC,uBAA4B;AAGrB,MAAM,CAAC,qBAAqB,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAmC;AAEnC,uBAA4B;AAGrB,MAAM,CAAC,qBAAqB,iBAAiB,QAAI,0CAAmB,4BAAW;AAE/E,MAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,4BAAW;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/BubbleSelect.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { usePrevious } from "@radix-ui/react-use-previous";
|
|
2
2
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
const BubbleSelect = React.forwardRef(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
const BubbleSelect = React.forwardRef(
|
|
5
|
+
(props, forwardedRef) => {
|
|
6
|
+
const { value, ...selectProps } = props;
|
|
7
|
+
const ref = React.useRef(null);
|
|
8
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
9
|
+
const prevValue = usePrevious(value);
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
const select = ref.current;
|
|
12
|
+
const selectProto = window.HTMLSelectElement.prototype;
|
|
13
|
+
const descriptor = Object.getOwnPropertyDescriptor(selectProto, "value");
|
|
14
|
+
const setValue = descriptor.set;
|
|
15
|
+
if (prevValue !== value && setValue) {
|
|
16
|
+
const event = new Event("change", { bubbles: true });
|
|
17
|
+
setValue.call(select, value);
|
|
18
|
+
select.dispatchEvent(event);
|
|
19
|
+
}
|
|
20
|
+
}, [prevValue, value]);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
);
|
|
22
24
|
//# sourceMappingURL=BubbleSelect.js.map
|
|
@@ -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<HTMLSelectElement, 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(selectProto, 'value') 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)\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAGvB,MAAM,eAAe,MAAM;AAAA,EACzB,CAAC,OAAO,iBAAiB;AACvB,UAAM,EAAE,UAAU,YAAY,IAAI;AAClC,UAAM,MAAM,MAAM,OAA0B,IAAI;AAChD,UAAM,eAAe,gBAAgB,cAAc,GAAG;AACtD,UAAM,YAAY,YAAY,KAAK;AAGnC,UAAM,UAAU,MAAM;AACpB,YAAM,SAAS,IAAI;AACnB,YAAM,cAAc,OAAO,kBAAkB;AAC7C,YAAM,aAAa,OAAO,yBAAyB,aAAa,OAAO;AACvE,YAAM,WAAW,WAAW;AAC5B,UAAI,cAAc,SAAS,UAAU;AACnC,cAAM,QAAQ,IAAI,MAAM,UAAU,EAAE,SAAS,KAAK,CAAC;AACnD,iBAAS,KAAK,QAAQ,KAAK;AAC3B,eAAO,cAAc,KAAK;AAAA,MAC5B;AAAA,IACF,GAAG,CAAC,WAAW,KAAK,CAAC;AAerB,WAAO;AAAA,EAMT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|