@apia/tree 2.0.9 → 2.0.11

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.
Files changed (54) hide show
  1. package/dist/OOTree/OOTreeChildren.d.ts +14 -0
  2. package/dist/OOTree/OOTreeChildren.d.ts.map +1 -0
  3. package/dist/OOTree/OOTreeChildren.js +17 -0
  4. package/dist/OOTree/OOTreeChildren.js.map +1 -0
  5. package/dist/OOTree/OOTreeNode.d.ts +30 -0
  6. package/dist/OOTree/OOTreeNode.d.ts.map +1 -0
  7. package/dist/OOTree/OOTreeNode.js +133 -0
  8. package/dist/OOTree/OOTreeNode.js.map +1 -0
  9. package/dist/OOTree/index.d.ts +36 -0
  10. package/dist/OOTree/index.d.ts.map +1 -0
  11. package/dist/OOTree/index.js +126 -0
  12. package/dist/OOTree/index.js.map +1 -0
  13. package/dist/OOTree/types.d.ts +11 -0
  14. package/dist/OOTree/types.d.ts.map +1 -0
  15. package/dist/SearchLabel.js +31 -0
  16. package/dist/SearchLabel.js.map +1 -0
  17. package/dist/Tree.d.ts +7 -0
  18. package/dist/Tree.d.ts.map +1 -0
  19. package/dist/Tree.js +131 -0
  20. package/dist/Tree.js.map +1 -0
  21. package/dist/TreeContext.d.ts +13 -0
  22. package/dist/TreeContext.d.ts.map +1 -0
  23. package/dist/TreeContext.js +22 -0
  24. package/dist/TreeContext.js.map +1 -0
  25. package/dist/TreeDataController.d.ts +116 -0
  26. package/dist/TreeDataController.d.ts.map +1 -0
  27. package/dist/TreeDataController.js +616 -0
  28. package/dist/TreeDataController.js.map +1 -0
  29. package/dist/TreeItem.js +51 -0
  30. package/dist/TreeItem.js.map +1 -0
  31. package/dist/TreeItemChildren.js +20 -0
  32. package/dist/TreeItemChildren.js.map +1 -0
  33. package/dist/TreeItemLabel.js +72 -0
  34. package/dist/TreeItemLabel.js.map +1 -0
  35. package/dist/getDomProps.js +37 -0
  36. package/dist/getDomProps.js.map +1 -0
  37. package/dist/index.d.ts +7 -417
  38. package/dist/index.js +6 -1546
  39. package/dist/index.js.map +1 -1
  40. package/dist/renderers/DefaultIconRenderer.js +18 -0
  41. package/dist/renderers/DefaultIconRenderer.js.map +1 -0
  42. package/dist/renderers/DefaultLabelRenderer.js +10 -0
  43. package/dist/renderers/DefaultLabelRenderer.js.map +1 -0
  44. package/dist/renderers/Spacer.js +10 -0
  45. package/dist/renderers/Spacer.js.map +1 -0
  46. package/dist/types.d.ts +211 -0
  47. package/dist/types.d.ts.map +1 -0
  48. package/dist/useTreeData.d.ts +25 -0
  49. package/dist/useTreeData.d.ts.map +1 -0
  50. package/dist/useTreeData.js +131 -0
  51. package/dist/useTreeData.js.map +1 -0
  52. package/dist/util.js +220 -0
  53. package/dist/util.js.map +1 -0
  54. package/package.json +6 -6
@@ -0,0 +1,131 @@
1
+ import { useMount } from 'ahooks';
2
+ import uniqueId from 'lodash-es/uniqueId';
3
+ import React from 'react';
4
+ import { shallowEqual } from 'react-redux';
5
+ import TreeDataController from './TreeDataController.js';
6
+ import { selectAllNodesBetweenTwoNodes } from './util.js';
7
+ import { useLatest, usePropsSelector, getSpecificParent } from '@apia/util';
8
+
9
+ function useTreeData({ name, treeProps }) {
10
+ const props = useLatest(treeProps);
11
+ const handler = React.useMemo(
12
+ () => props?.current.controller ?? new TreeDataController(name, props),
13
+ // eslint-disable-next-line react-hooks/exhaustive-deps
14
+ []
15
+ );
16
+ useMount(() => {
17
+ treeProps?.initialNodes?.forEach((current) => handler.append(current));
18
+ });
19
+ const data = usePropsSelector("root", {
20
+ comparator: shallowEqual,
21
+ propsStore: handler.propsStore,
22
+ selector: (current) => ({
23
+ children: current.children ?? [],
24
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
25
+ forceUpdate: current.forceUpdate
26
+ })
27
+ });
28
+ const keyHandlerId = React.useMemo(() => `keyHandler${uniqueId()}`, []);
29
+ const keyHandlerRef = React.useRef(null);
30
+ const focusOnNode = React.useCallback(
31
+ (key, retry = 3) => {
32
+ if (keyHandlerRef.current) {
33
+ const focusElement = keyHandlerRef.current.querySelector(
34
+ `[data-key="${key}"]`
35
+ );
36
+ keyHandlerRef.current?.focus();
37
+ if (focusElement) {
38
+ const actualFocusElement = (treeProps.focusGetter ?? ((liElement) => liElement.querySelector(
39
+ ":scope > .tree__nodeItemLabel"
40
+ )))(focusElement);
41
+ const nodeProps = handler.propsStore.getFieldProps(key);
42
+ if (!treeProps.focusGetter || !nodeProps.labelRenderer)
43
+ actualFocusElement.classList.add("focused");
44
+ actualFocusElement.scrollIntoView({
45
+ inline: "nearest",
46
+ block: "nearest"
47
+ });
48
+ } else if (retry > 0)
49
+ setTimeout(() => focusOnNode(key, retry - 1), 30);
50
+ }
51
+ },
52
+ [handler.propsStore, treeProps.focusGetter]
53
+ );
54
+ React.useEffect(() => {
55
+ const unsuscribe1 = handler.on("mustFocus", (node) => focusOnNode(node));
56
+ const unsuscribe2 = handler.on(
57
+ "onArrowUpOnFirstElement",
58
+ () => treeProps.onArrowUpOnFirstElement?.()
59
+ );
60
+ return () => {
61
+ unsuscribe1();
62
+ unsuscribe2();
63
+ };
64
+ }, [focusOnNode, handler, treeProps]);
65
+ return {
66
+ data,
67
+ handler,
68
+ keyHandler: {
69
+ id: keyHandlerId,
70
+ onKeyDown: React.useCallback(
71
+ (ev) => {
72
+ if (ev.key === "Enter") {
73
+ const key = handler.state.focusedNode;
74
+ if (key) {
75
+ const nodeProps = handler.propsStore.getFieldProps(key);
76
+ treeProps.onNodeClick?.(ev, nodeProps);
77
+ }
78
+ } else {
79
+ handler.handleKey(ev);
80
+ }
81
+ },
82
+ [handler, treeProps]
83
+ ),
84
+ onMouseDown: React.useCallback(
85
+ (ev) => {
86
+ const previousFocused = handler.state.focusedNode;
87
+ if (previousFocused !== null && ev.shiftKey && handler.configuration.current?.isMultiple)
88
+ ev.preventDefault();
89
+ },
90
+ [handler.configuration, handler.state.focusedNode]
91
+ ),
92
+ onClick: React.useCallback(
93
+ (ev) => {
94
+ if (getSpecificParent(
95
+ ev.target,
96
+ (current) => current.classList.contains("tree__expandIcon")
97
+ ))
98
+ return;
99
+ const node = getSpecificParent(
100
+ ev.target,
101
+ (current) => !!current.getAttribute("data-key")
102
+ );
103
+ if (node) {
104
+ const previousFocused = handler.state.focusedNode;
105
+ const key = node.getAttribute("data-key");
106
+ const nodeProps = handler.propsStore.getFieldProps(key);
107
+ treeProps.onNodeClick?.(ev, nodeProps);
108
+ if (previousFocused !== null && ev.shiftKey && handler.configuration.current?.isMultiple) {
109
+ selectAllNodesBetweenTwoNodes(
110
+ handler,
111
+ previousFocused,
112
+ key,
113
+ true
114
+ );
115
+ } else {
116
+ handler.setFocusedNode(key);
117
+ handler.setSelectedNodesByClickEvent(ev);
118
+ }
119
+ if (key)
120
+ focusOnNode(key);
121
+ }
122
+ },
123
+ [focusOnNode, handler, treeProps]
124
+ ),
125
+ ref: keyHandlerRef
126
+ }
127
+ };
128
+ }
129
+
130
+ export { useTreeData as default };
131
+ //# sourceMappingURL=useTreeData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTreeData.js","sources":["../src/useTreeData.ts"],"sourcesContent":["import { useMount } from 'ahooks';\r\nimport uniqueId from 'lodash-es/uniqueId';\r\nimport React from 'react';\r\nimport { shallowEqual } from 'react-redux';\r\nimport TreeDataController from './TreeDataController';\r\nimport { TTreeProps, TDataNode, TId } from './types';\r\nimport { selectAllNodesBetweenTwoNodes } from './util';\r\nimport { getSpecificParent, useLatest, usePropsSelector } from '@apia/util';\r\n\r\ninterface IUseTreeData<\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n> {\r\n name: string;\r\n treeProps: TTreeProps<NodeProps, NodeType>;\r\n}\r\n\r\nexport default function useTreeData<\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>({ name, treeProps }: IUseTreeData<NodeProps, NodeType>) {\r\n const props = useLatest(treeProps);\r\n const handler = React.useMemo(\r\n () =>\r\n props?.current.controller ??\r\n new TreeDataController<NodeProps, NodeType>(name, props),\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n [],\r\n );\r\n\r\n useMount(() => {\r\n treeProps?.initialNodes?.forEach((current) => handler.append(current));\r\n });\r\n\r\n const data = usePropsSelector('root', {\r\n comparator: shallowEqual,\r\n propsStore: handler.propsStore,\r\n selector: (current) => ({\r\n children: current.children ?? [],\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\r\n forceUpdate: (current as any).forceUpdate as number,\r\n }),\r\n });\r\n\r\n const keyHandlerId = React.useMemo(() => `keyHandler${uniqueId()}`, []);\r\n const keyHandlerRef = React.useRef<HTMLDivElement | null>(null);\r\n\r\n const focusOnNode = React.useCallback(\r\n (key: TId, retry = 3) => {\r\n if (keyHandlerRef.current) {\r\n const focusElement = keyHandlerRef.current.querySelector(\r\n `[data-key=\"${key}\"]`,\r\n ) as HTMLElement;\r\n keyHandlerRef.current?.focus();\r\n\r\n if (focusElement) {\r\n const actualFocusElement = (\r\n treeProps.focusGetter ??\r\n ((liElement: HTMLElement) =>\r\n liElement.querySelector(\r\n ':scope > .tree__nodeItemLabel',\r\n ) as HTMLElement)\r\n )(focusElement);\r\n\r\n const nodeProps = handler.propsStore.getFieldProps(key);\r\n\r\n if (!treeProps.focusGetter || !nodeProps.labelRenderer)\r\n actualFocusElement.classList.add('focused');\r\n actualFocusElement.scrollIntoView({\r\n inline: 'nearest',\r\n block: 'nearest',\r\n });\r\n } else if (retry > 0) setTimeout(() => focusOnNode(key, retry - 1), 30);\r\n }\r\n },\r\n [handler.propsStore, treeProps.focusGetter],\r\n );\r\n\r\n React.useEffect(() => {\r\n const unsuscribe1 = handler.on('mustFocus', (node) => focusOnNode(node));\r\n const unsuscribe2 = handler.on('onArrowUpOnFirstElement', () =>\r\n treeProps.onArrowUpOnFirstElement?.(),\r\n );\r\n\r\n return () => {\r\n unsuscribe1();\r\n unsuscribe2();\r\n };\r\n }, [focusOnNode, handler, treeProps]);\r\n\r\n return {\r\n data,\r\n handler,\r\n keyHandler: {\r\n id: keyHandlerId,\r\n onKeyDown: React.useCallback(\r\n (ev: React.KeyboardEvent) => {\r\n if (ev.key === 'Enter') {\r\n const key = handler.state.focusedNode;\r\n if (key) {\r\n const nodeProps = handler.propsStore.getFieldProps(key);\r\n treeProps.onNodeClick?.(ev, nodeProps);\r\n }\r\n } else {\r\n handler.handleKey(ev);\r\n }\r\n },\r\n [handler, treeProps],\r\n ),\r\n onMouseDown: React.useCallback(\r\n (ev: React.MouseEvent) => {\r\n const previousFocused = handler.state.focusedNode;\r\n if (\r\n previousFocused !== null &&\r\n ev.shiftKey &&\r\n handler.configuration.current?.isMultiple\r\n )\r\n ev.preventDefault();\r\n },\r\n [handler.configuration, handler.state.focusedNode],\r\n ),\r\n onClick: React.useCallback(\r\n (ev: React.MouseEvent) => {\r\n if (\r\n getSpecificParent(ev.target as HTMLElement, (current) =>\r\n current.classList.contains('tree__expandIcon'),\r\n )\r\n )\r\n return;\r\n\r\n const node = getSpecificParent(\r\n ev.target as HTMLElement,\r\n (current) => !!current.getAttribute('data-key'),\r\n );\r\n if (node) {\r\n const previousFocused = handler.state.focusedNode;\r\n const key = node.getAttribute('data-key') as string;\r\n\r\n const nodeProps = handler.propsStore.getFieldProps(key);\r\n treeProps.onNodeClick?.(ev, nodeProps);\r\n\r\n if (\r\n previousFocused !== null &&\r\n ev.shiftKey &&\r\n handler.configuration.current?.isMultiple\r\n ) {\r\n selectAllNodesBetweenTwoNodes(\r\n handler,\r\n previousFocused,\r\n key,\r\n true,\r\n );\r\n } else {\r\n handler.setFocusedNode(key);\r\n handler.setSelectedNodesByClickEvent(ev);\r\n }\r\n\r\n if (key) focusOnNode(key);\r\n }\r\n },\r\n [focusOnNode, handler, treeProps],\r\n ),\r\n ref: keyHandlerRef,\r\n },\r\n };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;AAAA,YACX,EAAG,CAAA,MAAA;AAAA,YACH,CAAC,OAAY,KAAA,CAAC,CAAC,OAAA,CAAQ,aAAa,UAAU,CAAA;AAAA,WAChD,CAAA;AACA,UAAA,IAAI,IAAM,EAAA;AACR,YAAM,MAAA,eAAA,GAAkB,QAAQ,KAAM,CAAA,WAAA,CAAA;AACtC,YAAM,MAAA,GAAA,GAAM,IAAK,CAAA,YAAA,CAAa,UAAU,CAAA,CAAA;AAExC,YAAA,MAAM,SAAY,GAAA,OAAA,CAAQ,UAAW,CAAA,aAAA,CAAc,GAAG,CAAA,CAAA;AACtD,YAAU,SAAA,CAAA,WAAA,GAAc,IAAI,SAAS,CAAA,CAAA;AAErC,YAAA,IACE,oBAAoB,IACpB,IAAA,EAAA,CAAG,YACH,OAAQ,CAAA,aAAA,CAAc,SAAS,UAC/B,EAAA;AACA,cAAA,6BAAA;AAAA,gBACE,OAAA;AAAA,gBACA,eAAA;AAAA,gBACA,GAAA;AAAA,gBACA,IAAA;AAAA,eACF,CAAA;AAAA,aACK,MAAA;AACL,cAAA,OAAA,CAAQ,eAAe,GAAG,CAAA,CAAA;AAC1B,cAAA,OAAA,CAAQ,6BAA6B,EAAE,CAAA,CAAA;AAAA,aACzC;AAEA,YAAI,IAAA,GAAA;AAAK,cAAA,WAAA,CAAY,GAAG,CAAA,CAAA;AAAA,WAC1B;AAAA,SACF;AAAA,QACA,CAAC,WAAa,EAAA,OAAA,EAAS,SAAS,CAAA;AAAA,OAClC;AAAA,MACA,GAAK,EAAA,aAAA;AAAA,KACP;AAAA,GACF,CAAA;AACF;;;;"}
package/dist/util.js ADDED
@@ -0,0 +1,220 @@
1
+ const getLastVisibleChild = (handler, id, avoidFiltered) => {
2
+ const nodeProps = handler.propsStore.getFieldProps(id);
3
+ if (id !== "root" && (nodeProps.isDisabled || !nodeProps.isExpanded) || nodeProps.children.length === 0)
4
+ return null;
5
+ for (let i = nodeProps.children.length - 1; i >= 0; i--) {
6
+ const currentId = nodeProps.children[i];
7
+ const currentProps = handler.propsStore.getFieldProps(currentId);
8
+ if (!avoidFiltered || !currentProps.isFiltered) {
9
+ const lastChildrenLastChildren = getLastVisibleChild(
10
+ handler,
11
+ currentId,
12
+ avoidFiltered
13
+ );
14
+ return lastChildrenLastChildren !== null ? lastChildrenLastChildren : currentId;
15
+ }
16
+ }
17
+ return null;
18
+ };
19
+ const getPreviousChild = (handler, id, avoidFiltered) => {
20
+ const nodeProps = handler.propsStore.getFieldProps(id);
21
+ const fatherProps = handler.propsStore.getFieldProps(nodeProps.parentId);
22
+ let childPosition = fatherProps.children?.findIndex((current) => current === nodeProps.id) ?? -1;
23
+ while (childPosition > 0) {
24
+ const prevSibling = handler.propsStore.getFieldProps(
25
+ fatherProps.children[childPosition - 1]
26
+ );
27
+ const prevSiblingLastChild = getLastVisibleChild(
28
+ handler,
29
+ prevSibling.id,
30
+ avoidFiltered
31
+ );
32
+ if (prevSiblingLastChild !== null)
33
+ return prevSiblingLastChild;
34
+ if (!avoidFiltered || !prevSibling.isFiltered)
35
+ return prevSibling.id;
36
+ childPosition--;
37
+ }
38
+ if (nodeProps.parentId === "root")
39
+ return null;
40
+ return nodeProps.parentId;
41
+ };
42
+ const getFirstNonFilteredChild = (handler, id) => {
43
+ const nodeProps = handler.propsStore.getFieldProps(id);
44
+ for (const child of nodeProps.children) {
45
+ if (!handler.propsStore.getFieldProps(child).isFiltered)
46
+ return child;
47
+ }
48
+ return null;
49
+ };
50
+ const getNextChild = (handler, id, avoidChildren, avoidFiltered) => {
51
+ const nodeProps = handler.propsStore.getFieldProps(id);
52
+ const fatherProps = handler.propsStore.getFieldProps(nodeProps.parentId);
53
+ let childPosition = fatherProps.children?.findIndex((current) => current === nodeProps.id) ?? Infinity;
54
+ if (!avoidChildren && nodeProps.isExpanded) {
55
+ if (!avoidFiltered && nodeProps.children.length > 0)
56
+ return nodeProps.children[0];
57
+ const firstNonFilteredChild = getFirstNonFilteredChild(
58
+ handler,
59
+ nodeProps.id
60
+ );
61
+ if (firstNonFilteredChild !== null)
62
+ return firstNonFilteredChild;
63
+ }
64
+ while (childPosition < fatherProps.children.length - 1) {
65
+ const nextSibling = fatherProps.children[childPosition + 1];
66
+ if (!avoidFiltered || !handler.propsStore.getFieldProps(nextSibling).isFiltered)
67
+ return nextSibling;
68
+ childPosition++;
69
+ }
70
+ if (nodeProps.parentId === "root")
71
+ return null;
72
+ return getNextChild(handler, fatherProps.id, true, avoidFiltered);
73
+ };
74
+ const getNextNodeWithKey = (handler, id, firstKey, avoidFiltered) => {
75
+ let nextChildWithKey = id;
76
+ do {
77
+ nextChildWithKey = getNextChild(
78
+ handler,
79
+ nextChildWithKey,
80
+ false,
81
+ avoidFiltered
82
+ );
83
+ if (nextChildWithKey !== null) {
84
+ const nodeProps2 = handler.propsStore.getFieldProps(nextChildWithKey);
85
+ if ((!nodeProps2.isFiltered || !avoidFiltered) && nodeProps2.label.toUpperCase().startsWith(firstKey.toUpperCase()))
86
+ return nextChildWithKey;
87
+ }
88
+ } while (nextChildWithKey !== null);
89
+ const nodeProps = handler.propsStore.getFieldProps(id);
90
+ const positionInParent = handler.propsStore.getFieldProps(nodeProps.parentId).children.findIndex((current) => current === id);
91
+ if (nodeProps.parentId !== "root" || positionInParent > 0) {
92
+ const [firstChildOfTree] = handler.propsStore.getFieldProps("root").children;
93
+ const firstChildProps = handler.propsStore.getFieldProps(firstChildOfTree);
94
+ if (firstChildOfTree && (!avoidFiltered || !firstChildProps.isFiltered) && firstChildProps.label.toUpperCase().startsWith(firstKey.toUpperCase()))
95
+ return firstChildOfTree;
96
+ nextChildWithKey = firstChildOfTree;
97
+ do {
98
+ nextChildWithKey = getNextChild(
99
+ handler,
100
+ nextChildWithKey,
101
+ false,
102
+ avoidFiltered
103
+ );
104
+ if (nextChildWithKey) {
105
+ const currentNodeProps = handler.propsStore.getFieldProps(nextChildWithKey);
106
+ if ((!avoidFiltered || !currentNodeProps.isFiltered) && currentNodeProps.label.toUpperCase().startsWith(firstKey.toUpperCase()))
107
+ return nextChildWithKey;
108
+ }
109
+ } while (nextChildWithKey !== id && nextChildWithKey !== null);
110
+ }
111
+ return null;
112
+ };
113
+ const getNodePath = (handler, nodeId) => {
114
+ const path = [nodeId];
115
+ let currentStep = nodeId;
116
+ do {
117
+ currentStep = handler.propsStore.getFieldProps(currentStep).parentId;
118
+ path.unshift(currentStep);
119
+ } while (currentStep !== "root");
120
+ return path;
121
+ };
122
+ const getCommonAncestor = (handler, oneNodeId, anotherNodeId) => {
123
+ const oneNodePath = getNodePath(handler, oneNodeId);
124
+ const anotherNodePath = getNodePath(handler, anotherNodeId);
125
+ for (let i = oneNodePath.length - 1; i >= 0; i--) {
126
+ const anotherNodeIndex = anotherNodePath.indexOf(oneNodePath[i]);
127
+ if (anotherNodeIndex !== -1)
128
+ return {
129
+ commonAncestor: oneNodePath[i],
130
+ oneNodeAncestorChild: oneNodePath[i + 1],
131
+ anotherNodeAncestorChild: anotherNodePath[anotherNodeIndex + 1]
132
+ };
133
+ }
134
+ console.warn(
135
+ "This point should have never been reached since the root node is common to all nodes",
136
+ { oneNodeId, anotherNodeId, oneNodePath, anotherNodePath }
137
+ );
138
+ return null;
139
+ };
140
+ const unfilterNodes = (handler) => {
141
+ handler.state.filteredNodes.forEach((current) => {
142
+ handler.propsStore.updateField(
143
+ current,
144
+ { isFiltered: false },
145
+ { noEmit: true }
146
+ );
147
+ });
148
+ const firstChild = handler.propsStore.getFieldProps("root").children[0];
149
+ if (firstChild)
150
+ handler.setFocusedNode(firstChild);
151
+ handler.setState({ filteredNodes: [] });
152
+ };
153
+ const matchNodesAgainstString = (handler, searchString, nodeId = "root") => {
154
+ let hasMatched = false;
155
+ let matchNode = null;
156
+ const nodeProps = handler.propsStore.getFieldProps(nodeId);
157
+ if (nodeId !== "root" && nodeProps.label.match(new RegExp(searchString, "i"))) {
158
+ handler.propsStore.updateField(nodeId, { isFiltered: false });
159
+ hasMatched = true;
160
+ matchNode = nodeProps.id;
161
+ handler.setState({
162
+ filteredNodes: handler.state.filteredNodes.filter(
163
+ (current) => current !== nodeId
164
+ )
165
+ });
166
+ }
167
+ let hasChildrenMatched = false;
168
+ nodeProps.children.forEach((current) => {
169
+ hasChildrenMatched = matchNodesAgainstString(handler, searchString, current) || hasMatched;
170
+ hasMatched = hasChildrenMatched || hasMatched;
171
+ if (hasMatched && !matchNode)
172
+ matchNode = current;
173
+ });
174
+ if (hasChildrenMatched) {
175
+ handler.propsStore.updateField(nodeId, { isExpanded: true });
176
+ if (hasMatched && !matchNode)
177
+ matchNode = nodeId;
178
+ }
179
+ if (!hasMatched) {
180
+ handler.propsStore.updateField(
181
+ nodeId,
182
+ { isFiltered: true },
183
+ { noEmit: true }
184
+ );
185
+ handler.setState({
186
+ filteredNodes: [...handler.state.filteredNodes, nodeId]
187
+ });
188
+ }
189
+ if (matchNode !== null)
190
+ handler.setFocusedNode(matchNode);
191
+ return hasMatched;
192
+ };
193
+ const selectAllNodesBetweenTwoNodes = (handler, oneNodeId, anotherNodeId, avoidFiltered) => {
194
+ const commonAncestorData = getCommonAncestor(
195
+ handler,
196
+ oneNodeId,
197
+ anotherNodeId
198
+ );
199
+ if (commonAncestorData) {
200
+ const { anotherNodeAncestorChild, commonAncestor, oneNodeAncestorChild } = commonAncestorData;
201
+ const ancestorProps = handler.propsStore.getFieldProps(commonAncestor);
202
+ const oneNodePosition = ancestorProps.children.findIndex(
203
+ (current) => current === oneNodeAncestorChild
204
+ );
205
+ const anotherNodePosition = ancestorProps.children.findIndex(
206
+ (current) => current === anotherNodeAncestorChild
207
+ );
208
+ let currentId = oneNodePosition >= anotherNodePosition ? anotherNodeId : oneNodeId;
209
+ const lastNodeId = oneNodePosition < anotherNodePosition ? anotherNodeId : oneNodeId;
210
+ handler.toggleNodeSelectedState(currentId, true);
211
+ do {
212
+ currentId = getNextChild(handler, currentId, false, avoidFiltered);
213
+ if (currentId !== null)
214
+ handler.toggleNodeSelectedState(currentId, true);
215
+ } while (currentId !== lastNodeId && currentId !== null);
216
+ }
217
+ };
218
+
219
+ export { getCommonAncestor, getFirstNonFilteredChild, getLastVisibleChild, getNextChild, getNextNodeWithKey, getNodePath, getPreviousChild, matchNodesAgainstString, selectAllNodesBetweenTwoNodes, unfilterNodes };
220
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sources":["../src/util.ts"],"sourcesContent":["import TreeDataController from './TreeDataController';\r\nimport { TDataNode, TId } from './types';\r\n\r\nexport const getLastVisibleChild: <\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>(\r\n handler: TreeDataController<NodeProps, NodeType>,\r\n id: TId,\r\n avoidFiltered?: boolean,\r\n) => TId | null = (handler, id, avoidFiltered) => {\r\n const nodeProps = handler.propsStore.getFieldProps(id);\r\n if (\r\n (id !== 'root' && (nodeProps.isDisabled || !nodeProps.isExpanded)) ||\r\n nodeProps.children.length === 0\r\n )\r\n return null;\r\n\r\n for (let i = nodeProps.children.length - 1; i >= 0; i--) {\r\n const currentId = nodeProps.children[i];\r\n const currentProps = handler.propsStore.getFieldProps(currentId);\r\n if (!avoidFiltered || !currentProps.isFiltered) {\r\n const lastChildrenLastChildren = getLastVisibleChild(\r\n handler,\r\n currentId,\r\n avoidFiltered,\r\n );\r\n return lastChildrenLastChildren !== null\r\n ? lastChildrenLastChildren\r\n : currentId;\r\n }\r\n }\r\n return null;\r\n};\r\n\r\nexport const getPreviousChild: <\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>(\r\n handler: TreeDataController<NodeProps, NodeType>,\r\n id: TId,\r\n avoidFiltered?: boolean,\r\n) => TId | null = (handler, id, avoidFiltered) => {\r\n const nodeProps = handler.propsStore.getFieldProps(id);\r\n const fatherProps = handler.propsStore.getFieldProps(nodeProps.parentId);\r\n let childPosition =\r\n fatherProps.children?.findIndex((current) => current === nodeProps.id) ??\r\n -1;\r\n\r\n while (childPosition > 0) {\r\n const prevSibling = handler.propsStore.getFieldProps(\r\n fatherProps.children[childPosition - 1],\r\n );\r\n const prevSiblingLastChild = getLastVisibleChild(\r\n handler,\r\n prevSibling.id,\r\n avoidFiltered,\r\n );\r\n if (prevSiblingLastChild !== null) return prevSiblingLastChild;\r\n if (!avoidFiltered || !prevSibling.isFiltered) return prevSibling.id;\r\n\r\n childPosition--;\r\n }\r\n if (nodeProps.parentId === 'root') return null;\r\n return nodeProps.parentId;\r\n};\r\n\r\nexport const getFirstNonFilteredChild: <\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>(\r\n handler: TreeDataController<NodeProps, NodeType>,\r\n id: TId,\r\n) => null | TId = (handler, id) => {\r\n const nodeProps = handler.propsStore.getFieldProps(id);\r\n // eslint-disable-next-line no-restricted-syntax\r\n for (const child of nodeProps.children) {\r\n if (!handler.propsStore.getFieldProps(child).isFiltered) return child;\r\n }\r\n return null;\r\n};\r\n\r\nexport const getNextChild: <\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>(\r\n handler: TreeDataController<NodeProps, NodeType>,\r\n id: TId,\r\n avoidChildren?: boolean,\r\n avoidFiltered?: boolean,\r\n) => TId | null = (handler, id, avoidChildren, avoidFiltered) => {\r\n const nodeProps = handler.propsStore.getFieldProps(id);\r\n const fatherProps = handler.propsStore.getFieldProps(nodeProps.parentId);\r\n let childPosition =\r\n fatherProps.children?.findIndex((current) => current === nodeProps.id) ??\r\n Infinity;\r\n if (!avoidChildren && nodeProps.isExpanded) {\r\n if (!avoidFiltered && nodeProps.children.length > 0)\r\n return nodeProps.children[0];\r\n\r\n const firstNonFilteredChild = getFirstNonFilteredChild(\r\n handler,\r\n nodeProps.id,\r\n );\r\n if (firstNonFilteredChild !== null) return firstNonFilteredChild;\r\n }\r\n while (childPosition < fatherProps.children.length - 1) {\r\n const nextSibling = fatherProps.children[childPosition + 1];\r\n if (\r\n !avoidFiltered ||\r\n !handler.propsStore.getFieldProps(nextSibling).isFiltered\r\n )\r\n return nextSibling;\r\n childPosition++;\r\n }\r\n if (nodeProps.parentId === 'root') return null;\r\n return getNextChild(handler, fatherProps.id, true, avoidFiltered);\r\n};\r\n\r\nexport const getNextNodeWithKey: <\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>(\r\n handler: TreeDataController<NodeProps, NodeType>,\r\n id: TId,\r\n firstKey: string,\r\n avoidFiltered?: boolean,\r\n) => TId | null = (handler, id, firstKey, avoidFiltered) => {\r\n let nextChildWithKey: TId | null = id;\r\n do {\r\n nextChildWithKey = getNextChild(\r\n handler,\r\n nextChildWithKey,\r\n false,\r\n avoidFiltered,\r\n );\r\n if (nextChildWithKey !== null) {\r\n const nodeProps = handler.propsStore.getFieldProps(nextChildWithKey);\r\n if (\r\n (!nodeProps.isFiltered || !avoidFiltered) &&\r\n nodeProps.label.toUpperCase().startsWith(firstKey.toUpperCase())\r\n )\r\n return nextChildWithKey;\r\n }\r\n } while (nextChildWithKey !== null);\r\n\r\n const nodeProps = handler.propsStore.getFieldProps(id);\r\n const positionInParent = handler.propsStore\r\n .getFieldProps(nodeProps.parentId)\r\n .children.findIndex((current) => current === id);\r\n\r\n if (nodeProps.parentId !== 'root' || positionInParent > 0) {\r\n const [firstChildOfTree] =\r\n handler.propsStore.getFieldProps('root').children;\r\n const firstChildProps = handler.propsStore.getFieldProps(firstChildOfTree);\r\n\r\n if (\r\n firstChildOfTree &&\r\n (!avoidFiltered || !firstChildProps.isFiltered) &&\r\n firstChildProps.label.toUpperCase().startsWith(firstKey.toUpperCase())\r\n )\r\n return firstChildOfTree;\r\n\r\n nextChildWithKey = firstChildOfTree;\r\n do {\r\n nextChildWithKey = getNextChild(\r\n handler,\r\n nextChildWithKey,\r\n false,\r\n avoidFiltered,\r\n );\r\n if (nextChildWithKey) {\r\n const currentNodeProps =\r\n handler.propsStore.getFieldProps(nextChildWithKey);\r\n if (\r\n (!avoidFiltered || !currentNodeProps.isFiltered) &&\r\n currentNodeProps.label\r\n .toUpperCase()\r\n .startsWith(firstKey.toUpperCase())\r\n )\r\n return nextChildWithKey;\r\n }\r\n } while (nextChildWithKey !== id && nextChildWithKey !== null);\r\n }\r\n\r\n return null;\r\n};\r\n\r\nexport const getNodePath: <\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>(\r\n handler: TreeDataController<NodeProps, NodeType>,\r\n nodeId: TId,\r\n) => TId[] = (handler, nodeId) => {\r\n const path: TId[] = [nodeId];\r\n let currentStep: TId = nodeId;\r\n do {\r\n currentStep = handler.propsStore.getFieldProps(currentStep).parentId;\r\n path.unshift(currentStep);\r\n } while (currentStep !== 'root');\r\n return path;\r\n};\r\n\r\nexport const getCommonAncestor: <\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>(\r\n handler: TreeDataController<NodeProps, NodeType>,\r\n oneNodeId: TId,\r\n anotherNodeId: TId,\r\n) => {\r\n commonAncestor: TId;\r\n oneNodeAncestorChild: TId;\r\n anotherNodeAncestorChild: TId;\r\n} | null = (handler, oneNodeId, anotherNodeId) => {\r\n const oneNodePath = getNodePath(handler, oneNodeId);\r\n const anotherNodePath = getNodePath(handler, anotherNodeId);\r\n\r\n for (let i = oneNodePath.length - 1; i >= 0; i--) {\r\n const anotherNodeIndex = anotherNodePath.indexOf(oneNodePath[i]);\r\n if (anotherNodeIndex !== -1)\r\n return {\r\n commonAncestor: oneNodePath[i],\r\n oneNodeAncestorChild: oneNodePath[i + 1],\r\n anotherNodeAncestorChild: anotherNodePath[anotherNodeIndex + 1],\r\n };\r\n }\r\n\r\n console.warn(\r\n 'This point should have never been reached since the root node is common to all nodes',\r\n { oneNodeId, anotherNodeId, oneNodePath, anotherNodePath },\r\n );\r\n return null;\r\n};\r\n\r\nexport const unfilterNodes: <\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>(\r\n handler: TreeDataController<NodeProps, NodeType>,\r\n) => void = (handler) => {\r\n handler.state.filteredNodes.forEach((current) => {\r\n handler.propsStore.updateField(\r\n current,\r\n { isFiltered: false },\r\n { noEmit: true },\r\n );\r\n });\r\n\r\n const firstChild = handler.propsStore.getFieldProps('root').children[0];\r\n if (firstChild) handler.setFocusedNode(firstChild);\r\n handler.setState({ filteredNodes: [] });\r\n};\r\n\r\nexport const matchNodesAgainstString: <\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>(\r\n handler: TreeDataController<NodeProps, NodeType>,\r\n searchString: string,\r\n nodeId?: TId,\r\n) => boolean = (handler, searchString, nodeId = 'root') => {\r\n let hasMatched = false;\r\n let matchNode: TId | null = null;\r\n const nodeProps = handler.propsStore.getFieldProps(nodeId);\r\n if (\r\n nodeId !== 'root' &&\r\n nodeProps.label.match(new RegExp(searchString, 'i'))\r\n ) {\r\n handler.propsStore.updateField(nodeId, { isFiltered: false });\r\n hasMatched = true;\r\n matchNode = nodeProps.id;\r\n handler.setState({\r\n filteredNodes: handler.state.filteredNodes.filter(\r\n (current) => current !== nodeId,\r\n ),\r\n });\r\n }\r\n let hasChildrenMatched = false;\r\n nodeProps.children.forEach((current) => {\r\n hasChildrenMatched =\r\n matchNodesAgainstString(handler, searchString, current) || hasMatched;\r\n hasMatched = hasChildrenMatched || hasMatched;\r\n if (hasMatched && !matchNode) matchNode = current;\r\n });\r\n if (hasChildrenMatched) {\r\n handler.propsStore.updateField(nodeId, { isExpanded: true });\r\n if (hasMatched && !matchNode) matchNode = nodeId;\r\n }\r\n if (!hasMatched) {\r\n handler.propsStore.updateField(\r\n nodeId,\r\n { isFiltered: true },\r\n { noEmit: true },\r\n );\r\n handler.setState({\r\n filteredNodes: [...handler.state.filteredNodes, nodeId],\r\n });\r\n }\r\n if (matchNode !== null) handler.setFocusedNode(matchNode);\r\n return hasMatched;\r\n};\r\n\r\nexport const selectAllNodesBetweenTwoNodes: <\r\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\r\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\r\n>(\r\n handler: TreeDataController<NodeProps, NodeType>,\r\n oneNodeId: TId,\r\n anotherNodeId: TId,\r\n avoidFiltered?: boolean,\r\n) => void = (handler, oneNodeId, anotherNodeId, avoidFiltered) => {\r\n const commonAncestorData = getCommonAncestor(\r\n handler,\r\n oneNodeId,\r\n anotherNodeId,\r\n );\r\n if (commonAncestorData) {\r\n const { anotherNodeAncestorChild, commonAncestor, oneNodeAncestorChild } =\r\n commonAncestorData;\r\n const ancestorProps = handler.propsStore.getFieldProps(commonAncestor);\r\n const oneNodePosition = ancestorProps.children.findIndex(\r\n (current) => current === oneNodeAncestorChild,\r\n );\r\n const anotherNodePosition = ancestorProps.children.findIndex(\r\n (current) => current === anotherNodeAncestorChild,\r\n );\r\n\r\n let currentId: TId | null =\r\n oneNodePosition >= anotherNodePosition ? anotherNodeId : oneNodeId;\r\n const lastNodeId =\r\n oneNodePosition < anotherNodePosition ? anotherNodeId : oneNodeId;\r\n handler.toggleNodeSelectedState(currentId, true);\r\n do {\r\n currentId = getNextChild(handler, currentId, false, avoidFiltered);\r\n if (currentId !== null) handler.toggleNodeSelectedState(currentId, true);\r\n } while (currentId !== lastNodeId && currentId !== null);\r\n }\r\n};\r\n"],"names":["nodeProps"],"mappings":"AAGO,MAAM,mBAOK,GAAA,CAAC,OAAS,EAAA,EAAA,EAAI,aAAkB,KAAA;AAChD,EAAA,MAAM,SAAY,GAAA,OAAA,CAAQ,UAAW,CAAA,aAAA,CAAc,EAAE,CAAA,CAAA;AACrD,EACG,IAAA,EAAA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,CAAA,CAAA;AACjE,MAAA,IAAI,SAAc,KAAA,IAAA;AAAM,QAAQ,OAAA,CAAA,uBAAA,CAAwB,WAAW,IAAI,CAAA,CAAA;AAAA,KACzE,QAAS,SAAc,KAAA,UAAA,IAAc,SAAc,KAAA,IAAA,EAAA;AAAA,GACrD;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apia/tree",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
4
4
  "sideEffects": false,
5
5
  "author": "Alexis Leite <alexisleite@live.com>",
6
6
  "main": "dist/index.js",
@@ -13,10 +13,10 @@
13
13
  "libWatch": "rollup --watch --config ../../config/rollup.common.mjs --environment MODE:development,ENTRY:index.ts,WATCH:true"
14
14
  },
15
15
  "dependencies": {
16
- "@apia/components": "^2.0.9",
17
- "@apia/icons": "^2.0.8",
18
- "@apia/theme": "^2.0.8",
19
- "@apia/util": "^2.0.8",
16
+ "@apia/components": "^2.0.11",
17
+ "@apia/icons": "^2.0.11",
18
+ "@apia/theme": "^2.0.11",
19
+ "@apia/util": "^2.0.11",
20
20
  "ahooks": "^3.7.10"
21
21
  },
22
22
  "devDependencies": {
@@ -34,5 +34,5 @@
34
34
  "access": "public",
35
35
  "registry": "https://registry.npmjs.org/"
36
36
  },
37
- "gitHead": "0fec582924d14ada0f317defb5e024b1a8f96c4d"
37
+ "gitHead": "2baba9f15d947ff574605579b8593604886f690f"
38
38
  }