@oliasoft-open-source/react-ui-library 5.11.0 → 5.11.1-beta-1
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/README.md +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +31 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2526,6 +2526,7 @@ The `Tree` component represents a hierarchical structure of items in a tree form
|
|
|
2526
2526
|
| `onChangeOpen` | Callback function invoked when the open/close state of tree nodes changes. | - |
|
|
2527
2527
|
| `testId` | Optional test id for testing purposes. | - |
|
|
2528
2528
|
| `isInitialOpen` | Determines which nodes should be initially open. | `false` |
|
|
2529
|
+
| `autoOpenActiveItems` | Automatically open tree to active items. | `false` |
|
|
2529
2530
|
| `treeRef` | Reference to the tree component. | - |
|
|
2530
2531
|
| `itemHasChild` | Function to determine if a tree node has child nodes. | - |
|
|
2531
2532
|
| `onItemToggle` | Callback function invoked when a tree node is toggled (opened/closed). | - |
|
package/dist/index.d.ts
CHANGED
|
@@ -1759,6 +1759,7 @@ export declare interface ITreeProps {
|
|
|
1759
1759
|
onChangeOpen?: (id: TStringOrNumber[]) => void;
|
|
1760
1760
|
testId?: string;
|
|
1761
1761
|
isInitialOpen?: boolean | Array<string> | Array<number>;
|
|
1762
|
+
autoOpenActiveItems?: boolean;
|
|
1762
1763
|
treeRef?: RefObject<any>;
|
|
1763
1764
|
itemHasChild?: (node: NodeModel<any>) => boolean;
|
|
1764
1765
|
onItemToggle?: (node: NodeModel<any>, isOpen: boolean) => void;
|
|
@@ -2163,7 +2164,7 @@ declare const TRANSLATION_FALLBACK: {
|
|
|
2163
2164
|
unknown: string;
|
|
2164
2165
|
};
|
|
2165
2166
|
|
|
2166
|
-
export declare const Tree: ({ list, draggable, onListReorder, onChangeOpen, testId, isInitialOpen, treeRef, itemHasChild, onItemToggle, icons, allowParentReassignment, stickyHeader, height, }: ITreeProps) => JSX_2.Element;
|
|
2167
|
+
export declare const Tree: ({ list, draggable, onListReorder, onChangeOpen, testId, isInitialOpen, autoOpenActiveItems, treeRef: treeRefProp, itemHasChild, onItemToggle, icons, allowParentReassignment, stickyHeader, height, }: ITreeProps) => JSX_2.Element;
|
|
2167
2168
|
|
|
2168
2169
|
export declare enum TriggerType {
|
|
2169
2170
|
TEXT = "Text",
|
package/dist/index.js
CHANGED
|
@@ -6516,26 +6516,39 @@ const TreeItem = ({ node: t, depth: n, isOpen: r, onToggle: i, hasChild: a, drag
|
|
|
6516
6516
|
}, TreePlaceholder = ({ depth: e }) => /* @__PURE__ */ jsx("div", {
|
|
6517
6517
|
className: tree_module_default.placeholder,
|
|
6518
6518
|
style: { left: e * 24 }
|
|
6519
|
-
}), Tree = ({ list: e, draggable: t = !1, onListReorder: n, onChangeOpen: r, testId: i, isInitialOpen: a = !1,
|
|
6520
|
-
let
|
|
6519
|
+
}), Tree = ({ list: e, draggable: t = !1, onListReorder: n, onChangeOpen: r, testId: i, isInitialOpen: a = !1, autoOpenActiveItems: o = !1, treeRef: s, itemHasChild: l, onItemToggle: u, icons: d, allowParentReassignment: f, stickyHeader: m, height: h }) => {
|
|
6520
|
+
let g = s ?? useRef(null), _ = (e) => {
|
|
6521
6521
|
r && r(e);
|
|
6522
|
-
},
|
|
6523
|
-
let n =
|
|
6522
|
+
}, v = (t) => {
|
|
6523
|
+
let n = e.items.find((e) => e.id === t);
|
|
6524
|
+
return n && n.parent ? [n.parent, ...v(n.parent)] : [];
|
|
6525
|
+
};
|
|
6526
|
+
useEffect(() => {
|
|
6527
|
+
if (o) {
|
|
6528
|
+
let t = e.items.find((e) => e.active);
|
|
6529
|
+
if (t) {
|
|
6530
|
+
let e = v(t.id);
|
|
6531
|
+
g.current?.open(e);
|
|
6532
|
+
}
|
|
6533
|
+
}
|
|
6534
|
+
}, [o, e.items]);
|
|
6535
|
+
let y = (e, t) => e?.findIndex((e) => e?.id === t) ?? -1, b = (e, t) => {
|
|
6536
|
+
let n = y(t, e?.parent);
|
|
6524
6537
|
if (n >= 0) {
|
|
6525
6538
|
let r = t?.find((e) => e?.id === t[n]?.parent);
|
|
6526
6539
|
e.parent = r ? r.id : 0;
|
|
6527
6540
|
}
|
|
6528
|
-
},
|
|
6541
|
+
}, x = (e, t) => t?.filter((t) => t?.id !== e?.id) ?? [], S = (e, t, n) => (n?.splice(t, 0, e), n), C = (e) => e.map(({ id: e, parent: t, droppable: n, data: r }) => ({
|
|
6529
6542
|
id: e,
|
|
6530
6543
|
parent: t,
|
|
6531
6544
|
droppable: n,
|
|
6532
6545
|
...r
|
|
6533
|
-
})),
|
|
6546
|
+
})), w = (e, t) => {
|
|
6534
6547
|
let { dragSource: r, dropTarget: i } = t, a = [...e];
|
|
6535
6548
|
if (!n) return;
|
|
6536
|
-
let o =
|
|
6537
|
-
r?.parent === i?.id && o === 0 &&
|
|
6538
|
-
},
|
|
6549
|
+
let o = y(a, r?.id), s = y(a, r?.parent), c = [];
|
|
6550
|
+
r?.parent === i?.id && o === 0 && f && (b(r, a), a = x(r, a), a = S(r, s, a)), c = C(a), n(c);
|
|
6551
|
+
}, T = e?.items?.map(({ id: e, droppable: t, parent: n, name: r, onDrop: i,...a }) => ({
|
|
6539
6552
|
id: e,
|
|
6540
6553
|
text: r,
|
|
6541
6554
|
droppable: t,
|
|
@@ -6549,18 +6562,18 @@ const TreeItem = ({ node: t, depth: n, isOpen: r, onToggle: i, hasChild: a, drag
|
|
|
6549
6562
|
return /* @__PURE__ */ jsxs("div", {
|
|
6550
6563
|
"data-testid": i,
|
|
6551
6564
|
className: list_module_default.list,
|
|
6552
|
-
style: { height:
|
|
6565
|
+
style: { height: h },
|
|
6553
6566
|
children: [e.name && !e.noHeader && /* @__PURE__ */ jsx(ListHeading, {
|
|
6554
6567
|
name: e.name,
|
|
6555
6568
|
actions: e.actions,
|
|
6556
|
-
stickyHeader:
|
|
6569
|
+
stickyHeader: m
|
|
6557
6570
|
}), /* @__PURE__ */ jsx(DndProvider, {
|
|
6558
6571
|
backend: MultiBackend,
|
|
6559
6572
|
options: getBackendOptions(),
|
|
6560
6573
|
context: window,
|
|
6561
6574
|
children: /* @__PURE__ */ jsx(Tree$1, {
|
|
6562
|
-
ref:
|
|
6563
|
-
tree:
|
|
6575
|
+
ref: g,
|
|
6576
|
+
tree: T,
|
|
6564
6577
|
sort: !1,
|
|
6565
6578
|
insertDroppableFirst: !1,
|
|
6566
6579
|
canDrag: () => t,
|
|
@@ -6569,19 +6582,19 @@ const TreeItem = ({ node: t, depth: n, isOpen: r, onToggle: i, hasChild: a, drag
|
|
|
6569
6582
|
},
|
|
6570
6583
|
rootId: 0,
|
|
6571
6584
|
render: (e, { depth: n, isOpen: r, onToggle: i, hasChild: a }) => /* @__PURE__ */ jsx(TreeItem, {
|
|
6572
|
-
hasChild:
|
|
6585
|
+
hasChild: l ? l(e) : a,
|
|
6573
6586
|
node: e,
|
|
6574
6587
|
depth: n,
|
|
6575
6588
|
isOpen: r,
|
|
6576
6589
|
onToggle: () => {
|
|
6577
|
-
|
|
6590
|
+
u?.(e, !r), i();
|
|
6578
6591
|
},
|
|
6579
6592
|
draggable: t,
|
|
6580
|
-
icons:
|
|
6593
|
+
icons: d,
|
|
6581
6594
|
onDrop: e.data?.onDrop
|
|
6582
6595
|
}),
|
|
6583
|
-
onDrop:
|
|
6584
|
-
onChangeOpen:
|
|
6596
|
+
onDrop: w,
|
|
6597
|
+
onChangeOpen: _,
|
|
6585
6598
|
dropTargetOffset: 10,
|
|
6586
6599
|
placeholderRender: (e, { depth: t }) => /* @__PURE__ */ jsx(TreePlaceholder, { depth: t }),
|
|
6587
6600
|
placeholderComponent: "div",
|
package/package.json
CHANGED