@radix-ui/react-select 2.3.5 → 2.3.6-rc.1784938226983
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 +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +26 -10
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +26 -10
- package/dist/index.mjs.map +2 -2
- package/package.json +17 -17
package/dist/index.mjs
CHANGED
|
@@ -29,6 +29,14 @@ import { VISUALLY_HIDDEN_STYLES } from "@radix-ui/react-visually-hidden";
|
|
|
29
29
|
import { hideOthers } from "aria-hidden";
|
|
30
30
|
import { RemoveScroll } from "react-remove-scroll";
|
|
31
31
|
import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
|
|
32
|
+
var Position = {
|
|
33
|
+
ItemAligned: "item-aligned",
|
|
34
|
+
Popper: "popper"
|
|
35
|
+
};
|
|
36
|
+
var Direction = {
|
|
37
|
+
LTR: "ltr",
|
|
38
|
+
RTL: "rtl"
|
|
39
|
+
};
|
|
32
40
|
var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
|
|
33
41
|
var SELECTION_KEYS = [" ", "Enter"];
|
|
34
42
|
var SELECT_NAME = "Select";
|
|
@@ -297,7 +305,7 @@ var SelectContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
297
305
|
/* @__PURE__ */ __name(function SelectContentImpl2(props, forwardedRef) {
|
|
298
306
|
const { __scopeSelect } = props;
|
|
299
307
|
const {
|
|
300
|
-
position =
|
|
308
|
+
position = Position.ItemAligned,
|
|
301
309
|
onCloseAutoFocus,
|
|
302
310
|
onEscapeKeyDown,
|
|
303
311
|
onPointerDownOutside,
|
|
@@ -426,7 +434,7 @@ var SelectContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
426
434
|
},
|
|
427
435
|
[context.value]
|
|
428
436
|
);
|
|
429
|
-
const SelectPosition = position ===
|
|
437
|
+
const SelectPosition = position === Position.Popper ? SelectPopperPosition : SelectItemAlignedPosition;
|
|
430
438
|
const popperContentProps = SelectPosition === SelectPopperPosition ? {
|
|
431
439
|
side,
|
|
432
440
|
sideOffset,
|
|
@@ -542,7 +550,7 @@ var SelectItemAlignedPosition = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */
|
|
|
542
550
|
const contentRect = content.getBoundingClientRect();
|
|
543
551
|
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
|
544
552
|
const itemTextRect = selectedItemText.getBoundingClientRect();
|
|
545
|
-
if (context.dir !==
|
|
553
|
+
if (context.dir !== Direction.RTL) {
|
|
546
554
|
const itemTextOffset = itemTextRect.left - contentRect.left;
|
|
547
555
|
const left = valueNodeRect.left - itemTextOffset;
|
|
548
556
|
const leftDelta = triggerRect.left - left;
|
|
@@ -827,10 +835,8 @@ var SelectItem = /* @__PURE__ */ React.forwardRef(
|
|
|
827
835
|
const textId = useId();
|
|
828
836
|
const pointerTypeRef = React.useRef("touch");
|
|
829
837
|
const handleSelect = /* @__PURE__ */ __name(() => {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
context.onOpenChange(false);
|
|
833
|
-
}
|
|
838
|
+
context.onValueChange(value);
|
|
839
|
+
context.onOpenChange(false);
|
|
834
840
|
}, "handleSelect");
|
|
835
841
|
return /* @__PURE__ */ jsx(
|
|
836
842
|
SelectItemContextProvider,
|
|
@@ -866,10 +872,20 @@ var SelectItem = /* @__PURE__ */ React.forwardRef(
|
|
|
866
872
|
onFocus: composeEventHandlers(itemProps.onFocus, () => setIsFocused(true)),
|
|
867
873
|
onBlur: composeEventHandlers(itemProps.onBlur, () => setIsFocused(false)),
|
|
868
874
|
onClick: composeEventHandlers(itemProps.onClick, () => {
|
|
869
|
-
if (
|
|
875
|
+
if (disabled) {
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
if (pointerTypeRef.current !== "mouse") {
|
|
879
|
+
handleSelect();
|
|
880
|
+
}
|
|
870
881
|
}),
|
|
871
882
|
onPointerUp: composeEventHandlers(itemProps.onPointerUp, () => {
|
|
872
|
-
if (
|
|
883
|
+
if (disabled) {
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
if (pointerTypeRef.current === "mouse") {
|
|
887
|
+
handleSelect();
|
|
888
|
+
}
|
|
873
889
|
}),
|
|
874
890
|
onPointerDown: composeEventHandlers(itemProps.onPointerDown, (event) => {
|
|
875
891
|
pointerTypeRef.current = event.pointerType;
|
|
@@ -1077,7 +1093,7 @@ var SelectArrow = /* @__PURE__ */ React.forwardRef(
|
|
|
1077
1093
|
const { __scopeSelect, ...arrowProps } = props;
|
|
1078
1094
|
const popperScope = usePopperScope(__scopeSelect);
|
|
1079
1095
|
const contentContext = useSelectContentContext(ARROW_NAME, __scopeSelect);
|
|
1080
|
-
return contentContext.position ===
|
|
1096
|
+
return contentContext.position === Position.Popper ? /* @__PURE__ */ jsx(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
|
|
1081
1097
|
}, "SelectArrow")
|
|
1082
1098
|
);
|
|
1083
1099
|
var BUBBLE_INPUT_NAME = "SelectBubbleInput";
|