@vritti/quantum-ui 0.5.7 → 0.5.9
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/ActiveShapeUtils.js +1 -1
- package/dist/AreaChart.js +1 -1
- package/dist/Avatar.js +5 -5
- package/dist/BarChart.js +1 -1
- package/dist/Breadcrumb.js +3 -1
- package/dist/Breadcrumb.js.map +1 -1
- package/dist/Button.js +1 -1
- package/dist/CartesianChart.js +40 -2
- package/dist/CartesianChart.js.map +1 -1
- package/dist/Chart.js +7 -3
- package/dist/Chart.js.map +1 -1
- package/dist/Checkbox.js +30 -6
- package/dist/Checkbox.js.map +1 -1
- package/dist/Checkbox2.js +2 -2
- package/dist/CheckboxGroup.js +20 -3
- package/dist/CheckboxGroup.js.map +1 -1
- package/dist/CurrencyField.js +32 -8
- package/dist/CurrencyField.js.map +1 -1
- package/dist/DangerZoneSkeleton.js +1 -1
- package/dist/DatePicker.js +144 -126
- package/dist/DatePicker.js.map +1 -1
- package/dist/DateRangePicker.js +138 -122
- package/dist/DateRangePicker.js.map +1 -1
- package/dist/DateTimePicker.js +181 -163
- package/dist/DateTimePicker.js.map +1 -1
- package/dist/DateTimeRangePicker.js +189 -173
- package/dist/DateTimeRangePicker.js.map +1 -1
- package/dist/Dialog.js +1 -1
- package/dist/DropdownMenu.js +1 -1
- package/dist/Form.js +2 -0
- package/dist/Form.js.map +1 -1
- package/dist/FormSection.js +22 -0
- package/dist/FormSection.js.map +1 -1
- package/dist/IconSelect.js +4 -2
- package/dist/IconSelect.js.map +1 -1
- package/dist/Label.js +1 -1
- package/dist/LineChart.js +390 -9
- package/dist/LineChart.js.map +1 -1
- package/dist/OTPField.js +39 -24
- package/dist/OTPField.js.map +1 -1
- package/dist/PermissionGate.js +25 -3
- package/dist/PermissionGate.js.map +1 -1
- package/dist/PhoneField.js +47 -30
- package/dist/PhoneField.js.map +1 -1
- package/dist/PieChart.js +1 -1
- package/dist/Progress.js +2 -2
- package/dist/RadarChart.js +1 -1
- package/dist/RadialChart.js +1 -1
- package/dist/RadioGroup.js +35 -18
- package/dist/RadioGroup.js.map +1 -1
- package/dist/Select.js +53 -33
- package/dist/Select.js.map +1 -1
- package/dist/SelectFilter.js +13 -6
- package/dist/SelectFilter.js.map +1 -1
- package/dist/Sidebar.js +1 -1
- package/dist/SingleSelect.js +50 -24
- package/dist/SingleSelect.js.map +1 -1
- package/dist/Switch.js +3 -3
- package/dist/TabsSkeleton.js +2 -2
- package/dist/TextArea.js +28 -12
- package/dist/TextArea.js.map +1 -1
- package/dist/TextField.js +70 -53
- package/dist/TextField.js.map +1 -1
- package/dist/Toggle.js +1 -1
- package/dist/UploadFile.js +22 -4
- package/dist/UploadFile.js.map +1 -1
- package/dist/assets/quantum-ui.css +76 -1
- package/dist/calendar2.js +1 -1
- package/dist/calendar2.js.map +1 -1
- package/dist/components/DateFilter.js +158 -0
- package/dist/components/DateFilter.js.map +1 -0
- package/dist/components/PermissionGate.js +1 -1
- package/dist/components/RichTextEditor.js +1 -1
- package/dist/components/TokenInput.js +96 -66
- package/dist/components/TokenInput.js.map +1 -1
- package/dist/contextAnchor.js +11 -0
- package/dist/contextAnchor.js.map +1 -0
- package/dist/disabledTip.js +3 -2
- package/dist/disabledTip.js.map +1 -1
- package/dist/dropdown-menu.js +5 -5
- package/dist/getZIndexFromUnknown.js +1 -1
- package/dist/image-component.js +1 -1
- package/dist/index.js +2 -2
- package/dist/index13.js +34 -5
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +22 -281
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +212 -1072
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +1139 -14
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +14 -20
- package/dist/index17.js.map +1 -1
- package/dist/index20.js +2 -2
- package/dist/index21.js +1 -1
- package/dist/index22.js +1 -1
- package/dist/index23.js +1 -1
- package/dist/index25.js +4 -232
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +35 -2534
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +223 -23
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +1124 -3
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +2481 -1035
- package/dist/index29.js.map +1 -1
- package/dist/index30.js +308 -36
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +7 -307
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +30 -8
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +59 -29
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +10 -59
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +35347 -9
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +79 -36
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +184 -35340
- package/dist/index37.js.map +1 -1
- package/dist/index5.js +1 -1
- package/dist/lib/components/Breadcrumb/Breadcrumb.d.ts +2 -1
- package/dist/lib/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/lib/components/Checkbox/Checkbox.d.ts +1 -0
- package/dist/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/lib/components/CheckboxGroup/CheckboxGroup.d.ts +1 -0
- package/dist/lib/components/CheckboxGroup/CheckboxGroup.d.ts.map +1 -1
- package/dist/lib/components/CurrencyField/CurrencyField.d.ts +2 -0
- package/dist/lib/components/CurrencyField/CurrencyField.d.ts.map +1 -1
- package/dist/lib/components/DataTable/DataTable.d.ts +1 -1
- package/dist/lib/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/RowActions.d.ts +1 -0
- package/dist/lib/components/DataTable/components/RowActions.d.ts.map +1 -1
- package/dist/lib/components/DataTable/store/store.d.ts.map +1 -1
- package/dist/lib/components/DataTable/types.d.ts +1 -0
- package/dist/lib/components/DataTable/types.d.ts.map +1 -1
- package/dist/lib/components/DateFilter/DateFilter.d.ts +17 -0
- package/dist/lib/components/DateFilter/DateFilter.d.ts.map +1 -0
- package/dist/lib/components/DateFilter/index.d.ts +3 -0
- package/dist/lib/components/DateFilter/index.d.ts.map +1 -0
- package/dist/lib/components/DatePicker/DatePicker.d.ts +1 -0
- package/dist/lib/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/lib/components/DateRangePicker/DateRangePicker.d.ts +1 -0
- package/dist/lib/components/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/lib/components/DateTimePicker/DateTimePicker.d.ts +1 -0
- package/dist/lib/components/DateTimePicker/DateTimePicker.d.ts.map +1 -1
- package/dist/lib/components/DateTimeRangePicker/DateTimeRangePicker.d.ts +1 -0
- package/dist/lib/components/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -1
- package/dist/lib/components/Form/Form.d.ts.map +1 -1
- package/dist/lib/components/Form/FormSection.d.ts +1 -1
- package/dist/lib/components/Form/FormSection.d.ts.map +1 -1
- package/dist/lib/components/Form/fieldPermissions.d.ts +6 -0
- package/dist/lib/components/Form/fieldPermissions.d.ts.map +1 -0
- package/dist/lib/components/LineChart/LineChart.d.ts +18 -4
- package/dist/lib/components/LineChart/LineChart.d.ts.map +1 -1
- package/dist/lib/components/LineChart/index.d.ts +1 -1
- package/dist/lib/components/LineChart/index.d.ts.map +1 -1
- package/dist/lib/components/OTPField/OTPField.d.ts +1 -0
- package/dist/lib/components/OTPField/OTPField.d.ts.map +1 -1
- package/dist/lib/components/PermissionGate/PermissionGate.d.ts +1 -0
- package/dist/lib/components/PermissionGate/PermissionGate.d.ts.map +1 -1
- package/dist/lib/components/PermissionGate/index.d.ts +1 -1
- package/dist/lib/components/PermissionGate/index.d.ts.map +1 -1
- package/dist/lib/components/PhoneField/PhoneField.d.ts +1 -0
- package/dist/lib/components/PhoneField/PhoneField.d.ts.map +1 -1
- package/dist/lib/components/RadioGroup/RadioGroup.d.ts +1 -0
- package/dist/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/dist/lib/components/Select/Select.d.ts.map +1 -1
- package/dist/lib/components/Select/SelectFilter.d.ts.map +1 -1
- package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts +1 -0
- package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts +1 -0
- package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts.map +1 -1
- package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts +3 -0
- package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts.map +1 -1
- package/dist/lib/components/Select/contextAnchor.d.ts +11 -0
- package/dist/lib/components/Select/contextAnchor.d.ts.map +1 -0
- package/dist/lib/components/TextArea/TextArea.d.ts +1 -0
- package/dist/lib/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/lib/components/TextField/TextField.d.ts +1 -0
- package/dist/lib/components/TextField/TextField.d.ts.map +1 -1
- package/dist/lib/components/TokenInput/TokenInput.d.ts +1 -0
- package/dist/lib/components/TokenInput/TokenInput.d.ts.map +1 -1
- package/dist/lib/components/UploadFile/UploadFile.d.ts +1 -0
- package/dist/lib/components/UploadFile/UploadFile.d.ts.map +1 -1
- package/dist/lib/selects/icon/IconSelect.d.ts +1 -0
- package/dist/lib/selects/icon/IconSelect.d.ts.map +1 -1
- package/dist/lib/utils/disabledTip.d.ts +1 -1
- package/dist/lib/utils/disabledTip.d.ts.map +1 -1
- package/dist/lib/utils/zod.d.ts +1 -0
- package/dist/lib/utils/zod.d.ts.map +1 -1
- package/dist/popover.js +1 -1
- package/dist/select2.js +1 -1
- package/dist/separator2.js +1 -1
- package/dist/shadcn/shadcnChart/Chart.d.ts +2 -1
- package/dist/shadcn/shadcnChart/Chart.d.ts.map +1 -1
- package/dist/useDataTable.js +25 -9
- package/dist/useDataTable.js.map +1 -1
- package/dist/utils/motion.js +2 -2
- package/dist/utils/zod.js +7 -2
- package/dist/utils/zod.js.map +1 -1
- package/dist/value.js +1 -1
- package/package.json +5 -1
- package/dist/index38.js +0 -84
- package/dist/index38.js.map +0 -1
- package/dist/index39.js +0 -199
- package/dist/index39.js.map +0 -1
- package/dist/lock-keyhole.js +0 -19
- package/dist/lock-keyhole.js.map +0 -1
package/dist/index15.js
CHANGED
|
@@ -1,883 +1,249 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { u as useControllableState, P as Primitive, c as composeEventHandlers, b as createSlot } from './index20.js';
|
|
4
|
-
import { u as useDirection, c as createCollection } from './index23.js';
|
|
2
|
+
import { u as useControllableState, P as Primitive, c as composeEventHandlers, a as createSlot } from './index20.js';
|
|
5
3
|
import { u as useComposedRefs } from './index12.js';
|
|
6
|
-
import { u as useId, c as createContextScope } from './index21.js';
|
|
7
|
-
import { P as Portal$1, D as DismissableLayer } from './
|
|
8
|
-
import { h as hideOthers,
|
|
9
|
-
import { R as Root2$1, A as Anchor, c as createPopperScope, C as Content, a as Arrow } from './
|
|
10
|
-
import {
|
|
11
|
-
import { u as useLayoutEffect2 } from './index28.js';
|
|
12
|
-
import { u as usePrevious } from './index35.js';
|
|
13
|
-
import { V as VISUALLY_HIDDEN_STYLES } from './index27.js';
|
|
14
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { u as useId, P as Presence, c as createContextScope } from './index21.js';
|
|
5
|
+
import { P as Portal$1, D as DismissableLayer } from './index27.js';
|
|
6
|
+
import { h as hideOthers, R as ReactRemoveScroll, u as useFocusGuards, F as FocusScope } from './index28.js';
|
|
7
|
+
import { R as Root2$1, A as Anchor, c as createPopperScope, C as Content, a as Arrow } from './index29.js';
|
|
8
|
+
import { jsx } from 'react/jsx-runtime';
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return Math.min(max, Math.max(min, value));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
|
|
22
|
-
var SELECTION_KEYS = [" ", "Enter"];
|
|
23
|
-
var SELECT_NAME = "Select";
|
|
24
|
-
var [Collection, useCollection, createCollectionScope] = createCollection(SELECT_NAME);
|
|
25
|
-
var [createSelectContext] = createContextScope(SELECT_NAME, [
|
|
26
|
-
createCollectionScope,
|
|
10
|
+
var POPOVER_NAME = "Popover";
|
|
11
|
+
var [createPopoverContext] = createContextScope(POPOVER_NAME, [
|
|
27
12
|
createPopperScope
|
|
28
13
|
]);
|
|
29
14
|
var usePopperScope = createPopperScope();
|
|
30
|
-
var [
|
|
31
|
-
var
|
|
32
|
-
var Select = (props) => {
|
|
15
|
+
var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
|
|
16
|
+
var Popover = (props) => {
|
|
33
17
|
const {
|
|
34
|
-
|
|
18
|
+
__scopePopover,
|
|
35
19
|
children,
|
|
36
20
|
open: openProp,
|
|
37
21
|
defaultOpen,
|
|
38
22
|
onOpenChange,
|
|
39
|
-
|
|
40
|
-
defaultValue,
|
|
41
|
-
onValueChange,
|
|
42
|
-
dir,
|
|
43
|
-
name,
|
|
44
|
-
autoComplete,
|
|
45
|
-
disabled,
|
|
46
|
-
required,
|
|
47
|
-
form
|
|
23
|
+
modal = false
|
|
48
24
|
} = props;
|
|
49
|
-
const popperScope = usePopperScope(
|
|
50
|
-
const
|
|
51
|
-
const [
|
|
52
|
-
const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
|
|
53
|
-
const direction = useDirection(dir);
|
|
25
|
+
const popperScope = usePopperScope(__scopePopover);
|
|
26
|
+
const triggerRef = React.useRef(null);
|
|
27
|
+
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
54
28
|
const [open, setOpen] = useControllableState({
|
|
55
29
|
prop: openProp,
|
|
56
30
|
defaultProp: defaultOpen ?? false,
|
|
57
31
|
onChange: onOpenChange,
|
|
58
|
-
caller:
|
|
59
|
-
});
|
|
60
|
-
const [value, setValue] = useControllableState({
|
|
61
|
-
prop: valueProp,
|
|
62
|
-
defaultProp: defaultValue,
|
|
63
|
-
onChange: onValueChange,
|
|
64
|
-
caller: SELECT_NAME
|
|
32
|
+
caller: POPOVER_NAME
|
|
65
33
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const [nativeOptionsSet, setNativeOptionsSet] = React.useState(/* @__PURE__ */ new Set());
|
|
69
|
-
const nativeSelectKey = Array.from(nativeOptionsSet).map((option) => option.props.value).join(";");
|
|
70
|
-
return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsxs(
|
|
71
|
-
SelectProvider,
|
|
34
|
+
return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
|
|
35
|
+
PopoverProvider,
|
|
72
36
|
{
|
|
73
|
-
|
|
74
|
-
scope: __scopeSelect,
|
|
75
|
-
trigger,
|
|
76
|
-
onTriggerChange: setTrigger,
|
|
77
|
-
valueNode,
|
|
78
|
-
onValueNodeChange: setValueNode,
|
|
79
|
-
valueNodeHasChildren,
|
|
80
|
-
onValueNodeHasChildrenChange: setValueNodeHasChildren,
|
|
37
|
+
scope: __scopePopover,
|
|
81
38
|
contentId: useId(),
|
|
82
|
-
|
|
83
|
-
onValueChange: setValue,
|
|
39
|
+
triggerRef,
|
|
84
40
|
open,
|
|
85
41
|
onOpenChange: setOpen,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
{
|
|
93
|
-
scope: props.__scopeSelect,
|
|
94
|
-
onNativeOptionAdd: React.useCallback((option) => {
|
|
95
|
-
setNativeOptionsSet((prev) => new Set(prev).add(option));
|
|
96
|
-
}, []),
|
|
97
|
-
onNativeOptionRemove: React.useCallback((option) => {
|
|
98
|
-
setNativeOptionsSet((prev) => {
|
|
99
|
-
const optionsSet = new Set(prev);
|
|
100
|
-
optionsSet.delete(option);
|
|
101
|
-
return optionsSet;
|
|
102
|
-
});
|
|
103
|
-
}, []),
|
|
104
|
-
children
|
|
105
|
-
}
|
|
106
|
-
) }),
|
|
107
|
-
isFormControl ? /* @__PURE__ */ jsxs(
|
|
108
|
-
SelectBubbleInput,
|
|
109
|
-
{
|
|
110
|
-
"aria-hidden": true,
|
|
111
|
-
required,
|
|
112
|
-
tabIndex: -1,
|
|
113
|
-
name,
|
|
114
|
-
autoComplete,
|
|
115
|
-
value,
|
|
116
|
-
onChange: (event) => setValue(event.target.value),
|
|
117
|
-
disabled,
|
|
118
|
-
form,
|
|
119
|
-
children: [
|
|
120
|
-
value === void 0 ? /* @__PURE__ */ jsx("option", { value: "" }) : null,
|
|
121
|
-
Array.from(nativeOptionsSet)
|
|
122
|
-
]
|
|
123
|
-
},
|
|
124
|
-
nativeSelectKey
|
|
125
|
-
) : null
|
|
126
|
-
]
|
|
42
|
+
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
43
|
+
hasCustomAnchor,
|
|
44
|
+
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
|
|
45
|
+
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),
|
|
46
|
+
modal,
|
|
47
|
+
children
|
|
127
48
|
}
|
|
128
49
|
) });
|
|
129
50
|
};
|
|
130
|
-
|
|
131
|
-
var
|
|
132
|
-
var
|
|
51
|
+
Popover.displayName = POPOVER_NAME;
|
|
52
|
+
var ANCHOR_NAME = "PopoverAnchor";
|
|
53
|
+
var PopoverAnchor = React.forwardRef(
|
|
133
54
|
(props, forwardedRef) => {
|
|
134
|
-
const {
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (pointerEvent) {
|
|
155
|
-
context.triggerPointerDownPosRef.current = {
|
|
156
|
-
x: Math.round(pointerEvent.pageX),
|
|
157
|
-
y: Math.round(pointerEvent.pageY)
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
return /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
|
|
55
|
+
const { __scopePopover, ...anchorProps } = props;
|
|
56
|
+
const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
|
|
57
|
+
const popperScope = usePopperScope(__scopePopover);
|
|
58
|
+
const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
onCustomAnchorAdd();
|
|
61
|
+
return () => onCustomAnchorRemove();
|
|
62
|
+
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
|
|
63
|
+
return /* @__PURE__ */ jsx(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
PopoverAnchor.displayName = ANCHOR_NAME;
|
|
67
|
+
var TRIGGER_NAME = "PopoverTrigger";
|
|
68
|
+
var PopoverTrigger = React.forwardRef(
|
|
69
|
+
(props, forwardedRef) => {
|
|
70
|
+
const { __scopePopover, ...triggerProps } = props;
|
|
71
|
+
const context = usePopoverContext(TRIGGER_NAME, __scopePopover);
|
|
72
|
+
const popperScope = usePopperScope(__scopePopover);
|
|
73
|
+
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
74
|
+
const trigger = /* @__PURE__ */ jsx(
|
|
162
75
|
Primitive.button,
|
|
163
76
|
{
|
|
164
77
|
type: "button",
|
|
165
|
-
|
|
166
|
-
"aria-controls": context.contentId,
|
|
78
|
+
"aria-haspopup": "dialog",
|
|
167
79
|
"aria-expanded": context.open,
|
|
168
|
-
"aria-
|
|
169
|
-
"
|
|
170
|
-
dir: context.dir,
|
|
171
|
-
"data-state": context.open ? "open" : "closed",
|
|
172
|
-
disabled: isDisabled,
|
|
173
|
-
"data-disabled": isDisabled ? "" : void 0,
|
|
174
|
-
"data-placeholder": shouldShowPlaceholder(context.value) ? "" : void 0,
|
|
80
|
+
"aria-controls": context.contentId,
|
|
81
|
+
"data-state": getState(context.open),
|
|
175
82
|
...triggerProps,
|
|
176
|
-
ref:
|
|
177
|
-
onClick: composeEventHandlers(
|
|
178
|
-
event.currentTarget.focus();
|
|
179
|
-
if (pointerTypeRef.current !== "mouse") {
|
|
180
|
-
handleOpen(event);
|
|
181
|
-
}
|
|
182
|
-
}),
|
|
183
|
-
onPointerDown: composeEventHandlers(triggerProps.onPointerDown, (event) => {
|
|
184
|
-
pointerTypeRef.current = event.pointerType;
|
|
185
|
-
const target = event.target;
|
|
186
|
-
if (target.hasPointerCapture(event.pointerId)) {
|
|
187
|
-
target.releasePointerCapture(event.pointerId);
|
|
188
|
-
}
|
|
189
|
-
if (event.button === 0 && event.ctrlKey === false && event.pointerType === "mouse") {
|
|
190
|
-
handleOpen(event);
|
|
191
|
-
event.preventDefault();
|
|
192
|
-
}
|
|
193
|
-
}),
|
|
194
|
-
onKeyDown: composeEventHandlers(triggerProps.onKeyDown, (event) => {
|
|
195
|
-
const isTypingAhead = searchRef.current !== "";
|
|
196
|
-
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
197
|
-
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
|
198
|
-
if (isTypingAhead && event.key === " ") return;
|
|
199
|
-
if (OPEN_KEYS.includes(event.key)) {
|
|
200
|
-
handleOpen();
|
|
201
|
-
event.preventDefault();
|
|
202
|
-
}
|
|
203
|
-
})
|
|
204
|
-
}
|
|
205
|
-
) });
|
|
206
|
-
}
|
|
207
|
-
);
|
|
208
|
-
SelectTrigger.displayName = TRIGGER_NAME;
|
|
209
|
-
var VALUE_NAME = "SelectValue";
|
|
210
|
-
var SelectValue = React.forwardRef(
|
|
211
|
-
(props, forwardedRef) => {
|
|
212
|
-
const { __scopeSelect, className, style, children, placeholder = "", ...valueProps } = props;
|
|
213
|
-
const context = useSelectContext(VALUE_NAME, __scopeSelect);
|
|
214
|
-
const { onValueNodeHasChildrenChange } = context;
|
|
215
|
-
const hasChildren = children !== void 0;
|
|
216
|
-
const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
|
|
217
|
-
useLayoutEffect2(() => {
|
|
218
|
-
onValueNodeHasChildrenChange(hasChildren);
|
|
219
|
-
}, [onValueNodeHasChildrenChange, hasChildren]);
|
|
220
|
-
return /* @__PURE__ */ jsx(
|
|
221
|
-
Primitive.span,
|
|
222
|
-
{
|
|
223
|
-
...valueProps,
|
|
224
|
-
ref: composedRefs,
|
|
225
|
-
style: { pointerEvents: "none" },
|
|
226
|
-
children: shouldShowPlaceholder(context.value) ? /* @__PURE__ */ jsx(Fragment, { children: placeholder }) : children
|
|
83
|
+
ref: composedTriggerRef,
|
|
84
|
+
onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
227
85
|
}
|
|
228
86
|
);
|
|
87
|
+
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: trigger });
|
|
229
88
|
}
|
|
230
89
|
);
|
|
231
|
-
|
|
232
|
-
var
|
|
233
|
-
var
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
var PORTAL_NAME = "SelectPortal";
|
|
241
|
-
var SelectPortal = (props) => {
|
|
242
|
-
return /* @__PURE__ */ jsx(Portal$1, { asChild: true, ...props });
|
|
90
|
+
PopoverTrigger.displayName = TRIGGER_NAME;
|
|
91
|
+
var PORTAL_NAME = "PopoverPortal";
|
|
92
|
+
var [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {
|
|
93
|
+
forceMount: void 0
|
|
94
|
+
});
|
|
95
|
+
var PopoverPortal = (props) => {
|
|
96
|
+
const { __scopePopover, forceMount, children, container } = props;
|
|
97
|
+
const context = usePopoverContext(PORTAL_NAME, __scopePopover);
|
|
98
|
+
return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
|
|
243
99
|
};
|
|
244
|
-
|
|
245
|
-
var CONTENT_NAME = "
|
|
246
|
-
var
|
|
100
|
+
PopoverPortal.displayName = PORTAL_NAME;
|
|
101
|
+
var CONTENT_NAME = "PopoverContent";
|
|
102
|
+
var PopoverContent = React.forwardRef(
|
|
247
103
|
(props, forwardedRef) => {
|
|
248
|
-
const
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}, []);
|
|
253
|
-
if (!context.open) {
|
|
254
|
-
const frag = fragment;
|
|
255
|
-
return frag ? ReactDOM.createPortal(
|
|
256
|
-
/* @__PURE__ */ jsx(SelectContentProvider, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx("div", { children: props.children }) }) }),
|
|
257
|
-
frag
|
|
258
|
-
) : null;
|
|
259
|
-
}
|
|
260
|
-
return /* @__PURE__ */ jsx(SelectContentImpl, { ...props, ref: forwardedRef });
|
|
104
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);
|
|
105
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
106
|
+
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
|
|
107
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
|
261
108
|
}
|
|
262
109
|
);
|
|
263
|
-
|
|
264
|
-
var
|
|
265
|
-
var
|
|
266
|
-
var CONTENT_IMPL_NAME = "SelectContentImpl";
|
|
267
|
-
var Slot = createSlot("SelectContent.RemoveScroll");
|
|
268
|
-
var SelectContentImpl = React.forwardRef(
|
|
110
|
+
PopoverContent.displayName = CONTENT_NAME;
|
|
111
|
+
var Slot = createSlot("PopoverContent.RemoveScroll");
|
|
112
|
+
var PopoverContentModal = React.forwardRef(
|
|
269
113
|
(props, forwardedRef) => {
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
onEscapeKeyDown,
|
|
275
|
-
onPointerDownOutside,
|
|
276
|
-
//
|
|
277
|
-
// PopperContent props
|
|
278
|
-
side,
|
|
279
|
-
sideOffset,
|
|
280
|
-
align,
|
|
281
|
-
alignOffset,
|
|
282
|
-
arrowPadding,
|
|
283
|
-
collisionBoundary,
|
|
284
|
-
collisionPadding,
|
|
285
|
-
sticky,
|
|
286
|
-
hideWhenDetached,
|
|
287
|
-
avoidCollisions,
|
|
288
|
-
//
|
|
289
|
-
...contentProps
|
|
290
|
-
} = props;
|
|
291
|
-
const context = useSelectContext(CONTENT_NAME, __scopeSelect);
|
|
292
|
-
const [content, setContent] = React.useState(null);
|
|
293
|
-
const [viewport, setViewport] = React.useState(null);
|
|
294
|
-
const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
295
|
-
const [selectedItem, setSelectedItem] = React.useState(null);
|
|
296
|
-
const [selectedItemText, setSelectedItemText] = React.useState(
|
|
297
|
-
null
|
|
298
|
-
);
|
|
299
|
-
const getItems = useCollection(__scopeSelect);
|
|
300
|
-
const [isPositioned, setIsPositioned] = React.useState(false);
|
|
301
|
-
const firstValidItemFoundRef = React.useRef(false);
|
|
114
|
+
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
|
|
115
|
+
const contentRef = React.useRef(null);
|
|
116
|
+
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
117
|
+
const isRightClickOutsideRef = React.useRef(false);
|
|
302
118
|
React.useEffect(() => {
|
|
119
|
+
const content = contentRef.current;
|
|
303
120
|
if (content) return hideOthers(content);
|
|
304
|
-
}, [
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
(candidates) => {
|
|
308
|
-
const [firstItem, ...restItems] = getItems().map((item) => item.ref.current);
|
|
309
|
-
const [lastItem] = restItems.slice(-1);
|
|
310
|
-
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
311
|
-
for (const candidate of candidates) {
|
|
312
|
-
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
313
|
-
candidate?.scrollIntoView({ block: "nearest" });
|
|
314
|
-
if (candidate === firstItem && viewport) viewport.scrollTop = 0;
|
|
315
|
-
if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
|
|
316
|
-
candidate?.focus();
|
|
317
|
-
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
[getItems, viewport]
|
|
321
|
-
);
|
|
322
|
-
const focusSelectedItem = React.useCallback(
|
|
323
|
-
() => focusFirst([selectedItem, content]),
|
|
324
|
-
[focusFirst, selectedItem, content]
|
|
325
|
-
);
|
|
326
|
-
React.useEffect(() => {
|
|
327
|
-
if (isPositioned) {
|
|
328
|
-
focusSelectedItem();
|
|
329
|
-
}
|
|
330
|
-
}, [isPositioned, focusSelectedItem]);
|
|
331
|
-
const { onOpenChange, triggerPointerDownPosRef } = context;
|
|
332
|
-
React.useEffect(() => {
|
|
333
|
-
if (content) {
|
|
334
|
-
let pointerMoveDelta = { x: 0, y: 0 };
|
|
335
|
-
const handlePointerMove = (event) => {
|
|
336
|
-
pointerMoveDelta = {
|
|
337
|
-
x: Math.abs(Math.round(event.pageX) - (triggerPointerDownPosRef.current?.x ?? 0)),
|
|
338
|
-
y: Math.abs(Math.round(event.pageY) - (triggerPointerDownPosRef.current?.y ?? 0))
|
|
339
|
-
};
|
|
340
|
-
};
|
|
341
|
-
const handlePointerUp = (event) => {
|
|
342
|
-
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
|
|
343
|
-
event.preventDefault();
|
|
344
|
-
} else {
|
|
345
|
-
if (!content.contains(event.target)) {
|
|
346
|
-
onOpenChange(false);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
document.removeEventListener("pointermove", handlePointerMove);
|
|
350
|
-
triggerPointerDownPosRef.current = null;
|
|
351
|
-
};
|
|
352
|
-
if (triggerPointerDownPosRef.current !== null) {
|
|
353
|
-
document.addEventListener("pointermove", handlePointerMove);
|
|
354
|
-
document.addEventListener("pointerup", handlePointerUp, { capture: true, once: true });
|
|
355
|
-
}
|
|
356
|
-
return () => {
|
|
357
|
-
document.removeEventListener("pointermove", handlePointerMove);
|
|
358
|
-
document.removeEventListener("pointerup", handlePointerUp, { capture: true });
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
}, [content, onOpenChange, triggerPointerDownPosRef]);
|
|
362
|
-
React.useEffect(() => {
|
|
363
|
-
const close = () => onOpenChange(false);
|
|
364
|
-
window.addEventListener("blur", close);
|
|
365
|
-
window.addEventListener("resize", close);
|
|
366
|
-
return () => {
|
|
367
|
-
window.removeEventListener("blur", close);
|
|
368
|
-
window.removeEventListener("resize", close);
|
|
369
|
-
};
|
|
370
|
-
}, [onOpenChange]);
|
|
371
|
-
const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((search) => {
|
|
372
|
-
const enabledItems = getItems().filter((item) => !item.disabled);
|
|
373
|
-
const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
|
|
374
|
-
const nextItem = findNextItem(enabledItems, search, currentItem);
|
|
375
|
-
if (nextItem) {
|
|
376
|
-
setTimeout(() => nextItem.ref.current.focus());
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
const itemRefCallback = React.useCallback(
|
|
380
|
-
(node, value, disabled) => {
|
|
381
|
-
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
382
|
-
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
383
|
-
if (isSelectedItem || isFirstValidItem) {
|
|
384
|
-
setSelectedItem(node);
|
|
385
|
-
if (isFirstValidItem) firstValidItemFoundRef.current = true;
|
|
386
|
-
}
|
|
387
|
-
},
|
|
388
|
-
[context.value]
|
|
389
|
-
);
|
|
390
|
-
const handleItemLeave = React.useCallback(() => content?.focus(), [content]);
|
|
391
|
-
const itemTextRefCallback = React.useCallback(
|
|
392
|
-
(node, value, disabled) => {
|
|
393
|
-
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
394
|
-
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
395
|
-
if (isSelectedItem || isFirstValidItem) {
|
|
396
|
-
setSelectedItemText(node);
|
|
397
|
-
}
|
|
398
|
-
},
|
|
399
|
-
[context.value]
|
|
400
|
-
);
|
|
401
|
-
const SelectPosition = position === "popper" ? SelectPopperPosition : SelectItemAlignedPosition;
|
|
402
|
-
const popperContentProps = SelectPosition === SelectPopperPosition ? {
|
|
403
|
-
side,
|
|
404
|
-
sideOffset,
|
|
405
|
-
align,
|
|
406
|
-
alignOffset,
|
|
407
|
-
arrowPadding,
|
|
408
|
-
collisionBoundary,
|
|
409
|
-
collisionPadding,
|
|
410
|
-
sticky,
|
|
411
|
-
hideWhenDetached,
|
|
412
|
-
avoidCollisions
|
|
413
|
-
} : {};
|
|
414
|
-
return /* @__PURE__ */ jsx(
|
|
415
|
-
SelectContentProvider,
|
|
121
|
+
}, []);
|
|
122
|
+
return /* @__PURE__ */ jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(
|
|
123
|
+
PopoverContentImpl,
|
|
416
124
|
{
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
event.preventDefault();
|
|
441
|
-
}),
|
|
442
|
-
children: /* @__PURE__ */ jsx(
|
|
443
|
-
DismissableLayer,
|
|
444
|
-
{
|
|
445
|
-
asChild: true,
|
|
446
|
-
disableOutsidePointerEvents: true,
|
|
447
|
-
onEscapeKeyDown,
|
|
448
|
-
onPointerDownOutside,
|
|
449
|
-
onFocusOutside: (event) => event.preventDefault(),
|
|
450
|
-
onDismiss: () => context.onOpenChange(false),
|
|
451
|
-
children: /* @__PURE__ */ jsx(
|
|
452
|
-
SelectPosition,
|
|
453
|
-
{
|
|
454
|
-
role: "listbox",
|
|
455
|
-
id: context.contentId,
|
|
456
|
-
"data-state": context.open ? "open" : "closed",
|
|
457
|
-
dir: context.dir,
|
|
458
|
-
onContextMenu: (event) => event.preventDefault(),
|
|
459
|
-
...contentProps,
|
|
460
|
-
...popperContentProps,
|
|
461
|
-
onPlaced: () => setIsPositioned(true),
|
|
462
|
-
ref: composedRefs,
|
|
463
|
-
style: {
|
|
464
|
-
// flex layout so we can place the scroll buttons properly
|
|
465
|
-
display: "flex",
|
|
466
|
-
flexDirection: "column",
|
|
467
|
-
// reset the outline by default as the content MAY get focused
|
|
468
|
-
outline: "none",
|
|
469
|
-
...contentProps.style
|
|
470
|
-
},
|
|
471
|
-
onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
|
|
472
|
-
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
473
|
-
if (event.key === "Tab") event.preventDefault();
|
|
474
|
-
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
|
475
|
-
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
|
|
476
|
-
const items = getItems().filter((item) => !item.disabled);
|
|
477
|
-
let candidateNodes = items.map((item) => item.ref.current);
|
|
478
|
-
if (["ArrowUp", "End"].includes(event.key)) {
|
|
479
|
-
candidateNodes = candidateNodes.slice().reverse();
|
|
480
|
-
}
|
|
481
|
-
if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
482
|
-
const currentElement = event.target;
|
|
483
|
-
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
484
|
-
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
485
|
-
}
|
|
486
|
-
setTimeout(() => focusFirst(candidateNodes));
|
|
487
|
-
event.preventDefault();
|
|
488
|
-
}
|
|
489
|
-
})
|
|
490
|
-
}
|
|
491
|
-
)
|
|
492
|
-
}
|
|
493
|
-
)
|
|
494
|
-
}
|
|
495
|
-
) })
|
|
125
|
+
...props,
|
|
126
|
+
ref: composedRefs,
|
|
127
|
+
trapFocus: context.open,
|
|
128
|
+
disableOutsidePointerEvents: true,
|
|
129
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
|
|
132
|
+
}),
|
|
133
|
+
onPointerDownOutside: composeEventHandlers(
|
|
134
|
+
props.onPointerDownOutside,
|
|
135
|
+
(event) => {
|
|
136
|
+
const originalEvent = event.detail.originalEvent;
|
|
137
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
138
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
139
|
+
isRightClickOutsideRef.current = isRightClick;
|
|
140
|
+
},
|
|
141
|
+
{ checkForDefaultPrevented: false }
|
|
142
|
+
),
|
|
143
|
+
onFocusOutside: composeEventHandlers(
|
|
144
|
+
props.onFocusOutside,
|
|
145
|
+
(event) => event.preventDefault(),
|
|
146
|
+
{ checkForDefaultPrevented: false }
|
|
147
|
+
)
|
|
496
148
|
}
|
|
497
|
-
);
|
|
149
|
+
) });
|
|
498
150
|
}
|
|
499
151
|
);
|
|
500
|
-
|
|
501
|
-
var ITEM_ALIGNED_POSITION_NAME = "SelectItemAlignedPosition";
|
|
502
|
-
var SelectItemAlignedPosition = React.forwardRef((props, forwardedRef) => {
|
|
503
|
-
const { __scopeSelect, onPlaced, ...popperProps } = props;
|
|
504
|
-
const context = useSelectContext(CONTENT_NAME, __scopeSelect);
|
|
505
|
-
const contentContext = useSelectContentContext(CONTENT_NAME, __scopeSelect);
|
|
506
|
-
const [contentWrapper, setContentWrapper] = React.useState(null);
|
|
507
|
-
const [content, setContent] = React.useState(null);
|
|
508
|
-
const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
509
|
-
const getItems = useCollection(__scopeSelect);
|
|
510
|
-
const shouldExpandOnScrollRef = React.useRef(false);
|
|
511
|
-
const shouldRepositionRef = React.useRef(true);
|
|
512
|
-
const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
|
|
513
|
-
const position = React.useCallback(() => {
|
|
514
|
-
if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
|
|
515
|
-
const triggerRect = context.trigger.getBoundingClientRect();
|
|
516
|
-
const contentRect = content.getBoundingClientRect();
|
|
517
|
-
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
|
518
|
-
const itemTextRect = selectedItemText.getBoundingClientRect();
|
|
519
|
-
if (context.dir !== "rtl") {
|
|
520
|
-
const itemTextOffset = itemTextRect.left - contentRect.left;
|
|
521
|
-
const left = valueNodeRect.left - itemTextOffset;
|
|
522
|
-
const leftDelta = triggerRect.left - left;
|
|
523
|
-
const minContentWidth = triggerRect.width + leftDelta;
|
|
524
|
-
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
525
|
-
const rightEdge = window.innerWidth - CONTENT_MARGIN;
|
|
526
|
-
const clampedLeft = clamp(left, [
|
|
527
|
-
CONTENT_MARGIN,
|
|
528
|
-
// Prevents the content from going off the starting edge of the
|
|
529
|
-
// viewport. It may still go off the ending edge, but this can be
|
|
530
|
-
// controlled by the user since they may want to manage overflow in a
|
|
531
|
-
// specific way.
|
|
532
|
-
// https://github.com/radix-ui/primitives/issues/2049
|
|
533
|
-
Math.max(CONTENT_MARGIN, rightEdge - contentWidth)
|
|
534
|
-
]);
|
|
535
|
-
contentWrapper.style.minWidth = minContentWidth + "px";
|
|
536
|
-
contentWrapper.style.left = clampedLeft + "px";
|
|
537
|
-
} else {
|
|
538
|
-
const itemTextOffset = contentRect.right - itemTextRect.right;
|
|
539
|
-
const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
|
|
540
|
-
const rightDelta = window.innerWidth - triggerRect.right - right;
|
|
541
|
-
const minContentWidth = triggerRect.width + rightDelta;
|
|
542
|
-
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
543
|
-
const leftEdge = window.innerWidth - CONTENT_MARGIN;
|
|
544
|
-
const clampedRight = clamp(right, [
|
|
545
|
-
CONTENT_MARGIN,
|
|
546
|
-
Math.max(CONTENT_MARGIN, leftEdge - contentWidth)
|
|
547
|
-
]);
|
|
548
|
-
contentWrapper.style.minWidth = minContentWidth + "px";
|
|
549
|
-
contentWrapper.style.right = clampedRight + "px";
|
|
550
|
-
}
|
|
551
|
-
const items = getItems();
|
|
552
|
-
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
553
|
-
const itemsHeight = viewport.scrollHeight;
|
|
554
|
-
const contentStyles = window.getComputedStyle(content);
|
|
555
|
-
const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
|
|
556
|
-
const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
|
|
557
|
-
const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
|
|
558
|
-
const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
|
|
559
|
-
const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
|
|
560
|
-
const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
|
|
561
|
-
const viewportStyles = window.getComputedStyle(viewport);
|
|
562
|
-
const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
|
|
563
|
-
const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
|
|
564
|
-
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
|
|
565
|
-
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
|
566
|
-
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
|
567
|
-
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
|
568
|
-
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
|
569
|
-
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
|
570
|
-
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
|
571
|
-
if (willAlignWithoutTopOverflow) {
|
|
572
|
-
const isLastItem = items.length > 0 && selectedItem === items[items.length - 1].ref.current;
|
|
573
|
-
contentWrapper.style.bottom = "0px";
|
|
574
|
-
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
|
575
|
-
const clampedTriggerMiddleToBottomEdge = Math.max(
|
|
576
|
-
triggerMiddleToBottomEdge,
|
|
577
|
-
selectedItemHalfHeight + // viewport might have padding bottom, include it to avoid a scrollable viewport
|
|
578
|
-
(isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth
|
|
579
|
-
);
|
|
580
|
-
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
|
581
|
-
contentWrapper.style.height = height + "px";
|
|
582
|
-
} else {
|
|
583
|
-
const isFirstItem = items.length > 0 && selectedItem === items[0].ref.current;
|
|
584
|
-
contentWrapper.style.top = "0px";
|
|
585
|
-
const clampedTopEdgeToTriggerMiddle = Math.max(
|
|
586
|
-
topEdgeToTriggerMiddle,
|
|
587
|
-
contentBorderTopWidth + viewport.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
|
|
588
|
-
(isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight
|
|
589
|
-
);
|
|
590
|
-
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
|
591
|
-
contentWrapper.style.height = height + "px";
|
|
592
|
-
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
|
593
|
-
}
|
|
594
|
-
contentWrapper.style.margin = `${CONTENT_MARGIN}px 0`;
|
|
595
|
-
contentWrapper.style.minHeight = minContentHeight + "px";
|
|
596
|
-
contentWrapper.style.maxHeight = availableHeight + "px";
|
|
597
|
-
onPlaced?.();
|
|
598
|
-
requestAnimationFrame(() => shouldExpandOnScrollRef.current = true);
|
|
599
|
-
}
|
|
600
|
-
}, [
|
|
601
|
-
getItems,
|
|
602
|
-
context.trigger,
|
|
603
|
-
context.valueNode,
|
|
604
|
-
contentWrapper,
|
|
605
|
-
content,
|
|
606
|
-
viewport,
|
|
607
|
-
selectedItem,
|
|
608
|
-
selectedItemText,
|
|
609
|
-
context.dir,
|
|
610
|
-
onPlaced
|
|
611
|
-
]);
|
|
612
|
-
useLayoutEffect2(() => position(), [position]);
|
|
613
|
-
const [contentZIndex, setContentZIndex] = React.useState();
|
|
614
|
-
useLayoutEffect2(() => {
|
|
615
|
-
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
616
|
-
}, [content]);
|
|
617
|
-
const handleScrollButtonChange = React.useCallback(
|
|
618
|
-
(node) => {
|
|
619
|
-
if (node && shouldRepositionRef.current === true) {
|
|
620
|
-
position();
|
|
621
|
-
focusSelectedItem?.();
|
|
622
|
-
shouldRepositionRef.current = false;
|
|
623
|
-
}
|
|
624
|
-
},
|
|
625
|
-
[position, focusSelectedItem]
|
|
626
|
-
);
|
|
627
|
-
return /* @__PURE__ */ jsx(
|
|
628
|
-
SelectViewportProvider,
|
|
629
|
-
{
|
|
630
|
-
scope: __scopeSelect,
|
|
631
|
-
contentWrapper,
|
|
632
|
-
shouldExpandOnScrollRef,
|
|
633
|
-
onScrollButtonChange: handleScrollButtonChange,
|
|
634
|
-
children: /* @__PURE__ */ jsx(
|
|
635
|
-
"div",
|
|
636
|
-
{
|
|
637
|
-
ref: setContentWrapper,
|
|
638
|
-
style: {
|
|
639
|
-
display: "flex",
|
|
640
|
-
flexDirection: "column",
|
|
641
|
-
position: "fixed",
|
|
642
|
-
zIndex: contentZIndex
|
|
643
|
-
},
|
|
644
|
-
children: /* @__PURE__ */ jsx(
|
|
645
|
-
Primitive.div,
|
|
646
|
-
{
|
|
647
|
-
...popperProps,
|
|
648
|
-
ref: composedRefs,
|
|
649
|
-
style: {
|
|
650
|
-
// When we get the height of the content, it includes borders. If we were to set
|
|
651
|
-
// the height without having `boxSizing: 'border-box'` it would be too big.
|
|
652
|
-
boxSizing: "border-box",
|
|
653
|
-
// We need to ensure the content doesn't get taller than the wrapper
|
|
654
|
-
maxHeight: "100%",
|
|
655
|
-
...popperProps.style
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
)
|
|
659
|
-
}
|
|
660
|
-
)
|
|
661
|
-
}
|
|
662
|
-
);
|
|
663
|
-
});
|
|
664
|
-
SelectItemAlignedPosition.displayName = ITEM_ALIGNED_POSITION_NAME;
|
|
665
|
-
var POPPER_POSITION_NAME = "SelectPopperPosition";
|
|
666
|
-
var SelectPopperPosition = React.forwardRef((props, forwardedRef) => {
|
|
667
|
-
const {
|
|
668
|
-
__scopeSelect,
|
|
669
|
-
align = "start",
|
|
670
|
-
collisionPadding = CONTENT_MARGIN,
|
|
671
|
-
...popperProps
|
|
672
|
-
} = props;
|
|
673
|
-
const popperScope = usePopperScope(__scopeSelect);
|
|
674
|
-
return /* @__PURE__ */ jsx(
|
|
675
|
-
Content,
|
|
676
|
-
{
|
|
677
|
-
...popperScope,
|
|
678
|
-
...popperProps,
|
|
679
|
-
ref: forwardedRef,
|
|
680
|
-
align,
|
|
681
|
-
collisionPadding,
|
|
682
|
-
style: {
|
|
683
|
-
// Ensure border-box for floating-ui calculations
|
|
684
|
-
boxSizing: "border-box",
|
|
685
|
-
...popperProps.style,
|
|
686
|
-
// re-namespace exposed content custom properties
|
|
687
|
-
...{
|
|
688
|
-
"--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
689
|
-
"--radix-select-content-available-width": "var(--radix-popper-available-width)",
|
|
690
|
-
"--radix-select-content-available-height": "var(--radix-popper-available-height)",
|
|
691
|
-
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
|
|
692
|
-
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
);
|
|
697
|
-
});
|
|
698
|
-
SelectPopperPosition.displayName = POPPER_POSITION_NAME;
|
|
699
|
-
var [SelectViewportProvider, useSelectViewportContext] = createSelectContext(CONTENT_NAME, {});
|
|
700
|
-
var VIEWPORT_NAME = "SelectViewport";
|
|
701
|
-
var SelectViewport = React.forwardRef(
|
|
152
|
+
var PopoverContentNonModal = React.forwardRef(
|
|
702
153
|
(props, forwardedRef) => {
|
|
703
|
-
const
|
|
704
|
-
const
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
// (independent of the scrollUpButton).
|
|
729
|
-
position: "relative",
|
|
730
|
-
flex: 1,
|
|
731
|
-
// Viewport should only be scrollable in the vertical direction.
|
|
732
|
-
// This won't work in vertical writing modes, so we'll need to
|
|
733
|
-
// revisit this if/when that is supported
|
|
734
|
-
// https://developer.chrome.com/blog/vertical-form-controls
|
|
735
|
-
overflow: "hidden auto",
|
|
736
|
-
...viewportProps.style
|
|
737
|
-
},
|
|
738
|
-
onScroll: composeEventHandlers(viewportProps.onScroll, (event) => {
|
|
739
|
-
const viewport = event.currentTarget;
|
|
740
|
-
const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
|
|
741
|
-
if (shouldExpandOnScrollRef?.current && contentWrapper) {
|
|
742
|
-
const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
|
|
743
|
-
if (scrolledBy > 0) {
|
|
744
|
-
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
745
|
-
const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
|
|
746
|
-
const cssHeight = parseFloat(contentWrapper.style.height);
|
|
747
|
-
const prevHeight = Math.max(cssMinHeight, cssHeight);
|
|
748
|
-
if (prevHeight < availableHeight) {
|
|
749
|
-
const nextHeight = prevHeight + scrolledBy;
|
|
750
|
-
const clampedNextHeight = Math.min(availableHeight, nextHeight);
|
|
751
|
-
const heightDiff = nextHeight - clampedNextHeight;
|
|
752
|
-
contentWrapper.style.height = clampedNextHeight + "px";
|
|
753
|
-
if (contentWrapper.style.bottom === "0px") {
|
|
754
|
-
viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
|
755
|
-
contentWrapper.style.justifyContent = "flex-end";
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}
|
|
154
|
+
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
|
|
155
|
+
const hasInteractedOutsideRef = React.useRef(false);
|
|
156
|
+
const hasPointerDownOutsideRef = React.useRef(false);
|
|
157
|
+
return /* @__PURE__ */ jsx(
|
|
158
|
+
PopoverContentImpl,
|
|
159
|
+
{
|
|
160
|
+
...props,
|
|
161
|
+
ref: forwardedRef,
|
|
162
|
+
trapFocus: false,
|
|
163
|
+
disableOutsidePointerEvents: false,
|
|
164
|
+
onCloseAutoFocus: (event) => {
|
|
165
|
+
props.onCloseAutoFocus?.(event);
|
|
166
|
+
if (!event.defaultPrevented) {
|
|
167
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
}
|
|
170
|
+
hasInteractedOutsideRef.current = false;
|
|
171
|
+
hasPointerDownOutsideRef.current = false;
|
|
172
|
+
},
|
|
173
|
+
onInteractOutside: (event) => {
|
|
174
|
+
props.onInteractOutside?.(event);
|
|
175
|
+
if (!event.defaultPrevented) {
|
|
176
|
+
hasInteractedOutsideRef.current = true;
|
|
177
|
+
if (event.detail.originalEvent.type === "pointerdown") {
|
|
178
|
+
hasPointerDownOutsideRef.current = true;
|
|
759
179
|
}
|
|
760
|
-
|
|
761
|
-
|
|
180
|
+
}
|
|
181
|
+
const target = event.target;
|
|
182
|
+
const targetIsTrigger = context.triggerRef.current?.contains(target);
|
|
183
|
+
if (targetIsTrigger) event.preventDefault();
|
|
184
|
+
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
}
|
|
762
187
|
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
}
|
|
766
|
-
);
|
|
767
|
-
SelectViewport.displayName = VIEWPORT_NAME;
|
|
768
|
-
var GROUP_NAME = "SelectGroup";
|
|
769
|
-
var [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
|
|
770
|
-
var SelectGroup = React.forwardRef(
|
|
771
|
-
(props, forwardedRef) => {
|
|
772
|
-
const { __scopeSelect, ...groupProps } = props;
|
|
773
|
-
const groupId = useId();
|
|
774
|
-
return /* @__PURE__ */ jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsx(Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
|
|
775
|
-
}
|
|
776
|
-
);
|
|
777
|
-
SelectGroup.displayName = GROUP_NAME;
|
|
778
|
-
var LABEL_NAME = "SelectLabel";
|
|
779
|
-
var SelectLabel = React.forwardRef(
|
|
780
|
-
(props, forwardedRef) => {
|
|
781
|
-
const { __scopeSelect, ...labelProps } = props;
|
|
782
|
-
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
783
|
-
return /* @__PURE__ */ jsx(Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
|
|
188
|
+
}
|
|
189
|
+
);
|
|
784
190
|
}
|
|
785
191
|
);
|
|
786
|
-
|
|
787
|
-
var ITEM_NAME = "SelectItem";
|
|
788
|
-
var [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
|
789
|
-
var SelectItem = React.forwardRef(
|
|
192
|
+
var PopoverContentImpl = React.forwardRef(
|
|
790
193
|
(props, forwardedRef) => {
|
|
791
194
|
const {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
195
|
+
__scopePopover,
|
|
196
|
+
trapFocus,
|
|
197
|
+
onOpenAutoFocus,
|
|
198
|
+
onCloseAutoFocus,
|
|
199
|
+
disableOutsidePointerEvents,
|
|
200
|
+
onEscapeKeyDown,
|
|
201
|
+
onPointerDownOutside,
|
|
202
|
+
onFocusOutside,
|
|
203
|
+
onInteractOutside,
|
|
204
|
+
...contentProps
|
|
797
205
|
} = props;
|
|
798
|
-
const context =
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
const [textValue, setTextValue] = React.useState(textValueProp ?? "");
|
|
802
|
-
const [isFocused, setIsFocused] = React.useState(false);
|
|
803
|
-
const composedRefs = useComposedRefs(
|
|
804
|
-
forwardedRef,
|
|
805
|
-
(node) => contentContext.itemRefCallback?.(node, value, disabled)
|
|
806
|
-
);
|
|
807
|
-
const textId = useId();
|
|
808
|
-
const pointerTypeRef = React.useRef("touch");
|
|
809
|
-
const handleSelect = () => {
|
|
810
|
-
if (!disabled) {
|
|
811
|
-
context.onValueChange(value);
|
|
812
|
-
context.onOpenChange(false);
|
|
813
|
-
}
|
|
814
|
-
};
|
|
815
|
-
if (value === "") {
|
|
816
|
-
throw new Error(
|
|
817
|
-
"A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
|
|
818
|
-
);
|
|
819
|
-
}
|
|
206
|
+
const context = usePopoverContext(CONTENT_NAME, __scopePopover);
|
|
207
|
+
const popperScope = usePopperScope(__scopePopover);
|
|
208
|
+
useFocusGuards();
|
|
820
209
|
return /* @__PURE__ */ jsx(
|
|
821
|
-
|
|
210
|
+
FocusScope,
|
|
822
211
|
{
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
onItemTextChange: React.useCallback((node) => {
|
|
829
|
-
setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? "").trim());
|
|
830
|
-
}, []),
|
|
212
|
+
asChild: true,
|
|
213
|
+
loop: true,
|
|
214
|
+
trapped: trapFocus,
|
|
215
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
216
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
831
217
|
children: /* @__PURE__ */ jsx(
|
|
832
|
-
|
|
218
|
+
DismissableLayer,
|
|
833
219
|
{
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
220
|
+
asChild: true,
|
|
221
|
+
disableOutsidePointerEvents,
|
|
222
|
+
onInteractOutside,
|
|
223
|
+
onEscapeKeyDown,
|
|
224
|
+
onPointerDownOutside,
|
|
225
|
+
onFocusOutside,
|
|
226
|
+
onDismiss: () => context.onOpenChange(false),
|
|
838
227
|
children: /* @__PURE__ */ jsx(
|
|
839
|
-
|
|
228
|
+
Content,
|
|
840
229
|
{
|
|
841
|
-
|
|
842
|
-
"
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
onPointerUp: composeEventHandlers(itemProps.onPointerUp, () => {
|
|
857
|
-
if (pointerTypeRef.current === "mouse") handleSelect();
|
|
858
|
-
}),
|
|
859
|
-
onPointerDown: composeEventHandlers(itemProps.onPointerDown, (event) => {
|
|
860
|
-
pointerTypeRef.current = event.pointerType;
|
|
861
|
-
}),
|
|
862
|
-
onPointerMove: composeEventHandlers(itemProps.onPointerMove, (event) => {
|
|
863
|
-
pointerTypeRef.current = event.pointerType;
|
|
864
|
-
if (disabled) {
|
|
865
|
-
contentContext.onItemLeave?.();
|
|
866
|
-
} else if (pointerTypeRef.current === "mouse") {
|
|
867
|
-
event.currentTarget.focus({ preventScroll: true });
|
|
868
|
-
}
|
|
869
|
-
}),
|
|
870
|
-
onPointerLeave: composeEventHandlers(itemProps.onPointerLeave, (event) => {
|
|
871
|
-
if (event.currentTarget === document.activeElement) {
|
|
872
|
-
contentContext.onItemLeave?.();
|
|
230
|
+
"data-state": getState(context.open),
|
|
231
|
+
role: "dialog",
|
|
232
|
+
id: context.contentId,
|
|
233
|
+
...popperScope,
|
|
234
|
+
...contentProps,
|
|
235
|
+
ref: forwardedRef,
|
|
236
|
+
style: {
|
|
237
|
+
...contentProps.style,
|
|
238
|
+
// re-namespace exposed content custom properties
|
|
239
|
+
...{
|
|
240
|
+
"--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
241
|
+
"--radix-popover-content-available-width": "var(--radix-popper-available-width)",
|
|
242
|
+
"--radix-popover-content-available-height": "var(--radix-popper-available-height)",
|
|
243
|
+
"--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
|
|
244
|
+
"--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
|
|
873
245
|
}
|
|
874
|
-
}
|
|
875
|
-
onKeyDown: composeEventHandlers(itemProps.onKeyDown, (event) => {
|
|
876
|
-
const isTypingAhead = contentContext.searchRef?.current !== "";
|
|
877
|
-
if (isTypingAhead && event.key === " ") return;
|
|
878
|
-
if (SELECTION_KEYS.includes(event.key)) handleSelect();
|
|
879
|
-
if (event.key === " ") event.preventDefault();
|
|
880
|
-
})
|
|
246
|
+
}
|
|
881
247
|
}
|
|
882
248
|
)
|
|
883
249
|
}
|
|
@@ -886,265 +252,39 @@ var SelectItem = React.forwardRef(
|
|
|
886
252
|
);
|
|
887
253
|
}
|
|
888
254
|
);
|
|
889
|
-
|
|
890
|
-
var
|
|
891
|
-
var SelectItemText = React.forwardRef(
|
|
892
|
-
(props, forwardedRef) => {
|
|
893
|
-
const { __scopeSelect, className, style, ...itemTextProps } = props;
|
|
894
|
-
const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
895
|
-
const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
896
|
-
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
897
|
-
const nativeOptionsContext = useSelectNativeOptionsContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
898
|
-
const [itemTextNode, setItemTextNode] = React.useState(null);
|
|
899
|
-
const composedRefs = useComposedRefs(
|
|
900
|
-
forwardedRef,
|
|
901
|
-
(node) => setItemTextNode(node),
|
|
902
|
-
itemContext.onItemTextChange,
|
|
903
|
-
(node) => contentContext.itemTextRefCallback?.(node, itemContext.value, itemContext.disabled)
|
|
904
|
-
);
|
|
905
|
-
const textContent = itemTextNode?.textContent;
|
|
906
|
-
const nativeOption = React.useMemo(
|
|
907
|
-
() => /* @__PURE__ */ jsx("option", { value: itemContext.value, disabled: itemContext.disabled, children: textContent }, itemContext.value),
|
|
908
|
-
[itemContext.disabled, itemContext.value, textContent]
|
|
909
|
-
);
|
|
910
|
-
const { onNativeOptionAdd, onNativeOptionRemove } = nativeOptionsContext;
|
|
911
|
-
useLayoutEffect2(() => {
|
|
912
|
-
onNativeOptionAdd(nativeOption);
|
|
913
|
-
return () => onNativeOptionRemove(nativeOption);
|
|
914
|
-
}, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
|
|
915
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
916
|
-
/* @__PURE__ */ jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
|
|
917
|
-
itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null
|
|
918
|
-
] });
|
|
919
|
-
}
|
|
920
|
-
);
|
|
921
|
-
SelectItemText.displayName = ITEM_TEXT_NAME;
|
|
922
|
-
var ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
923
|
-
var SelectItemIndicator = React.forwardRef(
|
|
924
|
-
(props, forwardedRef) => {
|
|
925
|
-
const { __scopeSelect, ...itemIndicatorProps } = props;
|
|
926
|
-
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
927
|
-
return itemContext.isSelected ? /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
|
|
928
|
-
}
|
|
929
|
-
);
|
|
930
|
-
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
931
|
-
var SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
932
|
-
var SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
933
|
-
const contentContext = useSelectContentContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
934
|
-
const viewportContext = useSelectViewportContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
935
|
-
const [canScrollUp, setCanScrollUp] = React.useState(false);
|
|
936
|
-
const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
|
|
937
|
-
useLayoutEffect2(() => {
|
|
938
|
-
if (contentContext.viewport && contentContext.isPositioned) {
|
|
939
|
-
let handleScroll2 = function() {
|
|
940
|
-
const canScrollUp2 = viewport.scrollTop > 0;
|
|
941
|
-
setCanScrollUp(canScrollUp2);
|
|
942
|
-
};
|
|
943
|
-
const viewport = contentContext.viewport;
|
|
944
|
-
handleScroll2();
|
|
945
|
-
viewport.addEventListener("scroll", handleScroll2);
|
|
946
|
-
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
947
|
-
}
|
|
948
|
-
}, [contentContext.viewport, contentContext.isPositioned]);
|
|
949
|
-
return canScrollUp ? /* @__PURE__ */ jsx(
|
|
950
|
-
SelectScrollButtonImpl,
|
|
951
|
-
{
|
|
952
|
-
...props,
|
|
953
|
-
ref: composedRefs,
|
|
954
|
-
onAutoScroll: () => {
|
|
955
|
-
const { viewport, selectedItem } = contentContext;
|
|
956
|
-
if (viewport && selectedItem) {
|
|
957
|
-
viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
) : null;
|
|
962
|
-
});
|
|
963
|
-
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
964
|
-
var SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
965
|
-
var SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
966
|
-
const contentContext = useSelectContentContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
967
|
-
const viewportContext = useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
968
|
-
const [canScrollDown, setCanScrollDown] = React.useState(false);
|
|
969
|
-
const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
|
|
970
|
-
useLayoutEffect2(() => {
|
|
971
|
-
if (contentContext.viewport && contentContext.isPositioned) {
|
|
972
|
-
let handleScroll2 = function() {
|
|
973
|
-
const maxScroll = viewport.scrollHeight - viewport.clientHeight;
|
|
974
|
-
const canScrollDown2 = Math.ceil(viewport.scrollTop) < maxScroll;
|
|
975
|
-
setCanScrollDown(canScrollDown2);
|
|
976
|
-
};
|
|
977
|
-
const viewport = contentContext.viewport;
|
|
978
|
-
handleScroll2();
|
|
979
|
-
viewport.addEventListener("scroll", handleScroll2);
|
|
980
|
-
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
981
|
-
}
|
|
982
|
-
}, [contentContext.viewport, contentContext.isPositioned]);
|
|
983
|
-
return canScrollDown ? /* @__PURE__ */ jsx(
|
|
984
|
-
SelectScrollButtonImpl,
|
|
985
|
-
{
|
|
986
|
-
...props,
|
|
987
|
-
ref: composedRefs,
|
|
988
|
-
onAutoScroll: () => {
|
|
989
|
-
const { viewport, selectedItem } = contentContext;
|
|
990
|
-
if (viewport && selectedItem) {
|
|
991
|
-
viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
) : null;
|
|
996
|
-
});
|
|
997
|
-
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
998
|
-
var SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
|
|
999
|
-
const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
|
|
1000
|
-
const contentContext = useSelectContentContext("SelectScrollButton", __scopeSelect);
|
|
1001
|
-
const autoScrollTimerRef = React.useRef(null);
|
|
1002
|
-
const getItems = useCollection(__scopeSelect);
|
|
1003
|
-
const clearAutoScrollTimer = React.useCallback(() => {
|
|
1004
|
-
if (autoScrollTimerRef.current !== null) {
|
|
1005
|
-
window.clearInterval(autoScrollTimerRef.current);
|
|
1006
|
-
autoScrollTimerRef.current = null;
|
|
1007
|
-
}
|
|
1008
|
-
}, []);
|
|
1009
|
-
React.useEffect(() => {
|
|
1010
|
-
return () => clearAutoScrollTimer();
|
|
1011
|
-
}, [clearAutoScrollTimer]);
|
|
1012
|
-
useLayoutEffect2(() => {
|
|
1013
|
-
const activeItem = getItems().find((item) => item.ref.current === document.activeElement);
|
|
1014
|
-
activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
|
|
1015
|
-
}, [getItems]);
|
|
1016
|
-
return /* @__PURE__ */ jsx(
|
|
1017
|
-
Primitive.div,
|
|
1018
|
-
{
|
|
1019
|
-
"aria-hidden": true,
|
|
1020
|
-
...scrollIndicatorProps,
|
|
1021
|
-
ref: forwardedRef,
|
|
1022
|
-
style: { flexShrink: 0, ...scrollIndicatorProps.style },
|
|
1023
|
-
onPointerDown: composeEventHandlers(scrollIndicatorProps.onPointerDown, () => {
|
|
1024
|
-
if (autoScrollTimerRef.current === null) {
|
|
1025
|
-
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1026
|
-
}
|
|
1027
|
-
}),
|
|
1028
|
-
onPointerMove: composeEventHandlers(scrollIndicatorProps.onPointerMove, () => {
|
|
1029
|
-
contentContext.onItemLeave?.();
|
|
1030
|
-
if (autoScrollTimerRef.current === null) {
|
|
1031
|
-
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1032
|
-
}
|
|
1033
|
-
}),
|
|
1034
|
-
onPointerLeave: composeEventHandlers(scrollIndicatorProps.onPointerLeave, () => {
|
|
1035
|
-
clearAutoScrollTimer();
|
|
1036
|
-
})
|
|
1037
|
-
}
|
|
1038
|
-
);
|
|
1039
|
-
});
|
|
1040
|
-
var SEPARATOR_NAME = "SelectSeparator";
|
|
1041
|
-
var SelectSeparator = React.forwardRef(
|
|
1042
|
-
(props, forwardedRef) => {
|
|
1043
|
-
const { __scopeSelect, ...separatorProps } = props;
|
|
1044
|
-
return /* @__PURE__ */ jsx(Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
|
|
1045
|
-
}
|
|
1046
|
-
);
|
|
1047
|
-
SelectSeparator.displayName = SEPARATOR_NAME;
|
|
1048
|
-
var ARROW_NAME = "SelectArrow";
|
|
1049
|
-
var SelectArrow = React.forwardRef(
|
|
255
|
+
var CLOSE_NAME = "PopoverClose";
|
|
256
|
+
var PopoverClose = React.forwardRef(
|
|
1050
257
|
(props, forwardedRef) => {
|
|
1051
|
-
const {
|
|
1052
|
-
const
|
|
1053
|
-
const context = useSelectContext(ARROW_NAME, __scopeSelect);
|
|
1054
|
-
const contentContext = useSelectContentContext(ARROW_NAME, __scopeSelect);
|
|
1055
|
-
return context.open && contentContext.position === "popper" ? /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
|
|
1056
|
-
}
|
|
1057
|
-
);
|
|
1058
|
-
SelectArrow.displayName = ARROW_NAME;
|
|
1059
|
-
var BUBBLE_INPUT_NAME = "SelectBubbleInput";
|
|
1060
|
-
var SelectBubbleInput = React.forwardRef(
|
|
1061
|
-
({ __scopeSelect, value, ...props }, forwardedRef) => {
|
|
1062
|
-
const ref = React.useRef(null);
|
|
1063
|
-
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
1064
|
-
const prevValue = usePrevious(value);
|
|
1065
|
-
React.useEffect(() => {
|
|
1066
|
-
const select = ref.current;
|
|
1067
|
-
if (!select) return;
|
|
1068
|
-
const selectProto = window.HTMLSelectElement.prototype;
|
|
1069
|
-
const descriptor = Object.getOwnPropertyDescriptor(
|
|
1070
|
-
selectProto,
|
|
1071
|
-
"value"
|
|
1072
|
-
);
|
|
1073
|
-
const setValue = descriptor.set;
|
|
1074
|
-
if (prevValue !== value && setValue) {
|
|
1075
|
-
const event = new Event("change", { bubbles: true });
|
|
1076
|
-
setValue.call(select, value);
|
|
1077
|
-
select.dispatchEvent(event);
|
|
1078
|
-
}
|
|
1079
|
-
}, [prevValue, value]);
|
|
258
|
+
const { __scopePopover, ...closeProps } = props;
|
|
259
|
+
const context = usePopoverContext(CLOSE_NAME, __scopePopover);
|
|
1080
260
|
return /* @__PURE__ */ jsx(
|
|
1081
|
-
Primitive.
|
|
261
|
+
Primitive.button,
|
|
1082
262
|
{
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
ref:
|
|
1086
|
-
|
|
263
|
+
type: "button",
|
|
264
|
+
...closeProps,
|
|
265
|
+
ref: forwardedRef,
|
|
266
|
+
onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
|
|
1087
267
|
}
|
|
1088
268
|
);
|
|
1089
269
|
}
|
|
1090
270
|
);
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
(function updateSearch(value) {
|
|
1104
|
-
searchRef.current = value;
|
|
1105
|
-
window.clearTimeout(timerRef.current);
|
|
1106
|
-
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
|
1107
|
-
})(search);
|
|
1108
|
-
},
|
|
1109
|
-
[handleSearchChange]
|
|
1110
|
-
);
|
|
1111
|
-
const resetTypeahead = React.useCallback(() => {
|
|
1112
|
-
searchRef.current = "";
|
|
1113
|
-
window.clearTimeout(timerRef.current);
|
|
1114
|
-
}, []);
|
|
1115
|
-
React.useEffect(() => {
|
|
1116
|
-
return () => window.clearTimeout(timerRef.current);
|
|
1117
|
-
}, []);
|
|
1118
|
-
return [searchRef, handleTypeaheadSearch, resetTypeahead];
|
|
1119
|
-
}
|
|
1120
|
-
function findNextItem(items, search, currentItem) {
|
|
1121
|
-
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
1122
|
-
const normalizedSearch = isRepeated ? search[0] : search;
|
|
1123
|
-
const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
|
|
1124
|
-
let wrappedItems = wrapArray(items, Math.max(currentItemIndex, 0));
|
|
1125
|
-
const excludeCurrentItem = normalizedSearch.length === 1;
|
|
1126
|
-
if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v) => v !== currentItem);
|
|
1127
|
-
const nextItem = wrappedItems.find(
|
|
1128
|
-
(item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
|
1129
|
-
);
|
|
1130
|
-
return nextItem !== currentItem ? nextItem : void 0;
|
|
1131
|
-
}
|
|
1132
|
-
function wrapArray(array, startIndex) {
|
|
1133
|
-
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
271
|
+
PopoverClose.displayName = CLOSE_NAME;
|
|
272
|
+
var ARROW_NAME = "PopoverArrow";
|
|
273
|
+
var PopoverArrow = React.forwardRef(
|
|
274
|
+
(props, forwardedRef) => {
|
|
275
|
+
const { __scopePopover, ...arrowProps } = props;
|
|
276
|
+
const popperScope = usePopperScope(__scopePopover);
|
|
277
|
+
return /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
PopoverArrow.displayName = ARROW_NAME;
|
|
281
|
+
function getState(open) {
|
|
282
|
+
return open ? "open" : "closed";
|
|
1134
283
|
}
|
|
1135
|
-
var Root2 =
|
|
1136
|
-
var Trigger =
|
|
1137
|
-
var
|
|
1138
|
-
var
|
|
1139
|
-
var Portal = SelectPortal;
|
|
1140
|
-
var Content2 = SelectContent;
|
|
1141
|
-
var Viewport = SelectViewport;
|
|
1142
|
-
var Group = SelectGroup;
|
|
1143
|
-
var Item = SelectItem;
|
|
1144
|
-
var ItemText = SelectItemText;
|
|
1145
|
-
var ItemIndicator = SelectItemIndicator;
|
|
1146
|
-
var ScrollUpButton = SelectScrollUpButton;
|
|
1147
|
-
var ScrollDownButton = SelectScrollDownButton;
|
|
284
|
+
var Root2 = Popover;
|
|
285
|
+
var Trigger = PopoverTrigger;
|
|
286
|
+
var Portal = PopoverPortal;
|
|
287
|
+
var Content2 = PopoverContent;
|
|
1148
288
|
|
|
1149
|
-
export { Content2 as C,
|
|
289
|
+
export { Content2 as C, Portal as P, Root2 as R, Trigger as T, PopoverPortal as a };
|
|
1150
290
|
//# sourceMappingURL=index15.js.map
|