@overmap-ai/blocks 1.0.40-overlay.1 → 1.0.40-phone-input.0
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/ButtonGroup/ButtonGroup.d.ts +1 -2
- package/dist/ButtonGroup/context.d.ts +2 -7
- package/dist/CheckboxGroup/context.d.ts +2 -6
- package/dist/CheckedIndicator/CheckedIndicator.d.ts +4 -3
- package/dist/CommandMenu/CheckboxIndicator.d.ts +2 -4
- package/dist/CommandMenu/SelectedIndicator.d.ts +2 -3
- package/dist/CommandMenu/context.d.ts +2 -3
- package/dist/Heading/cva.d.ts +1 -1
- package/dist/HoverUtility/HoverUtility.d.ts +2 -2
- package/dist/Link/cva.d.ts +1 -1
- package/dist/Menu/{CheckboxItem/CheckboxItem.d.ts → CheckboxItem.d.ts} +1 -1
- package/dist/Menu/{CheckboxItemIndicator/CheckboxItemIndicator.d.ts → CheckboxItemIndicator.d.ts} +1 -1
- package/dist/Menu/{ClickTrigger/ClickTrigger.d.ts → ClickTrigger.d.ts} +1 -1
- package/dist/Menu/{Content/Content.d.ts → Content.d.ts} +1 -1
- package/dist/Menu/{ContextTrigger/ContextTrigger.d.ts → ContextTrigger.d.ts} +1 -1
- package/dist/Menu/{Group/Group.d.ts → Group.d.ts} +1 -1
- package/dist/Menu/{Input/Field.d.ts → InputField.d.ts} +1 -1
- package/dist/Menu/{Input/Root.d.ts → InputRoot.d.ts} +1 -1
- package/dist/Menu/{Input/Slot.d.ts → InputSlot.d.ts} +1 -1
- package/dist/Menu/{Item/Item.d.ts → Item.d.ts} +1 -1
- package/dist/Menu/{MultiSelectGroup/MultiSelectGroup.d.ts → MultiSelectGroup.d.ts} +1 -1
- package/dist/Menu/{MultiSelectItem/MultiSelectItem.d.ts → MultiSelectItem.d.ts} +1 -1
- package/dist/Menu/PageContent.d.ts +2 -0
- package/dist/Menu/{PageTrigger/PageTrigger.d.ts → PageTrigger.d.ts} +1 -1
- package/dist/Menu/{Pages/Pages.d.ts → Pages.d.ts} +1 -1
- package/dist/Menu/{root/Root.d.ts → Root.d.ts} +1 -1
- package/dist/Menu/{Scroll/Scroll.d.ts → Scroll.d.ts} +1 -1
- package/dist/Menu/{SelectAll/SelectAllItem.d.ts → SelectAllItem.d.ts} +1 -1
- package/dist/Menu/{SelectGroup/SelectGroup.d.ts → SelectGroup.d.ts} +1 -1
- package/dist/Menu/{SelectItem/SelectItem.d.ts → SelectItem.d.ts} +1 -1
- package/dist/Menu/SelectedIndicator.d.ts +4 -0
- package/dist/Menu/{Separator/Separator.d.ts → Separator.d.ts} +1 -1
- package/dist/Menu/{Sub/Sub.d.ts → Sub.d.ts} +1 -1
- package/dist/Menu/{SubContent/SubContent.d.ts → SubContent.d.ts} +1 -1
- package/dist/Menu/{SubTrigger/SubTrigger.d.ts → SubTrigger.d.ts} +1 -1
- package/dist/Menu/{VirtualTrigger/VirtualTrigger.d.ts → VirtualTrigger.d.ts} +1 -1
- package/dist/Menu/index.d.ts +9 -7
- package/dist/Menu/{Content/context.d.ts → menuContentContext.d.ts} +2 -2
- package/dist/Menu/{root/context.d.ts → rootContext.d.ts} +1 -1
- package/dist/Menu/{Sub/context.d.ts → subContentContext.d.ts} +1 -1
- package/dist/Menu/utils.d.ts +0 -6
- package/dist/MenuV2/CheckboxItem.d.ts +6 -0
- package/dist/MenuV2/CheckboxItemIndicator.d.ts +3 -0
- package/dist/MenuV2/Group.d.ts +4 -0
- package/dist/MenuV2/GroupLabel.d.ts +4 -0
- package/dist/MenuV2/Item.d.ts +6 -0
- package/dist/MenuV2/MultiSelectAllItem.d.ts +4 -0
- package/dist/MenuV2/MultiSelectGroup.d.ts +5 -0
- package/dist/MenuV2/MultiSelectItem.d.ts +5 -0
- package/dist/MenuV2/Page.d.ts +5 -0
- package/dist/MenuV2/PageTriggerItem.d.ts +5 -0
- package/dist/MenuV2/Pages.d.ts +7 -0
- package/dist/MenuV2/Root.d.ts +6 -0
- package/dist/MenuV2/SelectGroup.d.ts +4 -0
- package/dist/MenuV2/SelectItem.d.ts +5 -0
- package/dist/MenuV2/SelectedIndicator.d.ts +3 -0
- package/dist/MenuV2/Separator.d.ts +5 -0
- package/dist/MenuV2/constants.d.ts +9 -0
- package/dist/MenuV2/context.d.ts +17 -0
- package/dist/MenuV2/cva.d.ts +14 -0
- package/dist/MenuV2/index.d.ts +36 -0
- package/dist/MenuV2/typings.d.ts +9 -0
- package/dist/MenuV2/utils.d.ts +1 -0
- package/dist/PhoneNumberInput/CountrySelect.d.ts +11 -0
- package/dist/PhoneNumberInput/FlagComponent.d.ts +2 -0
- package/dist/PhoneNumberInput/InputComponent.d.ts +5 -0
- package/dist/PhoneNumberInput/PhoneNumberInput.d.ts +6 -0
- package/dist/PhoneNumberInput/context.d.ts +4 -0
- package/dist/PhoneNumberInput/index.d.ts +2 -0
- package/dist/PhoneNumberInput/typings.d.ts +9 -0
- package/dist/Rating/Item.d.ts +6 -0
- package/dist/Rating/ItemIndicator.d.ts +5 -0
- package/dist/Rating/Root.d.ts +8 -0
- package/dist/Rating/context.d.ts +9 -0
- package/dist/Rating/index.d.ts +9 -0
- package/dist/SelectedIndicator/SelectedIndicator.d.ts +5 -0
- package/dist/{Menu/SelectedIndicator → SelectedIndicator}/context.d.ts +0 -1
- package/dist/SelectedIndicator/index.d.ts +2 -0
- package/dist/SlideOut/SlideOut.d.ts +1 -2
- package/dist/Text/cva.d.ts +1 -1
- package/dist/blocks.js +1364 -864
- package/dist/blocks.js.map +1 -1
- package/dist/blocks.umd.cjs +1652 -1155
- package/dist/blocks.umd.cjs.map +1 -1
- package/dist/hooks.d.ts +20 -0
- package/dist/index.d.ts +5 -2
- package/dist/typings.d.ts +0 -5
- package/dist/utils.d.ts +7 -30
- package/package.json +2 -1
- package/dist/CheckboxGroup/utils.d.ts +0 -1
- package/dist/CollapsibleTree/CollapsibleTree.d.ts +0 -5
- package/dist/CollapsibleTree/context.d.ts +0 -11
- package/dist/CollapsibleTree/index.d.ts +0 -2
- package/dist/CollapsibleTree/typings.d.ts +0 -58
- package/dist/CommandMenu/utils.d.ts +0 -4
- package/dist/Menu/ClickTrigger/index.d.ts +0 -1
- package/dist/Menu/Content/index.d.ts +0 -2
- package/dist/Menu/ContextTrigger/index.d.ts +0 -1
- package/dist/Menu/Group/index.d.ts +0 -1
- package/dist/Menu/Input/index.d.ts +0 -3
- package/dist/Menu/Item/index.d.ts +0 -1
- package/dist/Menu/Label/index.d.ts +0 -1
- package/dist/Menu/MultiSelectGroup/index.d.ts +0 -1
- package/dist/Menu/MultiSelectItem/index.d.ts +0 -1
- package/dist/Menu/PageContent/PageContent.d.ts +0 -3
- package/dist/Menu/PageContent/index.d.ts +0 -1
- package/dist/Menu/PageTrigger/index.d.ts +0 -1
- package/dist/Menu/Pages/index.d.ts +0 -2
- package/dist/Menu/SelectAll/index.d.ts +0 -1
- package/dist/Menu/SelectGroup/index.d.ts +0 -1
- package/dist/Menu/SelectItem/index.d.ts +0 -1
- package/dist/Menu/SelectedIndicator/SelectedIndicator.d.ts +0 -4
- package/dist/Menu/SelectedIndicator/index.d.ts +0 -2
- package/dist/Menu/Separator/index.d.ts +0 -1
- package/dist/Menu/Sub/index.d.ts +0 -2
- package/dist/Menu/SubContent/index.d.ts +0 -1
- package/dist/Menu/SubTrigger/index.d.ts +0 -1
- package/dist/Menu/VirtualTrigger/index.d.ts +0 -1
- package/dist/Menu/root/index.d.ts +0 -2
- /package/dist/Menu/{Label/Label.d.ts → Label.d.ts} +0 -0
- /package/dist/Menu/{Pages/context.d.ts → menuPagesContext.d.ts} +0 -0
package/dist/blocks.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@radix-ui/react-alert-dialog"), require("react/jsx-runtime"), require("class-variance-authority"), require("react"), require("@radix-ui/react-avatar"), require("@radix-ui/react-checkbox"), require("react-responsive"), require("
|
|
3
|
-
})(this, function(exports2, RadixAlertDialog, jsxRuntime, classVarianceAuthority,
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@radix-ui/react-alert-dialog"), require("react/jsx-runtime"), require("class-variance-authority"), require("react"), require("@radix-ui/react-avatar"), require("@radix-ui/react-checkbox"), require("react-responsive"), require("cmdk"), require("@radix-ui/react-dialog"), require("react-day-picker"), require("lucide-react/dynamic"), require("@radix-ui/react-hover-card"), require("react-transition-group"), require("react-dom"), require("@radix-ui/react-slot"), require("@floating-ui/react"), require("@radix-ui/react-separator"), require("@radix-ui/react-one-time-password-field"), require("react-error-boundary"), require("react-phone-number-input"), require("lucide-react"), require("react-phone-number-input/min"), require("@radix-ui/react-popover"), require("@radix-ui/react-progress"), require("@radix-ui/react-radio-group"), require("@radix-ui/react-toggle-group"), require("@radix-ui/react-tabs"), require("@radix-ui/react-slider"), require("@radix-ui/react-switch"), require("@radix-ui/react-toast"), require("@radix-ui/react-toggle"), require("@radix-ui/react-tooltip")) : typeof define === "function" && define.amd ? define(["exports", "@radix-ui/react-alert-dialog", "react/jsx-runtime", "class-variance-authority", "react", "@radix-ui/react-avatar", "@radix-ui/react-checkbox", "react-responsive", "cmdk", "@radix-ui/react-dialog", "react-day-picker", "lucide-react/dynamic", "@radix-ui/react-hover-card", "react-transition-group", "react-dom", "@radix-ui/react-slot", "@floating-ui/react", "@radix-ui/react-separator", "@radix-ui/react-one-time-password-field", "react-error-boundary", "react-phone-number-input", "lucide-react", "react-phone-number-input/min", "@radix-ui/react-popover", "@radix-ui/react-progress", "@radix-ui/react-radio-group", "@radix-ui/react-toggle-group", "@radix-ui/react-tabs", "@radix-ui/react-slider", "@radix-ui/react-switch", "@radix-ui/react-toast", "@radix-ui/react-toggle", "@radix-ui/react-tooltip"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.blocks = {}, global.RadixAlertDialog, global.jsxRuntime, global.classVarianceAuthority, global.react, global.RadixAvatar, global.RadixCheckbox, global.reactResponsive, global.cmdk, global.RadixDialog, global.reactDayPicker, global.dynamic, global.RadixHoverCard, global.reactTransitionGroup, global.ReactDOM, global.reactSlot, global.react$1, global.RadixSeparator, global.RadixOneTimePasswordField, global.reactErrorBoundary, global.PhoneInput, global.lucideReact, global.min, global.RadixPopover, global.RadixProgress, global.RadixRadioGroup, global.RadixToggleGroup, global.RadixTabs, global.RadixSlider, global.RadixSwitch, global.RadixToast, global.Toggle, global.RadixTooltip));
|
|
3
|
+
})(this, function(exports2, RadixAlertDialog, jsxRuntime, classVarianceAuthority, react, RadixAvatar, RadixCheckbox, reactResponsive, cmdk, RadixDialog, reactDayPicker, dynamic, RadixHoverCard, reactTransitionGroup, ReactDOM, reactSlot, react$1, RadixSeparator, RadixOneTimePasswordField, reactErrorBoundary, PhoneInput, lucideReact, min, RadixPopover, RadixProgress, RadixRadioGroup, RadixToggleGroup, RadixTabs, RadixSlider, RadixSwitch, RadixToast, Toggle, RadixTooltip) {
|
|
4
4
|
"use strict";
|
|
5
5
|
function _interopNamespaceDefault(e) {
|
|
6
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -19,10 +19,8 @@
|
|
|
19
19
|
return Object.freeze(n);
|
|
20
20
|
}
|
|
21
21
|
const RadixAlertDialog__namespace = /* @__PURE__ */ _interopNamespaceDefault(RadixAlertDialog);
|
|
22
|
-
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
23
22
|
const RadixAvatar__namespace = /* @__PURE__ */ _interopNamespaceDefault(RadixAvatar);
|
|
24
23
|
const RadixCheckbox__namespace = /* @__PURE__ */ _interopNamespaceDefault(RadixCheckbox);
|
|
25
|
-
const RadixPrimitiveCollapsible__namespace = /* @__PURE__ */ _interopNamespaceDefault(RadixPrimitiveCollapsible);
|
|
26
24
|
const RadixDialog__namespace = /* @__PURE__ */ _interopNamespaceDefault(RadixDialog);
|
|
27
25
|
const RadixHoverCard__namespace = /* @__PURE__ */ _interopNamespaceDefault(RadixHoverCard);
|
|
28
26
|
const RadixSeparator__namespace = /* @__PURE__ */ _interopNamespaceDefault(RadixSeparator);
|
|
@@ -103,17 +101,17 @@
|
|
|
103
101
|
}
|
|
104
102
|
]
|
|
105
103
|
});
|
|
106
|
-
const ProviderContext =
|
|
104
|
+
const ProviderContext = react.createContext({});
|
|
107
105
|
const useProvider = () => {
|
|
108
|
-
const context =
|
|
106
|
+
const context = react.useContext(ProviderContext);
|
|
109
107
|
if (!context) {
|
|
110
108
|
throw new Error("useProvider must be used within a Provider");
|
|
111
109
|
}
|
|
112
110
|
return context;
|
|
113
111
|
};
|
|
114
|
-
const Provider =
|
|
112
|
+
const Provider = react.memo((props) => {
|
|
115
113
|
const { accentColor, radius = "md", children } = props;
|
|
116
|
-
const contextValue =
|
|
114
|
+
const contextValue = react.useMemo(
|
|
117
115
|
() => ({
|
|
118
116
|
accentColor,
|
|
119
117
|
radius
|
|
@@ -180,7 +178,7 @@
|
|
|
180
178
|
}
|
|
181
179
|
}
|
|
182
180
|
);
|
|
183
|
-
const AlertDialogContent =
|
|
181
|
+
const AlertDialogContent = react.memo((props) => {
|
|
184
182
|
const { radius } = useProvider();
|
|
185
183
|
const { ref, children, className, size, container, ...rest } = props;
|
|
186
184
|
return /* @__PURE__ */ jsxRuntime.jsxs(RadixAlertDialog__namespace.Portal, { container, children: [
|
|
@@ -198,18 +196,18 @@
|
|
|
198
196
|
] });
|
|
199
197
|
});
|
|
200
198
|
AlertDialogContent.displayName = "AlertDialogContent";
|
|
201
|
-
const AlertDialogContext =
|
|
199
|
+
const AlertDialogContext = react.createContext(() => {
|
|
202
200
|
throw new Error("No AlertDialogProvider found");
|
|
203
201
|
});
|
|
204
202
|
const useAlertDialog = () => {
|
|
205
|
-
const alertDialogContext =
|
|
203
|
+
const alertDialogContext = react.useContext(AlertDialogContext);
|
|
206
204
|
if (!alertDialogContext) {
|
|
207
205
|
throw new Error("No AlertDialogProvider found");
|
|
208
206
|
}
|
|
209
207
|
return alertDialogContext;
|
|
210
208
|
};
|
|
211
|
-
const ButtonGroupContext =
|
|
212
|
-
const ButtonGroup =
|
|
209
|
+
const ButtonGroupContext = react.createContext({});
|
|
210
|
+
const ButtonGroup = react.memo((props) => {
|
|
213
211
|
const providerContext = useProvider();
|
|
214
212
|
const {
|
|
215
213
|
children,
|
|
@@ -219,7 +217,7 @@
|
|
|
219
217
|
accentColor = providerContext.accentColor,
|
|
220
218
|
...rest
|
|
221
219
|
} = props;
|
|
222
|
-
const value =
|
|
220
|
+
const value = react.useMemo(
|
|
223
221
|
() => ({
|
|
224
222
|
variant,
|
|
225
223
|
size,
|
|
@@ -231,7 +229,7 @@
|
|
|
231
229
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(ButtonGroupContext.Provider, { value, children }) });
|
|
232
230
|
});
|
|
233
231
|
ButtonGroup.displayName = "Buttons";
|
|
234
|
-
const useButtonGroup = () =>
|
|
232
|
+
const useButtonGroup = () => react.useContext(ButtonGroupContext);
|
|
235
233
|
const buttonCva = classVarianceAuthority.cva(
|
|
236
234
|
[
|
|
237
235
|
"inline-flex",
|
|
@@ -385,7 +383,7 @@
|
|
|
385
383
|
}
|
|
386
384
|
}
|
|
387
385
|
);
|
|
388
|
-
const Button =
|
|
386
|
+
const Button = react.memo((props) => {
|
|
389
387
|
const providerContext = useProvider();
|
|
390
388
|
const buttonsContext = useButtonGroup();
|
|
391
389
|
const {
|
|
@@ -410,7 +408,7 @@
|
|
|
410
408
|
);
|
|
411
409
|
});
|
|
412
410
|
Button.displayName = "Button";
|
|
413
|
-
const IconButton =
|
|
411
|
+
const IconButton = react.memo((props) => {
|
|
414
412
|
const providerContext = useProvider();
|
|
415
413
|
const buttonsContext = useButtonGroup();
|
|
416
414
|
const {
|
|
@@ -435,11 +433,11 @@
|
|
|
435
433
|
);
|
|
436
434
|
});
|
|
437
435
|
IconButton.displayName = "IconButton";
|
|
438
|
-
const AlertDialogProvider =
|
|
436
|
+
const AlertDialogProvider = react.memo((props) => {
|
|
439
437
|
const { children } = props;
|
|
440
|
-
const [open, setOpen] =
|
|
441
|
-
const [options, setOptions] =
|
|
442
|
-
const handleOpenChange =
|
|
438
|
+
const [open, setOpen] = react.useState(false);
|
|
439
|
+
const [options, setOptions] = react.useState(null);
|
|
440
|
+
const handleOpenChange = react.useCallback(
|
|
443
441
|
(open2) => {
|
|
444
442
|
var _a;
|
|
445
443
|
setOpen(open2);
|
|
@@ -448,7 +446,7 @@
|
|
|
448
446
|
},
|
|
449
447
|
[options]
|
|
450
448
|
);
|
|
451
|
-
const openAlertDialog =
|
|
449
|
+
const openAlertDialog = react.useCallback(
|
|
452
450
|
(config) => {
|
|
453
451
|
if (open) throw new Error("AlertDialog is already open");
|
|
454
452
|
setOpen(true);
|
|
@@ -485,7 +483,7 @@
|
|
|
485
483
|
Action: RadixAlertDialog__namespace.Action,
|
|
486
484
|
Cancel: RadixAlertDialog__namespace.Cancel
|
|
487
485
|
};
|
|
488
|
-
const AvatarContext =
|
|
486
|
+
const AvatarContext = react.createContext({});
|
|
489
487
|
const avatar = classVarianceAuthority.cva(["shrink-0", "select-none", "inline-block", "align-middle"], {
|
|
490
488
|
variants: {
|
|
491
489
|
size: {
|
|
@@ -513,13 +511,13 @@
|
|
|
513
511
|
variant: "solid"
|
|
514
512
|
}
|
|
515
513
|
});
|
|
516
|
-
const AvatarFallback =
|
|
514
|
+
const AvatarFallback = react.memo((props) => {
|
|
517
515
|
const { ref, children, className, ...rest } = props;
|
|
518
|
-
const { variant } =
|
|
516
|
+
const { variant } = react.useContext(AvatarContext);
|
|
519
517
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixAvatar__namespace.AvatarFallback, { className: classVarianceAuthority.cx(avatarFallback({ variant }), className), ref, ...rest, children });
|
|
520
518
|
});
|
|
521
519
|
AvatarFallback.displayName = "AvatarFallback";
|
|
522
|
-
const AvatarImage =
|
|
520
|
+
const AvatarImage = react.memo((props) => {
|
|
523
521
|
const { ref, className, ...rest } = props;
|
|
524
522
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
525
523
|
RadixAvatar__namespace.Image,
|
|
@@ -531,7 +529,7 @@
|
|
|
531
529
|
);
|
|
532
530
|
});
|
|
533
531
|
AvatarImage.displayName = "AvatarImage";
|
|
534
|
-
const AvatarRoot =
|
|
532
|
+
const AvatarRoot = react.memo((props) => {
|
|
535
533
|
const providerContext = useProvider();
|
|
536
534
|
const {
|
|
537
535
|
ref,
|
|
@@ -639,7 +637,7 @@
|
|
|
639
637
|
icon: false
|
|
640
638
|
}
|
|
641
639
|
});
|
|
642
|
-
const Badge =
|
|
640
|
+
const Badge = react.memo((props) => {
|
|
643
641
|
const providerContext = useProvider();
|
|
644
642
|
const {
|
|
645
643
|
ref,
|
|
@@ -684,7 +682,7 @@
|
|
|
684
682
|
variant: "surface"
|
|
685
683
|
}
|
|
686
684
|
});
|
|
687
|
-
const Card =
|
|
685
|
+
const Card = react.memo((props) => {
|
|
688
686
|
const providerContext = useProvider();
|
|
689
687
|
const {
|
|
690
688
|
ref,
|
|
@@ -708,7 +706,7 @@
|
|
|
708
706
|
);
|
|
709
707
|
});
|
|
710
708
|
Card.displayName = "Card";
|
|
711
|
-
const CheckboxIndicator =
|
|
709
|
+
const CheckboxIndicator = react.memo((props) => {
|
|
712
710
|
const { ref, children, className, ...rest } = props;
|
|
713
711
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
714
712
|
RadixCheckbox__namespace.CheckboxIndicator,
|
|
@@ -764,7 +762,7 @@
|
|
|
764
762
|
}
|
|
765
763
|
}
|
|
766
764
|
);
|
|
767
|
-
const CheckboxRoot =
|
|
765
|
+
const CheckboxRoot = react.memo((props) => {
|
|
768
766
|
const providerContext = useProvider();
|
|
769
767
|
const {
|
|
770
768
|
ref,
|
|
@@ -792,94 +790,18 @@
|
|
|
792
790
|
Root: CheckboxRoot,
|
|
793
791
|
Indicator: CheckboxIndicator
|
|
794
792
|
};
|
|
795
|
-
const SelectContext =
|
|
796
|
-
const MultiSelectContext =
|
|
797
|
-
const usePassiveLayoutEffect = React[typeof document !== "undefined" && document.createElement !== void 0 ? "useLayoutEffect" : "useEffect"];
|
|
798
|
-
const useLatest = (current) => {
|
|
799
|
-
const storedValue = React__namespace.useRef(current);
|
|
800
|
-
React__namespace.useEffect(() => {
|
|
801
|
-
storedValue.current = current;
|
|
802
|
-
});
|
|
803
|
-
return storedValue;
|
|
804
|
-
};
|
|
805
|
-
function _ref() {
|
|
806
|
-
}
|
|
807
|
-
function useResizeObserver(target, callback, options = {}) {
|
|
808
|
-
const resizeObserver = getResizeObserver(options.polyfill);
|
|
809
|
-
const storedCallback = useLatest(callback);
|
|
810
|
-
usePassiveLayoutEffect(() => {
|
|
811
|
-
let didUnsubscribe = false;
|
|
812
|
-
const targetEl = target && "current" in target ? target.current : target;
|
|
813
|
-
if (!targetEl) return _ref;
|
|
814
|
-
function cb(entry, observer) {
|
|
815
|
-
if (didUnsubscribe) return;
|
|
816
|
-
storedCallback.current(entry, observer);
|
|
817
|
-
}
|
|
818
|
-
resizeObserver.subscribe(targetEl, cb);
|
|
819
|
-
return () => {
|
|
820
|
-
didUnsubscribe = true;
|
|
821
|
-
resizeObserver.unsubscribe(targetEl, cb);
|
|
822
|
-
};
|
|
823
|
-
}, [target, resizeObserver, storedCallback]);
|
|
824
|
-
return resizeObserver.observer;
|
|
825
|
-
}
|
|
826
|
-
function createResizeObserver(polyfill) {
|
|
827
|
-
let ticking = false;
|
|
828
|
-
let allEntries = [];
|
|
829
|
-
const callbacks = /* @__PURE__ */ new Map();
|
|
830
|
-
const observer = new (polyfill || window.ResizeObserver)((entries, obs) => {
|
|
831
|
-
allEntries = allEntries.concat(entries);
|
|
832
|
-
function _ref2() {
|
|
833
|
-
const triggered = /* @__PURE__ */ new Set();
|
|
834
|
-
for (let i = 0; i < allEntries.length; i++) {
|
|
835
|
-
if (triggered.has(allEntries[i].target)) continue;
|
|
836
|
-
triggered.add(allEntries[i].target);
|
|
837
|
-
const cbs = callbacks.get(allEntries[i].target);
|
|
838
|
-
cbs === null || cbs === void 0 ? void 0 : cbs.forEach((cb) => cb(allEntries[i], obs));
|
|
839
|
-
}
|
|
840
|
-
allEntries = [];
|
|
841
|
-
ticking = false;
|
|
842
|
-
}
|
|
843
|
-
if (!ticking) {
|
|
844
|
-
window.requestAnimationFrame(_ref2);
|
|
845
|
-
}
|
|
846
|
-
ticking = true;
|
|
847
|
-
});
|
|
848
|
-
return {
|
|
849
|
-
observer,
|
|
850
|
-
subscribe(target, callback) {
|
|
851
|
-
var _callbacks$get;
|
|
852
|
-
observer.observe(target);
|
|
853
|
-
const cbs = (_callbacks$get = callbacks.get(target)) !== null && _callbacks$get !== void 0 ? _callbacks$get : [];
|
|
854
|
-
cbs.push(callback);
|
|
855
|
-
callbacks.set(target, cbs);
|
|
856
|
-
},
|
|
857
|
-
unsubscribe(target, callback) {
|
|
858
|
-
var _callbacks$get2;
|
|
859
|
-
const cbs = (_callbacks$get2 = callbacks.get(target)) !== null && _callbacks$get2 !== void 0 ? _callbacks$get2 : [];
|
|
860
|
-
if (cbs.length === 1) {
|
|
861
|
-
observer.unobserve(target);
|
|
862
|
-
callbacks.delete(target);
|
|
863
|
-
return;
|
|
864
|
-
}
|
|
865
|
-
const cbIndex = cbs.indexOf(callback);
|
|
866
|
-
if (cbIndex !== -1) cbs.splice(cbIndex, 1);
|
|
867
|
-
callbacks.set(target, cbs);
|
|
868
|
-
}
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
let _resizeObserver;
|
|
872
|
-
const getResizeObserver = (polyfill) => !_resizeObserver ? _resizeObserver = createResizeObserver(polyfill) : _resizeObserver;
|
|
793
|
+
const SelectContext = react.createContext({});
|
|
794
|
+
const MultiSelectContext = react.createContext({});
|
|
873
795
|
const useViewportSize = (props) => {
|
|
874
796
|
const { xs: xsProps, sm: smProps, md: mdProps, lg: lgProps, xl: xlProps } = props;
|
|
875
|
-
const [prevSize, setPrevSize] =
|
|
876
|
-
const [size, setSize] =
|
|
797
|
+
const [prevSize, setPrevSize] = react.useState("initial");
|
|
798
|
+
const [size, setSize] = react.useState("initial");
|
|
877
799
|
const xs = reactResponsive.useMediaQuery({ minWidth: xsProps });
|
|
878
800
|
const sm = reactResponsive.useMediaQuery({ minWidth: smProps });
|
|
879
801
|
const md = reactResponsive.useMediaQuery({ minWidth: mdProps });
|
|
880
802
|
const lg = reactResponsive.useMediaQuery({ minWidth: lgProps });
|
|
881
803
|
const xl = reactResponsive.useMediaQuery({ minWidth: xlProps });
|
|
882
|
-
|
|
804
|
+
react.useLayoutEffect(() => {
|
|
883
805
|
setSize((prev) => {
|
|
884
806
|
setPrevSize(prev);
|
|
885
807
|
return xl ? "xl" : lg ? "lg" : md ? "md" : sm ? "sm" : xs ? "xs" : "initial";
|
|
@@ -887,69 +809,58 @@
|
|
|
887
809
|
}, [lg, md, sm, xl, xs]);
|
|
888
810
|
return { size, prevSize, xs, sm, md, lg, xl };
|
|
889
811
|
};
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
const [filteredOptions, setFilteredOptions] = React.useState([]);
|
|
897
|
-
const [filterValue, setFilterValue] = React.useState("");
|
|
898
|
-
React.useEffect(() => {
|
|
899
|
-
setFilteredOptions(values.filter((value) => filterFunction(value, filterValue)));
|
|
900
|
-
}, [filterFunction, filterValue, values]);
|
|
812
|
+
function useTextFilter(items, filterFunction) {
|
|
813
|
+
const [filteredOptions, setFilteredOptions] = react.useState([]);
|
|
814
|
+
const [filterValue, setFilterValue] = react.useState("");
|
|
815
|
+
react.useEffect(() => {
|
|
816
|
+
setFilteredOptions(items.filter((value) => filterFunction(value, filterValue)));
|
|
817
|
+
}, [filterFunction, filterValue, items]);
|
|
901
818
|
return [filteredOptions, filterValue, setFilterValue];
|
|
902
819
|
}
|
|
903
|
-
const useSize = (target) => {
|
|
904
|
-
const [size, setSize] = React.useState();
|
|
905
|
-
React.useLayoutEffect(() => {
|
|
906
|
-
var _a;
|
|
907
|
-
setSize((_a = target.current) == null ? void 0 : _a.getBoundingClientRect());
|
|
908
|
-
}, [target]);
|
|
909
|
-
const handleResize = React.useCallback((entry) => {
|
|
910
|
-
const rect = entry.contentRect;
|
|
911
|
-
setSize(rect);
|
|
912
|
-
}, []);
|
|
913
|
-
useResizeObserver(target, handleResize);
|
|
914
|
-
return size;
|
|
915
|
-
};
|
|
916
|
-
const genericMemo = React.memo;
|
|
917
820
|
function useControlledState(initialState, state, setState) {
|
|
918
|
-
const [uncontrolledState, setUncontrolledState] =
|
|
919
|
-
const handleStateChange =
|
|
821
|
+
const [uncontrolledState, setUncontrolledState] = react.useState(initialState);
|
|
822
|
+
const handleStateChange = react.useCallback(
|
|
920
823
|
(state2) => {
|
|
921
824
|
setUncontrolledState(state2);
|
|
922
825
|
setState == null ? void 0 : setState(state2);
|
|
923
826
|
},
|
|
924
827
|
[setState]
|
|
925
828
|
);
|
|
926
|
-
|
|
829
|
+
react.useEffect(() => {
|
|
927
830
|
if (state !== void 0) {
|
|
928
831
|
setUncontrolledState(state);
|
|
929
832
|
}
|
|
930
833
|
}, [state]);
|
|
931
834
|
return [state ?? uncontrolledState, handleStateChange];
|
|
932
835
|
}
|
|
836
|
+
function useFallbackId(id) {
|
|
837
|
+
const fallbackId = react.useId();
|
|
838
|
+
return id ?? fallbackId;
|
|
839
|
+
}
|
|
840
|
+
const genericMemo = react.memo;
|
|
933
841
|
function mergeRefs(refs) {
|
|
934
842
|
return (value) => {
|
|
935
|
-
const cleanups = refs.reduce(
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
843
|
+
const cleanups = refs.reduce(
|
|
844
|
+
(cleanups2, ref) => {
|
|
845
|
+
if (typeof ref === "function") {
|
|
846
|
+
const cleanup = ref(value);
|
|
847
|
+
if (typeof cleanup === "function") {
|
|
848
|
+
cleanups2.push(cleanup);
|
|
849
|
+
} else {
|
|
850
|
+
cleanups2.push(() => {
|
|
851
|
+
ref(null);
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
} else if (ref != null) {
|
|
855
|
+
ref.current = value;
|
|
941
856
|
cleanups2.push(() => {
|
|
942
|
-
ref
|
|
857
|
+
ref.current = null;
|
|
943
858
|
});
|
|
944
859
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
});
|
|
950
|
-
}
|
|
951
|
-
return cleanups2;
|
|
952
|
-
}, []);
|
|
860
|
+
return cleanups2;
|
|
861
|
+
},
|
|
862
|
+
[]
|
|
863
|
+
);
|
|
953
864
|
return () => {
|
|
954
865
|
cleanups.forEach((cleanup) => {
|
|
955
866
|
cleanup();
|
|
@@ -960,11 +871,26 @@
|
|
|
960
871
|
const stopPropagation = (e) => {
|
|
961
872
|
e.stopPropagation();
|
|
962
873
|
};
|
|
874
|
+
function getSelectedState(selected) {
|
|
875
|
+
return selected ? "selected" : "unselected";
|
|
876
|
+
}
|
|
877
|
+
function getCheckedState(checked) {
|
|
878
|
+
return checked === true ? "checked" : checked === false ? "unchecked" : "indeterminate";
|
|
879
|
+
}
|
|
880
|
+
function getActiveState(active) {
|
|
881
|
+
return active ? "active" : "inactive";
|
|
882
|
+
}
|
|
883
|
+
function getBooleanState(value) {
|
|
884
|
+
return value ? "true" : "false";
|
|
885
|
+
}
|
|
886
|
+
function getOpenState(open) {
|
|
887
|
+
return open ? "open" : "closed";
|
|
888
|
+
}
|
|
963
889
|
const MultiSelectProvider = genericMemo(function MultiSelectProvider2(props) {
|
|
964
890
|
const { children, defaultValues, values: controlledValues, onValuesChange } = props;
|
|
965
|
-
const [itemValueMapping, setItemValueMapping] =
|
|
891
|
+
const [itemValueMapping, setItemValueMapping] = react.useState(/* @__PURE__ */ new Set());
|
|
966
892
|
const [values, setValues] = useControlledState(defaultValues ?? [], controlledValues, onValuesChange);
|
|
967
|
-
const registerValue =
|
|
893
|
+
const registerValue = react.useCallback((value) => {
|
|
968
894
|
setItemValueMapping((prev) => {
|
|
969
895
|
const newSet = new Set(prev);
|
|
970
896
|
newSet.add(value);
|
|
@@ -978,8 +904,8 @@
|
|
|
978
904
|
});
|
|
979
905
|
};
|
|
980
906
|
}, []);
|
|
981
|
-
const selected =
|
|
982
|
-
const selectValue =
|
|
907
|
+
const selected = react.useCallback((value) => values.includes(value), [values]);
|
|
908
|
+
const selectValue = react.useCallback(
|
|
983
909
|
(value) => {
|
|
984
910
|
if (selected(value)) {
|
|
985
911
|
setValues(values.filter((v) => v !== value));
|
|
@@ -989,20 +915,20 @@
|
|
|
989
915
|
},
|
|
990
916
|
[selected, setValues, values]
|
|
991
917
|
);
|
|
992
|
-
const allSelected =
|
|
918
|
+
const allSelected = react.useMemo(() => {
|
|
993
919
|
return Array.from(itemValueMapping.values()).every((value) => values.includes(value));
|
|
994
920
|
}, [itemValueMapping, values]);
|
|
995
|
-
const someSelected =
|
|
921
|
+
const someSelected = react.useMemo(() => {
|
|
996
922
|
return Array.from(itemValueMapping.values()).some((value) => values.includes(value));
|
|
997
923
|
}, [itemValueMapping, values]);
|
|
998
|
-
const toggleSelectAll =
|
|
924
|
+
const toggleSelectAll = react.useCallback(() => {
|
|
999
925
|
if (allSelected) {
|
|
1000
926
|
setValues([]);
|
|
1001
927
|
} else {
|
|
1002
928
|
setValues(Array.from(itemValueMapping.values()));
|
|
1003
929
|
}
|
|
1004
930
|
}, [allSelected, itemValueMapping, setValues]);
|
|
1005
|
-
const contextValue =
|
|
931
|
+
const contextValue = react.useMemo(
|
|
1006
932
|
() => ({ selected, selectValue, allSelected, someSelected, toggleSelectAll, registerValue }),
|
|
1007
933
|
[allSelected, registerValue, selectValue, selected, someSelected, toggleSelectAll]
|
|
1008
934
|
);
|
|
@@ -1011,51 +937,51 @@
|
|
|
1011
937
|
const SingleSelectRequiredProvider = genericMemo(function SingleSelectRequiredProvider2(props) {
|
|
1012
938
|
const { children, defaultValue, value, onValueChange } = props;
|
|
1013
939
|
const [controlledValue, setControlledValue] = useControlledState(defaultValue, value, onValueChange);
|
|
1014
|
-
const selected =
|
|
1015
|
-
const selectValue =
|
|
940
|
+
const selected = react.useCallback((v) => v === controlledValue, [controlledValue]);
|
|
941
|
+
const selectValue = react.useCallback(
|
|
1016
942
|
(v) => {
|
|
1017
943
|
if (selected(v)) return;
|
|
1018
944
|
setControlledValue(v);
|
|
1019
945
|
},
|
|
1020
946
|
[selected, setControlledValue]
|
|
1021
947
|
);
|
|
1022
|
-
const contextValue =
|
|
948
|
+
const contextValue = react.useMemo(() => ({ selected, selectValue }), [selectValue, selected]);
|
|
1023
949
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectContext, { value: contextValue, children });
|
|
1024
950
|
});
|
|
1025
951
|
const SingleSelectNotRequiredProvider = genericMemo(function SingleSelectNotRequiredProvider2(props) {
|
|
1026
952
|
const { children, defaultValue = void 0, value: controlledValue, onValueChange } = props;
|
|
1027
953
|
const [value, setValue] = useControlledState(defaultValue, controlledValue, onValueChange);
|
|
1028
|
-
const selected =
|
|
1029
|
-
const selectValue =
|
|
954
|
+
const selected = react.useCallback((v) => v === value, [value]);
|
|
955
|
+
const selectValue = react.useCallback(
|
|
1030
956
|
(v) => {
|
|
1031
957
|
setValue(selected(v) ? void 0 : v);
|
|
1032
958
|
},
|
|
1033
959
|
[selected, setValue]
|
|
1034
960
|
);
|
|
1035
|
-
const contextValue =
|
|
961
|
+
const contextValue = react.useMemo(() => ({ selected, selectValue }), [selected, selectValue]);
|
|
1036
962
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectContext, { value: contextValue, children });
|
|
1037
963
|
});
|
|
1038
|
-
const CheckboxGroupContext =
|
|
1039
|
-
const CheckboxGroupItem =
|
|
1040
|
-
const groupContext =
|
|
964
|
+
const CheckboxGroupContext = react.createContext({});
|
|
965
|
+
const CheckboxGroupItem = react.memo((props) => {
|
|
966
|
+
const groupContext = react.use(CheckboxGroupContext);
|
|
1041
967
|
const {
|
|
1042
968
|
ref,
|
|
1043
969
|
className,
|
|
1044
970
|
value,
|
|
1045
|
-
accentColor,
|
|
1046
971
|
disabled,
|
|
972
|
+
accentColor = groupContext.accentColor,
|
|
1047
973
|
variant = groupContext.variant,
|
|
1048
974
|
size = groupContext.size,
|
|
1049
975
|
radius = groupContext.radius,
|
|
1050
976
|
...rest
|
|
1051
977
|
} = props;
|
|
1052
|
-
const { selected, selectValue, registerValue } =
|
|
1053
|
-
|
|
978
|
+
const { selected, selectValue, registerValue } = react.use(MultiSelectContext);
|
|
979
|
+
react.useLayoutEffect(() => {
|
|
1054
980
|
return registerValue(value);
|
|
1055
981
|
}, [registerValue, value]);
|
|
1056
982
|
const isChecked = selected(value);
|
|
1057
983
|
const isDisabled = groupContext.disabled || disabled;
|
|
1058
|
-
const handleCheckedChange =
|
|
984
|
+
const handleCheckedChange = react.useCallback(() => {
|
|
1059
985
|
selectValue(value);
|
|
1060
986
|
}, [selectValue, value]);
|
|
1061
987
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1075,15 +1001,12 @@
|
|
|
1075
1001
|
);
|
|
1076
1002
|
});
|
|
1077
1003
|
CheckboxGroupItem.displayName = "CheckboxGroupItem";
|
|
1078
|
-
const CheckboxGroupItemIndicator =
|
|
1004
|
+
const CheckboxGroupItemIndicator = react.memo((props) => {
|
|
1079
1005
|
const { ref, className, ...rest } = props;
|
|
1080
1006
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixCheckbox__namespace.Indicator, { className: classVarianceAuthority.cx("flex items-center justify-center", className), ref, ...rest });
|
|
1081
1007
|
});
|
|
1082
1008
|
CheckboxGroupItemIndicator.displayName = "CheckboxGroupItemIndicator";
|
|
1083
|
-
|
|
1084
|
-
return value ? "true" : "false";
|
|
1085
|
-
}
|
|
1086
|
-
const CheckboxGroupRoot = React.memo((props) => {
|
|
1009
|
+
const CheckboxGroupRoot = react.memo((props) => {
|
|
1087
1010
|
const providerContext = useProvider();
|
|
1088
1011
|
const {
|
|
1089
1012
|
ref,
|
|
@@ -1100,25 +1023,27 @@
|
|
|
1100
1023
|
size = "md",
|
|
1101
1024
|
...rest
|
|
1102
1025
|
} = props;
|
|
1103
|
-
const contextValue =
|
|
1026
|
+
const contextValue = react.useMemo(
|
|
1104
1027
|
() => ({
|
|
1105
1028
|
name,
|
|
1106
1029
|
required,
|
|
1107
1030
|
disabled,
|
|
1031
|
+
// style props
|
|
1032
|
+
accentColor,
|
|
1108
1033
|
size,
|
|
1109
1034
|
variant,
|
|
1110
1035
|
radius
|
|
1111
1036
|
}),
|
|
1112
|
-
[disabled, name, radius, required, size, variant]
|
|
1037
|
+
[accentColor, disabled, name, radius, required, size, variant]
|
|
1113
1038
|
);
|
|
1114
1039
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1115
1040
|
"div",
|
|
1116
1041
|
{
|
|
1117
1042
|
ref,
|
|
1118
1043
|
role: "group",
|
|
1119
|
-
"data-disabled": getBooleanState
|
|
1044
|
+
"data-disabled": getBooleanState(!!disabled),
|
|
1120
1045
|
"data-accent-color": accentColor,
|
|
1121
|
-
"aria-disabled": getBooleanState
|
|
1046
|
+
"aria-disabled": getBooleanState(!!disabled),
|
|
1122
1047
|
...rest,
|
|
1123
1048
|
children: /* @__PURE__ */ jsxRuntime.jsx(CheckboxGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1124
1049
|
MultiSelectProvider,
|
|
@@ -1133,19 +1058,19 @@
|
|
|
1133
1058
|
);
|
|
1134
1059
|
});
|
|
1135
1060
|
CheckboxGroupRoot.displayName = "CheckboxGroupRoot";
|
|
1136
|
-
const CheckboxGroupSelectAllItem =
|
|
1137
|
-
const groupContext =
|
|
1061
|
+
const CheckboxGroupSelectAllItem = react.memo((props) => {
|
|
1062
|
+
const groupContext = react.use(CheckboxGroupContext);
|
|
1138
1063
|
const {
|
|
1139
1064
|
ref,
|
|
1140
1065
|
className,
|
|
1141
|
-
accentColor,
|
|
1142
1066
|
disabled,
|
|
1067
|
+
accentColor = groupContext.accentColor,
|
|
1143
1068
|
variant = groupContext.variant,
|
|
1144
1069
|
size = groupContext.size,
|
|
1145
1070
|
radius = groupContext.radius,
|
|
1146
1071
|
...rest
|
|
1147
1072
|
} = props;
|
|
1148
|
-
const { allSelected, someSelected, toggleSelectAll } =
|
|
1073
|
+
const { allSelected, someSelected, toggleSelectAll } = react.use(MultiSelectContext);
|
|
1149
1074
|
const checked = allSelected ? true : someSelected ? "indeterminate" : false;
|
|
1150
1075
|
const isDisabled = groupContext.disabled || disabled;
|
|
1151
1076
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1170,137 +1095,39 @@
|
|
|
1170
1095
|
SelectAllItem: CheckboxGroupSelectAllItem,
|
|
1171
1096
|
ItemIndicator: CheckboxGroupItemIndicator
|
|
1172
1097
|
};
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
}
|
|
1179
|
-
const CollapsibleNode = genericMemo(function(props) {
|
|
1180
|
-
const { meta, nodes, level = 0, disabled } = props;
|
|
1181
|
-
const [controlledOpenState, setControlledOpenState] = React.useState(false);
|
|
1182
|
-
const {
|
|
1183
|
-
nodeRenderer,
|
|
1184
|
-
disabled: disabledFromContext,
|
|
1185
|
-
onNodeOpen,
|
|
1186
|
-
onNodeClose,
|
|
1187
|
-
onNodeClick,
|
|
1188
|
-
nodeStyles,
|
|
1189
|
-
nodeClassName
|
|
1190
|
-
} = useCollapsibleTreeContext();
|
|
1191
|
-
const isDisabled = disabled ?? disabledFromContext;
|
|
1192
|
-
const handleClick = React.useCallback(() => {
|
|
1193
|
-
if (onNodeClick) onNodeClick(meta);
|
|
1194
|
-
}, [meta, onNodeClick]);
|
|
1195
|
-
const toggleOpenState = React.useCallback(() => {
|
|
1196
|
-
setControlledOpenState(!controlledOpenState);
|
|
1197
|
-
if (!controlledOpenState && onNodeOpen) onNodeOpen(meta);
|
|
1198
|
-
if (controlledOpenState && onNodeClose) onNodeClose(meta);
|
|
1199
|
-
}, [meta, onNodeClose, onNodeOpen, controlledOpenState]);
|
|
1200
|
-
const { children, style, className } = React.useMemo(() => {
|
|
1201
|
-
return nodeRenderer({
|
|
1202
|
-
meta,
|
|
1203
|
-
toggleOpen: toggleOpenState,
|
|
1204
|
-
open: controlledOpenState,
|
|
1205
|
-
disabled: isDisabled
|
|
1206
|
-
});
|
|
1207
|
-
}, [isDisabled, meta, nodeRenderer, toggleOpenState, controlledOpenState]);
|
|
1208
|
-
const combinedStyles = React.useMemo(
|
|
1209
|
-
() => ({
|
|
1210
|
-
// want node specific styles to overwrite and global node styles
|
|
1211
|
-
...nodeStyles,
|
|
1212
|
-
...style
|
|
1213
|
-
}),
|
|
1214
|
-
[nodeStyles, style]
|
|
1215
|
-
);
|
|
1216
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RadixPrimitiveCollapsible__namespace.Root, { asChild: true, open: controlledOpenState, disabled: isDisabled, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-col", children: [
|
|
1217
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1218
|
-
"div",
|
|
1219
|
-
{
|
|
1220
|
-
onClick: handleClick,
|
|
1221
|
-
className: classVarianceAuthority.cx(nodeClassName, "flex w-full shrink-0 items-center", className),
|
|
1222
|
-
style: combinedStyles,
|
|
1223
|
-
"data-state": controlledOpenState ? "open" : "closed",
|
|
1224
|
-
"data-disabled": isDisabled,
|
|
1225
|
-
children
|
|
1226
|
-
}
|
|
1227
|
-
),
|
|
1228
|
-
nodes && nodes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(RadixPrimitiveCollapsible__namespace.Content, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-max w-full flex-col pl-2", children: nodes.map((treeNodeProps, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1229
|
-
CollapsibleNode,
|
|
1230
|
-
{
|
|
1231
|
-
level: level + 1,
|
|
1232
|
-
...treeNodeProps
|
|
1233
|
-
},
|
|
1234
|
-
`${level},${index}`
|
|
1235
|
-
)) }) })
|
|
1236
|
-
] }) });
|
|
1237
|
-
});
|
|
1238
|
-
const CollapsibleTree = genericMemo(function(props) {
|
|
1239
|
-
const {
|
|
1240
|
-
nodes,
|
|
1241
|
-
disabled = false,
|
|
1242
|
-
nodeClassName,
|
|
1243
|
-
nodeStyles,
|
|
1244
|
-
onNodeClick,
|
|
1245
|
-
onNodeClose,
|
|
1246
|
-
onNodeOpen,
|
|
1247
|
-
nodeRenderer,
|
|
1248
|
-
...rest
|
|
1249
|
-
} = props;
|
|
1250
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1251
|
-
CollapsibleTreeContext.Provider,
|
|
1252
|
-
{
|
|
1253
|
-
value: {
|
|
1254
|
-
nodeRenderer,
|
|
1255
|
-
nodeClassName,
|
|
1256
|
-
nodeStyles,
|
|
1257
|
-
disabled,
|
|
1258
|
-
onNodeClick,
|
|
1259
|
-
onNodeClose,
|
|
1260
|
-
onNodeOpen
|
|
1261
|
-
},
|
|
1262
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-max w-full flex-col", ...rest, children: nodes.map((treeNodeProps, index) => /* @__PURE__ */ jsxRuntime.jsx(CollapsibleNode, { ...treeNodeProps }, `${0},${index}`)) })
|
|
1263
|
-
}
|
|
1264
|
-
);
|
|
1265
|
-
});
|
|
1266
|
-
const CommandMenuContext = React.createContext({});
|
|
1267
|
-
const SelectedIndicatorContext$1 = React.createContext(false);
|
|
1268
|
-
const CheckboxIndicatorContext = React.createContext(false);
|
|
1269
|
-
const CommandMenuPageContext = React.createContext({});
|
|
1270
|
-
const CommandMenuDialogContext = React.createContext({});
|
|
1271
|
-
function getSelectedState$1(selected) {
|
|
1272
|
-
return selected ? "selected" : "unselected";
|
|
1273
|
-
}
|
|
1274
|
-
function getCheckedState$1(checked) {
|
|
1275
|
-
return checked === true ? "checked" : checked === false ? "unchecked" : "indeterminate";
|
|
1276
|
-
}
|
|
1277
|
-
function getActiveState(active) {
|
|
1278
|
-
return active ? "active" : "inactive";
|
|
1279
|
-
}
|
|
1280
|
-
const CommandMenuCheckboxIndicator = React.memo((props) => {
|
|
1281
|
-
const { ref, className, children, ...rest } = props;
|
|
1282
|
-
const checkedState = React.use(CheckboxIndicatorContext);
|
|
1283
|
-
const computedChildren = React.useMemo(() => {
|
|
1284
|
-
return typeof children === "function" ? children(checkedState) : children;
|
|
1285
|
-
}, [checkedState, children]);
|
|
1098
|
+
const CheckedIndicatorContext = react.createContext({});
|
|
1099
|
+
const CheckedIndicator = react.memo((props) => {
|
|
1100
|
+
const { children, ref, className, ...rest } = props;
|
|
1101
|
+
const checked = react.useContext(CheckedIndicatorContext);
|
|
1102
|
+
const computedChildren = typeof children === "function" ? children(checked) : children;
|
|
1286
1103
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1287
1104
|
"span",
|
|
1288
1105
|
{
|
|
1289
1106
|
ref,
|
|
1290
|
-
"data-state": getCheckedState$1(checkedState),
|
|
1291
1107
|
className: classVarianceAuthority.cx(
|
|
1292
|
-
"
|
|
1108
|
+
"flex size-max items-center",
|
|
1293
1109
|
{
|
|
1294
|
-
invisible:
|
|
1110
|
+
invisible: checked === false
|
|
1295
1111
|
},
|
|
1296
1112
|
className
|
|
1297
1113
|
),
|
|
1114
|
+
"data-state": getCheckedState(checked),
|
|
1298
1115
|
...rest,
|
|
1299
1116
|
children: computedChildren
|
|
1300
1117
|
}
|
|
1301
1118
|
);
|
|
1302
1119
|
});
|
|
1120
|
+
CheckedIndicator.displayName = "CheckedIndicator";
|
|
1121
|
+
const CommandMenuCheckboxIndicator = react.memo((props) => {
|
|
1122
|
+
const { ref, children, ...rest } = props;
|
|
1123
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicator, { ref, ...rest, children });
|
|
1124
|
+
});
|
|
1303
1125
|
CommandMenuCheckboxIndicator.displayName = "CommandMenuCheckboxIndicator";
|
|
1126
|
+
const CommandMenuContext = react.createContext({});
|
|
1127
|
+
const SelectedIndicatorContext$1 = react.createContext(false);
|
|
1128
|
+
const CheckboxIndicatorContext = react.createContext(false);
|
|
1129
|
+
const CommandMenuPageContext = react.createContext({});
|
|
1130
|
+
const CommandMenuDialogContext = react.createContext({});
|
|
1304
1131
|
const commandMenuContentCva = classVarianceAuthority.cva(
|
|
1305
1132
|
[
|
|
1306
1133
|
"ring",
|
|
@@ -1509,11 +1336,11 @@
|
|
|
1509
1336
|
}
|
|
1510
1337
|
}
|
|
1511
1338
|
);
|
|
1512
|
-
const CommandMenuItem =
|
|
1339
|
+
const CommandMenuItem = react.memo((props) => {
|
|
1513
1340
|
const { className, ref, closeOnSelect = true, onSelect, filterValue, ...rest } = props;
|
|
1514
|
-
const { size, variant, radius } =
|
|
1515
|
-
const { setOpen } =
|
|
1516
|
-
const handleSelect =
|
|
1341
|
+
const { size, variant, radius } = react.use(CommandMenuContext);
|
|
1342
|
+
const { setOpen } = react.use(CommandMenuDialogContext);
|
|
1343
|
+
const handleSelect = react.useCallback(() => {
|
|
1517
1344
|
onSelect == null ? void 0 : onSelect();
|
|
1518
1345
|
if (closeOnSelect) {
|
|
1519
1346
|
setOpen(false);
|
|
@@ -1531,16 +1358,16 @@
|
|
|
1531
1358
|
);
|
|
1532
1359
|
});
|
|
1533
1360
|
CommandMenuItem.displayName = "CommandMenuItem";
|
|
1534
|
-
const CommandMenuCheckboxItem =
|
|
1361
|
+
const CommandMenuCheckboxItem = react.memo((props) => {
|
|
1535
1362
|
const { children, ref, checked, onCheckedChange, onSelect, ...rest } = props;
|
|
1536
|
-
const handleSelect =
|
|
1363
|
+
const handleSelect = react.useCallback(() => {
|
|
1537
1364
|
onSelect == null ? void 0 : onSelect();
|
|
1538
1365
|
onCheckedChange(checked !== true);
|
|
1539
1366
|
}, [checked, onCheckedChange, onSelect]);
|
|
1540
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CheckboxIndicatorContext, { value: checked, children: /* @__PURE__ */ jsxRuntime.jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getCheckedState
|
|
1367
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CheckboxIndicatorContext, { value: checked, children: /* @__PURE__ */ jsxRuntime.jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getCheckedState(checked), ...rest, children }) });
|
|
1541
1368
|
});
|
|
1542
1369
|
CommandMenuCheckboxItem.displayName = "CommandMenuCheckboxItem";
|
|
1543
|
-
const CommandMenuContent =
|
|
1370
|
+
const CommandMenuContent = react.memo((props) => {
|
|
1544
1371
|
const providerContext = useProvider();
|
|
1545
1372
|
const {
|
|
1546
1373
|
children,
|
|
@@ -1560,13 +1387,14 @@
|
|
|
1560
1387
|
radius = providerContext.radius,
|
|
1561
1388
|
...rest
|
|
1562
1389
|
} = props;
|
|
1563
|
-
const contextValue =
|
|
1390
|
+
const contextValue = react.useMemo(() => {
|
|
1564
1391
|
return {
|
|
1565
1392
|
variant,
|
|
1566
1393
|
size,
|
|
1567
|
-
radius
|
|
1394
|
+
radius,
|
|
1395
|
+
accentColor
|
|
1568
1396
|
};
|
|
1569
|
-
}, [radius, size, variant]);
|
|
1397
|
+
}, [accentColor, radius, size, variant]);
|
|
1570
1398
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog.DialogPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1571
1399
|
RadixDialog.DialogContent,
|
|
1572
1400
|
{
|
|
@@ -1596,27 +1424,27 @@
|
|
|
1596
1424
|
) });
|
|
1597
1425
|
});
|
|
1598
1426
|
CommandMenuContent.displayName = "CommandMenuContent";
|
|
1599
|
-
const CommandMenuEmpty =
|
|
1427
|
+
const CommandMenuEmpty = react.memo((props) => {
|
|
1600
1428
|
const { className, ref, ...rest } = props;
|
|
1601
|
-
const { size } =
|
|
1429
|
+
const { size } = react.use(CommandMenuContext);
|
|
1602
1430
|
return /* @__PURE__ */ jsxRuntime.jsx(cmdk.CommandEmpty, { className: classVarianceAuthority.cx(commandMenuEmptyCva({ size }), className), ref, ...rest });
|
|
1603
1431
|
});
|
|
1604
1432
|
CommandMenuEmpty.displayName = "CommandMenuEmpty";
|
|
1605
|
-
const CommandMenuGroup =
|
|
1433
|
+
const CommandMenuGroup = react.memo((props) => {
|
|
1606
1434
|
const { className, ref, ...rest } = props;
|
|
1607
|
-
const { size } =
|
|
1435
|
+
const { size } = react.use(CommandMenuContext);
|
|
1608
1436
|
return /* @__PURE__ */ jsxRuntime.jsx(cmdk.CommandGroup, { className: classVarianceAuthority.cx(commandMenuGroupCva({ size }), className), ref, ...rest });
|
|
1609
1437
|
});
|
|
1610
1438
|
CommandMenuGroup.displayName = "CommandMenuGroup";
|
|
1611
|
-
const CommandMenuInput =
|
|
1439
|
+
const CommandMenuInput = react.memo((props) => {
|
|
1612
1440
|
const { className, ref, ...rest } = props;
|
|
1613
|
-
const { size } =
|
|
1441
|
+
const { size } = react.use(CommandMenuContext);
|
|
1614
1442
|
return /* @__PURE__ */ jsxRuntime.jsx(cmdk.CommandInput, { className: classVarianceAuthority.cx(commandMenuInputCva({ size }), className), ref, ...rest });
|
|
1615
1443
|
});
|
|
1616
1444
|
CommandMenuInput.displayName = "CommandMenuInput";
|
|
1617
|
-
const CommandMenuList =
|
|
1445
|
+
const CommandMenuList = react.memo((props) => {
|
|
1618
1446
|
const { className, ref, ...rest } = props;
|
|
1619
|
-
const { size } =
|
|
1447
|
+
const { size } = react.use(CommandMenuContext);
|
|
1620
1448
|
const filterCount = cmdk.useCommandState((state) => state.filtered.count);
|
|
1621
1449
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1622
1450
|
cmdk.CommandList,
|
|
@@ -1639,11 +1467,11 @@
|
|
|
1639
1467
|
selected,
|
|
1640
1468
|
selectValue: handleSelectValue,
|
|
1641
1469
|
registerValue
|
|
1642
|
-
} =
|
|
1643
|
-
|
|
1470
|
+
} = react.use(MultiSelectContext);
|
|
1471
|
+
react.useLayoutEffect(() => {
|
|
1644
1472
|
return registerValue(value);
|
|
1645
1473
|
}, [registerValue, value]);
|
|
1646
|
-
const handleSelect =
|
|
1474
|
+
const handleSelect = react.useCallback(() => {
|
|
1647
1475
|
onSelect == null ? void 0 : onSelect();
|
|
1648
1476
|
handleSelectValue(value);
|
|
1649
1477
|
}, [handleSelectValue, onSelect, value]);
|
|
@@ -1653,7 +1481,7 @@
|
|
|
1653
1481
|
{
|
|
1654
1482
|
ref,
|
|
1655
1483
|
onSelect: handleSelect,
|
|
1656
|
-
"data-state": getSelectedState
|
|
1484
|
+
"data-state": getSelectedState(isSelected),
|
|
1657
1485
|
"aria-selected": isSelected,
|
|
1658
1486
|
closeOnSelect,
|
|
1659
1487
|
...rest,
|
|
@@ -1661,29 +1489,29 @@
|
|
|
1661
1489
|
}
|
|
1662
1490
|
) });
|
|
1663
1491
|
});
|
|
1664
|
-
const CommandMenuOverlay =
|
|
1492
|
+
const CommandMenuOverlay = react.memo((props) => {
|
|
1665
1493
|
const { container, className, ...rest } = props;
|
|
1666
1494
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog.DialogPortal, { container, children: /* @__PURE__ */ jsxRuntime.jsx(RadixDialog.DialogOverlay, { className: classVarianceAuthority.cx(commandMenuOverlayCva(), className), "data-floating-content": "", ...rest }) });
|
|
1667
1495
|
});
|
|
1668
1496
|
CommandMenuOverlay.displayName = "CommandMenuOverlay";
|
|
1669
|
-
const CommandMenuPage =
|
|
1497
|
+
const CommandMenuPage = react.memo((props) => {
|
|
1670
1498
|
const { children, ref, page, ...rest } = props;
|
|
1671
|
-
const { page: activePage } =
|
|
1672
|
-
const isActive =
|
|
1499
|
+
const { page: activePage } = react.use(CommandMenuPageContext);
|
|
1500
|
+
const isActive = react.useMemo(() => page === activePage, [page, activePage]);
|
|
1673
1501
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-active": getActiveState(isActive), hidden: !isActive, ...rest, children: isActive ? children : null });
|
|
1674
1502
|
});
|
|
1675
1503
|
CommandMenuPage.displayName = "CommandMenuPage";
|
|
1676
|
-
const CommandMenuPages =
|
|
1504
|
+
const CommandMenuPages = react.memo((props) => {
|
|
1677
1505
|
const { children, defaultPage = "", page: controlledPage, onPageChange } = props;
|
|
1678
1506
|
const [page, setPage] = useControlledState(defaultPage, controlledPage, onPageChange);
|
|
1679
1507
|
return /* @__PURE__ */ jsxRuntime.jsx(CommandMenuPageContext, { value: { page, setPage }, children });
|
|
1680
1508
|
});
|
|
1681
1509
|
CommandMenuPages.displayName = "CommandMenuPages";
|
|
1682
|
-
const CommandMenuPageTriggerItem =
|
|
1510
|
+
const CommandMenuPageTriggerItem = react.memo((props) => {
|
|
1683
1511
|
const { ref, page, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1684
|
-
const { page: activePage, setPage } =
|
|
1685
|
-
const isActive =
|
|
1686
|
-
const handleSelect =
|
|
1512
|
+
const { page: activePage, setPage } = react.use(CommandMenuPageContext);
|
|
1513
|
+
const isActive = react.useMemo(() => page === activePage, [page, activePage]);
|
|
1514
|
+
const handleSelect = react.useCallback(() => {
|
|
1687
1515
|
onSelect == null ? void 0 : onSelect();
|
|
1688
1516
|
setPage(page);
|
|
1689
1517
|
}, [onSelect, page, setPage]);
|
|
@@ -1721,18 +1549,18 @@
|
|
|
1721
1549
|
});
|
|
1722
1550
|
const CommandMenuRadioItem = genericMemo(function(props) {
|
|
1723
1551
|
const { children, ref, value, onSelect, ...rest } = props;
|
|
1724
|
-
const { selected, selectValue } =
|
|
1725
|
-
const handleSelect =
|
|
1552
|
+
const { selected, selectValue } = react.use(SelectContext);
|
|
1553
|
+
const handleSelect = react.useCallback(() => {
|
|
1726
1554
|
onSelect == null ? void 0 : onSelect();
|
|
1727
1555
|
selectValue(value);
|
|
1728
1556
|
}, [onSelect, selectValue, value]);
|
|
1729
1557
|
const isSelected = selected(value);
|
|
1730
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext$1, { value: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getSelectedState
|
|
1558
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext$1, { value: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getSelectedState(isSelected), ...rest, children }) });
|
|
1731
1559
|
});
|
|
1732
|
-
const CommandMenuRoot =
|
|
1560
|
+
const CommandMenuRoot = react.memo((props) => {
|
|
1733
1561
|
const { children, defaultOpen, open: controlledOpen, onOpenChange, modal } = props;
|
|
1734
1562
|
const [open, setOpen] = useControlledState(defaultOpen ?? false, controlledOpen, onOpenChange);
|
|
1735
|
-
const contextValue =
|
|
1563
|
+
const contextValue = react.useMemo(() => {
|
|
1736
1564
|
return {
|
|
1737
1565
|
open,
|
|
1738
1566
|
setOpen
|
|
@@ -1743,8 +1571,8 @@
|
|
|
1743
1571
|
CommandMenuRoot.displayName = "CommandMenuRoot";
|
|
1744
1572
|
const CommandMenuSelectAllItem = genericMemo(function(props) {
|
|
1745
1573
|
const { ref, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1746
|
-
const { allSelected, someSelected, toggleSelectAll } =
|
|
1747
|
-
const handleSelect =
|
|
1574
|
+
const { allSelected, someSelected, toggleSelectAll } = react.use(MultiSelectContext);
|
|
1575
|
+
const handleSelect = react.useCallback(() => {
|
|
1748
1576
|
onSelect == null ? void 0 : onSelect();
|
|
1749
1577
|
toggleSelectAll();
|
|
1750
1578
|
}, [onSelect, toggleSelectAll]);
|
|
@@ -1755,43 +1583,47 @@
|
|
|
1755
1583
|
ref,
|
|
1756
1584
|
role: "menuitemcheckbox",
|
|
1757
1585
|
onSelect: handleSelect,
|
|
1758
|
-
"data-state": getCheckedState
|
|
1586
|
+
"data-state": getCheckedState(selectedState),
|
|
1759
1587
|
closeOnSelect,
|
|
1760
1588
|
...rest
|
|
1761
1589
|
}
|
|
1762
1590
|
) });
|
|
1763
1591
|
});
|
|
1764
|
-
const
|
|
1765
|
-
|
|
1766
|
-
const
|
|
1767
|
-
const
|
|
1768
|
-
|
|
1769
|
-
}, [isSelected, children]);
|
|
1592
|
+
const SelectedIndicatorContext = react.createContext(false);
|
|
1593
|
+
const SelectedIndicator = react.memo((props) => {
|
|
1594
|
+
const { ref, children, className, ...rest } = props;
|
|
1595
|
+
const isSelected = react.use(SelectedIndicatorContext);
|
|
1596
|
+
const computedChildren = typeof children === "function" ? children(isSelected) : children;
|
|
1770
1597
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1771
1598
|
"span",
|
|
1772
1599
|
{
|
|
1773
1600
|
ref,
|
|
1774
|
-
"data-state": getSelectedState$1(isSelected),
|
|
1775
1601
|
className: classVarianceAuthority.cx(
|
|
1776
|
-
"
|
|
1602
|
+
"flex size-max items-center",
|
|
1777
1603
|
{
|
|
1778
1604
|
invisible: !isSelected
|
|
1779
1605
|
},
|
|
1780
1606
|
className
|
|
1781
1607
|
),
|
|
1608
|
+
"data-state": getSelectedState(isSelected),
|
|
1782
1609
|
...rest,
|
|
1783
1610
|
children: computedChildren
|
|
1784
1611
|
}
|
|
1785
1612
|
);
|
|
1786
1613
|
});
|
|
1614
|
+
SelectedIndicator.displayName = "SelectedIndicator";
|
|
1615
|
+
const CommandMenuSelectedIndicator = react.memo((props) => {
|
|
1616
|
+
const { ref, children, ...rest } = props;
|
|
1617
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicator, { ref, ...rest, children });
|
|
1618
|
+
});
|
|
1787
1619
|
CommandMenuSelectedIndicator.displayName = "CommandMenuSelectedIndicator";
|
|
1788
|
-
const CommandMenuSeparator =
|
|
1620
|
+
const CommandMenuSeparator = react.memo((props) => {
|
|
1789
1621
|
const { className, ref, spacing = false, ...rest } = props;
|
|
1790
|
-
const { size } =
|
|
1622
|
+
const { size } = react.use(CommandMenuContext);
|
|
1791
1623
|
return /* @__PURE__ */ jsxRuntime.jsx(cmdk.CommandSeparator, { ref, className: classVarianceAuthority.cx(commandMenuSeparatorCva({ size, spacing }), className), ...rest });
|
|
1792
1624
|
});
|
|
1793
1625
|
CommandMenuSeparator.displayName = "CommandMenuSeparator";
|
|
1794
|
-
const CommandMenuTrigger =
|
|
1626
|
+
const CommandMenuTrigger = react.memo((props) => {
|
|
1795
1627
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog.DialogTrigger, { ...props });
|
|
1796
1628
|
});
|
|
1797
1629
|
CommandMenuTrigger.displayName = "CommandMenuTrigger";
|
|
@@ -1822,7 +1654,7 @@
|
|
|
1822
1654
|
Page: CommandMenuPage,
|
|
1823
1655
|
PageTriggerItem: CommandMenuPageTriggerItem
|
|
1824
1656
|
};
|
|
1825
|
-
const LuIcon =
|
|
1657
|
+
const LuIcon = react.memo((props) => {
|
|
1826
1658
|
const { ref, icon, className, size = "1em", ...rest } = props;
|
|
1827
1659
|
return /* @__PURE__ */ jsxRuntime.jsx(dynamic.DynamicIcon, { ref, className: classVarianceAuthority.cx("shrink-0", className), size, name: icon, ...rest });
|
|
1828
1660
|
});
|
|
@@ -1978,7 +1810,7 @@
|
|
|
1978
1810
|
}
|
|
1979
1811
|
}
|
|
1980
1812
|
});
|
|
1981
|
-
const DayPicker =
|
|
1813
|
+
const DayPicker = react.memo((props) => {
|
|
1982
1814
|
const providerContext = useProvider();
|
|
1983
1815
|
const {
|
|
1984
1816
|
components,
|
|
@@ -1990,7 +1822,7 @@
|
|
|
1990
1822
|
showOutsideDays = true,
|
|
1991
1823
|
...rest
|
|
1992
1824
|
} = props;
|
|
1993
|
-
const computedClassNames =
|
|
1825
|
+
const computedClassNames = react.useMemo(() => {
|
|
1994
1826
|
return {
|
|
1995
1827
|
...classNames,
|
|
1996
1828
|
root: classVarianceAuthority.cx(classNames == null ? void 0 : classNames.root, rootCva({ size })),
|
|
@@ -2020,7 +1852,7 @@
|
|
|
2020
1852
|
range_end: classVarianceAuthority.cx(classNames == null ? void 0 : classNames.range_end, "rdp-range-end")
|
|
2021
1853
|
};
|
|
2022
1854
|
}, [classNames, radius, size, variant]);
|
|
2023
|
-
const computedComponents =
|
|
1855
|
+
const computedComponents = react.useMemo(() => {
|
|
2024
1856
|
return {
|
|
2025
1857
|
...components,
|
|
2026
1858
|
Chevron
|
|
@@ -2038,19 +1870,19 @@
|
|
|
2038
1870
|
);
|
|
2039
1871
|
});
|
|
2040
1872
|
DayPicker.displayName = "DayPicker";
|
|
2041
|
-
const CloseDialogContext =
|
|
1873
|
+
const CloseDialogContext = react.createContext({});
|
|
2042
1874
|
const useCloseDialog = () => {
|
|
2043
|
-
const dialogContext =
|
|
1875
|
+
const dialogContext = react.useContext(CloseDialogContext);
|
|
2044
1876
|
if (!dialogContext) {
|
|
2045
1877
|
throw new Error("useDialog must be used within a DialogRoot");
|
|
2046
1878
|
}
|
|
2047
1879
|
return dialogContext;
|
|
2048
1880
|
};
|
|
2049
|
-
const DialogContent =
|
|
1881
|
+
const DialogContent = react.memo((props) => {
|
|
2050
1882
|
const { radius } = useProvider();
|
|
2051
1883
|
const close = useCloseDialog();
|
|
2052
1884
|
const { ref, children, container, className, size, ...rest } = props;
|
|
2053
|
-
const computedChildren =
|
|
1885
|
+
const computedChildren = react.useMemo(() => {
|
|
2054
1886
|
return typeof children === "function" ? children(close) : children;
|
|
2055
1887
|
}, [children, close]);
|
|
2056
1888
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Portal, { container, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2065,7 +1897,7 @@
|
|
|
2065
1897
|
) });
|
|
2066
1898
|
});
|
|
2067
1899
|
DialogContent.displayName = "DialogContent";
|
|
2068
|
-
const DialogOverlay =
|
|
1900
|
+
const DialogOverlay = react.memo((props) => {
|
|
2069
1901
|
const { ref, children, className, container, ...rest } = props;
|
|
2070
1902
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Portal, { container, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2071
1903
|
RadixDialog__namespace.Overlay,
|
|
@@ -2079,7 +1911,7 @@
|
|
|
2079
1911
|
) });
|
|
2080
1912
|
});
|
|
2081
1913
|
DialogOverlay.displayName = "DialogOverlay";
|
|
2082
|
-
const DialogRoot =
|
|
1914
|
+
const DialogRoot = react.memo((props) => {
|
|
2083
1915
|
const {
|
|
2084
1916
|
children,
|
|
2085
1917
|
onOpen,
|
|
@@ -2089,9 +1921,9 @@
|
|
|
2089
1921
|
open: externalOpen,
|
|
2090
1922
|
onOpenChange: externalOpenChange
|
|
2091
1923
|
} = props;
|
|
2092
|
-
const [innerOpen, setInnerOpen] =
|
|
1924
|
+
const [innerOpen, setInnerOpen] = react.useState(defaultOpen ?? false);
|
|
2093
1925
|
const open = externalOpen ?? innerOpen;
|
|
2094
|
-
const handleOpenChange =
|
|
1926
|
+
const handleOpenChange = react.useCallback(
|
|
2095
1927
|
(next) => {
|
|
2096
1928
|
if (externalOpenChange) return externalOpenChange(next);
|
|
2097
1929
|
if (next && onOpen) {
|
|
@@ -2109,7 +1941,7 @@
|
|
|
2109
1941
|
},
|
|
2110
1942
|
[externalOpenChange, onOpen, onClose, onCloseInterrupt]
|
|
2111
1943
|
);
|
|
2112
|
-
const closeDialog =
|
|
1944
|
+
const closeDialog = react.useCallback(
|
|
2113
1945
|
(options) => {
|
|
2114
1946
|
if (options == null ? void 0 : options.force) {
|
|
2115
1947
|
return setInnerOpen(false);
|
|
@@ -2168,7 +2000,7 @@
|
|
|
2168
2000
|
}
|
|
2169
2001
|
}
|
|
2170
2002
|
});
|
|
2171
|
-
const Heading =
|
|
2003
|
+
const Heading = react.memo((props) => {
|
|
2172
2004
|
const {
|
|
2173
2005
|
ref,
|
|
2174
2006
|
children,
|
|
@@ -2201,7 +2033,7 @@
|
|
|
2201
2033
|
);
|
|
2202
2034
|
});
|
|
2203
2035
|
Heading.displayName = "Heading";
|
|
2204
|
-
const HoverCardArrow =
|
|
2036
|
+
const HoverCardArrow = react.memo((props) => {
|
|
2205
2037
|
const { ref, children, className, ...rest } = props;
|
|
2206
2038
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixHoverCard__namespace.Arrow, { className: classVarianceAuthority.cx("fill-(--base-6)", className), ref, ...rest, children });
|
|
2207
2039
|
});
|
|
@@ -2220,7 +2052,7 @@
|
|
|
2220
2052
|
size: "md"
|
|
2221
2053
|
}
|
|
2222
2054
|
});
|
|
2223
|
-
const HoverCardContent =
|
|
2055
|
+
const HoverCardContent = react.memo((props) => {
|
|
2224
2056
|
const providerContext = useProvider();
|
|
2225
2057
|
const {
|
|
2226
2058
|
ref,
|
|
@@ -2260,12 +2092,12 @@
|
|
|
2260
2092
|
Root: RadixHoverCard__namespace.Root,
|
|
2261
2093
|
Trigger: RadixHoverCard__namespace.Trigger
|
|
2262
2094
|
};
|
|
2263
|
-
const HoverUtility =
|
|
2264
|
-
const [isHovered, setIsHovered] =
|
|
2265
|
-
const handlePointerEnter =
|
|
2095
|
+
const HoverUtility = react.memo(({ children, forceHover }) => {
|
|
2096
|
+
const [isHovered, setIsHovered] = react.useState(false);
|
|
2097
|
+
const handlePointerEnter = react.useCallback(() => {
|
|
2266
2098
|
setIsHovered(true);
|
|
2267
2099
|
}, []);
|
|
2268
|
-
const handlePointerLeave =
|
|
2100
|
+
const handlePointerLeave = react.useCallback(() => {
|
|
2269
2101
|
setIsHovered(false);
|
|
2270
2102
|
}, []);
|
|
2271
2103
|
return children({
|
|
@@ -2274,7 +2106,8 @@
|
|
|
2274
2106
|
onPointerLeave: handlePointerLeave
|
|
2275
2107
|
});
|
|
2276
2108
|
});
|
|
2277
|
-
|
|
2109
|
+
HoverUtility.displayName = "HoverUtility";
|
|
2110
|
+
const InputContext = react.createContext({});
|
|
2278
2111
|
const inputRoot$1 = classVarianceAuthority.cva(
|
|
2279
2112
|
[
|
|
2280
2113
|
"flex",
|
|
@@ -2349,9 +2182,9 @@
|
|
|
2349
2182
|
size: "md"
|
|
2350
2183
|
}
|
|
2351
2184
|
});
|
|
2352
|
-
const InputField =
|
|
2185
|
+
const InputField = react.memo((props) => {
|
|
2353
2186
|
const { ref, children, className, ...rest } = props;
|
|
2354
|
-
const { size, variant } =
|
|
2187
|
+
const { size, variant } = react.useContext(InputContext);
|
|
2355
2188
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2356
2189
|
"input",
|
|
2357
2190
|
{
|
|
@@ -2363,7 +2196,7 @@
|
|
|
2363
2196
|
);
|
|
2364
2197
|
});
|
|
2365
2198
|
InputField.displayName = "InputField";
|
|
2366
|
-
const InputRoot =
|
|
2199
|
+
const InputRoot = react.memo((props) => {
|
|
2367
2200
|
const providerContext = useProvider();
|
|
2368
2201
|
const {
|
|
2369
2202
|
ref,
|
|
@@ -2387,9 +2220,9 @@
|
|
|
2387
2220
|
) });
|
|
2388
2221
|
});
|
|
2389
2222
|
InputRoot.displayName = "InputRoot";
|
|
2390
|
-
const InputSlot =
|
|
2223
|
+
const InputSlot = react.memo((props) => {
|
|
2391
2224
|
const { ref, children, className, ...rest } = props;
|
|
2392
|
-
const { size, variant } =
|
|
2225
|
+
const { size, variant } = react.useContext(InputContext);
|
|
2393
2226
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classVarianceAuthority.cx(inputSlot({ size, variant }), "flex items-center", className), ref, ...rest, children });
|
|
2394
2227
|
});
|
|
2395
2228
|
InputSlot.displayName = "InputSlot";
|
|
@@ -2398,27 +2231,27 @@
|
|
|
2398
2231
|
Root: InputRoot,
|
|
2399
2232
|
Slot: InputSlot
|
|
2400
2233
|
};
|
|
2401
|
-
const LayoutContext =
|
|
2402
|
-
const useLayoutContext = () =>
|
|
2403
|
-
const LayoutContainer =
|
|
2234
|
+
const LayoutContext = react.createContext({});
|
|
2235
|
+
const useLayoutContext = () => react.useContext(LayoutContext);
|
|
2236
|
+
const LayoutContainer = react.memo((props) => {
|
|
2404
2237
|
const { ref, children, className, ...rest } = props;
|
|
2405
2238
|
const { hideLayout = false } = useLayoutContext();
|
|
2406
2239
|
return !hideLayout && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classVarianceAuthority.cx("flex h-full grow", className), ref, ...rest, children });
|
|
2407
2240
|
});
|
|
2408
2241
|
LayoutContainer.displayName = "LayoutContainer";
|
|
2409
|
-
const LayoutRoot =
|
|
2242
|
+
const LayoutRoot = react.memo((props) => {
|
|
2410
2243
|
const { children, small = false, hideLayout = false } = props;
|
|
2411
|
-
const [openMapping, setOpenMapping] =
|
|
2412
|
-
const isOpen =
|
|
2244
|
+
const [openMapping, setOpenMapping] = react.useState({});
|
|
2245
|
+
const isOpen = react.useCallback(
|
|
2413
2246
|
(id) => {
|
|
2414
2247
|
return openMapping[id] ?? false;
|
|
2415
2248
|
},
|
|
2416
2249
|
[openMapping]
|
|
2417
2250
|
);
|
|
2418
|
-
const setOpen =
|
|
2251
|
+
const setOpen = react.useCallback((id, open) => {
|
|
2419
2252
|
setOpenMapping((prev) => ({ ...prev, [id]: open }));
|
|
2420
2253
|
}, []);
|
|
2421
|
-
const contextValue =
|
|
2254
|
+
const contextValue = react.useMemo(
|
|
2422
2255
|
() => ({
|
|
2423
2256
|
small,
|
|
2424
2257
|
hideLayout,
|
|
@@ -2432,10 +2265,10 @@
|
|
|
2432
2265
|
LayoutRoot.displayName = "LayoutRoot";
|
|
2433
2266
|
function usePointerDownOutside(onPointerDownOutside, ownerElement = globalThis == null ? void 0 : globalThis.document.body) {
|
|
2434
2267
|
const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
|
|
2435
|
-
const isPointerInsideReactTreeRef =
|
|
2436
|
-
const handleClickRef =
|
|
2268
|
+
const isPointerInsideReactTreeRef = react.useRef(false);
|
|
2269
|
+
const handleClickRef = react.useRef(() => {
|
|
2437
2270
|
});
|
|
2438
|
-
|
|
2271
|
+
react.useEffect(() => {
|
|
2439
2272
|
const handlePointerDown = (event) => {
|
|
2440
2273
|
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
2441
2274
|
const eventDetail = { originalEvent: event };
|
|
@@ -2482,17 +2315,17 @@
|
|
|
2482
2315
|
}
|
|
2483
2316
|
}
|
|
2484
2317
|
function useCallbackRef(callback) {
|
|
2485
|
-
const callbackRef =
|
|
2486
|
-
|
|
2318
|
+
const callbackRef = react.useRef(callback);
|
|
2319
|
+
react.useEffect(() => {
|
|
2487
2320
|
callbackRef.current = callback;
|
|
2488
2321
|
});
|
|
2489
|
-
return
|
|
2322
|
+
return react.useMemo(() => (...args) => {
|
|
2490
2323
|
var _a;
|
|
2491
2324
|
return (_a = callbackRef.current) == null ? void 0 : _a.call(callbackRef, ...args);
|
|
2492
2325
|
}, []);
|
|
2493
2326
|
}
|
|
2494
2327
|
const TIMEOUT_DURATION = 200;
|
|
2495
|
-
const SlideOut =
|
|
2328
|
+
const SlideOut = react.memo((props) => {
|
|
2496
2329
|
const {
|
|
2497
2330
|
ref,
|
|
2498
2331
|
children,
|
|
@@ -2515,25 +2348,25 @@
|
|
|
2515
2348
|
...otherProps
|
|
2516
2349
|
} = props;
|
|
2517
2350
|
const isLeft = side === "left";
|
|
2518
|
-
const [parentContainer, setParentContainer] =
|
|
2519
|
-
const childrenContainerRef =
|
|
2520
|
-
const localRef =
|
|
2521
|
-
const nodeRef =
|
|
2351
|
+
const [parentContainer, setParentContainer] = react.useState(document.body);
|
|
2352
|
+
const childrenContainerRef = react.useRef(null);
|
|
2353
|
+
const localRef = react.useRef(null);
|
|
2354
|
+
const nodeRef = react.useRef(null);
|
|
2522
2355
|
const mergedRefs = mergeRefs([ref, localRef, nodeRef]);
|
|
2523
|
-
const [isResizing, setIsResizing] =
|
|
2524
|
-
const [computedWidth, setComputedWidth] =
|
|
2525
|
-
const prevClientX =
|
|
2526
|
-
const handleDismiss =
|
|
2356
|
+
const [isResizing, setIsResizing] = react.useState(false);
|
|
2357
|
+
const [computedWidth, setComputedWidth] = react.useState(null);
|
|
2358
|
+
const prevClientX = react.useRef(null);
|
|
2359
|
+
const handleDismiss = react.useCallback(() => {
|
|
2527
2360
|
if (modal && onDismiss) {
|
|
2528
2361
|
onDismiss();
|
|
2529
2362
|
}
|
|
2530
2363
|
}, [modal, onDismiss]);
|
|
2531
|
-
const handleAssignParentContainer =
|
|
2364
|
+
const handleAssignParentContainer = react.useCallback((element) => {
|
|
2532
2365
|
if (element) {
|
|
2533
2366
|
setParentContainer(element);
|
|
2534
2367
|
}
|
|
2535
2368
|
}, []);
|
|
2536
|
-
|
|
2369
|
+
react.useEffect(() => {
|
|
2537
2370
|
if (!childrenContainerRef.current) return;
|
|
2538
2371
|
const originalParentPointerEvents = childrenContainerRef.current.style.pointerEvents;
|
|
2539
2372
|
if (open && modal) {
|
|
@@ -2546,7 +2379,7 @@
|
|
|
2546
2379
|
};
|
|
2547
2380
|
}, [modal, open, parentContainer.style]);
|
|
2548
2381
|
const { onPointerDownCapture: handlePointerDownCapture } = usePointerDownOutside(handleDismiss, parentContainer);
|
|
2549
|
-
const CSSTransitionClassNames =
|
|
2382
|
+
const CSSTransitionClassNames = react.useMemo(
|
|
2550
2383
|
() => ({
|
|
2551
2384
|
enter: isLeft ? "-ml-(--slide-out-width)" : "-mr-(--slide-out-width)",
|
|
2552
2385
|
enterActive: isLeft ? "ease-linear duration-200 transition-[margin-left] ml-0" : "ease-linear duration-200 transition-[margin-right] mr-0",
|
|
@@ -2556,12 +2389,12 @@
|
|
|
2556
2389
|
}),
|
|
2557
2390
|
[isLeft]
|
|
2558
2391
|
);
|
|
2559
|
-
const handleMouseDown =
|
|
2392
|
+
const handleMouseDown = react.useCallback((e) => {
|
|
2560
2393
|
const { clientX } = e;
|
|
2561
2394
|
prevClientX.current = clientX;
|
|
2562
2395
|
setIsResizing(true);
|
|
2563
2396
|
}, []);
|
|
2564
|
-
const handleMouseMove =
|
|
2397
|
+
const handleMouseMove = react.useCallback(
|
|
2565
2398
|
(e) => {
|
|
2566
2399
|
if (!isResizing) return;
|
|
2567
2400
|
const { clientX } = e;
|
|
@@ -2571,12 +2404,12 @@
|
|
|
2571
2404
|
},
|
|
2572
2405
|
[isLeft, isResizing]
|
|
2573
2406
|
);
|
|
2574
|
-
const handleMouseUp =
|
|
2407
|
+
const handleMouseUp = react.useCallback(() => {
|
|
2575
2408
|
if (!isResizing) return;
|
|
2576
2409
|
prevClientX.current = null;
|
|
2577
2410
|
setIsResizing(false);
|
|
2578
2411
|
}, [isResizing]);
|
|
2579
|
-
|
|
2412
|
+
react.useEffect(() => {
|
|
2580
2413
|
window.addEventListener("mousemove", handleMouseMove);
|
|
2581
2414
|
window.addEventListener("mouseup", handleMouseUp);
|
|
2582
2415
|
return () => {
|
|
@@ -2584,11 +2417,11 @@
|
|
|
2584
2417
|
window.removeEventListener("mouseup", handleMouseUp);
|
|
2585
2418
|
};
|
|
2586
2419
|
}, [handleMouseMove, handleMouseUp]);
|
|
2587
|
-
|
|
2420
|
+
react.useLayoutEffect(() => {
|
|
2588
2421
|
if (!open) return;
|
|
2589
2422
|
setComputedWidth(localRef.current.offsetWidth);
|
|
2590
2423
|
}, [open]);
|
|
2591
|
-
const resizableStyle =
|
|
2424
|
+
const resizableStyle = react.useMemo(
|
|
2592
2425
|
() => ({
|
|
2593
2426
|
...style,
|
|
2594
2427
|
width: computedWidth ?? initialWidth,
|
|
@@ -2599,11 +2432,11 @@
|
|
|
2599
2432
|
}),
|
|
2600
2433
|
[computedWidth, initialWidth, maxWidth, minWidth, position, style]
|
|
2601
2434
|
);
|
|
2602
|
-
const resizableEnable =
|
|
2435
|
+
const resizableEnable = react.useMemo(
|
|
2603
2436
|
() => ({ left: resizeable && !isLeft, right: resizeable && isLeft }),
|
|
2604
2437
|
[isLeft, resizeable]
|
|
2605
2438
|
);
|
|
2606
|
-
const SlideOut2 =
|
|
2439
|
+
const SlideOut2 = react.useMemo(
|
|
2607
2440
|
() => (
|
|
2608
2441
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2609
2442
|
// @ts-ignore
|
|
@@ -2698,7 +2531,7 @@
|
|
|
2698
2531
|
});
|
|
2699
2532
|
SlideOut.displayName = "SlideOut";
|
|
2700
2533
|
const DEFAULT_INITIAL_WIDTH = "30%";
|
|
2701
|
-
const LayoutSlideOut =
|
|
2534
|
+
const LayoutSlideOut = react.memo((props) => {
|
|
2702
2535
|
const { small, hideLayout, isOpen, setOpen } = useLayoutContext();
|
|
2703
2536
|
const {
|
|
2704
2537
|
ref,
|
|
@@ -2712,14 +2545,14 @@
|
|
|
2712
2545
|
...rest
|
|
2713
2546
|
} = props;
|
|
2714
2547
|
const open = isOpen(id);
|
|
2715
|
-
|
|
2548
|
+
react.useEffect(() => {
|
|
2716
2549
|
if (small && (defaultOpen == null ? void 0 : defaultOpen.small) !== void 0) {
|
|
2717
2550
|
setOpen(id, defaultOpen == null ? void 0 : defaultOpen.small);
|
|
2718
2551
|
} else if (!small && (defaultOpen == null ? void 0 : defaultOpen.large) !== void 0) {
|
|
2719
2552
|
setOpen(id, defaultOpen == null ? void 0 : defaultOpen.large);
|
|
2720
2553
|
}
|
|
2721
2554
|
}, [defaultOpen, id, setOpen, small]);
|
|
2722
|
-
const handleDismiss =
|
|
2555
|
+
const handleDismiss = react.useCallback(() => {
|
|
2723
2556
|
setOpen(id, false);
|
|
2724
2557
|
onDismiss == null ? void 0 : onDismiss();
|
|
2725
2558
|
}, [id, onDismiss, setOpen]);
|
|
@@ -2740,10 +2573,10 @@
|
|
|
2740
2573
|
);
|
|
2741
2574
|
});
|
|
2742
2575
|
LayoutSlideOut.displayName = "LayoutSlideOut";
|
|
2743
|
-
const LayoutSlideOutOverlay =
|
|
2576
|
+
const LayoutSlideOutOverlay = react.memo((props) => {
|
|
2744
2577
|
const { ref, children, className, active, slideOutId, smallModeOnly = false, ...rest } = props;
|
|
2745
2578
|
const { small, hideLayout, isOpen } = useLayoutContext();
|
|
2746
|
-
const showOverlay =
|
|
2579
|
+
const showOverlay = react.useMemo(() => {
|
|
2747
2580
|
if (active !== void 0) return active;
|
|
2748
2581
|
if (hideLayout) return false;
|
|
2749
2582
|
if (smallModeOnly && !small) return false;
|
|
@@ -2752,40 +2585,6 @@
|
|
|
2752
2585
|
return showOverlay && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classVarianceAuthority.cx("overmap-layout-overlay", "fixed inset-0", className), ref, ...rest, children });
|
|
2753
2586
|
});
|
|
2754
2587
|
LayoutSlideOutOverlay.displayName = "SlideOutOverlay";
|
|
2755
|
-
const MENU_OVERFLOW_PADDING = 20;
|
|
2756
|
-
const MENU_CONTENT_PADDING = 8;
|
|
2757
|
-
const MENU_MINIMUM_MAX_HEIGHT = 250;
|
|
2758
|
-
const computeOffsets = (side, alignment) => {
|
|
2759
|
-
switch (side) {
|
|
2760
|
-
case "right":
|
|
2761
|
-
if (alignment === "start") {
|
|
2762
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -MENU_CONTENT_PADDING };
|
|
2763
|
-
} else if (alignment === "end") {
|
|
2764
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2765
|
-
}
|
|
2766
|
-
break;
|
|
2767
|
-
case "left":
|
|
2768
|
-
if (alignment === "start") {
|
|
2769
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -MENU_CONTENT_PADDING };
|
|
2770
|
-
} else if (alignment === "end") {
|
|
2771
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2772
|
-
}
|
|
2773
|
-
break;
|
|
2774
|
-
}
|
|
2775
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: 0 };
|
|
2776
|
-
};
|
|
2777
|
-
function getSelectedState(selected) {
|
|
2778
|
-
return selected ? "selected" : "unselected";
|
|
2779
|
-
}
|
|
2780
|
-
function getCheckedState(checked) {
|
|
2781
|
-
return checked === true ? "checked" : checked === false ? "unchecked" : "indeterminate";
|
|
2782
|
-
}
|
|
2783
|
-
function getBooleanState(value) {
|
|
2784
|
-
return value ? "true" : "false";
|
|
2785
|
-
}
|
|
2786
|
-
function getOpenState(open) {
|
|
2787
|
-
return open ? "open" : "closed";
|
|
2788
|
-
}
|
|
2789
2588
|
function nextStateBasedOnType(open, type) {
|
|
2790
2589
|
switch (type) {
|
|
2791
2590
|
case "toggle":
|
|
@@ -2796,11 +2595,11 @@
|
|
|
2796
2595
|
return false;
|
|
2797
2596
|
}
|
|
2798
2597
|
}
|
|
2799
|
-
const LayoutSlideOutTrigger =
|
|
2598
|
+
const LayoutSlideOutTrigger = react.memo((props) => {
|
|
2800
2599
|
const { ref, slideOutId, type = "toggle", children, ...rest } = props;
|
|
2801
2600
|
const { isOpen, setOpen } = useLayoutContext();
|
|
2802
2601
|
const open = isOpen(slideOutId);
|
|
2803
|
-
const handleClick =
|
|
2602
|
+
const handleClick = react.useCallback(() => {
|
|
2804
2603
|
setOpen(slideOutId, nextStateBasedOnType(open, type));
|
|
2805
2604
|
}, [open, setOpen, slideOutId, type]);
|
|
2806
2605
|
return /* @__PURE__ */ jsxRuntime.jsx(reactSlot.Slot, { "data-state": getOpenState(open), ref, onClick: handleClick, ...rest, children });
|
|
@@ -2849,7 +2648,7 @@
|
|
|
2849
2648
|
align: "left"
|
|
2850
2649
|
}
|
|
2851
2650
|
});
|
|
2852
|
-
const Link =
|
|
2651
|
+
const Link = react.memo((props) => {
|
|
2853
2652
|
const providerContext = useProvider();
|
|
2854
2653
|
const {
|
|
2855
2654
|
ref,
|
|
@@ -2881,28 +2680,6 @@
|
|
|
2881
2680
|
);
|
|
2882
2681
|
});
|
|
2883
2682
|
Link.displayName = "Link";
|
|
2884
|
-
const CheckedIndicatorContext = React.createContext({});
|
|
2885
|
-
const CheckedIndicator = (props) => {
|
|
2886
|
-
const { children, ref, className, ...rest } = props;
|
|
2887
|
-
const checked = React.useContext(CheckedIndicatorContext);
|
|
2888
|
-
const computedChildren = typeof children === "function" ? children(checked === "indeterminate") : children;
|
|
2889
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2890
|
-
"span",
|
|
2891
|
-
{
|
|
2892
|
-
ref,
|
|
2893
|
-
className: classVarianceAuthority.cx(
|
|
2894
|
-
"flex size-max items-center",
|
|
2895
|
-
{
|
|
2896
|
-
invisible: checked === false
|
|
2897
|
-
},
|
|
2898
|
-
className
|
|
2899
|
-
),
|
|
2900
|
-
"data-state": getCheckedState$1(checked),
|
|
2901
|
-
...rest,
|
|
2902
|
-
children: computedChildren
|
|
2903
|
-
}
|
|
2904
|
-
);
|
|
2905
|
-
};
|
|
2906
2683
|
const menuItem = classVarianceAuthority.cva(
|
|
2907
2684
|
[
|
|
2908
2685
|
"select-none",
|
|
@@ -3048,319 +2825,28 @@
|
|
|
3048
2825
|
}
|
|
3049
2826
|
}
|
|
3050
2827
|
);
|
|
3051
|
-
const
|
|
3052
|
-
const
|
|
3053
|
-
const
|
|
3054
|
-
const
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
offset,
|
|
3060
|
-
loop = false,
|
|
3061
|
-
modal = false,
|
|
3062
|
-
// open state related props
|
|
3063
|
-
open: controlledOpen,
|
|
3064
|
-
onOpenChange,
|
|
3065
|
-
defaultOpen
|
|
3066
|
-
} = props;
|
|
3067
|
-
const [open, setOpen] = useControlledState(defaultOpen ?? false, controlledOpen, onOpenChange);
|
|
3068
|
-
const [activeIndex, setActiveIndex] = React.useState(null);
|
|
3069
|
-
const [triggerType, setTriggerType] = React.useState(null);
|
|
3070
|
-
const elementsRef = React.useRef([]);
|
|
3071
|
-
const nodeId = react.useFloatingNodeId();
|
|
3072
|
-
const { refs, floatingStyles, context, middlewareData } = react.useFloating({
|
|
3073
|
-
nodeId,
|
|
3074
|
-
strategy: "fixed",
|
|
3075
|
-
placement: side + (align !== "center" ? "-" + align : ""),
|
|
3076
|
-
whileElementsMounted: react.autoUpdate,
|
|
3077
|
-
open,
|
|
3078
|
-
onOpenChange: setOpen,
|
|
3079
|
-
middleware: [
|
|
3080
|
-
react.offset({ mainAxis: offset ?? DEFAULT_OFFSET }),
|
|
3081
|
-
react.size({
|
|
3082
|
-
apply({ availableHeight, elements }) {
|
|
3083
|
-
elements.floating.style.setProperty(
|
|
3084
|
-
"--overmap-menu-available-height",
|
|
3085
|
-
`${Math.max(availableHeight, MENU_MINIMUM_MAX_HEIGHT)}px`
|
|
3086
|
-
);
|
|
3087
|
-
},
|
|
3088
|
-
padding: MENU_OVERFLOW_PADDING
|
|
3089
|
-
}),
|
|
3090
|
-
react.flip({ fallbackStrategy: "initialPlacement" }),
|
|
3091
|
-
react.shift({ padding: MENU_OVERFLOW_PADDING }),
|
|
3092
|
-
react.hide()
|
|
3093
|
-
]
|
|
3094
|
-
});
|
|
3095
|
-
const role = react.useRole(context, {
|
|
3096
|
-
role: "menu"
|
|
3097
|
-
});
|
|
3098
|
-
const dismiss = react.useDismiss(context, {
|
|
3099
|
-
capture: true,
|
|
3100
|
-
ancestorScroll: triggerType === "context" || triggerType === "virtual"
|
|
3101
|
-
});
|
|
3102
|
-
const click = react.useClick(context, {
|
|
3103
|
-
enabled: triggerType === "click"
|
|
3104
|
-
});
|
|
3105
|
-
const listNavigation = react.useListNavigation(context, {
|
|
3106
|
-
listRef: elementsRef,
|
|
3107
|
-
activeIndex,
|
|
3108
|
-
onNavigate: setActiveIndex,
|
|
3109
|
-
loop
|
|
3110
|
-
});
|
|
3111
|
-
const { getFloatingProps, getItemProps, getReferenceProps } = react.useInteractions([
|
|
3112
|
-
dismiss,
|
|
3113
|
-
listNavigation,
|
|
3114
|
-
click,
|
|
3115
|
-
role
|
|
3116
|
-
]);
|
|
3117
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.FloatingTree, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3118
|
-
MenuContext.Provider,
|
|
3119
|
-
{
|
|
3120
|
-
value: {
|
|
3121
|
-
open,
|
|
3122
|
-
setOpen,
|
|
3123
|
-
refs,
|
|
3124
|
-
context,
|
|
3125
|
-
floatingStyles,
|
|
3126
|
-
elementsRef,
|
|
3127
|
-
getFloatingProps,
|
|
3128
|
-
getItemProps,
|
|
3129
|
-
getReferenceProps,
|
|
3130
|
-
nodeId,
|
|
3131
|
-
activeIndex,
|
|
3132
|
-
setActiveIndex,
|
|
3133
|
-
middlewareData,
|
|
3134
|
-
side,
|
|
3135
|
-
modal,
|
|
3136
|
-
setTriggerType
|
|
3137
|
-
},
|
|
3138
|
-
children
|
|
3139
|
-
}
|
|
3140
|
-
) });
|
|
3141
|
-
});
|
|
3142
|
-
MenuRoot.displayName = "Root";
|
|
3143
|
-
const MenuContentContext = React.createContext({});
|
|
3144
|
-
const useMenuContentContext = () => React.useContext(MenuContentContext);
|
|
3145
|
-
const MenuContent = React.memo((props) => {
|
|
3146
|
-
var _a;
|
|
3147
|
-
const providerContext = useProvider();
|
|
2828
|
+
const MenuContentContext = react.createContext({});
|
|
2829
|
+
const MenuContext = react.createContext({});
|
|
2830
|
+
const SubContext = react.createContext({});
|
|
2831
|
+
const TRIGGER_SELECT_KEYS = ["Enter", " "];
|
|
2832
|
+
const MenuItem = react.memo((props) => {
|
|
2833
|
+
const rootMenuContext = react.use(MenuContext);
|
|
2834
|
+
const { getItemProps, activeIndex, setOpen, size, variant, radius } = react.use(MenuContentContext);
|
|
2835
|
+
const { closeRoot } = react.use(SubContext);
|
|
3148
2836
|
const {
|
|
3149
2837
|
ref: forwardedRef,
|
|
3150
2838
|
className,
|
|
3151
2839
|
children,
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
2840
|
+
onSelect,
|
|
2841
|
+
onClick,
|
|
2842
|
+
onKeyDown,
|
|
2843
|
+
closeOnSelect = true,
|
|
2844
|
+
disabled = false,
|
|
3156
2845
|
...rest
|
|
3157
2846
|
} = props;
|
|
3158
|
-
const {
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
middlewareData,
|
|
3162
|
-
elementsRef,
|
|
3163
|
-
activeIndex,
|
|
3164
|
-
setActiveIndex,
|
|
3165
|
-
getItemProps,
|
|
3166
|
-
open,
|
|
3167
|
-
setOpen,
|
|
3168
|
-
nodeId,
|
|
3169
|
-
context,
|
|
3170
|
-
floatingStyles,
|
|
3171
|
-
modal,
|
|
3172
|
-
side
|
|
3173
|
-
} = useMenuContext();
|
|
3174
|
-
const computedFloatingStyles = React.useMemo(() => {
|
|
3175
|
-
var _a2;
|
|
3176
|
-
return {
|
|
3177
|
-
...floatingStyles,
|
|
3178
|
-
visibility: ((_a2 = middlewareData.hide) == null ? void 0 : _a2.referenceHidden) ? "hidden" : "visible"
|
|
3179
|
-
};
|
|
3180
|
-
}, [floatingStyles, (_a = middlewareData.hide) == null ? void 0 : _a.referenceHidden]);
|
|
3181
|
-
const handleOverlayPointerDown = React.useCallback(
|
|
3182
|
-
(e) => {
|
|
3183
|
-
if (modal) stopPropagation(e);
|
|
3184
|
-
},
|
|
3185
|
-
[modal]
|
|
3186
|
-
);
|
|
3187
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.FloatingNode, { id: nodeId, children: open && /* @__PURE__ */ jsxRuntime.jsx(react.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3188
|
-
react.FloatingOverlay,
|
|
3189
|
-
{
|
|
3190
|
-
className: menuOverlay({ modal }),
|
|
3191
|
-
onClick: handleOverlayPointerDown,
|
|
3192
|
-
lockScroll: true,
|
|
3193
|
-
"data-floating-content": "",
|
|
3194
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(react.FloatingFocusManager, { context, children: /* @__PURE__ */ jsxRuntime.jsx(react.FloatingList, { elementsRef, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3195
|
-
MenuContentContext.Provider,
|
|
3196
|
-
{
|
|
3197
|
-
value: {
|
|
3198
|
-
getItemProps,
|
|
3199
|
-
activeIndex,
|
|
3200
|
-
elementsRef,
|
|
3201
|
-
open,
|
|
3202
|
-
setOpen,
|
|
3203
|
-
refs,
|
|
3204
|
-
setActiveIndex,
|
|
3205
|
-
size,
|
|
3206
|
-
variant,
|
|
3207
|
-
accentColor,
|
|
3208
|
-
radius
|
|
3209
|
-
},
|
|
3210
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3211
|
-
"div",
|
|
3212
|
-
{
|
|
3213
|
-
className: "border-box w-max outline-none",
|
|
3214
|
-
ref: refs.setFloating,
|
|
3215
|
-
tabIndex: -1,
|
|
3216
|
-
style: computedFloatingStyles,
|
|
3217
|
-
"data-floating-content": "",
|
|
3218
|
-
...getFloatingProps(),
|
|
3219
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3220
|
-
"ul",
|
|
3221
|
-
{
|
|
3222
|
-
className: classVarianceAuthority.cx(
|
|
3223
|
-
menuContent({ size }),
|
|
3224
|
-
floating({ side, shadow: "3" }),
|
|
3225
|
-
radiusCva({ radius, maxLarge: true }),
|
|
3226
|
-
"max-h-(--overmap-menu-available-height)",
|
|
3227
|
-
className
|
|
3228
|
-
),
|
|
3229
|
-
ref: forwardedRef,
|
|
3230
|
-
"data-state": getOpenState(open),
|
|
3231
|
-
"data-side": side,
|
|
3232
|
-
"data-accent-color": accentColor,
|
|
3233
|
-
...rest,
|
|
3234
|
-
children
|
|
3235
|
-
}
|
|
3236
|
-
)
|
|
3237
|
-
}
|
|
3238
|
-
)
|
|
3239
|
-
}
|
|
3240
|
-
) }) })
|
|
3241
|
-
}
|
|
3242
|
-
) }) });
|
|
3243
|
-
});
|
|
3244
|
-
MenuContent.displayName = "Menu.Content";
|
|
3245
|
-
const SubContext = React.createContext({});
|
|
3246
|
-
const useSubContext = () => React.useContext(SubContext);
|
|
3247
|
-
const MenuSub = React.memo((props) => {
|
|
3248
|
-
const {
|
|
3249
|
-
children,
|
|
3250
|
-
disabled = false,
|
|
3251
|
-
side = "right",
|
|
3252
|
-
align = "start",
|
|
3253
|
-
closeRoot = false,
|
|
3254
|
-
loop = false,
|
|
3255
|
-
modal = false,
|
|
3256
|
-
// open state related props
|
|
3257
|
-
open: controlledOpen,
|
|
3258
|
-
onOpenChange,
|
|
3259
|
-
defaultOpen
|
|
3260
|
-
} = props;
|
|
3261
|
-
const [open, setOpen] = useControlledState(defaultOpen ?? false, controlledOpen, onOpenChange);
|
|
3262
|
-
const nodeId = react.useFloatingNodeId();
|
|
3263
|
-
const { refs, floatingStyles, context } = react.useFloating({
|
|
3264
|
-
nodeId,
|
|
3265
|
-
strategy: "fixed",
|
|
3266
|
-
whileElementsMounted: react.autoUpdate,
|
|
3267
|
-
open,
|
|
3268
|
-
onOpenChange: (open2, _event, reason) => {
|
|
3269
|
-
if (reason) setOpen(open2);
|
|
3270
|
-
},
|
|
3271
|
-
placement: side + (align !== "center" ? "-" + align : ""),
|
|
3272
|
-
middleware: [
|
|
3273
|
-
react.offset({ ...computeOffsets(side, align) }),
|
|
3274
|
-
react.size({
|
|
3275
|
-
padding: MENU_OVERFLOW_PADDING,
|
|
3276
|
-
apply({ availableHeight, elements }) {
|
|
3277
|
-
elements.floating.style.setProperty(
|
|
3278
|
-
"--overmap-menu-available-height",
|
|
3279
|
-
`${Math.max(availableHeight, MENU_MINIMUM_MAX_HEIGHT)}px`
|
|
3280
|
-
);
|
|
3281
|
-
}
|
|
3282
|
-
}),
|
|
3283
|
-
react.flip(),
|
|
3284
|
-
react.shift({ padding: MENU_OVERFLOW_PADDING }),
|
|
3285
|
-
react.hide()
|
|
3286
|
-
]
|
|
3287
|
-
});
|
|
3288
|
-
const dismiss = react.useDismiss(context, {
|
|
3289
|
-
bubbles: closeRoot,
|
|
3290
|
-
outsidePress: closeRoot
|
|
3291
|
-
});
|
|
3292
|
-
const hover = react.useHover(context, {
|
|
3293
|
-
restMs: 50,
|
|
3294
|
-
handleClose: react.safePolygon({
|
|
3295
|
-
blockPointerEvents: true,
|
|
3296
|
-
requireIntent: false
|
|
3297
|
-
}),
|
|
3298
|
-
enabled: !disabled
|
|
3299
|
-
});
|
|
3300
|
-
const click = react.useClick(context, {
|
|
3301
|
-
enabled: !disabled
|
|
3302
|
-
});
|
|
3303
|
-
const elementsRef = React.useRef([]);
|
|
3304
|
-
const [activeIndex, setActiveIndex] = React.useState(null);
|
|
3305
|
-
const listNavigation = react.useListNavigation(context, {
|
|
3306
|
-
listRef: elementsRef,
|
|
3307
|
-
nested: true,
|
|
3308
|
-
activeIndex,
|
|
3309
|
-
onNavigate: setActiveIndex,
|
|
3310
|
-
loop,
|
|
3311
|
-
rtl: side === "left"
|
|
3312
|
-
});
|
|
3313
|
-
const { getFloatingProps, getItemProps, getReferenceProps } = react.useInteractions([
|
|
3314
|
-
listNavigation,
|
|
3315
|
-
dismiss,
|
|
3316
|
-
hover,
|
|
3317
|
-
click
|
|
3318
|
-
]);
|
|
3319
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3320
|
-
SubContext.Provider,
|
|
3321
|
-
{
|
|
3322
|
-
value: {
|
|
3323
|
-
open,
|
|
3324
|
-
setOpen,
|
|
3325
|
-
nodeId,
|
|
3326
|
-
refs,
|
|
3327
|
-
floatingStyles,
|
|
3328
|
-
context,
|
|
3329
|
-
elementsRef,
|
|
3330
|
-
activeIndex,
|
|
3331
|
-
setActiveIndex,
|
|
3332
|
-
getFloatingProps,
|
|
3333
|
-
getItemProps,
|
|
3334
|
-
getReferenceProps,
|
|
3335
|
-
disabled,
|
|
3336
|
-
side,
|
|
3337
|
-
closeRoot,
|
|
3338
|
-
modal
|
|
3339
|
-
},
|
|
3340
|
-
children
|
|
3341
|
-
}
|
|
3342
|
-
);
|
|
3343
|
-
});
|
|
3344
|
-
MenuSub.displayName = "SubMenu";
|
|
3345
|
-
const TRIGGER_SELECT_KEYS = ["Enter", " "];
|
|
3346
|
-
const MenuItem = React.memo((props) => {
|
|
3347
|
-
const rootMenuContext = useMenuContext();
|
|
3348
|
-
const { getItemProps, activeIndex, setOpen, size, variant, radius } = useMenuContentContext();
|
|
3349
|
-
const { closeRoot } = useSubContext();
|
|
3350
|
-
const {
|
|
3351
|
-
ref: forwardedRef,
|
|
3352
|
-
className,
|
|
3353
|
-
children,
|
|
3354
|
-
onSelect,
|
|
3355
|
-
onClick,
|
|
3356
|
-
onKeyDown,
|
|
3357
|
-
closeOnSelect = true,
|
|
3358
|
-
disabled = false,
|
|
3359
|
-
...rest
|
|
3360
|
-
} = props;
|
|
3361
|
-
const { ref, index } = react.useListItem();
|
|
3362
|
-
const mergeRefs2 = react.useMergeRefs([ref, forwardedRef]);
|
|
3363
|
-
const handleClick = React.useCallback(
|
|
2847
|
+
const { ref, index } = react$1.useListItem();
|
|
2848
|
+
const mergeRefs2 = react$1.useMergeRefs([ref, forwardedRef]);
|
|
2849
|
+
const handleClick = react.useCallback(
|
|
3364
2850
|
(e) => {
|
|
3365
2851
|
e.stopPropagation();
|
|
3366
2852
|
if (disabled) return;
|
|
@@ -3371,7 +2857,7 @@
|
|
|
3371
2857
|
},
|
|
3372
2858
|
[closeOnSelect, closeRoot, disabled, rootMenuContext, onClick, onSelect, setOpen]
|
|
3373
2859
|
);
|
|
3374
|
-
const handleKeyDown =
|
|
2860
|
+
const handleKeyDown = react.useCallback(
|
|
3375
2861
|
(e) => {
|
|
3376
2862
|
if (disabled) return;
|
|
3377
2863
|
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
@@ -3382,8 +2868,8 @@
|
|
|
3382
2868
|
},
|
|
3383
2869
|
[closeOnSelect, disabled, onKeyDown, onSelect, setOpen]
|
|
3384
2870
|
);
|
|
3385
|
-
const isActive =
|
|
3386
|
-
const computedChildren =
|
|
2871
|
+
const isActive = react.useMemo(() => index === activeIndex, [activeIndex, index]);
|
|
2872
|
+
const computedChildren = react.useMemo(() => {
|
|
3387
2873
|
return typeof children === "function" ? children({ active: isActive, selected: false }) : children;
|
|
3388
2874
|
}, [children, isActive]);
|
|
3389
2875
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3406,9 +2892,9 @@
|
|
|
3406
2892
|
);
|
|
3407
2893
|
});
|
|
3408
2894
|
MenuItem.displayName = "MenuItem";
|
|
3409
|
-
const MenuCheckboxItem =
|
|
2895
|
+
const MenuCheckboxItem = react.memo((props) => {
|
|
3410
2896
|
const { ref, checked, onCheckedChange, onSelect, ...rest } = props;
|
|
3411
|
-
const handleSelect =
|
|
2897
|
+
const handleSelect = react.useCallback(() => {
|
|
3412
2898
|
onSelect == null ? void 0 : onSelect();
|
|
3413
2899
|
switch (checked) {
|
|
3414
2900
|
case true:
|
|
@@ -3423,16 +2909,16 @@
|
|
|
3423
2909
|
return /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicatorContext.Provider, { value: checked, children: /* @__PURE__ */ jsxRuntime.jsx(MenuItem, { ref, onSelect: handleSelect, ...rest }) });
|
|
3424
2910
|
});
|
|
3425
2911
|
MenuCheckboxItem.displayName = "MenuCheckboxItem";
|
|
3426
|
-
const MenuCheckboxItemIndicator =
|
|
2912
|
+
const MenuCheckboxItemIndicator = react.memo((props) => {
|
|
3427
2913
|
const { ref, children, ...rest } = props;
|
|
3428
2914
|
return /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicator, { ref, ...rest, children });
|
|
3429
2915
|
});
|
|
3430
2916
|
MenuCheckboxItemIndicator.displayName = "MenuCheckboxItemIndicator";
|
|
3431
|
-
const MenuClickTrigger =
|
|
2917
|
+
const MenuClickTrigger = react.memo((props) => {
|
|
3432
2918
|
const { ref: forwardedRef, children, disabled = false } = props;
|
|
3433
|
-
const { getReferenceProps, refs, setTriggerType, open } =
|
|
3434
|
-
const mergedRefs = react.useMergeRefs([refs.setReference, forwardedRef]);
|
|
3435
|
-
|
|
2919
|
+
const { getReferenceProps, refs, setTriggerType, open } = react.use(MenuContext);
|
|
2920
|
+
const mergedRefs = react$1.useMergeRefs([refs.setReference, forwardedRef]);
|
|
2921
|
+
react.useEffect(() => {
|
|
3436
2922
|
setTriggerType("click");
|
|
3437
2923
|
}, [setTriggerType]);
|
|
3438
2924
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3448,15 +2934,115 @@
|
|
|
3448
2934
|
);
|
|
3449
2935
|
});
|
|
3450
2936
|
MenuClickTrigger.displayName = "MenuClickTrigger";
|
|
3451
|
-
const
|
|
2937
|
+
const MenuContent = react.memo((props) => {
|
|
2938
|
+
var _a;
|
|
2939
|
+
const providerContext = useProvider();
|
|
2940
|
+
const {
|
|
2941
|
+
ref: forwardedRef,
|
|
2942
|
+
className,
|
|
2943
|
+
children,
|
|
2944
|
+
size = "md",
|
|
2945
|
+
variant = "soft",
|
|
2946
|
+
radius = providerContext.radius,
|
|
2947
|
+
accentColor = "base",
|
|
2948
|
+
...rest
|
|
2949
|
+
} = props;
|
|
2950
|
+
const {
|
|
2951
|
+
refs,
|
|
2952
|
+
getFloatingProps,
|
|
2953
|
+
middlewareData,
|
|
2954
|
+
elementsRef,
|
|
2955
|
+
activeIndex,
|
|
2956
|
+
setActiveIndex,
|
|
2957
|
+
getItemProps,
|
|
2958
|
+
open,
|
|
2959
|
+
setOpen,
|
|
2960
|
+
nodeId,
|
|
2961
|
+
context,
|
|
2962
|
+
floatingStyles,
|
|
2963
|
+
modal,
|
|
2964
|
+
side
|
|
2965
|
+
} = react.use(MenuContext);
|
|
2966
|
+
const computedFloatingStyles = react.useMemo(() => {
|
|
2967
|
+
var _a2;
|
|
2968
|
+
return {
|
|
2969
|
+
...floatingStyles,
|
|
2970
|
+
visibility: ((_a2 = middlewareData.hide) == null ? void 0 : _a2.referenceHidden) ? "hidden" : "visible"
|
|
2971
|
+
};
|
|
2972
|
+
}, [floatingStyles, (_a = middlewareData.hide) == null ? void 0 : _a.referenceHidden]);
|
|
2973
|
+
const handleOverlayPointerDown = react.useCallback(
|
|
2974
|
+
(e) => {
|
|
2975
|
+
if (modal) stopPropagation(e);
|
|
2976
|
+
},
|
|
2977
|
+
[modal]
|
|
2978
|
+
);
|
|
2979
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingNode, { id: nodeId, children: open && /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2980
|
+
react$1.FloatingOverlay,
|
|
2981
|
+
{
|
|
2982
|
+
className: menuOverlay({ modal }),
|
|
2983
|
+
onClick: handleOverlayPointerDown,
|
|
2984
|
+
lockScroll: true,
|
|
2985
|
+
"data-floating-content": "",
|
|
2986
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingFocusManager, { context, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingList, { elementsRef, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2987
|
+
MenuContentContext.Provider,
|
|
2988
|
+
{
|
|
2989
|
+
value: {
|
|
2990
|
+
getItemProps,
|
|
2991
|
+
activeIndex,
|
|
2992
|
+
elementsRef,
|
|
2993
|
+
open,
|
|
2994
|
+
setOpen,
|
|
2995
|
+
refs,
|
|
2996
|
+
setActiveIndex,
|
|
2997
|
+
size,
|
|
2998
|
+
variant,
|
|
2999
|
+
accentColor,
|
|
3000
|
+
radius
|
|
3001
|
+
},
|
|
3002
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3003
|
+
"div",
|
|
3004
|
+
{
|
|
3005
|
+
className: "border-box w-max outline-none",
|
|
3006
|
+
ref: refs.setFloating,
|
|
3007
|
+
tabIndex: -1,
|
|
3008
|
+
style: computedFloatingStyles,
|
|
3009
|
+
"data-floating-content": "",
|
|
3010
|
+
...getFloatingProps(),
|
|
3011
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3012
|
+
"ul",
|
|
3013
|
+
{
|
|
3014
|
+
className: classVarianceAuthority.cx(
|
|
3015
|
+
menuContent({ size }),
|
|
3016
|
+
floating({ side, shadow: "3" }),
|
|
3017
|
+
radiusCva({ radius, maxLarge: true }),
|
|
3018
|
+
"max-h-(--overmap-menu-available-height)",
|
|
3019
|
+
className
|
|
3020
|
+
),
|
|
3021
|
+
ref: forwardedRef,
|
|
3022
|
+
"data-state": getOpenState(open),
|
|
3023
|
+
"data-side": side,
|
|
3024
|
+
"data-accent-color": accentColor,
|
|
3025
|
+
...rest,
|
|
3026
|
+
children
|
|
3027
|
+
}
|
|
3028
|
+
)
|
|
3029
|
+
}
|
|
3030
|
+
)
|
|
3031
|
+
}
|
|
3032
|
+
) }) })
|
|
3033
|
+
}
|
|
3034
|
+
) }) });
|
|
3035
|
+
});
|
|
3036
|
+
MenuContent.displayName = "Menu.Content";
|
|
3037
|
+
const MenuContextTrigger = react.memo((props) => {
|
|
3452
3038
|
const { ref: forwardedRef, children, disabled = false } = props;
|
|
3453
|
-
const ref =
|
|
3454
|
-
const { setOpen, refs, setTriggerType, open } =
|
|
3455
|
-
const mergedRefs = react.useMergeRefs([forwardedRef, ref]);
|
|
3456
|
-
|
|
3039
|
+
const ref = react.useRef(null);
|
|
3040
|
+
const { setOpen, refs, setTriggerType, open } = react.use(MenuContext);
|
|
3041
|
+
const mergedRefs = react$1.useMergeRefs([forwardedRef, ref]);
|
|
3042
|
+
react.useEffect(() => {
|
|
3457
3043
|
setTriggerType("context");
|
|
3458
3044
|
}, [setTriggerType]);
|
|
3459
|
-
const handleContextMenu =
|
|
3045
|
+
const handleContextMenu = react.useCallback(
|
|
3460
3046
|
(e) => {
|
|
3461
3047
|
const { clientY, clientX } = e;
|
|
3462
3048
|
if (!disabled && ref.current) {
|
|
@@ -3495,24 +3081,24 @@
|
|
|
3495
3081
|
);
|
|
3496
3082
|
});
|
|
3497
3083
|
MenuContextTrigger.displayName = "MenuContextTrigger";
|
|
3498
|
-
const MenuGroup =
|
|
3084
|
+
const MenuGroup = react.memo((props) => {
|
|
3499
3085
|
const { ref, children, ...rest } = props;
|
|
3500
3086
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, role: "group", ...rest, children });
|
|
3501
3087
|
});
|
|
3502
3088
|
MenuGroup.displayName = "MenuGroup";
|
|
3503
|
-
const MenuInputField =
|
|
3089
|
+
const MenuInputField = react.memo((props) => {
|
|
3504
3090
|
const { ref: forwardedRef, className, onValueChange, onChange, disabled = false, ...rest } = props;
|
|
3505
|
-
const { activeIndex, getItemProps } =
|
|
3506
|
-
const { index, ref } = react.useListItem();
|
|
3507
|
-
const mergedRefs = react.useMergeRefs([ref, forwardedRef]);
|
|
3508
|
-
const handleChange =
|
|
3091
|
+
const { activeIndex, getItemProps } = react.use(MenuContentContext);
|
|
3092
|
+
const { index, ref } = react$1.useListItem();
|
|
3093
|
+
const mergedRefs = react$1.useMergeRefs([ref, forwardedRef]);
|
|
3094
|
+
const handleChange = react.useCallback(
|
|
3509
3095
|
(e) => {
|
|
3510
3096
|
onChange == null ? void 0 : onChange(e);
|
|
3511
3097
|
onValueChange == null ? void 0 : onValueChange(e.target.value);
|
|
3512
3098
|
},
|
|
3513
3099
|
[onChange, onValueChange]
|
|
3514
3100
|
);
|
|
3515
|
-
|
|
3101
|
+
react.useEffect(() => {
|
|
3516
3102
|
return () => {
|
|
3517
3103
|
onValueChange == null ? void 0 : onValueChange("");
|
|
3518
3104
|
};
|
|
@@ -3533,20 +3119,20 @@
|
|
|
3533
3119
|
);
|
|
3534
3120
|
});
|
|
3535
3121
|
MenuInputField.displayName = "MenuInputField";
|
|
3536
|
-
const MenuInputRoot =
|
|
3122
|
+
const MenuInputRoot = react.memo((props) => {
|
|
3537
3123
|
const { ref, className, ...rest } = props;
|
|
3538
|
-
const { size } =
|
|
3124
|
+
const { size } = react.use(MenuContentContext);
|
|
3539
3125
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classVarianceAuthority.cx(inputRoot({ size }), className), ref, ...rest });
|
|
3540
3126
|
});
|
|
3541
3127
|
MenuInputRoot.displayName = "MenuInputRoot";
|
|
3542
|
-
const MenuInputSlot =
|
|
3128
|
+
const MenuInputSlot = react.memo((props) => {
|
|
3543
3129
|
const { ref, className, ...rest } = props;
|
|
3544
3130
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classVarianceAuthority.cx("flex", "items-center", "text-(--base-a11)", className), ref, ...rest });
|
|
3545
3131
|
});
|
|
3546
3132
|
MenuInputSlot.displayName = "MenuInputSlot";
|
|
3547
|
-
const MenuLabel =
|
|
3133
|
+
const MenuLabel = react.memo((props) => {
|
|
3548
3134
|
const { ref, className, ...rest } = props;
|
|
3549
|
-
const { size } =
|
|
3135
|
+
const { size } = react.use(MenuContentContext);
|
|
3550
3136
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: classVarianceAuthority.cx(menuLabelCva({ size }), className), ...rest });
|
|
3551
3137
|
});
|
|
3552
3138
|
MenuLabel.displayName = "MenuLabel";
|
|
@@ -3554,41 +3140,18 @@
|
|
|
3554
3140
|
const { ref, children, defaultValues, values, onValuesChange, ...rest } = props;
|
|
3555
3141
|
return /* @__PURE__ */ jsxRuntime.jsx(MenuGroup, { ref, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(MultiSelectProvider, { defaultValues, values, onValuesChange, children }) });
|
|
3556
3142
|
});
|
|
3557
|
-
const SelectedIndicatorContext = React.createContext(false);
|
|
3558
|
-
const useSelectedIndicatorContext = () => React.useContext(SelectedIndicatorContext);
|
|
3559
|
-
const MenuSelectedIndicator = React.memo((props) => {
|
|
3560
|
-
const { ref, children, className, ...rest } = props;
|
|
3561
|
-
const isSelected = useSelectedIndicatorContext();
|
|
3562
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3563
|
-
"span",
|
|
3564
|
-
{
|
|
3565
|
-
ref,
|
|
3566
|
-
className: classVarianceAuthority.cx(
|
|
3567
|
-
"flex size-max items-center",
|
|
3568
|
-
{
|
|
3569
|
-
invisible: !isSelected
|
|
3570
|
-
},
|
|
3571
|
-
className
|
|
3572
|
-
),
|
|
3573
|
-
"data-state": getSelectedState(isSelected),
|
|
3574
|
-
...rest,
|
|
3575
|
-
children
|
|
3576
|
-
}
|
|
3577
|
-
);
|
|
3578
|
-
});
|
|
3579
|
-
MenuSelectedIndicator.displayName = "SelectedIndicator";
|
|
3580
3143
|
const MenuMultiSelectItem = genericMemo(function(props) {
|
|
3581
3144
|
const { ref, onSelect, children, closeOnSelect = false, value, ...rest } = props;
|
|
3582
|
-
const { selected, selectValue, registerValue } =
|
|
3583
|
-
|
|
3145
|
+
const { selected, selectValue, registerValue } = react.use(MultiSelectContext);
|
|
3146
|
+
react.useLayoutEffect(() => {
|
|
3584
3147
|
return registerValue(value);
|
|
3585
3148
|
}, [registerValue, value]);
|
|
3586
3149
|
const isSelected = selected(value);
|
|
3587
|
-
const handleSelect =
|
|
3150
|
+
const handleSelect = react.useCallback(() => {
|
|
3588
3151
|
onSelect == null ? void 0 : onSelect();
|
|
3589
3152
|
selectValue(value);
|
|
3590
3153
|
}, [onSelect, selectValue, value]);
|
|
3591
|
-
const computedChildren =
|
|
3154
|
+
const computedChildren = react.useMemo(() => {
|
|
3592
3155
|
return typeof children === "function" ? ({ active }) => children({ selected: isSelected, active }) : children;
|
|
3593
3156
|
}, [children, isSelected]);
|
|
3594
3157
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3604,26 +3167,25 @@
|
|
|
3604
3167
|
}
|
|
3605
3168
|
) });
|
|
3606
3169
|
});
|
|
3607
|
-
const PagesContext =
|
|
3608
|
-
const
|
|
3609
|
-
|
|
3170
|
+
const PagesContext = react.createContext({});
|
|
3171
|
+
const MenuPageContent = react.memo((props) => {
|
|
3172
|
+
const { page, children } = props;
|
|
3173
|
+
const { activePage } = react.use(PagesContext);
|
|
3174
|
+
return activePage === page ? children : null;
|
|
3175
|
+
});
|
|
3176
|
+
MenuPageContent.displayName = "PageContent";
|
|
3177
|
+
const MenuPages = react.memo((props) => {
|
|
3610
3178
|
const { children, defaultPage, page, onPageChange } = props;
|
|
3611
3179
|
const [activePage, setActivePage] = useControlledState(defaultPage ?? "", page, onPageChange);
|
|
3612
|
-
const contextValue =
|
|
3180
|
+
const contextValue = react.useMemo(() => ({ activePage, setActivePage }), [activePage, setActivePage]);
|
|
3613
3181
|
return /* @__PURE__ */ jsxRuntime.jsx(PagesContext.Provider, { value: contextValue, children });
|
|
3614
3182
|
});
|
|
3615
3183
|
MenuPages.displayName = "MenuPages";
|
|
3616
|
-
const
|
|
3617
|
-
const { page, children } = props;
|
|
3618
|
-
const { activePage } = usePagesContext();
|
|
3619
|
-
return activePage === page ? children : null;
|
|
3620
|
-
};
|
|
3621
|
-
MenuPageContent.displayName = "PageContent";
|
|
3622
|
-
const MenuPageTrigger = React.memo((props) => {
|
|
3184
|
+
const MenuPageTrigger = react.memo((props) => {
|
|
3623
3185
|
const { ref, onSelect, page, ...rest } = props;
|
|
3624
|
-
const { refs, setActiveIndex } =
|
|
3625
|
-
const { setActivePage } =
|
|
3626
|
-
const handleSelect =
|
|
3186
|
+
const { refs, setActiveIndex } = react.use(MenuContentContext);
|
|
3187
|
+
const { setActivePage } = react.use(PagesContext);
|
|
3188
|
+
const handleSelect = react.useCallback(() => {
|
|
3627
3189
|
var _a;
|
|
3628
3190
|
onSelect == null ? void 0 : onSelect();
|
|
3629
3191
|
setActivePage(page);
|
|
@@ -3633,47 +3195,944 @@
|
|
|
3633
3195
|
return /* @__PURE__ */ jsxRuntime.jsx(MenuItem, { ref, onSelect: handleSelect, closeOnSelect: false, ...rest });
|
|
3634
3196
|
});
|
|
3635
3197
|
MenuPageTrigger.displayName = "MenuPageTrigger";
|
|
3636
|
-
const
|
|
3198
|
+
const MENU_OVERFLOW_PADDING = 20;
|
|
3199
|
+
const MENU_CONTENT_PADDING = 8;
|
|
3200
|
+
const MENU_MINIMUM_MAX_HEIGHT = 250;
|
|
3201
|
+
const DEFAULT_OFFSET = 5;
|
|
3202
|
+
const MenuRoot = react.memo((props) => {
|
|
3203
|
+
const {
|
|
3204
|
+
children,
|
|
3205
|
+
side = "bottom",
|
|
3206
|
+
align = "center",
|
|
3207
|
+
offset,
|
|
3208
|
+
loop = false,
|
|
3209
|
+
modal = false,
|
|
3210
|
+
// open state related props
|
|
3211
|
+
open: controlledOpen,
|
|
3212
|
+
onOpenChange,
|
|
3213
|
+
defaultOpen
|
|
3214
|
+
} = props;
|
|
3215
|
+
const [open, setOpen] = useControlledState(defaultOpen ?? false, controlledOpen, onOpenChange);
|
|
3216
|
+
const [activeIndex, setActiveIndex] = react.useState(null);
|
|
3217
|
+
const [triggerType, setTriggerType] = react.useState(null);
|
|
3218
|
+
const elementsRef = react.useRef([]);
|
|
3219
|
+
const nodeId = react$1.useFloatingNodeId();
|
|
3220
|
+
const { refs, floatingStyles, context, middlewareData } = react$1.useFloating({
|
|
3221
|
+
nodeId,
|
|
3222
|
+
strategy: "fixed",
|
|
3223
|
+
// TODO: probably some way with template string types to not need the "as Placement"
|
|
3224
|
+
placement: side + (align !== "center" ? "-" + align : ""),
|
|
3225
|
+
whileElementsMounted: react$1.autoUpdate,
|
|
3226
|
+
open,
|
|
3227
|
+
onOpenChange: setOpen,
|
|
3228
|
+
middleware: [
|
|
3229
|
+
react$1.offset({ mainAxis: offset ?? DEFAULT_OFFSET }),
|
|
3230
|
+
react$1.size({
|
|
3231
|
+
apply({ availableHeight, elements }) {
|
|
3232
|
+
elements.floating.style.setProperty(
|
|
3233
|
+
"--overmap-menu-available-height",
|
|
3234
|
+
`${Math.max(availableHeight, MENU_MINIMUM_MAX_HEIGHT)}px`
|
|
3235
|
+
);
|
|
3236
|
+
},
|
|
3237
|
+
padding: MENU_OVERFLOW_PADDING
|
|
3238
|
+
}),
|
|
3239
|
+
react$1.flip({ fallbackStrategy: "initialPlacement" }),
|
|
3240
|
+
react$1.shift({ padding: MENU_OVERFLOW_PADDING }),
|
|
3241
|
+
react$1.hide()
|
|
3242
|
+
]
|
|
3243
|
+
});
|
|
3244
|
+
const role = react$1.useRole(context, {
|
|
3245
|
+
role: "menu"
|
|
3246
|
+
});
|
|
3247
|
+
const dismiss = react$1.useDismiss(context, {
|
|
3248
|
+
capture: true,
|
|
3249
|
+
ancestorScroll: triggerType === "context" || triggerType === "virtual"
|
|
3250
|
+
});
|
|
3251
|
+
const click = react$1.useClick(context, {
|
|
3252
|
+
enabled: triggerType === "click"
|
|
3253
|
+
});
|
|
3254
|
+
const listNavigation = react$1.useListNavigation(context, {
|
|
3255
|
+
listRef: elementsRef,
|
|
3256
|
+
activeIndex,
|
|
3257
|
+
onNavigate: setActiveIndex,
|
|
3258
|
+
loop
|
|
3259
|
+
});
|
|
3260
|
+
const { getFloatingProps, getItemProps, getReferenceProps } = react$1.useInteractions([
|
|
3261
|
+
dismiss,
|
|
3262
|
+
listNavigation,
|
|
3263
|
+
click,
|
|
3264
|
+
role
|
|
3265
|
+
]);
|
|
3266
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingTree, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3267
|
+
MenuContext.Provider,
|
|
3268
|
+
{
|
|
3269
|
+
value: {
|
|
3270
|
+
open,
|
|
3271
|
+
setOpen,
|
|
3272
|
+
refs,
|
|
3273
|
+
context,
|
|
3274
|
+
floatingStyles,
|
|
3275
|
+
elementsRef,
|
|
3276
|
+
getFloatingProps,
|
|
3277
|
+
getItemProps,
|
|
3278
|
+
getReferenceProps,
|
|
3279
|
+
nodeId,
|
|
3280
|
+
activeIndex,
|
|
3281
|
+
setActiveIndex,
|
|
3282
|
+
middlewareData,
|
|
3283
|
+
side,
|
|
3284
|
+
modal,
|
|
3285
|
+
setTriggerType
|
|
3286
|
+
},
|
|
3287
|
+
children
|
|
3288
|
+
}
|
|
3289
|
+
) });
|
|
3290
|
+
});
|
|
3291
|
+
MenuRoot.displayName = "Root";
|
|
3292
|
+
const MenuScroll = react.memo((props) => {
|
|
3293
|
+
const { ref, className, ...rest } = props;
|
|
3294
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3295
|
+
"div",
|
|
3296
|
+
{
|
|
3297
|
+
ref,
|
|
3298
|
+
className: classVarianceAuthority.cx(
|
|
3299
|
+
"h-full overflow-x-hidden overflow-y-auto [scrollbar-color:var(--base-6)_transparent] [scrollbar-width:thin]",
|
|
3300
|
+
className
|
|
3301
|
+
),
|
|
3302
|
+
...rest
|
|
3303
|
+
}
|
|
3304
|
+
);
|
|
3305
|
+
});
|
|
3306
|
+
MenuScroll.displayName = "MenuScroll";
|
|
3307
|
+
const MenuSelectAllItem = genericMemo((props) => {
|
|
3308
|
+
const { ref, children, onSelect, closeOnSelect = false, ...rest } = props;
|
|
3309
|
+
const { allSelected, someSelected, toggleSelectAll } = react.use(MultiSelectContext);
|
|
3310
|
+
const selectedState = allSelected ? true : someSelected ? "indeterminate" : false;
|
|
3311
|
+
const handleSelect = react.useCallback(() => {
|
|
3312
|
+
onSelect == null ? void 0 : onSelect();
|
|
3313
|
+
toggleSelectAll();
|
|
3314
|
+
}, [onSelect, toggleSelectAll]);
|
|
3315
|
+
const computedChildren = react.useMemo(() => {
|
|
3316
|
+
return typeof children === "function" ? ({ active }) => children({ selected: selectedState, active }) : children;
|
|
3317
|
+
}, [children, selectedState]);
|
|
3318
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicatorContext, { value: selectedState, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3319
|
+
MenuItem,
|
|
3320
|
+
{
|
|
3321
|
+
onSelect: handleSelect,
|
|
3322
|
+
ref,
|
|
3323
|
+
"data-state": getCheckedState(selectedState),
|
|
3324
|
+
closeOnSelect,
|
|
3325
|
+
...rest,
|
|
3326
|
+
children: computedChildren
|
|
3327
|
+
}
|
|
3328
|
+
) });
|
|
3329
|
+
});
|
|
3330
|
+
const MenuSelectedIndicator = react.memo((props) => {
|
|
3331
|
+
const { ref, children, ...rest } = props;
|
|
3332
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicator, { ref, ...rest, children });
|
|
3333
|
+
});
|
|
3334
|
+
MenuSelectedIndicator.displayName = "MenuSelectedIndicator";
|
|
3335
|
+
const MenuSelectGroup = genericMemo(function MenuSelectGroup2(props) {
|
|
3336
|
+
const { ref, children, required, defaultValue, value, onValueChange, ...rest } = props;
|
|
3337
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MenuGroup, { ref, ...rest, children: required ? /* @__PURE__ */ jsxRuntime.jsx(SingleSelectRequiredProvider, { defaultValue, value, onValueChange, children }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3338
|
+
SingleSelectNotRequiredProvider,
|
|
3339
|
+
{
|
|
3340
|
+
defaultValue,
|
|
3341
|
+
value,
|
|
3342
|
+
onValueChange,
|
|
3343
|
+
children
|
|
3344
|
+
}
|
|
3345
|
+
) });
|
|
3346
|
+
});
|
|
3347
|
+
const MenuSelectItem = genericMemo(function(props) {
|
|
3348
|
+
const { ref, value, onSelect, children, closeOnSelect = true, ...rest } = props;
|
|
3349
|
+
const { selected, selectValue } = react.use(SelectContext);
|
|
3350
|
+
const isSelected = selected(value);
|
|
3351
|
+
const handleSelect = react.useCallback(() => {
|
|
3352
|
+
onSelect == null ? void 0 : onSelect();
|
|
3353
|
+
selectValue(value);
|
|
3354
|
+
}, [onSelect, selectValue, value]);
|
|
3355
|
+
const computedChildren = react.useMemo(() => {
|
|
3356
|
+
return typeof children === "function" ? ({ active }) => children({ selected: isSelected, active }) : children;
|
|
3357
|
+
}, [children, isSelected]);
|
|
3358
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3359
|
+
MenuItem,
|
|
3360
|
+
{
|
|
3361
|
+
ref,
|
|
3362
|
+
role: "menuitemcheckbox",
|
|
3363
|
+
onSelect: handleSelect,
|
|
3364
|
+
closeOnSelect,
|
|
3365
|
+
"data-state": getSelectedState(isSelected),
|
|
3366
|
+
...rest,
|
|
3367
|
+
children: computedChildren
|
|
3368
|
+
}
|
|
3369
|
+
) });
|
|
3370
|
+
});
|
|
3371
|
+
const MenuSeparator = react.memo((props) => {
|
|
3637
3372
|
const { ref, className, ...rest } = props;
|
|
3373
|
+
const { size } = react.use(MenuContentContext);
|
|
3374
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RadixSeparator__namespace.Root, { className: classVarianceAuthority.cx(menuSeparator({ size }), className), ref, ...rest });
|
|
3375
|
+
});
|
|
3376
|
+
MenuSeparator.displayName = "MenuSeparator";
|
|
3377
|
+
const computeOffsets = (side, alignment) => {
|
|
3378
|
+
switch (side) {
|
|
3379
|
+
case "right":
|
|
3380
|
+
if (alignment === "start") {
|
|
3381
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -MENU_CONTENT_PADDING };
|
|
3382
|
+
} else if (alignment === "end") {
|
|
3383
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
3384
|
+
}
|
|
3385
|
+
break;
|
|
3386
|
+
case "left":
|
|
3387
|
+
if (alignment === "start") {
|
|
3388
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -MENU_CONTENT_PADDING };
|
|
3389
|
+
} else if (alignment === "end") {
|
|
3390
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
3391
|
+
}
|
|
3392
|
+
break;
|
|
3393
|
+
}
|
|
3394
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: 0 };
|
|
3395
|
+
};
|
|
3396
|
+
const MenuSub = react.memo((props) => {
|
|
3397
|
+
const {
|
|
3398
|
+
children,
|
|
3399
|
+
disabled = false,
|
|
3400
|
+
side = "right",
|
|
3401
|
+
align = "start",
|
|
3402
|
+
closeRoot = false,
|
|
3403
|
+
loop = false,
|
|
3404
|
+
modal = false,
|
|
3405
|
+
// open state related props
|
|
3406
|
+
open: controlledOpen,
|
|
3407
|
+
onOpenChange,
|
|
3408
|
+
defaultOpen
|
|
3409
|
+
} = props;
|
|
3410
|
+
const [open, setOpen] = useControlledState(defaultOpen ?? false, controlledOpen, onOpenChange);
|
|
3411
|
+
const nodeId = react$1.useFloatingNodeId();
|
|
3412
|
+
const { refs, floatingStyles, context } = react$1.useFloating({
|
|
3413
|
+
nodeId,
|
|
3414
|
+
strategy: "fixed",
|
|
3415
|
+
whileElementsMounted: react$1.autoUpdate,
|
|
3416
|
+
open,
|
|
3417
|
+
onOpenChange: (open2, _event, reason) => {
|
|
3418
|
+
if (reason) setOpen(open2);
|
|
3419
|
+
},
|
|
3420
|
+
placement: side + (align !== "center" ? "-" + align : ""),
|
|
3421
|
+
middleware: [
|
|
3422
|
+
react$1.offset({ ...computeOffsets(side, align) }),
|
|
3423
|
+
react$1.size({
|
|
3424
|
+
padding: MENU_OVERFLOW_PADDING,
|
|
3425
|
+
apply({ availableHeight, elements }) {
|
|
3426
|
+
elements.floating.style.setProperty(
|
|
3427
|
+
"--overmap-menu-available-height",
|
|
3428
|
+
`${Math.max(availableHeight, MENU_MINIMUM_MAX_HEIGHT)}px`
|
|
3429
|
+
);
|
|
3430
|
+
}
|
|
3431
|
+
}),
|
|
3432
|
+
react$1.flip(),
|
|
3433
|
+
react$1.shift({ padding: MENU_OVERFLOW_PADDING }),
|
|
3434
|
+
react$1.hide()
|
|
3435
|
+
]
|
|
3436
|
+
});
|
|
3437
|
+
const dismiss = react$1.useDismiss(context, {
|
|
3438
|
+
bubbles: closeRoot,
|
|
3439
|
+
outsidePress: closeRoot
|
|
3440
|
+
});
|
|
3441
|
+
const hover = react$1.useHover(context, {
|
|
3442
|
+
restMs: 50,
|
|
3443
|
+
handleClose: react$1.safePolygon({
|
|
3444
|
+
blockPointerEvents: true,
|
|
3445
|
+
requireIntent: false
|
|
3446
|
+
}),
|
|
3447
|
+
enabled: !disabled
|
|
3448
|
+
});
|
|
3449
|
+
const click = react$1.useClick(context, {
|
|
3450
|
+
enabled: !disabled
|
|
3451
|
+
});
|
|
3452
|
+
const elementsRef = react.useRef([]);
|
|
3453
|
+
const [activeIndex, setActiveIndex] = react.useState(null);
|
|
3454
|
+
const listNavigation = react$1.useListNavigation(context, {
|
|
3455
|
+
listRef: elementsRef,
|
|
3456
|
+
nested: true,
|
|
3457
|
+
activeIndex,
|
|
3458
|
+
onNavigate: setActiveIndex,
|
|
3459
|
+
loop,
|
|
3460
|
+
rtl: side === "left"
|
|
3461
|
+
});
|
|
3462
|
+
const { getFloatingProps, getItemProps, getReferenceProps } = react$1.useInteractions([
|
|
3463
|
+
listNavigation,
|
|
3464
|
+
dismiss,
|
|
3465
|
+
hover,
|
|
3466
|
+
click
|
|
3467
|
+
]);
|
|
3468
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3469
|
+
SubContext.Provider,
|
|
3470
|
+
{
|
|
3471
|
+
value: {
|
|
3472
|
+
open,
|
|
3473
|
+
setOpen,
|
|
3474
|
+
nodeId,
|
|
3475
|
+
refs,
|
|
3476
|
+
floatingStyles,
|
|
3477
|
+
context,
|
|
3478
|
+
elementsRef,
|
|
3479
|
+
activeIndex,
|
|
3480
|
+
setActiveIndex,
|
|
3481
|
+
getFloatingProps,
|
|
3482
|
+
getItemProps,
|
|
3483
|
+
getReferenceProps,
|
|
3484
|
+
disabled,
|
|
3485
|
+
side,
|
|
3486
|
+
closeRoot,
|
|
3487
|
+
modal
|
|
3488
|
+
},
|
|
3489
|
+
children
|
|
3490
|
+
}
|
|
3491
|
+
);
|
|
3492
|
+
});
|
|
3493
|
+
MenuSub.displayName = "SubMenu";
|
|
3494
|
+
const MenuSubContent = react.memo((props) => {
|
|
3495
|
+
var _a;
|
|
3496
|
+
const { ref: forwardedRef, children, ...rest } = props;
|
|
3497
|
+
const { middlewareData } = react.use(MenuContext);
|
|
3498
|
+
const { accentColor, radius, variant, size } = react.use(MenuContentContext);
|
|
3499
|
+
const {
|
|
3500
|
+
open,
|
|
3501
|
+
nodeId,
|
|
3502
|
+
refs,
|
|
3503
|
+
context,
|
|
3504
|
+
getFloatingProps,
|
|
3505
|
+
getItemProps,
|
|
3506
|
+
activeIndex,
|
|
3507
|
+
setActiveIndex,
|
|
3508
|
+
elementsRef,
|
|
3509
|
+
floatingStyles,
|
|
3510
|
+
setOpen,
|
|
3511
|
+
side
|
|
3512
|
+
} = react.use(SubContext);
|
|
3513
|
+
const wrapperRef = react.useRef(null);
|
|
3514
|
+
const mergeRefs2 = react$1.useMergeRefs([refs.setFloating, wrapperRef]);
|
|
3515
|
+
const computedFloatingStyles = react.useMemo(() => {
|
|
3516
|
+
var _a2;
|
|
3517
|
+
return {
|
|
3518
|
+
...floatingStyles,
|
|
3519
|
+
visibility: ((_a2 = middlewareData.hide) == null ? void 0 : _a2.referenceHidden) ? "hidden" : "visible"
|
|
3520
|
+
};
|
|
3521
|
+
}, [floatingStyles, (_a = middlewareData.hide) == null ? void 0 : _a.referenceHidden]);
|
|
3522
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingNode, { id: nodeId, children: open && /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingFocusManager, { context, initialFocus: wrapperRef, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingList, { elementsRef, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3523
|
+
MenuContentContext.Provider,
|
|
3524
|
+
{
|
|
3525
|
+
value: {
|
|
3526
|
+
getItemProps,
|
|
3527
|
+
activeIndex,
|
|
3528
|
+
setActiveIndex,
|
|
3529
|
+
elementsRef,
|
|
3530
|
+
open,
|
|
3531
|
+
setOpen,
|
|
3532
|
+
refs,
|
|
3533
|
+
size,
|
|
3534
|
+
radius,
|
|
3535
|
+
accentColor,
|
|
3536
|
+
variant
|
|
3537
|
+
},
|
|
3538
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3539
|
+
"div",
|
|
3540
|
+
{
|
|
3541
|
+
className: "outline-none",
|
|
3542
|
+
ref: mergeRefs2,
|
|
3543
|
+
style: computedFloatingStyles,
|
|
3544
|
+
...getFloatingProps(),
|
|
3545
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3546
|
+
"ul",
|
|
3547
|
+
{
|
|
3548
|
+
className: classVarianceAuthority.cx(
|
|
3549
|
+
"overmap-menu-sub-content",
|
|
3550
|
+
menuContent({ size }),
|
|
3551
|
+
floating({ side, shadow: "3" }),
|
|
3552
|
+
radiusCva({ radius, maxLarge: true }),
|
|
3553
|
+
"max-h-(--overmap-menu-available-height)"
|
|
3554
|
+
),
|
|
3555
|
+
ref: forwardedRef,
|
|
3556
|
+
"data-state": getOpenState(open),
|
|
3557
|
+
"data-side": side,
|
|
3558
|
+
"data-accent-color": accentColor,
|
|
3559
|
+
...rest,
|
|
3560
|
+
children
|
|
3561
|
+
}
|
|
3562
|
+
)
|
|
3563
|
+
}
|
|
3564
|
+
)
|
|
3565
|
+
}
|
|
3566
|
+
) }) }) }) });
|
|
3567
|
+
});
|
|
3568
|
+
MenuSubContent.displayName = "MenuSubContent";
|
|
3569
|
+
const MenuSubTrigger = react.memo((props) => {
|
|
3570
|
+
const { ref: forwardedRef, children, ...rest } = props;
|
|
3571
|
+
const { refs, getReferenceProps, open, disabled } = react.use(SubContext);
|
|
3572
|
+
const mergedRefs = react$1.useMergeRefs([forwardedRef, refs.setReference]);
|
|
3573
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3574
|
+
MenuItem,
|
|
3575
|
+
{
|
|
3576
|
+
ref: mergedRefs,
|
|
3577
|
+
closeOnSelect: false,
|
|
3578
|
+
"aria-haspopup": "menu",
|
|
3579
|
+
"data-state": getOpenState(open),
|
|
3580
|
+
disabled,
|
|
3581
|
+
...getReferenceProps(rest),
|
|
3582
|
+
children
|
|
3583
|
+
}
|
|
3584
|
+
);
|
|
3585
|
+
});
|
|
3586
|
+
MenuSubTrigger.displayName = "MenuSubTrigger";
|
|
3587
|
+
const MenuVirtualTrigger = react.memo((props) => {
|
|
3588
|
+
const { virtualElement, disabled } = props;
|
|
3589
|
+
const { refs, setTriggerType, setOpen } = react.use(MenuContext);
|
|
3590
|
+
react.useEffect(() => {
|
|
3591
|
+
setTriggerType("virtual");
|
|
3592
|
+
}, [setTriggerType]);
|
|
3593
|
+
react.useEffect(() => {
|
|
3594
|
+
if (!disabled && virtualElement) {
|
|
3595
|
+
refs.setPositionReference(virtualElement);
|
|
3596
|
+
setOpen(true);
|
|
3597
|
+
} else {
|
|
3598
|
+
refs.setPositionReference(null);
|
|
3599
|
+
setOpen(false);
|
|
3600
|
+
}
|
|
3601
|
+
}, [disabled, refs, setOpen, virtualElement]);
|
|
3602
|
+
return null;
|
|
3603
|
+
});
|
|
3604
|
+
MenuVirtualTrigger.displayName = "VirtualTrigger";
|
|
3605
|
+
const Menu = {
|
|
3606
|
+
Root: MenuRoot,
|
|
3607
|
+
Content: MenuContent,
|
|
3608
|
+
// sub
|
|
3609
|
+
Sub: MenuSub,
|
|
3610
|
+
SubContent: MenuSubContent,
|
|
3611
|
+
SubTrigger: MenuSubTrigger,
|
|
3612
|
+
// pages
|
|
3613
|
+
Pages: MenuPages,
|
|
3614
|
+
PageContent: MenuPageContent,
|
|
3615
|
+
PageTrigger: MenuPageTrigger,
|
|
3616
|
+
// triggers
|
|
3617
|
+
ClickTrigger: MenuClickTrigger,
|
|
3618
|
+
ContextTrigger: MenuContextTrigger,
|
|
3619
|
+
VirtualTrigger: MenuVirtualTrigger,
|
|
3620
|
+
// groups
|
|
3621
|
+
Group: MenuGroup,
|
|
3622
|
+
SelectGroup: MenuSelectGroup,
|
|
3623
|
+
MultiSelectGroup: MenuMultiSelectGroup,
|
|
3624
|
+
// items
|
|
3625
|
+
Item: MenuItem,
|
|
3626
|
+
SelectItem: MenuSelectItem,
|
|
3627
|
+
MultiSelectItem: MenuMultiSelectItem,
|
|
3628
|
+
SelectAllItem: MenuSelectAllItem,
|
|
3629
|
+
CheckboxItem: MenuCheckboxItem,
|
|
3630
|
+
// indicators
|
|
3631
|
+
SelectedIndicator: MenuSelectedIndicator,
|
|
3632
|
+
CheckboxItemIndicator: MenuCheckboxItemIndicator,
|
|
3633
|
+
// input
|
|
3634
|
+
InputRoot: MenuInputRoot,
|
|
3635
|
+
InputField: MenuInputField,
|
|
3636
|
+
InputSlot: MenuInputSlot,
|
|
3637
|
+
// others
|
|
3638
|
+
Label: MenuLabel,
|
|
3639
|
+
Separator: MenuSeparator,
|
|
3640
|
+
Scroll: MenuScroll
|
|
3641
|
+
};
|
|
3642
|
+
const KEY_MAPPING = {
|
|
3643
|
+
next: "ArrowDown",
|
|
3644
|
+
prev: "ArrowUp",
|
|
3645
|
+
first: "PageUp",
|
|
3646
|
+
last: "PageDown",
|
|
3647
|
+
selectItem: "Enter"
|
|
3648
|
+
};
|
|
3649
|
+
const ITEM_SELECTOR = "menu-item";
|
|
3650
|
+
const GROUP_SELECTOR = "menu-group";
|
|
3651
|
+
const MenuRootContext = react.createContext({});
|
|
3652
|
+
const MenuGroupContext = react.createContext({});
|
|
3653
|
+
const MenuPageContext = react.createContext({});
|
|
3654
|
+
const menuRootCva = classVarianceAuthority.cva(["w-full", "outline-none"], {
|
|
3655
|
+
variants: {
|
|
3656
|
+
size: {
|
|
3657
|
+
xs: ["p-0.5", "text-xs", "min-w-30"],
|
|
3658
|
+
sm: ["p-0.75", "text-sm", "min-w-35"],
|
|
3659
|
+
md: ["p-1", "text-md", "min-w-40"],
|
|
3660
|
+
lg: ["p-1.25", "text-lg", "min-w-45"],
|
|
3661
|
+
xl: ["p-1.5", "text-xl", "min-w-50"]
|
|
3662
|
+
},
|
|
3663
|
+
radius: {
|
|
3664
|
+
none: ["rounded-none"],
|
|
3665
|
+
xs: ["rounded-xs"],
|
|
3666
|
+
sm: ["rounded-sm"],
|
|
3667
|
+
md: ["rounded-md"],
|
|
3668
|
+
lg: ["rounded-lg"],
|
|
3669
|
+
xl: ["rounded-lg"],
|
|
3670
|
+
full: ["rounded-lg"]
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
});
|
|
3674
|
+
const menuItemCva = classVarianceAuthority.cva(
|
|
3675
|
+
[
|
|
3676
|
+
"select-none",
|
|
3677
|
+
"relative",
|
|
3678
|
+
"flex",
|
|
3679
|
+
"items-center",
|
|
3680
|
+
"outline-none",
|
|
3681
|
+
"data-[disabled=true]:text-(--base-a8)",
|
|
3682
|
+
"data-[disabled=true]:pointer-events-none",
|
|
3683
|
+
"shrink-0",
|
|
3684
|
+
"py-1",
|
|
3685
|
+
"text-(--base-12)"
|
|
3686
|
+
],
|
|
3687
|
+
{
|
|
3688
|
+
variants: {
|
|
3689
|
+
size: {
|
|
3690
|
+
xs: ["gap-1.5", "px-3"],
|
|
3691
|
+
sm: ["gap-1.75", "px-3.5"],
|
|
3692
|
+
md: ["gap-2", "px-4"],
|
|
3693
|
+
lg: ["gap-2.25", "px-4.5"],
|
|
3694
|
+
xl: ["gap-2.5", "px-5"]
|
|
3695
|
+
},
|
|
3696
|
+
variant: {
|
|
3697
|
+
solid: [
|
|
3698
|
+
"data-[active=true]:not-[data-[disabled=true]]:text-(--accent-contrast)",
|
|
3699
|
+
"data-[active=true]:not-[data-[disabled=true]]:bg-(--accent-a9)",
|
|
3700
|
+
"data-[active=true]:not-[data-[disabled=true]]:active:brightness-110"
|
|
3701
|
+
],
|
|
3702
|
+
soft: [
|
|
3703
|
+
"data-[active=true]:not-[data-[disabled=true]]:bg-(--accent-a3)",
|
|
3704
|
+
"data-[active=true]:not-[data-[disabled=true]]:active:bg-(--accent-a4)"
|
|
3705
|
+
]
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
);
|
|
3710
|
+
const menuGroupLabelCva = classVarianceAuthority.cva(["text-(--base-a11)", "flex", "items-center", "select-none", "py-1"], {
|
|
3711
|
+
variants: {
|
|
3712
|
+
size: {
|
|
3713
|
+
xs: ["gap-1.5", "px-3", "text-xs"],
|
|
3714
|
+
sm: ["gap-1.75", "px-3.5", "text-xs"],
|
|
3715
|
+
md: ["gap-2", "px-4", "text-sm"],
|
|
3716
|
+
lg: ["gap-2.25", "px-4.5", "text-base"],
|
|
3717
|
+
xl: ["gap-2.5", "px-5", "text-lg"]
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
});
|
|
3721
|
+
const menuSeparatorCva = classVarianceAuthority.cva(["h-px", "bg-(--base-a6)", "w-auto", "shrink-0"], {
|
|
3722
|
+
variants: {
|
|
3723
|
+
size: {
|
|
3724
|
+
xs: ["-mx-0.5", "my-0.5"],
|
|
3725
|
+
sm: ["-mx-0.75", "my-0.75"],
|
|
3726
|
+
md: ["-mx-1", "my-1"],
|
|
3727
|
+
lg: ["-mx-1.25", "my-1.25"],
|
|
3728
|
+
xl: ["-mx-1.5", "my-1.5"]
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
});
|
|
3732
|
+
const MenuV2Item = react.memo((props) => {
|
|
3733
|
+
const {
|
|
3734
|
+
ref,
|
|
3735
|
+
children,
|
|
3736
|
+
className,
|
|
3737
|
+
disabled = false,
|
|
3738
|
+
onClick,
|
|
3739
|
+
onSelect,
|
|
3740
|
+
onPointerEnter,
|
|
3741
|
+
onPointerLeave,
|
|
3742
|
+
onPointerMove,
|
|
3743
|
+
...rest
|
|
3744
|
+
} = props;
|
|
3745
|
+
const internalRef = react.useRef(null);
|
|
3746
|
+
const itemId = react.useId();
|
|
3747
|
+
const { activeItemId, setActiveItemId, size, variant, radius } = react.use(MenuRootContext);
|
|
3748
|
+
const isActive = itemId === activeItemId;
|
|
3749
|
+
const handleSelect = react.useCallback(
|
|
3750
|
+
(e) => {
|
|
3751
|
+
onSelect == null ? void 0 : onSelect(e);
|
|
3752
|
+
},
|
|
3753
|
+
[onSelect]
|
|
3754
|
+
);
|
|
3755
|
+
const handleClick = react.useCallback(
|
|
3756
|
+
(e) => {
|
|
3757
|
+
onClick == null ? void 0 : onClick(e);
|
|
3758
|
+
handleSelect(new Event("menu-select"));
|
|
3759
|
+
},
|
|
3760
|
+
[handleSelect, onClick]
|
|
3761
|
+
);
|
|
3762
|
+
const handlePointerEnter = react.useCallback(
|
|
3763
|
+
(e) => {
|
|
3764
|
+
onPointerEnter == null ? void 0 : onPointerEnter(e);
|
|
3765
|
+
if (e.defaultPrevented) return;
|
|
3766
|
+
setActiveItemId(itemId);
|
|
3767
|
+
},
|
|
3768
|
+
[onPointerEnter, setActiveItemId, itemId]
|
|
3769
|
+
);
|
|
3770
|
+
const handlePointerLeave = react.useCallback(
|
|
3771
|
+
(e) => {
|
|
3772
|
+
onPointerLeave == null ? void 0 : onPointerLeave(e);
|
|
3773
|
+
if (e.defaultPrevented) return;
|
|
3774
|
+
setActiveItemId(null);
|
|
3775
|
+
},
|
|
3776
|
+
[onPointerLeave, setActiveItemId]
|
|
3777
|
+
);
|
|
3778
|
+
const handlePointerMove = react.useCallback(
|
|
3779
|
+
(e) => {
|
|
3780
|
+
onPointerMove == null ? void 0 : onPointerMove(e);
|
|
3781
|
+
if (e.defaultPrevented) return;
|
|
3782
|
+
setActiveItemId(itemId);
|
|
3783
|
+
},
|
|
3784
|
+
[onPointerMove, itemId, setActiveItemId]
|
|
3785
|
+
);
|
|
3786
|
+
react.useEffect(() => {
|
|
3787
|
+
if (!internalRef.current) return;
|
|
3788
|
+
const element = internalRef.current;
|
|
3789
|
+
element.addEventListener("menu-select", handleSelect);
|
|
3790
|
+
return () => {
|
|
3791
|
+
element.removeEventListener("menu-select", handleSelect);
|
|
3792
|
+
};
|
|
3793
|
+
}, [handleSelect]);
|
|
3794
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3795
|
+
"div",
|
|
3796
|
+
{
|
|
3797
|
+
ref: mergeRefs([ref, internalRef]),
|
|
3798
|
+
className: classVarianceAuthority.cx(menuItemCva({ size, variant }), radiusCva({ radius, maxLarge: true }), className),
|
|
3799
|
+
role: "menuitem",
|
|
3800
|
+
onClick: handleClick,
|
|
3801
|
+
onPointerEnter: handlePointerEnter,
|
|
3802
|
+
onPointerLeave: handlePointerLeave,
|
|
3803
|
+
onPointerMove: handlePointerMove,
|
|
3804
|
+
...{ [ITEM_SELECTOR]: itemId },
|
|
3805
|
+
"data-active": getBooleanState(isActive),
|
|
3806
|
+
"data-disabled": getBooleanState(disabled),
|
|
3807
|
+
"aria-disabled": getBooleanState(disabled),
|
|
3808
|
+
...rest,
|
|
3809
|
+
children
|
|
3810
|
+
}
|
|
3811
|
+
);
|
|
3812
|
+
});
|
|
3813
|
+
MenuV2Item.displayName = "MenuItem";
|
|
3814
|
+
const MenuV2CheckboxItem = react.memo((props) => {
|
|
3815
|
+
const { ref, checked, onCheckedChange, onSelect, ...rest } = props;
|
|
3816
|
+
const handleSelect = react.useCallback(
|
|
3817
|
+
(e) => {
|
|
3818
|
+
onSelect == null ? void 0 : onSelect(e);
|
|
3819
|
+
if (e.defaultPrevented) return;
|
|
3820
|
+
switch (checked) {
|
|
3821
|
+
case true:
|
|
3822
|
+
onCheckedChange(false);
|
|
3823
|
+
break;
|
|
3824
|
+
case "indeterminate":
|
|
3825
|
+
onCheckedChange(true);
|
|
3826
|
+
break;
|
|
3827
|
+
case false:
|
|
3828
|
+
onCheckedChange(true);
|
|
3829
|
+
break;
|
|
3830
|
+
}
|
|
3831
|
+
},
|
|
3832
|
+
[checked, onCheckedChange, onSelect]
|
|
3833
|
+
);
|
|
3834
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicatorContext.Provider, { value: checked, children: /* @__PURE__ */ jsxRuntime.jsx(MenuV2Item, { ref, onSelect: handleSelect, ...rest }) });
|
|
3835
|
+
});
|
|
3836
|
+
MenuV2CheckboxItem.displayName = "MenuCheckboxItem";
|
|
3837
|
+
const MenuV2CheckedIndicator = react.memo((props) => {
|
|
3838
|
+
const { ref, children, ...rest } = props;
|
|
3839
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicator, { ref, ...rest, children });
|
|
3840
|
+
});
|
|
3841
|
+
MenuV2CheckedIndicator.displayName = "MenuCheckboxItemIndicator";
|
|
3842
|
+
const MenuV2Group = react.memo((props) => {
|
|
3843
|
+
const { ref, children, ...rest } = props;
|
|
3844
|
+
const groupId = react.useId();
|
|
3845
|
+
const [labelId, setLabelId] = react.useState(null);
|
|
3846
|
+
const contextValue = react.useMemo(
|
|
3847
|
+
() => ({
|
|
3848
|
+
labelId,
|
|
3849
|
+
setLabelId
|
|
3850
|
+
}),
|
|
3851
|
+
[labelId]
|
|
3852
|
+
);
|
|
3853
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, role: "group", ...{ [GROUP_SELECTOR]: groupId }, "aria-labelledby": labelId ?? void 0, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(MenuGroupContext, { value: contextValue, children }) });
|
|
3854
|
+
});
|
|
3855
|
+
MenuV2Group.displayName = "MenuGroup";
|
|
3856
|
+
const MenuV2GroupLabel = react.memo((props) => {
|
|
3857
|
+
const { ref, children, id, className, ...rest } = props;
|
|
3858
|
+
const labelId = useFallbackId(id);
|
|
3859
|
+
const { size } = react.use(MenuRootContext);
|
|
3860
|
+
const { setLabelId } = react.use(MenuGroupContext);
|
|
3861
|
+
react.useEffect(() => {
|
|
3862
|
+
setLabelId(labelId);
|
|
3863
|
+
}, [labelId, setLabelId]);
|
|
3864
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, id: labelId, className: classVarianceAuthority.cx(menuGroupLabelCva({ size }), className), ...rest, children });
|
|
3865
|
+
});
|
|
3866
|
+
MenuV2GroupLabel.displayName = "MenuGroupLabel";
|
|
3867
|
+
const MenuV2SelectAllItem = genericMemo((props) => {
|
|
3868
|
+
const { ref, children, onSelect, ...rest } = props;
|
|
3869
|
+
const { allSelected, someSelected, toggleSelectAll } = react.use(MultiSelectContext);
|
|
3870
|
+
const selectedState = allSelected ? true : someSelected ? "indeterminate" : false;
|
|
3871
|
+
const handleSelect = react.useCallback(
|
|
3872
|
+
(e) => {
|
|
3873
|
+
onSelect == null ? void 0 : onSelect(e);
|
|
3874
|
+
if (e.defaultPrevented) return;
|
|
3875
|
+
toggleSelectAll();
|
|
3876
|
+
},
|
|
3877
|
+
[onSelect, toggleSelectAll]
|
|
3878
|
+
);
|
|
3879
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MenuV2Item, { onSelect: handleSelect, ref, "data-state": getCheckedState(selectedState), ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicatorContext, { value: selectedState, children }) });
|
|
3880
|
+
});
|
|
3881
|
+
const MenuV2MultiSelectGroup = genericMemo(function MenuMultiSelectGroup2(props) {
|
|
3882
|
+
const { ref, children, defaultValues, values, onValuesChange, ...rest } = props;
|
|
3883
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MenuV2Group, { ref, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(MultiSelectProvider, { defaultValues, values, onValuesChange, children }) });
|
|
3884
|
+
});
|
|
3885
|
+
const MenuV2MultiSelectItem = genericMemo(function(props) {
|
|
3886
|
+
const { ref, onSelect, children, value, ...rest } = props;
|
|
3887
|
+
const { selected, selectValue, registerValue } = react.use(MultiSelectContext);
|
|
3888
|
+
react.useLayoutEffect(() => {
|
|
3889
|
+
return registerValue(value);
|
|
3890
|
+
}, [registerValue, value]);
|
|
3891
|
+
const isSelected = selected(value);
|
|
3892
|
+
const handleSelect = react.useCallback(
|
|
3893
|
+
(e) => {
|
|
3894
|
+
onSelect == null ? void 0 : onSelect(e);
|
|
3895
|
+
if (e.defaultPrevented) return;
|
|
3896
|
+
selectValue(value);
|
|
3897
|
+
},
|
|
3898
|
+
[onSelect, selectValue, value]
|
|
3899
|
+
);
|
|
3900
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3901
|
+
MenuV2Item,
|
|
3902
|
+
{
|
|
3903
|
+
ref,
|
|
3904
|
+
role: "menuitemcheckbox",
|
|
3905
|
+
onSelect: handleSelect,
|
|
3906
|
+
"data-state": getSelectedState(isSelected),
|
|
3907
|
+
...rest,
|
|
3908
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext, { value: isSelected, children })
|
|
3909
|
+
}
|
|
3910
|
+
);
|
|
3911
|
+
});
|
|
3912
|
+
const MenuV2Page = react.memo((props) => {
|
|
3913
|
+
const { children, ref, page, ...rest } = props;
|
|
3914
|
+
const { page: activePage } = react.use(MenuPageContext);
|
|
3915
|
+
const isActive = page === activePage;
|
|
3916
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-active": getActiveState(isActive), hidden: !isActive, ...rest, children: isActive ? children : null });
|
|
3917
|
+
});
|
|
3918
|
+
MenuV2Page.displayName = "MenuPage";
|
|
3919
|
+
const MenuV2Pages = react.memo((props) => {
|
|
3920
|
+
const { children, defaultPage = "", page: controlledPage, onPageChange } = props;
|
|
3921
|
+
const [page, setPage] = useControlledState(defaultPage, controlledPage, onPageChange);
|
|
3922
|
+
const contextValue = react.useMemo(
|
|
3923
|
+
() => ({
|
|
3924
|
+
page,
|
|
3925
|
+
setPage
|
|
3926
|
+
}),
|
|
3927
|
+
[page, setPage]
|
|
3928
|
+
);
|
|
3929
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MenuPageContext, { value: contextValue, children });
|
|
3930
|
+
});
|
|
3931
|
+
MenuV2Pages.displayName = "MenuPages";
|
|
3932
|
+
const MenuV2PageTriggerItem = react.memo((props) => {
|
|
3933
|
+
const { ref, children, page, onSelect, ...rest } = props;
|
|
3934
|
+
const { page: activePage, setPage } = react.use(MenuPageContext);
|
|
3935
|
+
const isActive = page === activePage;
|
|
3936
|
+
const handleSelect = react.useCallback(
|
|
3937
|
+
(e) => {
|
|
3938
|
+
onSelect == null ? void 0 : onSelect(e);
|
|
3939
|
+
if (e.defaultPrevented) return;
|
|
3940
|
+
setPage(page);
|
|
3941
|
+
},
|
|
3942
|
+
[onSelect, page, setPage]
|
|
3943
|
+
);
|
|
3944
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MenuV2Item, { ref, onSelect: handleSelect, "data-state": getActiveState(isActive), ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext, { value: isActive, children }) });
|
|
3945
|
+
});
|
|
3946
|
+
MenuV2PageTriggerItem.displayName = "CommandMenuPageTriggerItem";
|
|
3947
|
+
const computeNextIndex = (index, length, direction, loop) => {
|
|
3948
|
+
switch (direction) {
|
|
3949
|
+
case "next":
|
|
3950
|
+
return index === length - 1 ? loop ? 0 : index : index + 1;
|
|
3951
|
+
case "prev":
|
|
3952
|
+
return index === 0 ? loop ? length - 1 : index : index - 1;
|
|
3953
|
+
}
|
|
3954
|
+
};
|
|
3955
|
+
const MenuV2Root = react.memo((props) => {
|
|
3956
|
+
const providerContext = useProvider();
|
|
3957
|
+
const {
|
|
3958
|
+
ref,
|
|
3959
|
+
children,
|
|
3960
|
+
className,
|
|
3961
|
+
onKeyDown,
|
|
3962
|
+
loop = false,
|
|
3963
|
+
// style props
|
|
3964
|
+
radius = providerContext.radius,
|
|
3965
|
+
accentColor = "base",
|
|
3966
|
+
size = "md",
|
|
3967
|
+
variant = "soft",
|
|
3968
|
+
...rest
|
|
3969
|
+
} = props;
|
|
3970
|
+
const internalRef = react.useRef(null);
|
|
3971
|
+
const [activeItemId, setActiveItemId] = react.useState(null);
|
|
3972
|
+
const getItems = react.useCallback((element) => {
|
|
3973
|
+
return Array.from(element.querySelectorAll(`[${ITEM_SELECTOR}]:not([data-disabled=true]`));
|
|
3974
|
+
}, []);
|
|
3975
|
+
const getFirstItem = react.useCallback(
|
|
3976
|
+
(element) => {
|
|
3977
|
+
return getItems(element).at(0);
|
|
3978
|
+
},
|
|
3979
|
+
[getItems]
|
|
3980
|
+
);
|
|
3981
|
+
const getLastItem = react.useCallback(
|
|
3982
|
+
(element) => {
|
|
3983
|
+
return getItems(element).at(-1);
|
|
3984
|
+
},
|
|
3985
|
+
[getItems]
|
|
3986
|
+
);
|
|
3987
|
+
const getActiveItem = react.useCallback(
|
|
3988
|
+
(element) => {
|
|
3989
|
+
return getItems(element).find((itemEle) => itemEle.getAttribute(ITEM_SELECTOR) === activeItemId);
|
|
3990
|
+
},
|
|
3991
|
+
[activeItemId, getItems]
|
|
3992
|
+
);
|
|
3993
|
+
const getNextItem = react.useCallback(
|
|
3994
|
+
(element, direction) => {
|
|
3995
|
+
const items = getItems(element);
|
|
3996
|
+
const activeItem = getActiveItem(element);
|
|
3997
|
+
const activeItemIndex = items.findIndex((itemEle) => itemEle === activeItem);
|
|
3998
|
+
const nextItemIndex = computeNextIndex(activeItemIndex, items.length, direction, loop);
|
|
3999
|
+
return items[nextItemIndex];
|
|
4000
|
+
},
|
|
4001
|
+
[getActiveItem, getItems, loop]
|
|
4002
|
+
);
|
|
4003
|
+
const getGroups = react.useCallback(() => {
|
|
4004
|
+
if (!internalRef.current) return [];
|
|
4005
|
+
return Array.from(internalRef.current.querySelectorAll(`[${GROUP_SELECTOR}]`));
|
|
4006
|
+
}, []);
|
|
4007
|
+
const getActiveGroup = react.useCallback(() => {
|
|
4008
|
+
var _a;
|
|
4009
|
+
return ((_a = getActiveItem(internalRef.current)) == null ? void 0 : _a.closest(`[${GROUP_SELECTOR}]`)) ?? void 0;
|
|
4010
|
+
}, [getActiveItem]);
|
|
4011
|
+
const getNextGroup = react.useCallback(
|
|
4012
|
+
(direction) => {
|
|
4013
|
+
const groups = getGroups();
|
|
4014
|
+
const activeGroup = getActiveGroup();
|
|
4015
|
+
const activeGroupIndex = groups.findIndex((groupEle) => groupEle === activeGroup);
|
|
4016
|
+
const nextGroupIndex = computeNextIndex(activeGroupIndex, groups.length, direction, loop);
|
|
4017
|
+
return groups[nextGroupIndex];
|
|
4018
|
+
},
|
|
4019
|
+
[getActiveGroup, getGroups, loop]
|
|
4020
|
+
);
|
|
4021
|
+
const getFirstGroup = react.useCallback(() => {
|
|
4022
|
+
return getGroups().at(0);
|
|
4023
|
+
}, [getGroups]);
|
|
4024
|
+
const getLastGroup = react.useCallback(() => {
|
|
4025
|
+
return getGroups().at(-1);
|
|
4026
|
+
}, [getGroups]);
|
|
4027
|
+
const handleKeyDown = react.useCallback(
|
|
4028
|
+
(e) => {
|
|
4029
|
+
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
4030
|
+
if (e.defaultPrevented) return;
|
|
4031
|
+
switch (e.code) {
|
|
4032
|
+
case KEY_MAPPING.selectItem: {
|
|
4033
|
+
const activeItem = getActiveItem(internalRef.current);
|
|
4034
|
+
if (activeItem) activeItem.dispatchEvent(new Event("menu-select"));
|
|
4035
|
+
break;
|
|
4036
|
+
}
|
|
4037
|
+
case KEY_MAPPING.next: {
|
|
4038
|
+
let nextItem;
|
|
4039
|
+
if (e.shiftKey) {
|
|
4040
|
+
const nextGroup = getNextGroup("next");
|
|
4041
|
+
if (!nextGroup) return;
|
|
4042
|
+
nextItem = getFirstItem(nextGroup);
|
|
4043
|
+
} else {
|
|
4044
|
+
nextItem = getNextItem(internalRef.current, "next");
|
|
4045
|
+
}
|
|
4046
|
+
if (!nextItem) return;
|
|
4047
|
+
setActiveItemId(nextItem.getAttribute(ITEM_SELECTOR));
|
|
4048
|
+
break;
|
|
4049
|
+
}
|
|
4050
|
+
case KEY_MAPPING.prev: {
|
|
4051
|
+
let prevItem;
|
|
4052
|
+
if (e.shiftKey) {
|
|
4053
|
+
const prevGroup = getNextGroup("prev");
|
|
4054
|
+
if (!prevGroup) return;
|
|
4055
|
+
prevItem = getFirstItem(prevGroup);
|
|
4056
|
+
} else {
|
|
4057
|
+
prevItem = getNextItem(internalRef.current, "prev");
|
|
4058
|
+
}
|
|
4059
|
+
if (!prevItem) return;
|
|
4060
|
+
setActiveItemId(prevItem.getAttribute(ITEM_SELECTOR));
|
|
4061
|
+
break;
|
|
4062
|
+
}
|
|
4063
|
+
case KEY_MAPPING.first: {
|
|
4064
|
+
let firstItem;
|
|
4065
|
+
if (e.shiftKey) {
|
|
4066
|
+
const firstGroup = getFirstGroup();
|
|
4067
|
+
if (!firstGroup) return;
|
|
4068
|
+
firstItem = getFirstItem(firstGroup);
|
|
4069
|
+
} else {
|
|
4070
|
+
firstItem = getFirstItem(internalRef.current);
|
|
4071
|
+
}
|
|
4072
|
+
if (!firstItem) return;
|
|
4073
|
+
setActiveItemId(firstItem.getAttribute(ITEM_SELECTOR));
|
|
4074
|
+
break;
|
|
4075
|
+
}
|
|
4076
|
+
case KEY_MAPPING.last: {
|
|
4077
|
+
let lastItem;
|
|
4078
|
+
if (e.shiftKey) {
|
|
4079
|
+
const lastGroup = getLastGroup();
|
|
4080
|
+
if (!lastGroup) return;
|
|
4081
|
+
lastItem = getFirstItem(lastGroup);
|
|
4082
|
+
} else {
|
|
4083
|
+
lastItem = getLastItem(internalRef.current);
|
|
4084
|
+
}
|
|
4085
|
+
if (!lastItem) return;
|
|
4086
|
+
setActiveItemId(lastItem.getAttribute(ITEM_SELECTOR));
|
|
4087
|
+
break;
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
4090
|
+
},
|
|
4091
|
+
[getActiveItem, getFirstGroup, getFirstItem, getLastGroup, getLastItem, getNextGroup, getNextItem, onKeyDown]
|
|
4092
|
+
);
|
|
4093
|
+
react.useEffect(() => {
|
|
4094
|
+
var _a;
|
|
4095
|
+
const firstItem = getFirstItem(internalRef.current);
|
|
4096
|
+
if (!firstItem) return;
|
|
4097
|
+
(_a = internalRef.current) == null ? void 0 : _a.focus();
|
|
4098
|
+
setActiveItemId(firstItem.getAttribute(ITEM_SELECTOR));
|
|
4099
|
+
}, [getFirstItem]);
|
|
4100
|
+
const contextValue = react.useMemo(
|
|
4101
|
+
() => ({
|
|
4102
|
+
activeItemId,
|
|
4103
|
+
setActiveItemId,
|
|
4104
|
+
// style props
|
|
4105
|
+
accentColor,
|
|
4106
|
+
radius,
|
|
4107
|
+
variant,
|
|
4108
|
+
size
|
|
4109
|
+
}),
|
|
4110
|
+
[accentColor, activeItemId, radius, size, variant]
|
|
4111
|
+
);
|
|
3638
4112
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3639
4113
|
"div",
|
|
3640
4114
|
{
|
|
3641
|
-
ref,
|
|
3642
|
-
className: classVarianceAuthority.cx(
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
4115
|
+
ref: mergeRefs([ref, internalRef]),
|
|
4116
|
+
className: classVarianceAuthority.cx(menuRootCva({ size }), radiusCva({ radius, maxLarge: true }), className),
|
|
4117
|
+
role: "menu",
|
|
4118
|
+
onKeyDown: handleKeyDown,
|
|
4119
|
+
tabIndex: 0,
|
|
4120
|
+
"aria-activedescendant": activeItemId ?? void 0,
|
|
4121
|
+
"data-accent-color": accentColor,
|
|
4122
|
+
...rest,
|
|
4123
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MenuRootContext, { value: contextValue, children })
|
|
3647
4124
|
}
|
|
3648
4125
|
);
|
|
3649
4126
|
});
|
|
3650
|
-
|
|
3651
|
-
const
|
|
3652
|
-
const { ref, children,
|
|
3653
|
-
|
|
3654
|
-
const selectedState = allSelected ? true : someSelected ? "indeterminate" : false;
|
|
3655
|
-
const handleSelect = React.useCallback(() => {
|
|
3656
|
-
onSelect == null ? void 0 : onSelect();
|
|
3657
|
-
toggleSelectAll();
|
|
3658
|
-
}, [onSelect, toggleSelectAll]);
|
|
3659
|
-
const computedChildren = React.useMemo(() => {
|
|
3660
|
-
return typeof children === "function" ? ({ active }) => children({ selected: selectedState, active }) : children;
|
|
3661
|
-
}, [children, selectedState]);
|
|
3662
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicatorContext, { value: selectedState, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3663
|
-
MenuItem,
|
|
3664
|
-
{
|
|
3665
|
-
onSelect: handleSelect,
|
|
3666
|
-
ref,
|
|
3667
|
-
"data-state": getCheckedState(selectedState),
|
|
3668
|
-
closeOnSelect,
|
|
3669
|
-
...rest,
|
|
3670
|
-
children: computedChildren
|
|
3671
|
-
}
|
|
3672
|
-
) });
|
|
4127
|
+
MenuV2Root.displayName = "MenuRoot";
|
|
4128
|
+
const MenuV2SelectedIndicator = react.memo((props) => {
|
|
4129
|
+
const { ref, children, ...rest } = props;
|
|
4130
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicator, { ref, ...rest, children });
|
|
3673
4131
|
});
|
|
3674
|
-
|
|
4132
|
+
MenuV2SelectedIndicator.displayName = "MenuCheckboxItemIndicator";
|
|
4133
|
+
const MenuV2SelectGroup = genericMemo(function MenuSelectGroup2(props) {
|
|
3675
4134
|
const { ref, children, required, defaultValue, value, onValueChange, ...rest } = props;
|
|
3676
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4135
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MenuV2Group, { ref, ...rest, children: required ? /* @__PURE__ */ jsxRuntime.jsx(SingleSelectRequiredProvider, { defaultValue, value, onValueChange, children }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3677
4136
|
SingleSelectNotRequiredProvider,
|
|
3678
4137
|
{
|
|
3679
4138
|
defaultValue,
|
|
@@ -3683,189 +4142,59 @@
|
|
|
3683
4142
|
}
|
|
3684
4143
|
) });
|
|
3685
4144
|
});
|
|
3686
|
-
const
|
|
3687
|
-
const { ref, value, onSelect, children,
|
|
3688
|
-
const { selected, selectValue } =
|
|
3689
|
-
const isSelected =
|
|
3690
|
-
const handleSelect =
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
4145
|
+
const MenuV2SelectItem = genericMemo(function(props) {
|
|
4146
|
+
const { ref, value, onSelect, children, ...rest } = props;
|
|
4147
|
+
const { selected, selectValue } = react.use(SelectContext);
|
|
4148
|
+
const isSelected = selected(value);
|
|
4149
|
+
const handleSelect = react.useCallback(
|
|
4150
|
+
(e) => {
|
|
4151
|
+
onSelect == null ? void 0 : onSelect(e);
|
|
4152
|
+
if (e.defaultPrevented) return;
|
|
4153
|
+
selectValue(value);
|
|
4154
|
+
},
|
|
4155
|
+
[onSelect, selectValue, value]
|
|
4156
|
+
);
|
|
4157
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4158
|
+
MenuV2Item,
|
|
3699
4159
|
{
|
|
3700
4160
|
ref,
|
|
3701
4161
|
role: "menuitemcheckbox",
|
|
3702
4162
|
onSelect: handleSelect,
|
|
3703
|
-
closeOnSelect,
|
|
3704
4163
|
"data-state": getSelectedState(isSelected),
|
|
3705
4164
|
...rest,
|
|
3706
|
-
children:
|
|
3707
|
-
}
|
|
3708
|
-
) });
|
|
3709
|
-
});
|
|
3710
|
-
const MenuSeparator = React.memo((props) => {
|
|
3711
|
-
const { ref, className, ...rest } = props;
|
|
3712
|
-
const { size } = useMenuContentContext();
|
|
3713
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RadixSeparator__namespace.Root, { className: classVarianceAuthority.cx(menuSeparator({ size }), className), ref, ...rest });
|
|
3714
|
-
});
|
|
3715
|
-
MenuSeparator.displayName = "MenuSeparator";
|
|
3716
|
-
const MenuSubContent = React.memo((props) => {
|
|
3717
|
-
var _a;
|
|
3718
|
-
const { ref: forwardedRef, children, ...rest } = props;
|
|
3719
|
-
const { middlewareData } = useMenuContext();
|
|
3720
|
-
const { accentColor, radius, variant, size } = useMenuContentContext();
|
|
3721
|
-
const {
|
|
3722
|
-
open,
|
|
3723
|
-
nodeId,
|
|
3724
|
-
refs,
|
|
3725
|
-
context,
|
|
3726
|
-
getFloatingProps,
|
|
3727
|
-
getItemProps,
|
|
3728
|
-
activeIndex,
|
|
3729
|
-
setActiveIndex,
|
|
3730
|
-
elementsRef,
|
|
3731
|
-
floatingStyles,
|
|
3732
|
-
setOpen,
|
|
3733
|
-
side
|
|
3734
|
-
} = useSubContext();
|
|
3735
|
-
const wrapperRef = React.useRef(null);
|
|
3736
|
-
const mergeRefs2 = react.useMergeRefs([refs.setFloating, wrapperRef]);
|
|
3737
|
-
const computedFloatingStyles = React.useMemo(() => {
|
|
3738
|
-
var _a2;
|
|
3739
|
-
return {
|
|
3740
|
-
...floatingStyles,
|
|
3741
|
-
visibility: ((_a2 = middlewareData.hide) == null ? void 0 : _a2.referenceHidden) ? "hidden" : "visible"
|
|
3742
|
-
};
|
|
3743
|
-
}, [floatingStyles, (_a = middlewareData.hide) == null ? void 0 : _a.referenceHidden]);
|
|
3744
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.FloatingNode, { id: nodeId, children: open && /* @__PURE__ */ jsxRuntime.jsx(react.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(react.FloatingFocusManager, { context, initialFocus: wrapperRef, children: /* @__PURE__ */ jsxRuntime.jsx(react.FloatingList, { elementsRef, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3745
|
-
MenuContentContext.Provider,
|
|
3746
|
-
{
|
|
3747
|
-
value: {
|
|
3748
|
-
getItemProps,
|
|
3749
|
-
activeIndex,
|
|
3750
|
-
setActiveIndex,
|
|
3751
|
-
elementsRef,
|
|
3752
|
-
open,
|
|
3753
|
-
setOpen,
|
|
3754
|
-
refs,
|
|
3755
|
-
size,
|
|
3756
|
-
radius,
|
|
3757
|
-
accentColor,
|
|
3758
|
-
variant
|
|
3759
|
-
},
|
|
3760
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3761
|
-
"div",
|
|
3762
|
-
{
|
|
3763
|
-
className: "outline-none",
|
|
3764
|
-
ref: mergeRefs2,
|
|
3765
|
-
style: computedFloatingStyles,
|
|
3766
|
-
...getFloatingProps(),
|
|
3767
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3768
|
-
"ul",
|
|
3769
|
-
{
|
|
3770
|
-
className: classVarianceAuthority.cx(
|
|
3771
|
-
"overmap-menu-sub-content",
|
|
3772
|
-
menuContent({ size }),
|
|
3773
|
-
floating({ side, shadow: "3" }),
|
|
3774
|
-
radiusCva({ radius, maxLarge: true }),
|
|
3775
|
-
"max-h-(--overmap-menu-available-height)"
|
|
3776
|
-
),
|
|
3777
|
-
ref: forwardedRef,
|
|
3778
|
-
"data-state": getOpenState(open),
|
|
3779
|
-
"data-side": side,
|
|
3780
|
-
"data-accent-color": accentColor,
|
|
3781
|
-
...rest,
|
|
3782
|
-
children
|
|
3783
|
-
}
|
|
3784
|
-
)
|
|
3785
|
-
}
|
|
3786
|
-
)
|
|
3787
|
-
}
|
|
3788
|
-
) }) }) }) });
|
|
3789
|
-
});
|
|
3790
|
-
MenuSubContent.displayName = "MenuSubContent";
|
|
3791
|
-
const MenuSubTrigger = React.memo((props) => {
|
|
3792
|
-
const { ref: forwardedRef, children, ...rest } = props;
|
|
3793
|
-
const { refs, getReferenceProps, open, disabled } = useSubContext();
|
|
3794
|
-
const mergedRefs = react.useMergeRefs([forwardedRef, refs.setReference]);
|
|
3795
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3796
|
-
MenuItem,
|
|
3797
|
-
{
|
|
3798
|
-
ref: mergedRefs,
|
|
3799
|
-
closeOnSelect: false,
|
|
3800
|
-
"aria-haspopup": "menu",
|
|
3801
|
-
"data-state": getOpenState(open),
|
|
3802
|
-
disabled,
|
|
3803
|
-
...getReferenceProps(rest),
|
|
3804
|
-
children
|
|
4165
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext, { value: isSelected, children })
|
|
3805
4166
|
}
|
|
3806
4167
|
);
|
|
3807
4168
|
});
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
const {
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
Sub: MenuSub,
|
|
3832
|
-
SubContent: MenuSubContent,
|
|
3833
|
-
SubTrigger: MenuSubTrigger,
|
|
3834
|
-
// pages
|
|
3835
|
-
Pages: MenuPages,
|
|
3836
|
-
PageContent: MenuPageContent,
|
|
3837
|
-
PageTrigger: MenuPageTrigger,
|
|
3838
|
-
// triggers
|
|
3839
|
-
ClickTrigger: MenuClickTrigger,
|
|
3840
|
-
ContextTrigger: MenuContextTrigger,
|
|
3841
|
-
VirtualTrigger: MenuVirtualTrigger,
|
|
3842
|
-
// groups
|
|
3843
|
-
Group: MenuGroup,
|
|
3844
|
-
SelectGroup: MenuSelectGroup,
|
|
3845
|
-
MultiSelectGroup: MenuMultiSelectGroup,
|
|
3846
|
-
// items
|
|
3847
|
-
Item: MenuItem,
|
|
3848
|
-
SelectItem: MenuSelectItem,
|
|
3849
|
-
MultiSelectItem: MenuMultiSelectItem,
|
|
3850
|
-
SelectAllItem: MenuSelectAllItem,
|
|
3851
|
-
CheckboxItem: MenuCheckboxItem,
|
|
3852
|
-
// indicators
|
|
3853
|
-
SelectedIndicator: MenuSelectedIndicator,
|
|
3854
|
-
CheckboxItemIndicator: MenuCheckboxItemIndicator,
|
|
3855
|
-
// input
|
|
3856
|
-
InputRoot: MenuInputRoot,
|
|
3857
|
-
InputField: MenuInputField,
|
|
3858
|
-
InputSlot: MenuInputSlot,
|
|
3859
|
-
// others
|
|
3860
|
-
Label: MenuLabel,
|
|
3861
|
-
Separator: MenuSeparator,
|
|
3862
|
-
Scroll: MenuScroll
|
|
4169
|
+
const MenuV2Separator = react.memo((props) => {
|
|
4170
|
+
const { ref, className, ...rest } = props;
|
|
4171
|
+
const { size } = react.use(MenuRootContext);
|
|
4172
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RadixSeparator__namespace.Root, { className: classVarianceAuthority.cx(menuSeparatorCva({ size }), className), ref, ...rest });
|
|
4173
|
+
});
|
|
4174
|
+
MenuV2Separator.displayName = "MenuSeparator";
|
|
4175
|
+
const MenuV2 = {
|
|
4176
|
+
Root: MenuV2Root,
|
|
4177
|
+
Group: MenuV2Group,
|
|
4178
|
+
GroupLabel: MenuV2GroupLabel,
|
|
4179
|
+
Item: MenuV2Item,
|
|
4180
|
+
Separator: MenuV2Separator,
|
|
4181
|
+
SelectGroup: MenuV2SelectGroup,
|
|
4182
|
+
SelectItem: MenuV2SelectItem,
|
|
4183
|
+
MultiSelectGroup: MenuV2MultiSelectGroup,
|
|
4184
|
+
MultiSelectItem: MenuV2MultiSelectItem,
|
|
4185
|
+
SelectAllItem: MenuV2SelectAllItem,
|
|
4186
|
+
SelectedIndicator: MenuV2SelectedIndicator,
|
|
4187
|
+
CheckboxItem: MenuV2CheckboxItem,
|
|
4188
|
+
CheckedIndicator: MenuV2CheckedIndicator,
|
|
4189
|
+
Pages: MenuV2Pages,
|
|
4190
|
+
Page: MenuV2Page,
|
|
4191
|
+
PageTriggerItem: MenuV2PageTriggerItem
|
|
3863
4192
|
};
|
|
3864
|
-
const OneTimePasswordFieldHiddenInput =
|
|
4193
|
+
const OneTimePasswordFieldHiddenInput = react.memo((props) => {
|
|
3865
4194
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixOneTimePasswordField__namespace.HiddenInput, { ...props });
|
|
3866
4195
|
});
|
|
3867
4196
|
OneTimePasswordFieldHiddenInput.displayName = "OneTimePasswordFieldHiddenInput";
|
|
3868
|
-
const OneTimePasswordFieldContext =
|
|
4197
|
+
const OneTimePasswordFieldContext = react.createContext({});
|
|
3869
4198
|
const onetimePasswordFieldInput = classVarianceAuthority.cva(
|
|
3870
4199
|
[
|
|
3871
4200
|
"flex",
|
|
@@ -3922,9 +4251,9 @@
|
|
|
3922
4251
|
}
|
|
3923
4252
|
}
|
|
3924
4253
|
);
|
|
3925
|
-
const OneTimePasswordFieldInput =
|
|
4254
|
+
const OneTimePasswordFieldInput = react.memo((props) => {
|
|
3926
4255
|
const { ref, className, ...rest } = props;
|
|
3927
|
-
const { variant, size, radius, accentColor } =
|
|
4256
|
+
const { variant, size, radius, accentColor } = react.use(OneTimePasswordFieldContext);
|
|
3928
4257
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3929
4258
|
RadixOneTimePasswordField__namespace.Input,
|
|
3930
4259
|
{
|
|
@@ -3940,7 +4269,7 @@
|
|
|
3940
4269
|
);
|
|
3941
4270
|
});
|
|
3942
4271
|
OneTimePasswordFieldInput.displayName = "OneTimePasswordFieldInput";
|
|
3943
|
-
const OneTimePasswordFieldRoot =
|
|
4272
|
+
const OneTimePasswordFieldRoot = react.memo((props) => {
|
|
3944
4273
|
const providerContext = useProvider();
|
|
3945
4274
|
const {
|
|
3946
4275
|
ref,
|
|
@@ -3951,7 +4280,7 @@
|
|
|
3951
4280
|
accentColor = providerContext.accentColor,
|
|
3952
4281
|
...rest
|
|
3953
4282
|
} = props;
|
|
3954
|
-
const contextValue =
|
|
4283
|
+
const contextValue = react.useMemo(() => ({ variant, size, radius, accentColor }), [accentColor, radius, size, variant]);
|
|
3955
4284
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixOneTimePasswordField__namespace.Root, { ref, "data-accent-color": accentColor, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(OneTimePasswordFieldContext, { value: contextValue, children }) });
|
|
3956
4285
|
});
|
|
3957
4286
|
OneTimePasswordFieldRoot.displayName = "OneTimePasswordFieldRoot";
|
|
@@ -3960,7 +4289,7 @@
|
|
|
3960
4289
|
Input: OneTimePasswordFieldInput,
|
|
3961
4290
|
Root: OneTimePasswordFieldRoot
|
|
3962
4291
|
};
|
|
3963
|
-
const OverlayClose =
|
|
4292
|
+
const OverlayClose = react.memo((props) => {
|
|
3964
4293
|
const { ref, ...rest } = props;
|
|
3965
4294
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Close, { ref, ...rest });
|
|
3966
4295
|
});
|
|
@@ -3976,7 +4305,7 @@
|
|
|
3976
4305
|
"data-[state='open']:fade-in-0",
|
|
3977
4306
|
"data-[state='open']:zoom-in-95"
|
|
3978
4307
|
]);
|
|
3979
|
-
const OverlayContent =
|
|
4308
|
+
const OverlayContent = react.memo((props) => {
|
|
3980
4309
|
const { ref, container, className, ...rest } = props;
|
|
3981
4310
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Portal, { container, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3982
4311
|
RadixDialog__namespace.Content,
|
|
@@ -3989,21 +4318,21 @@
|
|
|
3989
4318
|
) });
|
|
3990
4319
|
});
|
|
3991
4320
|
OverlayContent.displayName = "OverlayContent";
|
|
3992
|
-
const OverlayDescription =
|
|
4321
|
+
const OverlayDescription = react.memo((props) => {
|
|
3993
4322
|
const { ref, ...rest } = props;
|
|
3994
4323
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Description, { ref, ...rest });
|
|
3995
4324
|
});
|
|
3996
4325
|
OverlayDescription.displayName = "OverlayDescription";
|
|
3997
|
-
const OverlayRoot =
|
|
4326
|
+
const OverlayRoot = react.memo((props) => {
|
|
3998
4327
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Root, { ...props });
|
|
3999
4328
|
});
|
|
4000
4329
|
OverlayRoot.displayName = "OverlayRoot";
|
|
4001
|
-
const OverlayTitle =
|
|
4330
|
+
const OverlayTitle = react.memo((props) => {
|
|
4002
4331
|
const { ref, ...rest } = props;
|
|
4003
4332
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Title, { ref, ...rest });
|
|
4004
4333
|
});
|
|
4005
4334
|
OverlayTitle.displayName = "OverlayTitle";
|
|
4006
|
-
const OverlayTrigger =
|
|
4335
|
+
const OverlayTrigger = react.memo((props) => {
|
|
4007
4336
|
const { ref, ...rest } = props;
|
|
4008
4337
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Trigger, { ref, ...rest });
|
|
4009
4338
|
});
|
|
@@ -4017,12 +4346,12 @@
|
|
|
4017
4346
|
Close: OverlayClose
|
|
4018
4347
|
};
|
|
4019
4348
|
const centerStyles = { placeSelf: "center" };
|
|
4020
|
-
const ErrorFallback =
|
|
4349
|
+
const ErrorFallback = react.memo((props) => {
|
|
4021
4350
|
const { absoluteCentering, message = "Something went wrong", onRetry } = props;
|
|
4022
4351
|
const { resetBoundary } = reactErrorBoundary.useErrorBoundary();
|
|
4023
4352
|
const height = "20px";
|
|
4024
4353
|
const outerFlexStyles = absoluteCentering ? { position: "absolute", top: "50%", transform: "translateY(-50%)" } : void 0;
|
|
4025
|
-
const handleRetry =
|
|
4354
|
+
const handleRetry = react.useCallback(() => {
|
|
4026
4355
|
resetBoundary();
|
|
4027
4356
|
onRetry();
|
|
4028
4357
|
}, [onRetry, resetBoundary]);
|
|
@@ -4035,14 +4364,14 @@
|
|
|
4035
4364
|
] });
|
|
4036
4365
|
});
|
|
4037
4366
|
ErrorFallback.displayName = "ErrorFallback";
|
|
4038
|
-
const OvermapErrorBoundary =
|
|
4367
|
+
const OvermapErrorBoundary = react.memo((props) => {
|
|
4039
4368
|
const { absoluteCentering, message } = props;
|
|
4040
|
-
const [attempt, setAttempt] =
|
|
4041
|
-
const logError =
|
|
4369
|
+
const [attempt, setAttempt] = react.useState(0);
|
|
4370
|
+
const logError = react.useCallback((error, info) => {
|
|
4042
4371
|
console.error("Error in OvermapErrorBoundary:", error, info);
|
|
4043
4372
|
setAttempt((prev) => prev + 1);
|
|
4044
4373
|
}, []);
|
|
4045
|
-
const handleRetry =
|
|
4374
|
+
const handleRetry = react.useCallback(() => {
|
|
4046
4375
|
setAttempt((prev) => prev + 1);
|
|
4047
4376
|
}, []);
|
|
4048
4377
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4056,7 +4385,96 @@
|
|
|
4056
4385
|
);
|
|
4057
4386
|
});
|
|
4058
4387
|
OvermapErrorBoundary.displayName = "OvermapErrorBoundary";
|
|
4059
|
-
const
|
|
4388
|
+
const PhoneNumberInputContext = react.createContext({});
|
|
4389
|
+
const FlagComponent = react.memo((props) => {
|
|
4390
|
+
const { country } = props;
|
|
4391
|
+
return country ? country : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PhoneIcon, { size: 16 });
|
|
4392
|
+
});
|
|
4393
|
+
FlagComponent.displayName = "FlagComponent";
|
|
4394
|
+
const CountrySelect = react.memo((props) => {
|
|
4395
|
+
const { disabled, value, onChange, options } = props;
|
|
4396
|
+
const { radius, size, variant, accentColor } = react.use(PhoneNumberInputContext);
|
|
4397
|
+
const handleSelect = react.useCallback(
|
|
4398
|
+
(e) => {
|
|
4399
|
+
onChange(e.target.value);
|
|
4400
|
+
},
|
|
4401
|
+
[onChange]
|
|
4402
|
+
);
|
|
4403
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4404
|
+
Button,
|
|
4405
|
+
{
|
|
4406
|
+
className: "relative",
|
|
4407
|
+
accentColor,
|
|
4408
|
+
radius,
|
|
4409
|
+
size,
|
|
4410
|
+
variant,
|
|
4411
|
+
disabled,
|
|
4412
|
+
children: [
|
|
4413
|
+
/* @__PURE__ */ jsxRuntime.jsx(FlagComponent, { country: value, countryName: value, "aria-hidden": "true" }),
|
|
4414
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { size: 16, "aria-hidden": "true" }),
|
|
4415
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4416
|
+
"select",
|
|
4417
|
+
{
|
|
4418
|
+
disabled,
|
|
4419
|
+
value,
|
|
4420
|
+
onChange: handleSelect,
|
|
4421
|
+
className: "absolute inset-0 text-sm opacity-0",
|
|
4422
|
+
"aria-label": "Select country",
|
|
4423
|
+
children: [
|
|
4424
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select a country" }, "default"),
|
|
4425
|
+
options.filter((x) => x.value).map((option, i) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: option.value, children: [
|
|
4426
|
+
option.label,
|
|
4427
|
+
" ",
|
|
4428
|
+
option.value && `+${min.getCountryCallingCode(option.value)}`
|
|
4429
|
+
] }, option.value ?? `empty-${i}`))
|
|
4430
|
+
]
|
|
4431
|
+
}
|
|
4432
|
+
)
|
|
4433
|
+
]
|
|
4434
|
+
}
|
|
4435
|
+
);
|
|
4436
|
+
});
|
|
4437
|
+
CountrySelect.displayName = "CountrySelect";
|
|
4438
|
+
const InputComponent = react.memo((props) => {
|
|
4439
|
+
const { accentColor, radius, size, variant } = react.use(PhoneNumberInputContext);
|
|
4440
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Input.Root, { variant, size, radius, accentColor, children: /* @__PURE__ */ jsxRuntime.jsx(Input.Field, { ...props }) });
|
|
4441
|
+
});
|
|
4442
|
+
InputComponent.displayName = "InputComponent";
|
|
4443
|
+
const PhoneNumberInput = react.memo((props) => {
|
|
4444
|
+
const providerContext = useProvider();
|
|
4445
|
+
const {
|
|
4446
|
+
ref,
|
|
4447
|
+
className,
|
|
4448
|
+
size = "md",
|
|
4449
|
+
variant = "outline",
|
|
4450
|
+
radius = providerContext.radius,
|
|
4451
|
+
accentColor = providerContext.accentColor,
|
|
4452
|
+
...rest
|
|
4453
|
+
} = props;
|
|
4454
|
+
const contextValue = react.useMemo(
|
|
4455
|
+
() => ({
|
|
4456
|
+
size,
|
|
4457
|
+
variant,
|
|
4458
|
+
radius,
|
|
4459
|
+
accentColor
|
|
4460
|
+
}),
|
|
4461
|
+
[accentColor, radius, size, variant]
|
|
4462
|
+
);
|
|
4463
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PhoneNumberInputContext, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4464
|
+
PhoneInput,
|
|
4465
|
+
{
|
|
4466
|
+
ref,
|
|
4467
|
+
className: classVarianceAuthority.cx(className, "flex gap-1"),
|
|
4468
|
+
flagComponent: FlagComponent,
|
|
4469
|
+
countrySelectComponent: CountrySelect,
|
|
4470
|
+
inputComponent: InputComponent,
|
|
4471
|
+
"data-accent-color": accentColor,
|
|
4472
|
+
...rest
|
|
4473
|
+
}
|
|
4474
|
+
) });
|
|
4475
|
+
});
|
|
4476
|
+
PhoneNumberInput.displayName = "PhoneNumberInput";
|
|
4477
|
+
const PopoverArrow = react.memo((props) => {
|
|
4060
4478
|
const { ref, children, className, ...rest } = props;
|
|
4061
4479
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixPopover__namespace.Arrow, { className: classVarianceAuthority.cx("fill-(--base-6)", className), ref, ...rest, children });
|
|
4062
4480
|
});
|
|
@@ -4075,7 +4493,7 @@
|
|
|
4075
4493
|
size: "md"
|
|
4076
4494
|
}
|
|
4077
4495
|
});
|
|
4078
|
-
const PopoverContent =
|
|
4496
|
+
const PopoverContent = react.memo((props) => {
|
|
4079
4497
|
const providerContext = useProvider();
|
|
4080
4498
|
const {
|
|
4081
4499
|
ref,
|
|
@@ -4150,7 +4568,7 @@
|
|
|
4150
4568
|
}
|
|
4151
4569
|
}
|
|
4152
4570
|
);
|
|
4153
|
-
const Progress =
|
|
4571
|
+
const Progress = react.memo((props) => {
|
|
4154
4572
|
const providerContext = useProvider();
|
|
4155
4573
|
const {
|
|
4156
4574
|
ref,
|
|
@@ -4162,7 +4580,7 @@
|
|
|
4162
4580
|
accentColor = providerContext.accentColor,
|
|
4163
4581
|
...rest
|
|
4164
4582
|
} = props;
|
|
4165
|
-
const computedStyle =
|
|
4583
|
+
const computedStyle = react.useMemo(
|
|
4166
4584
|
() => ({
|
|
4167
4585
|
...style,
|
|
4168
4586
|
"--progress-value": rest.value ?? 0,
|
|
@@ -4183,7 +4601,7 @@
|
|
|
4183
4601
|
);
|
|
4184
4602
|
});
|
|
4185
4603
|
Progress.displayName = "Progress";
|
|
4186
|
-
const RadioCardsContext =
|
|
4604
|
+
const RadioCardsContext = react.createContext({});
|
|
4187
4605
|
const radioCardsRootCva = classVarianceAuthority.cva([], {
|
|
4188
4606
|
variants: {
|
|
4189
4607
|
size: {
|
|
@@ -4243,8 +4661,8 @@
|
|
|
4243
4661
|
}
|
|
4244
4662
|
}
|
|
4245
4663
|
);
|
|
4246
|
-
const RadioCardsItem =
|
|
4247
|
-
const { variant, size, radius } =
|
|
4664
|
+
const RadioCardsItem = react.memo((props) => {
|
|
4665
|
+
const { variant, size, radius } = react.use(RadioCardsContext);
|
|
4248
4666
|
const { className, accentColor, ...rest } = props;
|
|
4249
4667
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4250
4668
|
RadixRadioGroup__namespace.Item,
|
|
@@ -4256,7 +4674,7 @@
|
|
|
4256
4674
|
);
|
|
4257
4675
|
});
|
|
4258
4676
|
RadioCardsItem.displayName = "RadioCardsItem";
|
|
4259
|
-
const RadioCardsRoot =
|
|
4677
|
+
const RadioCardsRoot = react.memo((props) => {
|
|
4260
4678
|
const providerContext = useProvider();
|
|
4261
4679
|
const {
|
|
4262
4680
|
className,
|
|
@@ -4267,7 +4685,7 @@
|
|
|
4267
4685
|
accentColor = providerContext.accentColor,
|
|
4268
4686
|
...rest
|
|
4269
4687
|
} = props;
|
|
4270
|
-
const contextValue =
|
|
4688
|
+
const contextValue = react.useMemo(
|
|
4271
4689
|
() => ({
|
|
4272
4690
|
variant,
|
|
4273
4691
|
size,
|
|
@@ -4290,7 +4708,7 @@
|
|
|
4290
4708
|
Root: RadioCardsRoot,
|
|
4291
4709
|
Item: RadioCardsItem
|
|
4292
4710
|
};
|
|
4293
|
-
const RadioGroupIndicator =
|
|
4711
|
+
const RadioGroupIndicator = react.memo((props) => {
|
|
4294
4712
|
const { ref, children, className, ...rest } = props;
|
|
4295
4713
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4296
4714
|
RadixRadioGroup__namespace.Indicator,
|
|
@@ -4303,7 +4721,7 @@
|
|
|
4303
4721
|
);
|
|
4304
4722
|
});
|
|
4305
4723
|
RadioGroupIndicator.displayName = "RadioGroupIndicator";
|
|
4306
|
-
const RadioGroupContext =
|
|
4724
|
+
const RadioGroupContext = react.createContext({});
|
|
4307
4725
|
const radioGroupItem = classVarianceAuthority.cva(
|
|
4308
4726
|
[
|
|
4309
4727
|
"inline-flex",
|
|
@@ -4347,8 +4765,8 @@
|
|
|
4347
4765
|
}
|
|
4348
4766
|
}
|
|
4349
4767
|
);
|
|
4350
|
-
const RadioGroupItem =
|
|
4351
|
-
const radioGroupContext =
|
|
4768
|
+
const RadioGroupItem = react.memo((props) => {
|
|
4769
|
+
const radioGroupContext = react.useContext(RadioGroupContext);
|
|
4352
4770
|
const {
|
|
4353
4771
|
ref,
|
|
4354
4772
|
children,
|
|
@@ -4360,7 +4778,7 @@
|
|
|
4360
4778
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixRadioGroup__namespace.Item, { className: classVarianceAuthority.cx(radioGroupItem({ size, variant }), className), ref, ...rest, children });
|
|
4361
4779
|
});
|
|
4362
4780
|
RadioGroupItem.displayName = "RadioGroupItem";
|
|
4363
|
-
const RadioGroupRoot =
|
|
4781
|
+
const RadioGroupRoot = react.memo((props) => {
|
|
4364
4782
|
const providerContext = useProvider();
|
|
4365
4783
|
const {
|
|
4366
4784
|
ref,
|
|
@@ -4379,6 +4797,65 @@
|
|
|
4379
4797
|
Item: RadioGroupItem,
|
|
4380
4798
|
Root: RadioGroupRoot
|
|
4381
4799
|
};
|
|
4800
|
+
const RatingRootContext = react.createContext({});
|
|
4801
|
+
const RatingItemContext = react.createContext({});
|
|
4802
|
+
const RatingItem = react.memo((props) => {
|
|
4803
|
+
const { ref, children, value, ...rest } = props;
|
|
4804
|
+
const { value: activeValue } = react.use(RatingRootContext);
|
|
4805
|
+
const active = !!activeValue && value <= activeValue;
|
|
4806
|
+
const contextValue = react.useMemo(() => ({ value }), [value]);
|
|
4807
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RadixRadioGroup__namespace.Item, { ref, value: value.toString(), "data-active": active, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(RatingItemContext, { value: contextValue, children }) });
|
|
4808
|
+
});
|
|
4809
|
+
RatingItem.displayName = "RatingItem";
|
|
4810
|
+
const RatingItemIndicator = react.memo((props) => {
|
|
4811
|
+
const { ref, children, forceMount, ...rest } = props;
|
|
4812
|
+
const { value: activeValue } = react.use(RatingRootContext);
|
|
4813
|
+
const { value } = react.use(RatingItemContext);
|
|
4814
|
+
const active = !!activeValue && value <= activeValue;
|
|
4815
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4816
|
+
RadixRadioGroup__namespace.Indicator,
|
|
4817
|
+
{
|
|
4818
|
+
ref,
|
|
4819
|
+
forceMount: forceMount ?? (active || void 0),
|
|
4820
|
+
"data-active": active,
|
|
4821
|
+
...rest,
|
|
4822
|
+
children
|
|
4823
|
+
}
|
|
4824
|
+
);
|
|
4825
|
+
});
|
|
4826
|
+
RatingItemIndicator.displayName = "RatingItemIndicator";
|
|
4827
|
+
const RatingRoot = react.memo((props) => {
|
|
4828
|
+
const { ref, children, defaultValue, value: controlledValue, onValueChange, ...rest } = props;
|
|
4829
|
+
const [value, setValue] = useControlledState(defaultValue ?? null, controlledValue, onValueChange);
|
|
4830
|
+
const handleValueChange = react.useCallback(
|
|
4831
|
+
(value2) => {
|
|
4832
|
+
setValue(parseInt(value2));
|
|
4833
|
+
},
|
|
4834
|
+
[setValue]
|
|
4835
|
+
);
|
|
4836
|
+
const contextValue = react.useMemo(
|
|
4837
|
+
() => ({
|
|
4838
|
+
value
|
|
4839
|
+
}),
|
|
4840
|
+
[value]
|
|
4841
|
+
);
|
|
4842
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4843
|
+
RadixRadioGroup__namespace.Root,
|
|
4844
|
+
{
|
|
4845
|
+
ref,
|
|
4846
|
+
value: value ? value.toString() : null,
|
|
4847
|
+
onValueChange: handleValueChange,
|
|
4848
|
+
...rest,
|
|
4849
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RatingRootContext, { value: contextValue, children })
|
|
4850
|
+
}
|
|
4851
|
+
);
|
|
4852
|
+
});
|
|
4853
|
+
RatingRoot.displayName = "RatingRoot";
|
|
4854
|
+
const Rating = {
|
|
4855
|
+
Item: RatingItem,
|
|
4856
|
+
ItemIndicator: RatingItemIndicator,
|
|
4857
|
+
Root: RatingRoot
|
|
4858
|
+
};
|
|
4382
4859
|
const segmentedControlRootCva = classVarianceAuthority.cva(
|
|
4383
4860
|
["shrink-0", "transition-colors", "inline-flex", "box-border", "min-w-max", "text-center"],
|
|
4384
4861
|
{
|
|
@@ -4522,15 +4999,15 @@
|
|
|
4522
4999
|
}
|
|
4523
5000
|
}
|
|
4524
5001
|
);
|
|
4525
|
-
const SegmentedControlContext =
|
|
5002
|
+
const SegmentedControlContext = react.createContext({});
|
|
4526
5003
|
const useSegmentedControl = () => {
|
|
4527
|
-
const segmentedControlContext =
|
|
5004
|
+
const segmentedControlContext = react.useContext(SegmentedControlContext);
|
|
4528
5005
|
if (!segmentedControlContext) {
|
|
4529
5006
|
throw new Error("useSegmentedControl must be used within a SegmentedControlProvider");
|
|
4530
5007
|
}
|
|
4531
5008
|
return segmentedControlContext;
|
|
4532
5009
|
};
|
|
4533
|
-
const SegmentedControlItem =
|
|
5010
|
+
const SegmentedControlItem = react.memo((props) => {
|
|
4534
5011
|
const { ref, className, ...rest } = props;
|
|
4535
5012
|
const { size, radius, variant, icon } = useSegmentedControl();
|
|
4536
5013
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4543,7 +5020,7 @@
|
|
|
4543
5020
|
);
|
|
4544
5021
|
});
|
|
4545
5022
|
SegmentedControlItem.displayName = "SegmentedControlItem";
|
|
4546
|
-
const SegmentedControlRoot =
|
|
5023
|
+
const SegmentedControlRoot = react.memo((props) => {
|
|
4547
5024
|
const providerContext = useProvider();
|
|
4548
5025
|
const {
|
|
4549
5026
|
ref,
|
|
@@ -4577,7 +5054,7 @@
|
|
|
4577
5054
|
Item: SegmentedControlItem,
|
|
4578
5055
|
Root: SegmentedControlRoot
|
|
4579
5056
|
};
|
|
4580
|
-
const SegmentedTabsListContext =
|
|
5057
|
+
const SegmentedTabsListContext = react.createContext({});
|
|
4581
5058
|
const segmentedTabsListCva = classVarianceAuthority.cva(
|
|
4582
5059
|
["shrink-0", "transition-colors", "inline-flex", "box-border", "min-w-max", "text-center"],
|
|
4583
5060
|
{
|
|
@@ -4725,7 +5202,7 @@
|
|
|
4725
5202
|
}
|
|
4726
5203
|
}
|
|
4727
5204
|
);
|
|
4728
|
-
const SegmentedTabsList =
|
|
5205
|
+
const SegmentedTabsList = react.memo((props) => {
|
|
4729
5206
|
const providerContext = useProvider();
|
|
4730
5207
|
const {
|
|
4731
5208
|
ref,
|
|
@@ -4737,7 +5214,7 @@
|
|
|
4737
5214
|
accentColor = providerContext.accentColor,
|
|
4738
5215
|
...rest
|
|
4739
5216
|
} = props;
|
|
4740
|
-
const contextValue =
|
|
5217
|
+
const contextValue = react.useMemo(
|
|
4741
5218
|
() => ({
|
|
4742
5219
|
size,
|
|
4743
5220
|
variant,
|
|
@@ -4757,14 +5234,14 @@
|
|
|
4757
5234
|
);
|
|
4758
5235
|
});
|
|
4759
5236
|
SegmentedTabsList.displayName = "TabsList";
|
|
4760
|
-
const SegmentedTabsRoot =
|
|
5237
|
+
const SegmentedTabsRoot = react.memo((props) => {
|
|
4761
5238
|
const { ref, className, ...rest } = props;
|
|
4762
5239
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixTabs__namespace.Root, { ref, className: classVarianceAuthority.cx("flex flex-col", className), ...rest });
|
|
4763
5240
|
});
|
|
4764
5241
|
SegmentedTabsRoot.displayName = "TabsRoot";
|
|
4765
|
-
const SegmentedTabsTrigger =
|
|
5242
|
+
const SegmentedTabsTrigger = react.memo((props) => {
|
|
4766
5243
|
const { ref, children, className, ...rest } = props;
|
|
4767
|
-
const { size, radius, variant } =
|
|
5244
|
+
const { size, radius, variant } = react.use(SegmentedTabsListContext);
|
|
4768
5245
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4769
5246
|
RadixTabs__namespace.Trigger,
|
|
4770
5247
|
{
|
|
@@ -4864,7 +5341,7 @@
|
|
|
4864
5341
|
orientation: "horizontal"
|
|
4865
5342
|
}
|
|
4866
5343
|
});
|
|
4867
|
-
const Separator =
|
|
5344
|
+
const Separator = react.memo((props) => {
|
|
4868
5345
|
const { ref, className, accentColor = "base", orientation, size, ...rest } = props;
|
|
4869
5346
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4870
5347
|
RadixSeparator__namespace.Root,
|
|
@@ -5086,7 +5563,7 @@
|
|
|
5086
5563
|
}
|
|
5087
5564
|
}
|
|
5088
5565
|
);
|
|
5089
|
-
const Slider =
|
|
5566
|
+
const Slider = react.memo((props) => {
|
|
5090
5567
|
const providerContext = useProvider();
|
|
5091
5568
|
const {
|
|
5092
5569
|
className,
|
|
@@ -5124,11 +5601,11 @@
|
|
|
5124
5601
|
);
|
|
5125
5602
|
});
|
|
5126
5603
|
Slider.displayName = "Slider";
|
|
5127
|
-
const Spinner =
|
|
5604
|
+
const Spinner = react.memo(() => {
|
|
5128
5605
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-6 animate-spin rounded-full border-2 border-(--base-a12) border-b-transparent" });
|
|
5129
5606
|
});
|
|
5130
5607
|
Spinner.displayName = "Spinner";
|
|
5131
|
-
const SwitchContext =
|
|
5608
|
+
const SwitchContext = react.createContext({});
|
|
5132
5609
|
const switchRoot = classVarianceAuthority.cva(
|
|
5133
5610
|
[
|
|
5134
5611
|
"shrink-0",
|
|
@@ -5188,7 +5665,7 @@
|
|
|
5188
5665
|
}
|
|
5189
5666
|
}
|
|
5190
5667
|
);
|
|
5191
|
-
const SwitchRoot =
|
|
5668
|
+
const SwitchRoot = react.memo((props) => {
|
|
5192
5669
|
const providerContext = useProvider();
|
|
5193
5670
|
const {
|
|
5194
5671
|
ref,
|
|
@@ -5211,9 +5688,9 @@
|
|
|
5211
5688
|
);
|
|
5212
5689
|
});
|
|
5213
5690
|
SwitchRoot.displayName = "SwitchRoot";
|
|
5214
|
-
const SwitchThumb =
|
|
5691
|
+
const SwitchThumb = react.memo((props) => {
|
|
5215
5692
|
const { ref, className, ...rest } = props;
|
|
5216
|
-
const { size, radius } =
|
|
5693
|
+
const { size, radius } = react.useContext(SwitchContext);
|
|
5217
5694
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5218
5695
|
RadixSwitch__namespace.Thumb,
|
|
5219
5696
|
{
|
|
@@ -5228,12 +5705,12 @@
|
|
|
5228
5705
|
Root: SwitchRoot,
|
|
5229
5706
|
Thumb: SwitchThumb
|
|
5230
5707
|
};
|
|
5231
|
-
const TableBody =
|
|
5708
|
+
const TableBody = react.memo((props) => {
|
|
5232
5709
|
const { ref, className, ...rest } = props;
|
|
5233
5710
|
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { ref, className: classVarianceAuthority.cx(className), ...rest });
|
|
5234
5711
|
});
|
|
5235
5712
|
TableBody.displayName = "TableBody";
|
|
5236
|
-
const TableContext =
|
|
5713
|
+
const TableContext = react.createContext({});
|
|
5237
5714
|
const tableRootCva = classVarianceAuthority.cva(["border-collapse text-left"], {
|
|
5238
5715
|
variants: {
|
|
5239
5716
|
variant: {
|
|
@@ -5274,29 +5751,29 @@
|
|
|
5274
5751
|
}
|
|
5275
5752
|
}
|
|
5276
5753
|
});
|
|
5277
|
-
const TableCell =
|
|
5754
|
+
const TableCell = react.memo((props) => {
|
|
5278
5755
|
const { ref, className, ...rest } = props;
|
|
5279
|
-
const { size, border, variant } =
|
|
5756
|
+
const { size, border, variant } = react.useContext(TableContext);
|
|
5280
5757
|
return /* @__PURE__ */ jsxRuntime.jsx("td", { ref, className: classVarianceAuthority.cx(tableCellCva({ size, border, cell: true, variant }), className), ...rest });
|
|
5281
5758
|
});
|
|
5282
5759
|
TableCell.displayName = "TableCell";
|
|
5283
|
-
const TableColumnHeaderCell =
|
|
5760
|
+
const TableColumnHeaderCell = react.memo((props) => {
|
|
5284
5761
|
const { ref, className, ...rest } = props;
|
|
5285
|
-
const { size, border, variant } =
|
|
5762
|
+
const { size, border, variant } = react.useContext(TableContext);
|
|
5286
5763
|
return /* @__PURE__ */ jsxRuntime.jsx("th", { ref, className: classVarianceAuthority.cx(tableCellCva({ size, border, cell: false, variant }), className), ...rest });
|
|
5287
5764
|
});
|
|
5288
5765
|
TableColumnHeaderCell.displayName = "TableColumnHeaderCell";
|
|
5289
|
-
const TableFooter =
|
|
5766
|
+
const TableFooter = react.memo((props) => {
|
|
5290
5767
|
const { ref, className, ...rest } = props;
|
|
5291
5768
|
return /* @__PURE__ */ jsxRuntime.jsx("tfoot", { ref, className: classVarianceAuthority.cx(className), ...rest });
|
|
5292
5769
|
});
|
|
5293
5770
|
TableFooter.displayName = "TableFooter";
|
|
5294
|
-
const TableHeader =
|
|
5771
|
+
const TableHeader = react.memo((props) => {
|
|
5295
5772
|
const { ref, className, ...rest } = props;
|
|
5296
5773
|
return /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: classVarianceAuthority.cx(className), ...rest });
|
|
5297
5774
|
});
|
|
5298
5775
|
TableHeader.displayName = "TableHeader";
|
|
5299
|
-
const TableRoot =
|
|
5776
|
+
const TableRoot = react.memo((props) => {
|
|
5300
5777
|
const providerContext = useProvider();
|
|
5301
5778
|
const {
|
|
5302
5779
|
ref,
|
|
@@ -5324,14 +5801,14 @@
|
|
|
5324
5801
|
);
|
|
5325
5802
|
});
|
|
5326
5803
|
TableRoot.displayName = "TableRoot";
|
|
5327
|
-
const TableRow =
|
|
5804
|
+
const TableRow = react.memo((props) => {
|
|
5328
5805
|
const { ref, className, ...rest } = props;
|
|
5329
5806
|
return /* @__PURE__ */ jsxRuntime.jsx("tr", { ref, className: classVarianceAuthority.cx(className), ...rest });
|
|
5330
5807
|
});
|
|
5331
5808
|
TableRow.displayName = "TableRow";
|
|
5332
|
-
const TableRowHeaderCell =
|
|
5809
|
+
const TableRowHeaderCell = react.memo((props) => {
|
|
5333
5810
|
const { ref, className, ...rest } = props;
|
|
5334
|
-
const { size, border, variant } =
|
|
5811
|
+
const { size, border, variant } = react.useContext(TableContext);
|
|
5335
5812
|
return /* @__PURE__ */ jsxRuntime.jsx("th", { ref, className: classVarianceAuthority.cx(tableCellCva({ size, border, cell: true, variant }), className), ...rest });
|
|
5336
5813
|
});
|
|
5337
5814
|
TableRowHeaderCell.displayName = "TableRow";
|
|
@@ -5345,7 +5822,7 @@
|
|
|
5345
5822
|
RowHeaderCell: TableRowHeaderCell,
|
|
5346
5823
|
ColumnHeaderCell: TableColumnHeaderCell
|
|
5347
5824
|
};
|
|
5348
|
-
const TabsListContext =
|
|
5825
|
+
const TabsListContext = react.createContext({});
|
|
5349
5826
|
const tabsListCva = classVarianceAuthority.cva(["flex", "border-box", "inset-shadow-[0_-1px_0_0_var(--base-a6)]"], {
|
|
5350
5827
|
variants: {
|
|
5351
5828
|
size: {
|
|
@@ -5395,7 +5872,7 @@
|
|
|
5395
5872
|
}
|
|
5396
5873
|
}
|
|
5397
5874
|
);
|
|
5398
|
-
const TabsList =
|
|
5875
|
+
const TabsList = react.memo((props) => {
|
|
5399
5876
|
const providerContext = useProvider();
|
|
5400
5877
|
const { ref, children, className, size = "md", accentColor = providerContext.accentColor, ...rest } = props;
|
|
5401
5878
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5410,19 +5887,19 @@
|
|
|
5410
5887
|
);
|
|
5411
5888
|
});
|
|
5412
5889
|
TabsList.displayName = "TabsList";
|
|
5413
|
-
const TabsRoot =
|
|
5890
|
+
const TabsRoot = react.memo((props) => {
|
|
5414
5891
|
const { ref, className, ...rest } = props;
|
|
5415
5892
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixTabs__namespace.Root, { ref, className: classVarianceAuthority.cx("flex flex-col", className), ...rest });
|
|
5416
5893
|
});
|
|
5417
5894
|
TabsRoot.displayName = "TabsRoot";
|
|
5418
5895
|
const useTabsList = () => {
|
|
5419
|
-
const tabsListContext =
|
|
5896
|
+
const tabsListContext = react.useContext(TabsListContext);
|
|
5420
5897
|
if (!tabsListContext) {
|
|
5421
5898
|
throw new Error("useTabsList must be used within a TabsList component");
|
|
5422
5899
|
}
|
|
5423
5900
|
return tabsListContext;
|
|
5424
5901
|
};
|
|
5425
|
-
const TabsTrigger =
|
|
5902
|
+
const TabsTrigger = react.memo((props) => {
|
|
5426
5903
|
const { ref, children, className, ...rest } = props;
|
|
5427
5904
|
const { size } = useTabsList();
|
|
5428
5905
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixTabs__namespace.Trigger, { ref, className: classVarianceAuthority.cx(tabsTriggerCva({ size }), className), ...rest, children });
|
|
@@ -5464,7 +5941,7 @@
|
|
|
5464
5941
|
}
|
|
5465
5942
|
}
|
|
5466
5943
|
});
|
|
5467
|
-
const Text =
|
|
5944
|
+
const Text = react.memo((props) => {
|
|
5468
5945
|
const { ref, className, size, weight, align, accentColor, highContrast = false, ...rest } = props;
|
|
5469
5946
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5470
5947
|
"span",
|
|
@@ -5545,7 +6022,7 @@
|
|
|
5545
6022
|
}
|
|
5546
6023
|
}
|
|
5547
6024
|
);
|
|
5548
|
-
const TextArea =
|
|
6025
|
+
const TextArea = react.memo((props) => {
|
|
5549
6026
|
const providerContext = useProvider();
|
|
5550
6027
|
const {
|
|
5551
6028
|
ref,
|
|
@@ -5613,8 +6090,8 @@
|
|
|
5613
6090
|
action,
|
|
5614
6091
|
...rest
|
|
5615
6092
|
} = props;
|
|
5616
|
-
const [open, setOpen] =
|
|
5617
|
-
const handleOpenChange =
|
|
6093
|
+
const [open, setOpen] = react.useState(true);
|
|
6094
|
+
const handleOpenChange = react.useCallback(
|
|
5618
6095
|
(open2) => {
|
|
5619
6096
|
if (!open2 && onClose) onClose();
|
|
5620
6097
|
setOpen(open2);
|
|
@@ -5652,11 +6129,11 @@
|
|
|
5652
6129
|
}
|
|
5653
6130
|
);
|
|
5654
6131
|
};
|
|
5655
|
-
const Toast =
|
|
6132
|
+
const Toast = react.memo(_Toast);
|
|
5656
6133
|
Toast.displayName = "Toast";
|
|
5657
|
-
const ToastContext =
|
|
6134
|
+
const ToastContext = react.createContext({});
|
|
5658
6135
|
const useToast = () => {
|
|
5659
|
-
const context =
|
|
6136
|
+
const context = react.useContext(ToastContext);
|
|
5660
6137
|
if (!context) {
|
|
5661
6138
|
throw new Error("useToast must be used within a ToastProvider");
|
|
5662
6139
|
}
|
|
@@ -5670,15 +6147,15 @@
|
|
|
5670
6147
|
return MIN_DURATION + words / WORDS_PER_SECOND;
|
|
5671
6148
|
};
|
|
5672
6149
|
exports2.unsafeShowToast = void 0;
|
|
5673
|
-
const ToastProvider =
|
|
6150
|
+
const ToastProvider = react.memo(function ToastContextProvider({
|
|
5674
6151
|
children,
|
|
5675
6152
|
// Use this class to change where the viewport for the toasts should be
|
|
5676
6153
|
className,
|
|
5677
6154
|
hotkey,
|
|
5678
6155
|
...rest
|
|
5679
6156
|
}) {
|
|
5680
|
-
const [toasts, setToasts] =
|
|
5681
|
-
const handleCloseToast =
|
|
6157
|
+
const [toasts, setToasts] = react.useState([]);
|
|
6158
|
+
const handleCloseToast = react.useCallback((id, reason, callback) => {
|
|
5682
6159
|
setToasts((prevToasts) => {
|
|
5683
6160
|
const toast = prevToasts.find((toast2) => toast2.id === id);
|
|
5684
6161
|
if (toast && reason === 0) clearTimeout(toast.timeout);
|
|
@@ -5686,7 +6163,7 @@
|
|
|
5686
6163
|
});
|
|
5687
6164
|
if (callback) callback();
|
|
5688
6165
|
}, []);
|
|
5689
|
-
const toastContextValue =
|
|
6166
|
+
const toastContextValue = react.useMemo(() => {
|
|
5690
6167
|
let counter = 0;
|
|
5691
6168
|
const showToast = (toastProps) => {
|
|
5692
6169
|
const duration = calculatedDuration(toastProps);
|
|
@@ -5710,7 +6187,7 @@
|
|
|
5710
6187
|
showWarning
|
|
5711
6188
|
};
|
|
5712
6189
|
}, [handleCloseToast]);
|
|
5713
|
-
|
|
6190
|
+
react.useEffect(() => {
|
|
5714
6191
|
return () => {
|
|
5715
6192
|
for (const { timeout } of toasts) clearTimeout(timeout);
|
|
5716
6193
|
};
|
|
@@ -5851,7 +6328,7 @@
|
|
|
5851
6328
|
}
|
|
5852
6329
|
}
|
|
5853
6330
|
);
|
|
5854
|
-
const BaseToggleButton =
|
|
6331
|
+
const BaseToggleButton = react.memo((props) => {
|
|
5855
6332
|
const providerContext = useProvider();
|
|
5856
6333
|
const {
|
|
5857
6334
|
ref,
|
|
@@ -5874,15 +6351,15 @@
|
|
|
5874
6351
|
);
|
|
5875
6352
|
});
|
|
5876
6353
|
BaseToggleButton.displayName = "BaseToggleButton";
|
|
5877
|
-
const IconToggleButton =
|
|
6354
|
+
const IconToggleButton = react.memo((props) => {
|
|
5878
6355
|
return /* @__PURE__ */ jsxRuntime.jsx(BaseToggleButton, { icon: true, ...props });
|
|
5879
6356
|
});
|
|
5880
6357
|
IconToggleButton.displayName = "IconToggleButton";
|
|
5881
|
-
const ToggleButton =
|
|
6358
|
+
const ToggleButton = react.memo((props) => {
|
|
5882
6359
|
return /* @__PURE__ */ jsxRuntime.jsx(BaseToggleButton, { icon: false, ...props });
|
|
5883
6360
|
});
|
|
5884
6361
|
ToggleButton.displayName = "ToggleButton";
|
|
5885
|
-
const ToggleGroupContext =
|
|
6362
|
+
const ToggleGroupContext = react.createContext({});
|
|
5886
6363
|
const toggleGroupItemCva = classVarianceAuthority.cva(
|
|
5887
6364
|
[
|
|
5888
6365
|
"flex",
|
|
@@ -5998,8 +6475,8 @@
|
|
|
5998
6475
|
]
|
|
5999
6476
|
}
|
|
6000
6477
|
);
|
|
6001
|
-
const ToggleGroupBaseItem =
|
|
6002
|
-
const toggleGroupContext =
|
|
6478
|
+
const ToggleGroupBaseItem = react.memo((props) => {
|
|
6479
|
+
const toggleGroupContext = react.use(ToggleGroupContext);
|
|
6003
6480
|
const {
|
|
6004
6481
|
ref,
|
|
6005
6482
|
className,
|
|
@@ -6025,15 +6502,15 @@
|
|
|
6025
6502
|
);
|
|
6026
6503
|
});
|
|
6027
6504
|
ToggleGroupBaseItem.displayName = "ToggleGroupBaseItem";
|
|
6028
|
-
const ToggleGroupIconItem =
|
|
6505
|
+
const ToggleGroupIconItem = react.memo((props) => {
|
|
6029
6506
|
return /* @__PURE__ */ jsxRuntime.jsx(ToggleGroupBaseItem, { icon: true, ...props });
|
|
6030
6507
|
});
|
|
6031
6508
|
ToggleGroupIconItem.displayName = "ToggleGroupIconItem";
|
|
6032
|
-
const ToggleGroupItem =
|
|
6509
|
+
const ToggleGroupItem = react.memo((props) => {
|
|
6033
6510
|
return /* @__PURE__ */ jsxRuntime.jsx(ToggleGroupBaseItem, { icon: false, ...props });
|
|
6034
6511
|
});
|
|
6035
6512
|
ToggleGroupItem.displayName = "ToggleGroupItem";
|
|
6036
|
-
const ToggleGroupRoot =
|
|
6513
|
+
const ToggleGroupRoot = react.memo((props) => {
|
|
6037
6514
|
const providerContext = useProvider();
|
|
6038
6515
|
const {
|
|
6039
6516
|
ref,
|
|
@@ -6044,7 +6521,7 @@
|
|
|
6044
6521
|
size = "md",
|
|
6045
6522
|
...rest
|
|
6046
6523
|
} = props;
|
|
6047
|
-
const contextValue =
|
|
6524
|
+
const contextValue = react.useMemo(
|
|
6048
6525
|
() => ({
|
|
6049
6526
|
variant,
|
|
6050
6527
|
size,
|
|
@@ -6061,7 +6538,7 @@
|
|
|
6061
6538
|
Item: ToggleGroupItem,
|
|
6062
6539
|
IconItem: ToggleGroupIconItem
|
|
6063
6540
|
};
|
|
6064
|
-
const TooltipArrow =
|
|
6541
|
+
const TooltipArrow = react.memo((props) => {
|
|
6065
6542
|
const { ref, className, ...rest } = props;
|
|
6066
6543
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixTooltip__namespace.Arrow, { className: classVarianceAuthority.cx("fill-(--base-6)", className), ref, ...rest });
|
|
6067
6544
|
});
|
|
@@ -6103,7 +6580,7 @@
|
|
|
6103
6580
|
}
|
|
6104
6581
|
}
|
|
6105
6582
|
);
|
|
6106
|
-
const TooltipContent =
|
|
6583
|
+
const TooltipContent = react.memo((props) => {
|
|
6107
6584
|
const providerContext = useProvider();
|
|
6108
6585
|
const {
|
|
6109
6586
|
ref,
|
|
@@ -6155,7 +6632,6 @@
|
|
|
6155
6632
|
exports2.CheckboxGroupSelectAllItem = CheckboxGroupSelectAllItem;
|
|
6156
6633
|
exports2.CheckboxIndicator = CheckboxIndicator;
|
|
6157
6634
|
exports2.CheckboxRoot = CheckboxRoot;
|
|
6158
|
-
exports2.CollapsibleTree = CollapsibleTree;
|
|
6159
6635
|
exports2.CommandMenu = CommandMenu;
|
|
6160
6636
|
exports2.CommandMenuCheckboxIndicator = CommandMenuCheckboxIndicator;
|
|
6161
6637
|
exports2.CommandMenuCheckboxItem = CommandMenuCheckboxItem;
|
|
@@ -6230,6 +6706,23 @@
|
|
|
6230
6706
|
exports2.MenuSub = MenuSub;
|
|
6231
6707
|
exports2.MenuSubContent = MenuSubContent;
|
|
6232
6708
|
exports2.MenuSubTrigger = MenuSubTrigger;
|
|
6709
|
+
exports2.MenuV2 = MenuV2;
|
|
6710
|
+
exports2.MenuV2CheckboxItem = MenuV2CheckboxItem;
|
|
6711
|
+
exports2.MenuV2CheckedIndicator = MenuV2CheckedIndicator;
|
|
6712
|
+
exports2.MenuV2Group = MenuV2Group;
|
|
6713
|
+
exports2.MenuV2GroupLabel = MenuV2GroupLabel;
|
|
6714
|
+
exports2.MenuV2Item = MenuV2Item;
|
|
6715
|
+
exports2.MenuV2MultiSelectGroup = MenuV2MultiSelectGroup;
|
|
6716
|
+
exports2.MenuV2MultiSelectItem = MenuV2MultiSelectItem;
|
|
6717
|
+
exports2.MenuV2Page = MenuV2Page;
|
|
6718
|
+
exports2.MenuV2PageTriggerItem = MenuV2PageTriggerItem;
|
|
6719
|
+
exports2.MenuV2Pages = MenuV2Pages;
|
|
6720
|
+
exports2.MenuV2Root = MenuV2Root;
|
|
6721
|
+
exports2.MenuV2SelectAllItem = MenuV2SelectAllItem;
|
|
6722
|
+
exports2.MenuV2SelectGroup = MenuV2SelectGroup;
|
|
6723
|
+
exports2.MenuV2SelectItem = MenuV2SelectItem;
|
|
6724
|
+
exports2.MenuV2SelectedIndicator = MenuV2SelectedIndicator;
|
|
6725
|
+
exports2.MenuV2Separator = MenuV2Separator;
|
|
6233
6726
|
exports2.MenuVirtualTrigger = MenuVirtualTrigger;
|
|
6234
6727
|
exports2.OneTimePasswordField = OneTimePasswordField;
|
|
6235
6728
|
exports2.OneTimePasswordFieldHiddenInput = OneTimePasswordFieldHiddenInput;
|
|
@@ -6243,6 +6736,7 @@
|
|
|
6243
6736
|
exports2.OverlayTitle = OverlayTitle;
|
|
6244
6737
|
exports2.OverlayTrigger = OverlayTrigger;
|
|
6245
6738
|
exports2.OvermapErrorBoundary = OvermapErrorBoundary;
|
|
6739
|
+
exports2.PhoneNumberInput = PhoneNumberInput;
|
|
6246
6740
|
exports2.Popover = Popover;
|
|
6247
6741
|
exports2.PopoverArrow = PopoverArrow;
|
|
6248
6742
|
exports2.PopoverContent = PopoverContent;
|
|
@@ -6255,6 +6749,10 @@
|
|
|
6255
6749
|
exports2.RadioGroupIndicator = RadioGroupIndicator;
|
|
6256
6750
|
exports2.RadioGroupItem = RadioGroupItem;
|
|
6257
6751
|
exports2.RadioGroupRoot = RadioGroupRoot;
|
|
6752
|
+
exports2.Rating = Rating;
|
|
6753
|
+
exports2.RatingItem = RatingItem;
|
|
6754
|
+
exports2.RatingItemIndicator = RatingItemIndicator;
|
|
6755
|
+
exports2.RatingRoot = RatingRoot;
|
|
6258
6756
|
exports2.SegmentedControl = SegmentedControl;
|
|
6259
6757
|
exports2.SegmentedControlItem = SegmentedControlItem;
|
|
6260
6758
|
exports2.SegmentedControlRoot = SegmentedControlRoot;
|
|
@@ -6262,7 +6760,6 @@
|
|
|
6262
6760
|
exports2.SegmentedTabsList = SegmentedTabsList;
|
|
6263
6761
|
exports2.SegmentedTabsRoot = SegmentedTabsRoot;
|
|
6264
6762
|
exports2.SegmentedTabsTrigger = SegmentedTabsTrigger;
|
|
6265
|
-
exports2.SelectedIndicatorContext = SelectedIndicatorContext;
|
|
6266
6763
|
exports2.Separator = Separator;
|
|
6267
6764
|
exports2.SlideOut = SlideOut;
|
|
6268
6765
|
exports2.Slider = Slider;
|
|
@@ -6299,21 +6796,21 @@
|
|
|
6299
6796
|
exports2.badge = badge;
|
|
6300
6797
|
exports2.buttonCva = buttonCva;
|
|
6301
6798
|
exports2.floating = floating;
|
|
6799
|
+
exports2.genericMemo = genericMemo;
|
|
6800
|
+
exports2.getActiveState = getActiveState;
|
|
6801
|
+
exports2.getBooleanState = getBooleanState;
|
|
6802
|
+
exports2.getCheckedState = getCheckedState;
|
|
6803
|
+
exports2.getOpenState = getOpenState;
|
|
6804
|
+
exports2.getSelectedState = getSelectedState;
|
|
6302
6805
|
exports2.mergeRefs = mergeRefs;
|
|
6303
6806
|
exports2.radiusCva = radiusCva;
|
|
6304
6807
|
exports2.stopPropagation = stopPropagation;
|
|
6305
6808
|
exports2.useAlertDialog = useAlertDialog;
|
|
6306
6809
|
exports2.useButtonGroup = useButtonGroup;
|
|
6307
6810
|
exports2.useControlledState = useControlledState;
|
|
6811
|
+
exports2.useFallbackId = useFallbackId;
|
|
6308
6812
|
exports2.useLayoutContext = useLayoutContext;
|
|
6309
|
-
exports2.useMenuContentContext = useMenuContentContext;
|
|
6310
|
-
exports2.useMenuContext = useMenuContext;
|
|
6311
|
-
exports2.usePagesContext = usePagesContext;
|
|
6312
6813
|
exports2.useProvider = useProvider;
|
|
6313
|
-
exports2.useSelectedIndicatorContext = useSelectedIndicatorContext;
|
|
6314
|
-
exports2.useSize = useSize;
|
|
6315
|
-
exports2.useStopEventPropagation = useStopEventPropagation;
|
|
6316
|
-
exports2.useSubContext = useSubContext;
|
|
6317
6814
|
exports2.useTextFilter = useTextFilter;
|
|
6318
6815
|
exports2.useToast = useToast;
|
|
6319
6816
|
exports2.useViewportSize = useViewportSize;
|