@constructive-io/ui 0.1.1 → 0.3.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/components/alert-dialog.js.map +1 -1
- package/dist/components/autocomplete.js +11 -3
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/card.d.ts +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/combobox.d.ts +1 -1
- package/dist/components/combobox.js +50 -14
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command.d.ts +16 -35
- package/dist/components/command.js +72 -508
- package/dist/components/command.js.map +1 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/dropdown-menu.js +3 -3
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/form-control.js.map +1 -1
- package/dist/components/form.js.map +1 -1
- package/dist/components/input-group.js +3 -3
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/json-input.js.map +1 -1
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/org-chart/index.d.ts +54 -0
- package/dist/components/org-chart/index.js +861 -0
- package/dist/components/org-chart/index.js.map +1 -0
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/portal.js.map +1 -1
- package/dist/components/record-picker.js +3 -3
- package/dist/components/record-picker.js.map +1 -1
- package/dist/components/resizable.js.map +1 -1
- package/dist/components/responsive-diagram.js +6 -4
- package/dist/components/responsive-diagram.js.map +1 -1
- package/dist/components/select.d.ts +2 -2
- package/dist/components/select.js +3 -3
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.js +1 -1
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/stack/index.d.ts +11 -0
- package/dist/components/stack/index.js +33 -6
- package/dist/components/stack/index.js.map +1 -1
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tags.d.ts +1 -3
- package/dist/components/tags.js +107 -388
- package/dist/components/tags.js.map +1 -1
- package/dist/components/textarea.js +1 -1
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/index.cjs +867 -378
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -24
- package/dist/index.d.ts +82 -24
- package/dist/index.js +746 -259
- package/dist/index.js.map +1 -1
- package/package.json +13 -6
- package/src/styles/globals.css +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
4
|
+
import * as React19 from 'react';
|
|
5
|
+
import React19__default, { createContext, memo, useState, useCallback, useMemo, useRef, useContext, useEffect, Suspense, useLayoutEffect, useReducer } from 'react';
|
|
6
6
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
8
8
|
import { Separator as Separator$1 } from '@base-ui/react/separator';
|
|
@@ -13,7 +13,7 @@ import { Radio as Radio$1 } from '@base-ui/react/radio';
|
|
|
13
13
|
import { RadioGroup as RadioGroup$1 } from '@base-ui/react/radio-group';
|
|
14
14
|
import { Switch as Switch$1 } from '@base-ui/react/switch';
|
|
15
15
|
import { Select as Select$1 } from '@base-ui/react/select';
|
|
16
|
-
import { ChevronsUpDownIcon, XCircle, XIcon, ChevronDown, SearchIcon, CheckIcon, ChevronRight, ChevronUpIcon, ChevronDownIcon, CircleIcon, ChevronRightIcon, X, GripVerticalIcon, ChevronLeftIcon, MoreHorizontalIcon, LoaderCircleIcon, PanelLeftIcon, WandSparkles, AlertCircleIcon, InfoIcon, CheckCircleIcon, AlertTriangleIcon, Loader2, CircleAlert, CheckCircle2 } from 'lucide-react';
|
|
16
|
+
import { ChevronsUpDownIcon, XCircle, XIcon, ChevronDown, SearchIcon, CheckIcon, Ellipsis, Pencil, Trash2, ChevronRight, ChevronUpIcon, ChevronDownIcon, CircleIcon, ChevronRightIcon, X, GripVerticalIcon, ChevronLeftIcon, MoreHorizontalIcon, LoaderCircleIcon, PanelLeftIcon, WandSparkles, AlertCircleIcon, InfoIcon, CheckCircleIcon, AlertTriangleIcon, Loader2, CircleAlert, CheckCircle2, Network, UserPlus } from 'lucide-react';
|
|
17
17
|
import { Progress as Progress$1 } from '@base-ui/react/progress';
|
|
18
18
|
import { FormProvider, Controller, useFormContext, useFormState } from 'react-hook-form';
|
|
19
19
|
import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
|
|
@@ -29,14 +29,17 @@ import { Collapsible as Collapsible$1 } from '@base-ui/react/collapsible';
|
|
|
29
29
|
import * as ResizablePrimitive from 'react-resizable-panels';
|
|
30
30
|
import { Avatar as Avatar$1 } from '@base-ui/react/avatar';
|
|
31
31
|
import { Autocomplete as Autocomplete$1 } from '@base-ui/react/autocomplete';
|
|
32
|
+
import { Handle, Position, useReactFlow, Panel, ReactFlowProvider, useNodesState, useEdgesState, ReactFlow, Background, BackgroundVariant, getSmoothStepPath, BaseEdge } from '@xyflow/react';
|
|
33
|
+
import { RiAddLine, RiSubtractLine, RiFocus3Line, RiSearchLine, RiLoader4Line, RiCheckLine, RiCloseLine } from '@remixicon/react';
|
|
34
|
+
import { Command as Command$1 } from 'cmdk';
|
|
32
35
|
import { Combobox as Combobox$1 } from '@base-ui/react/combobox';
|
|
33
|
-
import { RiSearchLine, RiLoader4Line, RiCheckLine, RiCloseLine } from '@remixicon/react';
|
|
34
36
|
import { matchSorter } from 'match-sorter';
|
|
35
37
|
import { today, getLocalTimeZone } from '@internationalized/date';
|
|
36
38
|
import { Calendar as Calendar$1, composeRenderProps, RangeCalendar as RangeCalendar$1, Button as Button$1, Heading, CalendarGrid, CalendarGridHeader, CalendarHeaderCell, CalendarGridBody, CalendarCell } from 'react-aria-components';
|
|
37
39
|
import { Toaster as Toaster$1, toast } from 'sonner';
|
|
38
40
|
import { createPortal } from 'react-dom';
|
|
39
41
|
import { useDrag } from '@use-gesture/react';
|
|
42
|
+
import '@xyflow/react/dist/style.css';
|
|
40
43
|
|
|
41
44
|
// src/lib/utils.ts
|
|
42
45
|
function cn(...inputs) {
|
|
@@ -83,22 +86,22 @@ function mergePropsWithRef(parentProps, childElement) {
|
|
|
83
86
|
return mergedProps;
|
|
84
87
|
}
|
|
85
88
|
function isSlottable(child) {
|
|
86
|
-
return
|
|
89
|
+
return React19.isValidElement(child);
|
|
87
90
|
}
|
|
88
|
-
var Slot =
|
|
91
|
+
var Slot = React19.forwardRef((props, forwardedRef) => {
|
|
89
92
|
const { children, ...slotProps } = props;
|
|
90
93
|
if (isSlottable(children)) {
|
|
91
94
|
const childProps = children.props;
|
|
92
95
|
const childRef = childProps.ref;
|
|
93
|
-
return
|
|
96
|
+
return React19.cloneElement(children, {
|
|
94
97
|
...mergeProps(slotProps, childProps),
|
|
95
98
|
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
96
99
|
});
|
|
97
100
|
}
|
|
98
|
-
if (
|
|
99
|
-
const childrenArray =
|
|
101
|
+
if (React19.Children.count(children) > 1) {
|
|
102
|
+
const childrenArray = React19.Children.toArray(children);
|
|
100
103
|
const slottableChild = childrenArray.find(
|
|
101
|
-
(child) =>
|
|
104
|
+
(child) => React19.isValidElement(child) && child.type === Slottable
|
|
102
105
|
);
|
|
103
106
|
if (slottableChild) {
|
|
104
107
|
const newElement = slottableChild.props.children;
|
|
@@ -106,12 +109,12 @@ var Slot = React20.forwardRef((props, forwardedRef) => {
|
|
|
106
109
|
const newElementProps = newElement.props;
|
|
107
110
|
const newChildren = childrenArray.map((child) => {
|
|
108
111
|
if (child === slottableChild) {
|
|
109
|
-
return
|
|
112
|
+
return React19.Children.count(newElementProps.children) > 1 ? React19.Children.only(null) : newElementProps.children;
|
|
110
113
|
}
|
|
111
114
|
return child;
|
|
112
115
|
});
|
|
113
116
|
const childRef = newElementProps.ref;
|
|
114
|
-
return
|
|
117
|
+
return React19.cloneElement(newElement, {
|
|
115
118
|
...mergeProps(slotProps, newElementProps),
|
|
116
119
|
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,
|
|
117
120
|
children: newChildren
|
|
@@ -311,12 +314,12 @@ var buttonVariants = cva(
|
|
|
311
314
|
}
|
|
312
315
|
}
|
|
313
316
|
);
|
|
314
|
-
var Button =
|
|
317
|
+
var Button = React19.forwardRef(
|
|
315
318
|
({ className, variant, size, asChild, children, type = "button", ...props }, ref) => {
|
|
316
319
|
const buttonClasses = cn(buttonVariants({ className, size, variant }));
|
|
317
|
-
if (asChild &&
|
|
320
|
+
if (asChild && React19.isValidElement(children)) {
|
|
318
321
|
const childProps = children.props;
|
|
319
|
-
return
|
|
322
|
+
return React19.cloneElement(children, {
|
|
320
323
|
...props,
|
|
321
324
|
className: cn(buttonClasses, childProps.className),
|
|
322
325
|
"data-slot": "button"
|
|
@@ -352,7 +355,7 @@ var badgeVariants = cva(
|
|
|
352
355
|
}
|
|
353
356
|
}
|
|
354
357
|
);
|
|
355
|
-
var Badge =
|
|
358
|
+
var Badge = React19.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ jsx("span", { ref, "data-slot": "badge", className: cn(badgeVariants({ variant, size }), className), ...props }));
|
|
356
359
|
Badge.displayName = "Badge";
|
|
357
360
|
function Label({ className, ...props }) {
|
|
358
361
|
return /* @__PURE__ */ jsx(
|
|
@@ -458,13 +461,13 @@ var alertVariants = cva(
|
|
|
458
461
|
}
|
|
459
462
|
}
|
|
460
463
|
);
|
|
461
|
-
var Alert =
|
|
464
|
+
var Alert = React19.forwardRef(({ className, variant, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, role: "alert", className: cn(alertVariants({ variant }), className), ...props }));
|
|
462
465
|
Alert.displayName = "Alert";
|
|
463
|
-
var AlertTitle =
|
|
466
|
+
var AlertTitle = React19.forwardRef(
|
|
464
467
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("h5", { ref, className: cn("mb-1 leading-none font-medium tracking-tight", className), ...props })
|
|
465
468
|
);
|
|
466
469
|
AlertTitle.displayName = "AlertTitle";
|
|
467
|
-
var AlertDescription =
|
|
470
|
+
var AlertDescription = React19.forwardRef(
|
|
468
471
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("text-sm [&_p]:leading-relaxed", className), ...props })
|
|
469
472
|
);
|
|
470
473
|
AlertDescription.displayName = "AlertDescription";
|
|
@@ -476,7 +479,7 @@ function Input({ className, size = "default", unstyled = false, ...props }) {
|
|
|
476
479
|
className: cn(
|
|
477
480
|
!unstyled && [
|
|
478
481
|
// Base layout
|
|
479
|
-
"relative inline-flex w-full rounded-lg border border-input bg-background bg-clip-padding text-base
|
|
482
|
+
"relative inline-flex w-full rounded-lg border border-input bg-background bg-clip-padding text-base transition-shadow",
|
|
480
483
|
// Inner shadow highlight
|
|
481
484
|
"before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)]",
|
|
482
485
|
"not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)]",
|
|
@@ -522,7 +525,7 @@ function Textarea({ className, size = "default", unstyled = false, ...props }) {
|
|
|
522
525
|
className: cn(
|
|
523
526
|
!unstyled && [
|
|
524
527
|
// Base layout
|
|
525
|
-
"relative inline-flex w-full rounded-lg border border-input bg-background bg-clip-padding text-base
|
|
528
|
+
"relative inline-flex w-full rounded-lg border border-input bg-background bg-clip-padding text-base transition-shadow",
|
|
526
529
|
// Inner shadow highlight
|
|
527
530
|
"before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)]",
|
|
528
531
|
"not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)]",
|
|
@@ -557,13 +560,13 @@ function Textarea({ className, size = "default", unstyled = false, ...props }) {
|
|
|
557
560
|
}
|
|
558
561
|
);
|
|
559
562
|
}
|
|
560
|
-
var Checkbox =
|
|
563
|
+
var Checkbox = React19.forwardRef(({ className, ...props }, ref) => {
|
|
561
564
|
return /* @__PURE__ */ jsx(
|
|
562
565
|
Checkbox$1.Root,
|
|
563
566
|
{
|
|
564
567
|
ref,
|
|
565
568
|
className: cn(
|
|
566
|
-
"relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-[4px] border border-input bg-background bg-clip-padding
|
|
569
|
+
"relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-[4px] border border-input bg-background bg-clip-padding outline-none ring-ring transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[3px] not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/48 data-disabled:opacity-64 sm:size-4 dark:not-data-checked:bg-input/32 dark:bg-clip-border dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/8%)] [[data-disabled],[data-checked],[aria-invalid]]:shadow-none",
|
|
567
570
|
className
|
|
568
571
|
),
|
|
569
572
|
"data-slot": "checkbox",
|
|
@@ -664,7 +667,7 @@ function Switch({ className, ...props }) {
|
|
|
664
667
|
);
|
|
665
668
|
}
|
|
666
669
|
var PORTAL_ROOT_ID = "portal-root";
|
|
667
|
-
var PortalContext =
|
|
670
|
+
var PortalContext = React19.createContext({
|
|
668
671
|
layer: "base",
|
|
669
672
|
depth: 0,
|
|
670
673
|
floatingPortalStrategy: "root",
|
|
@@ -675,9 +678,9 @@ function ModalPortalScope({
|
|
|
675
678
|
floatingPortalStrategy = "nested",
|
|
676
679
|
floatingZIndex = "default"
|
|
677
680
|
}) {
|
|
678
|
-
const parentContext =
|
|
681
|
+
const parentContext = React19.useContext(PortalContext);
|
|
679
682
|
const depth = parentContext.layer === "modal" ? parentContext.depth + 1 : 0;
|
|
680
|
-
const value =
|
|
683
|
+
const value = React19.useMemo(
|
|
681
684
|
() => ({
|
|
682
685
|
layer: "modal",
|
|
683
686
|
depth,
|
|
@@ -689,14 +692,14 @@ function ModalPortalScope({
|
|
|
689
692
|
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
690
693
|
}
|
|
691
694
|
function usePortalContext() {
|
|
692
|
-
return
|
|
695
|
+
return React19.useContext(PortalContext);
|
|
693
696
|
}
|
|
694
697
|
function useInModalOverlay() {
|
|
695
|
-
return
|
|
698
|
+
return React19.useContext(PortalContext).layer === "modal";
|
|
696
699
|
}
|
|
697
700
|
function useRootPortalContainer() {
|
|
698
|
-
const [container, setContainer] =
|
|
699
|
-
|
|
701
|
+
const [container, setContainer] = React19.useState(null);
|
|
702
|
+
React19.useLayoutEffect(() => {
|
|
700
703
|
const el = document.getElementById(PORTAL_ROOT_ID);
|
|
701
704
|
setContainer(el);
|
|
702
705
|
}, []);
|
|
@@ -704,7 +707,7 @@ function useRootPortalContainer() {
|
|
|
704
707
|
}
|
|
705
708
|
function useFloatingOverlayPortalProps() {
|
|
706
709
|
const rootContainer = useRootPortalContainer();
|
|
707
|
-
const { floatingPortalStrategy, floatingZIndex } =
|
|
710
|
+
const { floatingPortalStrategy, floatingZIndex } = React19.useContext(PortalContext);
|
|
708
711
|
const container = floatingPortalStrategy === "nested" ? void 0 : rootContainer ?? null;
|
|
709
712
|
const zIndexClass = floatingZIndex === "elevated" ? "z-[var(--z-layer-floating-elevated)]" : "z-[var(--z-layer-floating)]";
|
|
710
713
|
return { container, zIndexClass };
|
|
@@ -743,14 +746,14 @@ function Select({ onValueChange, ...props }) {
|
|
|
743
746
|
}
|
|
744
747
|
);
|
|
745
748
|
}
|
|
746
|
-
var SelectTrigger =
|
|
749
|
+
var SelectTrigger = React19.forwardRef(
|
|
747
750
|
({ className, size = "default", children, ...props }, ref) => {
|
|
748
751
|
return /* @__PURE__ */ jsxs(
|
|
749
752
|
Select$1.Trigger,
|
|
750
753
|
{
|
|
751
754
|
ref,
|
|
752
755
|
className: cn(
|
|
753
|
-
"relative inline-flex min-h-9 w-full min-w-36 select-none items-center justify-between gap-2 rounded-lg border border-input bg-background bg-clip-padding px-[calc(--spacing(3)-1px)] text-left text-base
|
|
756
|
+
"relative inline-flex min-h-9 w-full min-w-36 select-none items-center justify-between gap-2 rounded-lg border border-input bg-background bg-clip-padding px-[calc(--spacing(3)-1px)] text-left text-base outline-none ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 focus-visible:border-ring focus-visible:ring-[3px] aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/16 data-disabled:pointer-events-none data-disabled:opacity-64 sm:min-h-8 sm:text-sm dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/8%)] [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0 [[data-disabled],:focus-visible,[aria-invalid],[data-pressed]]:shadow-none",
|
|
754
757
|
size === "sm" && "min-h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:min-h-7",
|
|
755
758
|
size === "lg" && "min-h-10 sm:min-h-9",
|
|
756
759
|
className
|
|
@@ -884,10 +887,10 @@ function SelectSeparator({
|
|
|
884
887
|
}
|
|
885
888
|
);
|
|
886
889
|
}
|
|
887
|
-
function SelectGroup(props) {
|
|
890
|
+
function SelectGroup({ ...props }) {
|
|
888
891
|
return /* @__PURE__ */ jsx(Select$1.Group, { "data-slot": "select-group", ...props });
|
|
889
892
|
}
|
|
890
|
-
function SelectGroupLabel(props) {
|
|
893
|
+
function SelectGroupLabel({ ...props }) {
|
|
891
894
|
return /* @__PURE__ */ jsx(
|
|
892
895
|
Select$1.GroupLabel,
|
|
893
896
|
{
|
|
@@ -998,15 +1001,15 @@ function Progress({ className, value, ...props }) {
|
|
|
998
1001
|
) });
|
|
999
1002
|
}
|
|
1000
1003
|
var Form = FormProvider;
|
|
1001
|
-
var FormFieldContext =
|
|
1004
|
+
var FormFieldContext = React19.createContext({});
|
|
1002
1005
|
var FormField = ({
|
|
1003
1006
|
...props
|
|
1004
1007
|
}) => {
|
|
1005
1008
|
return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
|
|
1006
1009
|
};
|
|
1007
1010
|
var useFormField = () => {
|
|
1008
|
-
const fieldContext =
|
|
1009
|
-
const itemContext =
|
|
1011
|
+
const fieldContext = React19.useContext(FormFieldContext);
|
|
1012
|
+
const itemContext = React19.useContext(FormItemContext);
|
|
1010
1013
|
const { getFieldState } = useFormContext();
|
|
1011
1014
|
const formState = useFormState({ name: fieldContext.name });
|
|
1012
1015
|
const fieldState = getFieldState(fieldContext.name, formState);
|
|
@@ -1023,9 +1026,9 @@ var useFormField = () => {
|
|
|
1023
1026
|
...fieldState
|
|
1024
1027
|
};
|
|
1025
1028
|
};
|
|
1026
|
-
var FormItemContext =
|
|
1029
|
+
var FormItemContext = React19.createContext({});
|
|
1027
1030
|
function FormItem({ className, ...props }) {
|
|
1028
|
-
const id =
|
|
1031
|
+
const id = React19.useId();
|
|
1029
1032
|
return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx("div", { "data-slot": "form-item", className: cn("grid gap-2", className), ...props }) });
|
|
1030
1033
|
}
|
|
1031
1034
|
function FormLabel({ className, ...props }) {
|
|
@@ -1075,7 +1078,7 @@ function FormMessage({ className, ...props }) {
|
|
|
1075
1078
|
return /* @__PURE__ */ jsx("p", { "data-slot": "form-message", id: formMessageId, className: cn("text-destructive text-sm", className), ...props, children: body });
|
|
1076
1079
|
}
|
|
1077
1080
|
function FormControl2({ children, label, id, layout = "stacked", error, className }) {
|
|
1078
|
-
const generatedId =
|
|
1081
|
+
const generatedId = React19.useId();
|
|
1079
1082
|
const inputId = id || generatedId;
|
|
1080
1083
|
const errorId = error ? `${inputId}-error` : void 0;
|
|
1081
1084
|
const childProps = {
|
|
@@ -1086,7 +1089,7 @@ function FormControl2({ children, label, id, layout = "stacked", error, classNam
|
|
|
1086
1089
|
if (layout === "floating") {
|
|
1087
1090
|
childProps.placeholder = " ";
|
|
1088
1091
|
}
|
|
1089
|
-
const childWithProps =
|
|
1092
|
+
const childWithProps = React19.cloneElement(children, childProps);
|
|
1090
1093
|
if (layout === "floating") {
|
|
1091
1094
|
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-1", className), children: [
|
|
1092
1095
|
/* @__PURE__ */ jsxs(
|
|
@@ -1151,7 +1154,7 @@ function InputGroup({ className, ...props }) {
|
|
|
1151
1154
|
"div",
|
|
1152
1155
|
{
|
|
1153
1156
|
className: cn(
|
|
1154
|
-
"relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background bg-clip-padding text-base
|
|
1157
|
+
"relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background bg-clip-padding text-base transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-primary/60 has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/36 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid],textarea[aria-invalid]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] has-[input:focus-visible,textarea:focus-visible]:ring-primary/35 sm:text-sm dark:bg-input/32 dark:bg-clip-border dark:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/24 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_-1px_--theme(--color-white/8%)] has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]",
|
|
1155
1158
|
className
|
|
1156
1159
|
),
|
|
1157
1160
|
"data-slot": "input-group",
|
|
@@ -1315,7 +1318,7 @@ function Tooltip({ delayDuration: _delayDuration, ...props }) {
|
|
|
1315
1318
|
return /* @__PURE__ */ jsx(Tooltip$1.Root, { "data-slot": "tooltip", ...props });
|
|
1316
1319
|
}
|
|
1317
1320
|
function TooltipTrigger({ delay = 0, asChild, children, ...props }) {
|
|
1318
|
-
if (asChild &&
|
|
1321
|
+
if (asChild && React19.isValidElement(children)) {
|
|
1319
1322
|
return /* @__PURE__ */ jsx(
|
|
1320
1323
|
Tooltip$1.Trigger,
|
|
1321
1324
|
{
|
|
@@ -1323,7 +1326,7 @@ function TooltipTrigger({ delay = 0, asChild, children, ...props }) {
|
|
|
1323
1326
|
delay,
|
|
1324
1327
|
...props,
|
|
1325
1328
|
render: (triggerProps) => {
|
|
1326
|
-
return
|
|
1329
|
+
return React19.cloneElement(
|
|
1327
1330
|
children,
|
|
1328
1331
|
mergePropsWithRef(triggerProps, children)
|
|
1329
1332
|
);
|
|
@@ -1367,7 +1370,7 @@ function Popover({ ...props }) {
|
|
|
1367
1370
|
return /* @__PURE__ */ jsx(Popover$1.Root, { "data-slot": "popover", ...props });
|
|
1368
1371
|
}
|
|
1369
1372
|
function PopoverTrigger({ asChild, nativeButton, children, ...props }) {
|
|
1370
|
-
if (asChild &&
|
|
1373
|
+
if (asChild && React19.isValidElement(children)) {
|
|
1371
1374
|
return /* @__PURE__ */ jsx(
|
|
1372
1375
|
Popover$1.Trigger,
|
|
1373
1376
|
{
|
|
@@ -1376,7 +1379,7 @@ function PopoverTrigger({ asChild, nativeButton, children, ...props }) {
|
|
|
1376
1379
|
...props,
|
|
1377
1380
|
render: (triggerProps) => {
|
|
1378
1381
|
const { nativeButton: _, ...rest } = triggerProps;
|
|
1379
|
-
return
|
|
1382
|
+
return React19.cloneElement(
|
|
1380
1383
|
children,
|
|
1381
1384
|
mergePropsWithRef(rest, children)
|
|
1382
1385
|
);
|
|
@@ -1432,7 +1435,7 @@ function PopoverContent({
|
|
|
1432
1435
|
function PopoverAnchor({ ...props }) {
|
|
1433
1436
|
return /* @__PURE__ */ jsx("div", { "data-slot": "popover-anchor", ...props });
|
|
1434
1437
|
}
|
|
1435
|
-
var ScrollArea =
|
|
1438
|
+
var ScrollArea = React19.forwardRef(
|
|
1436
1439
|
({ className, children, scrollFade = false, scrollbarGutter = false, ...props }, ref) => {
|
|
1437
1440
|
return /* @__PURE__ */ jsxs(
|
|
1438
1441
|
ScrollArea$1.Root,
|
|
@@ -1499,7 +1502,7 @@ function DialogPortal({ keepMounted = true, ...props }) {
|
|
|
1499
1502
|
return /* @__PURE__ */ jsx(Dialog$1.Portal, { keepMounted, container, ...props, style });
|
|
1500
1503
|
}
|
|
1501
1504
|
function DialogTrigger({ asChild, nativeButton, children, ...props }) {
|
|
1502
|
-
if (asChild &&
|
|
1505
|
+
if (asChild && React19.isValidElement(children)) {
|
|
1503
1506
|
return /* @__PURE__ */ jsx(
|
|
1504
1507
|
Dialog$1.Trigger,
|
|
1505
1508
|
{
|
|
@@ -1508,7 +1511,7 @@ function DialogTrigger({ asChild, nativeButton, children, ...props }) {
|
|
|
1508
1511
|
...props,
|
|
1509
1512
|
render: (triggerProps) => {
|
|
1510
1513
|
const { nativeButton: _, ...rest } = triggerProps;
|
|
1511
|
-
return
|
|
1514
|
+
return React19.cloneElement(
|
|
1512
1515
|
children,
|
|
1513
1516
|
mergePropsWithRef(rest, children)
|
|
1514
1517
|
);
|
|
@@ -1519,7 +1522,7 @@ function DialogTrigger({ asChild, nativeButton, children, ...props }) {
|
|
|
1519
1522
|
return /* @__PURE__ */ jsx(Dialog$1.Trigger, { "data-slot": "dialog-trigger", nativeButton, ...props, children });
|
|
1520
1523
|
}
|
|
1521
1524
|
function DialogClose({ asChild, nativeButton, children, ...props }) {
|
|
1522
|
-
if (asChild &&
|
|
1525
|
+
if (asChild && React19.isValidElement(children)) {
|
|
1523
1526
|
return /* @__PURE__ */ jsx(
|
|
1524
1527
|
Dialog$1.Close,
|
|
1525
1528
|
{
|
|
@@ -1528,7 +1531,7 @@ function DialogClose({ asChild, nativeButton, children, ...props }) {
|
|
|
1528
1531
|
...props,
|
|
1529
1532
|
render: (closeProps) => {
|
|
1530
1533
|
const { nativeButton: _, ...rest } = closeProps;
|
|
1531
|
-
return
|
|
1534
|
+
return React19.cloneElement(
|
|
1532
1535
|
children,
|
|
1533
1536
|
mergePropsWithRef(rest, children)
|
|
1534
1537
|
);
|
|
@@ -1683,7 +1686,7 @@ function AlertDialog({ ...props }) {
|
|
|
1683
1686
|
return /* @__PURE__ */ jsx(AlertDialog$1.Root, { "data-slot": "alert-dialog", ...props });
|
|
1684
1687
|
}
|
|
1685
1688
|
function AlertDialogTrigger({ asChild, nativeButton, children, ...props }) {
|
|
1686
|
-
if (asChild &&
|
|
1689
|
+
if (asChild && React19.isValidElement(children)) {
|
|
1687
1690
|
return /* @__PURE__ */ jsx(
|
|
1688
1691
|
AlertDialog$1.Trigger,
|
|
1689
1692
|
{
|
|
@@ -1692,7 +1695,7 @@ function AlertDialogTrigger({ asChild, nativeButton, children, ...props }) {
|
|
|
1692
1695
|
...props,
|
|
1693
1696
|
render: (triggerProps) => {
|
|
1694
1697
|
const { nativeButton: _, ...rest } = triggerProps;
|
|
1695
|
-
return
|
|
1698
|
+
return React19.cloneElement(
|
|
1696
1699
|
children,
|
|
1697
1700
|
mergePropsWithRef(rest, children)
|
|
1698
1701
|
);
|
|
@@ -1823,7 +1826,7 @@ function DropdownMenuPortal({ ...props }) {
|
|
|
1823
1826
|
return /* @__PURE__ */ jsx(Menu.Portal, { "data-slot": "dropdown-menu-portal", container, ...props });
|
|
1824
1827
|
}
|
|
1825
1828
|
function DropdownMenuTrigger({ asChild, nativeButton, children, ...props }) {
|
|
1826
|
-
if (asChild &&
|
|
1829
|
+
if (asChild && React19.isValidElement(children)) {
|
|
1827
1830
|
return /* @__PURE__ */ jsx(
|
|
1828
1831
|
Menu.Trigger,
|
|
1829
1832
|
{
|
|
@@ -1832,7 +1835,7 @@ function DropdownMenuTrigger({ asChild, nativeButton, children, ...props }) {
|
|
|
1832
1835
|
...props,
|
|
1833
1836
|
render: (triggerProps) => {
|
|
1834
1837
|
const { nativeButton: _, ...rest } = triggerProps;
|
|
1835
|
-
return
|
|
1838
|
+
return React19.cloneElement(
|
|
1836
1839
|
children,
|
|
1837
1840
|
mergePropsWithRef(rest, children)
|
|
1838
1841
|
);
|
|
@@ -1883,15 +1886,15 @@ function DropdownMenuItem({
|
|
|
1883
1886
|
...props
|
|
1884
1887
|
}) {
|
|
1885
1888
|
const itemClassName = cn(
|
|
1886
|
-
`data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[variant=destructive]:text-destructive
|
|
1889
|
+
`data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[variant=destructive]:text-destructive
|
|
1887
1890
|
data-[variant=destructive]:data-[highlighted]:bg-destructive/10 dark:data-[variant=destructive]:data-[highlighted]:bg-destructive/40
|
|
1888
|
-
data-[variant=destructive]:data-[highlighted]:text-destructive
|
|
1889
|
-
data-[variant=destructive]:*:[svg]:!text-destructive
|
|
1891
|
+
data-[variant=destructive]:data-[highlighted]:text-destructive
|
|
1892
|
+
data-[variant=destructive]:*:[svg]:!text-destructive relative flex cursor-default items-center gap-2
|
|
1890
1893
|
rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none
|
|
1891
1894
|
data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0`,
|
|
1892
1895
|
className
|
|
1893
1896
|
);
|
|
1894
|
-
if (asChild &&
|
|
1897
|
+
if (asChild && React19.isValidElement(children)) {
|
|
1895
1898
|
return /* @__PURE__ */ jsx(
|
|
1896
1899
|
Menu.Item,
|
|
1897
1900
|
{
|
|
@@ -1902,7 +1905,7 @@ function DropdownMenuItem({
|
|
|
1902
1905
|
render: (itemProps) => {
|
|
1903
1906
|
const childProps = children.props;
|
|
1904
1907
|
const itemOnClick = itemProps.onClick;
|
|
1905
|
-
return
|
|
1908
|
+
return React19.cloneElement(children, {
|
|
1906
1909
|
...itemProps,
|
|
1907
1910
|
className: cn(itemClassName, childProps.className),
|
|
1908
1911
|
onClick: (e) => {
|
|
@@ -2075,19 +2078,19 @@ function DropdownMenuSubContent({ className, ...props }) {
|
|
|
2075
2078
|
}
|
|
2076
2079
|
) }) });
|
|
2077
2080
|
}
|
|
2078
|
-
var SheetStackContext =
|
|
2081
|
+
var SheetStackContext = React19.createContext(void 0);
|
|
2079
2082
|
var SHEET_INDENT = 24;
|
|
2080
2083
|
var useSheetStack = () => {
|
|
2081
|
-
return
|
|
2084
|
+
return React19.useContext(SheetStackContext);
|
|
2082
2085
|
};
|
|
2083
|
-
var SheetNestingContext =
|
|
2086
|
+
var SheetNestingContext = React19.createContext({
|
|
2084
2087
|
level: 0,
|
|
2085
2088
|
parentSheetId: null
|
|
2086
2089
|
});
|
|
2087
|
-
var useSheetNesting = () =>
|
|
2088
|
-
var SheetContext =
|
|
2090
|
+
var useSheetNesting = () => React19.useContext(SheetNestingContext);
|
|
2091
|
+
var SheetContext = React19.createContext(void 0);
|
|
2089
2092
|
var useSheet = () => {
|
|
2090
|
-
const context =
|
|
2093
|
+
const context = React19.useContext(SheetContext);
|
|
2091
2094
|
if (!context) {
|
|
2092
2095
|
throw new Error("useSheet must be used within a Sheet");
|
|
2093
2096
|
}
|
|
@@ -2095,23 +2098,23 @@ var useSheet = () => {
|
|
|
2095
2098
|
};
|
|
2096
2099
|
var sheetIdCounter = 0;
|
|
2097
2100
|
function Sheet({ children, sheetId: providedId, ...props }) {
|
|
2098
|
-
const [isOpen, setIsOpen] =
|
|
2101
|
+
const [isOpen, setIsOpen] = React19.useState(props?.open ?? props?.defaultOpen ?? false);
|
|
2099
2102
|
const sheetStack = useSheetStack();
|
|
2100
2103
|
const nesting = useSheetNesting();
|
|
2101
|
-
const sheetIdRef =
|
|
2104
|
+
const sheetIdRef = React19.useRef(providedId ?? `sheet-${++sheetIdCounter}`);
|
|
2102
2105
|
const sheetId = sheetIdRef.current;
|
|
2103
2106
|
const depth = nesting.level;
|
|
2104
|
-
const onOpenChangeRef =
|
|
2107
|
+
const onOpenChangeRef = React19.useRef(props.onOpenChange);
|
|
2105
2108
|
onOpenChangeRef.current = props.onOpenChange;
|
|
2106
|
-
const close =
|
|
2109
|
+
const close = React19.useCallback(() => {
|
|
2107
2110
|
setIsOpen(false);
|
|
2108
2111
|
onOpenChangeRef.current?.(false);
|
|
2109
2112
|
}, []);
|
|
2110
|
-
const registerSheetRef =
|
|
2111
|
-
const unregisterSheetRef =
|
|
2113
|
+
const registerSheetRef = React19.useRef(sheetStack?.registerSheet);
|
|
2114
|
+
const unregisterSheetRef = React19.useRef(sheetStack?.unregisterSheet);
|
|
2112
2115
|
registerSheetRef.current = sheetStack?.registerSheet;
|
|
2113
2116
|
unregisterSheetRef.current = sheetStack?.unregisterSheet;
|
|
2114
|
-
|
|
2117
|
+
React19.useEffect(() => {
|
|
2115
2118
|
if (registerSheetRef.current && isOpen) {
|
|
2116
2119
|
if (document.activeElement instanceof HTMLElement) {
|
|
2117
2120
|
document.activeElement.blur();
|
|
@@ -2120,10 +2123,10 @@ function Sheet({ children, sheetId: providedId, ...props }) {
|
|
|
2120
2123
|
return () => unregisterSheetRef.current?.(sheetId);
|
|
2121
2124
|
}
|
|
2122
2125
|
}, [isOpen, sheetId, depth, close]);
|
|
2123
|
-
|
|
2126
|
+
React19.useEffect(() => {
|
|
2124
2127
|
if (props?.open !== void 0) setIsOpen(props.open);
|
|
2125
2128
|
}, [props?.open]);
|
|
2126
|
-
const handleOpenChange =
|
|
2129
|
+
const handleOpenChange = React19.useCallback((open, _eventDetails) => {
|
|
2127
2130
|
setIsOpen(open);
|
|
2128
2131
|
onOpenChangeRef.current?.(open);
|
|
2129
2132
|
}, []);
|
|
@@ -2143,7 +2146,7 @@ function Sheet({ children, sheetId: providedId, ...props }) {
|
|
|
2143
2146
|
) }) });
|
|
2144
2147
|
}
|
|
2145
2148
|
function SheetTrigger({ asChild, nativeButton, children, ...props }) {
|
|
2146
|
-
if (asChild &&
|
|
2149
|
+
if (asChild && React19.isValidElement(children)) {
|
|
2147
2150
|
return /* @__PURE__ */ jsx(
|
|
2148
2151
|
Dialog$1.Trigger,
|
|
2149
2152
|
{
|
|
@@ -2152,7 +2155,7 @@ function SheetTrigger({ asChild, nativeButton, children, ...props }) {
|
|
|
2152
2155
|
...props,
|
|
2153
2156
|
render: (triggerProps) => {
|
|
2154
2157
|
const { nativeButton: _, ...rest } = triggerProps;
|
|
2155
|
-
return
|
|
2158
|
+
return React19.cloneElement(
|
|
2156
2159
|
children,
|
|
2157
2160
|
mergePropsWithRef(rest, children)
|
|
2158
2161
|
);
|
|
@@ -2163,7 +2166,7 @@ function SheetTrigger({ asChild, nativeButton, children, ...props }) {
|
|
|
2163
2166
|
return /* @__PURE__ */ jsx(Dialog$1.Trigger, { "data-slot": "sheet-trigger", nativeButton, ...props, children });
|
|
2164
2167
|
}
|
|
2165
2168
|
function SheetClose({ asChild, nativeButton, children, ...props }) {
|
|
2166
|
-
if (asChild &&
|
|
2169
|
+
if (asChild && React19.isValidElement(children)) {
|
|
2167
2170
|
return /* @__PURE__ */ jsx(
|
|
2168
2171
|
Dialog$1.Close,
|
|
2169
2172
|
{
|
|
@@ -2172,7 +2175,7 @@ function SheetClose({ asChild, nativeButton, children, ...props }) {
|
|
|
2172
2175
|
...props,
|
|
2173
2176
|
render: (closeProps) => {
|
|
2174
2177
|
const { nativeButton: _, ...rest } = closeProps;
|
|
2175
|
-
return
|
|
2178
|
+
return React19.cloneElement(
|
|
2176
2179
|
children,
|
|
2177
2180
|
mergePropsWithRef(rest, children)
|
|
2178
2181
|
);
|
|
@@ -2289,8 +2292,8 @@ function SheetContent({
|
|
|
2289
2292
|
const topSheetSize = topSheetId ? sheetStack?.getSheetSize(topSheetId) : void 0;
|
|
2290
2293
|
const collapseBaseSize = topSheetSize ? resolvedSide === "left" || resolvedSide === "right" ? topSheetSize.width : topSheetSize.height : void 0;
|
|
2291
2294
|
const pushOffset = getPushOffset(resolvedSide, sheetsAbove, stackMode, collapseBaseSize ?? NESTED_SHEET_WIDTH);
|
|
2292
|
-
const contentRef =
|
|
2293
|
-
|
|
2295
|
+
const contentRef = React19.useRef(null);
|
|
2296
|
+
React19.useLayoutEffect(() => {
|
|
2294
2297
|
if (!isOpen) return;
|
|
2295
2298
|
if (!sheetStack) return;
|
|
2296
2299
|
const el = contentRef.current;
|
|
@@ -2321,11 +2324,11 @@ function SheetContent({
|
|
|
2321
2324
|
duration: durations.normal,
|
|
2322
2325
|
ease: easings.physicalExit
|
|
2323
2326
|
};
|
|
2324
|
-
const isTargetInsideSheet =
|
|
2327
|
+
const isTargetInsideSheet = React19.useCallback((target) => {
|
|
2325
2328
|
if (!target || !(target instanceof HTMLElement)) return false;
|
|
2326
2329
|
return !!target.closest('[data-slot="sheet-content"]');
|
|
2327
2330
|
}, []);
|
|
2328
|
-
const isTargetInsidePopup =
|
|
2331
|
+
const isTargetInsidePopup = React19.useCallback((target) => {
|
|
2329
2332
|
if (!target || !(target instanceof HTMLElement)) return false;
|
|
2330
2333
|
return !!target.closest(
|
|
2331
2334
|
[
|
|
@@ -2338,7 +2341,7 @@ function SheetContent({
|
|
|
2338
2341
|
].join(", ")
|
|
2339
2342
|
);
|
|
2340
2343
|
}, []);
|
|
2341
|
-
|
|
2344
|
+
React19.useEffect(() => {
|
|
2342
2345
|
if (!isOpen) return;
|
|
2343
2346
|
const handlePointerDown = (event) => {
|
|
2344
2347
|
if (sheetsAbove > 0) return;
|
|
@@ -2480,7 +2483,7 @@ function DrawerOverlay({ className, ...props }) {
|
|
|
2480
2483
|
);
|
|
2481
2484
|
}
|
|
2482
2485
|
function DrawerContent({ className, children, ...props }) {
|
|
2483
|
-
return /* @__PURE__ */ jsxs(DrawerPortal, {
|
|
2486
|
+
return /* @__PURE__ */ jsxs(DrawerPortal, { children: [
|
|
2484
2487
|
/* @__PURE__ */ jsx(DrawerOverlay, {}),
|
|
2485
2488
|
/* @__PURE__ */ jsxs(
|
|
2486
2489
|
Drawer$1.Content,
|
|
@@ -2600,7 +2603,7 @@ function Collapsible({
|
|
|
2600
2603
|
}
|
|
2601
2604
|
);
|
|
2602
2605
|
}
|
|
2603
|
-
var CollapsibleTrigger =
|
|
2606
|
+
var CollapsibleTrigger = React19.forwardRef(({ className, asChild, nativeButton, children, ...props }, ref) => {
|
|
2604
2607
|
const triggerClassName = cn(
|
|
2605
2608
|
"group/trigger flex w-full cursor-pointer items-center justify-between text-sm font-medium outline-none transition-colors",
|
|
2606
2609
|
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
|
@@ -2609,7 +2612,7 @@ var CollapsibleTrigger = React20.forwardRef(({ className, asChild, nativeButton,
|
|
|
2609
2612
|
"[&[data-panel-open]_[data-slot=collapsible-icon]]:rotate-180",
|
|
2610
2613
|
className
|
|
2611
2614
|
);
|
|
2612
|
-
if (asChild &&
|
|
2615
|
+
if (asChild && React19.isValidElement(children)) {
|
|
2613
2616
|
return /* @__PURE__ */ jsx(
|
|
2614
2617
|
Collapsible$1.Trigger,
|
|
2615
2618
|
{
|
|
@@ -2620,7 +2623,7 @@ var CollapsibleTrigger = React20.forwardRef(({ className, asChild, nativeButton,
|
|
|
2620
2623
|
render: (triggerProps) => {
|
|
2621
2624
|
const { nativeButton: _, ...rest } = triggerProps;
|
|
2622
2625
|
const childProps = children.props;
|
|
2623
|
-
return
|
|
2626
|
+
return React19.cloneElement(
|
|
2624
2627
|
children,
|
|
2625
2628
|
{
|
|
2626
2629
|
...rest,
|
|
@@ -2644,7 +2647,7 @@ var CollapsibleTrigger = React20.forwardRef(({ className, asChild, nativeButton,
|
|
|
2644
2647
|
);
|
|
2645
2648
|
});
|
|
2646
2649
|
CollapsibleTrigger.displayName = "CollapsibleTrigger";
|
|
2647
|
-
var CollapsiblePanel =
|
|
2650
|
+
var CollapsiblePanel = React19.forwardRef(
|
|
2648
2651
|
({ className, innerClassName, children, ...props }, ref) => {
|
|
2649
2652
|
return /* @__PURE__ */ jsx(
|
|
2650
2653
|
Collapsible$1.Panel,
|
|
@@ -3052,35 +3055,6 @@ function AutocompleteSeparator({
|
|
|
3052
3055
|
}
|
|
3053
3056
|
);
|
|
3054
3057
|
}
|
|
3055
|
-
function AutocompleteGroup({
|
|
3056
|
-
className,
|
|
3057
|
-
...props
|
|
3058
|
-
}) {
|
|
3059
|
-
return /* @__PURE__ */ jsx(
|
|
3060
|
-
Autocomplete$1.Group,
|
|
3061
|
-
{
|
|
3062
|
-
className: cn("[[role=group]+&]:mt-1.5", className),
|
|
3063
|
-
"data-slot": "autocomplete-group",
|
|
3064
|
-
...props
|
|
3065
|
-
}
|
|
3066
|
-
);
|
|
3067
|
-
}
|
|
3068
|
-
function AutocompleteGroupLabel({
|
|
3069
|
-
className,
|
|
3070
|
-
...props
|
|
3071
|
-
}) {
|
|
3072
|
-
return /* @__PURE__ */ jsx(
|
|
3073
|
-
Autocomplete$1.GroupLabel,
|
|
3074
|
-
{
|
|
3075
|
-
className: cn(
|
|
3076
|
-
"px-2 py-1.5 font-medium text-muted-foreground text-xs",
|
|
3077
|
-
className
|
|
3078
|
-
),
|
|
3079
|
-
"data-slot": "autocomplete-group-label",
|
|
3080
|
-
...props
|
|
3081
|
-
}
|
|
3082
|
-
);
|
|
3083
|
-
}
|
|
3084
3058
|
function AutocompleteEmpty({
|
|
3085
3059
|
className,
|
|
3086
3060
|
...props
|
|
@@ -3097,22 +3071,6 @@ function AutocompleteEmpty({
|
|
|
3097
3071
|
}
|
|
3098
3072
|
);
|
|
3099
3073
|
}
|
|
3100
|
-
function AutocompleteList({
|
|
3101
|
-
className,
|
|
3102
|
-
...props
|
|
3103
|
-
}) {
|
|
3104
|
-
return /* @__PURE__ */ jsx(ScrollArea, { scrollbarGutter: true, scrollFade: true, children: /* @__PURE__ */ jsx(
|
|
3105
|
-
Autocomplete$1.List,
|
|
3106
|
-
{
|
|
3107
|
-
className: cn(
|
|
3108
|
-
"not-empty:scroll-py-1 not-empty:p-1 in-data-has-overflow-y:pe-3",
|
|
3109
|
-
className
|
|
3110
|
-
),
|
|
3111
|
-
"data-slot": "autocomplete-list",
|
|
3112
|
-
...props
|
|
3113
|
-
}
|
|
3114
|
-
) });
|
|
3115
|
-
}
|
|
3116
3074
|
function AutocompleteClear({
|
|
3117
3075
|
className,
|
|
3118
3076
|
...props
|
|
@@ -3143,49 +3101,71 @@ function AutocompleteTrigger({
|
|
|
3143
3101
|
}
|
|
3144
3102
|
);
|
|
3145
3103
|
}
|
|
3146
|
-
var
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3104
|
+
var BUTTON_CLASS = "text-muted-foreground/80 hover:text-muted-foreground bg-card size-10 rounded-none shadow-none first:rounded-s-lg last:rounded-e-lg focus-visible:z-10";
|
|
3105
|
+
function FlowZoomPanel({
|
|
3106
|
+
className,
|
|
3107
|
+
position = "bottom-right",
|
|
3108
|
+
fitViewIcon = /* @__PURE__ */ jsx(RiFocus3Line, { className: "size-5", "aria-hidden": "true" }),
|
|
3109
|
+
fitViewOptions
|
|
3110
|
+
}) {
|
|
3111
|
+
const { zoomIn, zoomOut, fitView } = useReactFlow();
|
|
3112
|
+
const onFitView = useCallback(() => {
|
|
3113
|
+
fitView(fitViewOptions);
|
|
3114
|
+
}, [fitView, fitViewOptions]);
|
|
3115
|
+
return /* @__PURE__ */ jsxs(
|
|
3116
|
+
Panel,
|
|
3117
|
+
{
|
|
3118
|
+
"data-slot": "flow-zoom-panel",
|
|
3119
|
+
position,
|
|
3120
|
+
className: cn("inline-flex -space-x-px rounded-md shadow-xs rtl:space-x-reverse", className),
|
|
3121
|
+
children: [
|
|
3122
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "icon", className: BUTTON_CLASS, onClick: () => zoomIn(), "aria-label": "Zoom in", children: /* @__PURE__ */ jsx(RiAddLine, { className: "size-5", "aria-hidden": "true" }) }),
|
|
3123
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "icon", className: BUTTON_CLASS, onClick: () => zoomOut(), "aria-label": "Zoom out", children: /* @__PURE__ */ jsx(RiSubtractLine, { className: "size-5", "aria-hidden": "true" }) }),
|
|
3124
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "icon", className: BUTTON_CLASS, onClick: onFitView, "aria-label": "Fit view", children: fitViewIcon })
|
|
3125
|
+
]
|
|
3126
|
+
}
|
|
3127
|
+
);
|
|
3128
|
+
}
|
|
3150
3129
|
function Command({
|
|
3151
|
-
|
|
3152
|
-
keepHighlight = true,
|
|
3153
|
-
open = true,
|
|
3130
|
+
className,
|
|
3154
3131
|
...props
|
|
3155
3132
|
}) {
|
|
3156
|
-
const AutocompleteAny = Autocomplete;
|
|
3157
3133
|
return /* @__PURE__ */ jsx(
|
|
3158
|
-
|
|
3134
|
+
Command$1,
|
|
3159
3135
|
{
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3136
|
+
className: cn(
|
|
3137
|
+
"flex h-full w-full flex-col overflow-hidden rounded-2xl",
|
|
3138
|
+
className
|
|
3139
|
+
),
|
|
3140
|
+
"data-slot": "command",
|
|
3163
3141
|
...props
|
|
3164
3142
|
}
|
|
3165
3143
|
);
|
|
3166
3144
|
}
|
|
3167
3145
|
function CommandInput({
|
|
3168
3146
|
className,
|
|
3169
|
-
placeholder
|
|
3170
|
-
value,
|
|
3171
|
-
onValueChange,
|
|
3147
|
+
placeholder,
|
|
3172
3148
|
...props
|
|
3173
3149
|
}) {
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
AutocompleteInput,
|
|
3150
|
+
return /* @__PURE__ */ jsx("div", { className: "px-2.5 py-1.5", "data-slot": "command-input-wrapper", children: /* @__PURE__ */ jsxs(
|
|
3151
|
+
"div",
|
|
3177
3152
|
{
|
|
3178
3153
|
className: cn(
|
|
3179
|
-
"
|
|
3154
|
+
"flex items-center gap-2 rounded-lg px-3 text-base",
|
|
3180
3155
|
className
|
|
3181
3156
|
),
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3157
|
+
children: [
|
|
3158
|
+
/* @__PURE__ */ jsx(SearchIcon, { className: "size-4 shrink-0 text-muted-foreground" }),
|
|
3159
|
+
/* @__PURE__ */ jsx(
|
|
3160
|
+
Command$1.Input,
|
|
3161
|
+
{
|
|
3162
|
+
className: "flex h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
3163
|
+
placeholder,
|
|
3164
|
+
"data-slot": "command-input",
|
|
3165
|
+
...props
|
|
3166
|
+
}
|
|
3167
|
+
)
|
|
3168
|
+
]
|
|
3189
3169
|
}
|
|
3190
3170
|
) });
|
|
3191
3171
|
}
|
|
@@ -3194,9 +3174,9 @@ function CommandList({
|
|
|
3194
3174
|
...props
|
|
3195
3175
|
}) {
|
|
3196
3176
|
return /* @__PURE__ */ jsx(
|
|
3197
|
-
|
|
3177
|
+
Command$1.List,
|
|
3198
3178
|
{
|
|
3199
|
-
className: cn("not-empty:scroll-py-2 not-empty:p-2", className),
|
|
3179
|
+
className: cn("not-empty:scroll-py-2 not-empty:p-2 max-h-[300px] overflow-y-auto overflow-x-hidden", className),
|
|
3200
3180
|
"data-slot": "command-list",
|
|
3201
3181
|
...props
|
|
3202
3182
|
}
|
|
@@ -3207,7 +3187,7 @@ function CommandEmpty({
|
|
|
3207
3187
|
...props
|
|
3208
3188
|
}) {
|
|
3209
3189
|
return /* @__PURE__ */ jsx(
|
|
3210
|
-
|
|
3190
|
+
Command$1.Empty,
|
|
3211
3191
|
{
|
|
3212
3192
|
className: cn("not-empty:py-6", className),
|
|
3213
3193
|
"data-slot": "command-empty",
|
|
@@ -3221,29 +3201,17 @@ function CommandGroup({
|
|
|
3221
3201
|
children,
|
|
3222
3202
|
...props
|
|
3223
3203
|
}) {
|
|
3224
|
-
return /* @__PURE__ */
|
|
3225
|
-
|
|
3204
|
+
return /* @__PURE__ */ jsx(
|
|
3205
|
+
Command$1.Group,
|
|
3226
3206
|
{
|
|
3227
|
-
className
|
|
3207
|
+
className: cn(
|
|
3208
|
+
"overflow-hidden text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
3209
|
+
className
|
|
3210
|
+
),
|
|
3211
|
+
heading,
|
|
3228
3212
|
"data-slot": "command-group",
|
|
3229
3213
|
...props,
|
|
3230
|
-
children
|
|
3231
|
-
heading && /* @__PURE__ */ jsx(CommandGroupLabel, { children: heading }),
|
|
3232
|
-
children
|
|
3233
|
-
]
|
|
3234
|
-
}
|
|
3235
|
-
);
|
|
3236
|
-
}
|
|
3237
|
-
function CommandGroupLabel({
|
|
3238
|
-
className,
|
|
3239
|
-
...props
|
|
3240
|
-
}) {
|
|
3241
|
-
return /* @__PURE__ */ jsx(
|
|
3242
|
-
AutocompleteGroupLabel,
|
|
3243
|
-
{
|
|
3244
|
-
className,
|
|
3245
|
-
"data-slot": "command-group-label",
|
|
3246
|
-
...props
|
|
3214
|
+
children
|
|
3247
3215
|
}
|
|
3248
3216
|
);
|
|
3249
3217
|
}
|
|
@@ -3252,20 +3220,23 @@ function CommandItem({
|
|
|
3252
3220
|
...props
|
|
3253
3221
|
}) {
|
|
3254
3222
|
return /* @__PURE__ */ jsx(
|
|
3255
|
-
|
|
3223
|
+
Command$1.Item,
|
|
3256
3224
|
{
|
|
3257
|
-
className: cn(
|
|
3225
|
+
className: cn(
|
|
3226
|
+
"relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
|
|
3227
|
+
className
|
|
3228
|
+
),
|
|
3258
3229
|
"data-slot": "command-item",
|
|
3259
3230
|
...props
|
|
3260
3231
|
}
|
|
3261
3232
|
);
|
|
3262
3233
|
}
|
|
3263
|
-
var ComboboxContext =
|
|
3234
|
+
var ComboboxContext = React19.createContext({
|
|
3264
3235
|
chipsRef: null,
|
|
3265
3236
|
multiple: false
|
|
3266
3237
|
});
|
|
3267
3238
|
function Combobox(props) {
|
|
3268
|
-
const chipsRef =
|
|
3239
|
+
const chipsRef = React19.useRef(null);
|
|
3269
3240
|
return /* @__PURE__ */ jsx(ComboboxContext.Provider, { value: { chipsRef, multiple: !!props.multiple }, children: /* @__PURE__ */ jsx(
|
|
3270
3241
|
Combobox$1.Root,
|
|
3271
3242
|
{
|
|
@@ -3281,7 +3252,7 @@ function ComboboxInput({
|
|
|
3281
3252
|
size,
|
|
3282
3253
|
...props
|
|
3283
3254
|
}) {
|
|
3284
|
-
const { multiple } =
|
|
3255
|
+
const { multiple } = React19.useContext(ComboboxContext);
|
|
3285
3256
|
const sizeValue = size ?? "default";
|
|
3286
3257
|
if (multiple) {
|
|
3287
3258
|
return /* @__PURE__ */ jsx(
|
|
@@ -3304,7 +3275,7 @@ function ComboboxInput({
|
|
|
3304
3275
|
"div",
|
|
3305
3276
|
{
|
|
3306
3277
|
"aria-hidden": "true",
|
|
3307
|
-
className: "[&_svg]:-mx-0.5 pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)]
|
|
3278
|
+
className: "[&_svg]:-mx-0.5 pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)] has-[+[data-size=sm]]:ps-[calc(--spacing(2.5)-1px)] [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:opacity-80",
|
|
3308
3279
|
"data-slot": "combobox-start-addon",
|
|
3309
3280
|
children: startAddon
|
|
3310
3281
|
}
|
|
@@ -3363,7 +3334,7 @@ function ComboboxPopup({
|
|
|
3363
3334
|
sideOffset = 4,
|
|
3364
3335
|
...props
|
|
3365
3336
|
}) {
|
|
3366
|
-
const { chipsRef, multiple } =
|
|
3337
|
+
const { chipsRef, multiple } = React19.useContext(ComboboxContext);
|
|
3367
3338
|
const { container, zIndexClass } = useFloatingOverlayPortalProps();
|
|
3368
3339
|
return /* @__PURE__ */ jsx(Combobox$1.Portal, { container, children: /* @__PURE__ */ jsx(
|
|
3369
3340
|
Combobox$1.Positioner,
|
|
@@ -3441,7 +3412,10 @@ function ComboboxSeparator({
|
|
|
3441
3412
|
}
|
|
3442
3413
|
);
|
|
3443
3414
|
}
|
|
3444
|
-
function ComboboxGroup({
|
|
3415
|
+
function ComboboxGroup({
|
|
3416
|
+
className,
|
|
3417
|
+
...props
|
|
3418
|
+
}) {
|
|
3445
3419
|
return /* @__PURE__ */ jsx(
|
|
3446
3420
|
Combobox$1.Group,
|
|
3447
3421
|
{
|
|
@@ -3451,7 +3425,10 @@ function ComboboxGroup({ className, ...props }) {
|
|
|
3451
3425
|
}
|
|
3452
3426
|
);
|
|
3453
3427
|
}
|
|
3454
|
-
function ComboboxEmpty({
|
|
3428
|
+
function ComboboxEmpty({
|
|
3429
|
+
className,
|
|
3430
|
+
...props
|
|
3431
|
+
}) {
|
|
3455
3432
|
return /* @__PURE__ */ jsx(
|
|
3456
3433
|
Combobox$1.Empty,
|
|
3457
3434
|
{
|
|
@@ -3464,7 +3441,10 @@ function ComboboxEmpty({ className, ...props }) {
|
|
|
3464
3441
|
}
|
|
3465
3442
|
);
|
|
3466
3443
|
}
|
|
3467
|
-
function ComboboxList({
|
|
3444
|
+
function ComboboxList({
|
|
3445
|
+
className,
|
|
3446
|
+
...props
|
|
3447
|
+
}) {
|
|
3468
3448
|
return /* @__PURE__ */ jsx(ScrollArea, { scrollbarGutter: true, scrollFade: true, children: /* @__PURE__ */ jsx(
|
|
3469
3449
|
Combobox$1.List,
|
|
3470
3450
|
{
|
|
@@ -3477,7 +3457,10 @@ function ComboboxList({ className, ...props }) {
|
|
|
3477
3457
|
}
|
|
3478
3458
|
) });
|
|
3479
3459
|
}
|
|
3480
|
-
function ComboboxClear({
|
|
3460
|
+
function ComboboxClear({
|
|
3461
|
+
className,
|
|
3462
|
+
...props
|
|
3463
|
+
}) {
|
|
3481
3464
|
return /* @__PURE__ */ jsx(
|
|
3482
3465
|
Combobox$1.Clear,
|
|
3483
3466
|
{
|
|
@@ -3553,7 +3536,7 @@ function OptionItem({
|
|
|
3553
3536
|
}
|
|
3554
3537
|
);
|
|
3555
3538
|
}
|
|
3556
|
-
var MultiSelect =
|
|
3539
|
+
var MultiSelect = React19.forwardRef(
|
|
3557
3540
|
({
|
|
3558
3541
|
options,
|
|
3559
3542
|
onValueChange,
|
|
@@ -3579,38 +3562,38 @@ var MultiSelect = React20.forwardRef(
|
|
|
3579
3562
|
onClick,
|
|
3580
3563
|
...props
|
|
3581
3564
|
}, ref) => {
|
|
3582
|
-
const [selectedValues, setSelectedValues] =
|
|
3583
|
-
const [isPopoverOpen, setIsPopoverOpen] =
|
|
3584
|
-
const [searchValue, setSearchValue] =
|
|
3585
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
3586
|
-
const multiSelectId =
|
|
3565
|
+
const [selectedValues, setSelectedValues] = React19.useState(defaultValue);
|
|
3566
|
+
const [isPopoverOpen, setIsPopoverOpen] = React19.useState(false);
|
|
3567
|
+
const [searchValue, setSearchValue] = React19.useState("");
|
|
3568
|
+
const [highlightedIndex, setHighlightedIndex] = React19.useState(-1);
|
|
3569
|
+
const multiSelectId = React19.useId();
|
|
3587
3570
|
const listboxId = `${multiSelectId}-listbox`;
|
|
3588
3571
|
const triggerDescriptionId = `${multiSelectId}-description`;
|
|
3589
3572
|
const selectedCountId = `${multiSelectId}-count`;
|
|
3590
3573
|
const searchInputId = `${multiSelectId}-search`;
|
|
3591
|
-
const searchInputRef =
|
|
3592
|
-
const listRef =
|
|
3593
|
-
const prevDefaultValueRef =
|
|
3594
|
-
const isGroupedOptions =
|
|
3574
|
+
const searchInputRef = React19.useRef(null);
|
|
3575
|
+
const listRef = React19.useRef(null);
|
|
3576
|
+
const prevDefaultValueRef = React19.useRef(defaultValue);
|
|
3577
|
+
const isGroupedOptions = React19.useCallback(
|
|
3595
3578
|
(opts) => {
|
|
3596
3579
|
return opts.length > 0 && "heading" in opts[0];
|
|
3597
3580
|
},
|
|
3598
3581
|
[]
|
|
3599
3582
|
);
|
|
3600
|
-
const arraysEqual =
|
|
3583
|
+
const arraysEqual = React19.useCallback((a, b) => {
|
|
3601
3584
|
if (a.length !== b.length) return false;
|
|
3602
3585
|
const sortedA = [...a].sort();
|
|
3603
3586
|
const sortedB = [...b].sort();
|
|
3604
3587
|
return sortedA.every((val, index) => val === sortedB[index]);
|
|
3605
3588
|
}, []);
|
|
3606
|
-
const resetToDefault =
|
|
3589
|
+
const resetToDefault = React19.useCallback(() => {
|
|
3607
3590
|
setSelectedValues(defaultValue);
|
|
3608
3591
|
setIsPopoverOpen(false);
|
|
3609
3592
|
setSearchValue("");
|
|
3610
3593
|
onValueChange(defaultValue);
|
|
3611
3594
|
}, [defaultValue, onValueChange]);
|
|
3612
|
-
const buttonRef =
|
|
3613
|
-
|
|
3595
|
+
const buttonRef = React19.useRef(null);
|
|
3596
|
+
React19.useImperativeHandle(
|
|
3614
3597
|
ref,
|
|
3615
3598
|
() => ({
|
|
3616
3599
|
reset: resetToDefault,
|
|
@@ -3641,8 +3624,8 @@ var MultiSelect = React20.forwardRef(
|
|
|
3641
3624
|
}),
|
|
3642
3625
|
[resetToDefault, selectedValues, onValueChange]
|
|
3643
3626
|
);
|
|
3644
|
-
const [screenSize, setScreenSize] =
|
|
3645
|
-
|
|
3627
|
+
const [screenSize, setScreenSize] = React19.useState("desktop");
|
|
3628
|
+
React19.useEffect(() => {
|
|
3646
3629
|
if (typeof window === "undefined") return;
|
|
3647
3630
|
const handleResize = () => {
|
|
3648
3631
|
const width = window.innerWidth;
|
|
@@ -3691,7 +3674,7 @@ var MultiSelect = React20.forwardRef(
|
|
|
3691
3674
|
};
|
|
3692
3675
|
};
|
|
3693
3676
|
const responsiveSettings = getResponsiveSettings();
|
|
3694
|
-
const getAllOptions =
|
|
3677
|
+
const getAllOptions = React19.useCallback(() => {
|
|
3695
3678
|
if (options.length === 0) return [];
|
|
3696
3679
|
let allOptions;
|
|
3697
3680
|
if (isGroupedOptions(options)) {
|
|
@@ -3721,7 +3704,7 @@ var MultiSelect = React20.forwardRef(
|
|
|
3721
3704
|
}
|
|
3722
3705
|
return deduplicateOptions ? uniqueOptions : allOptions;
|
|
3723
3706
|
}, [options, deduplicateOptions, isGroupedOptions]);
|
|
3724
|
-
const getOptionByValue =
|
|
3707
|
+
const getOptionByValue = React19.useCallback(
|
|
3725
3708
|
(value) => {
|
|
3726
3709
|
const option = getAllOptions().find((option2) => option2.value === value);
|
|
3727
3710
|
if (!option && process.env.NODE_ENV === "development") {
|
|
@@ -3731,7 +3714,7 @@ var MultiSelect = React20.forwardRef(
|
|
|
3731
3714
|
},
|
|
3732
3715
|
[getAllOptions]
|
|
3733
3716
|
);
|
|
3734
|
-
const filteredOptions =
|
|
3717
|
+
const filteredOptions = React19.useMemo(() => {
|
|
3735
3718
|
if (!searchable || !searchValue) return options;
|
|
3736
3719
|
if (options.length === 0) return [];
|
|
3737
3720
|
if (isGroupedOptions(options)) {
|
|
@@ -3746,13 +3729,13 @@ var MultiSelect = React20.forwardRef(
|
|
|
3746
3729
|
(option) => option.label.toLowerCase().includes(searchValue.toLowerCase()) || option.value.toLowerCase().includes(searchValue.toLowerCase())
|
|
3747
3730
|
);
|
|
3748
3731
|
}, [options, searchValue, searchable, isGroupedOptions]);
|
|
3749
|
-
const flatFilteredOptions =
|
|
3732
|
+
const flatFilteredOptions = React19.useMemo(() => {
|
|
3750
3733
|
if (isGroupedOptions(filteredOptions)) {
|
|
3751
3734
|
return filteredOptions.flatMap((group) => group.options);
|
|
3752
3735
|
}
|
|
3753
3736
|
return filteredOptions;
|
|
3754
3737
|
}, [filteredOptions, isGroupedOptions]);
|
|
3755
|
-
const toggleOption =
|
|
3738
|
+
const toggleOption = React19.useCallback(
|
|
3756
3739
|
(optionValue) => {
|
|
3757
3740
|
if (disabled) return;
|
|
3758
3741
|
const option = getOptionByValue(optionValue);
|
|
@@ -3781,7 +3764,7 @@ var MultiSelect = React20.forwardRef(
|
|
|
3781
3764
|
setSelectedValues(newSelectedValues);
|
|
3782
3765
|
onValueChange(newSelectedValues);
|
|
3783
3766
|
};
|
|
3784
|
-
const handleKeyDown =
|
|
3767
|
+
const handleKeyDown = React19.useCallback(
|
|
3785
3768
|
(event) => {
|
|
3786
3769
|
const optionsCount = flatFilteredOptions.length;
|
|
3787
3770
|
if (optionsCount === 0) return;
|
|
@@ -3819,7 +3802,7 @@ var MultiSelect = React20.forwardRef(
|
|
|
3819
3802
|
},
|
|
3820
3803
|
[flatFilteredOptions, highlightedIndex, toggleOption, searchValue, selectedValues, onValueChange]
|
|
3821
3804
|
);
|
|
3822
|
-
|
|
3805
|
+
React19.useEffect(() => {
|
|
3823
3806
|
if (!resetOnDefaultValueChange) return;
|
|
3824
3807
|
const prevDefaultValue = prevDefaultValueRef.current;
|
|
3825
3808
|
if (!arraysEqual(prevDefaultValue, defaultValue)) {
|
|
@@ -3840,17 +3823,17 @@ var MultiSelect = React20.forwardRef(
|
|
|
3840
3823
|
};
|
|
3841
3824
|
};
|
|
3842
3825
|
const widthConstraints = getWidthConstraints();
|
|
3843
|
-
const effectiveDropdownMaxHeight =
|
|
3826
|
+
const effectiveDropdownMaxHeight = React19.useMemo(() => {
|
|
3844
3827
|
if (dropdownMaxHeight) return dropdownMaxHeight;
|
|
3845
3828
|
return screenSize === "mobile" ? "70vh" : "60vh";
|
|
3846
3829
|
}, [dropdownMaxHeight, screenSize]);
|
|
3847
|
-
|
|
3830
|
+
React19.useEffect(() => {
|
|
3848
3831
|
if (!isPopoverOpen) {
|
|
3849
3832
|
setSearchValue("");
|
|
3850
3833
|
setHighlightedIndex(-1);
|
|
3851
3834
|
}
|
|
3852
3835
|
}, [isPopoverOpen]);
|
|
3853
|
-
|
|
3836
|
+
React19.useEffect(() => {
|
|
3854
3837
|
if (isPopoverOpen && searchable && searchInputRef.current) {
|
|
3855
3838
|
const timer = setTimeout(() => {
|
|
3856
3839
|
searchInputRef.current?.focus();
|
|
@@ -3858,10 +3841,10 @@ var MultiSelect = React20.forwardRef(
|
|
|
3858
3841
|
return () => clearTimeout(timer);
|
|
3859
3842
|
}
|
|
3860
3843
|
}, [isPopoverOpen, searchable]);
|
|
3861
|
-
|
|
3844
|
+
React19.useEffect(() => {
|
|
3862
3845
|
setHighlightedIndex(flatFilteredOptions.length > 0 ? 0 : -1);
|
|
3863
3846
|
}, [searchValue, flatFilteredOptions.length]);
|
|
3864
|
-
const totalFilteredCount =
|
|
3847
|
+
const totalFilteredCount = React19.useMemo(() => {
|
|
3865
3848
|
if (isGroupedOptions(filteredOptions)) {
|
|
3866
3849
|
return filteredOptions.reduce((acc, group) => acc + group.options.length, 0);
|
|
3867
3850
|
}
|
|
@@ -4378,8 +4361,8 @@ function Stepper({
|
|
|
4378
4361
|
className,
|
|
4379
4362
|
...props
|
|
4380
4363
|
}) {
|
|
4381
|
-
const [activeStep, setInternalStep] =
|
|
4382
|
-
const setActiveStep =
|
|
4364
|
+
const [activeStep, setInternalStep] = React19.useState(defaultValue);
|
|
4365
|
+
const setActiveStep = React19.useCallback(
|
|
4383
4366
|
(step) => {
|
|
4384
4367
|
if (value === void 0) {
|
|
4385
4368
|
setInternalStep(step);
|
|
@@ -4548,8 +4531,8 @@ function StepperSeparator({ className, ...props }) {
|
|
|
4548
4531
|
}
|
|
4549
4532
|
var MOBILE_BREAKPOINT = 768;
|
|
4550
4533
|
function useIsMobile() {
|
|
4551
|
-
const [isMobile, setIsMobile] =
|
|
4552
|
-
|
|
4534
|
+
const [isMobile, setIsMobile] = React19.useState(false);
|
|
4535
|
+
React19.useEffect(() => {
|
|
4553
4536
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
4554
4537
|
const onChange = () => {
|
|
4555
4538
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
@@ -4566,9 +4549,9 @@ var SIDEBAR_WIDTH = "14rem";
|
|
|
4566
4549
|
var SIDEBAR_WIDTH_MOBILE = "16rem";
|
|
4567
4550
|
var SIDEBAR_WIDTH_ICON = "4rem";
|
|
4568
4551
|
var SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
4569
|
-
var SidebarContext =
|
|
4552
|
+
var SidebarContext = React19.createContext(null);
|
|
4570
4553
|
function useSidebar() {
|
|
4571
|
-
const context =
|
|
4554
|
+
const context = React19.useContext(SidebarContext);
|
|
4572
4555
|
if (!context) {
|
|
4573
4556
|
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
4574
4557
|
}
|
|
@@ -4584,11 +4567,11 @@ function SidebarProvider({
|
|
|
4584
4567
|
...props
|
|
4585
4568
|
}) {
|
|
4586
4569
|
const isMobile = useIsMobile();
|
|
4587
|
-
const [openMobile, setOpenMobile] =
|
|
4588
|
-
const [isHovered, setIsHovered] =
|
|
4589
|
-
const [_open, _setOpen] =
|
|
4570
|
+
const [openMobile, setOpenMobile] = React19.useState(false);
|
|
4571
|
+
const [isHovered, setIsHovered] = React19.useState(false);
|
|
4572
|
+
const [_open, _setOpen] = React19.useState(defaultOpen);
|
|
4590
4573
|
const open = openProp ?? _open;
|
|
4591
|
-
const setOpen =
|
|
4574
|
+
const setOpen = React19.useCallback(
|
|
4592
4575
|
(value) => {
|
|
4593
4576
|
const openState = typeof value === "function" ? value(open) : value;
|
|
4594
4577
|
if (setOpenProp) {
|
|
@@ -4600,10 +4583,10 @@ function SidebarProvider({
|
|
|
4600
4583
|
},
|
|
4601
4584
|
[setOpenProp, open]
|
|
4602
4585
|
);
|
|
4603
|
-
const toggleSidebar =
|
|
4586
|
+
const toggleSidebar = React19.useCallback(() => {
|
|
4604
4587
|
return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
|
|
4605
4588
|
}, [isMobile, setOpen, setOpenMobile]);
|
|
4606
|
-
|
|
4589
|
+
React19.useEffect(() => {
|
|
4607
4590
|
const handleKeyDown = (event) => {
|
|
4608
4591
|
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
4609
4592
|
event.preventDefault();
|
|
@@ -4615,7 +4598,7 @@ function SidebarProvider({
|
|
|
4615
4598
|
}, [toggleSidebar]);
|
|
4616
4599
|
const effectiveOpen = isMobile ? open : isHovered || open;
|
|
4617
4600
|
const state = effectiveOpen ? "expanded" : "collapsed";
|
|
4618
|
-
const contextValue =
|
|
4601
|
+
const contextValue = React19.useMemo(
|
|
4619
4602
|
() => ({
|
|
4620
4603
|
state,
|
|
4621
4604
|
open,
|
|
@@ -5036,7 +5019,7 @@ function SidebarMenuSkeleton({
|
|
|
5036
5019
|
showIcon = false,
|
|
5037
5020
|
...props
|
|
5038
5021
|
}) {
|
|
5039
|
-
const width =
|
|
5022
|
+
const width = React19.useMemo(() => {
|
|
5040
5023
|
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
5041
5024
|
}, []);
|
|
5042
5025
|
return /* @__PURE__ */ jsxs(
|
|
@@ -5186,7 +5169,7 @@ function RangeCalendar({ className, ...props }) {
|
|
|
5186
5169
|
/* @__PURE__ */ jsx(CalendarGridComponent, { isRange: true })
|
|
5187
5170
|
] });
|
|
5188
5171
|
}
|
|
5189
|
-
var AceEditor =
|
|
5172
|
+
var AceEditor = React19.lazy(async () => {
|
|
5190
5173
|
const ace = await import('react-ace');
|
|
5191
5174
|
await import('ace-builds/src-noconflict/mode-json');
|
|
5192
5175
|
await import('ace-builds/src-noconflict/theme-textmate');
|
|
@@ -5335,7 +5318,7 @@ var dockVariants = cva(
|
|
|
5335
5318
|
// Solid themed surface (no glass/blur)
|
|
5336
5319
|
"mx-auto mt-8 flex h-[58px] w-max items-center justify-center gap-2 rounded-2xl border bg-card p-2 shadow"
|
|
5337
5320
|
);
|
|
5338
|
-
var Dock =
|
|
5321
|
+
var Dock = React19__default.forwardRef(
|
|
5339
5322
|
({
|
|
5340
5323
|
className,
|
|
5341
5324
|
children,
|
|
@@ -5347,9 +5330,9 @@ var Dock = React20__default.forwardRef(
|
|
|
5347
5330
|
}, ref) => {
|
|
5348
5331
|
const mouseX = useMotionValue(Infinity);
|
|
5349
5332
|
const renderChildren = () => {
|
|
5350
|
-
return
|
|
5351
|
-
if (
|
|
5352
|
-
return
|
|
5333
|
+
return React19__default.Children.map(children, (child) => {
|
|
5334
|
+
if (React19__default.isValidElement(child) && child.type === DockIcon) {
|
|
5335
|
+
return React19__default.cloneElement(child, {
|
|
5353
5336
|
...child.props,
|
|
5354
5337
|
mouseX,
|
|
5355
5338
|
size: iconSize,
|
|
@@ -5575,9 +5558,9 @@ var MotionGrid = ({
|
|
|
5575
5558
|
}) => {
|
|
5576
5559
|
const [cols, rows] = gridSize;
|
|
5577
5560
|
const frames = useLoadingFrames(cols, rows);
|
|
5578
|
-
const [index, setIndex] =
|
|
5579
|
-
const intervalRef =
|
|
5580
|
-
|
|
5561
|
+
const [index, setIndex] = React19.useState(0);
|
|
5562
|
+
const intervalRef = React19.useRef(null);
|
|
5563
|
+
React19.useEffect(() => {
|
|
5581
5564
|
if (!animate || frames.length === 0) return;
|
|
5582
5565
|
intervalRef.current = setInterval(() => setIndex((i) => (i + 1) % frames.length), duration);
|
|
5583
5566
|
return () => clearInterval(intervalRef.current);
|
|
@@ -5610,7 +5593,7 @@ var MotionGrid = ({
|
|
|
5610
5593
|
);
|
|
5611
5594
|
};
|
|
5612
5595
|
var useLoadingFrames = (cols = 8, rows = 4) => {
|
|
5613
|
-
const loadingFrames =
|
|
5596
|
+
const loadingFrames = React19.useMemo(() => {
|
|
5614
5597
|
const frames = [];
|
|
5615
5598
|
for (let s = 0; s < cols + rows; s++) {
|
|
5616
5599
|
const dots = [];
|
|
@@ -5760,10 +5743,12 @@ function ResponsiveDiagram({ children, targetRatio = 0.95, className }) {
|
|
|
5760
5743
|
const calculateZoom = useCallback(() => {
|
|
5761
5744
|
if (!containerRef.current || !contentRef.current) return;
|
|
5762
5745
|
contentRef.current.style.transform = "scale(1)";
|
|
5763
|
-
const
|
|
5764
|
-
const
|
|
5765
|
-
const
|
|
5766
|
-
const
|
|
5746
|
+
const style = getComputedStyle(containerRef.current);
|
|
5747
|
+
const padH = parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
|
5748
|
+
const containerW = containerRef.current.clientWidth - padH;
|
|
5749
|
+
const contentW = contentRef.current.scrollWidth;
|
|
5750
|
+
const targetW = containerW * targetRatio;
|
|
5751
|
+
const newZoom = contentW > targetW ? targetW / contentW : 1;
|
|
5767
5752
|
setZoom(newZoom);
|
|
5768
5753
|
contentRef.current.style.transform = `scale(${newZoom})`;
|
|
5769
5754
|
}, [targetRatio]);
|
|
@@ -5895,6 +5880,13 @@ function stackReducer(state, action) {
|
|
|
5895
5880
|
newCards[index] = { ...newCards[index], width: action.width };
|
|
5896
5881
|
return { cards: newCards };
|
|
5897
5882
|
}
|
|
5883
|
+
case "SET_DISMISSABLE": {
|
|
5884
|
+
const index = state.cards.findIndex((c) => c.id === action.id);
|
|
5885
|
+
if (index === -1) return state;
|
|
5886
|
+
const newCards = [...state.cards];
|
|
5887
|
+
newCards[index] = { ...newCards[index], dismissable: action.dismissable };
|
|
5888
|
+
return { cards: newCards };
|
|
5889
|
+
}
|
|
5898
5890
|
case "DISMISS": {
|
|
5899
5891
|
const index = state.cards.findIndex((c) => c.id === action.id);
|
|
5900
5892
|
if (index === -1) return state;
|
|
@@ -6011,6 +6003,9 @@ function CardStackProvider({
|
|
|
6011
6003
|
const setWidth = (id, width) => {
|
|
6012
6004
|
dispatch({ type: "SET_WIDTH", id, width });
|
|
6013
6005
|
};
|
|
6006
|
+
const setDismissable = (id, dismissable) => {
|
|
6007
|
+
dispatch({ type: "SET_DISMISSABLE", id, dismissable });
|
|
6008
|
+
};
|
|
6014
6009
|
const dismiss = (id, options) => {
|
|
6015
6010
|
const cascade = options?.cascade ?? true;
|
|
6016
6011
|
dispatch({ type: "DISMISS", id, cascade });
|
|
@@ -6038,6 +6033,7 @@ function CardStackProvider({
|
|
|
6038
6033
|
setTitle,
|
|
6039
6034
|
setDescription,
|
|
6040
6035
|
setWidth,
|
|
6036
|
+
setDismissable,
|
|
6041
6037
|
dismiss,
|
|
6042
6038
|
insertAt
|
|
6043
6039
|
};
|
|
@@ -6047,7 +6043,10 @@ function CardStackProvider({
|
|
|
6047
6043
|
if (event.key === "Escape" && stateRef.current.cards.length > 0) {
|
|
6048
6044
|
event.preventDefault();
|
|
6049
6045
|
event.stopPropagation();
|
|
6050
|
-
|
|
6046
|
+
const topCard = stateRef.current.cards[stateRef.current.cards.length - 1];
|
|
6047
|
+
if (topCard.dismissable !== false) {
|
|
6048
|
+
api.pop();
|
|
6049
|
+
}
|
|
6051
6050
|
}
|
|
6052
6051
|
};
|
|
6053
6052
|
document.addEventListener("keydown", handleEscape, true);
|
|
@@ -6119,6 +6118,7 @@ function useCardInjectedProps(id) {
|
|
|
6119
6118
|
setTitle: (title) => api.setTitle(id, title),
|
|
6120
6119
|
setDescription: (description) => api.setDescription(id, description),
|
|
6121
6120
|
setWidth: (width) => api.setWidth(id, width),
|
|
6121
|
+
setDismissable: (dismissable) => api.setDismissable(id, dismissable),
|
|
6122
6122
|
updateProps: (patch) => api.updateProps(id, patch)
|
|
6123
6123
|
}
|
|
6124
6124
|
}),
|
|
@@ -6263,16 +6263,17 @@ var reducedMotionBackdropVariants = {
|
|
|
6263
6263
|
exit: { opacity: 0, transition: { duration: 0 } }
|
|
6264
6264
|
};
|
|
6265
6265
|
function StackBackdrop({ className, onClick, config: backdropConfig }) {
|
|
6266
|
-
const { config } = useStackContext();
|
|
6266
|
+
const { config, state } = useStackContext();
|
|
6267
6267
|
const api = useCardStack();
|
|
6268
6268
|
const prefersReducedMotion = useReducedMotion();
|
|
6269
|
-
const handleClick =
|
|
6269
|
+
const handleClick = React19.useCallback(() => {
|
|
6270
|
+
if (state.cards.some((c) => c.dismissable === false)) return;
|
|
6270
6271
|
if (onClick) {
|
|
6271
6272
|
onClick();
|
|
6272
6273
|
} else {
|
|
6273
6274
|
api.clear();
|
|
6274
6275
|
}
|
|
6275
|
-
}, [onClick, api]);
|
|
6276
|
+
}, [onClick, api, state.cards]);
|
|
6276
6277
|
const variants2 = prefersReducedMotion ? reducedMotionBackdropVariants : backdropVariants;
|
|
6277
6278
|
const useBlur = backdropConfig?.blur ?? false;
|
|
6278
6279
|
return /* @__PURE__ */ jsx(
|
|
@@ -6341,7 +6342,7 @@ function StackHeader({ card, onClose, className, renderTitle }) {
|
|
|
6341
6342
|
title && /* @__PURE__ */ jsx("h2", { className: cn("text-foreground truncate", styles.title), children: title }),
|
|
6342
6343
|
card.description && /* @__PURE__ */ jsx("p", { className: cn("text-muted-foreground truncate", styles.description), children: card.description })
|
|
6343
6344
|
] }),
|
|
6344
|
-
/* @__PURE__ */ jsx(
|
|
6345
|
+
card.dismissable !== false && /* @__PURE__ */ jsx(
|
|
6345
6346
|
"button",
|
|
6346
6347
|
{
|
|
6347
6348
|
type: "button",
|
|
@@ -6732,11 +6733,15 @@ function StackCardInner({
|
|
|
6732
6733
|
api.dismiss(card.id);
|
|
6733
6734
|
}, [api, card.id]);
|
|
6734
6735
|
const handlePeekClick = useCallback(() => {
|
|
6736
|
+
const cardsAbove = state.cards.slice(index + 1);
|
|
6737
|
+
if (cardsAbove.some((c) => c.dismissable === false)) return;
|
|
6735
6738
|
api.popTo(card.id);
|
|
6736
|
-
}, [api, card.id]);
|
|
6739
|
+
}, [api, card.id, state.cards, index]);
|
|
6737
6740
|
const handlePeekDragDismiss = useCallback(() => {
|
|
6741
|
+
const cardsAbove = state.cards.slice(index + 1);
|
|
6742
|
+
if (cardsAbove.some((c) => c.dismissable === false)) return;
|
|
6738
6743
|
onPeekDragEnd?.(index, true);
|
|
6739
|
-
}, [index, onPeekDragEnd]);
|
|
6744
|
+
}, [index, onPeekDragEnd, state.cards]);
|
|
6740
6745
|
const handlePeekDrag = useCallback(
|
|
6741
6746
|
(offset) => {
|
|
6742
6747
|
onPeekDrag?.(index, offset);
|
|
@@ -7029,6 +7034,8 @@ function CardStackViewport({
|
|
|
7029
7034
|
}, [viewportWidth, cardWidths, cards.length, config.defaultPeekOffset, config.layoutMode]);
|
|
7030
7035
|
const useFullScreen = isMobile || responsiveOffset.shouldCollapse;
|
|
7031
7036
|
const handleDismiss = useCallback(() => {
|
|
7037
|
+
const topCard = api.top();
|
|
7038
|
+
if (topCard?.dismissable === false) return;
|
|
7032
7039
|
api.pop();
|
|
7033
7040
|
}, [api]);
|
|
7034
7041
|
const swipeThreshold = mobile?.gestures?.swipeThreshold ?? Math.max(120, Math.round(viewportWidth * 0.35));
|
|
@@ -7062,6 +7069,11 @@ function CardStackViewport({
|
|
|
7062
7069
|
const handlePeekDragEnd = useCallback(
|
|
7063
7070
|
(cardIndex, shouldDismiss) => {
|
|
7064
7071
|
if (shouldDismiss) {
|
|
7072
|
+
const cardsAbove = cards.slice(cardIndex + 1);
|
|
7073
|
+
if (cardsAbove.some((c) => c.dismissable === false)) {
|
|
7074
|
+
setPeekDrag({ sourceIndex: -1, offset: 0 });
|
|
7075
|
+
return;
|
|
7076
|
+
}
|
|
7065
7077
|
const card = cards[cardIndex];
|
|
7066
7078
|
if (card) {
|
|
7067
7079
|
api.popTo(card.id);
|
|
@@ -7079,7 +7091,7 @@ function CardStackViewport({
|
|
|
7079
7091
|
const defaultBackdrop = /* @__PURE__ */ jsx(StackBackdrop, { className: "pointer-events-auto", config: config2 }, "backdrop");
|
|
7080
7092
|
if (renderBackdrop) {
|
|
7081
7093
|
const customBackdrop = renderBackdrop();
|
|
7082
|
-
return
|
|
7094
|
+
return React19.isValidElement(customBackdrop) ? React19.cloneElement(customBackdrop, { key: "backdrop" }) : defaultBackdrop;
|
|
7083
7095
|
}
|
|
7084
7096
|
return defaultBackdrop;
|
|
7085
7097
|
};
|
|
@@ -7370,6 +7382,481 @@ var toast5 = {
|
|
|
7370
7382
|
warning: showWarningToast
|
|
7371
7383
|
};
|
|
7372
7384
|
|
|
7373
|
-
|
|
7385
|
+
// src/components/org-chart/layout.ts
|
|
7386
|
+
var NODE_WIDTH = 260;
|
|
7387
|
+
var NODE_HEIGHT = 100;
|
|
7388
|
+
var RANK_SEP = 80;
|
|
7389
|
+
var NODE_SEP = 40;
|
|
7390
|
+
var ROOT_KEY = "__root__";
|
|
7391
|
+
function computeLayout(edges) {
|
|
7392
|
+
const edgeById = /* @__PURE__ */ new Map();
|
|
7393
|
+
const childCountMap = /* @__PURE__ */ new Map();
|
|
7394
|
+
const childrenMap = /* @__PURE__ */ new Map();
|
|
7395
|
+
for (const e of edges) {
|
|
7396
|
+
edgeById.set(e.id, e);
|
|
7397
|
+
if (e.parentId) {
|
|
7398
|
+
childCountMap.set(e.parentId, (childCountMap.get(e.parentId) ?? 0) + 1);
|
|
7399
|
+
}
|
|
7400
|
+
const parent = e.parentId ?? ROOT_KEY;
|
|
7401
|
+
const bucket = childrenMap.get(parent);
|
|
7402
|
+
if (bucket) bucket.push(e.id);
|
|
7403
|
+
else childrenMap.set(parent, [e.id]);
|
|
7404
|
+
}
|
|
7405
|
+
for (const children of childrenMap.values()) {
|
|
7406
|
+
children.sort((a, b) => {
|
|
7407
|
+
const nameA = edgeById.get(a)?.displayName?.toLowerCase() ?? "";
|
|
7408
|
+
const nameB = edgeById.get(b)?.displayName?.toLowerCase() ?? "";
|
|
7409
|
+
return nameA.localeCompare(nameB);
|
|
7410
|
+
});
|
|
7411
|
+
}
|
|
7412
|
+
const widthCache = /* @__PURE__ */ new Map();
|
|
7413
|
+
const subtreeWidth = (nodeId) => {
|
|
7414
|
+
if (widthCache.has(nodeId)) return widthCache.get(nodeId);
|
|
7415
|
+
const children = childrenMap.get(nodeId);
|
|
7416
|
+
if (!children || children.length === 0) {
|
|
7417
|
+
widthCache.set(nodeId, NODE_WIDTH);
|
|
7418
|
+
return NODE_WIDTH;
|
|
7419
|
+
}
|
|
7420
|
+
const totalChildWidth = children.reduce((sum, c) => sum + subtreeWidth(c), 0);
|
|
7421
|
+
const gaps = (children.length - 1) * NODE_SEP;
|
|
7422
|
+
const w = Math.max(NODE_WIDTH, totalChildWidth + gaps);
|
|
7423
|
+
widthCache.set(nodeId, w);
|
|
7424
|
+
return w;
|
|
7425
|
+
};
|
|
7426
|
+
const positions = /* @__PURE__ */ new Map();
|
|
7427
|
+
const positionSubtree = (nodeId, centerX, y) => {
|
|
7428
|
+
positions.set(nodeId, { x: centerX, y });
|
|
7429
|
+
const children = childrenMap.get(nodeId);
|
|
7430
|
+
if (!children || children.length === 0) return;
|
|
7431
|
+
const totalWidth = children.reduce((sum, c) => sum + subtreeWidth(c), 0) + (children.length - 1) * NODE_SEP;
|
|
7432
|
+
let currentX = centerX - totalWidth / 2;
|
|
7433
|
+
for (const childId of children) {
|
|
7434
|
+
const childW = subtreeWidth(childId);
|
|
7435
|
+
positionSubtree(childId, currentX + childW / 2, y + NODE_HEIGHT + RANK_SEP);
|
|
7436
|
+
currentX += childW + NODE_SEP;
|
|
7437
|
+
}
|
|
7438
|
+
};
|
|
7439
|
+
const roots = childrenMap.get(ROOT_KEY) ?? [];
|
|
7440
|
+
if (roots.length === 1) {
|
|
7441
|
+
positionSubtree(roots[0], 0, 0);
|
|
7442
|
+
} else {
|
|
7443
|
+
const totalWidth = roots.reduce((sum, r) => sum + subtreeWidth(r), 0) + (roots.length - 1) * NODE_SEP;
|
|
7444
|
+
let currentX = -totalWidth / 2;
|
|
7445
|
+
for (const rootId of roots) {
|
|
7446
|
+
const w = subtreeWidth(rootId);
|
|
7447
|
+
positionSubtree(rootId, currentX + w / 2, 0);
|
|
7448
|
+
currentX += w + NODE_SEP;
|
|
7449
|
+
}
|
|
7450
|
+
}
|
|
7451
|
+
const nodes = edges.map((e) => {
|
|
7452
|
+
const pos = positions.get(e.id);
|
|
7453
|
+
return {
|
|
7454
|
+
id: e.id,
|
|
7455
|
+
type: "orgChartNode",
|
|
7456
|
+
width: NODE_WIDTH,
|
|
7457
|
+
height: NODE_HEIGHT,
|
|
7458
|
+
position: {
|
|
7459
|
+
x: pos.x - NODE_WIDTH / 2,
|
|
7460
|
+
y: pos.y
|
|
7461
|
+
},
|
|
7462
|
+
data: {
|
|
7463
|
+
id: e.id,
|
|
7464
|
+
displayName: e.displayName,
|
|
7465
|
+
avatarUrl: e.avatarUrl,
|
|
7466
|
+
positionTitle: e.positionTitle,
|
|
7467
|
+
parentId: e.parentId,
|
|
7468
|
+
childCount: childCountMap.get(e.id) ?? 0,
|
|
7469
|
+
isRoot: !e.parentId
|
|
7470
|
+
}
|
|
7471
|
+
};
|
|
7472
|
+
});
|
|
7473
|
+
const flowEdges = edges.filter((e) => e.parentId).map((e) => ({
|
|
7474
|
+
id: `edge-${e.parentId}-${e.id}`,
|
|
7475
|
+
source: e.parentId,
|
|
7476
|
+
target: e.id,
|
|
7477
|
+
type: "orgChartEdge"
|
|
7478
|
+
}));
|
|
7479
|
+
return { nodes, edges: flowEdges };
|
|
7480
|
+
}
|
|
7481
|
+
var NodeActionsContext = createContext(null);
|
|
7482
|
+
var OrgChartContext = createContext(null);
|
|
7483
|
+
function OrgChartProvider({ children, editable }) {
|
|
7484
|
+
const [selectedNodeId, setSelectedNodeId] = useState(null);
|
|
7485
|
+
const [draggedNodeId, setDraggedNodeId] = useState(null);
|
|
7486
|
+
const [dropTargetNodeId, setDropTargetNodeId] = useState(null);
|
|
7487
|
+
const selectNode = useCallback((nodeId) => setSelectedNodeId(nodeId), []);
|
|
7488
|
+
const clearSelection = useCallback(() => setSelectedNodeId(null), []);
|
|
7489
|
+
const value = useMemo(
|
|
7490
|
+
() => ({
|
|
7491
|
+
selectedNodeId,
|
|
7492
|
+
selectNode,
|
|
7493
|
+
clearSelection,
|
|
7494
|
+
editable,
|
|
7495
|
+
draggedNodeId,
|
|
7496
|
+
setDraggedNodeId,
|
|
7497
|
+
dropTargetNodeId,
|
|
7498
|
+
setDropTargetNodeId
|
|
7499
|
+
}),
|
|
7500
|
+
[selectedNodeId, selectNode, clearSelection, editable, draggedNodeId, dropTargetNodeId]
|
|
7501
|
+
);
|
|
7502
|
+
return /* @__PURE__ */ jsx(OrgChartContext.Provider, { value, children });
|
|
7503
|
+
}
|
|
7504
|
+
function useOrgChartContext() {
|
|
7505
|
+
const ctx = useContext(OrgChartContext);
|
|
7506
|
+
if (!ctx) throw new Error("useOrgChartContext must be used within OrgChartProvider");
|
|
7507
|
+
return ctx;
|
|
7508
|
+
}
|
|
7509
|
+
function NodeActionsProvider({
|
|
7510
|
+
children,
|
|
7511
|
+
onEditNode,
|
|
7512
|
+
onRemoveNode
|
|
7513
|
+
}) {
|
|
7514
|
+
const value = useMemo(() => ({ onEditNode, onRemoveNode }), [onEditNode, onRemoveNode]);
|
|
7515
|
+
return /* @__PURE__ */ jsx(NodeActionsContext.Provider, { value, children });
|
|
7516
|
+
}
|
|
7517
|
+
function useNodeActions() {
|
|
7518
|
+
const ctx = useContext(NodeActionsContext);
|
|
7519
|
+
if (!ctx) throw new Error("useNodeActions must be used within NodeActionsProvider");
|
|
7520
|
+
return ctx;
|
|
7521
|
+
}
|
|
7522
|
+
function OrgChartEdge({
|
|
7523
|
+
sourceX,
|
|
7524
|
+
sourceY,
|
|
7525
|
+
targetX,
|
|
7526
|
+
targetY,
|
|
7527
|
+
sourcePosition,
|
|
7528
|
+
targetPosition,
|
|
7529
|
+
style = {}
|
|
7530
|
+
}) {
|
|
7531
|
+
const [edgePath] = getSmoothStepPath({
|
|
7532
|
+
sourceX,
|
|
7533
|
+
sourceY,
|
|
7534
|
+
sourcePosition,
|
|
7535
|
+
targetX,
|
|
7536
|
+
targetY,
|
|
7537
|
+
targetPosition,
|
|
7538
|
+
borderRadius: 12
|
|
7539
|
+
});
|
|
7540
|
+
return /* @__PURE__ */ jsx(BaseEdge, { path: edgePath, style });
|
|
7541
|
+
}
|
|
7542
|
+
function OrgChartEmpty({ editable, onAddRoot }) {
|
|
7543
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-card border-border/60 flex flex-col items-center justify-center rounded-xl border py-16", children: [
|
|
7544
|
+
/* @__PURE__ */ jsx("div", { className: "bg-muted mb-4 flex size-14 items-center justify-center rounded-2xl", children: /* @__PURE__ */ jsx(Network, { className: "text-muted-foreground size-7" }) }),
|
|
7545
|
+
/* @__PURE__ */ jsx("h3", { className: "text-foreground text-base font-semibold", children: "No Org Chart Yet" }),
|
|
7546
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-1.5 max-w-sm text-center text-sm", children: "Build your organization hierarchy by adding the first person." }),
|
|
7547
|
+
editable && /* @__PURE__ */ jsxs(Button, { className: "mt-5 gap-1.5", onClick: onAddRoot, children: [
|
|
7548
|
+
/* @__PURE__ */ jsx(UserPlus, { className: "size-3.5" }),
|
|
7549
|
+
"Add First Member"
|
|
7550
|
+
] })
|
|
7551
|
+
] });
|
|
7552
|
+
}
|
|
7553
|
+
|
|
7554
|
+
// src/components/org-chart/org-chart-utils.ts
|
|
7555
|
+
function getInitials(name) {
|
|
7556
|
+
if (!name) return "--";
|
|
7557
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
7558
|
+
if (parts.length === 0) return "--";
|
|
7559
|
+
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
|
7560
|
+
return (parts[0][0] + parts[1][0]).toUpperCase();
|
|
7561
|
+
}
|
|
7562
|
+
function OrgChartNodeComponent({ id, data }) {
|
|
7563
|
+
const { selectedNodeId, dropTargetNodeId, editable } = useOrgChartContext();
|
|
7564
|
+
const { onEditNode, onRemoveNode } = useNodeActions();
|
|
7565
|
+
const isSelected = selectedNodeId === id;
|
|
7566
|
+
const isDropTarget = dropTargetNodeId === id;
|
|
7567
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
7568
|
+
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
7569
|
+
return /* @__PURE__ */ jsxs(
|
|
7570
|
+
"div",
|
|
7571
|
+
{
|
|
7572
|
+
style: { width: NODE_WIDTH },
|
|
7573
|
+
className: cn(
|
|
7574
|
+
"bg-card dark:bg-muted relative rounded-xl border shadow-sm transition-all",
|
|
7575
|
+
"border-border/60",
|
|
7576
|
+
isSelected && "ring-primary ring-2 ring-offset-2 dark:ring-offset-zinc-900",
|
|
7577
|
+
isDropTarget && "ring-primary/50 border-primary scale-105 ring-2"
|
|
7578
|
+
),
|
|
7579
|
+
onMouseEnter: () => setIsHovered(true),
|
|
7580
|
+
onMouseLeave: () => setIsHovered(false),
|
|
7581
|
+
children: [
|
|
7582
|
+
!data.isRoot && /* @__PURE__ */ jsx(Handle, { type: "target", position: Position.Top, className: "!bg-border !size-2 !rounded-full !border-0" }),
|
|
7583
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [
|
|
7584
|
+
/* @__PURE__ */ jsxs(Avatar, { className: "size-10 shrink-0", children: [
|
|
7585
|
+
data.avatarUrl && /* @__PURE__ */ jsx(AvatarImage, { src: data.avatarUrl, alt: data.displayName ?? "" }),
|
|
7586
|
+
/* @__PURE__ */ jsx(AvatarFallback, { className: "bg-primary/10 text-primary text-xs font-medium", children: getInitials(data.displayName) })
|
|
7587
|
+
] }),
|
|
7588
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
7589
|
+
/* @__PURE__ */ jsx("p", { className: "text-foreground truncate text-sm font-semibold", children: data.displayName ?? "Unknown" }),
|
|
7590
|
+
data.positionTitle && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground truncate text-xs", children: data.positionTitle })
|
|
7591
|
+
] }),
|
|
7592
|
+
editable && (isHovered || isMenuOpen) ? /* @__PURE__ */ jsx("div", { className: "nodrag nopan shrink-0", children: /* @__PURE__ */ jsxs(DropdownMenu, { open: isMenuOpen, onOpenChange: setIsMenuOpen, children: [
|
|
7593
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
7594
|
+
Button,
|
|
7595
|
+
{
|
|
7596
|
+
variant: "ghost",
|
|
7597
|
+
size: "icon",
|
|
7598
|
+
className: "size-7 rounded-full",
|
|
7599
|
+
onClick: (e) => e.stopPropagation(),
|
|
7600
|
+
children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-4" })
|
|
7601
|
+
}
|
|
7602
|
+
) }),
|
|
7603
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", side: "right", className: "translate-x-1 -translate-y-3.5", children: [
|
|
7604
|
+
/* @__PURE__ */ jsxs(
|
|
7605
|
+
DropdownMenuItem,
|
|
7606
|
+
{
|
|
7607
|
+
onClick: (e) => {
|
|
7608
|
+
e.stopPropagation();
|
|
7609
|
+
setIsMenuOpen(false);
|
|
7610
|
+
onEditNode(data);
|
|
7611
|
+
},
|
|
7612
|
+
children: [
|
|
7613
|
+
/* @__PURE__ */ jsx(Pencil, { className: "mr-2 size-3.5" }),
|
|
7614
|
+
"Edit Position"
|
|
7615
|
+
]
|
|
7616
|
+
}
|
|
7617
|
+
),
|
|
7618
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
7619
|
+
/* @__PURE__ */ jsxs(
|
|
7620
|
+
DropdownMenuItem,
|
|
7621
|
+
{
|
|
7622
|
+
className: "text-destructive hover:bg-destructive/10 focus:bg-destructive/10 hover:text-destructive\n focus:text-destructive data-[highlighted]:bg-destructive/10 data-[highlighted]:text-destructive",
|
|
7623
|
+
onClick: (e) => {
|
|
7624
|
+
e.stopPropagation();
|
|
7625
|
+
setIsMenuOpen(false);
|
|
7626
|
+
onRemoveNode(data);
|
|
7627
|
+
},
|
|
7628
|
+
children: [
|
|
7629
|
+
/* @__PURE__ */ jsx(Trash2, { className: "mr-2 size-3.5" }),
|
|
7630
|
+
"Remove from Chart"
|
|
7631
|
+
]
|
|
7632
|
+
}
|
|
7633
|
+
)
|
|
7634
|
+
] })
|
|
7635
|
+
] }) }) : data.childCount > 0 && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "shrink-0 text-[10px]", children: data.childCount })
|
|
7636
|
+
] }),
|
|
7637
|
+
/* @__PURE__ */ jsx(Handle, { type: "source", position: Position.Bottom, className: "!bg-border !size-2 !rounded-full !border-0" })
|
|
7638
|
+
]
|
|
7639
|
+
}
|
|
7640
|
+
);
|
|
7641
|
+
}
|
|
7642
|
+
var OrgChartNodeMemo = memo(OrgChartNodeComponent);
|
|
7643
|
+
var FIT_VIEW_OPTIONS = { padding: 0.12 };
|
|
7644
|
+
function getDescendantIds(nodeId, nodes) {
|
|
7645
|
+
const descendants = /* @__PURE__ */ new Set();
|
|
7646
|
+
const queue = [nodeId];
|
|
7647
|
+
while (queue.length > 0) {
|
|
7648
|
+
const current = queue.pop();
|
|
7649
|
+
for (const n of nodes) {
|
|
7650
|
+
if (n.data.parentId === current && !descendants.has(n.id)) {
|
|
7651
|
+
descendants.add(n.id);
|
|
7652
|
+
queue.push(n.id);
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7655
|
+
}
|
|
7656
|
+
return descendants;
|
|
7657
|
+
}
|
|
7658
|
+
function mergeWithMeasured(prev, layoutNodes) {
|
|
7659
|
+
const prevMap = new Map(prev.map((n) => [n.id, n]));
|
|
7660
|
+
return layoutNodes.map((n) => {
|
|
7661
|
+
const existing = prevMap.get(n.id);
|
|
7662
|
+
if (!existing) return n;
|
|
7663
|
+
return existing.data.isRoot !== n.data.isRoot ? n : { ...n, measured: existing.measured };
|
|
7664
|
+
});
|
|
7665
|
+
}
|
|
7666
|
+
function OrgChartInner({
|
|
7667
|
+
className,
|
|
7668
|
+
edges: controlledEdges,
|
|
7669
|
+
defaultEdges,
|
|
7670
|
+
isLoading = false,
|
|
7671
|
+
editable = true,
|
|
7672
|
+
onReparent,
|
|
7673
|
+
onAddToChart,
|
|
7674
|
+
onEditNode,
|
|
7675
|
+
onRemoveNode,
|
|
7676
|
+
onReparentSuccess,
|
|
7677
|
+
onReparentError
|
|
7678
|
+
}) {
|
|
7679
|
+
const isControlled = controlledEdges !== void 0;
|
|
7680
|
+
const {
|
|
7681
|
+
selectNode,
|
|
7682
|
+
clearSelection,
|
|
7683
|
+
setDraggedNodeId,
|
|
7684
|
+
setDropTargetNodeId
|
|
7685
|
+
} = useOrgChartContext();
|
|
7686
|
+
const [internalEdges, setInternalEdges] = useState(defaultEdges ?? []);
|
|
7687
|
+
const defaultEdgesHash = useMemo(
|
|
7688
|
+
() => defaultEdges?.map((e) => `${e.id}:${e.parentId}:${e.positionTitle ?? ""}:${e.displayName ?? ""}`).join(",") ?? "",
|
|
7689
|
+
[defaultEdges]
|
|
7690
|
+
);
|
|
7691
|
+
useEffect(() => {
|
|
7692
|
+
if (!isControlled && defaultEdges) {
|
|
7693
|
+
setInternalEdges(defaultEdges);
|
|
7694
|
+
}
|
|
7695
|
+
}, [defaultEdgesHash]);
|
|
7696
|
+
const apiEdges = controlledEdges ?? internalEdges;
|
|
7697
|
+
const layout = useMemo(() => apiEdges.length > 0 ? computeLayout(apiEdges) : null, [apiEdges]);
|
|
7698
|
+
const layoutNodes = layout?.nodes ?? [];
|
|
7699
|
+
const layoutEdges = layout?.edges ?? [];
|
|
7700
|
+
const isEmpty = apiEdges.length === 0 && !isLoading;
|
|
7701
|
+
const { fitView, getIntersectingNodes } = useReactFlow();
|
|
7702
|
+
const [nodes, setNodes, onNodesChange] = useNodesState([]);
|
|
7703
|
+
const [rfEdges, setRfEdges, onEdgesChange] = useEdgesState([]);
|
|
7704
|
+
const nodesHash = useMemo(
|
|
7705
|
+
() => layoutNodes.map((n) => `${n.id}:${n.data.parentId ?? ""}:${n.data.positionTitle ?? ""}:${n.data.displayName ?? ""}`).join(","),
|
|
7706
|
+
[layoutNodes]
|
|
7707
|
+
);
|
|
7708
|
+
const edgesHash = useMemo(() => layoutEdges.map((e) => `${e.id}:${e.source}:${e.target}`).join(","), [layoutEdges]);
|
|
7709
|
+
const fitViewRef = useRef(fitView);
|
|
7710
|
+
fitViewRef.current = fitView;
|
|
7711
|
+
useEffect(() => {
|
|
7712
|
+
setNodes((prev) => mergeWithMeasured(prev, layoutNodes));
|
|
7713
|
+
setRfEdges(layoutEdges);
|
|
7714
|
+
const raf = requestAnimationFrame(() => fitViewRef.current(FIT_VIEW_OPTIONS));
|
|
7715
|
+
return () => cancelAnimationFrame(raf);
|
|
7716
|
+
}, [nodesHash, edgesHash]);
|
|
7717
|
+
const draggedNodeRef = useRef(null);
|
|
7718
|
+
const dropTargetIdRef = useRef(null);
|
|
7719
|
+
const nodeTypes = useMemo(() => ({ orgChartNode: OrgChartNodeMemo }), []);
|
|
7720
|
+
const edgeTypes = useMemo(() => ({ orgChartEdge: OrgChartEdge }), []);
|
|
7721
|
+
const onNodeDragStart = useCallback(
|
|
7722
|
+
(_, node) => {
|
|
7723
|
+
if (!editable) return;
|
|
7724
|
+
draggedNodeRef.current = node.id;
|
|
7725
|
+
setDraggedNodeId(node.id);
|
|
7726
|
+
},
|
|
7727
|
+
[editable, setDraggedNodeId]
|
|
7728
|
+
);
|
|
7729
|
+
const onNodeDrag = useCallback(
|
|
7730
|
+
(_, node) => {
|
|
7731
|
+
if (!editable || !draggedNodeRef.current) return;
|
|
7732
|
+
const intersecting = getIntersectingNodes(node);
|
|
7733
|
+
const target = intersecting.find((n) => n.id !== node.id);
|
|
7734
|
+
const targetId = target?.id ?? null;
|
|
7735
|
+
if (targetId === dropTargetIdRef.current) return;
|
|
7736
|
+
dropTargetIdRef.current = targetId;
|
|
7737
|
+
setDropTargetNodeId(targetId);
|
|
7738
|
+
},
|
|
7739
|
+
[editable, getIntersectingNodes, setDropTargetNodeId]
|
|
7740
|
+
);
|
|
7741
|
+
const applyOptimisticReparent = useCallback((childId, newParentId) => {
|
|
7742
|
+
setInternalEdges(
|
|
7743
|
+
(prev) => prev.map((e) => e.id === childId ? { ...e, parentId: newParentId } : e)
|
|
7744
|
+
);
|
|
7745
|
+
}, []);
|
|
7746
|
+
const snapBack = useCallback(() => {
|
|
7747
|
+
setNodes((prev) => mergeWithMeasured(prev, layoutNodes));
|
|
7748
|
+
}, [layoutNodes, setNodes]);
|
|
7749
|
+
const onNodeDragStop = useCallback(
|
|
7750
|
+
async (_, _node) => {
|
|
7751
|
+
if (!editable || !draggedNodeRef.current) return;
|
|
7752
|
+
const childId = draggedNodeRef.current;
|
|
7753
|
+
const newParentId = dropTargetIdRef.current;
|
|
7754
|
+
draggedNodeRef.current = null;
|
|
7755
|
+
dropTargetIdRef.current = null;
|
|
7756
|
+
setDraggedNodeId(null);
|
|
7757
|
+
setDropTargetNodeId(null);
|
|
7758
|
+
if (!newParentId || newParentId === childId) {
|
|
7759
|
+
snapBack();
|
|
7760
|
+
return;
|
|
7761
|
+
}
|
|
7762
|
+
if (getDescendantIds(childId, layoutNodes).has(newParentId)) {
|
|
7763
|
+
onReparentError?.("Cannot create circular reporting chain");
|
|
7764
|
+
snapBack();
|
|
7765
|
+
return;
|
|
7766
|
+
}
|
|
7767
|
+
const draggedData = layoutNodes.find((n) => n.id === childId)?.data;
|
|
7768
|
+
if (!draggedData || newParentId === draggedData.parentId) {
|
|
7769
|
+
snapBack();
|
|
7770
|
+
return;
|
|
7771
|
+
}
|
|
7772
|
+
const targetName = layoutNodes.find((n) => n.id === newParentId)?.data.displayName;
|
|
7773
|
+
const preserve = { positionTitle: draggedData.positionTitle };
|
|
7774
|
+
if (!isControlled) {
|
|
7775
|
+
const snapshotEdges = internalEdges;
|
|
7776
|
+
applyOptimisticReparent(childId, newParentId);
|
|
7777
|
+
try {
|
|
7778
|
+
await onReparent?.(childId, newParentId, preserve);
|
|
7779
|
+
onReparentSuccess?.(draggedData.displayName ?? "Member", targetName ?? "new manager");
|
|
7780
|
+
} catch (err) {
|
|
7781
|
+
console.error("[OrgChart] reparent failed", err);
|
|
7782
|
+
setInternalEdges(snapshotEdges);
|
|
7783
|
+
onReparentError?.("Failed to update reporting line");
|
|
7784
|
+
}
|
|
7785
|
+
} else {
|
|
7786
|
+
snapBack();
|
|
7787
|
+
try {
|
|
7788
|
+
await onReparent?.(childId, newParentId, preserve);
|
|
7789
|
+
onReparentSuccess?.(draggedData.displayName ?? "Member", targetName ?? "new manager");
|
|
7790
|
+
} catch (err) {
|
|
7791
|
+
console.error("[OrgChart] reparent failed", err);
|
|
7792
|
+
onReparentError?.("Failed to update reporting line");
|
|
7793
|
+
}
|
|
7794
|
+
}
|
|
7795
|
+
},
|
|
7796
|
+
[editable, isControlled, internalEdges, layoutNodes, onReparent, onReparentSuccess, onReparentError, applyOptimisticReparent, snapBack, setDraggedNodeId, setDropTargetNodeId]
|
|
7797
|
+
);
|
|
7798
|
+
const onNodeClick = useCallback((_, node) => selectNode(node.id), [selectNode]);
|
|
7799
|
+
const onPaneClick = useCallback(() => clearSelection(), [clearSelection]);
|
|
7800
|
+
const handleEditNode = useCallback(
|
|
7801
|
+
(nodeData) => onEditNode?.(nodeData),
|
|
7802
|
+
[onEditNode]
|
|
7803
|
+
);
|
|
7804
|
+
const handleRemoveNode = useCallback(
|
|
7805
|
+
(nodeData) => onRemoveNode?.(nodeData),
|
|
7806
|
+
[onRemoveNode]
|
|
7807
|
+
);
|
|
7808
|
+
if (isLoading) {
|
|
7809
|
+
return /* @__PURE__ */ jsx("div", { className: "bg-card border-border/60 flex items-center justify-center rounded-xl border p-16", children: /* @__PURE__ */ jsx(Loader2, { className: "text-muted-foreground size-6 animate-spin" }) });
|
|
7810
|
+
}
|
|
7811
|
+
if (isEmpty) {
|
|
7812
|
+
return /* @__PURE__ */ jsx(OrgChartEmpty, { editable, onAddRoot: onAddToChart ?? (() => {
|
|
7813
|
+
}) });
|
|
7814
|
+
}
|
|
7815
|
+
return /* @__PURE__ */ jsx(NodeActionsProvider, { onEditNode: handleEditNode, onRemoveNode: handleRemoveNode, children: /* @__PURE__ */ jsx("div", { className: cn("border-border/60 h-[600px] overflow-hidden rounded-xl border", className), children: /* @__PURE__ */ jsxs(
|
|
7816
|
+
ReactFlow,
|
|
7817
|
+
{
|
|
7818
|
+
nodes,
|
|
7819
|
+
edges: rfEdges,
|
|
7820
|
+
onNodesChange,
|
|
7821
|
+
onEdgesChange,
|
|
7822
|
+
onNodeClick,
|
|
7823
|
+
proOptions: { hideAttribution: true },
|
|
7824
|
+
onPaneClick,
|
|
7825
|
+
onNodeDragStart,
|
|
7826
|
+
onNodeDrag,
|
|
7827
|
+
onNodeDragStop,
|
|
7828
|
+
nodeTypes,
|
|
7829
|
+
edgeTypes,
|
|
7830
|
+
fitView: true,
|
|
7831
|
+
fitViewOptions: FIT_VIEW_OPTIONS,
|
|
7832
|
+
minZoom: 0.3,
|
|
7833
|
+
maxZoom: 1.5,
|
|
7834
|
+
nodesDraggable: editable,
|
|
7835
|
+
nodesConnectable: false,
|
|
7836
|
+
elementsSelectable: true,
|
|
7837
|
+
selectNodesOnDrag: false,
|
|
7838
|
+
panOnDrag: true,
|
|
7839
|
+
zoomOnScroll: true,
|
|
7840
|
+
preventScrolling: true,
|
|
7841
|
+
style: {
|
|
7842
|
+
"--xy-background-pattern-dots-color-default": "var(--color-border)",
|
|
7843
|
+
"--xy-edge-stroke-width-default": 2,
|
|
7844
|
+
"--xy-edge-stroke-default": "var(--color-border)",
|
|
7845
|
+
"--xy-edge-stroke-selected-default": "var(--color-foreground)",
|
|
7846
|
+
"--xy-attribution-background-color-default": "transparent"
|
|
7847
|
+
},
|
|
7848
|
+
attributionPosition: "bottom-left",
|
|
7849
|
+
children: [
|
|
7850
|
+
/* @__PURE__ */ jsx(Background, { variant: BackgroundVariant.Dots, gap: 20, size: 2 }),
|
|
7851
|
+
/* @__PURE__ */ jsx(FlowZoomPanel, { fitViewOptions: FIT_VIEW_OPTIONS })
|
|
7852
|
+
]
|
|
7853
|
+
}
|
|
7854
|
+
) }) });
|
|
7855
|
+
}
|
|
7856
|
+
function OrgChart(props) {
|
|
7857
|
+
return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(OrgChartProvider, { editable: props.editable ?? true, children: /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(OrgChartInner, { ...props }) }) }) });
|
|
7858
|
+
}
|
|
7859
|
+
|
|
7860
|
+
export { Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, Autocomplete, AutocompleteEmpty, AutocompleteInput, AutocompleteItem, AutocompletePopup, AutocompleteSeparator, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardStackProvider, CardStackViewport, CardTitle, Checkbox, CheckboxGroup, Collapsible, CollapsiblePanel as CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxList, ComboboxSeparator, ComboboxTrigger, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, DEFAULT_ANIMATION_CONFIG, DeferredCardContent, Dialog, DialogBackdrop, DialogClose, DialogPopup as DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogPortal, DialogTitle, DialogTrigger, Dock, DockIcon, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Field, FieldRow, FlickeringGrid, FlowZoomPanel, Form, FormControl, FormControl2 as FormControlComponent, FormDescription, FormField, FormItem, FormLabel, FormMessage, Input, InputGroup, InputGroupAddon, InputGroupInput, InputGroupText, InputGroupTextarea, JsonEditor, JsonInput, Label, ModalPortalScope, MotionGrid, MultiSelect, OrgChart, PORTAL_ROOT_ID, PageHeader, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PortalRoot, Progress, ProgressiveBlur, ProgressiveBlurScrollContainer, Radio, RadioGroup, Radio as RadioGroupItem, RangeCalendar, RecordPicker, ResizableHandle, ResizablePanel, ResizablePanelGroup, ResponsiveDiagram, ScrollArea, ScrollBar, Select, SelectPopup as SelectContent, SelectFieldItem, SelectGroup, SelectGroupLabel, SelectItem, SelectGroupLabel as SelectLabel, SelectPopup, SelectRichItem, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarSeparator, SidebarTrigger, Skeleton, Slot, Slottable, StackBackdrop, StackCard, StackHeader, StackHeaderSlot, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperSeparator, StepperTitle, StepperTrigger, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tags, TagsContent, TagsEmpty, TagsGroup, TagsInput, TagsItem, TagsList, TagsTrigger, TagsValue, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UnlinkButton, alertVariants, backdropVariants, badgeVariants, buttonVariants, calculateResponsiveOffset, cardVariants, cn, composeRefs, createCardVariants, createOffsetTransition, createReducedMotionVariants, dockVariants, durations, easings, getCardOffset, getCardZIndex, getCascadeOffset, getResponsiveCardOffset, getSideBySideOffset, getVisibleCardIndices, isCardVisible, mergeProps, normalizeWidth, parseWidthToPixels, peekDragSpring, peekHoverSpring, peekSlideSpring, reducedMotionBackdropVariants, showErrorToast, showInfoToast, showSuccessToast, showWarningToast, snapBackSpring, springs, swipeDismissTransition, toast5 as toast, transitions, useCardIndex, useCardInjectedProps, useCardReady, useCardStack, useControllableState, useFloatingOverlayPortalProps, useFormField, useInModalOverlay, useIsMobile2 as useIsMobile, useIsTopCard, usePeekGestures, usePortalContainer, usePortalContext, useRootPortalContainer, useSidebar, useStackCards, useStackContext, useStackGestures, useStackLayoutMode, useStackResponsive, validateJson, variants };
|
|
7374
7861
|
//# sourceMappingURL=index.js.map
|
|
7375
7862
|
//# sourceMappingURL=index.js.map
|