@radix-ui/react-select 2.1.2-rc.9 → 2.1.3-rc.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/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as _radix_ui_react_context from '@radix-ui/react-context';
1
2
  import * as React from 'react';
2
3
  import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
3
4
  import { FocusScope } from '@radix-ui/react-focus-scope';
@@ -5,19 +6,8 @@ import * as PopperPrimitive from '@radix-ui/react-popper';
5
6
  import { Portal as Portal$1 } from '@radix-ui/react-portal';
6
7
  import { Primitive } from '@radix-ui/react-primitive';
7
8
 
8
- type Scope<C = any> = {
9
- [scopeName: string]: React.Context<C>[];
10
- } | undefined;
11
- type ScopeHook = (scope: Scope) => {
12
- [__scopeProp: string]: Scope;
13
- };
14
- interface CreateScope {
15
- scopeName: string;
16
- (): ScopeHook;
17
- }
18
-
19
9
  type Direction = 'ltr' | 'rtl';
20
- declare const createSelectScope: CreateScope;
10
+ declare const createSelectScope: _radix_ui_react_context.CreateScope;
21
11
  interface SelectProps {
22
12
  children?: React.ReactNode;
23
13
  value?: string;
@@ -31,6 +21,7 @@ interface SelectProps {
31
21
  autoComplete?: string;
32
22
  disabled?: boolean;
33
23
  required?: boolean;
24
+ form?: string;
34
25
  }
35
26
  declare const Select: React.FC<SelectProps>;
36
27
  type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as _radix_ui_react_context from '@radix-ui/react-context';
1
2
  import * as React from 'react';
2
3
  import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
3
4
  import { FocusScope } from '@radix-ui/react-focus-scope';
@@ -5,19 +6,8 @@ import * as PopperPrimitive from '@radix-ui/react-popper';
5
6
  import { Portal as Portal$1 } from '@radix-ui/react-portal';
6
7
  import { Primitive } from '@radix-ui/react-primitive';
7
8
 
8
- type Scope<C = any> = {
9
- [scopeName: string]: React.Context<C>[];
10
- } | undefined;
11
- type ScopeHook = (scope: Scope) => {
12
- [__scopeProp: string]: Scope;
13
- };
14
- interface CreateScope {
15
- scopeName: string;
16
- (): ScopeHook;
17
- }
18
-
19
9
  type Direction = 'ltr' | 'rtl';
20
- declare const createSelectScope: CreateScope;
10
+ declare const createSelectScope: _radix_ui_react_context.CreateScope;
21
11
  interface SelectProps {
22
12
  children?: React.ReactNode;
23
13
  value?: string;
@@ -31,6 +21,7 @@ interface SelectProps {
31
21
  autoComplete?: string;
32
22
  disabled?: boolean;
33
23
  required?: boolean;
24
+ form?: string;
34
25
  }
35
26
  declare const Select: React.FC<SelectProps>;
36
27
  type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
package/dist/index.js CHANGED
@@ -118,7 +118,8 @@ var Select = (props) => {
118
118
  name,
119
119
  autoComplete,
120
120
  disabled,
121
- required
121
+ required,
122
+ form
122
123
  } = props;
123
124
  const popperScope = usePopperScope(__scopeSelect);
124
125
  const [trigger, setTrigger] = React.useState(null);
@@ -136,7 +137,7 @@ var Select = (props) => {
136
137
  onChange: onValueChange
137
138
  });
138
139
  const triggerPointerDownPosRef = React.useRef(null);
139
- const isFormControl = trigger ? Boolean(trigger.closest("form")) : true;
140
+ const isFormControl = trigger ? form || !!trigger.closest("form") : true;
140
141
  const [nativeOptionsSet, setNativeOptionsSet] = React.useState(/* @__PURE__ */ new Set());
141
142
  const nativeSelectKey = Array.from(nativeOptionsSet).map((option) => option.props.value).join(";");
142
143
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
@@ -187,6 +188,7 @@ var Select = (props) => {
187
188
  value,
188
189
  onChange: (event) => setValue(event.target.value),
189
190
  disabled,
191
+ form,
190
192
  children: [
191
193
  value === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "" }) : null,
192
194
  Array.from(nativeOptionsSet)
@@ -593,7 +595,15 @@ var SelectItemAlignedPosition = React.forwardRef((props, forwardedRef) => {
593
595
  const minContentWidth = triggerRect.width + leftDelta;
594
596
  const contentWidth = Math.max(minContentWidth, contentRect.width);
595
597
  const rightEdge = window.innerWidth - CONTENT_MARGIN;
596
- const clampedLeft = (0, import_number.clamp)(left, [CONTENT_MARGIN, rightEdge - contentWidth]);
598
+ const clampedLeft = (0, import_number.clamp)(left, [
599
+ CONTENT_MARGIN,
600
+ // Prevents the content from going off the starting edge of the
601
+ // viewport. It may still go off the ending edge, but this can be
602
+ // controlled by the user since they may want to manage overflow in a
603
+ // specific way.
604
+ // https://github.com/radix-ui/primitives/issues/2049
605
+ Math.max(CONTENT_MARGIN, rightEdge - contentWidth)
606
+ ]);
597
607
  contentWrapper.style.minWidth = minContentWidth + "px";
598
608
  contentWrapper.style.left = clampedLeft + "px";
599
609
  } else {
@@ -603,7 +613,10 @@ var SelectItemAlignedPosition = React.forwardRef((props, forwardedRef) => {
603
613
  const minContentWidth = triggerRect.width + rightDelta;
604
614
  const contentWidth = Math.max(minContentWidth, contentRect.width);
605
615
  const leftEdge = window.innerWidth - CONTENT_MARGIN;
606
- const clampedRight = (0, import_number.clamp)(right, [CONTENT_MARGIN, leftEdge - contentWidth]);
616
+ const clampedRight = (0, import_number.clamp)(right, [
617
+ CONTENT_MARGIN,
618
+ Math.max(CONTENT_MARGIN, leftEdge - contentWidth)
619
+ ]);
607
620
  contentWrapper.style.minWidth = minContentWidth + "px";
608
621
  contentWrapper.style.right = clampedRight + "px";
609
622
  }
@@ -787,7 +800,11 @@ var SelectViewport = React.forwardRef(
787
800
  // (independent of the scrollUpButton).
788
801
  position: "relative",
789
802
  flex: 1,
790
- overflow: "auto",
803
+ // Viewport should only be scrollable in the vertical direction.
804
+ // This won't work in vertical writing modes, so we'll need to
805
+ // revisit this if/when that is supported
806
+ // https://developer.chrome.com/blog/vertical-form-controls
807
+ overflow: "hidden auto",
791
808
  ...viewportProps.style
792
809
  },
793
810
  onScroll: (0, import_primitive.composeEventHandlers)(viewportProps.onScroll, (event) => {