@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.
@@ -0,0 +1,54 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ /** A single edge in the org chart — represents a person and their reporting relationship */
4
+ interface OrgChartEdge {
5
+ /** Person ID (used as the React Flow node id) */
6
+ id: string;
7
+ /** ID of the person this edge reports to (null = root) */
8
+ parentId: string | null;
9
+ displayName: string | null;
10
+ avatarUrl: string | null;
11
+ positionTitle: string | null;
12
+ }
13
+ /** Data carried by each React Flow node */
14
+ interface OrgChartNodeData extends OrgChartEdge {
15
+ childCount: number;
16
+ isRoot: boolean;
17
+ [key: string]: unknown;
18
+ }
19
+
20
+ interface OrgChartPropsBase {
21
+ /** Additional classes for the chart container (e.g. `"h-full"` to fill parent). Default height: 600px. */
22
+ className?: string;
23
+ /** Whether data is still loading */
24
+ isLoading?: boolean;
25
+ /** Whether the current user can manage the chart (drag, edit, remove) */
26
+ editable?: boolean;
27
+ /** Called when a node is dragged onto a new parent. In uncontrolled mode, the component updates visually first — if this throws, it reverts. */
28
+ onReparent?: (childId: string, newParentId: string, preserve: {
29
+ positionTitle?: string | null;
30
+ }) => void | Promise<void>;
31
+ /** Called when the "Add to Chart" button is clicked (empty state) */
32
+ onAddToChart?: () => void;
33
+ /** Called when "Edit Position" is selected from the node menu */
34
+ onEditNode?: (nodeData: OrgChartNodeData) => void;
35
+ /** Called when "Remove from Chart" is selected from the node menu */
36
+ onRemoveNode?: (nodeData: OrgChartNodeData) => void;
37
+ /** Toast handler for reparent success/error messages. If not provided, no toasts are shown. */
38
+ onReparentSuccess?: (childName: string, parentName: string) => void;
39
+ onReparentError?: (message: string) => void;
40
+ }
41
+ /** Controlled mode — consumer owns edge state */
42
+ interface OrgChartControlledProps extends OrgChartPropsBase {
43
+ edges: OrgChartEdge[];
44
+ defaultEdges?: never;
45
+ }
46
+ /** Uncontrolled mode — component manages edge state internally with optimistic reparent */
47
+ interface OrgChartUncontrolledProps extends OrgChartPropsBase {
48
+ edges?: never;
49
+ defaultEdges: OrgChartEdge[];
50
+ }
51
+ type OrgChartProps = OrgChartControlledProps | OrgChartUncontrolledProps;
52
+ declare function OrgChart(props: OrgChartProps): react_jsx_runtime.JSX.Element;
53
+
54
+ export { OrgChart, type OrgChartEdge, type OrgChartNodeData, type OrgChartProps };