@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
1
2
|
import { FloatingFocusManager } from "@floating-ui/react-dom-interactions";
|
|
2
3
|
import { isWeb } from "@tamagui/core";
|
|
3
4
|
import { styled } from "@tamagui/core";
|
|
@@ -27,41 +28,51 @@ const SelectViewportFrame = styled(ThemeableStack, {
|
|
|
27
28
|
size: "$2"
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
|
-
const SelectViewport = React.forwardRef(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
if (!context.open) {
|
|
43
|
-
return children;
|
|
44
|
-
}
|
|
45
|
-
const {
|
|
46
|
-
style: { scrollbarWidth, listStyleType, ...restStyle },
|
|
47
|
-
...floatingProps
|
|
48
|
-
} = context.interactions.getFloatingProps();
|
|
49
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("style", {
|
|
50
|
-
dangerouslySetInnerHTML: {
|
|
51
|
-
__html: selectViewportCSS
|
|
31
|
+
const SelectViewport = React.forwardRef(
|
|
32
|
+
(props, forwardedRef) => {
|
|
33
|
+
const { __scopeSelect, children, ...viewportProps } = props;
|
|
34
|
+
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
35
|
+
const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
|
|
36
|
+
if (breakpointActive || !isWeb) {
|
|
37
|
+
return /* @__PURE__ */ jsx(PortalItem, {
|
|
38
|
+
hostName: `${context.scopeKey}SheetContents`,
|
|
39
|
+
children
|
|
40
|
+
});
|
|
52
41
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
if (!context.floatingContext) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (!context.open) {
|
|
46
|
+
return children;
|
|
47
|
+
}
|
|
48
|
+
const {
|
|
49
|
+
style: { scrollbarWidth, listStyleType, ...restStyle },
|
|
50
|
+
...floatingProps
|
|
51
|
+
} = context.interactions.getFloatingProps();
|
|
52
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx("style", {
|
|
55
|
+
dangerouslySetInnerHTML: {
|
|
56
|
+
__html: selectViewportCSS
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ jsx(FloatingFocusManager, {
|
|
60
|
+
context: context.floatingContext,
|
|
61
|
+
preventTabbing: true,
|
|
62
|
+
children: /* @__PURE__ */ jsx(SelectViewportFrame, {
|
|
63
|
+
size: context.size,
|
|
64
|
+
role: "presentation",
|
|
65
|
+
...viewportProps,
|
|
66
|
+
ref: forwardedRef,
|
|
67
|
+
...floatingProps,
|
|
68
|
+
...restStyle,
|
|
69
|
+
children
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
);
|
|
65
76
|
SelectViewport.displayName = VIEWPORT_NAME;
|
|
66
77
|
const selectViewportCSS = `
|
|
67
78
|
.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": "
|
|
5
|
+
"mappings": "AA8Ca,SAiBP,UAjBO,KAiBP,YAjBO;AA9Cb,SAAS,4BAA4B;AACrC,SAAyB,aAAa;AACtC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,iCAAiC;AAOnC,MAAM,sBAAsB,OAAO,gBAAgB;AAAA,EACxD,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EAEZ,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,KAAK,EAAE,OAAO,MAAM;AAC9B,eAAO;AAAA,UACL,cAAc,OAAO,OAAO,QAAQ;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,aAAa,cAAc,IAAI;AACtD,UAAM,UAAU,iBAAiB,eAAe,aAAa;AAC7D,UAAM,mBAAmB,0BAA0B,QAAQ,eAAe;AAE1E,QAAI,oBAAoB,CAAC,OAAO;AAC9B,aAAO,oBAAC;AAAA,QAAW,UAAU,GAAG,QAAQ;AAAA,QAA0B;AAAA,OAAS;AAAA,IAC7E;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,kBAAkB,UAAU;AAAA,SAClD;AAAA,IACL,IAAI,QAAQ,aAAc,iBAAiB;AAE3C,WACE;AAAA,MACE;AAAA,4BAAC;AAAA,UACC,yBAAyB;AAAA,YACvB,QAAQ;AAAA,UACV;AAAA,SACF;AAAA,QACA,oBAAC;AAAA,UAAqB,SAAS,QAAQ;AAAA,UAAiB,gBAAc;AAAA,UACpE,8BAAC;AAAA,YACC,MAAM,QAAQ;AAAA,YAEd,MAAK;AAAA,YACJ,GAAG;AAAA,YACJ,KAAK;AAAA,YACJ,GAAG;AAAA,YACH,GAAG;AAAA,YAEH;AAAA,WACH;AAAA,SACF;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAE7B,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import { PortalItem } from "@tamagui/portal";
|
|
2
|
-
import * as React from "react";
|
|
3
3
|
import { VIEWPORT_NAME } from "./constants";
|
|
4
4
|
import { useSelectContext } from "./context";
|
|
5
5
|
const SelectViewport = (props) => {
|
|
6
6
|
const { __scopeSelect, children } = props;
|
|
7
7
|
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
8
|
-
return /* @__PURE__ */
|
|
9
|
-
hostName: `${context.scopeKey}SheetContents
|
|
10
|
-
|
|
8
|
+
return /* @__PURE__ */ jsx(PortalItem, {
|
|
9
|
+
hostName: `${context.scopeKey}SheetContents`,
|
|
10
|
+
children
|
|
11
|
+
});
|
|
11
12
|
};
|
|
12
13
|
SelectViewport.displayName = VIEWPORT_NAME;
|
|
13
14
|
export {
|
|
@@ -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": "AAUS;AAVT,SAAS,kBAAkB;AAG3B,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AAG1B,MAAM,iBAAiB,CAAC,UAA4C;AACzE,QAAM,EAAE,eAAe,SAAS,IAAI;AACpC,QAAM,UAAU,iBAAiB,eAAe,aAAa;AAC7D,SAAO,oBAAC;AAAA,IAAW,UAAU,GAAG,QAAQ;AAAA,IAA0B;AAAA,GAAS;AAC7E;AAEA,eAAe,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/context.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/context.tsx"],
|
|
4
4
|
"sourcesContent": ["import { createContextScope } from '@tamagui/create-context'\n\nimport { SELECT_NAME } from './constants'\nimport { 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;
|
|
5
|
+
"mappings": "AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAGrB,MAAM,CAAC,qBAAqB,iBAAiB,IAAI,mBAAmB,WAAW;AAE/E,MAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,WAAW;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["export * from './Select'\nexport type {\n SelectContentProps,\n SelectProps,\n SelectScrollButtonProps,\n SelectViewportProps,\n} from './types'\nexport * from './context'\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,cAAc;AAOd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/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
|
}
|