@radix-ui/react-select 2.3.0-rc.1780509379622 → 2.3.0-rc.1780518364979
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 +21 -19
- package/dist/index.d.ts +21 -19
- package/dist/index.js +113 -98
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +113 -98
- package/dist/index.mjs.map +3 -3
- package/package.json +21 -21
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
1
2
|
import * as _radix_ui_react_context from '@radix-ui/react-context';
|
|
3
|
+
import { Scope } from '@radix-ui/react-context';
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
|
|
4
6
|
import { FocusScope } from '@radix-ui/react-focus-scope';
|
|
5
7
|
import * as PopperPrimitive from '@radix-ui/react-popper';
|
|
6
|
-
import { Portal
|
|
8
|
+
import { Portal } from '@radix-ui/react-portal';
|
|
7
9
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
8
10
|
|
|
9
11
|
type Direction = 'ltr' | 'rtl';
|
|
12
|
+
type ScopedProps<P> = P & {
|
|
13
|
+
__scopeSelect?: Scope;
|
|
14
|
+
};
|
|
10
15
|
declare const createSelectScope: _radix_ui_react_context.CreateScope;
|
|
11
16
|
interface SelectSharedProps {
|
|
12
17
|
children?: React.ReactNode;
|
|
@@ -25,6 +30,15 @@ type SelectProps = SelectSharedProps & {
|
|
|
25
30
|
defaultValue?: string;
|
|
26
31
|
onValueChange?(value: string): void;
|
|
27
32
|
};
|
|
33
|
+
interface SelectProviderProps extends SelectSharedProps {
|
|
34
|
+
value?: string;
|
|
35
|
+
defaultValue?: string;
|
|
36
|
+
onValueChange?(value: string): void;
|
|
37
|
+
}
|
|
38
|
+
declare function SelectProvider(props: ScopedProps<SelectProviderProps>): react_jsx_runtime.JSX.Element;
|
|
39
|
+
declare namespace SelectProvider {
|
|
40
|
+
var displayName: string;
|
|
41
|
+
}
|
|
28
42
|
declare const Select: React.FC<SelectProps>;
|
|
29
43
|
type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
|
|
30
44
|
interface SelectTriggerProps extends PrimitiveButtonProps {
|
|
@@ -38,7 +52,7 @@ declare const SelectValue: React.ForwardRefExoticComponent<SelectValueProps & Re
|
|
|
38
52
|
interface SelectIconProps extends PrimitiveSpanProps {
|
|
39
53
|
}
|
|
40
54
|
declare const SelectIcon: React.ForwardRefExoticComponent<SelectIconProps & React.RefAttributes<HTMLSpanElement>>;
|
|
41
|
-
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal
|
|
55
|
+
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal>;
|
|
42
56
|
interface SelectPortalProps {
|
|
43
57
|
children?: React.ReactNode;
|
|
44
58
|
/**
|
|
@@ -127,21 +141,9 @@ type PopperArrowProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Ar
|
|
|
127
141
|
interface SelectArrowProps extends PopperArrowProps {
|
|
128
142
|
}
|
|
129
143
|
declare const SelectArrow: React.ForwardRefExoticComponent<SelectArrowProps & React.RefAttributes<SVGSVGElement>>;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
declare const
|
|
134
|
-
declare const Portal: React.FC<SelectPortalProps>;
|
|
135
|
-
declare const Content: React.ForwardRefExoticComponent<SelectContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
136
|
-
declare const Viewport: React.ForwardRefExoticComponent<SelectViewportProps & React.RefAttributes<HTMLDivElement>>;
|
|
137
|
-
declare const Group: React.ForwardRefExoticComponent<SelectGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
138
|
-
declare const Label: React.ForwardRefExoticComponent<SelectLabelProps & React.RefAttributes<HTMLDivElement>>;
|
|
139
|
-
declare const Item: React.ForwardRefExoticComponent<SelectItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
140
|
-
declare const ItemText: React.ForwardRefExoticComponent<SelectItemTextProps & React.RefAttributes<HTMLSpanElement>>;
|
|
141
|
-
declare const ItemIndicator: React.ForwardRefExoticComponent<SelectItemIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
|
|
142
|
-
declare const ScrollUpButton: React.ForwardRefExoticComponent<SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>>;
|
|
143
|
-
declare const ScrollDownButton: React.ForwardRefExoticComponent<SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>>;
|
|
144
|
-
declare const Separator: React.ForwardRefExoticComponent<SelectSeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
145
|
-
declare const Arrow: React.ForwardRefExoticComponent<SelectArrowProps & React.RefAttributes<SVGSVGElement>>;
|
|
144
|
+
type PrimitiveSelectProps = React.ComponentPropsWithoutRef<typeof Primitive.select>;
|
|
145
|
+
interface SelectBubbleInputProps extends Omit<PrimitiveSelectProps, 'value'> {
|
|
146
|
+
}
|
|
147
|
+
declare const SelectBubbleInput: React.ForwardRefExoticComponent<SelectBubbleInputProps & React.RefAttributes<HTMLSelectElement>>;
|
|
146
148
|
|
|
147
|
-
export { Arrow, Content, Group, Icon, Item, ItemIndicator, ItemText, Label, Portal, Root, ScrollDownButton, ScrollUpButton, Select, SelectArrow, type SelectArrowProps, SelectContent, type SelectContentProps, SelectGroup, type SelectGroupProps, SelectIcon, type SelectIconProps, SelectItem, SelectItemIndicator, type SelectItemIndicatorProps, type SelectItemProps, SelectItemText, type SelectItemTextProps, SelectLabel, type SelectLabelProps, SelectPortal, type SelectPortalProps, type SelectProps, SelectScrollDownButton, type SelectScrollDownButtonProps, SelectScrollUpButton, type SelectScrollUpButtonProps, SelectSeparator, type SelectSeparatorProps, type SelectSharedProps, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, SelectViewport, type SelectViewportProps, Separator, Trigger, Value, Viewport, createSelectScope };
|
|
149
|
+
export { SelectArrow as Arrow, SelectContent as Content, SelectGroup as Group, SelectIcon as Icon, SelectItem as Item, SelectItemIndicator as ItemIndicator, SelectItemText as ItemText, SelectLabel as Label, SelectPortal as Portal, Select as Root, SelectScrollDownButton as ScrollDownButton, SelectScrollUpButton as ScrollUpButton, Select, SelectArrow, type SelectArrowProps, SelectContent, type SelectContentProps, SelectGroup, type SelectGroupProps, SelectIcon, type SelectIconProps, SelectItem, SelectItemIndicator, type SelectItemIndicatorProps, type SelectItemProps, SelectItemText, type SelectItemTextProps, SelectLabel, type SelectLabelProps, SelectPortal, type SelectPortalProps, type SelectProps, SelectScrollDownButton, type SelectScrollDownButtonProps, SelectScrollUpButton, type SelectScrollUpButtonProps, SelectSeparator, type SelectSeparatorProps, type SelectSharedProps, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, SelectViewport, type SelectViewportProps, SelectSeparator as Separator, SelectTrigger as Trigger, SelectValue as Value, SelectViewport as Viewport, createSelectScope, SelectBubbleInput as unstable_BubbleInput, SelectProvider as unstable_Provider, SelectBubbleInput as unstable_SelectBubbleInput, type SelectBubbleInputProps as unstable_SelectBubbleInputProps, SelectProvider as unstable_SelectProvider, type SelectProviderProps as unstable_SelectProviderProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
1
2
|
import * as _radix_ui_react_context from '@radix-ui/react-context';
|
|
3
|
+
import { Scope } from '@radix-ui/react-context';
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
|
|
4
6
|
import { FocusScope } from '@radix-ui/react-focus-scope';
|
|
5
7
|
import * as PopperPrimitive from '@radix-ui/react-popper';
|
|
6
|
-
import { Portal
|
|
8
|
+
import { Portal } from '@radix-ui/react-portal';
|
|
7
9
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
8
10
|
|
|
9
11
|
type Direction = 'ltr' | 'rtl';
|
|
12
|
+
type ScopedProps<P> = P & {
|
|
13
|
+
__scopeSelect?: Scope;
|
|
14
|
+
};
|
|
10
15
|
declare const createSelectScope: _radix_ui_react_context.CreateScope;
|
|
11
16
|
interface SelectSharedProps {
|
|
12
17
|
children?: React.ReactNode;
|
|
@@ -25,6 +30,15 @@ type SelectProps = SelectSharedProps & {
|
|
|
25
30
|
defaultValue?: string;
|
|
26
31
|
onValueChange?(value: string): void;
|
|
27
32
|
};
|
|
33
|
+
interface SelectProviderProps extends SelectSharedProps {
|
|
34
|
+
value?: string;
|
|
35
|
+
defaultValue?: string;
|
|
36
|
+
onValueChange?(value: string): void;
|
|
37
|
+
}
|
|
38
|
+
declare function SelectProvider(props: ScopedProps<SelectProviderProps>): react_jsx_runtime.JSX.Element;
|
|
39
|
+
declare namespace SelectProvider {
|
|
40
|
+
var displayName: string;
|
|
41
|
+
}
|
|
28
42
|
declare const Select: React.FC<SelectProps>;
|
|
29
43
|
type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
|
|
30
44
|
interface SelectTriggerProps extends PrimitiveButtonProps {
|
|
@@ -38,7 +52,7 @@ declare const SelectValue: React.ForwardRefExoticComponent<SelectValueProps & Re
|
|
|
38
52
|
interface SelectIconProps extends PrimitiveSpanProps {
|
|
39
53
|
}
|
|
40
54
|
declare const SelectIcon: React.ForwardRefExoticComponent<SelectIconProps & React.RefAttributes<HTMLSpanElement>>;
|
|
41
|
-
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal
|
|
55
|
+
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal>;
|
|
42
56
|
interface SelectPortalProps {
|
|
43
57
|
children?: React.ReactNode;
|
|
44
58
|
/**
|
|
@@ -127,21 +141,9 @@ type PopperArrowProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Ar
|
|
|
127
141
|
interface SelectArrowProps extends PopperArrowProps {
|
|
128
142
|
}
|
|
129
143
|
declare const SelectArrow: React.ForwardRefExoticComponent<SelectArrowProps & React.RefAttributes<SVGSVGElement>>;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
declare const
|
|
134
|
-
declare const Portal: React.FC<SelectPortalProps>;
|
|
135
|
-
declare const Content: React.ForwardRefExoticComponent<SelectContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
136
|
-
declare const Viewport: React.ForwardRefExoticComponent<SelectViewportProps & React.RefAttributes<HTMLDivElement>>;
|
|
137
|
-
declare const Group: React.ForwardRefExoticComponent<SelectGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
138
|
-
declare const Label: React.ForwardRefExoticComponent<SelectLabelProps & React.RefAttributes<HTMLDivElement>>;
|
|
139
|
-
declare const Item: React.ForwardRefExoticComponent<SelectItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
140
|
-
declare const ItemText: React.ForwardRefExoticComponent<SelectItemTextProps & React.RefAttributes<HTMLSpanElement>>;
|
|
141
|
-
declare const ItemIndicator: React.ForwardRefExoticComponent<SelectItemIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
|
|
142
|
-
declare const ScrollUpButton: React.ForwardRefExoticComponent<SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>>;
|
|
143
|
-
declare const ScrollDownButton: React.ForwardRefExoticComponent<SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>>;
|
|
144
|
-
declare const Separator: React.ForwardRefExoticComponent<SelectSeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
145
|
-
declare const Arrow: React.ForwardRefExoticComponent<SelectArrowProps & React.RefAttributes<SVGSVGElement>>;
|
|
144
|
+
type PrimitiveSelectProps = React.ComponentPropsWithoutRef<typeof Primitive.select>;
|
|
145
|
+
interface SelectBubbleInputProps extends Omit<PrimitiveSelectProps, 'value'> {
|
|
146
|
+
}
|
|
147
|
+
declare const SelectBubbleInput: React.ForwardRefExoticComponent<SelectBubbleInputProps & React.RefAttributes<HTMLSelectElement>>;
|
|
146
148
|
|
|
147
|
-
export { Arrow, Content, Group, Icon, Item, ItemIndicator, ItemText, Label, Portal, Root, ScrollDownButton, ScrollUpButton, Select, SelectArrow, type SelectArrowProps, SelectContent, type SelectContentProps, SelectGroup, type SelectGroupProps, SelectIcon, type SelectIconProps, SelectItem, SelectItemIndicator, type SelectItemIndicatorProps, type SelectItemProps, SelectItemText, type SelectItemTextProps, SelectLabel, type SelectLabelProps, SelectPortal, type SelectPortalProps, type SelectProps, SelectScrollDownButton, type SelectScrollDownButtonProps, SelectScrollUpButton, type SelectScrollUpButtonProps, SelectSeparator, type SelectSeparatorProps, type SelectSharedProps, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, SelectViewport, type SelectViewportProps, Separator, Trigger, Value, Viewport, createSelectScope };
|
|
149
|
+
export { SelectArrow as Arrow, SelectContent as Content, SelectGroup as Group, SelectIcon as Icon, SelectItem as Item, SelectItemIndicator as ItemIndicator, SelectItemText as ItemText, SelectLabel as Label, SelectPortal as Portal, Select as Root, SelectScrollDownButton as ScrollDownButton, SelectScrollUpButton as ScrollUpButton, Select, SelectArrow, type SelectArrowProps, SelectContent, type SelectContentProps, SelectGroup, type SelectGroupProps, SelectIcon, type SelectIconProps, SelectItem, SelectItemIndicator, type SelectItemIndicatorProps, type SelectItemProps, SelectItemText, type SelectItemTextProps, SelectLabel, type SelectLabelProps, SelectPortal, type SelectPortalProps, type SelectProps, SelectScrollDownButton, type SelectScrollDownButtonProps, SelectScrollUpButton, type SelectScrollUpButtonProps, SelectSeparator, type SelectSeparatorProps, type SelectSharedProps, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, SelectViewport, type SelectViewportProps, SelectSeparator as Separator, SelectTrigger as Trigger, SelectValue as Value, SelectViewport as Viewport, createSelectScope, SelectBubbleInput as unstable_BubbleInput, SelectProvider as unstable_Provider, SelectBubbleInput as unstable_SelectBubbleInput, type SelectBubbleInputProps as unstable_SelectBubbleInputProps, SelectProvider as unstable_SelectProvider, type SelectProviderProps as unstable_SelectProviderProps };
|
package/dist/index.js
CHANGED
|
@@ -31,18 +31,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var index_exports = {};
|
|
33
33
|
__export(index_exports, {
|
|
34
|
-
Arrow: () =>
|
|
35
|
-
Content: () =>
|
|
36
|
-
Group: () =>
|
|
37
|
-
Icon: () =>
|
|
38
|
-
Item: () =>
|
|
39
|
-
ItemIndicator: () =>
|
|
40
|
-
ItemText: () =>
|
|
41
|
-
Label: () =>
|
|
42
|
-
Portal: () =>
|
|
43
|
-
Root: () =>
|
|
44
|
-
ScrollDownButton: () =>
|
|
45
|
-
ScrollUpButton: () =>
|
|
34
|
+
Arrow: () => SelectArrow,
|
|
35
|
+
Content: () => SelectContent,
|
|
36
|
+
Group: () => SelectGroup,
|
|
37
|
+
Icon: () => SelectIcon,
|
|
38
|
+
Item: () => SelectItem,
|
|
39
|
+
ItemIndicator: () => SelectItemIndicator,
|
|
40
|
+
ItemText: () => SelectItemText,
|
|
41
|
+
Label: () => SelectLabel,
|
|
42
|
+
Portal: () => SelectPortal,
|
|
43
|
+
Root: () => Select,
|
|
44
|
+
ScrollDownButton: () => SelectScrollDownButton,
|
|
45
|
+
ScrollUpButton: () => SelectScrollUpButton,
|
|
46
46
|
Select: () => Select,
|
|
47
47
|
SelectArrow: () => SelectArrow,
|
|
48
48
|
SelectContent: () => SelectContent,
|
|
@@ -59,11 +59,15 @@ __export(index_exports, {
|
|
|
59
59
|
SelectTrigger: () => SelectTrigger,
|
|
60
60
|
SelectValue: () => SelectValue,
|
|
61
61
|
SelectViewport: () => SelectViewport,
|
|
62
|
-
Separator: () =>
|
|
63
|
-
Trigger: () =>
|
|
64
|
-
Value: () =>
|
|
65
|
-
Viewport: () =>
|
|
66
|
-
createSelectScope: () => createSelectScope
|
|
62
|
+
Separator: () => SelectSeparator,
|
|
63
|
+
Trigger: () => SelectTrigger,
|
|
64
|
+
Value: () => SelectValue,
|
|
65
|
+
Viewport: () => SelectViewport,
|
|
66
|
+
createSelectScope: () => createSelectScope,
|
|
67
|
+
unstable_BubbleInput: () => SelectBubbleInput,
|
|
68
|
+
unstable_Provider: () => SelectProvider,
|
|
69
|
+
unstable_SelectBubbleInput: () => SelectBubbleInput,
|
|
70
|
+
unstable_SelectProvider: () => SelectProvider
|
|
67
71
|
});
|
|
68
72
|
module.exports = __toCommonJS(index_exports);
|
|
69
73
|
|
|
@@ -103,9 +107,10 @@ var [createSelectContext, createSelectScope] = (0, import_react_context.createCo
|
|
|
103
107
|
import_react_popper.createPopperScope
|
|
104
108
|
]);
|
|
105
109
|
var usePopperScope = (0, import_react_popper.createPopperScope)();
|
|
106
|
-
var [
|
|
110
|
+
var [SelectProviderImpl, useSelectContext] = createSelectContext(SELECT_NAME);
|
|
107
111
|
var [SelectNativeOptionsProvider, useSelectNativeOptionsContext] = createSelectContext(SELECT_NAME);
|
|
108
|
-
var
|
|
112
|
+
var PROVIDER_NAME = "SelectProvider";
|
|
113
|
+
function SelectProvider(props) {
|
|
109
114
|
const {
|
|
110
115
|
__scopeSelect,
|
|
111
116
|
children,
|
|
@@ -120,7 +125,9 @@ var Select = (props) => {
|
|
|
120
125
|
autoComplete,
|
|
121
126
|
disabled,
|
|
122
127
|
required,
|
|
123
|
-
form
|
|
128
|
+
form,
|
|
129
|
+
// @ts-expect-error internal render prop used by `Select` to compose its default parts
|
|
130
|
+
internal_do_not_use_render
|
|
124
131
|
} = props;
|
|
125
132
|
const popperScope = usePopperScope(__scopeSelect);
|
|
126
133
|
const [trigger, setTrigger] = React.useState(null);
|
|
@@ -140,68 +147,72 @@ var Select = (props) => {
|
|
|
140
147
|
caller: SELECT_NAME
|
|
141
148
|
});
|
|
142
149
|
const triggerPointerDownPosRef = React.useRef(null);
|
|
143
|
-
const isFormControl = trigger ? form || !!trigger.closest("form") : true;
|
|
150
|
+
const isFormControl = trigger ? !!form || !!trigger.closest("form") : true;
|
|
144
151
|
const [nativeOptionsSet, setNativeOptionsSet] = React.useState(/* @__PURE__ */ new Set());
|
|
152
|
+
const contentId = (0, import_react_id.useId)();
|
|
145
153
|
const nativeSelectKey = Array.from(nativeOptionsSet).map((option) => option.props.value).join(";");
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
const handleNativeOptionAdd = React.useCallback((option) => {
|
|
155
|
+
setNativeOptionsSet((prev) => new Set(prev).add(option));
|
|
156
|
+
}, []);
|
|
157
|
+
const handleNativeOptionRemove = React.useCallback((option) => {
|
|
158
|
+
setNativeOptionsSet((prev) => {
|
|
159
|
+
const optionsSet = new Set(prev);
|
|
160
|
+
optionsSet.delete(option);
|
|
161
|
+
return optionsSet;
|
|
162
|
+
});
|
|
163
|
+
}, []);
|
|
164
|
+
const context = {
|
|
165
|
+
required,
|
|
166
|
+
trigger,
|
|
167
|
+
onTriggerChange: setTrigger,
|
|
168
|
+
valueNode,
|
|
169
|
+
onValueNodeChange: setValueNode,
|
|
170
|
+
valueNodeHasChildren,
|
|
171
|
+
onValueNodeHasChildrenChange: setValueNodeHasChildren,
|
|
172
|
+
contentId,
|
|
173
|
+
value,
|
|
174
|
+
onValueChange: setValue,
|
|
175
|
+
open,
|
|
176
|
+
onOpenChange: setOpen,
|
|
177
|
+
dir: direction,
|
|
178
|
+
triggerPointerDownPosRef,
|
|
179
|
+
disabled,
|
|
180
|
+
name,
|
|
181
|
+
autoComplete,
|
|
182
|
+
form,
|
|
183
|
+
nativeOptions: nativeOptionsSet,
|
|
184
|
+
nativeSelectKey,
|
|
185
|
+
isFormControl
|
|
186
|
+
};
|
|
187
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectProviderImpl, { scope: __scopeSelect, ...context, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { scope: __scopeSelect, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
188
|
+
SelectNativeOptionsProvider,
|
|
148
189
|
{
|
|
149
|
-
required,
|
|
150
190
|
scope: __scopeSelect,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
children: [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
{
|
|
169
|
-
scope: props.__scopeSelect,
|
|
170
|
-
onNativeOptionAdd: React.useCallback((option) => {
|
|
171
|
-
setNativeOptionsSet((prev) => new Set(prev).add(option));
|
|
172
|
-
}, []),
|
|
173
|
-
onNativeOptionRemove: React.useCallback((option) => {
|
|
174
|
-
setNativeOptionsSet((prev) => {
|
|
175
|
-
const optionsSet = new Set(prev);
|
|
176
|
-
optionsSet.delete(option);
|
|
177
|
-
return optionsSet;
|
|
178
|
-
});
|
|
179
|
-
}, []),
|
|
180
|
-
children
|
|
181
|
-
}
|
|
182
|
-
) }),
|
|
183
|
-
isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
191
|
+
onNativeOptionAdd: handleNativeOptionAdd,
|
|
192
|
+
onNativeOptionRemove: handleNativeOptionRemove,
|
|
193
|
+
children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
|
194
|
+
}
|
|
195
|
+
) }) }) });
|
|
196
|
+
}
|
|
197
|
+
SelectProvider.displayName = PROVIDER_NAME;
|
|
198
|
+
var Select = (props) => {
|
|
199
|
+
const { __scopeSelect, children, ...providerProps } = props;
|
|
200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
201
|
+
SelectProvider,
|
|
202
|
+
{
|
|
203
|
+
__scopeSelect,
|
|
204
|
+
...providerProps,
|
|
205
|
+
internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
206
|
+
children,
|
|
207
|
+
isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
184
208
|
SelectBubbleInput,
|
|
185
209
|
{
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
tabIndex: -1,
|
|
189
|
-
name,
|
|
190
|
-
autoComplete,
|
|
191
|
-
value: value ?? "",
|
|
192
|
-
onChange: (event) => setValue(event.target.value),
|
|
193
|
-
disabled,
|
|
194
|
-
form,
|
|
195
|
-
children: [
|
|
196
|
-
shouldShowPlaceholder(value) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "" }) : null,
|
|
197
|
-
Array.from(nativeOptionsSet)
|
|
198
|
-
]
|
|
199
|
-
},
|
|
200
|
-
nativeSelectKey
|
|
210
|
+
__scopeSelect
|
|
211
|
+
}
|
|
201
212
|
) : null
|
|
202
|
-
]
|
|
213
|
+
] })
|
|
203
214
|
}
|
|
204
|
-
)
|
|
215
|
+
);
|
|
205
216
|
};
|
|
206
217
|
Select.displayName = SELECT_NAME;
|
|
207
218
|
var TRIGGER_NAME = "SelectTrigger";
|
|
@@ -1145,10 +1156,14 @@ var SelectArrow = React.forwardRef(
|
|
|
1145
1156
|
SelectArrow.displayName = ARROW_NAME;
|
|
1146
1157
|
var BUBBLE_INPUT_NAME = "SelectBubbleInput";
|
|
1147
1158
|
var SelectBubbleInput = React.forwardRef(
|
|
1148
|
-
({ __scopeSelect,
|
|
1159
|
+
({ __scopeSelect, ...props }, forwardedRef) => {
|
|
1160
|
+
const context = useSelectContext(BUBBLE_INPUT_NAME, __scopeSelect);
|
|
1161
|
+
const { value, onValueChange, required, disabled, name, autoComplete, form } = context;
|
|
1162
|
+
const { nativeOptions, nativeSelectKey } = context;
|
|
1149
1163
|
const ref = React.useRef(null);
|
|
1150
1164
|
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
1151
|
-
const
|
|
1165
|
+
const selectValue = value ?? "";
|
|
1166
|
+
const prevValue = (0, import_react_use_previous.usePrevious)(selectValue);
|
|
1152
1167
|
React.useEffect(() => {
|
|
1153
1168
|
const select = ref.current;
|
|
1154
1169
|
if (!select) return;
|
|
@@ -1158,24 +1173,40 @@ var SelectBubbleInput = React.forwardRef(
|
|
|
1158
1173
|
"value"
|
|
1159
1174
|
);
|
|
1160
1175
|
const setValue = descriptor.set;
|
|
1161
|
-
if (prevValue !==
|
|
1176
|
+
if (prevValue !== selectValue && setValue) {
|
|
1162
1177
|
const event = new Event("change", { bubbles: true });
|
|
1163
|
-
setValue.call(select,
|
|
1178
|
+
setValue.call(select, selectValue);
|
|
1164
1179
|
select.dispatchEvent(event);
|
|
1165
1180
|
}
|
|
1166
|
-
}, [prevValue,
|
|
1167
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
1181
|
+
}, [prevValue, selectValue]);
|
|
1182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1168
1183
|
import_react_primitive.Primitive.select,
|
|
1169
1184
|
{
|
|
1185
|
+
"aria-hidden": true,
|
|
1186
|
+
required,
|
|
1187
|
+
tabIndex: -1,
|
|
1188
|
+
name,
|
|
1189
|
+
autoComplete,
|
|
1190
|
+
disabled,
|
|
1191
|
+
form,
|
|
1192
|
+
onChange: (event) => onValueChange(event.target.value),
|
|
1170
1193
|
...props,
|
|
1171
1194
|
style: { ...import_react_visually_hidden.VISUALLY_HIDDEN_STYLES, ...props.style },
|
|
1172
1195
|
ref: composedRefs,
|
|
1173
|
-
defaultValue:
|
|
1174
|
-
|
|
1196
|
+
defaultValue: selectValue,
|
|
1197
|
+
children: [
|
|
1198
|
+
shouldShowPlaceholder(value) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "" }) : null,
|
|
1199
|
+
Array.from(nativeOptions)
|
|
1200
|
+
]
|
|
1201
|
+
},
|
|
1202
|
+
nativeSelectKey
|
|
1175
1203
|
);
|
|
1176
1204
|
}
|
|
1177
1205
|
);
|
|
1178
1206
|
SelectBubbleInput.displayName = BUBBLE_INPUT_NAME;
|
|
1207
|
+
function isFunction(value) {
|
|
1208
|
+
return typeof value === "function";
|
|
1209
|
+
}
|
|
1179
1210
|
function shouldShowPlaceholder(value) {
|
|
1180
1211
|
return value === "" || value === void 0;
|
|
1181
1212
|
}
|
|
@@ -1219,20 +1250,4 @@ function findNextItem(items, search, currentItem) {
|
|
|
1219
1250
|
function wrapArray(array, startIndex) {
|
|
1220
1251
|
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
1221
1252
|
}
|
|
1222
|
-
var Root2 = Select;
|
|
1223
|
-
var Trigger = SelectTrigger;
|
|
1224
|
-
var Value = SelectValue;
|
|
1225
|
-
var Icon = SelectIcon;
|
|
1226
|
-
var Portal = SelectPortal;
|
|
1227
|
-
var Content2 = SelectContent;
|
|
1228
|
-
var Viewport = SelectViewport;
|
|
1229
|
-
var Group = SelectGroup;
|
|
1230
|
-
var Label = SelectLabel;
|
|
1231
|
-
var Item = SelectItem;
|
|
1232
|
-
var ItemText = SelectItemText;
|
|
1233
|
-
var ItemIndicator = SelectItemIndicator;
|
|
1234
|
-
var ScrollUpButton = SelectScrollUpButton;
|
|
1235
|
-
var ScrollDownButton = SelectScrollDownButton;
|
|
1236
|
-
var Separator = SelectSeparator;
|
|
1237
|
-
var Arrow2 = SelectArrow;
|
|
1238
1253
|
//# sourceMappingURL=index.js.map
|