@tamagui/select 3.0.0-beta.924.1 → 3.0.1
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.cjs +23 -25
- package/dist/cjs/Select.native.cjs +27 -26
- package/dist/cjs/Select.native.js +27 -26
- package/dist/cjs/Select.native.js.map +1 -1
- package/dist/cjs/SelectImpl.cjs +67 -63
- package/dist/cjs/SelectItem.cjs +49 -60
- package/dist/cjs/SelectItem.native.cjs +51 -79
- package/dist/cjs/SelectItem.native.js +51 -79
- package/dist/cjs/SelectItem.native.js.map +1 -1
- package/dist/cjs/SelectScrollButton.cjs +9 -25
- package/dist/cjs/SelectTrigger.cjs +22 -5
- package/dist/cjs/SelectTrigger.native.cjs +15 -5
- package/dist/cjs/SelectTrigger.native.js +15 -5
- package/dist/cjs/SelectTrigger.native.js.map +1 -1
- package/dist/cjs/SelectViewport.cjs +29 -32
- package/dist/cjs/SelectViewport.native.cjs +2 -2
- package/dist/cjs/SelectViewport.native.js +2 -2
- package/dist/cjs/SelectViewport.native.js.map +1 -1
- package/dist/cjs/selectionController.cjs +15 -5
- package/dist/cjs/selectionController.native.cjs +20 -15
- package/dist/cjs/selectionController.native.js +20 -15
- package/dist/cjs/selectionController.native.js.map +1 -1
- package/dist/esm/Select.mjs +27 -28
- package/dist/esm/Select.mjs.map +1 -1
- package/dist/esm/Select.native.js +31 -29
- package/dist/esm/Select.native.js.map +1 -1
- package/dist/esm/SelectImpl.mjs +68 -64
- package/dist/esm/SelectImpl.mjs.map +1 -1
- package/dist/esm/SelectItem.mjs +50 -61
- package/dist/esm/SelectItem.mjs.map +1 -1
- package/dist/esm/SelectItem.native.js +52 -80
- package/dist/esm/SelectItem.native.js.map +1 -1
- package/dist/esm/SelectScrollButton.mjs +10 -26
- package/dist/esm/SelectScrollButton.mjs.map +1 -1
- package/dist/esm/SelectTrigger.mjs +16 -5
- package/dist/esm/SelectTrigger.mjs.map +1 -1
- package/dist/esm/SelectTrigger.native.js +15 -4
- package/dist/esm/SelectTrigger.native.js.map +1 -1
- package/dist/esm/SelectViewport.mjs +30 -33
- package/dist/esm/SelectViewport.mjs.map +1 -1
- package/dist/esm/SelectViewport.native.js +3 -3
- package/dist/esm/SelectViewport.native.js.map +1 -1
- package/dist/esm/selectionController.mjs +15 -5
- package/dist/esm/selectionController.mjs.map +1 -1
- package/dist/esm/selectionController.native.js +20 -15
- package/dist/esm/selectionController.native.js.map +1 -1
- package/dist/jsx/Select.mjs +27 -28
- package/dist/jsx/Select.mjs.map +1 -1
- package/dist/jsx/Select.native.cjs +27 -26
- package/dist/jsx/Select.native.js +27 -26
- package/dist/jsx/Select.native.js.map +1 -1
- package/dist/jsx/SelectImpl.mjs +68 -64
- package/dist/jsx/SelectImpl.mjs.map +1 -1
- package/dist/jsx/SelectItem.mjs +50 -61
- package/dist/jsx/SelectItem.mjs.map +1 -1
- package/dist/jsx/SelectItem.native.cjs +51 -79
- package/dist/jsx/SelectItem.native.js +51 -79
- package/dist/jsx/SelectItem.native.js.map +1 -1
- package/dist/jsx/SelectScrollButton.mjs +10 -26
- package/dist/jsx/SelectScrollButton.mjs.map +1 -1
- package/dist/jsx/SelectTrigger.mjs +16 -5
- package/dist/jsx/SelectTrigger.mjs.map +1 -1
- package/dist/jsx/SelectTrigger.native.cjs +15 -5
- package/dist/jsx/SelectTrigger.native.js +15 -5
- package/dist/jsx/SelectTrigger.native.js.map +1 -1
- package/dist/jsx/SelectViewport.mjs +30 -33
- package/dist/jsx/SelectViewport.mjs.map +1 -1
- package/dist/jsx/SelectViewport.native.cjs +2 -2
- package/dist/jsx/SelectViewport.native.js +2 -2
- package/dist/jsx/SelectViewport.native.js.map +1 -1
- package/dist/jsx/selectionController.mjs +15 -5
- package/dist/jsx/selectionController.mjs.map +1 -1
- package/dist/jsx/selectionController.native.cjs +20 -15
- package/dist/jsx/selectionController.native.js +20 -15
- package/dist/jsx/selectionController.native.js.map +1 -1
- package/package.json +30 -29
- package/src/Select.tsx +41 -41
- package/src/SelectImpl.tsx +107 -95
- package/src/SelectItem.tsx +66 -91
- package/src/SelectScrollButton.tsx +14 -32
- package/src/SelectTrigger.tsx +19 -2
- package/src/SelectViewport.native.tsx +4 -4
- package/src/SelectViewport.tsx +34 -30
- package/src/selectionController.ts +20 -5
- package/src/types.tsx +26 -22
- package/types/Select.d.ts +42 -81
- package/types/Select.d.ts.map +1 -1
- package/types/SelectImpl.d.ts.map +1 -1
- package/types/SelectItem.d.ts +3 -5
- package/types/SelectItem.d.ts.map +1 -1
- package/types/SelectItemText.d.ts +3 -5
- package/types/SelectItemText.d.ts.map +1 -1
- package/types/SelectScrollButton.d.ts +5 -9
- package/types/SelectScrollButton.d.ts.map +1 -1
- package/types/SelectScrollButton.native.d.ts +5 -9
- package/types/SelectScrollButton.native.d.ts.map +1 -1
- package/types/SelectTrigger.d.ts +3 -5
- package/types/SelectTrigger.d.ts.map +1 -1
- package/types/SelectViewport.d.ts +4 -9
- package/types/SelectViewport.d.ts.map +1 -1
- package/types/SelectViewport.native.d.ts +4 -9
- package/types/SelectViewport.native.d.ts.map +1 -1
- package/types/selectionController.d.ts +2 -0
- package/types/selectionController.d.ts.map +1 -1
- package/types/types.d.ts +30 -22
- package/types/types.d.ts.map +1 -1
|
@@ -43,13 +43,6 @@ var import_helpers = require("@tamagui/helpers");
|
|
|
43
43
|
var React = __toESM(require("react"), 1);
|
|
44
44
|
var import_context = require("./context.native.js");
|
|
45
45
|
var import_selectionController = require("./selectionController.native.js");
|
|
46
|
-
function _instanceof(left, right) {
|
|
47
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
48
|
-
return !!right[Symbol.hasInstance](left);
|
|
49
|
-
} else {
|
|
50
|
-
return left instanceof right;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
46
|
var ITEM_NAME = "SelectItem";
|
|
54
47
|
var { Provider: SelectItemContextProvider, useStyledContext: useSelectItemContext } = (0, import_core.createStyledContext)(null, ITEM_NAME);
|
|
55
48
|
var SelectItemFrame = (0, import_core.styled)(import_core.View, {
|
|
@@ -61,44 +54,22 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
61
54
|
var { scope, value, disabled: disabledProp, "aria-disabled": ariaDisabled, textValue: textValueProp, ...restProps } = props;
|
|
62
55
|
var disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : ariaDisabled === true;
|
|
63
56
|
var context = (0, import_context.useSelectItemParentContext)(scope);
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var { listRef, registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, interactions, shouldRenderWebNative, setActiveIndexFast, moveActive, search } = context;
|
|
57
|
+
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
58
|
+
var { registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, getItemProps, shouldRenderWebNative, setActiveIndex, lastPointerRef, moveActive, search } = context;
|
|
67
59
|
var isSelected = selectedValues.includes(value);
|
|
68
60
|
var pendingMouseUpSelectionRef = React.useRef(false);
|
|
69
61
|
var itemNodeRef = React.useRef(null);
|
|
70
|
-
var [, rerenderRegistry] = React.useReducer(function(version) {
|
|
71
|
-
return version + 1;
|
|
72
|
-
}, 0);
|
|
73
62
|
var registrationRef = React.useRef(null);
|
|
74
63
|
var initialRegistration = React.useRef({
|
|
75
64
|
value,
|
|
76
65
|
disabled,
|
|
77
66
|
textValue: textValueProp
|
|
78
67
|
});
|
|
79
|
-
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
80
|
-
return registry.subscribe(function() {
|
|
81
|
-
return rerenderRegistry();
|
|
82
|
-
});
|
|
83
|
-
}, [registry]);
|
|
84
68
|
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
85
69
|
var registration = registry.registerItem(initialRegistration.current);
|
|
86
70
|
registrationRef.current = registration;
|
|
87
|
-
|
|
88
|
-
registration.setNode(registeredNode);
|
|
89
|
-
var registeredIndex = registry.getItems().findIndex(function(item) {
|
|
90
|
-
return item.id === registration.id;
|
|
91
|
-
});
|
|
92
|
-
if (import_constants.isWeb && listRef && registeredIndex >= 0 && _instanceof(registeredNode, HTMLElement)) {
|
|
93
|
-
listRef.current[registeredIndex] = registeredNode;
|
|
94
|
-
}
|
|
71
|
+
registration.setNode(itemNodeRef.current);
|
|
95
72
|
return function() {
|
|
96
|
-
var currentIndex = registry.getItems().findIndex(function(item) {
|
|
97
|
-
return item.id === registration.id;
|
|
98
|
-
});
|
|
99
|
-
if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {
|
|
100
|
-
listRef.current[currentIndex] = null;
|
|
101
|
-
}
|
|
102
73
|
registrationRef.current = null;
|
|
103
74
|
registration.unregister();
|
|
104
75
|
};
|
|
@@ -119,39 +90,37 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
119
90
|
var _registrationRef_current;
|
|
120
91
|
(_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(itemNodeRef.current);
|
|
121
92
|
});
|
|
122
|
-
var
|
|
93
|
+
var [isActive, setIsActive] = React.useState(false);
|
|
94
|
+
var isActiveRef = React.useRef(false);
|
|
123
95
|
React.useEffect(function() {
|
|
124
96
|
var handleActiveIndex = function(i) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
97
|
+
var next = i != null && registry.getIndex(value) === i;
|
|
98
|
+
if (next !== isActiveRef.current) {
|
|
99
|
+
isActiveRef.current = next;
|
|
100
|
+
setIsActive(next);
|
|
101
|
+
}
|
|
102
|
+
if (next && import_constants.isWeb) {
|
|
103
|
+
requestAnimationFrame(function() {
|
|
104
|
+
var _itemNodeRef_current_focus, _itemNodeRef_current;
|
|
105
|
+
(_itemNodeRef_current = itemNodeRef.current) === null || _itemNodeRef_current === void 0 ? void 0 : (_itemNodeRef_current_focus = _itemNodeRef_current.focus) === null || _itemNodeRef_current_focus === void 0 ? void 0 : _itemNodeRef_current_focus.call(_itemNodeRef_current);
|
|
106
|
+
});
|
|
132
107
|
}
|
|
133
108
|
};
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
handleActiveIndex(currentActiveIndex);
|
|
137
|
-
}
|
|
109
|
+
var _activeIndexRef_current;
|
|
110
|
+
handleActiveIndex((_activeIndexRef_current = activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current) !== null && _activeIndexRef_current !== void 0 ? _activeIndexRef_current : null);
|
|
138
111
|
return activeIndexSubscribe(handleActiveIndex);
|
|
139
112
|
}, [
|
|
140
113
|
activeIndexRef,
|
|
141
114
|
activeIndexSubscribe,
|
|
142
|
-
|
|
143
|
-
|
|
115
|
+
registry,
|
|
116
|
+
value
|
|
144
117
|
]);
|
|
145
118
|
var textId = React.useId();
|
|
146
119
|
var refCallback = React.useCallback(function(node) {
|
|
147
120
|
var _registrationRef_current;
|
|
148
121
|
itemNodeRef.current = node;
|
|
149
122
|
(_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(node);
|
|
150
|
-
|
|
151
|
-
if (listRef && index >= 0) {
|
|
152
|
-
listRef.current[index] = _instanceof(node, HTMLElement) ? node : null;
|
|
153
|
-
}
|
|
154
|
-
}, [index, listRef]);
|
|
123
|
+
}, []);
|
|
155
124
|
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, refCallback);
|
|
156
125
|
var handleSelect = React.useCallback(function(event) {
|
|
157
126
|
var reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "item-press";
|
|
@@ -163,6 +132,27 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
163
132
|
selectValue,
|
|
164
133
|
value
|
|
165
134
|
]);
|
|
135
|
+
var handleMouseMove = React.useCallback(function(event) {
|
|
136
|
+
if (disabled) return;
|
|
137
|
+
var index = registry.getIndex(value);
|
|
138
|
+
if (index < 0) return;
|
|
139
|
+
var last = lastPointerRef.current;
|
|
140
|
+
if (event.clientX === last.x && event.clientY === last.y) return;
|
|
141
|
+
last.x = event.clientX;
|
|
142
|
+
last.y = event.clientY;
|
|
143
|
+
setActiveIndex(index, {
|
|
144
|
+
reason: "item-hover",
|
|
145
|
+
event: event.nativeEvent || event,
|
|
146
|
+
trigger: event.currentTarget,
|
|
147
|
+
index
|
|
148
|
+
});
|
|
149
|
+
}, [
|
|
150
|
+
disabled,
|
|
151
|
+
lastPointerRef,
|
|
152
|
+
registry,
|
|
153
|
+
setActiveIndex,
|
|
154
|
+
value
|
|
155
|
+
]);
|
|
166
156
|
var handleKeyDown = React.useCallback(function(event) {
|
|
167
157
|
var _event_key;
|
|
168
158
|
if (disabled) return;
|
|
@@ -177,7 +167,7 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
177
167
|
moveActive(event.key === "ArrowDown" ? 1 : -1, event.nativeEvent || event);
|
|
178
168
|
return;
|
|
179
169
|
}
|
|
180
|
-
if (!
|
|
170
|
+
if (!getItemProps && ((_event_key = event.key) === null || _event_key === void 0 ? void 0 : _event_key.length) === 1 && !event.metaKey && !event.ctrlKey) {
|
|
181
171
|
search(event.key, event.nativeEvent || event);
|
|
182
172
|
}
|
|
183
173
|
if (allowSelectRef) {
|
|
@@ -187,14 +177,14 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
187
177
|
allowSelectRef,
|
|
188
178
|
disabled,
|
|
189
179
|
handleSelect,
|
|
190
|
-
|
|
180
|
+
getItemProps,
|
|
191
181
|
moveActive,
|
|
192
182
|
search
|
|
193
183
|
]);
|
|
194
184
|
var selectItemProps = React.useMemo(function() {
|
|
195
|
-
if (
|
|
185
|
+
if (getItemProps) {
|
|
196
186
|
var { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;
|
|
197
|
-
var interactionProps =
|
|
187
|
+
var interactionProps = getItemProps({
|
|
198
188
|
...itemProps,
|
|
199
189
|
onTouchMove() {
|
|
200
190
|
allowSelectRef.current = true;
|
|
@@ -204,15 +194,7 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
204
194
|
allowSelectRef.current = false;
|
|
205
195
|
allowMouseUpRef.current = true;
|
|
206
196
|
},
|
|
207
|
-
onMouseMove
|
|
208
|
-
if (disabled || index < 0) return;
|
|
209
|
-
setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {
|
|
210
|
-
reason: "item-hover",
|
|
211
|
-
event: event.nativeEvent || event,
|
|
212
|
-
trigger: event.currentTarget,
|
|
213
|
-
index
|
|
214
|
-
});
|
|
215
|
-
},
|
|
197
|
+
onMouseMove: handleMouseMove,
|
|
216
198
|
onKeyDown: handleKeyDown,
|
|
217
199
|
onClick(event) {
|
|
218
200
|
if (disabled) return;
|
|
@@ -266,15 +248,7 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
266
248
|
return {
|
|
267
249
|
...restProps,
|
|
268
250
|
onKeyDown: (0, import_helpers.composeEventHandlers)(restProps.onKeyDown, handleKeyDown),
|
|
269
|
-
onMouseMove: (0, import_helpers.composeEventHandlers)(restProps.onMouseMove,
|
|
270
|
-
if (disabled || index < 0) return;
|
|
271
|
-
setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {
|
|
272
|
-
reason: "item-hover",
|
|
273
|
-
event: event.nativeEvent || event,
|
|
274
|
-
trigger: event.currentTarget,
|
|
275
|
-
index
|
|
276
|
-
});
|
|
277
|
-
}),
|
|
251
|
+
onMouseMove: (0, import_helpers.composeEventHandlers)(restProps.onMouseMove, handleMouseMove),
|
|
278
252
|
onPress: (0, import_helpers.composeEventHandlers)(restProps.onPress, handleSelect)
|
|
279
253
|
};
|
|
280
254
|
}, [
|
|
@@ -282,15 +256,13 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
282
256
|
allowSelectRef,
|
|
283
257
|
disabled,
|
|
284
258
|
handleKeyDown,
|
|
259
|
+
handleMouseMove,
|
|
285
260
|
handleSelect,
|
|
286
|
-
|
|
287
|
-
interactions,
|
|
261
|
+
getItemProps,
|
|
288
262
|
restProps,
|
|
289
|
-
selectTimeoutRef
|
|
290
|
-
setActiveIndexFast
|
|
263
|
+
selectTimeoutRef
|
|
291
264
|
]);
|
|
292
265
|
var accessibilityProps = (0, import_selectionController.getSelectOptionProps)(mode, isSelected, disabled, import_constants.isWeb ? "web" : "native");
|
|
293
|
-
var _selectContext_activeIndex;
|
|
294
266
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemContextProvider, {
|
|
295
267
|
scope,
|
|
296
268
|
value,
|
|
@@ -307,7 +279,7 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
307
279
|
"aria-labelledby": textId,
|
|
308
280
|
"data-state": isSelected ? "active" : "inactive",
|
|
309
281
|
"data-disabled": disabled ? "" : void 0,
|
|
310
|
-
tabIndex: disabled ? void 0 : import_constants.isWeb && isAdapted
|
|
282
|
+
tabIndex: disabled ? void 0 : import_constants.isWeb && isAdapted && (isActive || (activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current) == null && isSelected) ? 0 : -1,
|
|
311
283
|
zIndex: 100,
|
|
312
284
|
...selectItemProps,
|
|
313
285
|
...accessibilityProps
|
|
@@ -43,13 +43,6 @@ var import_helpers = require("@tamagui/helpers");
|
|
|
43
43
|
var React = __toESM(require("react"), 1);
|
|
44
44
|
var import_context = require("./context.native.js");
|
|
45
45
|
var import_selectionController = require("./selectionController.native.js");
|
|
46
|
-
function _instanceof(left, right) {
|
|
47
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
48
|
-
return !!right[Symbol.hasInstance](left);
|
|
49
|
-
} else {
|
|
50
|
-
return left instanceof right;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
46
|
var ITEM_NAME = "SelectItem";
|
|
54
47
|
var { Provider: SelectItemContextProvider, useStyledContext: useSelectItemContext } = (0, import_core.createStyledContext)(null, ITEM_NAME);
|
|
55
48
|
var SelectItemFrame = (0, import_core.styled)(import_core.View, {
|
|
@@ -61,44 +54,22 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
61
54
|
var { scope, value, disabled: disabledProp, "aria-disabled": ariaDisabled, textValue: textValueProp, ...restProps } = props;
|
|
62
55
|
var disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : ariaDisabled === true;
|
|
63
56
|
var context = (0, import_context.useSelectItemParentContext)(scope);
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var { listRef, registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, interactions, shouldRenderWebNative, setActiveIndexFast, moveActive, search } = context;
|
|
57
|
+
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
58
|
+
var { registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, getItemProps, shouldRenderWebNative, setActiveIndex, lastPointerRef, moveActive, search } = context;
|
|
67
59
|
var isSelected = selectedValues.includes(value);
|
|
68
60
|
var pendingMouseUpSelectionRef = React.useRef(false);
|
|
69
61
|
var itemNodeRef = React.useRef(null);
|
|
70
|
-
var [, rerenderRegistry] = React.useReducer(function(version) {
|
|
71
|
-
return version + 1;
|
|
72
|
-
}, 0);
|
|
73
62
|
var registrationRef = React.useRef(null);
|
|
74
63
|
var initialRegistration = React.useRef({
|
|
75
64
|
value,
|
|
76
65
|
disabled,
|
|
77
66
|
textValue: textValueProp
|
|
78
67
|
});
|
|
79
|
-
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
80
|
-
return registry.subscribe(function() {
|
|
81
|
-
return rerenderRegistry();
|
|
82
|
-
});
|
|
83
|
-
}, [registry]);
|
|
84
68
|
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
85
69
|
var registration = registry.registerItem(initialRegistration.current);
|
|
86
70
|
registrationRef.current = registration;
|
|
87
|
-
|
|
88
|
-
registration.setNode(registeredNode);
|
|
89
|
-
var registeredIndex = registry.getItems().findIndex(function(item) {
|
|
90
|
-
return item.id === registration.id;
|
|
91
|
-
});
|
|
92
|
-
if (import_constants.isWeb && listRef && registeredIndex >= 0 && _instanceof(registeredNode, HTMLElement)) {
|
|
93
|
-
listRef.current[registeredIndex] = registeredNode;
|
|
94
|
-
}
|
|
71
|
+
registration.setNode(itemNodeRef.current);
|
|
95
72
|
return function() {
|
|
96
|
-
var currentIndex = registry.getItems().findIndex(function(item) {
|
|
97
|
-
return item.id === registration.id;
|
|
98
|
-
});
|
|
99
|
-
if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {
|
|
100
|
-
listRef.current[currentIndex] = null;
|
|
101
|
-
}
|
|
102
73
|
registrationRef.current = null;
|
|
103
74
|
registration.unregister();
|
|
104
75
|
};
|
|
@@ -119,39 +90,37 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
119
90
|
var _registrationRef_current;
|
|
120
91
|
(_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(itemNodeRef.current);
|
|
121
92
|
});
|
|
122
|
-
var
|
|
93
|
+
var [isActive, setIsActive] = React.useState(false);
|
|
94
|
+
var isActiveRef = React.useRef(false);
|
|
123
95
|
React.useEffect(function() {
|
|
124
96
|
var handleActiveIndex = function(i) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
97
|
+
var next = i != null && registry.getIndex(value) === i;
|
|
98
|
+
if (next !== isActiveRef.current) {
|
|
99
|
+
isActiveRef.current = next;
|
|
100
|
+
setIsActive(next);
|
|
101
|
+
}
|
|
102
|
+
if (next && import_constants.isWeb) {
|
|
103
|
+
requestAnimationFrame(function() {
|
|
104
|
+
var _itemNodeRef_current_focus, _itemNodeRef_current;
|
|
105
|
+
(_itemNodeRef_current = itemNodeRef.current) === null || _itemNodeRef_current === void 0 ? void 0 : (_itemNodeRef_current_focus = _itemNodeRef_current.focus) === null || _itemNodeRef_current_focus === void 0 ? void 0 : _itemNodeRef_current_focus.call(_itemNodeRef_current);
|
|
106
|
+
});
|
|
132
107
|
}
|
|
133
108
|
};
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
handleActiveIndex(currentActiveIndex);
|
|
137
|
-
}
|
|
109
|
+
var _activeIndexRef_current;
|
|
110
|
+
handleActiveIndex((_activeIndexRef_current = activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current) !== null && _activeIndexRef_current !== void 0 ? _activeIndexRef_current : null);
|
|
138
111
|
return activeIndexSubscribe(handleActiveIndex);
|
|
139
112
|
}, [
|
|
140
113
|
activeIndexRef,
|
|
141
114
|
activeIndexSubscribe,
|
|
142
|
-
|
|
143
|
-
|
|
115
|
+
registry,
|
|
116
|
+
value
|
|
144
117
|
]);
|
|
145
118
|
var textId = React.useId();
|
|
146
119
|
var refCallback = React.useCallback(function(node) {
|
|
147
120
|
var _registrationRef_current;
|
|
148
121
|
itemNodeRef.current = node;
|
|
149
122
|
(_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(node);
|
|
150
|
-
|
|
151
|
-
if (listRef && index >= 0) {
|
|
152
|
-
listRef.current[index] = _instanceof(node, HTMLElement) ? node : null;
|
|
153
|
-
}
|
|
154
|
-
}, [index, listRef]);
|
|
123
|
+
}, []);
|
|
155
124
|
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, refCallback);
|
|
156
125
|
var handleSelect = React.useCallback(function(event) {
|
|
157
126
|
var reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "item-press";
|
|
@@ -163,6 +132,27 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
163
132
|
selectValue,
|
|
164
133
|
value
|
|
165
134
|
]);
|
|
135
|
+
var handleMouseMove = React.useCallback(function(event) {
|
|
136
|
+
if (disabled) return;
|
|
137
|
+
var index = registry.getIndex(value);
|
|
138
|
+
if (index < 0) return;
|
|
139
|
+
var last = lastPointerRef.current;
|
|
140
|
+
if (event.clientX === last.x && event.clientY === last.y) return;
|
|
141
|
+
last.x = event.clientX;
|
|
142
|
+
last.y = event.clientY;
|
|
143
|
+
setActiveIndex(index, {
|
|
144
|
+
reason: "item-hover",
|
|
145
|
+
event: event.nativeEvent || event,
|
|
146
|
+
trigger: event.currentTarget,
|
|
147
|
+
index
|
|
148
|
+
});
|
|
149
|
+
}, [
|
|
150
|
+
disabled,
|
|
151
|
+
lastPointerRef,
|
|
152
|
+
registry,
|
|
153
|
+
setActiveIndex,
|
|
154
|
+
value
|
|
155
|
+
]);
|
|
166
156
|
var handleKeyDown = React.useCallback(function(event) {
|
|
167
157
|
var _event_key;
|
|
168
158
|
if (disabled) return;
|
|
@@ -177,7 +167,7 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
177
167
|
moveActive(event.key === "ArrowDown" ? 1 : -1, event.nativeEvent || event);
|
|
178
168
|
return;
|
|
179
169
|
}
|
|
180
|
-
if (!
|
|
170
|
+
if (!getItemProps && ((_event_key = event.key) === null || _event_key === void 0 ? void 0 : _event_key.length) === 1 && !event.metaKey && !event.ctrlKey) {
|
|
181
171
|
search(event.key, event.nativeEvent || event);
|
|
182
172
|
}
|
|
183
173
|
if (allowSelectRef) {
|
|
@@ -187,14 +177,14 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
187
177
|
allowSelectRef,
|
|
188
178
|
disabled,
|
|
189
179
|
handleSelect,
|
|
190
|
-
|
|
180
|
+
getItemProps,
|
|
191
181
|
moveActive,
|
|
192
182
|
search
|
|
193
183
|
]);
|
|
194
184
|
var selectItemProps = React.useMemo(function() {
|
|
195
|
-
if (
|
|
185
|
+
if (getItemProps) {
|
|
196
186
|
var { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;
|
|
197
|
-
var interactionProps =
|
|
187
|
+
var interactionProps = getItemProps({
|
|
198
188
|
...itemProps,
|
|
199
189
|
onTouchMove() {
|
|
200
190
|
allowSelectRef.current = true;
|
|
@@ -204,15 +194,7 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
204
194
|
allowSelectRef.current = false;
|
|
205
195
|
allowMouseUpRef.current = true;
|
|
206
196
|
},
|
|
207
|
-
onMouseMove
|
|
208
|
-
if (disabled || index < 0) return;
|
|
209
|
-
setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {
|
|
210
|
-
reason: "item-hover",
|
|
211
|
-
event: event.nativeEvent || event,
|
|
212
|
-
trigger: event.currentTarget,
|
|
213
|
-
index
|
|
214
|
-
});
|
|
215
|
-
},
|
|
197
|
+
onMouseMove: handleMouseMove,
|
|
216
198
|
onKeyDown: handleKeyDown,
|
|
217
199
|
onClick(event) {
|
|
218
200
|
if (disabled) return;
|
|
@@ -266,15 +248,7 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
266
248
|
return {
|
|
267
249
|
...restProps,
|
|
268
250
|
onKeyDown: (0, import_helpers.composeEventHandlers)(restProps.onKeyDown, handleKeyDown),
|
|
269
|
-
onMouseMove: (0, import_helpers.composeEventHandlers)(restProps.onMouseMove,
|
|
270
|
-
if (disabled || index < 0) return;
|
|
271
|
-
setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {
|
|
272
|
-
reason: "item-hover",
|
|
273
|
-
event: event.nativeEvent || event,
|
|
274
|
-
trigger: event.currentTarget,
|
|
275
|
-
index
|
|
276
|
-
});
|
|
277
|
-
}),
|
|
251
|
+
onMouseMove: (0, import_helpers.composeEventHandlers)(restProps.onMouseMove, handleMouseMove),
|
|
278
252
|
onPress: (0, import_helpers.composeEventHandlers)(restProps.onPress, handleSelect)
|
|
279
253
|
};
|
|
280
254
|
}, [
|
|
@@ -282,15 +256,13 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
282
256
|
allowSelectRef,
|
|
283
257
|
disabled,
|
|
284
258
|
handleKeyDown,
|
|
259
|
+
handleMouseMove,
|
|
285
260
|
handleSelect,
|
|
286
|
-
|
|
287
|
-
interactions,
|
|
261
|
+
getItemProps,
|
|
288
262
|
restProps,
|
|
289
|
-
selectTimeoutRef
|
|
290
|
-
setActiveIndexFast
|
|
263
|
+
selectTimeoutRef
|
|
291
264
|
]);
|
|
292
265
|
var accessibilityProps = (0, import_selectionController.getSelectOptionProps)(mode, isSelected, disabled, import_constants.isWeb ? "web" : "native");
|
|
293
|
-
var _selectContext_activeIndex;
|
|
294
266
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemContextProvider, {
|
|
295
267
|
scope,
|
|
296
268
|
value,
|
|
@@ -307,7 +279,7 @@ var SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function Sele
|
|
|
307
279
|
"aria-labelledby": textId,
|
|
308
280
|
"data-state": isSelected ? "active" : "inactive",
|
|
309
281
|
"data-disabled": disabled ? "" : void 0,
|
|
310
|
-
tabIndex: disabled ? void 0 : import_constants.isWeb && isAdapted
|
|
282
|
+
tabIndex: disabled ? void 0 : import_constants.isWeb && isAdapted && (isActive || (activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current) == null && isSelected) ? 0 : -1,
|
|
311
283
|
zIndex: 100,
|
|
312
284
|
...selectItemProps,
|
|
313
285
|
...accessibilityProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectItem.native.js","names":[],"sources":["cjs/SelectItem.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar SelectItem_exports = {};\n__export(SelectItem_exports, {\n SelectItem: () => SelectItem,\n SelectItemContextProvider: () => SelectItemContextProvider,\n SelectItemFrame: () => SelectItemFrame,\n useSelectItemContext: () => useSelectItemContext\n});\nmodule.exports = __toCommonJS(SelectItem_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_compose_refs = require(\"@tamagui/compose-refs\");\nvar import_adapt = require(\"@tamagui/adapt\");\nvar import_constants = require(\"@tamagui/constants\");\nvar import_core = require(\"@tamagui/core\");\nvar import_helpers = require(\"@tamagui/helpers\");\nvar React = __toESM(require(\"react\"), 1);\nvar import_context = require(\"./context\");\nvar import_selectionController = require(\"./selectionController\");\nfunction _instanceof(left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return !!right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n}\nvar ITEM_NAME = \"SelectItem\";\nvar { Provider: SelectItemContextProvider, useStyledContext: useSelectItemContext } = (0, import_core.createStyledContext)(null, ITEM_NAME);\nvar SelectItemFrame = (0, import_core.styled)(import_core.View, {\n displayName: ITEM_NAME,\n alignItems: \"center\",\n flexDirection: \"row\"\n});\nvar SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function SelectItem2(props, forwardedRef) {\n var { scope, value, disabled: disabledProp, \"aria-disabled\": ariaDisabled, textValue: textValueProp, ...restProps } = props;\n var disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : ariaDisabled === true;\n var context = (0, import_context.useSelectItemParentContext)(scope);\n var selectContext = (0, import_context.useSelectContext)(scope);\n var isAdapted = (0, import_adapt.useAdaptIsActive)(selectContext.adaptScope);\n var { listRef, registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, interactions, shouldRenderWebNative, setActiveIndexFast, moveActive, search } = context;\n var isSelected = selectedValues.includes(value);\n var pendingMouseUpSelectionRef = React.useRef(false);\n var itemNodeRef = React.useRef(null);\n var [, rerenderRegistry] = React.useReducer(function(version) {\n return version + 1;\n }, 0);\n var registrationRef = React.useRef(null);\n var initialRegistration = React.useRef({\n value,\n disabled,\n textValue: textValueProp\n });\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n return registry.subscribe(function() {\n return rerenderRegistry();\n });\n }, [\n registry\n ]);\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var registration = registry.registerItem(initialRegistration.current);\n registrationRef.current = registration;\n var registeredNode = itemNodeRef.current;\n registration.setNode(registeredNode);\n var registeredIndex = registry.getItems().findIndex(function(item) {\n return item.id === registration.id;\n });\n if (import_constants.isWeb && listRef && registeredIndex >= 0 && _instanceof(registeredNode, HTMLElement)) {\n listRef.current[registeredIndex] = registeredNode;\n }\n return function() {\n var currentIndex = registry.getItems().findIndex(function(item) {\n return item.id === registration.id;\n });\n if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {\n listRef.current[currentIndex] = null;\n }\n registrationRef.current = null;\n registration.unregister();\n };\n }, [\n registry\n ]);\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.update({\n value,\n disabled,\n textValue: textValueProp\n });\n }, [\n disabled,\n textValueProp,\n value\n ]);\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(itemNodeRef.current);\n });\n var index = registry.getIndex(value);\n React.useEffect(function() {\n var handleActiveIndex = function(i) {\n if (index === i) {\n if (import_constants.isWeb) {\n requestAnimationFrame(function() {\n var _listRef_current_index;\n listRef === null || listRef === void 0 ? void 0 : (_listRef_current_index = listRef.current[index]) === null || _listRef_current_index === void 0 ? void 0 : _listRef_current_index.focus();\n });\n }\n }\n };\n var currentActiveIndex = activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current;\n if (currentActiveIndex !== null && currentActiveIndex !== void 0) {\n handleActiveIndex(currentActiveIndex);\n }\n return activeIndexSubscribe(handleActiveIndex);\n }, [\n activeIndexRef,\n activeIndexSubscribe,\n index,\n listRef\n ]);\n var textId = React.useId();\n var refCallback = React.useCallback(function(node) {\n var _registrationRef_current;\n itemNodeRef.current = node;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(node);\n if (!import_constants.isWeb) return;\n if (listRef && index >= 0) {\n listRef.current[index] = _instanceof(node, HTMLElement) ? node : null;\n }\n }, [\n index,\n listRef\n ]);\n var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, refCallback);\n var handleSelect = React.useCallback(function(event) {\n var reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : \"item-press\";\n if (disabled) return;\n var nativeEvent = (event === null || event === void 0 ? void 0 : event.nativeEvent) || event;\n selectValue(value, (0, import_core.createChangeEventDetails)(reason, nativeEvent, event === null || event === void 0 ? void 0 : event.currentTarget));\n }, [\n disabled,\n selectValue,\n value\n ]);\n var handleKeyDown = React.useCallback(function(event) {\n var _event_key;\n if (disabled) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n handleSelect(event, \"keyboard\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n event.stopPropagation();\n moveActive(event.key === \"ArrowDown\" ? 1 : -1, event.nativeEvent || event);\n return;\n }\n if (!interactions && ((_event_key = event.key) === null || _event_key === void 0 ? void 0 : _event_key.length) === 1 && !event.metaKey && !event.ctrlKey) {\n search(event.key, event.nativeEvent || event);\n }\n if (allowSelectRef) {\n allowSelectRef.current = true;\n }\n }, [\n allowSelectRef,\n disabled,\n handleSelect,\n interactions,\n moveActive,\n search\n ]);\n var selectItemProps = React.useMemo(function() {\n if (interactions) {\n var { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;\n var interactionProps = interactions.getItemProps({\n ...itemProps,\n onTouchMove() {\n allowSelectRef.current = true;\n allowMouseUpRef.current = false;\n },\n onTouchEnd() {\n allowSelectRef.current = false;\n allowMouseUpRef.current = true;\n },\n onMouseMove(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n },\n onKeyDown: handleKeyDown,\n onClick(event) {\n if (disabled) return;\n var shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n if (shouldSelect) {\n handleSelect(event);\n }\n },\n onMouseUp(event) {\n if (disabled) return;\n if (!allowMouseUpRef.current) {\n allowMouseUpRef.current = true;\n allowSelectRef.current = true;\n return;\n }\n pendingMouseUpSelectionRef.current = allowSelectRef.current;\n clearTimeout(selectTimeoutRef.current);\n selectTimeoutRef.current = setTimeout(function() {\n allowSelectRef.current = true;\n if (pendingMouseUpSelectionRef.current) {\n pendingMouseUpSelectionRef.current = false;\n handleSelect(event);\n }\n });\n }\n });\n return {\n ...interactionProps,\n onTouchMove: (0, import_helpers.composeEventHandlers)(onTouchMove, interactionProps.onTouchMove),\n onTouchEnd: (0, import_helpers.composeEventHandlers)(onTouchEnd, interactionProps.onTouchEnd),\n onKeyDown: (0, import_helpers.composeEventHandlers)(onKeyDown, interactionProps.onKeyDown),\n onClick(event) {\n var _interactionProps_onClick;\n onClick === null || onClick === void 0 ? void 0 : onClick(event);\n if (event.defaultPrevented) {\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n return;\n }\n (_interactionProps_onClick = interactionProps.onClick) === null || _interactionProps_onClick === void 0 ? void 0 : _interactionProps_onClick.call(interactionProps, event);\n },\n onMouseUp: (0, import_helpers.composeEventHandlers)(onMouseUp, interactionProps.onMouseUp),\n onMouseMove: (0, import_helpers.composeEventHandlers)(onMouseMove, interactionProps.onMouseMove),\n onPress\n };\n }\n return {\n ...restProps,\n onKeyDown: (0, import_helpers.composeEventHandlers)(restProps.onKeyDown, handleKeyDown),\n onMouseMove: (0, import_helpers.composeEventHandlers)(restProps.onMouseMove, function(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n }),\n onPress: (0, import_helpers.composeEventHandlers)(restProps.onPress, handleSelect)\n };\n }, [\n allowMouseUpRef,\n allowSelectRef,\n disabled,\n handleKeyDown,\n handleSelect,\n index,\n interactions,\n restProps,\n selectTimeoutRef,\n setActiveIndexFast\n ]);\n var accessibilityProps = (0, import_selectionController.getSelectOptionProps)(mode, isSelected, disabled, import_constants.isWeb ? \"web\" : \"native\");\n var _selectContext_activeIndex;\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemContextProvider, {\n scope,\n value,\n textId: textId || \"\",\n textValue: textValueProp,\n isSelected,\n children: shouldRenderWebNative ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(\"option\", {\n value,\n disabled,\n children: props.children\n }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemFrame, {\n render: \"div\",\n ref: composedRefs,\n \"aria-labelledby\": textId,\n \"data-state\": isSelected ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : void 0,\n tabIndex: disabled ? void 0 : import_constants.isWeb && isAdapted ? index === ((_selectContext_activeIndex = selectContext.activeIndex) !== null && _selectContext_activeIndex !== void 0 ? _selectContext_activeIndex : selectContext.selectedIndex) ? 0 : -1 : -1,\n zIndex: 100,\n ...selectItemProps,\n ...accessibilityProps\n })\n });\n}, {\n disableTheme: true\n});\n//# sourceMappingURL=SelectItem.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ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U,GAAG,eAAe,qBAAoB,CAAE,UAAU,SAAS,YAAY;EACnF;CACF,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,IAAI,sBAAsB,GAAG,2BAA2B,qBAAoB,CAAE,MAAM,YAAY,UAAU,iBAAiB,QAAQ,QAAQ,QAAQ;CACnJ,IAAI;CACJ,OAAuB,iBAAC,GAAG,mBAAmB,IAAG,CAAE,2BAA2B;EAC5E;EACA;EACA,QAAQ,UAAU;EAClB,WAAW;EACX;EACA,UAAU,wBAAwC,iBAAC,GAAG,mBAAmB,IAAG,CAAE,UAAU;GACtF;GACA;GACA,UAAU,MAAM;EAClB,CAAC,IAAoB,iBAAC,GAAG,mBAAmB,IAAG,CAAE,iBAAiB;GAChE,QAAQ;GACR,KAAK;GACL,mBAAmB;GACnB,cAAc,aAAa,WAAW;GACtC,iBAAiB,WAAW,KAAK,KAAK;GACtC,UAAU,WAAW,KAAK,IAAI,iBAAiB,SAAS,YAAY,YAAY,6BAA6B,cAAc,iBAAiB,QAAQ,+BAA+B,KAAK,IAAI,6BAA6B,cAAc,iBAAiB,IAAI,CAAC,IAAI,CAAC;GAClQ,QAAQ;GACR,GAAG;GACH,GAAG;EACL,CAAC;CACH,CAAC;AACH,GAAG,EACD,cAAc,KAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"SelectItem.native.js","names":[],"sources":["cjs/SelectItem.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar SelectItem_exports = {};\n__export(SelectItem_exports, {\n SelectItem: () => SelectItem,\n SelectItemContextProvider: () => SelectItemContextProvider,\n SelectItemFrame: () => SelectItemFrame,\n useSelectItemContext: () => useSelectItemContext\n});\nmodule.exports = __toCommonJS(SelectItem_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_compose_refs = require(\"@tamagui/compose-refs\");\nvar import_adapt = require(\"@tamagui/adapt\");\nvar import_constants = require(\"@tamagui/constants\");\nvar import_core = require(\"@tamagui/core\");\nvar import_helpers = require(\"@tamagui/helpers\");\nvar React = __toESM(require(\"react\"), 1);\nvar import_context = require(\"./context\");\nvar import_selectionController = require(\"./selectionController\");\nvar ITEM_NAME = \"SelectItem\";\nvar { Provider: SelectItemContextProvider, useStyledContext: useSelectItemContext } = (0, import_core.createStyledContext)(null, ITEM_NAME);\nvar SelectItemFrame = (0, import_core.styled)(import_core.View, {\n displayName: ITEM_NAME,\n alignItems: \"center\",\n flexDirection: \"row\"\n});\nvar SelectItem = (0, import_core.createStyledHOC)(SelectItemFrame, function SelectItem2(props, forwardedRef) {\n var { scope, value, disabled: disabledProp, \"aria-disabled\": ariaDisabled, textValue: textValueProp, ...restProps } = props;\n var disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : ariaDisabled === true;\n var context = (0, import_context.useSelectItemParentContext)(scope);\n var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);\n var { registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, getItemProps, shouldRenderWebNative, setActiveIndex, lastPointerRef, moveActive, search } = context;\n var isSelected = selectedValues.includes(value);\n var pendingMouseUpSelectionRef = React.useRef(false);\n var itemNodeRef = React.useRef(null);\n var registrationRef = React.useRef(null);\n var initialRegistration = React.useRef({\n value,\n disabled,\n textValue: textValueProp\n });\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var registration = registry.registerItem(initialRegistration.current);\n registrationRef.current = registration;\n registration.setNode(itemNodeRef.current);\n return function() {\n registrationRef.current = null;\n registration.unregister();\n };\n }, [\n registry\n ]);\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.update({\n value,\n disabled,\n textValue: textValueProp\n });\n }, [\n disabled,\n textValueProp,\n value\n ]);\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(itemNodeRef.current);\n });\n var [isActive, setIsActive] = React.useState(false);\n var isActiveRef = React.useRef(false);\n React.useEffect(function() {\n var handleActiveIndex = function(i) {\n var next = i != null && registry.getIndex(value) === i;\n if (next !== isActiveRef.current) {\n isActiveRef.current = next;\n setIsActive(next);\n }\n if (next && import_constants.isWeb) {\n requestAnimationFrame(function() {\n var _itemNodeRef_current_focus, _itemNodeRef_current;\n (_itemNodeRef_current = itemNodeRef.current) === null || _itemNodeRef_current === void 0 ? void 0 : (_itemNodeRef_current_focus = _itemNodeRef_current.focus) === null || _itemNodeRef_current_focus === void 0 ? void 0 : _itemNodeRef_current_focus.call(_itemNodeRef_current);\n });\n }\n };\n var _activeIndexRef_current;\n handleActiveIndex((_activeIndexRef_current = activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current) !== null && _activeIndexRef_current !== void 0 ? _activeIndexRef_current : null);\n return activeIndexSubscribe(handleActiveIndex);\n }, [\n activeIndexRef,\n activeIndexSubscribe,\n registry,\n value\n ]);\n var textId = React.useId();\n var refCallback = React.useCallback(function(node) {\n var _registrationRef_current;\n itemNodeRef.current = node;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(node);\n }, []);\n var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, refCallback);\n var handleSelect = React.useCallback(function(event) {\n var reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : \"item-press\";\n if (disabled) return;\n var nativeEvent = (event === null || event === void 0 ? void 0 : event.nativeEvent) || event;\n selectValue(value, (0, import_core.createChangeEventDetails)(reason, nativeEvent, event === null || event === void 0 ? void 0 : event.currentTarget));\n }, [\n disabled,\n selectValue,\n value\n ]);\n var handleMouseMove = React.useCallback(function(event) {\n if (disabled) return;\n var index = registry.getIndex(value);\n if (index < 0) return;\n var last = lastPointerRef.current;\n if (event.clientX === last.x && event.clientY === last.y) return;\n last.x = event.clientX;\n last.y = event.clientY;\n setActiveIndex(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n }, [\n disabled,\n lastPointerRef,\n registry,\n setActiveIndex,\n value\n ]);\n var handleKeyDown = React.useCallback(function(event) {\n var _event_key;\n if (disabled) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n handleSelect(event, \"keyboard\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n event.stopPropagation();\n moveActive(event.key === \"ArrowDown\" ? 1 : -1, event.nativeEvent || event);\n return;\n }\n if (!getItemProps && ((_event_key = event.key) === null || _event_key === void 0 ? void 0 : _event_key.length) === 1 && !event.metaKey && !event.ctrlKey) {\n search(event.key, event.nativeEvent || event);\n }\n if (allowSelectRef) {\n allowSelectRef.current = true;\n }\n }, [\n allowSelectRef,\n disabled,\n handleSelect,\n getItemProps,\n moveActive,\n search\n ]);\n var selectItemProps = React.useMemo(function() {\n if (getItemProps) {\n var { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;\n var interactionProps = getItemProps({\n ...itemProps,\n onTouchMove() {\n allowSelectRef.current = true;\n allowMouseUpRef.current = false;\n },\n onTouchEnd() {\n allowSelectRef.current = false;\n allowMouseUpRef.current = true;\n },\n onMouseMove: handleMouseMove,\n onKeyDown: handleKeyDown,\n onClick(event) {\n if (disabled) return;\n var shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n if (shouldSelect) {\n handleSelect(event);\n }\n },\n onMouseUp(event) {\n if (disabled) return;\n if (!allowMouseUpRef.current) {\n allowMouseUpRef.current = true;\n allowSelectRef.current = true;\n return;\n }\n pendingMouseUpSelectionRef.current = allowSelectRef.current;\n clearTimeout(selectTimeoutRef.current);\n selectTimeoutRef.current = setTimeout(function() {\n allowSelectRef.current = true;\n if (pendingMouseUpSelectionRef.current) {\n pendingMouseUpSelectionRef.current = false;\n handleSelect(event);\n }\n });\n }\n });\n return {\n ...interactionProps,\n onTouchMove: (0, import_helpers.composeEventHandlers)(onTouchMove, interactionProps.onTouchMove),\n onTouchEnd: (0, import_helpers.composeEventHandlers)(onTouchEnd, interactionProps.onTouchEnd),\n onKeyDown: (0, import_helpers.composeEventHandlers)(onKeyDown, interactionProps.onKeyDown),\n onClick(event) {\n var _interactionProps_onClick;\n onClick === null || onClick === void 0 ? void 0 : onClick(event);\n if (event.defaultPrevented) {\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n return;\n }\n (_interactionProps_onClick = interactionProps.onClick) === null || _interactionProps_onClick === void 0 ? void 0 : _interactionProps_onClick.call(interactionProps, event);\n },\n onMouseUp: (0, import_helpers.composeEventHandlers)(onMouseUp, interactionProps.onMouseUp),\n onMouseMove: (0, import_helpers.composeEventHandlers)(onMouseMove, interactionProps.onMouseMove),\n onPress\n };\n }\n return {\n ...restProps,\n onKeyDown: (0, import_helpers.composeEventHandlers)(restProps.onKeyDown, handleKeyDown),\n onMouseMove: (0, import_helpers.composeEventHandlers)(restProps.onMouseMove, handleMouseMove),\n onPress: (0, import_helpers.composeEventHandlers)(restProps.onPress, handleSelect)\n };\n }, [\n allowMouseUpRef,\n allowSelectRef,\n disabled,\n handleKeyDown,\n handleMouseMove,\n handleSelect,\n getItemProps,\n restProps,\n selectTimeoutRef\n ]);\n var accessibilityProps = (0, import_selectionController.getSelectOptionProps)(mode, isSelected, disabled, import_constants.isWeb ? \"web\" : \"native\");\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemContextProvider, {\n scope,\n value,\n textId: textId || \"\",\n textValue: textValueProp,\n isSelected,\n children: shouldRenderWebNative ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(\"option\", {\n value,\n disabled,\n children: props.children\n }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemFrame, {\n render: \"div\",\n ref: composedRefs,\n \"aria-labelledby\": textId,\n \"data-state\": isSelected ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : void 0,\n tabIndex: disabled ? void 0 : import_constants.isWeb && isAdapted && (isActive || (activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current) == null && isSelected) ? 0 : -1,\n zIndex: 100,\n ...selectItemProps,\n ...accessibilityProps\n })\n });\n}, {\n disableTheme: true\n});\n//# sourceMappingURL=SelectItem.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAA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B,SAAS,cAAc,aAAa,mBAAmB,QAAQ,mBAAmB,KAAK,IAAI,KAAK,IAAI,eAAe,YAAY,QAAQ,cAAc,IAAI,CAAC;GACzM,QAAQ;GACR,GAAG;GACH,GAAG;EACL,CAAC;CACH,CAAC;AACH,GAAG,EACD,cAAc,KAChB,CAAC"}
|
|
@@ -36,7 +36,6 @@ var import_floating = require("@tamagui/floating");
|
|
|
36
36
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
37
37
|
var import_helpers = require("@tamagui/helpers");
|
|
38
38
|
var React = __toESM(require("react"), 1);
|
|
39
|
-
var import_react_dom = require("react-dom");
|
|
40
39
|
var import_context = require("./context.cjs");
|
|
41
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
41
|
const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
@@ -63,53 +62,39 @@ SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
|
63
62
|
const SelectScrollButtonImpl = React.memo((0, import_core.createStyledHOC)(SelectScrollButtonFrame, (props, forwardedRef) => {
|
|
64
63
|
const { scope, dir, partClassName, ...scrollIndicatorProps } = props;
|
|
65
64
|
const { className, onPointerEnter, onPointerLeave, ...frameProps } = scrollIndicatorProps;
|
|
66
|
-
const { open,
|
|
65
|
+
const { open, ...context } = (0, import_context.useSelectContext)(scope);
|
|
67
66
|
const floatingRef = context.floatingContext?.refs.floating;
|
|
68
|
-
const statusRef = React.useRef("idle");
|
|
69
67
|
const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
|
|
70
68
|
const frameRef = React.useRef(null);
|
|
69
|
+
const arrowRef = dir === "up" ? context.upArrowRef : context.downArrowRef;
|
|
71
70
|
const { x, y, refs, strategy } = (0, import_floating.useFloatingRaw)({
|
|
72
71
|
open: open && isVisible,
|
|
73
72
|
strategy: "fixed",
|
|
74
73
|
elements: { reference: floatingRef?.current },
|
|
75
74
|
placement: dir === "up" ? "top" : "bottom",
|
|
76
|
-
|
|
77
|
-
whileElementsMounted: (...args) => (0, import_floating.autoUpdate)(...args, { animationFrame: true })
|
|
75
|
+
whileElementsMounted: import_floating.autoUpdate
|
|
78
76
|
});
|
|
79
77
|
const setFloatingRef = React.useCallback((node) => {
|
|
80
78
|
refs.setFloating(node);
|
|
81
|
-
|
|
79
|
+
if (arrowRef) arrowRef.current = node;
|
|
80
|
+
}, [refs.setFloating, arrowRef]);
|
|
82
81
|
const composedRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, setFloatingRef);
|
|
83
82
|
React.useEffect(() => {
|
|
84
83
|
return () => cancelAnimationFrame(frameRef.current);
|
|
85
|
-
}, []);
|
|
86
|
-
if (!isVisible) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
const onScroll = (amount) => {
|
|
90
|
-
const floating = floatingRef;
|
|
91
|
-
if (!floating) return;
|
|
92
|
-
if (fallback) {
|
|
93
|
-
if (floating.current) {
|
|
94
|
-
floating.current.scrollTop -= amount;
|
|
95
|
-
(0, import_react_dom.flushSync)(() => setScrollTop(floating.current?.scrollTop ?? 0));
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
(0, import_react_dom.flushSync)(() => setInnerOffset((value) => value - amount));
|
|
99
|
-
}
|
|
100
|
-
};
|
|
84
|
+
}, [isVisible]);
|
|
101
85
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectScrollButtonFrame, {
|
|
102
86
|
ref: composedRef,
|
|
103
87
|
className: `${partClassName} ${className || ""}`.trim(),
|
|
104
88
|
"aria-hidden": true,
|
|
105
89
|
...frameProps,
|
|
90
|
+
visibility: isVisible ? "visible" : "hidden",
|
|
91
|
+
pointerEvents: isVisible ? "auto" : "none",
|
|
106
92
|
zIndex: 1e3,
|
|
107
93
|
position: strategy,
|
|
108
94
|
left: x || 0,
|
|
109
95
|
top: y || 0,
|
|
110
96
|
width: `calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`,
|
|
111
97
|
onPointerEnter: (0, import_helpers.composeEventHandlers)(onPointerEnter, () => {
|
|
112
|
-
statusRef.current = "active";
|
|
113
98
|
let prevNow = Date.now();
|
|
114
99
|
function frame() {
|
|
115
100
|
const element = floatingRef?.current;
|
|
@@ -120,7 +105,7 @@ const SelectScrollButtonImpl = React.memo((0, import_core.createStyledHOC)(Selec
|
|
|
120
105
|
const pixelsToScroll = msElapsed / 2;
|
|
121
106
|
const remainingPixels = dir === "up" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;
|
|
122
107
|
const scrollRemaining = dir === "up" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;
|
|
123
|
-
|
|
108
|
+
element.scrollTop += dir === "up" ? -Math.min(pixelsToScroll, remainingPixels) : Math.min(pixelsToScroll, remainingPixels);
|
|
124
109
|
if (scrollRemaining) {
|
|
125
110
|
frameRef.current = requestAnimationFrame(frame);
|
|
126
111
|
}
|
|
@@ -130,7 +115,6 @@ const SelectScrollButtonImpl = React.memo((0, import_core.createStyledHOC)(Selec
|
|
|
130
115
|
frameRef.current = requestAnimationFrame(frame);
|
|
131
116
|
}),
|
|
132
117
|
onPointerLeave: (0, import_helpers.composeEventHandlers)(onPointerLeave, () => {
|
|
133
|
-
statusRef.current = "idle";
|
|
134
118
|
cancelAnimationFrame(frameRef.current);
|
|
135
119
|
})
|
|
136
120
|
});
|