@radix-ui/react-select 2.2.0-rc.1744660991666 → 2.2.0-rc.1744830756566

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
@@ -8,11 +8,8 @@ import { Primitive } from '@radix-ui/react-primitive';
8
8
 
9
9
  type Direction = 'ltr' | 'rtl';
10
10
  declare const createSelectScope: _radix_ui_react_context.CreateScope;
11
- interface SelectProps {
11
+ interface SelectSharedProps {
12
12
  children?: React.ReactNode;
13
- value?: string;
14
- defaultValue?: string;
15
- onValueChange?(value: string): void;
16
13
  open?: boolean;
17
14
  defaultOpen?: boolean;
18
15
  onOpenChange?(open: boolean): void;
@@ -23,6 +20,11 @@ interface SelectProps {
23
20
  required?: boolean;
24
21
  form?: string;
25
22
  }
23
+ type SelectProps = SelectSharedProps & {
24
+ value?: string;
25
+ defaultValue?: string;
26
+ onValueChange?(value: string): void;
27
+ };
26
28
  declare const Select: React.FC<SelectProps>;
27
29
  type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
28
30
  interface SelectTriggerProps extends PrimitiveButtonProps {
package/dist/index.d.ts CHANGED
@@ -8,11 +8,8 @@ import { Primitive } from '@radix-ui/react-primitive';
8
8
 
9
9
  type Direction = 'ltr' | 'rtl';
10
10
  declare const createSelectScope: _radix_ui_react_context.CreateScope;
11
- interface SelectProps {
11
+ interface SelectSharedProps {
12
12
  children?: React.ReactNode;
13
- value?: string;
14
- defaultValue?: string;
15
- onValueChange?(value: string): void;
16
13
  open?: boolean;
17
14
  defaultOpen?: boolean;
18
15
  onOpenChange?(open: boolean): void;
@@ -23,6 +20,11 @@ interface SelectProps {
23
20
  required?: boolean;
24
21
  form?: string;
25
22
  }
23
+ type SelectProps = SelectSharedProps & {
24
+ value?: string;
25
+ defaultValue?: string;
26
+ onValueChange?(value: string): void;
27
+ };
26
28
  declare const Select: React.FC<SelectProps>;
27
29
  type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
28
30
  interface SelectTriggerProps extends PrimitiveButtonProps {
package/dist/index.js CHANGED
@@ -126,15 +126,17 @@ var Select = (props) => {
126
126
  const [valueNode, setValueNode] = React.useState(null);
127
127
  const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
128
128
  const direction = (0, import_react_direction.useDirection)(dir);
129
- const [open = false, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
129
+ const [open, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
130
130
  prop: openProp,
131
- defaultProp: defaultOpen,
132
- onChange: onOpenChange
131
+ defaultProp: defaultOpen ?? false,
132
+ onChange: onOpenChange,
133
+ caller: SELECT_NAME
133
134
  });
134
135
  const [value, setValue] = (0, import_react_use_controllable_state.useControllableState)({
135
136
  prop: valueProp,
136
137
  defaultProp: defaultValue,
137
- onChange: onValueChange
138
+ onChange: onValueChange,
139
+ caller: SELECT_NAME
138
140
  });
139
141
  const triggerPointerDownPosRef = React.useRef(null);
140
142
  const isFormControl = trigger ? form || !!trigger.closest("form") : true;
@@ -178,7 +180,7 @@ var Select = (props) => {
178
180
  }
179
181
  ) }),
180
182
  isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
181
- BubbleSelect,
183
+ SelectBubbleInput,
182
184
  {
183
185
  "aria-hidden": true,
184
186
  required,
@@ -1131,17 +1133,15 @@ var SelectArrow = React.forwardRef(
1131
1133
  }
1132
1134
  );
1133
1135
  SelectArrow.displayName = ARROW_NAME;
1134
- function shouldShowPlaceholder(value) {
1135
- return value === "" || value === void 0;
1136
- }
1137
- var BubbleSelect = React.forwardRef(
1138
- (props, forwardedRef) => {
1139
- const { value, ...selectProps } = props;
1136
+ var BUBBLE_INPUT_NAME = "SelectBubbleInput";
1137
+ var SelectBubbleInput = React.forwardRef(
1138
+ ({ __scopeSelect, value, ...props }, forwardedRef) => {
1140
1139
  const ref = React.useRef(null);
1141
1140
  const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
1142
1141
  const prevValue = (0, import_react_use_previous.usePrevious)(value);
1143
1142
  React.useEffect(() => {
1144
1143
  const select = ref.current;
1144
+ if (!select) return;
1145
1145
  const selectProto = window.HTMLSelectElement.prototype;
1146
1146
  const descriptor = Object.getOwnPropertyDescriptor(
1147
1147
  selectProto,
@@ -1154,10 +1154,21 @@ var BubbleSelect = React.forwardRef(
1154
1154
  select.dispatchEvent(event);
1155
1155
  }
1156
1156
  }, [prevValue, value]);
1157
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_visually_hidden.VisuallyHidden, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { ...selectProps, ref: composedRefs, defaultValue: value }) });
1157
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1158
+ import_react_primitive.Primitive.select,
1159
+ {
1160
+ ...props,
1161
+ style: { ...import_react_visually_hidden.VISUALLY_HIDDEN_STYLES, ...props.style },
1162
+ ref: composedRefs,
1163
+ defaultValue: value
1164
+ }
1165
+ );
1158
1166
  }
1159
1167
  );
1160
- BubbleSelect.displayName = "BubbleSelect";
1168
+ SelectBubbleInput.displayName = BUBBLE_INPUT_NAME;
1169
+ function shouldShowPlaceholder(value) {
1170
+ return value === "" || value === void 0;
1171
+ }
1161
1172
  function useTypeaheadSearch(onSearchChange) {
1162
1173
  const handleSearchChange = (0, import_react_use_callback_ref.useCallbackRef)(onSearchChange);
1163
1174
  const searchRef = React.useRef("");