@tamagui/select 1.13.3 → 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
package/dist/cjs/BubbleSelect.js
CHANGED
|
@@ -1,48 +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 __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var import_react_use_previous = require("@radix-ui/react-use-previous");
|
|
25
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
26
|
-
var React = __toESM(require("react"));
|
|
27
|
-
const BubbleSelect = React.forwardRef((props, forwardedRef) => {
|
|
28
|
-
const { value, ...selectProps } = props;
|
|
29
|
-
const ref = React.useRef(null);
|
|
30
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
31
|
-
const prevValue = (0, import_react_use_previous.usePrevious)(value);
|
|
32
|
-
React.useEffect(() => {
|
|
33
|
-
const select = ref.current;
|
|
34
|
-
const selectProto = window.HTMLSelectElement.prototype;
|
|
35
|
-
const descriptor = Object.getOwnPropertyDescriptor(
|
|
36
|
-
selectProto,
|
|
37
|
-
"value"
|
|
38
|
-
);
|
|
39
|
-
const setValue = descriptor.set;
|
|
40
|
-
if (prevValue !== value && setValue) {
|
|
41
|
-
const event = new Event("change", { bubbles: true });
|
|
42
|
-
setValue.call(select, value);
|
|
43
|
-
select.dispatchEvent(event);
|
|
44
|
-
}
|
|
45
|
-
}, [prevValue, value]);
|
|
46
|
-
return null;
|
|
47
|
-
});
|
|
1
|
+
"use strict";var d=Object.create;var u=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var P=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of R(t))!E.call(e,s)&&s!==o&&u(e,s,{get:()=>t[s],enumerable:!(r=v(t,s))||r.enumerable});return e};var w=(e,t,o)=>(o=e!=null?d(b(e)):{},P(t||!e||!e.__esModule?u(o,"default",{value:e,enumerable:!0}):o,e));var f=require("@radix-ui/react-use-previous"),a=require("@tamagui/compose-refs"),c=w(require("react"));const H=c.forwardRef((e,t)=>{const{value:o,...r}=e,s=c.useRef(null),S=(0,a.useComposedRefs)(t,s),n=(0,f.usePrevious)(o);return c.useEffect(()=>{const l=s.current,i=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(i,"value").set;if(n!==o&&p){const m=new Event("change",{bubbles:!0});p.call(l,o),l.dispatchEvent(m)}},[n,o]),null});
|
|
48
2
|
//# 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<\n HTMLSelectElement,\n React.ComponentPropsWithoutRef<'select'>\n>((props, forwardedRef) => {\n const { value, ...selectProps } = props\n const ref = React.useRef<HTMLSelectElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref)\n const prevValue = usePrevious(value)\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const select = ref.current!\n const selectProto = window.HTMLSelectElement.prototype\n const descriptor = Object.getOwnPropertyDescriptor(\n selectProto,\n 'value',\n ) as PropertyDescriptor\n const setValue = descriptor.set\n if (prevValue !== value && setValue) {\n const event = new Event('change', { bubbles: true })\n setValue.call(select, value)\n select.dispatchEvent(event)\n }\n }, [prevValue, value])\n\n /**\n * We purposefully use a `select` here to support form autofill as much\n * as possible.\n *\n * We purposefully do not add the `value` attribute here to allow the value\n * to be set programatically and bubble to any parent form `onChange` event.\n * Adding the `value` will cause React to consider the programatic\n * dispatch a duplicate and it will get swallowed.\n *\n * We use `VisuallyHidden` rather than `display: \"none\"` because Safari autofill\n * won't work otherwise.\n */\n // TODO\n return null\n // return (\n // <VisuallyHidden asChild>\n // <select {...selectProps} ref={composedRefs} defaultValue={value} />\n // </VisuallyHidden>\n // )\n})\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "wdAAA,IAAAA,EAA4B,wCAC5BC,EAAgC,iCAChCC,EAAuB,oBAGvB,MAAMC,EAAeD,EAAM,WAGzB,CAACE,EAAOC,IAAiB,CACzB,KAAM,CAAE,MAAAC,EAAO,GAAGC,CAAY,EAAIH,EAC5BI,EAAMN,EAAM,OAA0B,IAAI,EAC1CO,KAAe,mBAAgBJ,EAAcG,CAAG,EAChDE,KAAY,eAAYJ,CAAK,EAGnC,OAAAJ,EAAM,UAAU,IAAM,CACpB,MAAMS,EAASH,EAAI,QACbI,EAAc,OAAO,kBAAkB,UAKvCC,EAJa,OAAO,yBACxBD,EACA,OACF,EAC4B,IAC5B,GAAIF,IAAcJ,GAASO,EAAU,CACnC,MAAMC,EAAQ,IAAI,MAAM,SAAU,CAAE,QAAS,EAAK,CAAC,EACnDD,EAAS,KAAKF,EAAQL,CAAK,EAC3BK,EAAO,cAAcG,CAAK,CAC5B,CACF,EAAG,CAACJ,EAAWJ,CAAK,CAAC,EAed,IAMT,CAAC",
|
|
6
|
+
"names": ["import_react_use_previous", "import_compose_refs", "React", "BubbleSelect", "props", "forwardedRef", "value", "selectProps", "ref", "composedRefs", "prevValue", "select", "selectProto", "setValue", "event"]
|
|
7
7
|
}
|
package/dist/cjs/Select.js
CHANGED
|
@@ -1,495 +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 Select_exports = {};
|
|
30
|
-
__export(Select_exports, {
|
|
31
|
-
Select: () => Select,
|
|
32
|
-
SelectGroupFrame: () => SelectGroupFrame,
|
|
33
|
-
SelectIcon: () => SelectIcon,
|
|
34
|
-
SelectItem: () => SelectItem,
|
|
35
|
-
SelectItemTextFrame: () => SelectItemTextFrame,
|
|
36
|
-
SelectSeparator: () => SelectSeparator,
|
|
37
|
-
SelectTrigger: () => SelectTrigger
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(Select_exports);
|
|
40
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
-
var import_adapt = require("@tamagui/adapt");
|
|
42
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
43
|
-
var import_core = require("@tamagui/core");
|
|
44
|
-
var import_list_item = require("@tamagui/list-item");
|
|
45
|
-
var import_portal = require("@tamagui/portal");
|
|
46
|
-
var import_separator = require("@tamagui/separator");
|
|
47
|
-
var import_sheet = require("@tamagui/sheet");
|
|
48
|
-
var import_stacks = require("@tamagui/stacks");
|
|
49
|
-
var import_text = require("@tamagui/text");
|
|
50
|
-
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
51
|
-
var React = __toESM(require("react"));
|
|
52
|
-
var import_constants = require("./constants");
|
|
53
|
-
var import_context = require("./context");
|
|
54
|
-
var import_SelectContent = require("./SelectContent");
|
|
55
|
-
var import_SelectImpl = require("./SelectImpl");
|
|
56
|
-
var import_SelectScrollButton = require("./SelectScrollButton");
|
|
57
|
-
var import_SelectViewport = require("./SelectViewport");
|
|
58
|
-
var import_useSelectBreakpointActive = require("./useSelectBreakpointActive");
|
|
59
|
-
const TRIGGER_NAME = "SelectTrigger";
|
|
60
|
-
const SelectTrigger = React.forwardRef(
|
|
61
|
-
(props, forwardedRef) => {
|
|
62
|
-
const {
|
|
63
|
-
__scopeSelect,
|
|
64
|
-
disabled = false,
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
"aria-labelledby": ariaLabelledby,
|
|
67
|
-
...triggerProps
|
|
68
|
-
} = props;
|
|
69
|
-
const context = (0, import_context.useSelectContext)(TRIGGER_NAME, __scopeSelect);
|
|
70
|
-
const labelledBy = ariaLabelledby;
|
|
71
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
72
|
-
import_list_item.ListItem,
|
|
73
|
-
{
|
|
74
|
-
componentName: TRIGGER_NAME,
|
|
75
|
-
backgrounded: true,
|
|
76
|
-
radiused: true,
|
|
77
|
-
hoverTheme: true,
|
|
78
|
-
pressTheme: true,
|
|
79
|
-
focusTheme: true,
|
|
80
|
-
focusable: true,
|
|
81
|
-
borderWidth: 1,
|
|
82
|
-
size: context.size,
|
|
83
|
-
"aria-expanded": context.open,
|
|
84
|
-
"aria-autocomplete": "none",
|
|
85
|
-
"aria-labelledby": labelledBy,
|
|
86
|
-
dir: context.dir,
|
|
87
|
-
disabled,
|
|
88
|
-
"data-disabled": disabled ? "" : void 0,
|
|
89
|
-
...triggerProps,
|
|
90
|
-
ref: forwardedRef,
|
|
91
|
-
...process.env.TAMAGUI_TARGET === "web" && context.interactions ? context.interactions.getReferenceProps() : {
|
|
92
|
-
onPress() {
|
|
93
|
-
context.setOpen(!context.open);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
SelectTrigger.displayName = TRIGGER_NAME;
|
|
101
|
-
const VALUE_NAME = "SelectValue";
|
|
102
|
-
const SelectValueFrame = (0, import_core.styled)(import_text.Paragraph, {
|
|
103
|
-
name: VALUE_NAME,
|
|
104
|
-
userSelect: "none"
|
|
105
|
-
});
|
|
106
|
-
const SelectValue = SelectValueFrame.extractable(
|
|
107
|
-
React.forwardRef(
|
|
108
|
-
({
|
|
109
|
-
__scopeSelect,
|
|
110
|
-
children: childrenProp,
|
|
111
|
-
placeholder
|
|
112
|
-
}, forwardedRef) => {
|
|
113
|
-
const context = (0, import_context.useSelectContext)(VALUE_NAME, __scopeSelect);
|
|
114
|
-
const { onValueNodeHasChildrenChange } = context;
|
|
115
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.onValueNodeChange);
|
|
116
|
-
const children = childrenProp ?? context.selectedItem;
|
|
117
|
-
const hasChildren = !!children;
|
|
118
|
-
const isEmptyValue = context.value == null || context.value === "";
|
|
119
|
-
const selectValueChildren = isEmptyValue ? placeholder ?? children : children;
|
|
120
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
121
|
-
onValueNodeHasChildrenChange(hasChildren);
|
|
122
|
-
}, [onValueNodeHasChildrenChange, hasChildren]);
|
|
123
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
124
|
-
SelectValueFrame,
|
|
125
|
-
{
|
|
126
|
-
size: context.size,
|
|
127
|
-
ref: composedRefs,
|
|
128
|
-
pointerEvents: "none",
|
|
129
|
-
children: selectValueChildren
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
)
|
|
134
|
-
);
|
|
135
|
-
SelectValue.displayName = VALUE_NAME;
|
|
136
|
-
const SelectIcon = (0, import_core.styled)(import_stacks.XStack, {
|
|
137
|
-
name: "SelectIcon",
|
|
138
|
-
// @ts-ignore
|
|
139
|
-
"aria-hidden": true,
|
|
140
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.Paragraph, { children: "\u25BC" })
|
|
141
|
-
});
|
|
142
|
-
const ITEM_NAME = "SelectItem";
|
|
143
|
-
const [SelectItemContextProvider, useSelectItemContext] = (0, import_context.createSelectContext)(ITEM_NAME);
|
|
144
|
-
const SelectItem = React.forwardRef(
|
|
145
|
-
(props, forwardedRef) => {
|
|
146
|
-
const {
|
|
147
|
-
__scopeSelect,
|
|
148
|
-
value,
|
|
149
|
-
disabled = false,
|
|
150
|
-
textValue: textValueProp,
|
|
151
|
-
index,
|
|
152
|
-
...itemProps
|
|
153
|
-
} = props;
|
|
154
|
-
const context = (0, import_context.useSelectContext)(ITEM_NAME, __scopeSelect);
|
|
155
|
-
const isSelected = context.value === value;
|
|
156
|
-
const textId = (0, import_core.useId)();
|
|
157
|
-
const {
|
|
158
|
-
selectedIndex,
|
|
159
|
-
setSelectedIndex,
|
|
160
|
-
listRef,
|
|
161
|
-
open,
|
|
162
|
-
setOpen,
|
|
163
|
-
onChange,
|
|
164
|
-
setActiveIndex,
|
|
165
|
-
allowMouseUpRef,
|
|
166
|
-
allowSelectRef,
|
|
167
|
-
setValueAtIndex,
|
|
168
|
-
selectTimeoutRef,
|
|
169
|
-
dataRef
|
|
170
|
-
} = context;
|
|
171
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => {
|
|
172
|
-
if (!import_core.isWeb)
|
|
173
|
-
return;
|
|
174
|
-
if (node instanceof HTMLElement) {
|
|
175
|
-
if (listRef) {
|
|
176
|
-
listRef.current[index] = node;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
React.useEffect(() => {
|
|
181
|
-
setValueAtIndex(index, value);
|
|
182
|
-
}, [index, setValueAtIndex, value]);
|
|
183
|
-
function handleSelect() {
|
|
184
|
-
setSelectedIndex(index);
|
|
185
|
-
onChange(value);
|
|
186
|
-
setOpen(false);
|
|
187
|
-
}
|
|
188
|
-
const selectItemProps = context.interactions ? context.interactions.getItemProps({
|
|
189
|
-
onTouchStart() {
|
|
190
|
-
allowSelectRef.current = true;
|
|
191
|
-
allowMouseUpRef.current = false;
|
|
192
|
-
},
|
|
193
|
-
onKeyDown(event) {
|
|
194
|
-
if (event.key === "Enter" || event.key === " " && !(dataRef == null ? void 0 : dataRef.current.typing)) {
|
|
195
|
-
event.preventDefault();
|
|
196
|
-
handleSelect();
|
|
197
|
-
} else {
|
|
198
|
-
allowSelectRef.current = true;
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
onClick() {
|
|
202
|
-
if (allowSelectRef.current) {
|
|
203
|
-
setSelectedIndex(index);
|
|
204
|
-
setOpen(false);
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
onMouseUp() {
|
|
208
|
-
if (!allowMouseUpRef.current) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
if (allowSelectRef.current) {
|
|
212
|
-
handleSelect();
|
|
213
|
-
}
|
|
214
|
-
clearTimeout(selectTimeoutRef.current);
|
|
215
|
-
selectTimeoutRef.current = setTimeout(() => {
|
|
216
|
-
allowSelectRef.current = true;
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}) : {
|
|
220
|
-
onPress: handleSelect
|
|
221
|
-
};
|
|
222
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
223
|
-
SelectItemContextProvider,
|
|
224
|
-
{
|
|
225
|
-
scope: __scopeSelect,
|
|
226
|
-
value,
|
|
227
|
-
textId: textId || "",
|
|
228
|
-
isSelected,
|
|
229
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
230
|
-
import_list_item.ListItem,
|
|
231
|
-
{
|
|
232
|
-
tag: "div",
|
|
233
|
-
backgrounded: true,
|
|
234
|
-
pressTheme: true,
|
|
235
|
-
hoverTheme: true,
|
|
236
|
-
cursor: "default",
|
|
237
|
-
outlineWidth: 0,
|
|
238
|
-
componentName: ITEM_NAME,
|
|
239
|
-
ref: composedRefs,
|
|
240
|
-
"aria-labelledby": textId,
|
|
241
|
-
"aria-selected": isSelected,
|
|
242
|
-
"data-state": isSelected ? "active" : "inactive",
|
|
243
|
-
"aria-disabled": disabled || void 0,
|
|
244
|
-
"data-disabled": disabled ? "" : void 0,
|
|
245
|
-
tabIndex: disabled ? void 0 : -1,
|
|
246
|
-
size: context.size,
|
|
247
|
-
focusStyle: {
|
|
248
|
-
backgroundColor: "$backgroundHover"
|
|
249
|
-
},
|
|
250
|
-
...itemProps,
|
|
251
|
-
...selectItemProps
|
|
252
|
-
}
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
);
|
|
258
|
-
SelectItem.displayName = ITEM_NAME;
|
|
259
|
-
const ITEM_TEXT_NAME = "SelectItemText";
|
|
260
|
-
const SelectItemTextFrame = (0, import_core.styled)(import_text.SizableText, {
|
|
261
|
-
name: ITEM_TEXT_NAME,
|
|
262
|
-
userSelect: "none"
|
|
263
|
-
});
|
|
264
|
-
const SelectItemText = React.forwardRef(
|
|
265
|
-
(props, forwardedRef) => {
|
|
266
|
-
const { __scopeSelect, className, ...itemTextProps } = props;
|
|
267
|
-
const context = (0, import_context.useSelectContext)(ITEM_TEXT_NAME, __scopeSelect);
|
|
268
|
-
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
269
|
-
const ref = React.useRef(null);
|
|
270
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
271
|
-
const isSelected = Boolean(itemContext.isSelected && context.valueNode);
|
|
272
|
-
const contents = React.useMemo(
|
|
273
|
-
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
274
|
-
SelectItemTextFrame,
|
|
275
|
-
{
|
|
276
|
-
className,
|
|
277
|
-
size: context.size,
|
|
278
|
-
id: itemContext.textId,
|
|
279
|
-
...itemTextProps,
|
|
280
|
-
ref: composedRefs
|
|
281
|
-
}
|
|
282
|
-
),
|
|
283
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
284
|
-
[props, context.size, className, itemContext.textId]
|
|
285
|
-
);
|
|
286
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
287
|
-
if (isSelected) {
|
|
288
|
-
context.setSelectedItem(contents);
|
|
289
|
-
}
|
|
290
|
-
}, [isSelected, contents]);
|
|
291
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: contents });
|
|
292
|
-
}
|
|
293
|
-
);
|
|
294
|
-
SelectItemText.displayName = ITEM_TEXT_NAME;
|
|
295
|
-
const ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
296
|
-
const SelectItemIndicatorFrame = (0, import_core.styled)(import_stacks.XStack, {
|
|
297
|
-
name: ITEM_TEXT_NAME
|
|
298
|
-
});
|
|
299
|
-
const SelectItemIndicator = React.forwardRef(
|
|
300
|
-
(props, forwardedRef) => {
|
|
301
|
-
const { __scopeSelect, ...itemIndicatorProps } = props;
|
|
302
|
-
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
303
|
-
return itemContext.isSelected ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemIndicatorFrame, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
|
|
304
|
-
}
|
|
305
|
-
);
|
|
306
|
-
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
307
|
-
const GROUP_NAME = "SelectGroup";
|
|
308
|
-
const [SelectGroupContextProvider, useSelectGroupContext] = (0, import_context.createSelectContext)(GROUP_NAME);
|
|
309
|
-
const SelectGroupFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
310
|
-
name: GROUP_NAME,
|
|
311
|
-
width: "100%"
|
|
312
|
-
});
|
|
313
|
-
const SelectGroup = React.forwardRef(
|
|
314
|
-
(props, forwardedRef) => {
|
|
315
|
-
const { __scopeSelect, ...groupProps } = props;
|
|
316
|
-
const groupId = (0, import_core.useId)();
|
|
317
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId || "", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
318
|
-
SelectGroupFrame,
|
|
319
|
-
{
|
|
320
|
-
role: "group",
|
|
321
|
-
"aria-labelledby": groupId,
|
|
322
|
-
...groupProps,
|
|
323
|
-
ref: forwardedRef
|
|
324
|
-
}
|
|
325
|
-
) });
|
|
326
|
-
}
|
|
327
|
-
);
|
|
328
|
-
SelectGroup.displayName = GROUP_NAME;
|
|
329
|
-
const LABEL_NAME = "SelectLabel";
|
|
330
|
-
const SelectLabel = React.forwardRef(
|
|
331
|
-
(props, forwardedRef) => {
|
|
332
|
-
const { __scopeSelect, ...labelProps } = props;
|
|
333
|
-
const context = (0, import_context.useSelectContext)(LABEL_NAME, __scopeSelect);
|
|
334
|
-
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
335
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
336
|
-
import_list_item.ListItem,
|
|
337
|
-
{
|
|
338
|
-
tag: "div",
|
|
339
|
-
componentName: LABEL_NAME,
|
|
340
|
-
fontWeight: "800",
|
|
341
|
-
id: groupContext.id,
|
|
342
|
-
size: context.size,
|
|
343
|
-
...labelProps,
|
|
344
|
-
ref: forwardedRef
|
|
345
|
-
}
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
|
-
);
|
|
349
|
-
SelectLabel.displayName = LABEL_NAME;
|
|
350
|
-
const SelectSeparator = (0, import_core.styled)(import_separator.Separator, {
|
|
351
|
-
name: "SelectSeparator"
|
|
352
|
-
});
|
|
353
|
-
const SelectSheetController = (props) => {
|
|
354
|
-
const context = (0, import_context.useSelectContext)("SelectSheetController", props.__scopeSelect);
|
|
355
|
-
const showSheet = (0, import_useSelectBreakpointActive.useShowSelectSheet)(context);
|
|
356
|
-
const breakpointActive = (0, import_useSelectBreakpointActive.useSelectBreakpointActive)(context.sheetBreakpoint);
|
|
357
|
-
const getShowSheet = (0, import_core.useGet)(showSheet);
|
|
358
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
359
|
-
import_sheet.SheetController,
|
|
360
|
-
{
|
|
361
|
-
onOpenChange: (val) => {
|
|
362
|
-
if (getShowSheet()) {
|
|
363
|
-
props.onOpenChange(val);
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
open: context.open,
|
|
367
|
-
hidden: breakpointActive === false,
|
|
368
|
-
children: props.children
|
|
369
|
-
}
|
|
370
|
-
);
|
|
371
|
-
};
|
|
372
|
-
const SelectSheetImpl = (props) => {
|
|
373
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: props.children });
|
|
374
|
-
};
|
|
375
|
-
const Select = (0, import_core.withStaticProperties)(
|
|
376
|
-
(props) => {
|
|
377
|
-
const {
|
|
378
|
-
__scopeSelect,
|
|
379
|
-
children,
|
|
380
|
-
open: openProp,
|
|
381
|
-
defaultOpen,
|
|
382
|
-
onOpenChange,
|
|
383
|
-
value: valueProp,
|
|
384
|
-
defaultValue,
|
|
385
|
-
onValueChange,
|
|
386
|
-
size: sizeProp = "$true",
|
|
387
|
-
dir
|
|
388
|
-
} = props;
|
|
389
|
-
const id = (0, import_core.useId)();
|
|
390
|
-
const scopeKey = __scopeSelect ? Object.keys(__scopeSelect)[0] ?? id : id;
|
|
391
|
-
const { when, AdaptProvider } = (0, import_adapt.useAdaptParent)({
|
|
392
|
-
Contents: React.useCallback(
|
|
393
|
-
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, { name: `${scopeKey}SheetContents` }),
|
|
394
|
-
[scopeKey]
|
|
395
|
-
)
|
|
396
|
-
});
|
|
397
|
-
const sheetBreakpoint = when;
|
|
398
|
-
const isSheet = (0, import_useSelectBreakpointActive.useSelectBreakpointActive)(sheetBreakpoint);
|
|
399
|
-
const SelectImpl = isSheet || !import_core.isWeb ? SelectSheetImpl : import_SelectImpl.SelectInlineImpl;
|
|
400
|
-
const forceUpdate = React.useReducer(() => ({}), {})[1];
|
|
401
|
-
const [selectedItem, setSelectedItem] = React.useState(null);
|
|
402
|
-
const [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
403
|
-
prop: openProp,
|
|
404
|
-
defaultProp: defaultOpen || false,
|
|
405
|
-
onChange: onOpenChange
|
|
406
|
-
});
|
|
407
|
-
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
408
|
-
prop: valueProp,
|
|
409
|
-
defaultProp: defaultValue || "",
|
|
410
|
-
onChange: onValueChange,
|
|
411
|
-
transition: true
|
|
412
|
-
});
|
|
413
|
-
const [activeIndex, setActiveIndex] = React.useState(0);
|
|
414
|
-
const selectedIndexRef = React.useRef(null);
|
|
415
|
-
const activeIndexRef = React.useRef(null);
|
|
416
|
-
const listContentRef = React.useRef([]);
|
|
417
|
-
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
418
|
-
const [valueNode, setValueNode] = React.useState(null);
|
|
419
|
-
const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
|
|
420
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
421
|
-
selectedIndexRef.current = selectedIndex;
|
|
422
|
-
activeIndexRef.current = activeIndex;
|
|
423
|
-
});
|
|
424
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdaptProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
425
|
-
import_context.SelectProvider,
|
|
426
|
-
{
|
|
427
|
-
dir,
|
|
428
|
-
blockSelection: false,
|
|
429
|
-
size: sizeProp,
|
|
430
|
-
fallback: false,
|
|
431
|
-
selectedItem,
|
|
432
|
-
setSelectedItem,
|
|
433
|
-
forceUpdate,
|
|
434
|
-
valueNode,
|
|
435
|
-
onValueNodeChange: setValueNode,
|
|
436
|
-
onValueNodeHasChildrenChange: setValueNodeHasChildren,
|
|
437
|
-
valueNodeHasChildren,
|
|
438
|
-
scopeKey,
|
|
439
|
-
sheetBreakpoint,
|
|
440
|
-
scope: __scopeSelect,
|
|
441
|
-
setValueAtIndex: (index, value2) => {
|
|
442
|
-
listContentRef.current[index] = value2;
|
|
443
|
-
},
|
|
444
|
-
activeIndex,
|
|
445
|
-
onChange: setValue,
|
|
446
|
-
selectedIndex,
|
|
447
|
-
setActiveIndex,
|
|
448
|
-
setOpen,
|
|
449
|
-
setSelectedIndex,
|
|
450
|
-
value,
|
|
451
|
-
open,
|
|
452
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectSheetController, { onOpenChange: setOpen, __scopeSelect, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
453
|
-
SelectImpl,
|
|
454
|
-
{
|
|
455
|
-
activeIndexRef,
|
|
456
|
-
listContentRef,
|
|
457
|
-
selectedIndexRef,
|
|
458
|
-
...props,
|
|
459
|
-
open,
|
|
460
|
-
value,
|
|
461
|
-
children
|
|
462
|
-
}
|
|
463
|
-
) })
|
|
464
|
-
}
|
|
465
|
-
) });
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
Adapt: import_adapt.Adapt,
|
|
469
|
-
Content: import_SelectContent.SelectContent,
|
|
470
|
-
Group: SelectGroup,
|
|
471
|
-
Icon: SelectIcon,
|
|
472
|
-
Item: SelectItem,
|
|
473
|
-
ItemIndicator: SelectItemIndicator,
|
|
474
|
-
ItemText: SelectItemText,
|
|
475
|
-
Label: SelectLabel,
|
|
476
|
-
ScrollDownButton: import_SelectScrollButton.SelectScrollDownButton,
|
|
477
|
-
ScrollUpButton: import_SelectScrollButton.SelectScrollUpButton,
|
|
478
|
-
Trigger: SelectTrigger,
|
|
479
|
-
Value: SelectValue,
|
|
480
|
-
Viewport: import_SelectViewport.SelectViewport,
|
|
481
|
-
Sheet: import_sheet.ControlledSheet
|
|
482
|
-
}
|
|
483
|
-
);
|
|
484
|
-
Select.displayName = import_constants.SELECT_NAME;
|
|
485
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
486
|
-
0 && (module.exports = {
|
|
487
|
-
Select,
|
|
488
|
-
SelectGroupFrame,
|
|
489
|
-
SelectIcon,
|
|
490
|
-
SelectItem,
|
|
491
|
-
SelectItemTextFrame,
|
|
492
|
-
SelectSeparator,
|
|
493
|
-
SelectTrigger
|
|
494
|
-
});
|
|
1
|
+
"use strict";var Re=Object.create;var A=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Ee=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var _e=(e,t)=>{for(var r in t)A(e,r,{get:t[r],enumerable:!0})},Z=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ne(t))!Ve.call(e,o)&&o!==r&&A(e,o,{get:()=>t[o],enumerable:!(n=ye(t,o))||n.enumerable});return e};var Ae=(e,t,r)=>(r=e!=null?Re(Ee(e)):{},Z(t||!e||!e.__esModule?A(r,"default",{value:e,enumerable:!0}):r,e)),Ge=e=>Z(A({},"__esModule",{value:!0}),e);var Fe={};_e(Fe,{Select:()=>he,SelectGroupFrame:()=>Ie,SelectIcon:()=>Se,SelectItem:()=>K,SelectItemTextFrame:()=>fe,SelectSeparator:()=>ze,SelectTrigger:()=>W});module.exports=Ge(Fe);var l=require("react/jsx-runtime"),M=require("@tamagui/adapt"),L=require("@tamagui/compose-refs"),c=require("@tamagui/core"),k=require("@tamagui/list-item"),ae=require("@tamagui/portal"),ie=require("@tamagui/separator"),z=require("@tamagui/sheet"),T=require("@tamagui/stacks"),v=require("@tamagui/text"),D=require("@tamagui/use-controllable-state"),a=Ae(require("react")),pe=require("./constants"),d=require("./context"),de=require("./SelectContent"),ue=require("./SelectImpl"),O=require("./SelectScrollButton"),me=require("./SelectViewport"),R=require("./useSelectBreakpointActive");const F="SelectTrigger",W=a.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,"aria-labelledby":o,...i}=e,s=(0,d.useSelectContext)(F,r),u=o;return(0,l.jsx)(k.ListItem,{componentName:F,backgrounded:!0,radiused:!0,hoverTheme:!0,pressTheme:!0,focusTheme:!0,focusable:!0,borderWidth:1,size:s.size,"aria-expanded":s.open,"aria-autocomplete":"none","aria-labelledby":u,dir:s.dir,disabled:n,"data-disabled":n?"":void 0,...i,ref:t,...process.env.TAMAGUI_TARGET==="web"&&s.interactions?s.interactions.getReferenceProps():{onPress(){s.setOpen(!s.open)}}})});W.displayName=F;const H="SelectValue",ee=(0,c.styled)(v.Paragraph,{name:H,userSelect:"none"}),te=ee.extractable(a.forwardRef(({__scopeSelect:e,children:t,placeholder:r},n)=>{const o=(0,d.useSelectContext)(H,e),{onValueNodeHasChildrenChange:i}=o,s=(0,L.useComposedRefs)(n,o.onValueNodeChange),u=t??o.selectedItem,p=!!u,m=o.value==null||o.value===""?r??u:u;return(0,c.useIsomorphicLayoutEffect)(()=>{i(p)},[i,p]),(0,l.jsx)(ee,{size:o.size,ref:s,pointerEvents:"none",children:m})}));te.displayName=H;const Se=(0,c.styled)(T.XStack,{name:"SelectIcon","aria-hidden":!0,children:(0,l.jsx)(v.Paragraph,{children:"\u25BC"})}),G="SelectItem",[we,oe]=(0,d.createSelectContext)(G),K=a.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:i,index:s,...u}=e,p=(0,d.useSelectContext)(G,r),S=p.value===n,m=(0,c.useId)(),{selectedIndex:B,setSelectedIndex:h,listRef:y,open:$,setOpen:x,onChange:X,setActiveIndex:Y,allowMouseUpRef:N,allowSelectRef:I,setValueAtIndex:E,selectTimeoutRef:g,dataRef:P}=p,V=(0,L.useComposedRefs)(t,f=>{c.isWeb&&f instanceof HTMLElement&&y&&(y.current[s]=f)});a.useEffect(()=>{E(s,n)},[s,E,n]);function C(){h(s),X(n),x(!1)}const _=p.interactions?p.interactions.getItemProps({onTouchStart(){I.current=!0,N.current=!1},onKeyDown(f){f.key==="Enter"||f.key===" "&&!(P!=null&&P.current.typing)?(f.preventDefault(),C()):I.current=!0},onClick(){I.current&&(h(s),x(!1))},onMouseUp(){N.current&&(I.current&&C(),clearTimeout(g.current),g.current=setTimeout(()=>{I.current=!0}))}}):{onPress:C};return(0,l.jsx)(we,{scope:r,value:n,textId:m||"",isSelected:S,children:(0,l.jsx)(k.ListItem,{tag:"div",backgrounded:!0,pressTheme:!0,hoverTheme:!0,cursor:"default",outlineWidth:0,componentName:G,ref:V,"aria-labelledby":m,"aria-selected":S,"data-state":S?"active":"inactive","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,size:p.size,focusStyle:{backgroundColor:"$backgroundHover"},...u,..._})})});K.displayName=G;const b="SelectItemText",fe=(0,c.styled)(v.SizableText,{name:b,userSelect:"none"}),re=a.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,...o}=e,i=(0,d.useSelectContext)(b,r),s=oe(b,r),u=a.useRef(null),p=(0,L.useComposedRefs)(t,u),S=Boolean(s.isSelected&&i.valueNode),m=a.useMemo(()=>(0,l.jsx)(fe,{className:n,size:i.size,id:s.textId,...o,ref:p}),[e,i.size,n,s.textId]);return(0,c.useIsomorphicLayoutEffect)(()=>{S&&i.setSelectedItem(m)},[S,m]),(0,l.jsx)(l.Fragment,{children:m})});re.displayName=b;const ne="SelectItemIndicator",Le=(0,c.styled)(T.XStack,{name:b}),le=a.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return oe(ne,r).isSelected?(0,l.jsx)(Le,{"aria-hidden":!0,...n,ref:t}):null});le.displayName=ne;const U="SelectGroup",[ke,Me]=(0,d.createSelectContext)(U),Ie=(0,c.styled)(T.YStack,{name:U,width:"100%"}),ce=a.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=(0,c.useId)();return(0,l.jsx)(ke,{scope:r,id:o||"",children:(0,l.jsx)(Ie,{role:"group","aria-labelledby":o,...n,ref:t})})});ce.displayName=U;const w="SelectLabel",se=a.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=(0,d.useSelectContext)(w,r),i=Me(w,r);return(0,l.jsx)(k.ListItem,{tag:"div",componentName:w,fontWeight:"800",id:i.id,size:o.size,...n,ref:t})});se.displayName=w;const ze=(0,c.styled)(ie.Separator,{name:"SelectSeparator"}),Oe=e=>{const t=(0,d.useSelectContext)("SelectSheetController",e.__scopeSelect),r=(0,R.useShowSelectSheet)(t),n=(0,R.useSelectBreakpointActive)(t.sheetBreakpoint),o=(0,c.useGet)(r);return(0,l.jsx)(z.SheetController,{onOpenChange:i=>{o()&&e.onOpenChange(i)},open:t.open,hidden:n===!1,children:e.children})},Be=e=>(0,l.jsx)(l.Fragment,{children:e.children}),he=(0,c.withStaticProperties)(e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:i,value:s,defaultValue:u,onValueChange:p,size:S="$true",dir:m}=e,B=(0,c.useId)(),h=t?Object.keys(t)[0]??B:B,{when:y,AdaptProvider:$}=(0,M.useAdaptParent)({Contents:a.useCallback(()=>(0,l.jsx)(ae.PortalHost,{name:`${h}SheetContents`}),[h])}),x=y,Y=(0,R.useSelectBreakpointActive)(x)||!c.isWeb?Be:ue.SelectInlineImpl,N=a.useReducer(()=>({}),{})[1],[I,E]=a.useState(null),[g,P]=(0,D.useControllableState)({prop:n,defaultProp:o||!1,onChange:i}),[V,C]=(0,D.useControllableState)({prop:s,defaultProp:u||"",onChange:p,transition:!0}),[_,f]=a.useState(0),j=a.useRef(null),q=a.useRef(null),J=a.useRef([]),[Q,Pe]=a.useState(0),[xe,ge]=a.useState(null),[Ce,be]=a.useState(!1);return(0,c.useIsomorphicLayoutEffect)(()=>{j.current=Q,q.current=_}),(0,l.jsx)($,{children:(0,l.jsx)(d.SelectProvider,{dir:m,blockSelection:!1,size:S,fallback:!1,selectedItem:I,setSelectedItem:E,forceUpdate:N,valueNode:xe,onValueNodeChange:ge,onValueNodeHasChildrenChange:be,valueNodeHasChildren:Ce,scopeKey:h,sheetBreakpoint:x,scope:t,setValueAtIndex:(Te,ve)=>{J.current[Te]=ve},activeIndex:_,onChange:C,selectedIndex:Q,setActiveIndex:f,setOpen:P,setSelectedIndex:Pe,value:V,open:g,children:(0,l.jsx)(Oe,{onOpenChange:P,__scopeSelect:t,children:(0,l.jsx)(Y,{activeIndexRef:q,listContentRef:J,selectedIndexRef:j,...e,open:g,value:V,children:r})})})})},{Adapt:M.Adapt,Content:de.SelectContent,Group:ce,Icon:Se,Item:K,ItemIndicator:le,ItemText:re,Label:se,ScrollDownButton:O.SelectScrollDownButton,ScrollUpButton:O.SelectScrollUpButton,Trigger:W,Value:te,Viewport:me.SelectViewport,Sheet:z.ControlledSheet});he.displayName=pe.SELECT_NAME;0&&(module.exports={Select,SelectGroupFrame,SelectIcon,SelectItem,SelectItemTextFrame,SelectSeparator,SelectTrigger});
|
|
495
2
|
//# sourceMappingURL=Select.js.map
|