@tamagui/select 1.39.8 → 1.40.0
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/Select.js +10 -193
- package/dist/cjs/Select.js.map +2 -2
- package/dist/cjs/SelectContent.js +8 -2
- package/dist/cjs/SelectContent.js.map +1 -1
- package/dist/cjs/SelectImpl.js +2 -2
- package/dist/cjs/SelectImpl.js.map +1 -1
- package/dist/cjs/SelectItem.js +181 -0
- package/dist/cjs/SelectItem.js.map +6 -0
- package/dist/cjs/SelectTrigger.js +98 -0
- package/dist/cjs/SelectTrigger.js.map +6 -0
- package/dist/cjs/SelectViewport.js +23 -31
- package/dist/cjs/SelectViewport.js.map +2 -2
- package/dist/cjs/useSelectItemContext.js +180 -0
- package/dist/cjs/useSelectItemContext.js.map +6 -0
- package/dist/esm/Select.js +5 -187
- package/dist/esm/Select.js.map +2 -2
- package/dist/esm/SelectContent.js +8 -2
- package/dist/esm/SelectContent.js.map +1 -1
- package/dist/esm/SelectImpl.js +2 -2
- package/dist/esm/SelectImpl.js.map +1 -1
- package/dist/esm/SelectItem.js +149 -0
- package/dist/esm/SelectItem.js.map +6 -0
- package/dist/esm/SelectTrigger.js +64 -0
- package/dist/esm/SelectTrigger.js.map +6 -0
- package/dist/esm/SelectViewport.js +23 -21
- package/dist/esm/SelectViewport.js.map +2 -2
- package/dist/esm/useSelectItemContext.js +146 -0
- package/dist/esm/useSelectItemContext.js.map +6 -0
- package/dist/jsx/Select.js +5 -186
- package/dist/jsx/Select.js.map +2 -2
- package/dist/jsx/Select.mjs +5 -186
- package/dist/jsx/Select.mjs.map +2 -2
- package/dist/jsx/SelectContent.js +4 -2
- package/dist/jsx/SelectContent.js.map +1 -1
- package/dist/jsx/SelectContent.mjs +4 -2
- package/dist/jsx/SelectContent.mjs.map +1 -1
- package/dist/jsx/SelectImpl.js +2 -2
- package/dist/jsx/SelectImpl.js.map +1 -1
- package/dist/jsx/SelectImpl.mjs +2 -2
- package/dist/jsx/SelectImpl.mjs.map +1 -1
- package/dist/jsx/SelectItem.js +140 -0
- package/dist/jsx/SelectItem.js.map +6 -0
- package/dist/jsx/SelectItem.mjs +140 -0
- package/dist/jsx/SelectItem.mjs.map +6 -0
- package/dist/jsx/SelectTrigger.js +58 -0
- package/dist/jsx/SelectTrigger.js.map +6 -0
- package/dist/jsx/SelectTrigger.mjs +58 -0
- package/dist/jsx/SelectTrigger.mjs.map +6 -0
- package/dist/jsx/SelectViewport.js +25 -20
- package/dist/jsx/SelectViewport.js.map +2 -2
- package/dist/jsx/SelectViewport.mjs +25 -20
- package/dist/jsx/SelectViewport.mjs.map +2 -2
- package/dist/jsx/useSelectItemContext.js +137 -0
- package/dist/jsx/useSelectItemContext.js.map +6 -0
- package/dist/jsx/useSelectItemContext.mjs +137 -0
- package/dist/jsx/useSelectItemContext.mjs.map +6 -0
- package/package.json +19 -18
- package/src/Select.tsx +6 -245
- package/src/SelectContent.tsx +10 -10
- package/src/SelectImpl.tsx +2 -2
- package/src/SelectItem.tsx +188 -0
- package/src/SelectTrigger.tsx +74 -0
- package/src/SelectViewport.tsx +40 -32
- package/src/types.tsx +1 -0
- package/types/Select.d.ts +169 -100
- package/types/Select.d.ts.map +1 -1
- package/types/SelectContent.d.ts.map +1 -1
- package/types/SelectItem.d.ts +27 -0
- package/types/SelectItem.d.ts.map +1 -0
- package/types/SelectTrigger.d.ts +87 -0
- package/types/SelectTrigger.d.ts.map +1 -0
- package/types/SelectViewport.d.ts +168 -5
- package/types/SelectViewport.d.ts.map +1 -1
- package/types/types.d.ts +1 -0
- package/types/types.d.ts.map +1 -1
- package/types/useSelectItemContext.d.ts +145 -0
- package/types/useSelectItemContext.d.ts.map +1 -0
|
@@ -0,0 +1,98 @@
|
|
|
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 SelectTrigger_exports = {};
|
|
30
|
+
__export(SelectTrigger_exports, {
|
|
31
|
+
SelectTrigger: () => SelectTrigger
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(SelectTrigger_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
36
|
+
var import_list_item = require("@tamagui/list-item");
|
|
37
|
+
var React = __toESM(require("react"));
|
|
38
|
+
var import_context = require("./context");
|
|
39
|
+
const TRIGGER_NAME = "SelectTrigger";
|
|
40
|
+
const SelectTrigger = React.forwardRef(
|
|
41
|
+
function SelectTrigger2(props, forwardedRef) {
|
|
42
|
+
var _a;
|
|
43
|
+
const { __scopeSelect, disabled = false, unstyled = false, ...triggerProps } = props;
|
|
44
|
+
const context = (0, import_context.useSelectContext)(TRIGGER_NAME, __scopeSelect);
|
|
45
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(
|
|
46
|
+
forwardedRef,
|
|
47
|
+
(_a = context.floatingContext) == null ? void 0 : _a.refs.setReference
|
|
48
|
+
);
|
|
49
|
+
if (context.shouldRenderWebNative) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
53
|
+
import_list_item.ListItem,
|
|
54
|
+
{
|
|
55
|
+
componentName: TRIGGER_NAME,
|
|
56
|
+
unstyled,
|
|
57
|
+
...!unstyled && {
|
|
58
|
+
backgrounded: true,
|
|
59
|
+
radiused: true,
|
|
60
|
+
hoverTheme: true,
|
|
61
|
+
pressTheme: true,
|
|
62
|
+
focusable: true,
|
|
63
|
+
focusStyle: {
|
|
64
|
+
outlineStyle: "solid",
|
|
65
|
+
outlineWidth: 2,
|
|
66
|
+
outlineColor: "$borderColorFocus"
|
|
67
|
+
},
|
|
68
|
+
borderWidth: 1
|
|
69
|
+
},
|
|
70
|
+
size: context.size,
|
|
71
|
+
"aria-expanded": context.open,
|
|
72
|
+
"aria-autocomplete": "none",
|
|
73
|
+
dir: context.dir,
|
|
74
|
+
disabled,
|
|
75
|
+
"data-disabled": disabled ? "" : void 0,
|
|
76
|
+
...triggerProps,
|
|
77
|
+
ref: composedRefs,
|
|
78
|
+
...process.env.TAMAGUI_TARGET === "web" && context.interactions ? {
|
|
79
|
+
...context.interactions.getReferenceProps(),
|
|
80
|
+
onMouseDown() {
|
|
81
|
+
var _a2;
|
|
82
|
+
(_a2 = context.floatingContext) == null ? void 0 : _a2.update();
|
|
83
|
+
context.setOpen(!context.open);
|
|
84
|
+
}
|
|
85
|
+
} : {
|
|
86
|
+
onPress() {
|
|
87
|
+
context.setOpen(!context.open);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
SelectTrigger
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=SelectTrigger.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SelectTrigger.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCM;AAhCN,0BAAgC;AAEhC,uBAAwC;AACxC,YAAuB;AAEvB,qBAAiC;AAMjC,MAAM,eAAe;AAId,MAAM,gBAAgB,MAAM;AAAA,EACjC,SAASA,eAAc,OAAwC,cAAc;AAhB/E;AAiBI,UAAM,EAAE,eAAe,WAAW,OAAO,WAAW,OAAO,GAAG,aAAa,IAAI;AAE/E,UAAM,cAAU,iCAAiB,cAAc,aAAa;AAC5D,UAAM,mBAAe;AAAA,MACnB;AAAA,OACA,aAAQ,oBAAR,mBAAyB,KAAK;AAAA,IAChC;AAIA,QAAI,QAAQ,uBAAuB;AACjC,aAAO;AAAA,IACT;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAe;AAAA,QACf;AAAA,QACC,GAAI,CAAC,YAAY;AAAA,UAChB,cAAc;AAAA,UACd,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,YAAY;AAAA,UACZ,WAAW;AAAA,UACX,YAAY;AAAA,YACV,cAAc;AAAA,YACd,cAAc;AAAA,YACd,cAAc;AAAA,UAChB;AAAA,UACA,aAAa;AAAA,QACf;AAAA,QACA,MAAM,QAAQ;AAAA,QAEd,iBAAe,QAAQ;AAAA,QACvB,qBAAkB;AAAA,QAClB,KAAK,QAAQ;AAAA,QACb;AAAA,QACA,iBAAe,WAAW,KAAK;AAAA,QAC9B,GAAG;AAAA,QACJ,KAAK;AAAA,QACJ,GAAI,QAAQ,IAAI,mBAAmB,SAAS,QAAQ,eACjD;AAAA,UACE,GAAG,QAAQ,aAAa,kBAAkB;AAAA,UAC1C,cAAc;AA5D5B,gBAAAC;AA6DgB,aAAAA,MAAA,QAAQ,oBAAR,gBAAAA,IAAyB;AACzB,oBAAQ,QAAQ,CAAC,QAAQ,IAAI;AAAA,UAC/B;AAAA,QACF,IACA;AAAA,UACE,UAAU;AACR,oBAAQ,QAAQ,CAAC,QAAQ,IAAI;AAAA,UAC/B;AAAA,QACF;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;",
|
|
5
|
+
"names": ["SelectTrigger", "_a"]
|
|
6
|
+
}
|
|
@@ -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,14 +15,6 @@ 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(
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var SelectViewport_exports = {};
|
|
30
20
|
__export(SelectViewport_exports, {
|
|
@@ -34,22 +24,27 @@ __export(SelectViewport_exports, {
|
|
|
34
24
|
module.exports = __toCommonJS(SelectViewport_exports);
|
|
35
25
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
26
|
var import_react = require("@floating-ui/react");
|
|
27
|
+
var import_animate_presence = require("@tamagui/animate-presence");
|
|
37
28
|
var import_core = require("@tamagui/core");
|
|
38
29
|
var import_core2 = require("@tamagui/core");
|
|
39
30
|
var import_portal = require("@tamagui/portal");
|
|
40
31
|
var import_stacks = require("@tamagui/stacks");
|
|
41
|
-
var React = __toESM(require("react"));
|
|
42
32
|
var import_constants = require("./constants");
|
|
43
33
|
var import_context = require("./context");
|
|
44
34
|
var import_useSelectBreakpointActive = require("./useSelectBreakpointActive");
|
|
45
35
|
const SelectViewportFrame = (0, import_core2.styled)(import_stacks.ThemeableStack, {
|
|
46
36
|
name: import_constants.VIEWPORT_NAME,
|
|
47
|
-
backgroundColor: "$background",
|
|
48
|
-
elevate: true,
|
|
49
|
-
bordered: true,
|
|
50
|
-
userSelect: "none",
|
|
51
|
-
outlineWidth: 0,
|
|
52
37
|
variants: {
|
|
38
|
+
unstyled: {
|
|
39
|
+
false: {
|
|
40
|
+
size: "$2",
|
|
41
|
+
backgroundColor: "$background",
|
|
42
|
+
elevate: true,
|
|
43
|
+
bordered: true,
|
|
44
|
+
userSelect: "none",
|
|
45
|
+
outlineWidth: 0
|
|
46
|
+
}
|
|
47
|
+
},
|
|
53
48
|
size: {
|
|
54
49
|
"...size": (val, { tokens }) => {
|
|
55
50
|
return {
|
|
@@ -59,11 +54,11 @@ const SelectViewportFrame = (0, import_core2.styled)(import_stacks.ThemeableStac
|
|
|
59
54
|
}
|
|
60
55
|
},
|
|
61
56
|
defaultVariants: {
|
|
62
|
-
|
|
57
|
+
unstyled: false
|
|
63
58
|
}
|
|
64
59
|
});
|
|
65
|
-
const SelectViewport =
|
|
66
|
-
(props, forwardedRef)
|
|
60
|
+
const SelectViewport = SelectViewportFrame.styleable(
|
|
61
|
+
function SelectViewport2(props, forwardedRef) {
|
|
67
62
|
var _a;
|
|
68
63
|
const { __scopeSelect, children, disableScroll, ...viewportProps } = props;
|
|
69
64
|
const context = (0, import_context.useSelectContext)(import_constants.VIEWPORT_NAME, __scopeSelect);
|
|
@@ -83,18 +78,12 @@ const SelectViewport = React.forwardRef(
|
|
|
83
78
|
if (breakpointActive || !import_core.isWeb) {
|
|
84
79
|
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 }) });
|
|
85
80
|
}
|
|
86
|
-
if (!context.floatingContext) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
if (!context.open) {
|
|
90
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
91
|
-
}
|
|
92
81
|
const {
|
|
93
82
|
style: { scrollbarWidth, listStyleType, overflow, ...restStyle },
|
|
94
83
|
...floatingProps
|
|
95
84
|
} = context.interactions.getFloatingProps();
|
|
96
85
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
97
|
-
!disableScroll && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
|
+
!disableScroll && !props.unstyled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
87
|
"style",
|
|
99
88
|
{
|
|
100
89
|
dangerouslySetInnerHTML: {
|
|
@@ -102,7 +91,7 @@ const SelectViewport = React.forwardRef(
|
|
|
102
91
|
}
|
|
103
92
|
}
|
|
104
93
|
),
|
|
105
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.FloatingFocusManager, { context: context.floatingContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
94
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.FloatingFocusManager, { context: context.floatingContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { children: context.open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
95
|
SelectViewportFrame,
|
|
107
96
|
{
|
|
108
97
|
size: context.size,
|
|
@@ -111,14 +100,17 @@ const SelectViewport = React.forwardRef(
|
|
|
111
100
|
ref: composedRefs,
|
|
112
101
|
...floatingProps,
|
|
113
102
|
...restStyle,
|
|
114
|
-
|
|
103
|
+
...!props.unstyled && {
|
|
104
|
+
overflow: disableScroll ? void 0 : overflow ?? "scroll"
|
|
105
|
+
},
|
|
115
106
|
children
|
|
116
|
-
}
|
|
117
|
-
|
|
107
|
+
},
|
|
108
|
+
"select-viewport"
|
|
109
|
+
) : null }) }),
|
|
110
|
+
!context.open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "none" }, children: props.children })
|
|
118
111
|
] });
|
|
119
112
|
}
|
|
120
113
|
);
|
|
121
|
-
SelectViewport.displayName = import_constants.VIEWPORT_NAME;
|
|
122
114
|
const selectViewportCSS = `
|
|
123
115
|
.is_SelectViewport {
|
|
124
116
|
scrollbar-width: none;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SelectViewport.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": ["import_core"]
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqEa;AArEb,mBAAqC;AACrC,8BAAgC;AAChC,kBAKO;AACP,IAAAA,eAAuB;AACvB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AAG;AAAA,IACL,IAAI,QAAQ,aAAc,iBAAiB;AAE3C,WACE,4EACG;AAAA,OAAC,iBAAiB,CAAC,MAAM,YACxB;AAAA,QAAC;AAAA;AAAA,UACC,yBAAyB;AAAA,YACvB,QAAQ;AAAA,UACV;AAAA;AAAA,MACF;AAAA,MAEF,4CAAC,qCAAqB,SAAS,QAAQ,iBACrC,sDAAC,2CACE,kBAAQ,OACP;AAAA,QAAC;AAAA;AAAA,UAEC,MAAM,QAAQ;AAAA,UAEd,MAAK;AAAA,UACJ,GAAG;AAAA,UACJ,KAAK;AAAA,UACJ,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAI,CAAC,MAAM,YAAY;AAAA,YACtB,UAAU,gBAAgB,SAAY,YAAY;AAAA,UACpD;AAAA,UAEC;AAAA;AAAA,QAZG;AAAA,MAaN,IACE,MACN,GACF;AAAA,MAGC,CAAC,QAAQ,QAAQ,4CAAC,SAAI,OAAO,EAAE,SAAS,OAAO,GAAI,gBAAM,UAAS;AAAA,OACrE;AAAA,EAEJ;AACF;AAEA,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
5
|
+
"names": ["import_core", "SelectViewport"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,180 @@
|
|
|
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 useSelectItemContext_exports = {};
|
|
30
|
+
__export(useSelectItemContext_exports, {
|
|
31
|
+
SelectItem: () => SelectItem
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useSelectItemContext_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
36
|
+
var import_core = require("@tamagui/core");
|
|
37
|
+
var import_list_item = require("@tamagui/list-item");
|
|
38
|
+
var React = __toESM(require("react"));
|
|
39
|
+
var import_context = require("./context");
|
|
40
|
+
const ITEM_NAME = "SelectItem";
|
|
41
|
+
const [SelectItemContextProvider, useSelectItemContext] = (0, import_context.createSelectContext)(ITEM_NAME);
|
|
42
|
+
const SelectItem = import_list_item.ListItem.styleable(
|
|
43
|
+
(props, forwardedRef) => {
|
|
44
|
+
const {
|
|
45
|
+
__scopeSelect,
|
|
46
|
+
value,
|
|
47
|
+
disabled = false,
|
|
48
|
+
textValue: textValueProp,
|
|
49
|
+
index,
|
|
50
|
+
...itemProps
|
|
51
|
+
} = props;
|
|
52
|
+
const context = (0, import_context.useSelectContext)(ITEM_NAME, __scopeSelect);
|
|
53
|
+
const isSelected = context.value === value;
|
|
54
|
+
const textId = React.useId();
|
|
55
|
+
const {
|
|
56
|
+
selectedIndex,
|
|
57
|
+
setSelectedIndex,
|
|
58
|
+
listRef,
|
|
59
|
+
open,
|
|
60
|
+
setOpen,
|
|
61
|
+
onChange,
|
|
62
|
+
activeIndex,
|
|
63
|
+
allowMouseUpRef,
|
|
64
|
+
allowSelectRef,
|
|
65
|
+
setValueAtIndex,
|
|
66
|
+
selectTimeoutRef,
|
|
67
|
+
dataRef
|
|
68
|
+
} = context;
|
|
69
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => {
|
|
70
|
+
if (!import_core.isWeb)
|
|
71
|
+
return;
|
|
72
|
+
if (node instanceof HTMLElement) {
|
|
73
|
+
if (listRef) {
|
|
74
|
+
listRef.current[index] = node;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
79
|
+
setValueAtIndex(index, value);
|
|
80
|
+
}, [index, setValueAtIndex, value]);
|
|
81
|
+
function handleSelect() {
|
|
82
|
+
setSelectedIndex(index);
|
|
83
|
+
onChange(value);
|
|
84
|
+
setOpen(false);
|
|
85
|
+
}
|
|
86
|
+
const selectItemProps = context.interactions ? context.interactions.getItemProps({
|
|
87
|
+
...import_core.isWebTouchable ? {
|
|
88
|
+
onTouchStart() {
|
|
89
|
+
allowSelectRef.current = true;
|
|
90
|
+
allowMouseUpRef.current = false;
|
|
91
|
+
}
|
|
92
|
+
} : {
|
|
93
|
+
onTouchMove() {
|
|
94
|
+
allowSelectRef.current = true;
|
|
95
|
+
allowMouseUpRef.current = false;
|
|
96
|
+
},
|
|
97
|
+
onTouchEnd() {
|
|
98
|
+
allowSelectRef.current = false;
|
|
99
|
+
allowMouseUpRef.current = true;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
onKeyDown(event) {
|
|
103
|
+
if (event.key === "Enter" || event.key === " " && !(dataRef == null ? void 0 : dataRef.current.typing)) {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
handleSelect();
|
|
106
|
+
} else {
|
|
107
|
+
allowSelectRef.current = true;
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
onClick() {
|
|
111
|
+
if (allowSelectRef.current) {
|
|
112
|
+
setSelectedIndex(index);
|
|
113
|
+
setOpen(false);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
onMouseUp() {
|
|
117
|
+
if (!allowMouseUpRef.current) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (allowSelectRef.current) {
|
|
121
|
+
handleSelect();
|
|
122
|
+
}
|
|
123
|
+
clearTimeout(selectTimeoutRef.current);
|
|
124
|
+
selectTimeoutRef.current = setTimeout(() => {
|
|
125
|
+
allowSelectRef.current = true;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}) : {
|
|
129
|
+
onPress: handleSelect
|
|
130
|
+
};
|
|
131
|
+
const isActive = activeIndex === index;
|
|
132
|
+
React.useEffect(() => {
|
|
133
|
+
var _a;
|
|
134
|
+
if (isActive) {
|
|
135
|
+
(_a = listRef == null ? void 0 : listRef.current[index]) == null ? void 0 : _a.focus();
|
|
136
|
+
}
|
|
137
|
+
}, [isActive]);
|
|
138
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
139
|
+
SelectItemContextProvider,
|
|
140
|
+
{
|
|
141
|
+
scope: __scopeSelect,
|
|
142
|
+
value,
|
|
143
|
+
textId: textId || "",
|
|
144
|
+
isSelected,
|
|
145
|
+
children: context.shouldRenderWebNative ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value, children: props.children }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
146
|
+
import_list_item.ListItem,
|
|
147
|
+
{
|
|
148
|
+
tag: "div",
|
|
149
|
+
componentName: ITEM_NAME,
|
|
150
|
+
backgrounded: true,
|
|
151
|
+
pressTheme: true,
|
|
152
|
+
hoverTheme: true,
|
|
153
|
+
focusTheme: true,
|
|
154
|
+
cursor: "default",
|
|
155
|
+
outlineWidth: 0,
|
|
156
|
+
ref: composedRefs,
|
|
157
|
+
"aria-labelledby": textId,
|
|
158
|
+
"aria-selected": isSelected,
|
|
159
|
+
"data-state": isSelected ? "active" : "inactive",
|
|
160
|
+
"aria-disabled": disabled || void 0,
|
|
161
|
+
"data-disabled": disabled ? "" : void 0,
|
|
162
|
+
tabIndex: disabled ? void 0 : -1,
|
|
163
|
+
size: context.size,
|
|
164
|
+
...itemProps,
|
|
165
|
+
...selectItemProps,
|
|
166
|
+
...isActive && {
|
|
167
|
+
theme: "active"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
SelectItem.displayName = ITEM_NAME;
|
|
176
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
+
0 && (module.exports = {
|
|
178
|
+
SelectItem
|
|
179
|
+
});
|
|
180
|
+
//# sourceMappingURL=useSelectItemContext.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useSelectItemContext.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuJU;AAvJV,0BAAgC;AAChC,kBAAiE;AACjE,uBAAwC;AACxC,YAAuB;AAEvB,qBAAsD;AAMtD,MAAM,YAAY;AAMlB,MAAM,CAAC,2BAA2B,oBAAoB,QACpD,oCAA4C,SAAS;AAShD,MAAM,aAAa,0BAAS;AAAA,EACjC,CAAC,OAAqC,iBAAiB;AACrD,UAAM;AAAA,MACJ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
|
+
"names": []
|
|
6
|
+
}
|
package/dist/esm/Select.js
CHANGED
|
@@ -4,7 +4,6 @@ import { useComposedRefs } from "@tamagui/compose-refs";
|
|
|
4
4
|
import {
|
|
5
5
|
getVariableValue,
|
|
6
6
|
isWeb,
|
|
7
|
-
isWebTouchable,
|
|
8
7
|
styled,
|
|
9
8
|
useGet,
|
|
10
9
|
useIsomorphicLayoutEffect,
|
|
@@ -23,67 +22,14 @@ import { SELECT_NAME } from "./constants";
|
|
|
23
22
|
import { SelectProvider, createSelectContext, useSelectContext } from "./context";
|
|
24
23
|
import { SelectContent } from "./SelectContent";
|
|
25
24
|
import { SelectInlineImpl } from "./SelectImpl";
|
|
25
|
+
import { SelectItem, useSelectItemContext } from "./SelectItem";
|
|
26
26
|
import { SelectScrollDownButton, SelectScrollUpButton } from "./SelectScrollButton";
|
|
27
|
+
import { SelectTrigger } from "./SelectTrigger";
|
|
27
28
|
import { SelectViewport } from "./SelectViewport";
|
|
28
29
|
import {
|
|
29
30
|
useSelectBreakpointActive,
|
|
30
31
|
useShowSelectSheet
|
|
31
32
|
} from "./useSelectBreakpointActive";
|
|
32
|
-
const TRIGGER_NAME = "SelectTrigger";
|
|
33
|
-
const SelectTrigger = React.forwardRef(
|
|
34
|
-
function SelectTrigger2(props, forwardedRef) {
|
|
35
|
-
var _a;
|
|
36
|
-
const { __scopeSelect, disabled = false, unstyled = false, ...triggerProps } = props;
|
|
37
|
-
const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
|
|
38
|
-
const composedRefs = useComposedRefs(
|
|
39
|
-
forwardedRef,
|
|
40
|
-
(_a = context.floatingContext) == null ? void 0 : _a.refs.setReference
|
|
41
|
-
);
|
|
42
|
-
if (context.shouldRenderWebNative) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
return /* @__PURE__ */ jsx(
|
|
46
|
-
ListItem,
|
|
47
|
-
{
|
|
48
|
-
componentName: TRIGGER_NAME,
|
|
49
|
-
unstyled,
|
|
50
|
-
...!unstyled && {
|
|
51
|
-
backgrounded: true,
|
|
52
|
-
radiused: true,
|
|
53
|
-
hoverTheme: true,
|
|
54
|
-
pressTheme: true,
|
|
55
|
-
focusable: true,
|
|
56
|
-
focusStyle: {
|
|
57
|
-
outlineStyle: "solid",
|
|
58
|
-
outlineWidth: 2,
|
|
59
|
-
outlineColor: "$borderColorFocus"
|
|
60
|
-
},
|
|
61
|
-
borderWidth: 1
|
|
62
|
-
},
|
|
63
|
-
size: context.size,
|
|
64
|
-
"aria-expanded": context.open,
|
|
65
|
-
"aria-autocomplete": "none",
|
|
66
|
-
dir: context.dir,
|
|
67
|
-
disabled,
|
|
68
|
-
"data-disabled": disabled ? "" : void 0,
|
|
69
|
-
...triggerProps,
|
|
70
|
-
ref: composedRefs,
|
|
71
|
-
...process.env.TAMAGUI_TARGET === "web" && context.interactions ? {
|
|
72
|
-
...context.interactions.getReferenceProps(),
|
|
73
|
-
onMouseDown() {
|
|
74
|
-
var _a2;
|
|
75
|
-
(_a2 = context.floatingContext) == null ? void 0 : _a2.update();
|
|
76
|
-
context.setOpen(!context.open);
|
|
77
|
-
}
|
|
78
|
-
} : {
|
|
79
|
-
onPress() {
|
|
80
|
-
context.setOpen(!context.open);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
33
|
const VALUE_NAME = "SelectValue";
|
|
88
34
|
const SelectValueFrame = styled(SizableText, {
|
|
89
35
|
name: VALUE_NAME,
|
|
@@ -131,133 +77,6 @@ const SelectIcon = styled(XStack, {
|
|
|
131
77
|
"aria-hidden": true,
|
|
132
78
|
children: /* @__PURE__ */ jsx(Paragraph, { children: "\u25BC" })
|
|
133
79
|
});
|
|
134
|
-
const ITEM_NAME = "SelectItem";
|
|
135
|
-
const [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
|
136
|
-
const SelectItem = React.forwardRef(
|
|
137
|
-
(props, forwardedRef) => {
|
|
138
|
-
const {
|
|
139
|
-
__scopeSelect,
|
|
140
|
-
value,
|
|
141
|
-
disabled = false,
|
|
142
|
-
textValue: textValueProp,
|
|
143
|
-
index,
|
|
144
|
-
...itemProps
|
|
145
|
-
} = props;
|
|
146
|
-
const context = useSelectContext(ITEM_NAME, __scopeSelect);
|
|
147
|
-
const isSelected = context.value === value;
|
|
148
|
-
const textId = React.useId();
|
|
149
|
-
const {
|
|
150
|
-
selectedIndex,
|
|
151
|
-
setSelectedIndex,
|
|
152
|
-
listRef,
|
|
153
|
-
open,
|
|
154
|
-
setOpen,
|
|
155
|
-
onChange,
|
|
156
|
-
activeIndex,
|
|
157
|
-
allowMouseUpRef,
|
|
158
|
-
allowSelectRef,
|
|
159
|
-
setValueAtIndex,
|
|
160
|
-
selectTimeoutRef,
|
|
161
|
-
dataRef
|
|
162
|
-
} = context;
|
|
163
|
-
const composedRefs = useComposedRefs(forwardedRef, (node) => {
|
|
164
|
-
if (!isWeb)
|
|
165
|
-
return;
|
|
166
|
-
if (node instanceof HTMLElement) {
|
|
167
|
-
if (listRef) {
|
|
168
|
-
listRef.current[index] = node;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
useIsomorphicLayoutEffect(() => {
|
|
173
|
-
setValueAtIndex(index, value);
|
|
174
|
-
}, [index, setValueAtIndex, value]);
|
|
175
|
-
function handleSelect() {
|
|
176
|
-
setSelectedIndex(index);
|
|
177
|
-
onChange(value);
|
|
178
|
-
setOpen(false);
|
|
179
|
-
}
|
|
180
|
-
const selectItemProps = context.interactions ? context.interactions.getItemProps({
|
|
181
|
-
...isWebTouchable ? {
|
|
182
|
-
onTouchStart() {
|
|
183
|
-
allowSelectRef.current = true;
|
|
184
|
-
allowMouseUpRef.current = false;
|
|
185
|
-
}
|
|
186
|
-
} : {
|
|
187
|
-
onTouchMove() {
|
|
188
|
-
allowSelectRef.current = true;
|
|
189
|
-
allowMouseUpRef.current = false;
|
|
190
|
-
},
|
|
191
|
-
onTouchEnd() {
|
|
192
|
-
allowSelectRef.current = false;
|
|
193
|
-
allowMouseUpRef.current = true;
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
onKeyDown(event) {
|
|
197
|
-
if (event.key === "Enter" || event.key === " " && !(dataRef == null ? void 0 : dataRef.current.typing)) {
|
|
198
|
-
event.preventDefault();
|
|
199
|
-
handleSelect();
|
|
200
|
-
} else {
|
|
201
|
-
allowSelectRef.current = true;
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
onClick() {
|
|
205
|
-
if (allowSelectRef.current) {
|
|
206
|
-
setSelectedIndex(index);
|
|
207
|
-
setOpen(false);
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
onMouseUp() {
|
|
211
|
-
if (!allowMouseUpRef.current) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
if (allowSelectRef.current) {
|
|
215
|
-
handleSelect();
|
|
216
|
-
}
|
|
217
|
-
clearTimeout(selectTimeoutRef.current);
|
|
218
|
-
selectTimeoutRef.current = setTimeout(() => {
|
|
219
|
-
allowSelectRef.current = true;
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
}) : {
|
|
223
|
-
onPress: handleSelect
|
|
224
|
-
};
|
|
225
|
-
const isActive = activeIndex === index;
|
|
226
|
-
return /* @__PURE__ */ jsx(
|
|
227
|
-
SelectItemContextProvider,
|
|
228
|
-
{
|
|
229
|
-
scope: __scopeSelect,
|
|
230
|
-
value,
|
|
231
|
-
textId: textId || "",
|
|
232
|
-
isSelected,
|
|
233
|
-
children: context.shouldRenderWebNative ? /* @__PURE__ */ jsx("option", { value, children: props.children }) : /* @__PURE__ */ jsx(
|
|
234
|
-
ListItem,
|
|
235
|
-
{
|
|
236
|
-
tag: "div",
|
|
237
|
-
componentName: ITEM_NAME,
|
|
238
|
-
backgrounded: true,
|
|
239
|
-
pressTheme: true,
|
|
240
|
-
hoverTheme: true,
|
|
241
|
-
focusTheme: true,
|
|
242
|
-
cursor: "default",
|
|
243
|
-
outlineWidth: 0,
|
|
244
|
-
ref: composedRefs,
|
|
245
|
-
"aria-labelledby": textId,
|
|
246
|
-
"aria-selected": isSelected,
|
|
247
|
-
"data-state": isSelected ? "active" : "inactive",
|
|
248
|
-
"aria-disabled": disabled || void 0,
|
|
249
|
-
"data-disabled": disabled ? "" : void 0,
|
|
250
|
-
tabIndex: disabled ? void 0 : -1,
|
|
251
|
-
size: context.size,
|
|
252
|
-
...itemProps,
|
|
253
|
-
...selectItemProps
|
|
254
|
-
}
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
SelectItem.displayName = ITEM_NAME;
|
|
261
80
|
const ITEM_TEXT_NAME = "SelectItemText";
|
|
262
81
|
const SelectItemTextFrame = styled(SizableText, {
|
|
263
82
|
name: ITEM_TEXT_NAME,
|
|
@@ -300,8 +119,9 @@ const SelectItemText = React.forwardRef(
|
|
|
300
119
|
context.setSelectedItem(contents);
|
|
301
120
|
}
|
|
302
121
|
}, [isSelected, contents]);
|
|
303
|
-
if (context.shouldRenderWebNative)
|
|
122
|
+
if (context.shouldRenderWebNative) {
|
|
304
123
|
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
124
|
+
}
|
|
305
125
|
return /* @__PURE__ */ jsx(Fragment, { children: contents });
|
|
306
126
|
}
|
|
307
127
|
);
|
|
@@ -570,9 +390,7 @@ export {
|
|
|
570
390
|
Select,
|
|
571
391
|
SelectGroupFrame,
|
|
572
392
|
SelectIcon,
|
|
573
|
-
SelectItem,
|
|
574
393
|
SelectItemTextFrame,
|
|
575
|
-
SelectSeparator
|
|
576
|
-
SelectTrigger
|
|
394
|
+
SelectSeparator
|
|
577
395
|
};
|
|
578
396
|
//# sourceMappingURL=Select.js.map
|