eai-frontend-components 2.0.83 → 2.0.84
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/index.d.ts +9 -1
- package/dist/index.esm.js +12 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1113,13 +1113,21 @@ interface OrgChartNodeData {
|
|
|
1113
1113
|
children?: OrgChartNodeData[];
|
|
1114
1114
|
data?: Record<string, unknown>;
|
|
1115
1115
|
}
|
|
1116
|
+
interface NodeCardProps {
|
|
1117
|
+
node: OrgChartNodeData;
|
|
1118
|
+
onNodeClick?: (node: OrgChartNodeData) => void;
|
|
1119
|
+
isExpanded: boolean;
|
|
1120
|
+
hasChildren: boolean;
|
|
1121
|
+
onToggle: () => void;
|
|
1122
|
+
}
|
|
1116
1123
|
interface OrgChartProps {
|
|
1117
1124
|
data: OrgChartNodeData;
|
|
1118
1125
|
onNodeClick?: (node: OrgChartNodeData) => void;
|
|
1119
1126
|
defaultExpanded?: boolean;
|
|
1120
1127
|
className?: string;
|
|
1128
|
+
renderNode?: (props: NodeCardProps) => ReactNode;
|
|
1121
1129
|
}
|
|
1122
|
-
declare function OrgChart({ data, onNodeClick, defaultExpanded, className }: OrgChartProps): react_jsx_runtime.JSX.Element;
|
|
1130
|
+
declare function OrgChart({ data, onNodeClick, defaultExpanded, className, renderNode }: OrgChartProps): react_jsx_runtime.JSX.Element;
|
|
1123
1131
|
|
|
1124
1132
|
type ResponsiveDialogAction = {
|
|
1125
1133
|
label: string;
|
package/dist/index.esm.js
CHANGED
|
@@ -10144,19 +10144,26 @@ function NodeCard({ node, onNodeClick, isExpanded, hasChildren, onToggle }) {
|
|
|
10144
10144
|
onToggle();
|
|
10145
10145
|
}, children: isExpanded ? jsx(ChevronUp, { className: 'h-3 w-3' }) : jsx(ChevronDown, { className: 'h-3 w-3' }) }) }))] }) }));
|
|
10146
10146
|
}
|
|
10147
|
-
function OrgChartTreeNode({ node, onNodeClick, defaultExpanded }) {
|
|
10147
|
+
function OrgChartTreeNode({ node, onNodeClick, defaultExpanded, renderNode }) {
|
|
10148
10148
|
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
|
|
10149
10149
|
const children = node.children ?? [];
|
|
10150
10150
|
const hasChildren = children.length > 0;
|
|
10151
|
-
|
|
10151
|
+
const cardProps = {
|
|
10152
|
+
node,
|
|
10153
|
+
onNodeClick,
|
|
10154
|
+
isExpanded,
|
|
10155
|
+
hasChildren,
|
|
10156
|
+
onToggle: () => setIsExpanded((prev) => !prev),
|
|
10157
|
+
};
|
|
10158
|
+
return (jsxs("div", { className: 'flex flex-col items-center', children: [renderNode ? renderNode(cardProps) : jsx(NodeCard, { ...cardProps }), hasChildren && isExpanded && (jsxs(Fragment, { children: [jsx("div", { className: 'h-4 w-px bg-border' }), jsx("div", { className: 'flex items-start', children: children.map((child, i) => {
|
|
10152
10159
|
const isOnly = children.length === 1;
|
|
10153
10160
|
const isFirst = i === 0;
|
|
10154
10161
|
const isLast = i === children.length - 1;
|
|
10155
|
-
return (jsxs("div", { className: cn('relative flex flex-col items-center px-4', !isOnly && "after:absolute after:top-0 after:h-px after:bg-border after:content-['']", !isOnly && isFirst && 'after:-right-4 after:left-1/2', !isOnly && isLast && 'after:-left-4 after:right-1/2', !isOnly && !isFirst && !isLast && 'after:-left-4 after:-right-4'), children: [jsx("div", { className: 'h-4 w-px bg-border' }), jsx(OrgChartTreeNode, { node: child, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded })] }, child.id));
|
|
10162
|
+
return (jsxs("div", { className: cn('relative flex flex-col items-center px-4', !isOnly && "after:absolute after:top-0 after:h-px after:bg-border after:content-['']", !isOnly && isFirst && 'after:-right-4 after:left-1/2', !isOnly && isLast && 'after:-left-4 after:right-1/2', !isOnly && !isFirst && !isLast && 'after:-left-4 after:-right-4'), children: [jsx("div", { className: 'h-4 w-px bg-border' }), jsx(OrgChartTreeNode, { node: child, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded, renderNode: renderNode })] }, child.id));
|
|
10156
10163
|
}) })] }))] }));
|
|
10157
10164
|
}
|
|
10158
|
-
function OrgChart({ data, onNodeClick, defaultExpanded = true, className }) {
|
|
10159
|
-
return (jsx("div", { className: cn('w-full overflow-x-auto', className), children: jsx("div", { className: 'flex justify-center px-4 py-6', children: jsx(OrgChartTreeNode, { node: data, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded }) }) }));
|
|
10165
|
+
function OrgChart({ data, onNodeClick, defaultExpanded = true, className, renderNode }) {
|
|
10166
|
+
return (jsx("div", { className: cn('w-full overflow-x-auto', className), children: jsx("div", { className: 'flex justify-center px-4 py-6', children: jsx(OrgChartTreeNode, { node: data, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded, renderNode: renderNode }) }) }));
|
|
10160
10167
|
}
|
|
10161
10168
|
|
|
10162
10169
|
function useMediaQuery(queryInput) {
|