@radix-ui/react-select 2.3.5 → 2.3.6-rc.1784910896438

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 CHANGED
@@ -7,7 +7,16 @@ import * as PopperPrimitive from '@radix-ui/react-popper';
7
7
  import { Portal } from '@radix-ui/react-portal';
8
8
  import { Primitive } from '@radix-ui/react-primitive';
9
9
 
10
- type Direction = 'ltr' | 'rtl';
10
+ declare const Position: {
11
+ readonly ItemAligned: "item-aligned";
12
+ readonly Popper: "popper";
13
+ };
14
+ type Position = (typeof Position)[keyof typeof Position];
15
+ declare const Direction: {
16
+ readonly LTR: "ltr";
17
+ readonly RTL: "rtl";
18
+ };
19
+ type Direction = (typeof Direction)[keyof typeof Direction];
11
20
  type ScopedProps<P> = P & {
12
21
  __scopeSelect?: Scope;
13
22
  };
@@ -91,7 +100,7 @@ interface SelectContentImplProps extends Omit<SelectPopperPositionProps, keyof S
91
100
  * Can be prevented.
92
101
  */
93
102
  onPointerDownOutside?: DismissableLayerProps['onPointerDownOutside'];
94
- position?: 'item-aligned' | 'popper';
103
+ position?: Position;
95
104
  }
96
105
  interface SelectItemAlignedPositionProps extends PrimitiveDivProps, SelectPopperPrivateProps {
97
106
  }
package/dist/index.d.ts CHANGED
@@ -7,7 +7,16 @@ import * as PopperPrimitive from '@radix-ui/react-popper';
7
7
  import { Portal } from '@radix-ui/react-portal';
8
8
  import { Primitive } from '@radix-ui/react-primitive';
9
9
 
10
- type Direction = 'ltr' | 'rtl';
10
+ declare const Position: {
11
+ readonly ItemAligned: "item-aligned";
12
+ readonly Popper: "popper";
13
+ };
14
+ type Position = (typeof Position)[keyof typeof Position];
15
+ declare const Direction: {
16
+ readonly LTR: "ltr";
17
+ readonly RTL: "rtl";
18
+ };
19
+ type Direction = (typeof Direction)[keyof typeof Direction];
11
20
  type ScopedProps<P> = P & {
12
21
  __scopeSelect?: Scope;
13
22
  };
@@ -91,7 +100,7 @@ interface SelectContentImplProps extends Omit<SelectPopperPositionProps, keyof S
91
100
  * Can be prevented.
92
101
  */
93
102
  onPointerDownOutside?: DismissableLayerProps['onPointerDownOutside'];
94
- position?: 'item-aligned' | 'popper';
103
+ position?: Position;
95
104
  }
96
105
  interface SelectItemAlignedPositionProps extends PrimitiveDivProps, SelectPopperPrivateProps {
97
106
  }
package/dist/index.js CHANGED
@@ -99,6 +99,14 @@ var import_react_visually_hidden = require("@radix-ui/react-visually-hidden");
99
99
  var import_aria_hidden = require("aria-hidden");
100
100
  var import_react_remove_scroll = require("react-remove-scroll");
101
101
  var import_jsx_runtime = require("react/jsx-runtime");
102
+ var Position = {
103
+ ItemAligned: "item-aligned",
104
+ Popper: "popper"
105
+ };
106
+ var Direction = {
107
+ LTR: "ltr",
108
+ RTL: "rtl"
109
+ };
102
110
  var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
103
111
  var SELECTION_KEYS = [" ", "Enter"];
104
112
  var SELECT_NAME = "Select";
@@ -367,7 +375,7 @@ var SelectContentImpl = /* @__PURE__ */ React.forwardRef(
367
375
  /* @__PURE__ */ __name(function SelectContentImpl2(props, forwardedRef) {
368
376
  const { __scopeSelect } = props;
369
377
  const {
370
- position = "item-aligned",
378
+ position = Position.ItemAligned,
371
379
  onCloseAutoFocus,
372
380
  onEscapeKeyDown,
373
381
  onPointerDownOutside,
@@ -496,7 +504,7 @@ var SelectContentImpl = /* @__PURE__ */ React.forwardRef(
496
504
  },
497
505
  [context.value]
498
506
  );
499
- const SelectPosition = position === "popper" ? SelectPopperPosition : SelectItemAlignedPosition;
507
+ const SelectPosition = position === Position.Popper ? SelectPopperPosition : SelectItemAlignedPosition;
500
508
  const popperContentProps = SelectPosition === SelectPopperPosition ? {
501
509
  side,
502
510
  sideOffset,
@@ -612,7 +620,7 @@ var SelectItemAlignedPosition = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */
612
620
  const contentRect = content.getBoundingClientRect();
613
621
  const valueNodeRect = context.valueNode.getBoundingClientRect();
614
622
  const itemTextRect = selectedItemText.getBoundingClientRect();
615
- if (context.dir !== "rtl") {
623
+ if (context.dir !== Direction.RTL) {
616
624
  const itemTextOffset = itemTextRect.left - contentRect.left;
617
625
  const left = valueNodeRect.left - itemTextOffset;
618
626
  const leftDelta = triggerRect.left - left;
@@ -897,10 +905,8 @@ var SelectItem = /* @__PURE__ */ React.forwardRef(
897
905
  const textId = (0, import_react_id.useId)();
898
906
  const pointerTypeRef = React.useRef("touch");
899
907
  const handleSelect = /* @__PURE__ */ __name(() => {
900
- if (!disabled) {
901
- context.onValueChange(value);
902
- context.onOpenChange(false);
903
- }
908
+ context.onValueChange(value);
909
+ context.onOpenChange(false);
904
910
  }, "handleSelect");
905
911
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
906
912
  SelectItemContextProvider,
@@ -936,10 +942,20 @@ var SelectItem = /* @__PURE__ */ React.forwardRef(
936
942
  onFocus: (0, import_primitive.composeEventHandlers)(itemProps.onFocus, () => setIsFocused(true)),
937
943
  onBlur: (0, import_primitive.composeEventHandlers)(itemProps.onBlur, () => setIsFocused(false)),
938
944
  onClick: (0, import_primitive.composeEventHandlers)(itemProps.onClick, () => {
939
- if (pointerTypeRef.current !== "mouse") handleSelect();
945
+ if (disabled) {
946
+ return;
947
+ }
948
+ if (pointerTypeRef.current !== "mouse") {
949
+ handleSelect();
950
+ }
940
951
  }),
941
952
  onPointerUp: (0, import_primitive.composeEventHandlers)(itemProps.onPointerUp, () => {
942
- if (pointerTypeRef.current === "mouse") handleSelect();
953
+ if (disabled) {
954
+ return;
955
+ }
956
+ if (pointerTypeRef.current === "mouse") {
957
+ handleSelect();
958
+ }
943
959
  }),
944
960
  onPointerDown: (0, import_primitive.composeEventHandlers)(itemProps.onPointerDown, (event) => {
945
961
  pointerTypeRef.current = event.pointerType;
@@ -1147,7 +1163,7 @@ var SelectArrow = /* @__PURE__ */ React.forwardRef(
1147
1163
  const { __scopeSelect, ...arrowProps } = props;
1148
1164
  const popperScope = usePopperScope(__scopeSelect);
1149
1165
  const contentContext = useSelectContentContext(ARROW_NAME, __scopeSelect);
1150
- return contentContext.position === "popper" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
1166
+ return contentContext.position === Position.Popper ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
1151
1167
  }, "SelectArrow")
1152
1168
  );
1153
1169
  var BUBBLE_INPUT_NAME = "SelectBubbleInput";