@constructive-io/ui 0.2.0 → 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/card.d.ts +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/combobox.js +1 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/dropdown-menu.js +3 -3
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/input-group.js +1 -1
- package/dist/components/input-group.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/record-picker.js +2 -2
- package/dist/components/record-picker.js.map +1 -1
- package/dist/index.cjs +519 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -1
- package/dist/index.d.ts +61 -1
- package/dist/index.js +511 -9
- package/dist/index.js.map +1 -1
- package/package.json +13 -2
package/dist/index.cjs
CHANGED
|
@@ -30,15 +30,17 @@ var collapsible = require('@base-ui/react/collapsible');
|
|
|
30
30
|
var ResizablePrimitive = require('react-resizable-panels');
|
|
31
31
|
var avatar = require('@base-ui/react/avatar');
|
|
32
32
|
var autocomplete = require('@base-ui/react/autocomplete');
|
|
33
|
+
var react$1 = require('@xyflow/react');
|
|
34
|
+
var react$2 = require('@remixicon/react');
|
|
33
35
|
var cmdk = require('cmdk');
|
|
34
36
|
var combobox = require('@base-ui/react/combobox');
|
|
35
|
-
var react$1 = require('@remixicon/react');
|
|
36
37
|
var matchSorter = require('match-sorter');
|
|
37
38
|
var date = require('@internationalized/date');
|
|
38
39
|
var reactAriaComponents = require('react-aria-components');
|
|
39
40
|
var sonner = require('sonner');
|
|
40
41
|
var reactDom = require('react-dom');
|
|
41
|
-
var react$
|
|
42
|
+
var react$3 = require('@use-gesture/react');
|
|
43
|
+
require('@xyflow/react/dist/style.css');
|
|
42
44
|
|
|
43
45
|
function _interopNamespace(e) {
|
|
44
46
|
if (e && e.__esModule) return e;
|
|
@@ -586,7 +588,7 @@ var Checkbox = React19__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
|
586
588
|
{
|
|
587
589
|
ref,
|
|
588
590
|
className: cn(
|
|
589
|
-
"relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-[4px] border border-input bg-background bg-clip-padding
|
|
591
|
+
"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",
|
|
590
592
|
className
|
|
591
593
|
),
|
|
592
594
|
"data-slot": "checkbox",
|
|
@@ -1174,7 +1176,7 @@ function InputGroup({ className, ...props }) {
|
|
|
1174
1176
|
"div",
|
|
1175
1177
|
{
|
|
1176
1178
|
className: cn(
|
|
1177
|
-
"relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background bg-clip-padding text-base
|
|
1179
|
+
"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)]",
|
|
1178
1180
|
className
|
|
1179
1181
|
),
|
|
1180
1182
|
"data-slot": "input-group",
|
|
@@ -1906,10 +1908,10 @@ function DropdownMenuItem({
|
|
|
1906
1908
|
...props
|
|
1907
1909
|
}) {
|
|
1908
1910
|
const itemClassName = cn(
|
|
1909
|
-
`data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[variant=destructive]:text-destructive
|
|
1911
|
+
`data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[variant=destructive]:text-destructive
|
|
1910
1912
|
data-[variant=destructive]:data-[highlighted]:bg-destructive/10 dark:data-[variant=destructive]:data-[highlighted]:bg-destructive/40
|
|
1911
|
-
data-[variant=destructive]:data-[highlighted]:text-destructive
|
|
1912
|
-
data-[variant=destructive]:*:[svg]:!text-destructive
|
|
1913
|
+
data-[variant=destructive]:data-[highlighted]:text-destructive
|
|
1914
|
+
data-[variant=destructive]:*:[svg]:!text-destructive relative flex cursor-default items-center gap-2
|
|
1913
1915
|
rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none
|
|
1914
1916
|
data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0`,
|
|
1915
1917
|
className
|
|
@@ -3121,6 +3123,31 @@ function AutocompleteTrigger({
|
|
|
3121
3123
|
}
|
|
3122
3124
|
);
|
|
3123
3125
|
}
|
|
3126
|
+
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";
|
|
3127
|
+
function FlowZoomPanel({
|
|
3128
|
+
className,
|
|
3129
|
+
position = "bottom-right",
|
|
3130
|
+
fitViewIcon = /* @__PURE__ */ jsxRuntime.jsx(react$2.RiFocus3Line, { className: "size-5", "aria-hidden": "true" }),
|
|
3131
|
+
fitViewOptions
|
|
3132
|
+
}) {
|
|
3133
|
+
const { zoomIn, zoomOut, fitView } = react$1.useReactFlow();
|
|
3134
|
+
const onFitView = React19.useCallback(() => {
|
|
3135
|
+
fitView(fitViewOptions);
|
|
3136
|
+
}, [fitView, fitViewOptions]);
|
|
3137
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3138
|
+
react$1.Panel,
|
|
3139
|
+
{
|
|
3140
|
+
"data-slot": "flow-zoom-panel",
|
|
3141
|
+
position,
|
|
3142
|
+
className: cn("inline-flex -space-x-px rounded-md shadow-xs rtl:space-x-reverse", className),
|
|
3143
|
+
children: [
|
|
3144
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", size: "icon", className: BUTTON_CLASS, onClick: () => zoomIn(), "aria-label": "Zoom in", children: /* @__PURE__ */ jsxRuntime.jsx(react$2.RiAddLine, { className: "size-5", "aria-hidden": "true" }) }),
|
|
3145
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", size: "icon", className: BUTTON_CLASS, onClick: () => zoomOut(), "aria-label": "Zoom out", children: /* @__PURE__ */ jsxRuntime.jsx(react$2.RiSubtractLine, { className: "size-5", "aria-hidden": "true" }) }),
|
|
3146
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", size: "icon", className: BUTTON_CLASS, onClick: onFitView, "aria-label": "Fit view", children: fitViewIcon })
|
|
3147
|
+
]
|
|
3148
|
+
}
|
|
3149
|
+
);
|
|
3150
|
+
}
|
|
3124
3151
|
function Command({
|
|
3125
3152
|
className,
|
|
3126
3153
|
...props
|
|
@@ -3270,7 +3297,7 @@ function ComboboxInput({
|
|
|
3270
3297
|
"div",
|
|
3271
3298
|
{
|
|
3272
3299
|
"aria-hidden": "true",
|
|
3273
|
-
className: "[&_svg]:-mx-0.5 pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)]
|
|
3300
|
+
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",
|
|
3274
3301
|
"data-slot": "combobox-start-addon",
|
|
3275
3302
|
children: startAddon
|
|
3276
3303
|
}
|
|
@@ -4255,7 +4282,7 @@ function RecordPicker({
|
|
|
4255
4282
|
);
|
|
4256
4283
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
4257
4284
|
/* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { children: [
|
|
4258
|
-
/* @__PURE__ */ jsxRuntime.jsx(InputGroupAddon, { children: /* @__PURE__ */ jsxRuntime.jsx(react$
|
|
4285
|
+
/* @__PURE__ */ jsxRuntime.jsx(InputGroupAddon, { children: /* @__PURE__ */ jsxRuntime.jsx(react$2.RiSearchLine, {}) }),
|
|
4259
4286
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4260
4287
|
InputGroupInput,
|
|
4261
4288
|
{
|
|
@@ -4299,7 +4326,7 @@ function RecordPicker({
|
|
|
4299
4326
|
children: label
|
|
4300
4327
|
}
|
|
4301
4328
|
),
|
|
4302
|
-
isLinking && /* @__PURE__ */ jsxRuntime.jsx(react$
|
|
4329
|
+
isLinking && /* @__PURE__ */ jsxRuntime.jsx(react$2.RiLoader4Line, { className: "text-muted-foreground h-4 w-4 flex-shrink-0 animate-spin" })
|
|
4303
4330
|
]
|
|
4304
4331
|
},
|
|
4305
4332
|
recordId
|
|
@@ -4316,17 +4343,17 @@ function RecordPicker({
|
|
|
4316
4343
|
const recordId = getRecordId(record);
|
|
4317
4344
|
const label = getRecordLabel(record);
|
|
4318
4345
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted/30 flex items-center space-x-3 rounded-md p-2", children: [
|
|
4319
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-4 w-4 flex-shrink-0 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(react$
|
|
4346
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-4 w-4 flex-shrink-0 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(react$2.RiCheckLine, { className: "h-3 w-3 text-green-600" }) }),
|
|
4320
4347
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground flex-1 truncate text-sm", title: label, children: label })
|
|
4321
4348
|
] }, recordId);
|
|
4322
4349
|
})
|
|
4323
4350
|
] }),
|
|
4324
4351
|
filteredRecords.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-muted-foreground py-8 text-center", children: [
|
|
4325
|
-
/* @__PURE__ */ jsxRuntime.jsx(react$
|
|
4352
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.RiSearchLine, { className: "mx-auto mb-2 h-8 w-8 opacity-50" }),
|
|
4326
4353
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: searchQuery ? "No records match your search" : "No records available" })
|
|
4327
4354
|
] }),
|
|
4328
4355
|
filteredRecords.length > 0 && unlinkableRecords.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-muted-foreground py-4 text-center", children: [
|
|
4329
|
-
/* @__PURE__ */ jsxRuntime.jsx(react$
|
|
4356
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$2.RiCheckLine, { className: "mx-auto mb-2 h-6 w-6 opacity-50" }),
|
|
4330
4357
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: "All matching records are already linked" })
|
|
4331
4358
|
] })
|
|
4332
4359
|
] }) })
|
|
@@ -5807,7 +5834,7 @@ function UnlinkButton({
|
|
|
5807
5834
|
),
|
|
5808
5835
|
"aria-label": ariaLabel,
|
|
5809
5836
|
title: isUnlinking ? "Unlinking..." : "Unlink record",
|
|
5810
|
-
children: isUnlinking ? /* @__PURE__ */ jsxRuntime.jsx(react$
|
|
5837
|
+
children: isUnlinking ? /* @__PURE__ */ jsxRuntime.jsx(react$2.RiLoader4Line, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(react$2.RiCloseLine, { className: "h-3 w-3" })
|
|
5811
5838
|
}
|
|
5812
5839
|
);
|
|
5813
5840
|
}
|
|
@@ -6883,7 +6910,7 @@ function useStackGestures(options) {
|
|
|
6883
6910
|
}, [onDismiss]);
|
|
6884
6911
|
const dismissedRef = React19.useRef(false);
|
|
6885
6912
|
const velocityMinDistance = Math.max(MIN_VELOCITY_DISTANCE, swipeThreshold * 0.25);
|
|
6886
|
-
const bind = react$
|
|
6913
|
+
const bind = react$3.useDrag(
|
|
6887
6914
|
({ active, movement: [mx], velocity: [vx], direction: [dx], initial: [initialX], xy: [currentX], cancel, first }) => {
|
|
6888
6915
|
if (first && initialX < EDGE_IGNORE_ZONE) {
|
|
6889
6916
|
cancel();
|
|
@@ -7377,6 +7404,481 @@ var toast5 = {
|
|
|
7377
7404
|
warning: showWarningToast
|
|
7378
7405
|
};
|
|
7379
7406
|
|
|
7407
|
+
// src/components/org-chart/layout.ts
|
|
7408
|
+
var NODE_WIDTH = 260;
|
|
7409
|
+
var NODE_HEIGHT = 100;
|
|
7410
|
+
var RANK_SEP = 80;
|
|
7411
|
+
var NODE_SEP = 40;
|
|
7412
|
+
var ROOT_KEY = "__root__";
|
|
7413
|
+
function computeLayout(edges) {
|
|
7414
|
+
const edgeById = /* @__PURE__ */ new Map();
|
|
7415
|
+
const childCountMap = /* @__PURE__ */ new Map();
|
|
7416
|
+
const childrenMap = /* @__PURE__ */ new Map();
|
|
7417
|
+
for (const e of edges) {
|
|
7418
|
+
edgeById.set(e.id, e);
|
|
7419
|
+
if (e.parentId) {
|
|
7420
|
+
childCountMap.set(e.parentId, (childCountMap.get(e.parentId) ?? 0) + 1);
|
|
7421
|
+
}
|
|
7422
|
+
const parent = e.parentId ?? ROOT_KEY;
|
|
7423
|
+
const bucket = childrenMap.get(parent);
|
|
7424
|
+
if (bucket) bucket.push(e.id);
|
|
7425
|
+
else childrenMap.set(parent, [e.id]);
|
|
7426
|
+
}
|
|
7427
|
+
for (const children of childrenMap.values()) {
|
|
7428
|
+
children.sort((a, b) => {
|
|
7429
|
+
const nameA = edgeById.get(a)?.displayName?.toLowerCase() ?? "";
|
|
7430
|
+
const nameB = edgeById.get(b)?.displayName?.toLowerCase() ?? "";
|
|
7431
|
+
return nameA.localeCompare(nameB);
|
|
7432
|
+
});
|
|
7433
|
+
}
|
|
7434
|
+
const widthCache = /* @__PURE__ */ new Map();
|
|
7435
|
+
const subtreeWidth = (nodeId) => {
|
|
7436
|
+
if (widthCache.has(nodeId)) return widthCache.get(nodeId);
|
|
7437
|
+
const children = childrenMap.get(nodeId);
|
|
7438
|
+
if (!children || children.length === 0) {
|
|
7439
|
+
widthCache.set(nodeId, NODE_WIDTH);
|
|
7440
|
+
return NODE_WIDTH;
|
|
7441
|
+
}
|
|
7442
|
+
const totalChildWidth = children.reduce((sum, c) => sum + subtreeWidth(c), 0);
|
|
7443
|
+
const gaps = (children.length - 1) * NODE_SEP;
|
|
7444
|
+
const w = Math.max(NODE_WIDTH, totalChildWidth + gaps);
|
|
7445
|
+
widthCache.set(nodeId, w);
|
|
7446
|
+
return w;
|
|
7447
|
+
};
|
|
7448
|
+
const positions = /* @__PURE__ */ new Map();
|
|
7449
|
+
const positionSubtree = (nodeId, centerX, y) => {
|
|
7450
|
+
positions.set(nodeId, { x: centerX, y });
|
|
7451
|
+
const children = childrenMap.get(nodeId);
|
|
7452
|
+
if (!children || children.length === 0) return;
|
|
7453
|
+
const totalWidth = children.reduce((sum, c) => sum + subtreeWidth(c), 0) + (children.length - 1) * NODE_SEP;
|
|
7454
|
+
let currentX = centerX - totalWidth / 2;
|
|
7455
|
+
for (const childId of children) {
|
|
7456
|
+
const childW = subtreeWidth(childId);
|
|
7457
|
+
positionSubtree(childId, currentX + childW / 2, y + NODE_HEIGHT + RANK_SEP);
|
|
7458
|
+
currentX += childW + NODE_SEP;
|
|
7459
|
+
}
|
|
7460
|
+
};
|
|
7461
|
+
const roots = childrenMap.get(ROOT_KEY) ?? [];
|
|
7462
|
+
if (roots.length === 1) {
|
|
7463
|
+
positionSubtree(roots[0], 0, 0);
|
|
7464
|
+
} else {
|
|
7465
|
+
const totalWidth = roots.reduce((sum, r) => sum + subtreeWidth(r), 0) + (roots.length - 1) * NODE_SEP;
|
|
7466
|
+
let currentX = -totalWidth / 2;
|
|
7467
|
+
for (const rootId of roots) {
|
|
7468
|
+
const w = subtreeWidth(rootId);
|
|
7469
|
+
positionSubtree(rootId, currentX + w / 2, 0);
|
|
7470
|
+
currentX += w + NODE_SEP;
|
|
7471
|
+
}
|
|
7472
|
+
}
|
|
7473
|
+
const nodes = edges.map((e) => {
|
|
7474
|
+
const pos = positions.get(e.id);
|
|
7475
|
+
return {
|
|
7476
|
+
id: e.id,
|
|
7477
|
+
type: "orgChartNode",
|
|
7478
|
+
width: NODE_WIDTH,
|
|
7479
|
+
height: NODE_HEIGHT,
|
|
7480
|
+
position: {
|
|
7481
|
+
x: pos.x - NODE_WIDTH / 2,
|
|
7482
|
+
y: pos.y
|
|
7483
|
+
},
|
|
7484
|
+
data: {
|
|
7485
|
+
id: e.id,
|
|
7486
|
+
displayName: e.displayName,
|
|
7487
|
+
avatarUrl: e.avatarUrl,
|
|
7488
|
+
positionTitle: e.positionTitle,
|
|
7489
|
+
parentId: e.parentId,
|
|
7490
|
+
childCount: childCountMap.get(e.id) ?? 0,
|
|
7491
|
+
isRoot: !e.parentId
|
|
7492
|
+
}
|
|
7493
|
+
};
|
|
7494
|
+
});
|
|
7495
|
+
const flowEdges = edges.filter((e) => e.parentId).map((e) => ({
|
|
7496
|
+
id: `edge-${e.parentId}-${e.id}`,
|
|
7497
|
+
source: e.parentId,
|
|
7498
|
+
target: e.id,
|
|
7499
|
+
type: "orgChartEdge"
|
|
7500
|
+
}));
|
|
7501
|
+
return { nodes, edges: flowEdges };
|
|
7502
|
+
}
|
|
7503
|
+
var NodeActionsContext = React19.createContext(null);
|
|
7504
|
+
var OrgChartContext = React19.createContext(null);
|
|
7505
|
+
function OrgChartProvider({ children, editable }) {
|
|
7506
|
+
const [selectedNodeId, setSelectedNodeId] = React19.useState(null);
|
|
7507
|
+
const [draggedNodeId, setDraggedNodeId] = React19.useState(null);
|
|
7508
|
+
const [dropTargetNodeId, setDropTargetNodeId] = React19.useState(null);
|
|
7509
|
+
const selectNode = React19.useCallback((nodeId) => setSelectedNodeId(nodeId), []);
|
|
7510
|
+
const clearSelection = React19.useCallback(() => setSelectedNodeId(null), []);
|
|
7511
|
+
const value = React19.useMemo(
|
|
7512
|
+
() => ({
|
|
7513
|
+
selectedNodeId,
|
|
7514
|
+
selectNode,
|
|
7515
|
+
clearSelection,
|
|
7516
|
+
editable,
|
|
7517
|
+
draggedNodeId,
|
|
7518
|
+
setDraggedNodeId,
|
|
7519
|
+
dropTargetNodeId,
|
|
7520
|
+
setDropTargetNodeId
|
|
7521
|
+
}),
|
|
7522
|
+
[selectedNodeId, selectNode, clearSelection, editable, draggedNodeId, dropTargetNodeId]
|
|
7523
|
+
);
|
|
7524
|
+
return /* @__PURE__ */ jsxRuntime.jsx(OrgChartContext.Provider, { value, children });
|
|
7525
|
+
}
|
|
7526
|
+
function useOrgChartContext() {
|
|
7527
|
+
const ctx = React19.useContext(OrgChartContext);
|
|
7528
|
+
if (!ctx) throw new Error("useOrgChartContext must be used within OrgChartProvider");
|
|
7529
|
+
return ctx;
|
|
7530
|
+
}
|
|
7531
|
+
function NodeActionsProvider({
|
|
7532
|
+
children,
|
|
7533
|
+
onEditNode,
|
|
7534
|
+
onRemoveNode
|
|
7535
|
+
}) {
|
|
7536
|
+
const value = React19.useMemo(() => ({ onEditNode, onRemoveNode }), [onEditNode, onRemoveNode]);
|
|
7537
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NodeActionsContext.Provider, { value, children });
|
|
7538
|
+
}
|
|
7539
|
+
function useNodeActions() {
|
|
7540
|
+
const ctx = React19.useContext(NodeActionsContext);
|
|
7541
|
+
if (!ctx) throw new Error("useNodeActions must be used within NodeActionsProvider");
|
|
7542
|
+
return ctx;
|
|
7543
|
+
}
|
|
7544
|
+
function OrgChartEdge({
|
|
7545
|
+
sourceX,
|
|
7546
|
+
sourceY,
|
|
7547
|
+
targetX,
|
|
7548
|
+
targetY,
|
|
7549
|
+
sourcePosition,
|
|
7550
|
+
targetPosition,
|
|
7551
|
+
style = {}
|
|
7552
|
+
}) {
|
|
7553
|
+
const [edgePath] = react$1.getSmoothStepPath({
|
|
7554
|
+
sourceX,
|
|
7555
|
+
sourceY,
|
|
7556
|
+
sourcePosition,
|
|
7557
|
+
targetX,
|
|
7558
|
+
targetY,
|
|
7559
|
+
targetPosition,
|
|
7560
|
+
borderRadius: 12
|
|
7561
|
+
});
|
|
7562
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react$1.BaseEdge, { path: edgePath, style });
|
|
7563
|
+
}
|
|
7564
|
+
function OrgChartEmpty({ editable, onAddRoot }) {
|
|
7565
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-card border-border/60 flex flex-col items-center justify-center rounded-xl border py-16", children: [
|
|
7566
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted mb-4 flex size-14 items-center justify-center rounded-2xl", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Network, { className: "text-muted-foreground size-7" }) }),
|
|
7567
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-foreground text-base font-semibold", children: "No Org Chart Yet" }),
|
|
7568
|
+
/* @__PURE__ */ jsxRuntime.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." }),
|
|
7569
|
+
editable && /* @__PURE__ */ jsxRuntime.jsxs(Button, { className: "mt-5 gap-1.5", onClick: onAddRoot, children: [
|
|
7570
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.UserPlus, { className: "size-3.5" }),
|
|
7571
|
+
"Add First Member"
|
|
7572
|
+
] })
|
|
7573
|
+
] });
|
|
7574
|
+
}
|
|
7575
|
+
|
|
7576
|
+
// src/components/org-chart/org-chart-utils.ts
|
|
7577
|
+
function getInitials(name) {
|
|
7578
|
+
if (!name) return "--";
|
|
7579
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
7580
|
+
if (parts.length === 0) return "--";
|
|
7581
|
+
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
|
7582
|
+
return (parts[0][0] + parts[1][0]).toUpperCase();
|
|
7583
|
+
}
|
|
7584
|
+
function OrgChartNodeComponent({ id, data }) {
|
|
7585
|
+
const { selectedNodeId, dropTargetNodeId, editable } = useOrgChartContext();
|
|
7586
|
+
const { onEditNode, onRemoveNode } = useNodeActions();
|
|
7587
|
+
const isSelected = selectedNodeId === id;
|
|
7588
|
+
const isDropTarget = dropTargetNodeId === id;
|
|
7589
|
+
const [isHovered, setIsHovered] = React19.useState(false);
|
|
7590
|
+
const [isMenuOpen, setIsMenuOpen] = React19.useState(false);
|
|
7591
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7592
|
+
"div",
|
|
7593
|
+
{
|
|
7594
|
+
style: { width: NODE_WIDTH },
|
|
7595
|
+
className: cn(
|
|
7596
|
+
"bg-card dark:bg-muted relative rounded-xl border shadow-sm transition-all",
|
|
7597
|
+
"border-border/60",
|
|
7598
|
+
isSelected && "ring-primary ring-2 ring-offset-2 dark:ring-offset-zinc-900",
|
|
7599
|
+
isDropTarget && "ring-primary/50 border-primary scale-105 ring-2"
|
|
7600
|
+
),
|
|
7601
|
+
onMouseEnter: () => setIsHovered(true),
|
|
7602
|
+
onMouseLeave: () => setIsHovered(false),
|
|
7603
|
+
children: [
|
|
7604
|
+
!data.isRoot && /* @__PURE__ */ jsxRuntime.jsx(react$1.Handle, { type: "target", position: react$1.Position.Top, className: "!bg-border !size-2 !rounded-full !border-0" }),
|
|
7605
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [
|
|
7606
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "size-10 shrink-0", children: [
|
|
7607
|
+
data.avatarUrl && /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: data.avatarUrl, alt: data.displayName ?? "" }),
|
|
7608
|
+
/* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { className: "bg-primary/10 text-primary text-xs font-medium", children: getInitials(data.displayName) })
|
|
7609
|
+
] }),
|
|
7610
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
7611
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-foreground truncate text-sm font-semibold", children: data.displayName ?? "Unknown" }),
|
|
7612
|
+
data.positionTitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground truncate text-xs", children: data.positionTitle })
|
|
7613
|
+
] }),
|
|
7614
|
+
editable && (isHovered || isMenuOpen) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nodrag nopan shrink-0", children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { open: isMenuOpen, onOpenChange: setIsMenuOpen, children: [
|
|
7615
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7616
|
+
Button,
|
|
7617
|
+
{
|
|
7618
|
+
variant: "ghost",
|
|
7619
|
+
size: "icon",
|
|
7620
|
+
className: "size-7 rounded-full",
|
|
7621
|
+
onClick: (e) => e.stopPropagation(),
|
|
7622
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Ellipsis, { className: "size-4" })
|
|
7623
|
+
}
|
|
7624
|
+
) }),
|
|
7625
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuContent, { align: "start", side: "right", className: "translate-x-1 -translate-y-3.5", children: [
|
|
7626
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
7627
|
+
DropdownMenuItem,
|
|
7628
|
+
{
|
|
7629
|
+
onClick: (e) => {
|
|
7630
|
+
e.stopPropagation();
|
|
7631
|
+
setIsMenuOpen(false);
|
|
7632
|
+
onEditNode(data);
|
|
7633
|
+
},
|
|
7634
|
+
children: [
|
|
7635
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pencil, { className: "mr-2 size-3.5" }),
|
|
7636
|
+
"Edit Position"
|
|
7637
|
+
]
|
|
7638
|
+
}
|
|
7639
|
+
),
|
|
7640
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
|
|
7641
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
7642
|
+
DropdownMenuItem,
|
|
7643
|
+
{
|
|
7644
|
+
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",
|
|
7645
|
+
onClick: (e) => {
|
|
7646
|
+
e.stopPropagation();
|
|
7647
|
+
setIsMenuOpen(false);
|
|
7648
|
+
onRemoveNode(data);
|
|
7649
|
+
},
|
|
7650
|
+
children: [
|
|
7651
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "mr-2 size-3.5" }),
|
|
7652
|
+
"Remove from Chart"
|
|
7653
|
+
]
|
|
7654
|
+
}
|
|
7655
|
+
)
|
|
7656
|
+
] })
|
|
7657
|
+
] }) }) : data.childCount > 0 && /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "secondary", className: "shrink-0 text-[10px]", children: data.childCount })
|
|
7658
|
+
] }),
|
|
7659
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Handle, { type: "source", position: react$1.Position.Bottom, className: "!bg-border !size-2 !rounded-full !border-0" })
|
|
7660
|
+
]
|
|
7661
|
+
}
|
|
7662
|
+
);
|
|
7663
|
+
}
|
|
7664
|
+
var OrgChartNodeMemo = React19.memo(OrgChartNodeComponent);
|
|
7665
|
+
var FIT_VIEW_OPTIONS = { padding: 0.12 };
|
|
7666
|
+
function getDescendantIds(nodeId, nodes) {
|
|
7667
|
+
const descendants = /* @__PURE__ */ new Set();
|
|
7668
|
+
const queue = [nodeId];
|
|
7669
|
+
while (queue.length > 0) {
|
|
7670
|
+
const current = queue.pop();
|
|
7671
|
+
for (const n of nodes) {
|
|
7672
|
+
if (n.data.parentId === current && !descendants.has(n.id)) {
|
|
7673
|
+
descendants.add(n.id);
|
|
7674
|
+
queue.push(n.id);
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7677
|
+
}
|
|
7678
|
+
return descendants;
|
|
7679
|
+
}
|
|
7680
|
+
function mergeWithMeasured(prev, layoutNodes) {
|
|
7681
|
+
const prevMap = new Map(prev.map((n) => [n.id, n]));
|
|
7682
|
+
return layoutNodes.map((n) => {
|
|
7683
|
+
const existing = prevMap.get(n.id);
|
|
7684
|
+
if (!existing) return n;
|
|
7685
|
+
return existing.data.isRoot !== n.data.isRoot ? n : { ...n, measured: existing.measured };
|
|
7686
|
+
});
|
|
7687
|
+
}
|
|
7688
|
+
function OrgChartInner({
|
|
7689
|
+
className,
|
|
7690
|
+
edges: controlledEdges,
|
|
7691
|
+
defaultEdges,
|
|
7692
|
+
isLoading = false,
|
|
7693
|
+
editable = true,
|
|
7694
|
+
onReparent,
|
|
7695
|
+
onAddToChart,
|
|
7696
|
+
onEditNode,
|
|
7697
|
+
onRemoveNode,
|
|
7698
|
+
onReparentSuccess,
|
|
7699
|
+
onReparentError
|
|
7700
|
+
}) {
|
|
7701
|
+
const isControlled = controlledEdges !== void 0;
|
|
7702
|
+
const {
|
|
7703
|
+
selectNode,
|
|
7704
|
+
clearSelection,
|
|
7705
|
+
setDraggedNodeId,
|
|
7706
|
+
setDropTargetNodeId
|
|
7707
|
+
} = useOrgChartContext();
|
|
7708
|
+
const [internalEdges, setInternalEdges] = React19.useState(defaultEdges ?? []);
|
|
7709
|
+
const defaultEdgesHash = React19.useMemo(
|
|
7710
|
+
() => defaultEdges?.map((e) => `${e.id}:${e.parentId}:${e.positionTitle ?? ""}:${e.displayName ?? ""}`).join(",") ?? "",
|
|
7711
|
+
[defaultEdges]
|
|
7712
|
+
);
|
|
7713
|
+
React19.useEffect(() => {
|
|
7714
|
+
if (!isControlled && defaultEdges) {
|
|
7715
|
+
setInternalEdges(defaultEdges);
|
|
7716
|
+
}
|
|
7717
|
+
}, [defaultEdgesHash]);
|
|
7718
|
+
const apiEdges = controlledEdges ?? internalEdges;
|
|
7719
|
+
const layout = React19.useMemo(() => apiEdges.length > 0 ? computeLayout(apiEdges) : null, [apiEdges]);
|
|
7720
|
+
const layoutNodes = layout?.nodes ?? [];
|
|
7721
|
+
const layoutEdges = layout?.edges ?? [];
|
|
7722
|
+
const isEmpty = apiEdges.length === 0 && !isLoading;
|
|
7723
|
+
const { fitView, getIntersectingNodes } = react$1.useReactFlow();
|
|
7724
|
+
const [nodes, setNodes, onNodesChange] = react$1.useNodesState([]);
|
|
7725
|
+
const [rfEdges, setRfEdges, onEdgesChange] = react$1.useEdgesState([]);
|
|
7726
|
+
const nodesHash = React19.useMemo(
|
|
7727
|
+
() => layoutNodes.map((n) => `${n.id}:${n.data.parentId ?? ""}:${n.data.positionTitle ?? ""}:${n.data.displayName ?? ""}`).join(","),
|
|
7728
|
+
[layoutNodes]
|
|
7729
|
+
);
|
|
7730
|
+
const edgesHash = React19.useMemo(() => layoutEdges.map((e) => `${e.id}:${e.source}:${e.target}`).join(","), [layoutEdges]);
|
|
7731
|
+
const fitViewRef = React19.useRef(fitView);
|
|
7732
|
+
fitViewRef.current = fitView;
|
|
7733
|
+
React19.useEffect(() => {
|
|
7734
|
+
setNodes((prev) => mergeWithMeasured(prev, layoutNodes));
|
|
7735
|
+
setRfEdges(layoutEdges);
|
|
7736
|
+
const raf = requestAnimationFrame(() => fitViewRef.current(FIT_VIEW_OPTIONS));
|
|
7737
|
+
return () => cancelAnimationFrame(raf);
|
|
7738
|
+
}, [nodesHash, edgesHash]);
|
|
7739
|
+
const draggedNodeRef = React19.useRef(null);
|
|
7740
|
+
const dropTargetIdRef = React19.useRef(null);
|
|
7741
|
+
const nodeTypes = React19.useMemo(() => ({ orgChartNode: OrgChartNodeMemo }), []);
|
|
7742
|
+
const edgeTypes = React19.useMemo(() => ({ orgChartEdge: OrgChartEdge }), []);
|
|
7743
|
+
const onNodeDragStart = React19.useCallback(
|
|
7744
|
+
(_, node) => {
|
|
7745
|
+
if (!editable) return;
|
|
7746
|
+
draggedNodeRef.current = node.id;
|
|
7747
|
+
setDraggedNodeId(node.id);
|
|
7748
|
+
},
|
|
7749
|
+
[editable, setDraggedNodeId]
|
|
7750
|
+
);
|
|
7751
|
+
const onNodeDrag = React19.useCallback(
|
|
7752
|
+
(_, node) => {
|
|
7753
|
+
if (!editable || !draggedNodeRef.current) return;
|
|
7754
|
+
const intersecting = getIntersectingNodes(node);
|
|
7755
|
+
const target = intersecting.find((n) => n.id !== node.id);
|
|
7756
|
+
const targetId = target?.id ?? null;
|
|
7757
|
+
if (targetId === dropTargetIdRef.current) return;
|
|
7758
|
+
dropTargetIdRef.current = targetId;
|
|
7759
|
+
setDropTargetNodeId(targetId);
|
|
7760
|
+
},
|
|
7761
|
+
[editable, getIntersectingNodes, setDropTargetNodeId]
|
|
7762
|
+
);
|
|
7763
|
+
const applyOptimisticReparent = React19.useCallback((childId, newParentId) => {
|
|
7764
|
+
setInternalEdges(
|
|
7765
|
+
(prev) => prev.map((e) => e.id === childId ? { ...e, parentId: newParentId } : e)
|
|
7766
|
+
);
|
|
7767
|
+
}, []);
|
|
7768
|
+
const snapBack = React19.useCallback(() => {
|
|
7769
|
+
setNodes((prev) => mergeWithMeasured(prev, layoutNodes));
|
|
7770
|
+
}, [layoutNodes, setNodes]);
|
|
7771
|
+
const onNodeDragStop = React19.useCallback(
|
|
7772
|
+
async (_, _node) => {
|
|
7773
|
+
if (!editable || !draggedNodeRef.current) return;
|
|
7774
|
+
const childId = draggedNodeRef.current;
|
|
7775
|
+
const newParentId = dropTargetIdRef.current;
|
|
7776
|
+
draggedNodeRef.current = null;
|
|
7777
|
+
dropTargetIdRef.current = null;
|
|
7778
|
+
setDraggedNodeId(null);
|
|
7779
|
+
setDropTargetNodeId(null);
|
|
7780
|
+
if (!newParentId || newParentId === childId) {
|
|
7781
|
+
snapBack();
|
|
7782
|
+
return;
|
|
7783
|
+
}
|
|
7784
|
+
if (getDescendantIds(childId, layoutNodes).has(newParentId)) {
|
|
7785
|
+
onReparentError?.("Cannot create circular reporting chain");
|
|
7786
|
+
snapBack();
|
|
7787
|
+
return;
|
|
7788
|
+
}
|
|
7789
|
+
const draggedData = layoutNodes.find((n) => n.id === childId)?.data;
|
|
7790
|
+
if (!draggedData || newParentId === draggedData.parentId) {
|
|
7791
|
+
snapBack();
|
|
7792
|
+
return;
|
|
7793
|
+
}
|
|
7794
|
+
const targetName = layoutNodes.find((n) => n.id === newParentId)?.data.displayName;
|
|
7795
|
+
const preserve = { positionTitle: draggedData.positionTitle };
|
|
7796
|
+
if (!isControlled) {
|
|
7797
|
+
const snapshotEdges = internalEdges;
|
|
7798
|
+
applyOptimisticReparent(childId, newParentId);
|
|
7799
|
+
try {
|
|
7800
|
+
await onReparent?.(childId, newParentId, preserve);
|
|
7801
|
+
onReparentSuccess?.(draggedData.displayName ?? "Member", targetName ?? "new manager");
|
|
7802
|
+
} catch (err) {
|
|
7803
|
+
console.error("[OrgChart] reparent failed", err);
|
|
7804
|
+
setInternalEdges(snapshotEdges);
|
|
7805
|
+
onReparentError?.("Failed to update reporting line");
|
|
7806
|
+
}
|
|
7807
|
+
} else {
|
|
7808
|
+
snapBack();
|
|
7809
|
+
try {
|
|
7810
|
+
await onReparent?.(childId, newParentId, preserve);
|
|
7811
|
+
onReparentSuccess?.(draggedData.displayName ?? "Member", targetName ?? "new manager");
|
|
7812
|
+
} catch (err) {
|
|
7813
|
+
console.error("[OrgChart] reparent failed", err);
|
|
7814
|
+
onReparentError?.("Failed to update reporting line");
|
|
7815
|
+
}
|
|
7816
|
+
}
|
|
7817
|
+
},
|
|
7818
|
+
[editable, isControlled, internalEdges, layoutNodes, onReparent, onReparentSuccess, onReparentError, applyOptimisticReparent, snapBack, setDraggedNodeId, setDropTargetNodeId]
|
|
7819
|
+
);
|
|
7820
|
+
const onNodeClick = React19.useCallback((_, node) => selectNode(node.id), [selectNode]);
|
|
7821
|
+
const onPaneClick = React19.useCallback(() => clearSelection(), [clearSelection]);
|
|
7822
|
+
const handleEditNode = React19.useCallback(
|
|
7823
|
+
(nodeData) => onEditNode?.(nodeData),
|
|
7824
|
+
[onEditNode]
|
|
7825
|
+
);
|
|
7826
|
+
const handleRemoveNode = React19.useCallback(
|
|
7827
|
+
(nodeData) => onRemoveNode?.(nodeData),
|
|
7828
|
+
[onRemoveNode]
|
|
7829
|
+
);
|
|
7830
|
+
if (isLoading) {
|
|
7831
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-card border-border/60 flex items-center justify-center rounded-xl border p-16", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "text-muted-foreground size-6 animate-spin" }) });
|
|
7832
|
+
}
|
|
7833
|
+
if (isEmpty) {
|
|
7834
|
+
return /* @__PURE__ */ jsxRuntime.jsx(OrgChartEmpty, { editable, onAddRoot: onAddToChart ?? (() => {
|
|
7835
|
+
}) });
|
|
7836
|
+
}
|
|
7837
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NodeActionsProvider, { onEditNode: handleEditNode, onRemoveNode: handleRemoveNode, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("border-border/60 h-[600px] overflow-hidden rounded-xl border", className), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7838
|
+
react$1.ReactFlow,
|
|
7839
|
+
{
|
|
7840
|
+
nodes,
|
|
7841
|
+
edges: rfEdges,
|
|
7842
|
+
onNodesChange,
|
|
7843
|
+
onEdgesChange,
|
|
7844
|
+
onNodeClick,
|
|
7845
|
+
proOptions: { hideAttribution: true },
|
|
7846
|
+
onPaneClick,
|
|
7847
|
+
onNodeDragStart,
|
|
7848
|
+
onNodeDrag,
|
|
7849
|
+
onNodeDragStop,
|
|
7850
|
+
nodeTypes,
|
|
7851
|
+
edgeTypes,
|
|
7852
|
+
fitView: true,
|
|
7853
|
+
fitViewOptions: FIT_VIEW_OPTIONS,
|
|
7854
|
+
minZoom: 0.3,
|
|
7855
|
+
maxZoom: 1.5,
|
|
7856
|
+
nodesDraggable: editable,
|
|
7857
|
+
nodesConnectable: false,
|
|
7858
|
+
elementsSelectable: true,
|
|
7859
|
+
selectNodesOnDrag: false,
|
|
7860
|
+
panOnDrag: true,
|
|
7861
|
+
zoomOnScroll: true,
|
|
7862
|
+
preventScrolling: true,
|
|
7863
|
+
style: {
|
|
7864
|
+
"--xy-background-pattern-dots-color-default": "var(--color-border)",
|
|
7865
|
+
"--xy-edge-stroke-width-default": 2,
|
|
7866
|
+
"--xy-edge-stroke-default": "var(--color-border)",
|
|
7867
|
+
"--xy-edge-stroke-selected-default": "var(--color-foreground)",
|
|
7868
|
+
"--xy-attribution-background-color-default": "transparent"
|
|
7869
|
+
},
|
|
7870
|
+
attributionPosition: "bottom-left",
|
|
7871
|
+
children: [
|
|
7872
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Background, { variant: react$1.BackgroundVariant.Dots, gap: 20, size: 2 }),
|
|
7873
|
+
/* @__PURE__ */ jsxRuntime.jsx(FlowZoomPanel, { fitViewOptions: FIT_VIEW_OPTIONS })
|
|
7874
|
+
]
|
|
7875
|
+
}
|
|
7876
|
+
) }) });
|
|
7877
|
+
}
|
|
7878
|
+
function OrgChart(props) {
|
|
7879
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react$1.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OrgChartProvider, { editable: props.editable ?? true, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OrgChartInner, { ...props }) }) }) });
|
|
7880
|
+
}
|
|
7881
|
+
|
|
7380
7882
|
exports.Alert = Alert;
|
|
7381
7883
|
exports.AlertDescription = AlertDescription;
|
|
7382
7884
|
exports.AlertDialog = AlertDialog;
|
|
@@ -7480,6 +7982,7 @@ exports.DropdownMenuTrigger = DropdownMenuTrigger;
|
|
|
7480
7982
|
exports.Field = Field;
|
|
7481
7983
|
exports.FieldRow = FieldRow;
|
|
7482
7984
|
exports.FlickeringGrid = FlickeringGrid;
|
|
7985
|
+
exports.FlowZoomPanel = FlowZoomPanel;
|
|
7483
7986
|
exports.Form = Form;
|
|
7484
7987
|
exports.FormControl = FormControl;
|
|
7485
7988
|
exports.FormControlComponent = FormControl2;
|
|
@@ -7500,6 +8003,7 @@ exports.Label = Label;
|
|
|
7500
8003
|
exports.ModalPortalScope = ModalPortalScope;
|
|
7501
8004
|
exports.MotionGrid = MotionGrid;
|
|
7502
8005
|
exports.MultiSelect = MultiSelect;
|
|
8006
|
+
exports.OrgChart = OrgChart;
|
|
7503
8007
|
exports.PORTAL_ROOT_ID = PORTAL_ROOT_ID;
|
|
7504
8008
|
exports.PageHeader = PageHeader;
|
|
7505
8009
|
exports.Pagination = Pagination;
|