@huin-core/react-select 1.0.5 → 1.0.7
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/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +298 -323
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +298 -323
- package/dist/index.mjs.map +3 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,6 @@ import { createPopperScope } from "@huin-core/react-popper";
|
|
|
12
12
|
import { useControllableState } from "@huin-core/react-use-controllable-state";
|
|
13
13
|
import { usePrevious } from "@huin-core/react-use-previous";
|
|
14
14
|
import { VisuallyHidden } from "@huin-core/react-visually-hidden";
|
|
15
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
15
|
var SELECT_NAME = "Select";
|
|
17
16
|
var [Collection, useCollection, createCollectionScope] = createCollection(SELECT_NAME);
|
|
18
17
|
var [createSelectContext, createSelectScope] = createContextScope(
|
|
@@ -63,7 +62,7 @@ var Select = (props) => {
|
|
|
63
62
|
/* @__PURE__ */ new Set()
|
|
64
63
|
);
|
|
65
64
|
const nativeSelectKey = Array.from(nativeOptionsSet).map((option) => option.props.value).join(";");
|
|
66
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ React.createElement(PopperPrimitive.Root, { ...popperScope }, /* @__PURE__ */ React.createElement(
|
|
67
66
|
SelectProvider,
|
|
68
67
|
{
|
|
69
68
|
required,
|
|
@@ -81,46 +80,42 @@ var Select = (props) => {
|
|
|
81
80
|
onOpenChange: setOpen,
|
|
82
81
|
dir: direction,
|
|
83
82
|
triggerPointerDownPosRef,
|
|
84
|
-
disabled
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
) : null
|
|
121
|
-
]
|
|
122
|
-
}
|
|
123
|
-
) });
|
|
83
|
+
disabled
|
|
84
|
+
},
|
|
85
|
+
/* @__PURE__ */ React.createElement(Collection.Provider, { scope: __scopeSelect }, /* @__PURE__ */ React.createElement(
|
|
86
|
+
SelectNativeOptionsProvider,
|
|
87
|
+
{
|
|
88
|
+
scope: props.__scopeSelect,
|
|
89
|
+
onNativeOptionAdd: React.useCallback((option) => {
|
|
90
|
+
setNativeOptionsSet((prev) => new Set(prev).add(option));
|
|
91
|
+
}, []),
|
|
92
|
+
onNativeOptionRemove: React.useCallback((option) => {
|
|
93
|
+
setNativeOptionsSet((prev) => {
|
|
94
|
+
const optionsSet = new Set(prev);
|
|
95
|
+
optionsSet.delete(option);
|
|
96
|
+
return optionsSet;
|
|
97
|
+
});
|
|
98
|
+
}, [])
|
|
99
|
+
},
|
|
100
|
+
children
|
|
101
|
+
)),
|
|
102
|
+
isFormControl ? /* @__PURE__ */ React.createElement(
|
|
103
|
+
BubbleSelect,
|
|
104
|
+
{
|
|
105
|
+
key: nativeSelectKey,
|
|
106
|
+
"aria-hidden": true,
|
|
107
|
+
required,
|
|
108
|
+
tabIndex: -1,
|
|
109
|
+
name,
|
|
110
|
+
autoComplete,
|
|
111
|
+
value,
|
|
112
|
+
onChange: (event) => setValue(event.target.value),
|
|
113
|
+
disabled
|
|
114
|
+
},
|
|
115
|
+
value === void 0 ? /* @__PURE__ */ React.createElement("option", { value: "" }) : null,
|
|
116
|
+
Array.from(nativeOptionsSet)
|
|
117
|
+
) : null
|
|
118
|
+
));
|
|
124
119
|
};
|
|
125
120
|
Select.displayName = SELECT_NAME;
|
|
126
121
|
var BubbleSelect = React.forwardRef((props, forwardedRef) => {
|
|
@@ -142,7 +137,7 @@ var BubbleSelect = React.forwardRef((props, forwardedRef) => {
|
|
|
142
137
|
select.dispatchEvent(event);
|
|
143
138
|
}
|
|
144
139
|
}, [prevValue, value]);
|
|
145
|
-
return /* @__PURE__ */
|
|
140
|
+
return /* @__PURE__ */ React.createElement(VisuallyHidden, { asChild: true }, /* @__PURE__ */ React.createElement("select", { ...selectProps, ref: composedRefs, defaultValue: value }));
|
|
146
141
|
});
|
|
147
142
|
BubbleSelect.displayName = "BubbleSelect";
|
|
148
143
|
var Root2 = Select;
|
|
@@ -163,7 +158,6 @@ import React2 from "react";
|
|
|
163
158
|
import { Primitive } from "@huin-core/react-primitive";
|
|
164
159
|
import { useComposedRefs as useComposedRefs2 } from "@huin-core/react-compose-refs";
|
|
165
160
|
import { composeEventHandlers } from "@huin-core/primitive";
|
|
166
|
-
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
167
161
|
var CONTENT_NAME = "SelectContent";
|
|
168
162
|
var [SelectViewportProvider, useSelectViewportContext] = createSelectContext(CONTENT_NAME, {});
|
|
169
163
|
var VIEWPORT_NAME = "SelectViewport";
|
|
@@ -179,64 +173,61 @@ var SelectViewport = React2.forwardRef((props, forwardedRef) => {
|
|
|
179
173
|
contentContext.onViewportChange
|
|
180
174
|
);
|
|
181
175
|
const prevScrollTopRef = React2.useRef(0);
|
|
182
|
-
return /* @__PURE__ */
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
{
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
|
230
|
-
contentWrapper.style.justifyContent = "flex-end";
|
|
231
|
-
}
|
|
176
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
177
|
+
"style",
|
|
178
|
+
{
|
|
179
|
+
dangerouslySetInnerHTML: {
|
|
180
|
+
__html: `[data-huin-core-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-huin-core-select-viewport]::-webkit-scrollbar{display:none}`
|
|
181
|
+
},
|
|
182
|
+
nonce
|
|
183
|
+
}
|
|
184
|
+
), /* @__PURE__ */ React2.createElement(Collection.Slot, { scope: __scopeSelect }, /* @__PURE__ */ React2.createElement(
|
|
185
|
+
Primitive.div,
|
|
186
|
+
{
|
|
187
|
+
"data-huin-core-select-viewport": "",
|
|
188
|
+
role: "presentation",
|
|
189
|
+
...viewportProps,
|
|
190
|
+
ref: composedRefs,
|
|
191
|
+
style: {
|
|
192
|
+
// we use position: 'relative' here on the `viewport` so that when we call
|
|
193
|
+
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
|
|
194
|
+
// (independent of the scrollUpButton).
|
|
195
|
+
position: "relative",
|
|
196
|
+
flex: 1,
|
|
197
|
+
overflow: "auto",
|
|
198
|
+
...viewportProps.style
|
|
199
|
+
},
|
|
200
|
+
onScroll: composeEventHandlers(viewportProps.onScroll, (event) => {
|
|
201
|
+
const viewport = event.currentTarget;
|
|
202
|
+
const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
|
|
203
|
+
if (shouldExpandOnScrollRef?.current && contentWrapper) {
|
|
204
|
+
const scrolledBy = Math.abs(
|
|
205
|
+
prevScrollTopRef.current - viewport.scrollTop
|
|
206
|
+
);
|
|
207
|
+
if (scrolledBy > 0) {
|
|
208
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
209
|
+
const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
|
|
210
|
+
const cssHeight = parseFloat(contentWrapper.style.height);
|
|
211
|
+
const prevHeight = Math.max(cssMinHeight, cssHeight);
|
|
212
|
+
if (prevHeight < availableHeight) {
|
|
213
|
+
const nextHeight = prevHeight + scrolledBy;
|
|
214
|
+
const clampedNextHeight = Math.min(
|
|
215
|
+
availableHeight,
|
|
216
|
+
nextHeight
|
|
217
|
+
);
|
|
218
|
+
const heightDiff = nextHeight - clampedNextHeight;
|
|
219
|
+
contentWrapper.style.height = clampedNextHeight + "px";
|
|
220
|
+
if (contentWrapper.style.bottom === "0px") {
|
|
221
|
+
viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
|
222
|
+
contentWrapper.style.justifyContent = "flex-end";
|
|
232
223
|
}
|
|
233
224
|
}
|
|
234
225
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
226
|
+
}
|
|
227
|
+
prevScrollTopRef.current = viewport.scrollTop;
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
)));
|
|
240
231
|
});
|
|
241
232
|
SelectViewport.displayName = VIEWPORT_NAME;
|
|
242
233
|
|
|
@@ -252,7 +243,6 @@ import { composeEventHandlers as composeEventHandlers2 } from "@huin-core/primit
|
|
|
252
243
|
import { clamp } from "@huin-core/number";
|
|
253
244
|
import * as PopperPrimitive2 from "@huin-core/react-popper";
|
|
254
245
|
import { useCallbackRef } from "@huin-core/react-use-callback-ref";
|
|
255
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
256
246
|
var CONTENT_NAME2 = "SelectContent";
|
|
257
247
|
var SelectContent = React3.forwardRef(
|
|
258
248
|
(props, forwardedRef) => {
|
|
@@ -264,11 +254,11 @@ var SelectContent = React3.forwardRef(
|
|
|
264
254
|
if (!context.open) {
|
|
265
255
|
const frag = fragment;
|
|
266
256
|
return frag ? ReactDOM.createPortal(
|
|
267
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ React3.createElement(SelectContentProvider, { scope: props.__scopeSelect }, /* @__PURE__ */ React3.createElement(Collection.Slot, { scope: props.__scopeSelect }, /* @__PURE__ */ React3.createElement("div", null, props.children))),
|
|
268
258
|
frag
|
|
269
259
|
) : null;
|
|
270
260
|
}
|
|
271
|
-
return /* @__PURE__ */
|
|
261
|
+
return /* @__PURE__ */ React3.createElement(SelectContentImpl, { ...props, ref: forwardedRef });
|
|
272
262
|
}
|
|
273
263
|
);
|
|
274
264
|
SelectContent.displayName = CONTENT_NAME2;
|
|
@@ -439,7 +429,7 @@ var SelectContentImpl = React3.forwardRef((props, forwardedRef) => {
|
|
|
439
429
|
hideWhenDetached,
|
|
440
430
|
avoidCollisions
|
|
441
431
|
} : {};
|
|
442
|
-
return /* @__PURE__ */
|
|
432
|
+
return /* @__PURE__ */ React3.createElement(
|
|
443
433
|
SelectContentProvider,
|
|
444
434
|
{
|
|
445
435
|
scope: __scopeSelect,
|
|
@@ -454,81 +444,81 @@ var SelectContentImpl = React3.forwardRef((props, forwardedRef) => {
|
|
|
454
444
|
selectedItemText,
|
|
455
445
|
position,
|
|
456
446
|
isPositioned,
|
|
457
|
-
searchRef
|
|
458
|
-
|
|
459
|
-
|
|
447
|
+
searchRef
|
|
448
|
+
},
|
|
449
|
+
/* @__PURE__ */ React3.createElement(RemoveScroll, { as: Slot, allowPinchZoom: true }, /* @__PURE__ */ React3.createElement(
|
|
450
|
+
FocusScope,
|
|
451
|
+
{
|
|
452
|
+
asChild: true,
|
|
453
|
+
trapped: context.open,
|
|
454
|
+
onMountAutoFocus: (event) => {
|
|
455
|
+
event.preventDefault();
|
|
456
|
+
},
|
|
457
|
+
onUnmountAutoFocus: composeEventHandlers2(
|
|
458
|
+
onCloseAutoFocus,
|
|
459
|
+
(event) => {
|
|
460
|
+
context.trigger?.focus({ preventScroll: true });
|
|
461
|
+
event.preventDefault();
|
|
462
|
+
}
|
|
463
|
+
)
|
|
464
|
+
},
|
|
465
|
+
/* @__PURE__ */ React3.createElement(
|
|
466
|
+
DismissableLayer,
|
|
460
467
|
{
|
|
461
468
|
asChild: true,
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
(
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
handleTypeaheadSearch(event.key);
|
|
509
|
-
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
|
|
510
|
-
const items = getItems().filter((item) => !item.disabled);
|
|
511
|
-
let candidateNodes = items.map((item) => item.ref.current);
|
|
512
|
-
if (["ArrowUp", "End"].includes(event.key)) {
|
|
513
|
-
candidateNodes = candidateNodes.slice().reverse();
|
|
514
|
-
}
|
|
515
|
-
if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
516
|
-
const currentElement = event.target;
|
|
517
|
-
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
518
|
-
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
519
|
-
}
|
|
520
|
-
setTimeout(() => focusFirst(candidateNodes));
|
|
521
|
-
event.preventDefault();
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
)
|
|
469
|
+
disableOutsidePointerEvents: true,
|
|
470
|
+
onEscapeKeyDown,
|
|
471
|
+
onPointerDownOutside,
|
|
472
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
473
|
+
onDismiss: () => context.onOpenChange(false)
|
|
474
|
+
},
|
|
475
|
+
/* @__PURE__ */ React3.createElement(
|
|
476
|
+
SelectPosition,
|
|
477
|
+
{
|
|
478
|
+
role: "listbox",
|
|
479
|
+
id: context.contentId,
|
|
480
|
+
"data-state": context.open ? "open" : "closed",
|
|
481
|
+
dir: context.dir,
|
|
482
|
+
onContextMenu: (event) => event.preventDefault(),
|
|
483
|
+
...contentProps,
|
|
484
|
+
...popperContentProps,
|
|
485
|
+
onPlaced: () => setIsPositioned(true),
|
|
486
|
+
ref: composedRefs,
|
|
487
|
+
style: {
|
|
488
|
+
// flex layout so we can place the scroll buttons properly
|
|
489
|
+
display: "flex",
|
|
490
|
+
flexDirection: "column",
|
|
491
|
+
// reset the outline by default as the content MAY get focused
|
|
492
|
+
outline: "none",
|
|
493
|
+
...contentProps.style
|
|
494
|
+
},
|
|
495
|
+
onKeyDown: composeEventHandlers2(
|
|
496
|
+
contentProps.onKeyDown,
|
|
497
|
+
(event) => {
|
|
498
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
499
|
+
if (event.key === "Tab") event.preventDefault();
|
|
500
|
+
if (!isModifierKey && event.key.length === 1)
|
|
501
|
+
handleTypeaheadSearch(event.key);
|
|
502
|
+
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
|
|
503
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
504
|
+
let candidateNodes = items.map((item) => item.ref.current);
|
|
505
|
+
if (["ArrowUp", "End"].includes(event.key)) {
|
|
506
|
+
candidateNodes = candidateNodes.slice().reverse();
|
|
507
|
+
}
|
|
508
|
+
if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
509
|
+
const currentElement = event.target;
|
|
510
|
+
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
511
|
+
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
512
|
+
}
|
|
513
|
+
setTimeout(() => focusFirst(candidateNodes));
|
|
514
|
+
event.preventDefault();
|
|
525
515
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
)
|
|
531
|
-
|
|
516
|
+
}
|
|
517
|
+
)
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
)
|
|
521
|
+
))
|
|
532
522
|
);
|
|
533
523
|
});
|
|
534
524
|
SelectContentImpl.displayName = CONTENT_IMPL_NAME;
|
|
@@ -662,41 +652,41 @@ var SelectItemAlignedPosition = React3.forwardRef((props, forwardedRef) => {
|
|
|
662
652
|
},
|
|
663
653
|
[position, focusSelectedItem]
|
|
664
654
|
);
|
|
665
|
-
return /* @__PURE__ */
|
|
655
|
+
return /* @__PURE__ */ React3.createElement(
|
|
666
656
|
SelectViewportProvider,
|
|
667
657
|
{
|
|
668
658
|
scope: __scopeSelect,
|
|
669
659
|
contentWrapper,
|
|
670
660
|
shouldExpandOnScrollRef,
|
|
671
|
-
onScrollButtonChange: handleScrollButtonChange
|
|
672
|
-
|
|
673
|
-
|
|
661
|
+
onScrollButtonChange: handleScrollButtonChange
|
|
662
|
+
},
|
|
663
|
+
/* @__PURE__ */ React3.createElement(
|
|
664
|
+
"div",
|
|
665
|
+
{
|
|
666
|
+
ref: setContentWrapper,
|
|
667
|
+
style: {
|
|
668
|
+
display: "flex",
|
|
669
|
+
flexDirection: "column",
|
|
670
|
+
position: "fixed",
|
|
671
|
+
zIndex: contentZIndex
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
/* @__PURE__ */ React3.createElement(
|
|
675
|
+
Primitive2.div,
|
|
674
676
|
{
|
|
675
|
-
|
|
677
|
+
...popperProps,
|
|
678
|
+
ref: composedRefs,
|
|
676
679
|
style: {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
{
|
|
685
|
-
...popperProps,
|
|
686
|
-
ref: composedRefs,
|
|
687
|
-
style: {
|
|
688
|
-
// When we get the height of the content, it includes borders. If we were to set
|
|
689
|
-
// the height without having `boxSizing: 'border-box'` it would be too big.
|
|
690
|
-
boxSizing: "border-box",
|
|
691
|
-
// We need to ensure the content doesn't get taller than the wrapper
|
|
692
|
-
maxHeight: "100%",
|
|
693
|
-
...popperProps.style
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
)
|
|
680
|
+
// When we get the height of the content, it includes borders. If we were to set
|
|
681
|
+
// the height without having `boxSizing: 'border-box'` it would be too big.
|
|
682
|
+
boxSizing: "border-box",
|
|
683
|
+
// We need to ensure the content doesn't get taller than the wrapper
|
|
684
|
+
maxHeight: "100%",
|
|
685
|
+
...popperProps.style
|
|
686
|
+
}
|
|
697
687
|
}
|
|
698
688
|
)
|
|
699
|
-
|
|
689
|
+
)
|
|
700
690
|
);
|
|
701
691
|
});
|
|
702
692
|
SelectItemAlignedPosition.displayName = ITEM_ALIGNED_POSITION_NAME;
|
|
@@ -709,7 +699,7 @@ var SelectPopperPosition = React3.forwardRef((props, forwardedRef) => {
|
|
|
709
699
|
...popperProps
|
|
710
700
|
} = props;
|
|
711
701
|
const popperScope = usePopperScope(__scopeSelect);
|
|
712
|
-
return /* @__PURE__ */
|
|
702
|
+
return /* @__PURE__ */ React3.createElement(
|
|
713
703
|
PopperPrimitive2.Content,
|
|
714
704
|
{
|
|
715
705
|
...popperScope,
|
|
@@ -785,7 +775,6 @@ import React4 from "react";
|
|
|
785
775
|
import { Primitive as Primitive3 } from "@huin-core/react-primitive";
|
|
786
776
|
import { useComposedRefs as useComposedRefs4 } from "@huin-core/react-compose-refs";
|
|
787
777
|
import { useLayoutEffect as useLayoutEffect2 } from "@huin-core/react-use-layout-effect";
|
|
788
|
-
import { Fragment as Fragment2, jsx as jsx4 } from "react/jsx-runtime";
|
|
789
778
|
var VALUE_NAME = "SelectValue";
|
|
790
779
|
var SelectValue = React4.forwardRef(
|
|
791
780
|
(props, forwardedRef) => {
|
|
@@ -800,14 +789,14 @@ var SelectValue = React4.forwardRef(
|
|
|
800
789
|
useLayoutEffect2(() => {
|
|
801
790
|
onValueNodeHasChildrenChange(hasChildren);
|
|
802
791
|
}, [onValueNodeHasChildrenChange, hasChildren]);
|
|
803
|
-
return /* @__PURE__ */
|
|
792
|
+
return /* @__PURE__ */ React4.createElement(
|
|
804
793
|
Primitive3.span,
|
|
805
794
|
{
|
|
806
795
|
...valueProps,
|
|
807
796
|
ref: composedRefs,
|
|
808
|
-
style: { pointerEvents: "none" }
|
|
809
|
-
|
|
810
|
-
|
|
797
|
+
style: { pointerEvents: "none" }
|
|
798
|
+
},
|
|
799
|
+
shouldShowPlaceholder(context.value) ? /* @__PURE__ */ React4.createElement(React4.Fragment, null, placeholder) : children
|
|
811
800
|
);
|
|
812
801
|
}
|
|
813
802
|
);
|
|
@@ -818,7 +807,6 @@ function shouldShowPlaceholder(value) {
|
|
|
818
807
|
|
|
819
808
|
// packages/react/select/src/SelectTrigger.tsx
|
|
820
809
|
import { composeEventHandlers as composeEventHandlers3 } from "@huin-core/primitive";
|
|
821
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
822
810
|
var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
|
|
823
811
|
var TRIGGER_NAME = "SelectTrigger";
|
|
824
812
|
var SelectTrigger = React5.forwardRef((props, forwardedRef) => {
|
|
@@ -853,7 +841,7 @@ var SelectTrigger = React5.forwardRef((props, forwardedRef) => {
|
|
|
853
841
|
};
|
|
854
842
|
}
|
|
855
843
|
};
|
|
856
|
-
return /* @__PURE__ */
|
|
844
|
+
return /* @__PURE__ */ React5.createElement(PopperPrimitive3.Anchor, { asChild: true, ...popperScope }, /* @__PURE__ */ React5.createElement(
|
|
857
845
|
Primitive4.button,
|
|
858
846
|
{
|
|
859
847
|
type: "button",
|
|
@@ -897,44 +885,42 @@ var SelectTrigger = React5.forwardRef((props, forwardedRef) => {
|
|
|
897
885
|
}
|
|
898
886
|
})
|
|
899
887
|
}
|
|
900
|
-
)
|
|
888
|
+
));
|
|
901
889
|
});
|
|
902
890
|
SelectTrigger.displayName = TRIGGER_NAME;
|
|
903
891
|
|
|
904
892
|
// packages/react/select/src/SelectIcon.tsx
|
|
905
893
|
import React6 from "react";
|
|
906
894
|
import { Primitive as Primitive5 } from "@huin-core/react-primitive";
|
|
907
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
908
895
|
var ICON_NAME = "SelectIcon";
|
|
909
896
|
var SelectIcon = React6.forwardRef(
|
|
910
897
|
(props, forwardedRef) => {
|
|
911
898
|
const { __scopeSelect, children, ...iconProps } = props;
|
|
912
|
-
return /* @__PURE__ */
|
|
899
|
+
return /* @__PURE__ */ React6.createElement(Primitive5.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef }, children || "\u25BC");
|
|
913
900
|
}
|
|
914
901
|
);
|
|
915
902
|
SelectIcon.displayName = ICON_NAME;
|
|
916
903
|
|
|
917
904
|
// packages/react/select/src/SelectPortal.tsx
|
|
905
|
+
import React7 from "react";
|
|
918
906
|
import { Portal as PortalPrimitive } from "@huin-core/react-portal";
|
|
919
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
920
907
|
var PORTAL_NAME = "SelectPortal";
|
|
921
908
|
var SelectPortal = (props) => {
|
|
922
|
-
return /* @__PURE__ */
|
|
909
|
+
return /* @__PURE__ */ React7.createElement(PortalPrimitive, { asChild: true, ...props });
|
|
923
910
|
};
|
|
924
911
|
SelectPortal.displayName = PORTAL_NAME;
|
|
925
912
|
|
|
926
913
|
// packages/react/select/src/SelectGroup.tsx
|
|
927
|
-
import
|
|
914
|
+
import React8 from "react";
|
|
928
915
|
import { Primitive as Primitive6 } from "@huin-core/react-primitive";
|
|
929
916
|
import { useId as useId2 } from "@huin-core/react-id";
|
|
930
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
931
917
|
var GROUP_NAME = "SelectGroup";
|
|
932
918
|
var [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
|
|
933
|
-
var SelectGroup =
|
|
919
|
+
var SelectGroup = React8.forwardRef(
|
|
934
920
|
(props, forwardedRef) => {
|
|
935
921
|
const { __scopeSelect, ...groupProps } = props;
|
|
936
922
|
const groupId = useId2();
|
|
937
|
-
return /* @__PURE__ */
|
|
923
|
+
return /* @__PURE__ */ React8.createElement(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId }, /* @__PURE__ */ React8.createElement(
|
|
938
924
|
Primitive6.div,
|
|
939
925
|
{
|
|
940
926
|
role: "group",
|
|
@@ -942,36 +928,34 @@ var SelectGroup = React7.forwardRef(
|
|
|
942
928
|
...groupProps,
|
|
943
929
|
ref: forwardedRef
|
|
944
930
|
}
|
|
945
|
-
)
|
|
931
|
+
));
|
|
946
932
|
}
|
|
947
933
|
);
|
|
948
934
|
SelectGroup.displayName = GROUP_NAME;
|
|
949
935
|
|
|
950
936
|
// packages/react/select/src/SelectLabel.tsx
|
|
951
|
-
import
|
|
937
|
+
import React9 from "react";
|
|
952
938
|
import { Primitive as Primitive7 } from "@huin-core/react-primitive";
|
|
953
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
954
939
|
var LABEL_NAME = "SelectLabel";
|
|
955
|
-
var SelectLabel =
|
|
940
|
+
var SelectLabel = React9.forwardRef(
|
|
956
941
|
(props, forwardedRef) => {
|
|
957
942
|
const { __scopeSelect, ...labelProps } = props;
|
|
958
943
|
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
959
|
-
return /* @__PURE__ */
|
|
944
|
+
return /* @__PURE__ */ React9.createElement(Primitive7.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
|
|
960
945
|
}
|
|
961
946
|
);
|
|
962
947
|
SelectLabel.displayName = LABEL_NAME;
|
|
963
948
|
|
|
964
949
|
// packages/react/select/src/SelectItem.tsx
|
|
965
|
-
import
|
|
950
|
+
import React10 from "react";
|
|
966
951
|
import { Primitive as Primitive8 } from "@huin-core/react-primitive";
|
|
967
952
|
import { useComposedRefs as useComposedRefs6 } from "@huin-core/react-compose-refs";
|
|
968
953
|
import { useId as useId3 } from "@huin-core/react-id";
|
|
969
954
|
import { composeEventHandlers as composeEventHandlers4 } from "@huin-core/primitive";
|
|
970
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
971
955
|
var SELECTION_KEYS = [" ", "Enter"];
|
|
972
956
|
var ITEM_NAME = "SelectItem";
|
|
973
957
|
var [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
|
974
|
-
var SelectItem =
|
|
958
|
+
var SelectItem = React10.forwardRef(
|
|
975
959
|
(props, forwardedRef) => {
|
|
976
960
|
const {
|
|
977
961
|
__scopeSelect,
|
|
@@ -983,14 +967,14 @@ var SelectItem = React9.forwardRef(
|
|
|
983
967
|
const context = useSelectContext(ITEM_NAME, __scopeSelect);
|
|
984
968
|
const contentContext = useSelectContentContext(ITEM_NAME, __scopeSelect);
|
|
985
969
|
const isSelected = context.value === value;
|
|
986
|
-
const [textValue, setTextValue] =
|
|
987
|
-
const [isFocused, setIsFocused] =
|
|
970
|
+
const [textValue, setTextValue] = React10.useState(textValueProp ?? "");
|
|
971
|
+
const [isFocused, setIsFocused] = React10.useState(false);
|
|
988
972
|
const composedRefs = useComposedRefs6(
|
|
989
973
|
forwardedRef,
|
|
990
974
|
(node) => contentContext.itemRefCallback?.(node, value, disabled)
|
|
991
975
|
);
|
|
992
976
|
const textId = useId3();
|
|
993
|
-
const pointerTypeRef =
|
|
977
|
+
const pointerTypeRef = React10.useRef("touch");
|
|
994
978
|
const handleSelect = () => {
|
|
995
979
|
if (!disabled) {
|
|
996
980
|
context.onValueChange(value);
|
|
@@ -1002,7 +986,7 @@ var SelectItem = React9.forwardRef(
|
|
|
1002
986
|
"A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
|
|
1003
987
|
);
|
|
1004
988
|
}
|
|
1005
|
-
return /* @__PURE__ */
|
|
989
|
+
return /* @__PURE__ */ React10.createElement(
|
|
1006
990
|
SelectItemContextProvider,
|
|
1007
991
|
{
|
|
1008
992
|
scope: __scopeSelect,
|
|
@@ -1010,78 +994,77 @@ var SelectItem = React9.forwardRef(
|
|
|
1010
994
|
disabled,
|
|
1011
995
|
textId,
|
|
1012
996
|
isSelected,
|
|
1013
|
-
onItemTextChange:
|
|
997
|
+
onItemTextChange: React10.useCallback((node) => {
|
|
1014
998
|
setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? "").trim());
|
|
1015
|
-
}, [])
|
|
1016
|
-
|
|
1017
|
-
|
|
999
|
+
}, [])
|
|
1000
|
+
},
|
|
1001
|
+
/* @__PURE__ */ React10.createElement(
|
|
1002
|
+
Collection.ItemSlot,
|
|
1003
|
+
{
|
|
1004
|
+
scope: __scopeSelect,
|
|
1005
|
+
value,
|
|
1006
|
+
disabled,
|
|
1007
|
+
textValue
|
|
1008
|
+
},
|
|
1009
|
+
/* @__PURE__ */ React10.createElement(
|
|
1010
|
+
Primitive8.div,
|
|
1018
1011
|
{
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
}),
|
|
1047
|
-
onPointerMove: composeEventHandlers4(itemProps.onPointerMove, (event) => {
|
|
1048
|
-
pointerTypeRef.current = event.pointerType;
|
|
1049
|
-
if (disabled) {
|
|
1050
|
-
contentContext.onItemLeave?.();
|
|
1051
|
-
} else if (pointerTypeRef.current === "mouse") {
|
|
1052
|
-
event.currentTarget.focus({ preventScroll: true });
|
|
1053
|
-
}
|
|
1054
|
-
}),
|
|
1055
|
-
onPointerLeave: composeEventHandlers4(itemProps.onPointerLeave, (event) => {
|
|
1056
|
-
if (event.currentTarget === document.activeElement) {
|
|
1057
|
-
contentContext.onItemLeave?.();
|
|
1058
|
-
}
|
|
1059
|
-
}),
|
|
1060
|
-
onKeyDown: composeEventHandlers4(itemProps.onKeyDown, (event) => {
|
|
1061
|
-
const isTypingAhead = contentContext.searchRef?.current !== "";
|
|
1062
|
-
if (isTypingAhead && event.key === " ") return;
|
|
1063
|
-
if (SELECTION_KEYS.includes(event.key)) handleSelect();
|
|
1064
|
-
if (event.key === " ") event.preventDefault();
|
|
1065
|
-
})
|
|
1012
|
+
role: "option",
|
|
1013
|
+
"aria-labelledby": textId,
|
|
1014
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
1015
|
+
"aria-selected": isSelected && isFocused,
|
|
1016
|
+
"data-state": isSelected ? "checked" : "unchecked",
|
|
1017
|
+
"aria-disabled": disabled || void 0,
|
|
1018
|
+
"data-disabled": disabled ? "" : void 0,
|
|
1019
|
+
tabIndex: disabled ? void 0 : -1,
|
|
1020
|
+
...itemProps,
|
|
1021
|
+
ref: composedRefs,
|
|
1022
|
+
onFocus: composeEventHandlers4(itemProps.onFocus, () => setIsFocused(true)),
|
|
1023
|
+
onBlur: composeEventHandlers4(itemProps.onBlur, () => setIsFocused(false)),
|
|
1024
|
+
onClick: composeEventHandlers4(itemProps.onClick, () => {
|
|
1025
|
+
if (pointerTypeRef.current !== "mouse") handleSelect();
|
|
1026
|
+
}),
|
|
1027
|
+
onPointerUp: composeEventHandlers4(itemProps.onPointerUp, () => {
|
|
1028
|
+
if (pointerTypeRef.current === "mouse") handleSelect();
|
|
1029
|
+
}),
|
|
1030
|
+
onPointerDown: composeEventHandlers4(itemProps.onPointerDown, (event) => {
|
|
1031
|
+
pointerTypeRef.current = event.pointerType;
|
|
1032
|
+
}),
|
|
1033
|
+
onPointerMove: composeEventHandlers4(itemProps.onPointerMove, (event) => {
|
|
1034
|
+
pointerTypeRef.current = event.pointerType;
|
|
1035
|
+
if (disabled) {
|
|
1036
|
+
contentContext.onItemLeave?.();
|
|
1037
|
+
} else if (pointerTypeRef.current === "mouse") {
|
|
1038
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
1066
1039
|
}
|
|
1067
|
-
)
|
|
1040
|
+
}),
|
|
1041
|
+
onPointerLeave: composeEventHandlers4(itemProps.onPointerLeave, (event) => {
|
|
1042
|
+
if (event.currentTarget === document.activeElement) {
|
|
1043
|
+
contentContext.onItemLeave?.();
|
|
1044
|
+
}
|
|
1045
|
+
}),
|
|
1046
|
+
onKeyDown: composeEventHandlers4(itemProps.onKeyDown, (event) => {
|
|
1047
|
+
const isTypingAhead = contentContext.searchRef?.current !== "";
|
|
1048
|
+
if (isTypingAhead && event.key === " ") return;
|
|
1049
|
+
if (SELECTION_KEYS.includes(event.key)) handleSelect();
|
|
1050
|
+
if (event.key === " ") event.preventDefault();
|
|
1051
|
+
})
|
|
1068
1052
|
}
|
|
1069
1053
|
)
|
|
1070
|
-
|
|
1054
|
+
)
|
|
1071
1055
|
);
|
|
1072
1056
|
}
|
|
1073
1057
|
);
|
|
1074
1058
|
SelectItem.displayName = ITEM_NAME;
|
|
1075
1059
|
|
|
1076
1060
|
// packages/react/select/src/SelectItemText.tsx
|
|
1077
|
-
import
|
|
1061
|
+
import React11 from "react";
|
|
1078
1062
|
import { Primitive as Primitive9 } from "@huin-core/react-primitive";
|
|
1079
1063
|
import { useComposedRefs as useComposedRefs7 } from "@huin-core/react-compose-refs";
|
|
1080
1064
|
import { useLayoutEffect as useLayoutEffect3 } from "@huin-core/react-use-layout-effect";
|
|
1081
1065
|
import ReactDOM2 from "react-dom";
|
|
1082
|
-
import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1083
1066
|
var ITEM_TEXT_NAME = "SelectItemText";
|
|
1084
|
-
var SelectItemText =
|
|
1067
|
+
var SelectItemText = React11.forwardRef((props, forwardedRef) => {
|
|
1085
1068
|
const { __scopeSelect, className, style, ...itemTextProps } = props;
|
|
1086
1069
|
const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
1087
1070
|
const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
@@ -1090,7 +1073,7 @@ var SelectItemText = React10.forwardRef((props, forwardedRef) => {
|
|
|
1090
1073
|
ITEM_TEXT_NAME,
|
|
1091
1074
|
__scopeSelect
|
|
1092
1075
|
);
|
|
1093
|
-
const [itemTextNode, setItemTextNode] =
|
|
1076
|
+
const [itemTextNode, setItemTextNode] = React11.useState(null);
|
|
1094
1077
|
const composedRefs = useComposedRefs7(
|
|
1095
1078
|
forwardedRef,
|
|
1096
1079
|
(node) => setItemTextNode(node),
|
|
@@ -1102,15 +1085,15 @@ var SelectItemText = React10.forwardRef((props, forwardedRef) => {
|
|
|
1102
1085
|
)
|
|
1103
1086
|
);
|
|
1104
1087
|
const textContent = itemTextNode?.textContent;
|
|
1105
|
-
const nativeOption =
|
|
1106
|
-
() => /* @__PURE__ */
|
|
1088
|
+
const nativeOption = React11.useMemo(
|
|
1089
|
+
() => /* @__PURE__ */ React11.createElement(
|
|
1107
1090
|
"option",
|
|
1108
1091
|
{
|
|
1092
|
+
key: itemContext.value,
|
|
1109
1093
|
value: itemContext.value,
|
|
1110
|
-
disabled: itemContext.disabled
|
|
1111
|
-
children: textContent
|
|
1094
|
+
disabled: itemContext.disabled
|
|
1112
1095
|
},
|
|
1113
|
-
|
|
1096
|
+
textContent
|
|
1114
1097
|
),
|
|
1115
1098
|
[itemContext.disabled, itemContext.value, textContent]
|
|
1116
1099
|
);
|
|
@@ -1119,37 +1102,32 @@ var SelectItemText = React10.forwardRef((props, forwardedRef) => {
|
|
|
1119
1102
|
onNativeOptionAdd(nativeOption);
|
|
1120
1103
|
return () => onNativeOptionRemove(nativeOption);
|
|
1121
1104
|
}, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
|
|
1122
|
-
return /* @__PURE__ */
|
|
1123
|
-
/* @__PURE__ */ jsx11(Primitive9.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
|
|
1124
|
-
itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM2.createPortal(itemTextProps.children, context.valueNode) : null
|
|
1125
|
-
] });
|
|
1105
|
+
return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Primitive9.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }), itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM2.createPortal(itemTextProps.children, context.valueNode) : null);
|
|
1126
1106
|
});
|
|
1127
1107
|
SelectItemText.displayName = ITEM_TEXT_NAME;
|
|
1128
1108
|
|
|
1129
1109
|
// packages/react/select/src/SelectItemIndicator.tsx
|
|
1130
|
-
import
|
|
1110
|
+
import React12 from "react";
|
|
1131
1111
|
import { Primitive as Primitive10 } from "@huin-core/react-primitive";
|
|
1132
|
-
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1133
1112
|
var ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
1134
|
-
var SelectItemIndicator =
|
|
1113
|
+
var SelectItemIndicator = React12.forwardRef((props, forwardedRef) => {
|
|
1135
1114
|
const { __scopeSelect, ...itemIndicatorProps } = props;
|
|
1136
1115
|
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
1137
|
-
return itemContext.isSelected ? /* @__PURE__ */
|
|
1116
|
+
return itemContext.isSelected ? /* @__PURE__ */ React12.createElement(Primitive10.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
|
|
1138
1117
|
});
|
|
1139
1118
|
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
1140
1119
|
|
|
1141
1120
|
// packages/react/select/src/SelectScrollUpButton.tsx
|
|
1142
|
-
import
|
|
1121
|
+
import React14 from "react";
|
|
1143
1122
|
|
|
1144
1123
|
// packages/react/select/src/SelectScrollDownButton.tsx
|
|
1145
|
-
import
|
|
1124
|
+
import React13 from "react";
|
|
1146
1125
|
import { useComposedRefs as useComposedRefs8 } from "@huin-core/react-compose-refs";
|
|
1147
1126
|
import { useLayoutEffect as useLayoutEffect4 } from "@huin-core/react-use-layout-effect";
|
|
1148
1127
|
import { Primitive as Primitive11 } from "@huin-core/react-primitive";
|
|
1149
1128
|
import { composeEventHandlers as composeEventHandlers5 } from "@huin-core/primitive";
|
|
1150
|
-
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1151
1129
|
var SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
1152
|
-
var SelectScrollDownButton =
|
|
1130
|
+
var SelectScrollDownButton = React13.forwardRef((props, forwardedRef) => {
|
|
1153
1131
|
const contentContext = useSelectContentContext(
|
|
1154
1132
|
SCROLL_DOWN_BUTTON_NAME,
|
|
1155
1133
|
props.__scopeSelect
|
|
@@ -1158,7 +1136,7 @@ var SelectScrollDownButton = React12.forwardRef((props, forwardedRef) => {
|
|
|
1158
1136
|
SCROLL_DOWN_BUTTON_NAME,
|
|
1159
1137
|
props.__scopeSelect
|
|
1160
1138
|
);
|
|
1161
|
-
const [canScrollDown, setCanScrollDown] =
|
|
1139
|
+
const [canScrollDown, setCanScrollDown] = React13.useState(false);
|
|
1162
1140
|
const composedRefs = useComposedRefs8(
|
|
1163
1141
|
forwardedRef,
|
|
1164
1142
|
viewportContext.onScrollButtonChange
|
|
@@ -1177,7 +1155,7 @@ var SelectScrollDownButton = React12.forwardRef((props, forwardedRef) => {
|
|
|
1177
1155
|
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
1178
1156
|
}
|
|
1179
1157
|
}, [contentContext.viewport, contentContext.isPositioned]);
|
|
1180
|
-
return canScrollDown ? /* @__PURE__ */
|
|
1158
|
+
return canScrollDown ? /* @__PURE__ */ React13.createElement(
|
|
1181
1159
|
SelectScrollButtonImpl,
|
|
1182
1160
|
{
|
|
1183
1161
|
...props,
|
|
@@ -1192,21 +1170,21 @@ var SelectScrollDownButton = React12.forwardRef((props, forwardedRef) => {
|
|
|
1192
1170
|
) : null;
|
|
1193
1171
|
});
|
|
1194
1172
|
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
1195
|
-
var SelectScrollButtonImpl =
|
|
1173
|
+
var SelectScrollButtonImpl = React13.forwardRef((props, forwardedRef) => {
|
|
1196
1174
|
const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
|
|
1197
1175
|
const contentContext = useSelectContentContext(
|
|
1198
1176
|
"SelectScrollButton",
|
|
1199
1177
|
__scopeSelect
|
|
1200
1178
|
);
|
|
1201
|
-
const autoScrollTimerRef =
|
|
1179
|
+
const autoScrollTimerRef = React13.useRef(null);
|
|
1202
1180
|
const getItems = useCollection(__scopeSelect);
|
|
1203
|
-
const clearAutoScrollTimer =
|
|
1181
|
+
const clearAutoScrollTimer = React13.useCallback(() => {
|
|
1204
1182
|
if (autoScrollTimerRef.current !== null) {
|
|
1205
1183
|
window.clearInterval(autoScrollTimerRef.current);
|
|
1206
1184
|
autoScrollTimerRef.current = null;
|
|
1207
1185
|
}
|
|
1208
1186
|
}, []);
|
|
1209
|
-
|
|
1187
|
+
React13.useEffect(() => {
|
|
1210
1188
|
return () => clearAutoScrollTimer();
|
|
1211
1189
|
}, [clearAutoScrollTimer]);
|
|
1212
1190
|
useLayoutEffect4(() => {
|
|
@@ -1215,7 +1193,7 @@ var SelectScrollButtonImpl = React12.forwardRef((props, forwardedRef) => {
|
|
|
1215
1193
|
);
|
|
1216
1194
|
activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
|
|
1217
1195
|
}, [getItems]);
|
|
1218
|
-
return /* @__PURE__ */
|
|
1196
|
+
return /* @__PURE__ */ React13.createElement(
|
|
1219
1197
|
Primitive11.div,
|
|
1220
1198
|
{
|
|
1221
1199
|
"aria-hidden": true,
|
|
@@ -1252,9 +1230,8 @@ var SelectScrollButtonImpl = React12.forwardRef((props, forwardedRef) => {
|
|
|
1252
1230
|
// packages/react/select/src/SelectScrollUpButton.tsx
|
|
1253
1231
|
import { useComposedRefs as useComposedRefs9 } from "@huin-core/react-compose-refs";
|
|
1254
1232
|
import { useLayoutEffect as useLayoutEffect5 } from "@huin-core/react-use-layout-effect";
|
|
1255
|
-
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1256
1233
|
var SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
1257
|
-
var SelectScrollUpButton =
|
|
1234
|
+
var SelectScrollUpButton = React14.forwardRef((props, forwardedRef) => {
|
|
1258
1235
|
const contentContext = useSelectContentContext(
|
|
1259
1236
|
SCROLL_UP_BUTTON_NAME,
|
|
1260
1237
|
props.__scopeSelect
|
|
@@ -1263,7 +1240,7 @@ var SelectScrollUpButton = React13.forwardRef((props, forwardedRef) => {
|
|
|
1263
1240
|
SCROLL_UP_BUTTON_NAME,
|
|
1264
1241
|
props.__scopeSelect
|
|
1265
1242
|
);
|
|
1266
|
-
const [canScrollUp, setCanScrollUp] =
|
|
1243
|
+
const [canScrollUp, setCanScrollUp] = React14.useState(false);
|
|
1267
1244
|
const composedRefs = useComposedRefs9(
|
|
1268
1245
|
forwardedRef,
|
|
1269
1246
|
viewportContext.onScrollButtonChange
|
|
@@ -1281,7 +1258,7 @@ var SelectScrollUpButton = React13.forwardRef((props, forwardedRef) => {
|
|
|
1281
1258
|
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
1282
1259
|
}
|
|
1283
1260
|
}, [contentContext.viewport, contentContext.isPositioned]);
|
|
1284
|
-
return canScrollUp ? /* @__PURE__ */
|
|
1261
|
+
return canScrollUp ? /* @__PURE__ */ React14.createElement(
|
|
1285
1262
|
SelectScrollButtonImpl,
|
|
1286
1263
|
{
|
|
1287
1264
|
...props,
|
|
@@ -1298,28 +1275,26 @@ var SelectScrollUpButton = React13.forwardRef((props, forwardedRef) => {
|
|
|
1298
1275
|
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
1299
1276
|
|
|
1300
1277
|
// packages/react/select/src/SelectSeparator.tsx
|
|
1301
|
-
import
|
|
1278
|
+
import React15 from "react";
|
|
1302
1279
|
import { Primitive as Primitive12 } from "@huin-core/react-primitive";
|
|
1303
|
-
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1304
1280
|
var SEPARATOR_NAME = "SelectSeparator";
|
|
1305
|
-
var SelectSeparator =
|
|
1281
|
+
var SelectSeparator = React15.forwardRef((props, forwardedRef) => {
|
|
1306
1282
|
const { __scopeSelect, ...separatorProps } = props;
|
|
1307
|
-
return /* @__PURE__ */
|
|
1283
|
+
return /* @__PURE__ */ React15.createElement(Primitive12.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
|
|
1308
1284
|
});
|
|
1309
1285
|
SelectSeparator.displayName = SEPARATOR_NAME;
|
|
1310
1286
|
|
|
1311
1287
|
// packages/react/select/src/SelectArrow.tsx
|
|
1312
1288
|
import * as PopperPrimitive4 from "@huin-core/react-popper";
|
|
1313
|
-
import
|
|
1314
|
-
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1289
|
+
import React16 from "react";
|
|
1315
1290
|
var ARROW_NAME = "SelectArrow";
|
|
1316
|
-
var SelectArrow =
|
|
1291
|
+
var SelectArrow = React16.forwardRef(
|
|
1317
1292
|
(props, forwardedRef) => {
|
|
1318
1293
|
const { __scopeSelect, ...arrowProps } = props;
|
|
1319
1294
|
const popperScope = usePopperScope(__scopeSelect);
|
|
1320
1295
|
const context = useSelectContext(ARROW_NAME, __scopeSelect);
|
|
1321
1296
|
const contentContext = useSelectContentContext(ARROW_NAME, __scopeSelect);
|
|
1322
|
-
return context.open && contentContext.position === "popper" ? /* @__PURE__ */
|
|
1297
|
+
return context.open && contentContext.position === "popper" ? /* @__PURE__ */ React16.createElement(
|
|
1323
1298
|
PopperPrimitive4.Arrow,
|
|
1324
1299
|
{
|
|
1325
1300
|
...popperScope,
|