eai-frontend-components 2.0.83 → 2.0.85
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 +23 -4
- package/dist/index.esm.js +24 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +24 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10184,19 +10184,38 @@ function NodeCard({ node, onNodeClick, isExpanded, hasChildren, onToggle }) {
|
|
|
10184
10184
|
onToggle();
|
|
10185
10185
|
}, children: isExpanded ? jsxRuntime.jsx(lucideReact.ChevronUp, { className: 'h-3 w-3' }) : jsxRuntime.jsx(lucideReact.ChevronDown, { className: 'h-3 w-3' }) }) }))] }) }));
|
|
10186
10186
|
}
|
|
10187
|
-
function OrgChartTreeNode({ node, onNodeClick, defaultExpanded }) {
|
|
10187
|
+
function OrgChartTreeNode({ node, onNodeClick, defaultExpanded, renderNode }) {
|
|
10188
10188
|
const [isExpanded, setIsExpanded] = React$1.useState(defaultExpanded);
|
|
10189
10189
|
const children = node.children ?? [];
|
|
10190
10190
|
const hasChildren = children.length > 0;
|
|
10191
|
-
|
|
10191
|
+
const cardProps = {
|
|
10192
|
+
node,
|
|
10193
|
+
onNodeClick,
|
|
10194
|
+
isExpanded,
|
|
10195
|
+
hasChildren,
|
|
10196
|
+
onToggle: () => setIsExpanded((prev) => !prev),
|
|
10197
|
+
};
|
|
10198
|
+
return (jsxRuntime.jsxs("div", { className: 'flex flex-col items-center', children: [renderNode ? renderNode(cardProps) : jsxRuntime.jsx(NodeCard, { ...cardProps }), hasChildren && isExpanded && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'h-4 w-px bg-border' }), jsxRuntime.jsx("div", { className: 'flex items-start', children: children.map((child, i) => {
|
|
10192
10199
|
const isOnly = children.length === 1;
|
|
10193
10200
|
const isFirst = i === 0;
|
|
10194
10201
|
const isLast = i === children.length - 1;
|
|
10195
|
-
return (jsxRuntime.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: [jsxRuntime.jsx("div", { className: 'h-4 w-px bg-border' }), jsxRuntime.jsx(OrgChartTreeNode, { node: child, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded })] }, child.id));
|
|
10202
|
+
return (jsxRuntime.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: [jsxRuntime.jsx("div", { className: 'h-4 w-px bg-border' }), jsxRuntime.jsx(OrgChartTreeNode, { node: child, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded, renderNode: renderNode })] }, child.id));
|
|
10196
10203
|
}) })] }))] }));
|
|
10197
10204
|
}
|
|
10198
|
-
function OrgChart({ data, onNodeClick, defaultExpanded = true, className }) {
|
|
10199
|
-
|
|
10205
|
+
function OrgChart({ defaultSearch, setSearch, actions, data, onNodeClick, defaultExpanded = true, className, renderNode }) {
|
|
10206
|
+
const debounceTimeout = React$1.useRef(null);
|
|
10207
|
+
const handleSearchChange = (event) => {
|
|
10208
|
+
const value = event.currentTarget.value;
|
|
10209
|
+
if (debounceTimeout.current) {
|
|
10210
|
+
clearTimeout(debounceTimeout.current);
|
|
10211
|
+
}
|
|
10212
|
+
debounceTimeout.current = setTimeout(() => {
|
|
10213
|
+
setSearch?.(value);
|
|
10214
|
+
}, 300);
|
|
10215
|
+
};
|
|
10216
|
+
return (jsxRuntime.jsxs("div", { className: 'flex h-full flex-col gap-4 overflow-x-auto', children: [jsxRuntime.jsxs("div", { className: 'flex items-center gap-x-4', children: [jsxRuntime.jsx("div", { className: 'flex gap-x-4', children: jsxRuntime.jsxs("div", { className: 'flex bg-background items-center border border-slate-300 rounded-sm w-[350px] overflow-hidden focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 group', children: [jsxRuntime.jsx("div", { className: 'pl-3.5 transform transition-transform duration-300 group-hover:-translate-x-1', children: jsxRuntime.jsx(lucideReact.Search, { size: 18, className: 'w-5 h-5 stroke-zinc-500 dark:stroke-default' }) }), jsxRuntime.jsx("input", { placeholder: 'Buscar', defaultValue: defaultSearch, onChange: (event) => {
|
|
10217
|
+
handleSearchChange(event);
|
|
10218
|
+
}, className: 'w-full bg-background text-default border-none focus:ring-0 focus:outline-none px-3 py-2 transform transition-transform duration-300 group-hover:-translate-x-1 ' })] }) }), jsxRuntime.jsx("div", { className: 'flex space-x-4 content-end', children: actions?.map((action, index) => (jsxRuntime.jsx("div", { children: jsxRuntime.jsxs(Button, { type: 'button', onClick: () => action.onClick?.(), className: cn(action.className), variant: action.variant || 'default', disabled: action.disabled, children: [jsxRuntime.jsx("div", { className: '[&_svg]:size-5', children: action.icon }), action.label] }) }, `action-table-${index}`))) })] }), jsxRuntime.jsx(Card, { className: 'flex-1 overflow-hidden', children: jsxRuntime.jsx(CardContent, { className: 'h-full p-0', children: jsxRuntime.jsx("div", { className: cn('w-full overflow-x-auto', className), children: jsxRuntime.jsx("div", { className: 'flex justify-center px-4 py-6', children: jsxRuntime.jsx(OrgChartTreeNode, { node: data, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded, renderNode: renderNode }) }) }) }) })] }));
|
|
10200
10219
|
}
|
|
10201
10220
|
|
|
10202
10221
|
function useMediaQuery(queryInput) {
|