@apia/tree 2.0.8 → 2.0.9

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/index.d.ts +417 -7
  2. package/dist/index.js +1546 -6
  3. package/dist/index.js.map +1 -1
  4. package/package.json +3 -3
  5. package/dist/OOTree/OOTreeChildren.d.ts +0 -14
  6. package/dist/OOTree/OOTreeChildren.d.ts.map +0 -1
  7. package/dist/OOTree/OOTreeChildren.js +0 -17
  8. package/dist/OOTree/OOTreeChildren.js.map +0 -1
  9. package/dist/OOTree/OOTreeNode.d.ts +0 -30
  10. package/dist/OOTree/OOTreeNode.d.ts.map +0 -1
  11. package/dist/OOTree/OOTreeNode.js +0 -133
  12. package/dist/OOTree/OOTreeNode.js.map +0 -1
  13. package/dist/OOTree/index.d.ts +0 -36
  14. package/dist/OOTree/index.d.ts.map +0 -1
  15. package/dist/OOTree/index.js +0 -126
  16. package/dist/OOTree/index.js.map +0 -1
  17. package/dist/OOTree/types.d.ts +0 -11
  18. package/dist/OOTree/types.d.ts.map +0 -1
  19. package/dist/SearchLabel.js +0 -30
  20. package/dist/SearchLabel.js.map +0 -1
  21. package/dist/Tree.d.ts +0 -7
  22. package/dist/Tree.d.ts.map +0 -1
  23. package/dist/Tree.js +0 -131
  24. package/dist/Tree.js.map +0 -1
  25. package/dist/TreeContext.d.ts +0 -13
  26. package/dist/TreeContext.d.ts.map +0 -1
  27. package/dist/TreeContext.js +0 -22
  28. package/dist/TreeContext.js.map +0 -1
  29. package/dist/TreeDataController.d.ts +0 -116
  30. package/dist/TreeDataController.d.ts.map +0 -1
  31. package/dist/TreeDataController.js +0 -611
  32. package/dist/TreeDataController.js.map +0 -1
  33. package/dist/TreeItem.js +0 -51
  34. package/dist/TreeItem.js.map +0 -1
  35. package/dist/TreeItemChildren.js +0 -20
  36. package/dist/TreeItemChildren.js.map +0 -1
  37. package/dist/TreeItemLabel.js +0 -72
  38. package/dist/TreeItemLabel.js.map +0 -1
  39. package/dist/getDomProps.js +0 -37
  40. package/dist/getDomProps.js.map +0 -1
  41. package/dist/renderers/DefaultIconRenderer.js +0 -17
  42. package/dist/renderers/DefaultIconRenderer.js.map +0 -1
  43. package/dist/renderers/DefaultLabelRenderer.js +0 -9
  44. package/dist/renderers/DefaultLabelRenderer.js.map +0 -1
  45. package/dist/renderers/Spacer.js +0 -9
  46. package/dist/renderers/Spacer.js.map +0 -1
  47. package/dist/types.d.ts +0 -211
  48. package/dist/types.d.ts.map +0 -1
  49. package/dist/useTreeData.d.ts +0 -25
  50. package/dist/useTreeData.d.ts.map +0 -1
  51. package/dist/useTreeData.js +0 -129
  52. package/dist/useTreeData.js.map +0 -1
  53. package/dist/util.js +0 -210
  54. package/dist/util.js.map +0 -1
@@ -1,129 +0,0 @@
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
- } else {
114
- handler.setFocusedNode(key);
115
- handler.setSelectedNodesByClickEvent(ev);
116
- }
117
- if (key)
118
- focusOnNode(key);
119
- }
120
- },
121
- [focusOnNode, handler, treeProps]
122
- ),
123
- ref: keyHandlerRef
124
- }
125
- };
126
- }
127
-
128
- export { useTreeData as default };
129
- //# sourceMappingURL=useTreeData.js.map
@@ -1 +0,0 @@
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 };\r\n}\r\n"],"names":[],"mappings":";;;;;;;;AAiBA,SAAwB,WAGtB,CAAA,EAAE,IAAM,EAAA,SAAA,EAAgD,EAAA;AACxD,EAAM,MAAA,KAAA,GAAQ,UAAU,SAAS,CAAA,CAAA;AACjC,EAAA,M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AA,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,GAEF,CAAA,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 DELETED
@@ -1,210 +0,0 @@
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 (!currentProps.isFiltered) {
9
- const lastChildrenLastChildren = getLastVisibleChild(
10
- handler,
11
- currentId);
12
- return lastChildrenLastChildren !== null ? lastChildrenLastChildren : currentId;
13
- }
14
- }
15
- return null;
16
- };
17
- const getPreviousChild = (handler, id, avoidFiltered) => {
18
- const nodeProps = handler.propsStore.getFieldProps(id);
19
- const fatherProps = handler.propsStore.getFieldProps(nodeProps.parentId);
20
- let childPosition = fatherProps.children?.findIndex((current) => current === nodeProps.id) ?? -1;
21
- while (childPosition > 0) {
22
- const prevSibling = handler.propsStore.getFieldProps(
23
- fatherProps.children[childPosition - 1]
24
- );
25
- const prevSiblingLastChild = getLastVisibleChild(
26
- handler,
27
- prevSibling.id);
28
- if (prevSiblingLastChild !== null)
29
- return prevSiblingLastChild;
30
- if (!prevSibling.isFiltered)
31
- return prevSibling.id;
32
- childPosition--;
33
- }
34
- if (nodeProps.parentId === "root")
35
- return null;
36
- return nodeProps.parentId;
37
- };
38
- const getFirstNonFilteredChild = (handler, id) => {
39
- const nodeProps = handler.propsStore.getFieldProps(id);
40
- for (const child of nodeProps.children) {
41
- if (!handler.propsStore.getFieldProps(child).isFiltered)
42
- return child;
43
- }
44
- return null;
45
- };
46
- const getNextChild = (handler, id, avoidChildren, avoidFiltered) => {
47
- const nodeProps = handler.propsStore.getFieldProps(id);
48
- const fatherProps = handler.propsStore.getFieldProps(nodeProps.parentId);
49
- let childPosition = fatherProps.children?.findIndex((current) => current === nodeProps.id) ?? Infinity;
50
- if (!avoidChildren && nodeProps.isExpanded) {
51
- const firstNonFilteredChild = getFirstNonFilteredChild(
52
- handler,
53
- nodeProps.id
54
- );
55
- if (firstNonFilteredChild !== null)
56
- return firstNonFilteredChild;
57
- }
58
- while (childPosition < fatherProps.children.length - 1) {
59
- const nextSibling = fatherProps.children[childPosition + 1];
60
- if (!handler.propsStore.getFieldProps(nextSibling).isFiltered)
61
- return nextSibling;
62
- childPosition++;
63
- }
64
- if (nodeProps.parentId === "root")
65
- return null;
66
- return getNextChild(handler, fatherProps.id, true);
67
- };
68
- const getNextNodeWithKey = (handler, id, firstKey, avoidFiltered) => {
69
- let nextChildWithKey = id;
70
- do {
71
- nextChildWithKey = getNextChild(
72
- handler,
73
- nextChildWithKey,
74
- false);
75
- if (nextChildWithKey !== null) {
76
- const nodeProps2 = handler.propsStore.getFieldProps(nextChildWithKey);
77
- if ((!nodeProps2.isFiltered || !avoidFiltered) && nodeProps2.label.toUpperCase().startsWith(firstKey.toUpperCase()))
78
- return nextChildWithKey;
79
- }
80
- } while (nextChildWithKey !== null);
81
- const nodeProps = handler.propsStore.getFieldProps(id);
82
- const positionInParent = handler.propsStore.getFieldProps(nodeProps.parentId).children.findIndex((current) => current === id);
83
- if (nodeProps.parentId !== "root" || positionInParent > 0) {
84
- const [firstChildOfTree] = handler.propsStore.getFieldProps("root").children;
85
- const firstChildProps = handler.propsStore.getFieldProps(firstChildOfTree);
86
- if (firstChildOfTree && (!firstChildProps.isFiltered) && firstChildProps.label.toUpperCase().startsWith(firstKey.toUpperCase()))
87
- return firstChildOfTree;
88
- nextChildWithKey = firstChildOfTree;
89
- do {
90
- nextChildWithKey = getNextChild(
91
- handler,
92
- nextChildWithKey,
93
- false);
94
- if (nextChildWithKey) {
95
- const currentNodeProps = handler.propsStore.getFieldProps(nextChildWithKey);
96
- if ((!currentNodeProps.isFiltered) && currentNodeProps.label.toUpperCase().startsWith(firstKey.toUpperCase()))
97
- return nextChildWithKey;
98
- }
99
- } while (nextChildWithKey !== id && nextChildWithKey !== null);
100
- }
101
- return null;
102
- };
103
- const getNodePath = (handler, nodeId) => {
104
- const path = [nodeId];
105
- let currentStep = nodeId;
106
- do {
107
- currentStep = handler.propsStore.getFieldProps(currentStep).parentId;
108
- path.unshift(currentStep);
109
- } while (currentStep !== "root");
110
- return path;
111
- };
112
- const getCommonAncestor = (handler, oneNodeId, anotherNodeId) => {
113
- const oneNodePath = getNodePath(handler, oneNodeId);
114
- const anotherNodePath = getNodePath(handler, anotherNodeId);
115
- for (let i = oneNodePath.length - 1; i >= 0; i--) {
116
- const anotherNodeIndex = anotherNodePath.indexOf(oneNodePath[i]);
117
- if (anotherNodeIndex !== -1)
118
- return {
119
- commonAncestor: oneNodePath[i],
120
- oneNodeAncestorChild: oneNodePath[i + 1],
121
- anotherNodeAncestorChild: anotherNodePath[anotherNodeIndex + 1]
122
- };
123
- }
124
- console.warn(
125
- "This point should have never been reached since the root node is common to all nodes",
126
- { oneNodeId, anotherNodeId, oneNodePath, anotherNodePath }
127
- );
128
- return null;
129
- };
130
- const unfilterNodes = (handler) => {
131
- handler.state.filteredNodes.forEach((current) => {
132
- handler.propsStore.updateField(
133
- current,
134
- { isFiltered: false },
135
- { noEmit: true }
136
- );
137
- });
138
- const firstChild = handler.propsStore.getFieldProps("root").children[0];
139
- if (firstChild)
140
- handler.setFocusedNode(firstChild);
141
- handler.setState({ filteredNodes: [] });
142
- };
143
- const matchNodesAgainstString = (handler, searchString, nodeId = "root") => {
144
- let hasMatched = false;
145
- let matchNode = null;
146
- const nodeProps = handler.propsStore.getFieldProps(nodeId);
147
- if (nodeId !== "root" && nodeProps.label.match(new RegExp(searchString, "i"))) {
148
- handler.propsStore.updateField(nodeId, { isFiltered: false });
149
- hasMatched = true;
150
- matchNode = nodeProps.id;
151
- handler.setState({
152
- filteredNodes: handler.state.filteredNodes.filter(
153
- (current) => current !== nodeId
154
- )
155
- });
156
- }
157
- let hasChildrenMatched = false;
158
- nodeProps.children.forEach((current) => {
159
- hasChildrenMatched = matchNodesAgainstString(handler, searchString, current) || hasMatched;
160
- hasMatched = hasChildrenMatched || hasMatched;
161
- if (hasMatched && !matchNode)
162
- matchNode = current;
163
- });
164
- if (hasChildrenMatched) {
165
- handler.propsStore.updateField(nodeId, { isExpanded: true });
166
- if (hasMatched && !matchNode)
167
- matchNode = nodeId;
168
- }
169
- if (!hasMatched) {
170
- handler.propsStore.updateField(
171
- nodeId,
172
- { isFiltered: true },
173
- { noEmit: true }
174
- );
175
- handler.setState({
176
- filteredNodes: [...handler.state.filteredNodes, nodeId]
177
- });
178
- }
179
- if (matchNode !== null)
180
- handler.setFocusedNode(matchNode);
181
- return hasMatched;
182
- };
183
- const selectAllNodesBetweenTwoNodes = (handler, oneNodeId, anotherNodeId, avoidFiltered) => {
184
- const commonAncestorData = getCommonAncestor(
185
- handler,
186
- oneNodeId,
187
- anotherNodeId
188
- );
189
- if (commonAncestorData) {
190
- const { anotherNodeAncestorChild, commonAncestor, oneNodeAncestorChild } = commonAncestorData;
191
- const ancestorProps = handler.propsStore.getFieldProps(commonAncestor);
192
- const oneNodePosition = ancestorProps.children.findIndex(
193
- (current) => current === oneNodeAncestorChild
194
- );
195
- const anotherNodePosition = ancestorProps.children.findIndex(
196
- (current) => current === anotherNodeAncestorChild
197
- );
198
- let currentId = oneNodePosition >= anotherNodePosition ? anotherNodeId : oneNodeId;
199
- const lastNodeId = oneNodePosition < anotherNodePosition ? anotherNodeId : oneNodeId;
200
- handler.toggleNodeSelectedState(currentId, true);
201
- do {
202
- currentId = getNextChild(handler, currentId, false);
203
- if (currentId !== null)
204
- handler.toggleNodeSelectedState(currentId, true);
205
- } while (currentId !== lastNodeId && currentId !== null);
206
- }
207
- };
208
-
209
- export { getCommonAncestor, getFirstNonFilteredChild, getLastVisibleChild, getNextChild, getNextNodeWithKey, getNodePath, getPreviousChild, matchNodesAgainstString, selectAllNodesBetweenTwoNodes, unfilterNodes };
210
- //# sourceMappingURL=util.js.map
package/dist/util.js.map DELETED
@@ -1 +0,0 @@
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,KAAO,WAAW,SAAU,CAAA,UAAA,IAAc,CAAC,SAAU,CAAA,UAAA,CAAA,IACtD,SAAU,CAAA,QAAA,CAAS,MAAW,KAAA,CAAA;AAE9B,IAAO,OAAA,IAAA,CAAA;AAET,EAAA,KAAA,IAAS,IAAI,SAAU,CAAA,QAAA,CAAS,SAAS,CAAG,EAAA,CAAA,IAAK,GAAG,CAAK,EAAA,EAAA;AACvD,IAAM,MAAA,SAAA,GAAY,SAAU,CAAA,QAAA,CAAS,CAAC,CAAA,CAAA;AACtC,IAAA,MAAM,YAAe,GAAA,OAAA,CAAQ,UAAW,CAAA,aAAA,CAAc,SAAS,CAAA,CAAA;AAC/D,IAAA,IAAsB,CAAC,YAAA,CAAa,UAAY,EAAA;AAC9C,MAAA,MAAM,wBAA2B,GAAA,mBAAA;AAAA,QAC/B,OAAA;AAAA,QACA,SAEF,CAAA,CAAA;AACA,MAAO,OAAA,wBAAA,KAA6B,OAChC,wBACA,GAAA,SAAA,CAAA;AAAA,KACN;AAAA,GACF;AACA,E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