@tamagui/select 1.0.1-beta.151 → 1.0.1-beta.154
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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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/dist/cjs/Select.js
CHANGED
|
@@ -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 Select_exports = {};
|
|
23
26
|
__export(Select_exports, {
|
|
@@ -33,6 +36,7 @@ __export(Select_exports, {
|
|
|
33
36
|
useShowSelectSheet: () => useShowSelectSheet
|
|
34
37
|
});
|
|
35
38
|
module.exports = __toCommonJS(Select_exports);
|
|
39
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
40
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
37
41
|
var import_core = require("@tamagui/core");
|
|
38
42
|
var import_core2 = require("@tamagui/core");
|
|
@@ -53,211 +57,232 @@ var import_SelectImpl = require("./SelectImpl");
|
|
|
53
57
|
var import_SelectScrollButton = require("./SelectScrollButton");
|
|
54
58
|
var import_SelectViewport = require("./SelectViewport");
|
|
55
59
|
const TRIGGER_NAME = "SelectTrigger";
|
|
56
|
-
const SelectTrigger = React.forwardRef(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
60
|
+
const SelectTrigger = React.forwardRef(
|
|
61
|
+
(props, forwardedRef) => {
|
|
62
|
+
const {
|
|
63
|
+
__scopeSelect,
|
|
64
|
+
disabled = false,
|
|
65
|
+
"aria-labelledby": ariaLabelledby,
|
|
66
|
+
...triggerProps
|
|
67
|
+
} = props;
|
|
68
|
+
const context = (0, import_context.useSelectContext)(TRIGGER_NAME, __scopeSelect);
|
|
69
|
+
const labelledBy = ariaLabelledby;
|
|
70
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_list_item.ListItem, {
|
|
71
|
+
componentName: TRIGGER_NAME,
|
|
72
|
+
backgrounded: true,
|
|
73
|
+
radiused: true,
|
|
74
|
+
hoverTheme: true,
|
|
75
|
+
pressTheme: true,
|
|
76
|
+
focusTheme: true,
|
|
77
|
+
focusable: true,
|
|
78
|
+
borderWidth: 1,
|
|
79
|
+
size: context.size,
|
|
80
|
+
"aria-expanded": context.open,
|
|
81
|
+
"aria-autocomplete": "none",
|
|
82
|
+
"aria-labelledby": labelledBy,
|
|
83
|
+
dir: context.dir,
|
|
84
|
+
disabled,
|
|
85
|
+
"data-disabled": disabled ? "" : void 0,
|
|
86
|
+
...triggerProps,
|
|
87
|
+
ref: forwardedRef,
|
|
88
|
+
...process.env.TAMAGUI_TARGET === "web" && context.interactions ? context.interactions.getReferenceProps() : {
|
|
89
|
+
onPress() {
|
|
90
|
+
context.setOpen(!context.open);
|
|
91
|
+
}
|
|
86
92
|
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
);
|
|
90
96
|
SelectTrigger.displayName = TRIGGER_NAME;
|
|
91
97
|
const VALUE_NAME = "SelectValue";
|
|
92
98
|
const SelectValueFrame = (0, import_core2.styled)(import_text.Paragraph, {
|
|
93
99
|
name: VALUE_NAME,
|
|
94
100
|
selectable: false
|
|
95
101
|
});
|
|
96
|
-
const SelectValue = SelectValueFrame.extractable(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
const SelectValue = SelectValueFrame.extractable(
|
|
103
|
+
React.forwardRef(
|
|
104
|
+
({ __scopeSelect, children: childrenProp, placeholder }, forwardedRef) => {
|
|
105
|
+
const context = (0, import_context.useSelectContext)(VALUE_NAME, __scopeSelect);
|
|
106
|
+
const { onValueNodeHasChildrenChange } = context;
|
|
107
|
+
const hasChildren = childrenProp !== void 0;
|
|
108
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.onValueNodeChange);
|
|
109
|
+
(0, import_core2.useIsomorphicLayoutEffect)(() => {
|
|
110
|
+
onValueNodeHasChildrenChange(hasChildren);
|
|
111
|
+
}, [onValueNodeHasChildrenChange, hasChildren]);
|
|
112
|
+
const children = childrenProp ?? context.selectedItem;
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValueFrame, {
|
|
114
|
+
size: context.size,
|
|
115
|
+
ref: composedRefs,
|
|
116
|
+
pointerEvents: "none",
|
|
117
|
+
children: context.value === void 0 && placeholder !== void 0 ? placeholder : children
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
);
|
|
111
122
|
SelectValue.displayName = VALUE_NAME;
|
|
112
123
|
const SelectIcon = (0, import_core2.styled)(import_stacks.XStack, {
|
|
113
124
|
name: "SelectIcon",
|
|
114
125
|
"aria-hidden": true,
|
|
115
|
-
children: /* @__PURE__ */
|
|
126
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.Paragraph, {
|
|
127
|
+
children: "\u25BC"
|
|
128
|
+
})
|
|
116
129
|
});
|
|
117
130
|
const ITEM_NAME = "SelectItem";
|
|
118
131
|
const [SelectItemContextProvider, useSelectItemContext] = (0, import_context.createSelectContext)(ITEM_NAME);
|
|
119
|
-
const SelectItem = React.forwardRef(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
listRef
|
|
132
|
+
const SelectItem = React.forwardRef(
|
|
133
|
+
(props, forwardedRef) => {
|
|
134
|
+
const {
|
|
135
|
+
__scopeSelect,
|
|
136
|
+
value,
|
|
137
|
+
disabled = false,
|
|
138
|
+
textValue: textValueProp,
|
|
139
|
+
index,
|
|
140
|
+
...itemProps
|
|
141
|
+
} = props;
|
|
142
|
+
const context = (0, import_context.useSelectContext)(ITEM_NAME, __scopeSelect);
|
|
143
|
+
const isSelected = context.value === value;
|
|
144
|
+
const textId = (0, import_core3.useId)();
|
|
145
|
+
const {
|
|
146
|
+
selectedIndex,
|
|
147
|
+
setSelectedIndex,
|
|
148
|
+
listRef,
|
|
149
|
+
open,
|
|
150
|
+
setOpen,
|
|
151
|
+
onChange,
|
|
152
|
+
setActiveIndex,
|
|
153
|
+
allowMouseUpRef,
|
|
154
|
+
allowSelectRef,
|
|
155
|
+
setValueAtIndex,
|
|
156
|
+
selectTimeoutRef,
|
|
157
|
+
dataRef
|
|
158
|
+
} = context;
|
|
159
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => {
|
|
160
|
+
if (!import_core.isWeb)
|
|
161
|
+
return;
|
|
162
|
+
if (node instanceof HTMLElement) {
|
|
163
|
+
if (listRef) {
|
|
164
|
+
listRef.current[index] = node;
|
|
165
|
+
}
|
|
151
166
|
}
|
|
167
|
+
});
|
|
168
|
+
React.useEffect(() => {
|
|
169
|
+
setValueAtIndex(index, value);
|
|
170
|
+
}, [index, setValueAtIndex, value]);
|
|
171
|
+
function handleSelect() {
|
|
172
|
+
setSelectedIndex(index);
|
|
173
|
+
onChange(value);
|
|
174
|
+
setOpen(false);
|
|
152
175
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
setValueAtIndex(index, value);
|
|
156
|
-
}, [index, setValueAtIndex, value]);
|
|
157
|
-
function handleSelect() {
|
|
158
|
-
setSelectedIndex(index);
|
|
159
|
-
onChange(value);
|
|
160
|
-
setOpen(false);
|
|
161
|
-
}
|
|
162
|
-
const selectItemProps = context.interactions ? context.interactions.getItemProps({
|
|
163
|
-
onTouchStart() {
|
|
164
|
-
allowSelectRef.current = true;
|
|
165
|
-
allowMouseUpRef.current = false;
|
|
166
|
-
},
|
|
167
|
-
onKeyDown(event) {
|
|
168
|
-
if (event.key === "Enter" || event.key === " " && !(dataRef == null ? void 0 : dataRef.current.typing)) {
|
|
169
|
-
event.preventDefault();
|
|
170
|
-
handleSelect();
|
|
171
|
-
} else {
|
|
176
|
+
const selectItemProps = context.interactions ? context.interactions.getItemProps({
|
|
177
|
+
onTouchStart() {
|
|
172
178
|
allowSelectRef.current = true;
|
|
179
|
+
allowMouseUpRef.current = false;
|
|
180
|
+
},
|
|
181
|
+
onKeyDown(event) {
|
|
182
|
+
if (event.key === "Enter" || event.key === " " && !(dataRef == null ? void 0 : dataRef.current.typing)) {
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
handleSelect();
|
|
185
|
+
} else {
|
|
186
|
+
allowSelectRef.current = true;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
onClick() {
|
|
190
|
+
if (allowSelectRef.current) {
|
|
191
|
+
setSelectedIndex(index);
|
|
192
|
+
setOpen(false);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
onMouseUp() {
|
|
196
|
+
if (!allowMouseUpRef.current) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (allowSelectRef.current) {
|
|
200
|
+
handleSelect();
|
|
201
|
+
}
|
|
202
|
+
clearTimeout(selectTimeoutRef.current);
|
|
203
|
+
selectTimeoutRef.current = setTimeout(() => {
|
|
204
|
+
allowSelectRef.current = true;
|
|
205
|
+
});
|
|
173
206
|
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}, /* @__PURE__ */ React.createElement(import_list_item.ListItem, {
|
|
202
|
-
backgrounded: true,
|
|
203
|
-
pressTheme: true,
|
|
204
|
-
focusTheme: true,
|
|
205
|
-
componentName: ITEM_NAME,
|
|
206
|
-
ref: composedRefs,
|
|
207
|
-
"aria-labelledby": textId,
|
|
208
|
-
"aria-selected": isSelected,
|
|
209
|
-
"data-state": isSelected ? "active" : "inactive",
|
|
210
|
-
"aria-disabled": disabled || void 0,
|
|
211
|
-
"data-disabled": disabled ? "" : void 0,
|
|
212
|
-
tabIndex: disabled ? void 0 : -1,
|
|
213
|
-
size: context.size,
|
|
214
|
-
...itemProps,
|
|
215
|
-
...selectItemProps
|
|
216
|
-
}));
|
|
217
|
-
});
|
|
207
|
+
}) : {
|
|
208
|
+
onPress: handleSelect
|
|
209
|
+
};
|
|
210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemContextProvider, {
|
|
211
|
+
scope: __scopeSelect,
|
|
212
|
+
value,
|
|
213
|
+
textId: textId || "",
|
|
214
|
+
isSelected,
|
|
215
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_list_item.ListItem, {
|
|
216
|
+
backgrounded: true,
|
|
217
|
+
pressTheme: true,
|
|
218
|
+
focusTheme: true,
|
|
219
|
+
componentName: ITEM_NAME,
|
|
220
|
+
ref: composedRefs,
|
|
221
|
+
"aria-labelledby": textId,
|
|
222
|
+
"aria-selected": isSelected,
|
|
223
|
+
"data-state": isSelected ? "active" : "inactive",
|
|
224
|
+
"aria-disabled": disabled || void 0,
|
|
225
|
+
"data-disabled": disabled ? "" : void 0,
|
|
226
|
+
tabIndex: disabled ? void 0 : -1,
|
|
227
|
+
size: context.size,
|
|
228
|
+
...itemProps,
|
|
229
|
+
...selectItemProps
|
|
230
|
+
})
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
);
|
|
218
234
|
SelectItem.displayName = ITEM_NAME;
|
|
219
235
|
const ITEM_TEXT_NAME = "SelectItemText";
|
|
220
236
|
const SelectItemTextFrame = (0, import_core2.styled)(import_text.Paragraph, {
|
|
221
237
|
name: ITEM_TEXT_NAME,
|
|
222
238
|
selectable: false
|
|
223
239
|
});
|
|
224
|
-
const SelectItemText = React.forwardRef(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
const SelectItemText = React.forwardRef(
|
|
241
|
+
(props, forwardedRef) => {
|
|
242
|
+
const { __scopeSelect, className, ...itemTextProps } = props;
|
|
243
|
+
const context = (0, import_context.useSelectContext)(ITEM_TEXT_NAME, __scopeSelect);
|
|
244
|
+
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
245
|
+
const ref = React.useRef(null);
|
|
246
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
247
|
+
const isSelected = itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren;
|
|
248
|
+
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemTextFrame, {
|
|
249
|
+
className,
|
|
250
|
+
size: context.size,
|
|
251
|
+
id: itemContext.textId,
|
|
252
|
+
...itemTextProps,
|
|
253
|
+
ref: composedRefs
|
|
254
|
+
});
|
|
255
|
+
if (!import_core.isWeb) {
|
|
256
|
+
React.useEffect(() => {
|
|
257
|
+
if (isSelected) {
|
|
258
|
+
context.setSelectedItem(contents);
|
|
259
|
+
}
|
|
260
|
+
}, [isSelected]);
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
263
|
+
children: [
|
|
264
|
+
contents,
|
|
265
|
+
import_core.isWeb && isSelected ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null
|
|
266
|
+
]
|
|
267
|
+
});
|
|
244
268
|
}
|
|
245
|
-
|
|
246
|
-
});
|
|
269
|
+
);
|
|
247
270
|
SelectItemText.displayName = ITEM_TEXT_NAME;
|
|
248
271
|
const ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
249
272
|
const SelectItemIndicatorFrame = (0, import_core2.styled)(import_stacks.XStack, {
|
|
250
273
|
name: ITEM_TEXT_NAME
|
|
251
274
|
});
|
|
252
|
-
const SelectItemIndicator = React.forwardRef(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
275
|
+
const SelectItemIndicator = React.forwardRef(
|
|
276
|
+
(props, forwardedRef) => {
|
|
277
|
+
const { __scopeSelect, ...itemIndicatorProps } = props;
|
|
278
|
+
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
279
|
+
return itemContext.isSelected ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemIndicatorFrame, {
|
|
280
|
+
"aria-hidden": true,
|
|
281
|
+
...itemIndicatorProps,
|
|
282
|
+
ref: forwardedRef
|
|
283
|
+
}) : null;
|
|
284
|
+
}
|
|
285
|
+
);
|
|
261
286
|
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
262
287
|
const GROUP_NAME = "SelectGroup";
|
|
263
288
|
const [SelectGroupContextProvider, useSelectGroupContext] = (0, import_context.createSelectContext)(GROUP_NAME);
|
|
@@ -265,34 +290,39 @@ const SelectGroupFrame = (0, import_core2.styled)(import_stacks.YStack, {
|
|
|
265
290
|
name: GROUP_NAME,
|
|
266
291
|
width: "100%"
|
|
267
292
|
});
|
|
268
|
-
const SelectGroup = React.forwardRef(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
})
|
|
293
|
+
const SelectGroup = React.forwardRef(
|
|
294
|
+
(props, forwardedRef) => {
|
|
295
|
+
const { __scopeSelect, ...groupProps } = props;
|
|
296
|
+
const groupId = (0, import_core3.useId)();
|
|
297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectGroupContextProvider, {
|
|
298
|
+
scope: __scopeSelect,
|
|
299
|
+
id: groupId || "",
|
|
300
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectGroupFrame, {
|
|
301
|
+
role: "group",
|
|
302
|
+
"aria-labelledby": groupId,
|
|
303
|
+
...groupProps,
|
|
304
|
+
ref: forwardedRef
|
|
305
|
+
})
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
);
|
|
281
309
|
SelectGroup.displayName = GROUP_NAME;
|
|
282
310
|
const LABEL_NAME = "SelectLabel";
|
|
283
|
-
const SelectLabel = React.forwardRef(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
});
|
|
311
|
+
const SelectLabel = React.forwardRef(
|
|
312
|
+
(props, forwardedRef) => {
|
|
313
|
+
const { __scopeSelect, ...labelProps } = props;
|
|
314
|
+
const context = (0, import_context.useSelectContext)(LABEL_NAME, __scopeSelect);
|
|
315
|
+
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
316
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_list_item.ListItem, {
|
|
317
|
+
componentName: LABEL_NAME,
|
|
318
|
+
fontWeight: "800",
|
|
319
|
+
id: groupContext.id,
|
|
320
|
+
size: context.size,
|
|
321
|
+
...labelProps,
|
|
322
|
+
ref: forwardedRef
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
);
|
|
296
326
|
SelectLabel.displayName = LABEL_NAME;
|
|
297
327
|
const SelectSeparator = (0, import_core2.styled)(import_separator.Separator, {
|
|
298
328
|
name: "SelectSeparator"
|
|
@@ -310,121 +340,132 @@ const SelectSheetController = (props) => {
|
|
|
310
340
|
const showSheet = useShowSelectSheet(context);
|
|
311
341
|
const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
|
|
312
342
|
const getShowSheet = (0, import_core2.useGet)(showSheet);
|
|
313
|
-
return /* @__PURE__ */
|
|
343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sheet.SheetController, {
|
|
314
344
|
onChangeOpen: (val) => {
|
|
315
345
|
if (getShowSheet()) {
|
|
316
346
|
props.onChangeOpen(val);
|
|
317
347
|
}
|
|
318
348
|
},
|
|
319
349
|
open: context.open,
|
|
320
|
-
hidden: breakpointActive === false
|
|
321
|
-
|
|
350
|
+
hidden: breakpointActive === false,
|
|
351
|
+
children: props.children
|
|
352
|
+
});
|
|
322
353
|
};
|
|
323
354
|
const SHEET_CONTENTS_NAME = "SelectSheetContents";
|
|
324
355
|
const SelectSheetContents = ({ __scopeSelect }) => {
|
|
325
356
|
const context = (0, import_context.useSelectContext)(SHEET_CONTENTS_NAME, __scopeSelect);
|
|
326
|
-
return /* @__PURE__ */
|
|
357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, {
|
|
327
358
|
name: `${context.scopeKey}SheetContents`
|
|
328
359
|
});
|
|
329
360
|
};
|
|
330
361
|
SelectSheetContents.displayName = SHEET_CONTENTS_NAME;
|
|
331
362
|
const SelectSheetImpl = (props) => {
|
|
332
|
-
return /* @__PURE__ */
|
|
333
|
-
|
|
334
|
-
const Select = (0, import_core2.withStaticProperties)((props) => {
|
|
335
|
-
const {
|
|
336
|
-
__scopeSelect,
|
|
337
|
-
children,
|
|
338
|
-
open: openProp,
|
|
339
|
-
defaultOpen,
|
|
340
|
-
onOpenChange,
|
|
341
|
-
value: valueProp,
|
|
342
|
-
defaultValue,
|
|
343
|
-
onValueChange,
|
|
344
|
-
size: sizeProp = "$4",
|
|
345
|
-
sheetBreakpoint = false,
|
|
346
|
-
dir
|
|
347
|
-
} = props;
|
|
348
|
-
const isSheet = useSelectBreakpointActive(sheetBreakpoint);
|
|
349
|
-
const SelectImpl = isSheet ? SelectSheetImpl : import_SelectImpl.SelectInlineImpl;
|
|
350
|
-
const forceUpdate = React.useReducer(() => ({}), {})[1];
|
|
351
|
-
const [selectedItem, setSelectedItem] = React.useState(null);
|
|
352
|
-
const [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
353
|
-
prop: openProp,
|
|
354
|
-
defaultProp: defaultOpen || false,
|
|
355
|
-
onChange: onOpenChange,
|
|
356
|
-
strategy: "most-recent-wins"
|
|
357
|
-
});
|
|
358
|
-
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
359
|
-
prop: valueProp,
|
|
360
|
-
defaultProp: defaultValue || "",
|
|
361
|
-
onChange: onValueChange,
|
|
362
|
-
strategy: "most-recent-wins"
|
|
363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
364
|
+
children: props.children
|
|
363
365
|
});
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
forceUpdate,
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
setActiveIndex
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
366
|
+
};
|
|
367
|
+
const Select = (0, import_core2.withStaticProperties)(
|
|
368
|
+
(props) => {
|
|
369
|
+
const {
|
|
370
|
+
__scopeSelect,
|
|
371
|
+
children,
|
|
372
|
+
open: openProp,
|
|
373
|
+
defaultOpen,
|
|
374
|
+
onOpenChange,
|
|
375
|
+
value: valueProp,
|
|
376
|
+
defaultValue,
|
|
377
|
+
onValueChange,
|
|
378
|
+
size: sizeProp = "$4",
|
|
379
|
+
sheetBreakpoint = false,
|
|
380
|
+
dir
|
|
381
|
+
} = props;
|
|
382
|
+
const isSheet = useSelectBreakpointActive(sheetBreakpoint);
|
|
383
|
+
const SelectImpl = isSheet ? SelectSheetImpl : import_SelectImpl.SelectInlineImpl;
|
|
384
|
+
const forceUpdate = React.useReducer(() => ({}), {})[1];
|
|
385
|
+
const [selectedItem, setSelectedItem] = React.useState(null);
|
|
386
|
+
const [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
387
|
+
prop: openProp,
|
|
388
|
+
defaultProp: defaultOpen || false,
|
|
389
|
+
onChange: onOpenChange,
|
|
390
|
+
strategy: "most-recent-wins"
|
|
391
|
+
});
|
|
392
|
+
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
393
|
+
prop: valueProp,
|
|
394
|
+
defaultProp: defaultValue || "",
|
|
395
|
+
onChange: onValueChange,
|
|
396
|
+
strategy: "most-recent-wins"
|
|
397
|
+
});
|
|
398
|
+
const [activeIndex, setActiveIndex] = React.useState(null);
|
|
399
|
+
const selectedIndexRef = React.useRef(null);
|
|
400
|
+
const activeIndexRef = React.useRef(null);
|
|
401
|
+
const listContentRef = React.useRef([]);
|
|
402
|
+
const [selectedIndex, setSelectedIndex] = React.useState(
|
|
403
|
+
Math.max(0, listContentRef.current.indexOf(value))
|
|
404
|
+
);
|
|
405
|
+
const [valueNode, setValueNode] = React.useState(null);
|
|
406
|
+
const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
|
|
407
|
+
(0, import_core2.useIsomorphicLayoutEffect)(() => {
|
|
408
|
+
selectedIndexRef.current = selectedIndex;
|
|
409
|
+
activeIndexRef.current = activeIndex;
|
|
410
|
+
});
|
|
411
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.SelectProvider, {
|
|
412
|
+
dir,
|
|
413
|
+
blockSelection: false,
|
|
414
|
+
size: sizeProp,
|
|
415
|
+
fallback: false,
|
|
416
|
+
selectedItem,
|
|
417
|
+
setSelectedItem,
|
|
418
|
+
forceUpdate,
|
|
419
|
+
valueNode,
|
|
420
|
+
onValueNodeChange: setValueNode,
|
|
421
|
+
onValueNodeHasChildrenChange: setValueNodeHasChildren,
|
|
422
|
+
valueNodeHasChildren,
|
|
423
|
+
scopeKey: __scopeSelect ? Object.keys(__scopeSelect)[0] : "",
|
|
424
|
+
sheetBreakpoint,
|
|
425
|
+
scope: __scopeSelect,
|
|
426
|
+
setValueAtIndex: (index, value2) => {
|
|
427
|
+
listContentRef.current[index] = value2;
|
|
428
|
+
},
|
|
429
|
+
activeIndex,
|
|
430
|
+
onChange: setValue,
|
|
431
|
+
selectedIndex,
|
|
432
|
+
setActiveIndex,
|
|
433
|
+
setOpen,
|
|
434
|
+
setSelectedIndex,
|
|
435
|
+
value,
|
|
436
|
+
open,
|
|
437
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectSheetController, {
|
|
438
|
+
onChangeOpen: setOpen,
|
|
439
|
+
__scopeSelect,
|
|
440
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectImpl, {
|
|
441
|
+
activeIndexRef,
|
|
442
|
+
listContentRef,
|
|
443
|
+
selectedIndexRef,
|
|
444
|
+
...props,
|
|
445
|
+
open,
|
|
446
|
+
value,
|
|
447
|
+
children
|
|
448
|
+
})
|
|
449
|
+
})
|
|
450
|
+
});
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
Content: import_SelectContent.SelectContent,
|
|
454
|
+
Group: SelectGroup,
|
|
455
|
+
Icon: SelectIcon,
|
|
456
|
+
Item: SelectItem,
|
|
457
|
+
ItemIndicator: SelectItemIndicator,
|
|
458
|
+
ItemText: SelectItemText,
|
|
459
|
+
Label: SelectLabel,
|
|
460
|
+
ScrollDownButton: import_SelectScrollButton.SelectScrollDownButton,
|
|
461
|
+
ScrollUpButton: import_SelectScrollButton.SelectScrollUpButton,
|
|
462
|
+
Trigger: SelectTrigger,
|
|
463
|
+
Value: SelectValue,
|
|
464
|
+
Viewport: import_SelectViewport.SelectViewport,
|
|
465
|
+
SheetContents: SelectSheetContents,
|
|
466
|
+
Sheet: import_sheet.Sheet
|
|
467
|
+
}
|
|
468
|
+
);
|
|
428
469
|
Select.displayName = import_constants.SELECT_NAME;
|
|
429
470
|
// Annotate the CommonJS export names for ESM import in node:
|
|
430
471
|
0 && (module.exports = {
|