@elliemae/ds-tree-model 3.36.0-rc.0 → 3.36.1-next.7
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/cjs/DSTree.js +1 -2
- package/dist/cjs/DSTree.js.map +1 -1
- package/dist/cjs/Node.js +5 -10
- package/dist/cjs/Node.js.map +1 -1
- package/dist/cjs/adapters/arraish-tree/fromDSTreeToTreeishArray.js +1 -2
- package/dist/cjs/adapters/arraish-tree/fromDSTreeToTreeishArray.js.map +1 -1
- package/dist/cjs/adapters/arraish-tree/fromTreeishArrayToDSTree.js +1 -2
- package/dist/cjs/adapters/arraish-tree/fromTreeishArrayToDSTree.js.map +1 -1
- package/dist/cjs/adapters/treeview/useTreeviewAsDSTree.js.map +1 -1
- package/dist/cjs/typescript-testing/typescript-use-arraish-as-ds-tree-valid.js.map +1 -1
- package/dist/esm/DSTree.js +1 -2
- package/dist/esm/DSTree.js.map +1 -1
- package/dist/esm/Node.js +5 -10
- package/dist/esm/Node.js.map +1 -1
- package/dist/esm/adapters/arraish-tree/fromDSTreeToTreeishArray.js +1 -2
- package/dist/esm/adapters/arraish-tree/fromDSTreeToTreeishArray.js.map +1 -1
- package/dist/esm/adapters/arraish-tree/fromTreeishArrayToDSTree.js +1 -2
- package/dist/esm/adapters/arraish-tree/fromTreeishArrayToDSTree.js.map +1 -1
- package/dist/esm/adapters/treeview/useTreeviewAsDSTree.js.map +1 -1
- package/dist/esm/typescript-testing/typescript-use-arraish-as-ds-tree-valid.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/DSTree.js
CHANGED
|
@@ -64,8 +64,7 @@ class DSTree {
|
|
|
64
64
|
};
|
|
65
65
|
this.removeNode = (id, options = {}) => {
|
|
66
66
|
const node = this.getNode(id);
|
|
67
|
-
if (!node)
|
|
68
|
-
throw new Error(`Node with id ${id} not found`);
|
|
67
|
+
if (!node) throw new Error(`Node with id ${id} not found`);
|
|
69
68
|
node.removeNode();
|
|
70
69
|
this._hash += 1;
|
|
71
70
|
options.callback?.(node, this);
|
package/dist/cjs/DSTree.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSTree.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import type { AddOptions, Item, MoveOptions, MutateOptions, RemoveOptions } from './types.js';\nimport { Node } from './Node.js';\n\nexport class DSTree<T extends Item> {\n private root: Node<T>;\n\n private _hash: number;\n\n private nodes: Record<string | number, Node<T>>;\n\n getUniqueId: (item: T) => string | number;\n\n constructor(item: T, options: { getUniqueId: (item: T) => string | number }) {\n this.getUniqueId = options.getUniqueId;\n this.root = new Node(item, { childIndex: 0, depth: 0, tree: this });\n this.nodes = {};\n this._hash = 0;\n\n // autocalculate a dictionary where dsId are keys and nodes are values\n // and add the tree link to each node\n this.root.walk((node) => {\n this.nodes[node.dsId] = node;\n return true;\n });\n }\n\n addNodeToNodesDictionary(node: Node<T>): void {\n // check that we have no repeated ids\n if (this.nodes[node.dsId]) {\n throw new Error(`DSTree: repeated dsId ${node.dsId}`);\n }\n\n this.nodes[node.dsId] = node;\n }\n\n removeNodeFromNodesDictionary(node: Node<T>): void {\n delete this.nodes[node.dsId];\n }\n\n get hash(): number {\n return this._hash;\n }\n\n getRoot = (): Node<T> => this.root;\n\n getNode = (id: string | number): Node<T> => this.nodes[id];\n\n getNodes = (): Record<string, Node<T>> => this.nodes;\n\n walk = (callback: (node: Node<T>) => boolean): void => {\n this.root.walk(callback);\n };\n\n walkParents = (callback: (node: Node<T>) => boolean): void => {\n this.root.walkParents(callback);\n };\n\n findNode = (callback: (node: Node<T>) => boolean): Node<T> | null => this.root.findNode(callback);\n\n findAllNodes = (callback: (node: Node<T>) => boolean): Node<T>[] => this.root.findAllNodes(callback);\n\n flatten = (): Node<T>[] => this.root.flatten();\n\n addNode = (item: T, options: AddOptions<T> = {}): Node<T> => {\n const { position, parent, callback } = options;\n const parentDefault = parent || this.root;\n const positionDefault = position ?? parentDefault.children.length;\n\n // create node and add it to the parent\n const node = new Node(item, {\n childIndex: positionDefault,\n depth: parentDefault.depth + 1,\n parent: parentDefault,\n tree: this,\n });\n this.getNode(parentDefault.dsId).addNode(node);\n\n // change hash\n this._hash += 1;\n\n // invoke the callback if present\n callback?.(node, this);\n\n return node;\n };\n\n removeNode = (id: string | number, options: RemoveOptions<T> = {}): Node<T> => {\n const node = this.getNode(id);\n if (!node) throw new Error(`Node with id ${id} not found`);\n\n node.removeNode();\n\n // change hash\n this._hash += 1;\n\n // invoke the callback if present\n options.callback?.(node, this);\n\n return node;\n };\n\n moveNode = (id: string | number, options: MoveOptions<T> = {}): Node<T> => {\n const removedNode = this.removeNode(id);\n const node = this.addNode(removedNode.getJson(), options);\n\n this._hash += 1;\n\n return node;\n };\n\n replaceNode = (id: string | number, item: T, options: MutateOptions<T> = {}): Node<T> => {\n const removedNode = this.removeNode(id);\n const node = this.addNode(item, { parent: removedNode.parent, position: removedNode.childIndex });\n\n this._hash += 1;\n\n // invoke the callback if present\n options.callback?.(node, this);\n\n return node;\n };\n\n getPath = (id: string | number): Node<T>[] => this.getRoot().getPath(id);\n\n getPathIds = (id: string | number) => this.getRoot().getPathIds(id);\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,kBAAqB;AAEd,MAAM,OAAuB;AAAA,EASlC,YAAY,MAAS,SAAwD;AA+B7E,mBAAU,MAAe,KAAK;AAE9B,mBAAU,CAAC,OAAiC,KAAK,MAAM,EAAE;AAEzD,oBAAW,MAA+B,KAAK;AAE/C,gBAAO,CAAC,aAA+C;AACrD,WAAK,KAAK,KAAK,QAAQ;AAAA,IACzB;AAEA,uBAAc,CAAC,aAA+C;AAC5D,WAAK,KAAK,YAAY,QAAQ;AAAA,IAChC;AAEA,oBAAW,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,IAAI,iBAAK,MAAM,EAAE,YAAY,GAAG,OAAO,GAAG,MAAM,KAAK,CAAC;AAClE,SAAK,QAAQ,CAAC;AACd,SAAK,QAAQ;AAIb,SAAK,KAAK,KAAK,CAAC,SAAS;AACvB,WAAK,MAAM,KAAK,IAAI,IAAI;AACxB,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAAA,EAEA,yBAAyB,MAAqB;AAE5C,QAAI,KAAK,MAAM,KAAK,IAAI,GAAG;AACzB,YAAM,IAAI,MAAM,yBAAyB,KAAK,IAAI,EAAE;AAAA,IACtD;AAEA,SAAK,MAAM,KAAK,IAAI,IAAI;AAAA,EAC1B;AAAA,EAEA,8BAA8B,MAAqB;AACjD,WAAO,KAAK,MAAM,KAAK,IAAI;AAAA,EAC7B;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,KAAK;AAAA,EACd;AAoFF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/Node.js
CHANGED
|
@@ -65,10 +65,8 @@ class Node {
|
|
|
65
65
|
this.findNode = (callback) => {
|
|
66
66
|
let found = null;
|
|
67
67
|
this.walk((node) => {
|
|
68
|
-
if (found)
|
|
69
|
-
|
|
70
|
-
if (callback(node))
|
|
71
|
-
found = node;
|
|
68
|
+
if (found) return false;
|
|
69
|
+
if (callback(node)) found = node;
|
|
72
70
|
return !found;
|
|
73
71
|
});
|
|
74
72
|
return found;
|
|
@@ -76,8 +74,7 @@ class Node {
|
|
|
76
74
|
this.findAllNodes = (callback) => {
|
|
77
75
|
const found = [];
|
|
78
76
|
this.walk((node) => {
|
|
79
|
-
if (callback(node))
|
|
80
|
-
found.push(node);
|
|
77
|
+
if (callback(node)) found.push(node);
|
|
81
78
|
return true;
|
|
82
79
|
});
|
|
83
80
|
return found;
|
|
@@ -93,8 +90,7 @@ class Node {
|
|
|
93
90
|
this.getPath = (id) => {
|
|
94
91
|
const path = [];
|
|
95
92
|
const node = this.tree.getNode(id);
|
|
96
|
-
if (!node)
|
|
97
|
-
return path;
|
|
93
|
+
if (!node) return path;
|
|
98
94
|
node.walkParents((parent) => {
|
|
99
95
|
path.push(parent);
|
|
100
96
|
return parent.dsId !== this.dsId;
|
|
@@ -123,8 +119,7 @@ class Node {
|
|
|
123
119
|
this._hash += 1;
|
|
124
120
|
};
|
|
125
121
|
this.removeNode = () => {
|
|
126
|
-
if (!this.parent)
|
|
127
|
-
throw new Error(`Cannot remove root node with id ${this.dsId}`);
|
|
122
|
+
if (!this.parent) throw new Error(`Cannot remove root node with id ${this.dsId}`);
|
|
128
123
|
this.parent.children.splice(this.childIndex, 1);
|
|
129
124
|
this.parent.fixChildIndexes();
|
|
130
125
|
this.walk((child) => {
|
package/dist/cjs/Node.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Node.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable no-use-before-define */\n/* eslint-disable max-params */\nimport { cloneDeep, omit } from 'lodash';\nimport type { DSTree } from './DSTree.js';\nimport type { Item, NodeConstructorOptions } from './types.js';\n\nexport class Node<T extends Item> {\n dsId: string | number;\n\n plainItem: T;\n\n childIndex: number;\n\n depth: number;\n\n parent: Node<T> | null;\n\n children: Node<T>[];\n\n private tree!: DSTree<T>;\n\n private _hash: number;\n\n constructor(item: T, { childIndex, depth, parent, tree }: NodeConstructorOptions<T>) {\n this.dsId = tree.getUniqueId(item);\n this.childIndex = childIndex;\n this.depth = depth;\n this.parent = parent ?? null;\n this.tree = tree;\n this._hash = 0;\n\n this.children =\n item.subitems?.map(\n (subitem, index) => new Node(subitem as T, { childIndex: index, depth: depth + 1, parent: this, tree }),\n ) ?? [];\n\n // Save the item without the subitems\n this.plainItem = this.getCleanItem(item);\n }\n\n // ===========================================================================\n // INTERNAL METHODS\n // ===========================================================================\n\n fixChildIndexes = (): void => {\n for (let i = 0; i < this.children.length; i++) {\n this.children[i].childIndex = i;\n }\n this._hash += 1;\n };\n\n getCleanItem = (item: T): T => {\n const plainItem = omit(item, ['subitems']);\n return cloneDeep(plainItem as T);\n };\n\n // ===========================================================================\n // READ METHODS\n // ===========================================================================\n\n get hash(): number {\n return this._hash;\n }\n\n walk = (callback: (node: Node<T>) => boolean): void => {\n const shouldContinueWalking = callback(this);\n if (shouldContinueWalking) {\n for (const child of this.children) {\n child.walk(callback);\n }\n }\n };\n\n walkParents = (callback: (node: Node<T>) => boolean): void => {\n const shouldContinueWalking = callback(this);\n if (shouldContinueWalking && this.parent) {\n this.parent.walkParents(callback);\n }\n };\n\n findNode = (callback: (node: Node<T>) => boolean): Node<T> | null => {\n // find first node using walk\n let found: Node<T> | null = null;\n this.walk((node) => {\n // If we already found it, don't look anymore\n if (found) return false;\n\n // Otherwise keep looking\n if (callback(node)) found = node;\n return !found;\n });\n\n return found;\n };\n\n findAllNodes = (callback: (node: Node<T>) => boolean): Node<T>[] => {\n const found: Node<T>[] = [];\n this.walk((node) => {\n if (callback(node)) found.push(node);\n return true;\n });\n return found;\n };\n\n flatten = (): Node<T>[] => {\n const flattened: Node<T>[] = [];\n this.walk((node) => {\n flattened.push(node);\n return true;\n });\n return flattened;\n };\n\n getPath = (id: string | number): Node<T>[] => {\n const path: Node<T>[] = [];\n const node = this.tree.getNode(id);\n if (!node) return path;\n node.walkParents((parent) => {\n path.push(parent);\n return parent.dsId !== this.dsId;\n });\n return path.reverse();\n };\n\n getPathIds = (id: string | number) => this.getPath(id).map((node) => node.dsId);\n\n getJson = (): T => ({\n ...this.plainItem,\n subitems: this.children.map((child) => child.getJson()),\n });\n\n // ===========================================================================\n // WRITE METHODS\n // ===========================================================================\n\n addNode = (node: Node<T>) => {\n // check that the position is valid for that parent\n const position = node.childIndex;\n if (position < 0 || position > this.children.length) {\n throw new Error(`Invalid position ${position} for parent ${this.dsId} with item ${node.dsId}`);\n }\n\n // add the new node\n this.children.splice(position, 0, node);\n\n // fix the childIndex of the nodes after the new one\n this.fixChildIndexes();\n\n // add subtree of the new node to the node dictionary\n node.walk((child) => {\n this.tree.addNodeToNodesDictionary(child);\n return true;\n });\n\n this._hash += 1;\n };\n\n removeNode = () => {\n // if no parent throw error\n if (!this.parent) throw new Error(`Cannot remove root node with id ${this.dsId}`);\n\n // remove from parent\n this.parent.children.splice(this.childIndex, 1);\n\n // fix the childIndex of the nodes of the parent\n this.parent.fixChildIndexes();\n\n // remove subtree from the node dictionary\n this.walk((child) => {\n this.tree.removeNodeFromNodesDictionary(child);\n return true;\n });\n\n this._hash += 1;\n };\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,oBAAgC;AAIzB,MAAM,KAAqB;AAAA,EAiBhC,YAAY,MAAS,EAAE,YAAY,OAAO,QAAQ,KAAK,GAA8B;AAqBrF;AAAA;AAAA;AAAA,2BAAkB,MAAY;AAC5B,eAAS,IAAI,GAAG,IAAI,KAAK,SAAS,QAAQ,KAAK;AAC7C,aAAK,SAAS,CAAC,EAAE,aAAa;AAAA,MAChC;AACA,WAAK,SAAS;AAAA,IAChB;AAEA,wBAAe,CAAC,SAAe;AAC7B,YAAM,gBAAY,oBAAK,MAAM,CAAC,UAAU,CAAC;AACzC,iBAAO,yBAAU,SAAc;AAAA,IACjC;AAUA,gBAAO,CAAC,aAA+C;AACrD,YAAM,wBAAwB,SAAS,IAAI;AAC3C,UAAI,uBAAuB;AACzB,mBAAW,SAAS,KAAK,UAAU;AACjC,gBAAM,KAAK,QAAQ;AAAA,QACrB;AAAA,MACF;AAAA,IACF;AAEA,uBAAc,CAAC,aAA+C;AAC5D,YAAM,wBAAwB,SAAS,IAAI;AAC3C,UAAI,yBAAyB,KAAK,QAAQ;AACxC,aAAK,OAAO,YAAY,QAAQ;AAAA,MAClC;AAAA,IACF;AAEA,oBAAW,CAAC,aAAyD;AAEnE,UAAI,QAAwB;AAC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aAAK,KAAK,8BAA8B,KAAK;AAC7C,eAAO;AAAA,MACT,CAAC;AAED,WAAK,SAAS;AAAA,IAChB;AAtJE,SAAK,OAAO,KAAK,YAAY,IAAI;AACjC,SAAK,aAAa;AAClB,SAAK,QAAQ;AACb,SAAK,SAAS,UAAU;AACxB,SAAK,OAAO;AACZ,SAAK,QAAQ;AAEb,SAAK,WACH,KAAK,UAAU;AAAA,MACb,CAAC,SAAS,UAAU,IAAI,KAAK,SAAc,EAAE,YAAY,OAAO,OAAO,QAAQ,GAAG,QAAQ,MAAM,KAAK,CAAC;AAAA,IACxG,KAAK,CAAC;AAGR,SAAK,YAAY,KAAK,aAAa,IAAI;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAsBA,IAAI,OAAe;AACjB,WAAO,KAAK;AAAA,EACd;AAiHF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -38,8 +38,7 @@ const fromDSTreeToTreeishArray = (args) => {
|
|
|
38
38
|
const root = tree.getRoot();
|
|
39
39
|
const restoredTreeish = [];
|
|
40
40
|
const callback = (node) => {
|
|
41
|
-
if (node.depth === 0)
|
|
42
|
-
return true;
|
|
41
|
+
if (node.depth === 0) return true;
|
|
43
42
|
const nodeJson = node.getJson();
|
|
44
43
|
const originalNode = structuredClone(nodeJson.originalNodeData);
|
|
45
44
|
const nodeChildrenKey = getChildrenKey(originalNode);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/adapters/arraish-tree/fromDSTreeToTreeishArray.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable max-statements */\nimport type { DSTree } from '../../DSTree.js';\nimport type { Node } from '../../Node.js';\nimport type { OverloadedItem } from '../../types.js';\n\n/*\n * a function that given a DSTree datastructure and some options returns a treeish array that compltely preserves the original data.\n * this is meant to revert the operation done by fromTreeishArrayToDSTree in a seamless way,\n * as such makes, some assumptions:\n * - the original data lives under the \"originalNodeData\" property of the node\n * - the root node is a pseudoRoot node that will not be part of the final treeish array\n * NOTE: This create a deep clone of the node original data, so it's not suitable for large trees and will not preserve any reference in the nodes original data\n * NOTE2: Nodes that have no children will be restored with an empty \"children\" array, this may be a data-loss, but this can't be easily avoided,\n * if this is important for your use-case you should implement your own conversion function with your requirements\n * @param {DSTree} tree - a DSTree datastructure (generated with a structure exactly the same as the one resulting from invoking fromTreeishArrayToDSTree)\n * @param {Object} opts - an object that governs how the treeish array will be converted to a DSTree datastructure\n * @param {Function} opts.getChildrenKey - a function that given a node returns the key used to access the node children\n * @param {Function} opts.getUniqueId - a function that given a node returns a unique string used to identify the node\n * @returns {Array} - a treeish array\n */\n\nexport const fromDSTreeToTreeishArray = <T extends object = object>(args: {\n tree: DSTree<OverloadedItem<T>>;\n opts: {\n getChildrenKey: (node: T) => keyof T;\n getUniqueId: (node: T) => string;\n };\n}): T[] => {\n const { tree, opts } = args;\n const { getChildrenKey, getUniqueId } = opts;\n const root = tree.getRoot();\n const restoredTreeish: T[] = [];\n const callback = (node: Node<OverloadedItem<T>>) => {\n // everytime we step in a node we want to:\n // - understand if the node has a parent\n // - if it does, we want to find the parent in the restoredTreeish array and add the node to the parent's children\n // the \"children\" are stored under the key returned by the getChildrenKey function\n // - if it doesn't, we make the assumption that this is a \"first-level\" node and we add it to the restoredTreeish array\n // - what ends up in the restoredTreeish array are only value from the \"originalNodeData\" property of the node + childrens under the key returned by the getChildrenKey function\n // we skip the root node\n if (node.depth === 0) return true;\n // we create the original node from the originalNodeData property of the node\n const nodeJson = node.getJson();\n const originalNode = structuredClone(nodeJson.originalNodeData);\n const nodeChildrenKey = getChildrenKey(originalNode);\n // we add a \"children\" array, creating it if doesn't exist\n if (!Object.hasOwnProperty.call(originalNode, nodeChildrenKey)) {\n Object.defineProperty(originalNode, nodeChildrenKey, {\n value: [] as T[],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n // if depth is 1, we are dealing with a first-level node, so we add it to the restoredTreeish array as is\n if (node.depth === 1) {\n restoredTreeish.push(originalNode);\n return true;\n }\n // if depth is > 1, we are dealing with a node that has a parent, so we need to find the parent in the restoredTreeish array\n // and add the node to the parent's children\n const parents = root.getPathIds(node.dsId);\n parents.shift(); // we added the pseudo-root, we skip it based on the assumption\n parents.pop(); // getPathIds also include the current searched for at the end of the array, we don't need that\n\n // we now find the parent in the restoredTreeish array\n // if this find fails this is an unrecoverable error, something is wrong in the opts callbacks or at app-level\n // the only other alternative is that the \"walk\" method from DSTree changed the order of the nodes, which would be a breaking change\n let parent = restoredTreeish.find((item: T) => `${getUniqueId(item)}` === parents[0]) as T;\n if (!parent)\n throw new Error(\n `Unable to find parent node with id ${parents[0]}, have you provided the correct getUniqueId function?`,\n );\n let parentChildrenKey = getChildrenKey(parent);\n // we now walk the parents array, skipping the first element (we already found the parent),\n // we must use the for loop to be sure that we are invoking code sequentially\n for (let i = 1; i < parents.length; i++) {\n // if this loop fails this is an unrecoverable error, something is wrong in the opts callbacks or at app-level\n // the only other alternative is that the \"walk\" method from DSTree changed the order of the nodes, which would be a breaking change\n const childrens = parent[parentChildrenKey] as T[];\n if (!childrens)\n throw new Error(\n `Unable to children node with id ${parents[i]}, have you provided the correct getChildrenKey function?`,\n );\n parent = childrens.find((item: T) => `${getUniqueId(item)}` === parents[i]) as T;\n parentChildrenKey = getChildrenKey(parent);\n }\n\n const parentChildrenArray = parent[parentChildrenKey] as T[];\n parentChildrenArray.push(originalNode);\n\n return true; // we will walk all the nodes no matter what\n };\n root.walk(callback);\n\n return restoredTreeish;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADqBhB,MAAM,2BAA2B,CAA4B,SAMzD;AACT,QAAM,EAAE,MAAM,KAAK,IAAI;AACvB,QAAM,EAAE,gBAAgB,YAAY,IAAI;AACxC,QAAM,OAAO,KAA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ACR,mCAAmC,QAAQ,CAAC,CAAC;AAAA,QAC/C;AACF,eAAS,UAAU,KAAK,CAAC,SAAY,GAAG,YAAY,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC1E,0BAAoB,eAAe,MAAM;AAAA,IAC3C;AAEA,UAAM,sBAAsB,OAAO,iBAAiB;AACpD,wBAAoB,KAAK,YAAY;AAErC,WAAO;AAAA,EACT;AACA,OAAK,KAAK,QAAQ;AAElB,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -63,8 +63,7 @@ const fromTreeishArrayToDSTree = (args) => {
|
|
|
63
63
|
const overloadedGetChildren = (node) => node.subitems;
|
|
64
64
|
const overloadedGetUniqueId = (node) => node.id;
|
|
65
65
|
const callback = (node) => {
|
|
66
|
-
if (node.id === rootId)
|
|
67
|
-
return;
|
|
66
|
+
if (node.id === rootId) return;
|
|
68
67
|
const originalNodeData = structuredClone(node);
|
|
69
68
|
Object.keys(node).forEach((key) => {
|
|
70
69
|
delete node[key];
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/adapters/arraish-tree/fromTreeishArrayToDSTree.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable max-statements */\nimport { DSTree } from '../../DSTree.js';\nimport type { OverloadedItem } from '../../types.js';\n\n// we don't really need a 100% sure unique id, since we prepend a string that is most likely unique already\n// we just need to reduce the risk of collisions\n// we avoid depending on a library for this:\nconst unsecureUuid = () =>\n 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c == 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n\n/*\n * @param {Object} args\n * @param {Function} args.callback - a function that will be called for each node in the treeish data-structure\n * @param {Object} args.node - the node that is being currently visited\n * @param {Object} args.opts - an object that holds the opinions of the caller on how to walk the treeish data-structure\n * @param {Function} args.opts.getChildren - a function that given a node returns an array of children\n * @returns {void}\n */\nconst walkTreeish = <T extends object>({\n callback,\n node,\n opts,\n}: {\n callback: (node: T) => void;\n node: T;\n opts?: {\n getChildren: (node: T) => T[];\n };\n}): void => {\n callback(node);\n const children = opts?.getChildren(node);\n if (Array.isArray(children) && children.length > 0) {\n for (let i = 0; i < children.length; i += 1) {\n walkTreeish<T>({ callback, node: children[i], opts });\n }\n }\n};\n\n/*\n * a function that given a treeish array and some options returns a DSTree datastructure that compltely preserves the treeish array\n * but still allows to use the full power of the DSTree datastructure\n * NOTE: This create a deep clone of the treeish array, so it's not suitable for large trees and will not preserve any reference to the original treeish array\n * @param {Array} treeish - an array of items that rapresents a tree, this will be used to create a DSTree datastructure\n * @param {Object} opts - an object that governs how the treeish array will be converted to a DSTree datastructure\n * @param {Function} opts.getChildrenKey - a function that given a node returns the key used to access the node children\n * @param {Function} opts.getUniqueId - a function that given a node returns a unique string used to identify the node\n * @returns {DSTree} - a DSTree datastructure\n */\nexport const fromTreeishArrayToDSTree = <T extends object = object>(args: {\n treeish: T[];\n opts: {\n getChildrenKey: (node: T) => keyof T;\n getUniqueId: (item: T) => string;\n };\n}): DSTree<OverloadedItem<T>> => {\n // we use crypto to generate a unique id for the root, this is important for reduce the risk of collisions with any user provided id\n const rootId = `_autogenerated-ds-pseudoRoot-${unsecureUuid()}`;\n const { opts, treeish } = args;\n const { getUniqueId, getChildrenKey } = opts;\n\n // a DSTree compatible datastructure has the following characteristics:\n // - it has a \"subitems\" property that contains an array of children\n // - it has a property that holds a unique string used to identify the node (accessed via the getUniqueId function)\n // - it is in an object format\n const pseudoRoot: OverloadedItem<T> = {\n id: rootId,\n subitems: structuredClone(treeish) as unknown as OverloadedItem<T>[],\n originalNodeData: {} as T,\n };\n // we now create an over-charged getChildren function\n // this is because we mutate the object every step during the walk\n //. this function is going to receive the OverloadedItem<T> each step\n const overloadedGetChildren = (node: OverloadedItem<T>) => node.subitems;\n const overloadedGetUniqueId = (node: OverloadedItem<T>) => node.id;\n // we now create a \"callback\" function that will be used when walking the pseudoRoot object.\n // this callback will mutate the pseudoRoot object, making sure that after the mutation it will be compatible with the DSTree datastructure\n // we can't really make an assumption that the subitems key isn't somehow already part of the data from the user,\n // so to avoid any collision we will create an extra-level of nesting, in this layer only 3 properties will be allowed:\n // - id: a unique string used to identify the node, this is already a requirement from the treeish datastructure provided by the user\n // - subitems: an array of children\n // - original: the original data provided by the user\n // we remove the original tree rapresentation from the node, we only want one source of truth for the tree\n // if we don't remove this, when operating the DSTree we would have to somehow also propagate the changes to the original tree\n // the way this is intended to be used is instead to convert back and forth between the DSTree and the treeish array\n // the conversion will restore the treeish structure with the updated tree after operating on the DSTree\n const callback = (node: OverloadedItem<T>) => {\n // we skip the root node\n if (node.id === rootId) return;\n // we safe-keep the original data provided by the user\n const originalNodeData = structuredClone(node) as unknown as T;\n // we now mutate the node, making it compatible with the DSTree datastructure\n // first we clean all the properties\n Object.keys(node).forEach((key) => {\n delete node[key];\n });\n // we now add the properties that are required by the DSTree datastructure\n const overloadedNode = node as unknown as OverloadedItem<T>;\n const childrenKey = getChildrenKey(originalNodeData);\n overloadedNode.id = getUniqueId(originalNodeData);\n overloadedNode.subitems = originalNodeData[childrenKey] as OverloadedItem<T>[];\n delete originalNodeData[childrenKey];\n overloadedNode.originalNodeData = originalNodeData;\n };\n // we now walk the pseudoRoot object, mutating it in the process\n walkTreeish<OverloadedItem<T>>({ callback, node: pseudoRoot, opts: { getChildren: overloadedGetChildren } });\n\n // we know that pseudoRoot is an item after we have walked and mutated it, so we can safely cast it\n return new DSTree<OverloadedItem<T>>(pseudoRoot, { getUniqueId: overloadedGetUniqueId });\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,oBAAuB;AAMvB,MAAM,eAAe,MACnB,uCAA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SAAS,gCAAgC,aAAa,CAAC;AAC7D,QAAM,EAAE,MAAM,QAAQ,IAAI;AAC1B,QAAM,EAAE,aAAa,eAAe,IAAI;AAMxC,QAAM,aAAgC;AAAA,IACpC,IAAI;AAAA,IACJ,UAAU,gBAAgB,OAAO;AAAA,IACjC,kBAAkB,CAAC;AAAA,EACrB;AAIA,QAAM,wBAAwB,CAAC,SAA4B,KAAK;AAChE,QAAM,wBAAwB,CAAC,SAA4B,KAAK;AAYhE,QAAM,WAAW,CAAC,SAA4B;AAE5C,QAAI,KAAK,OAAO,OAAQ;AAExB,UAAM,mBAAmB,gBAAgB,IAAI;AAG7C,WAAO,KAAK,IAAI,EAAE,QAAQ,CAAC,QAAQ;AACjC,aAAO,KAAK,GAAG;AAAA,IACjB,CAAC;AAED,UAAM,iBAAiB;AACvB,UAAM,cAAc,eAAe,gBAAgB;AACnD,mBAAe,KAAK,YAAY,gBAAgB;AAChD,mBAAe,WAAW,iBAAiB,WAAW;AACtD,WAAO,iBAAiB,WAAW;AACnC,mBAAe,mBAAmB;AAAA,EACpC;AAEA,cAA+B,EAAE,UAAU,MAAM,YAAY,MAAM,EAAE,aAAa,sBAAsB,EAAE,CAAC;AAG3G,SAAO,IAAI,qBAA0B,YAAY,EAAE,aAAa,sBAAsB,CAAC;AACzF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/adapters/treeview/useTreeviewAsDSTree.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import { useMemo } from 'react';\nimport { useArraishAsDSTree } from '../arraish-tree/useArraishAsDSTree.js';\nimport type { UseArraishAsDSTreeT } from '../arraish-tree/react-desc-prop-types.js';\n\ntype TreeviewItem<T extends object = object> = T & {\n id: string | number;\n children?: TreeviewItem[];\n};\n\nexport const useTreeviewAsDSTree = <\n T extends TreeviewItem<UseArraishAsDSTreeT.FirstParameter> = TreeviewItem<UseArraishAsDSTreeT.FirstParameter>,\n>(\n treeData: T[],\n) => {\n const opts = useMemo(\n () => ({\n getChildrenKey: () => 'children',\n getUniqueId: (node: UseArraishAsDSTreeT.FirstParameter) => `${node.id}`,\n }),\n [],\n );\n return useArraishAsDSTree(treeData, opts);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwB;AACxB,gCAAmC;AAQ5B,MAAM,sBAAsB,CAGjC,aACG;AACH,QAAM,WAAO;AAAA,IACX,OAAO;AAAA,MACL,gBAAgB,MAAM;AAAA,MACtB,aAAa,CAAC,SAA6C,GAAG,KAAK;AAAA,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwB;AACxB,gCAAmC;AAQ5B,MAAM,sBAAsB,CAGjC,aACG;AACH,QAAM,WAAO;AAAA,IACX,OAAO;AAAA,MACL,gBAAgB,MAAM;AAAA,MACtB,aAAa,CAAC,SAA6C,GAAG,KAAK,EAAE;AAAA,IACvE;AAAA,IACA,CAAC;AAAA,EACH;AACA,aAAO,8CAAmB,UAAU,IAAI;AAC1C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-use-arraish-as-ds-tree-valid.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { useArraishAsDSTree } from '../adapters/arraish-tree/useArraishAsDSTree.js';\nimport type { UseArraishAsDSTreeT } from '../adapters/arraish-tree/react-desc-prop-types.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype FirstParameterForApp = UseArraishAsDSTreeT.FirstParameter;\ntype FirstParameterInternals = UseArraishAsDSTreeT.FirstParameterInternals;\ntype FirstParameterDefaultProps = UseArraishAsDSTreeT.FirstParameterDefault;\ntype FirstParameterOptionalProps = UseArraishAsDSTreeT.FirstParameterOptional;\ntype FirstParameterRequiredProps = UseArraishAsDSTreeT.FirstParameterRequired;\n\ntype SecondParameterForApp = UseArraishAsDSTreeT.SecondParameter;\ntype SecondParameterInternals = UseArraishAsDSTreeT.SecondParameterInternals;\ntype SecondParameterDefaultProps = UseArraishAsDSTreeT.SecondParameterDefault;\ntype SecondParameterOptionalProps = UseArraishAsDSTreeT.SecondParameterOptional;\ntype SecondParameterRequiredProps = UseArraishAsDSTreeT.SecondParameterRequired;\n\nconst testRequiredPropsFirstParameter: FirstParameterRequiredProps = {};\n\nconst testRequiredPropsSecondParameter: SecondParameterRequiredProps = {\n getUniqueId: (item) => item.id as string,\n getChildrenKey: (item) => `children${item.id}`,\n};\n\nconst testOptionalPropsFirstParameter: FirstParameterOptionalProps = {\n isGroup: true,\n};\n\nconst testOptionalPropsSecondParameter: SecondParameterOptionalProps = {};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaultsFirstParameter: Partial<FirstParameterDefaultProps> = {\n idPart1: 'aa',\n idPart2: 'bb',\n};\n\nconst testPropsFirstParameter: FirstParameterForApp = {\n ...testRequiredPropsFirstParameter,\n ...testOptionalPropsFirstParameter,\n ...testPartialDefaultsFirstParameter,\n};\n\nconst testPropsAsSyntaxFirstParameter = {\n ...testRequiredPropsFirstParameter,\n ...testOptionalPropsFirstParameter,\n ...testPartialDefaultsFirstParameter,\n} as FirstParameterForApp;\n\nconst testPartialDefaultsSecondParameter: Partial<SecondParameterDefaultProps> = {};\n\nconst testPropsSecondParameter: SecondParameterForApp = {\n ...testRequiredPropsSecondParameter,\n ...testOptionalPropsSecondParameter,\n ...testPartialDefaultsSecondParameter,\n};\n\nconst testPropsAsSyntaxSecondParameter = {\n ...testRequiredPropsSecondParameter,\n ...testOptionalPropsSecondParameter,\n ...testPartialDefaultsSecondParameter,\n} as SecondParameterForApp;\n\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaultsFirstParameter: Required<FirstParameterDefaultProps> = {\n id: 'root',\n idPart1: 'root_1',\n idPart2: 'root_2',\n name: '',\n};\n\nconst testInternalPropsFirstParameter: FirstParameterInternals = {\n ...testRequiredPropsFirstParameter,\n ...testOptionalPropsFirstParameter,\n ...testCompleteDefaultsFirstParameter,\n};\n\nconst testInternalPropsAsSyntaxFirstParameter = {\n ...testRequiredPropsFirstParameter,\n ...testOptionalPropsFirstParameter,\n ...testCompleteDefaultsFirstParameter,\n} as FirstParameterInternals;\n\nconst testCompleteDefaultsSecondParameter: Required<SecondParameterDefaultProps> = {};\n\nconst testInternalPropsSecondParameter: SecondParameterInternals = {\n ...testRequiredPropsSecondParameter,\n ...testOptionalPropsSecondParameter,\n ...testCompleteDefaultsSecondParameter,\n};\n\nconst testInternalPropsAsSyntaxSecondParameter = {\n ...testRequiredPropsSecondParameter,\n ...testOptionalPropsSecondParameter,\n ...testCompleteDefaultsSecondParameter,\n} as SecondParameterInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinitionFirstParameter: FirstParameterForApp = {\n id: 'root',\n idPart1: 'root_1',\n idPart2: 'root_2',\n name: '',\n isGroup: false,\n};\n\nconst testExplicitDefinitionSecondParameter: SecondParameterForApp = {\n getUniqueId: (item) => item.id as string,\n getChildrenKey: (item) => `children${item.id}`,\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibilityFirstParameter = {\n id: 'root',\n idPart1: 'root_1',\n idPart2: 'root_2',\n name: '',\n isGroup: false,\n} as FirstParameterForApp;\n\nconst testInferedTypeCompatibilitySecondParameter = {\n getUniqueId: (item) => item.id as string,\n getChildrenKey: (item) => `children${item.id}`,\n} as SecondParameterForApp;\n\nconst testDefinitionAsConstFirstParameter = {\n id: 'root',\n idPart1: 'root_1',\n idPart2: 'root_2',\n name: '',\n isGroup: false,\n} as const;\n\nconst testDefinitionAsConstSecondParameter = {\n getUniqueId: (item: UseArraishAsDSTreeT.FirstParameter) => item.id as string,\n getChildrenKey: (item: UseArraishAsDSTreeT.FirstParameter) => `children${item.id}`,\n} as const;\n\nconst ExampleUsageComponent = () => {\n const {\n addNode,\n findAllNodes,\n findNode,\n flatten,\n getNode,\n getPath,\n getPathIds,\n getRoot,\n hash,\n moveNode,\n removeNode,\n replaceNode,\n walk,\n walkParents,\n } = useArraishAsDSTree([testExplicitDefinitionFirstParameter], testExplicitDefinitionSecondParameter);\n\n const output2 = useArraishAsDSTree(\n [testInferedTypeCompatibilityFirstParameter],\n testInferedTypeCompatibilitySecondParameter,\n );\n\n return <></>;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACiKd;AAhKT,gCAAmC;AAgBnC,MAAM,kCAA+D,CAAC;AAEtE,MAAM,mCAAiE;AAAA,EACrE,aAAa,CAAC,SAAS,KAAK;AAAA,EAC5B,gBAAgB,CAAC,SAAS,WAAW,KAAK;
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACiKd;AAhKT,gCAAmC;AAgBnC,MAAM,kCAA+D,CAAC;AAEtE,MAAM,mCAAiE;AAAA,EACrE,aAAa,CAAC,SAAS,KAAK;AAAA,EAC5B,gBAAgB,CAAC,SAAS,WAAW,KAAK,EAAE;AAC9C;AAEA,MAAM,kCAA+D;AAAA,EACnE,SAAS;AACX;AAEA,MAAM,mCAAiE,CAAC;AAIxE,MAAM,oCAAyE;AAAA,EAC7E,SAAS;AAAA,EACT,SAAS;AACX;AAEA,MAAM,0BAAgD;AAAA,EACpD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MA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AAA,EACN,SAAS;AACX;AAEA,MAAM,uCAAuC;AAAA,EAC3C,aAAa,CAAC,SAA6C,KAAK;AAAA,EAChE,gBAAgB,CAAC,SAA6C,WAAW,KAAK,EAAE;AAClF;AAEA,MAAM,wBAAwB,MAAM;AAClC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,8CAAmB,CAAC,oCAAoC,GAAG,qCAAqC;AAEpG,QAAM,cAAU;AAAA,IACd,CAAC,0CAA0C;AAAA,IAC3C;AAAA,EACF;AAEA,SAAO,2EAAE;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/DSTree.js
CHANGED
|
@@ -31,8 +31,7 @@ class DSTree {
|
|
|
31
31
|
};
|
|
32
32
|
this.removeNode = (id, options = {}) => {
|
|
33
33
|
const node = this.getNode(id);
|
|
34
|
-
if (!node)
|
|
35
|
-
throw new Error(`Node with id ${id} not found`);
|
|
34
|
+
if (!node) throw new Error(`Node with id ${id} not found`);
|
|
36
35
|
node.removeNode();
|
|
37
36
|
this._hash += 1;
|
|
38
37
|
options.callback?.(node, this);
|
package/dist/esm/DSTree.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSTree.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { AddOptions, Item, MoveOptions, MutateOptions, RemoveOptions } from './types.js';\nimport { Node } from './Node.js';\n\nexport class DSTree<T extends Item> {\n private root: Node<T>;\n\n private _hash: number;\n\n private nodes: Record<string | number, Node<T>>;\n\n getUniqueId: (item: T) => string | number;\n\n constructor(item: T, options: { getUniqueId: (item: T) => string | number }) {\n this.getUniqueId = options.getUniqueId;\n this.root = new Node(item, { childIndex: 0, depth: 0, tree: this });\n this.nodes = {};\n this._hash = 0;\n\n // autocalculate a dictionary where dsId are keys and nodes are values\n // and add the tree link to each node\n this.root.walk((node) => {\n this.nodes[node.dsId] = node;\n return true;\n });\n }\n\n addNodeToNodesDictionary(node: Node<T>): void {\n // check that we have no repeated ids\n if (this.nodes[node.dsId]) {\n throw new Error(`DSTree: repeated dsId ${node.dsId}`);\n }\n\n this.nodes[node.dsId] = node;\n }\n\n removeNodeFromNodesDictionary(node: Node<T>): void {\n delete this.nodes[node.dsId];\n }\n\n get hash(): number {\n return this._hash;\n }\n\n getRoot = (): Node<T> => this.root;\n\n getNode = (id: string | number): Node<T> => this.nodes[id];\n\n getNodes = (): Record<string, Node<T>> => this.nodes;\n\n walk = (callback: (node: Node<T>) => boolean): void => {\n this.root.walk(callback);\n };\n\n walkParents = (callback: (node: Node<T>) => boolean): void => {\n this.root.walkParents(callback);\n };\n\n findNode = (callback: (node: Node<T>) => boolean): Node<T> | null => this.root.findNode(callback);\n\n findAllNodes = (callback: (node: Node<T>) => boolean): Node<T>[] => this.root.findAllNodes(callback);\n\n flatten = (): Node<T>[] => this.root.flatten();\n\n addNode = (item: T, options: AddOptions<T> = {}): Node<T> => {\n const { position, parent, callback } = options;\n const parentDefault = parent || this.root;\n const positionDefault = position ?? parentDefault.children.length;\n\n // create node and add it to the parent\n const node = new Node(item, {\n childIndex: positionDefault,\n depth: parentDefault.depth + 1,\n parent: parentDefault,\n tree: this,\n });\n this.getNode(parentDefault.dsId).addNode(node);\n\n // change hash\n this._hash += 1;\n\n // invoke the callback if present\n callback?.(node, this);\n\n return node;\n };\n\n removeNode = (id: string | number, options: RemoveOptions<T> = {}): Node<T> => {\n const node = this.getNode(id);\n if (!node) throw new Error(`Node with id ${id} not found`);\n\n node.removeNode();\n\n // change hash\n this._hash += 1;\n\n // invoke the callback if present\n options.callback?.(node, this);\n\n return node;\n };\n\n moveNode = (id: string | number, options: MoveOptions<T> = {}): Node<T> => {\n const removedNode = this.removeNode(id);\n const node = this.addNode(removedNode.getJson(), options);\n\n this._hash += 1;\n\n return node;\n };\n\n replaceNode = (id: string | number, item: T, options: MutateOptions<T> = {}): Node<T> => {\n const removedNode = this.removeNode(id);\n const node = this.addNode(item, { parent: removedNode.parent, position: removedNode.childIndex });\n\n this._hash += 1;\n\n // invoke the callback if present\n options.callback?.(node, this);\n\n return node;\n };\n\n getPath = (id: string | number): Node<T>[] => this.getRoot().getPath(id);\n\n getPathIds = (id: string | number) => this.getRoot().getPathIds(id);\n}\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,YAAY;AAEd,MAAM,OAAuB;AAAA,EASlC,YAAY,MAAS,SAAwD;AA+B7E,mBAAU,MAAe,KAAK;AAE9B,mBAAU,CAAC,OAAiC,KAAK,MAAM,EAAE;AAEzD,oBAAW,MAA+B,KAAK;AAE/C,gBAAO,CAAC,aAA+C;AACrD,WAAK,KAAK,KAAK,QAAQ;AAAA,IACzB;AAEA,uBAAc,CAAC,aAA+C;AAC5D,WAAK,KAAK,YAAY,QAAQ;AAAA,IAChC;AAEA,oBAAW,CAAC,aAAyD,KAAK,KAAK,SAAS,QAAQ;AAEhG,wBAAe,CAAC,aAAoD,KAAK,KAAK,aAAa,QAAQ;AAEnG,mBAAU,MAAiB,KAAK,KAAK,QAAQ;AAE7C,mBAAU,CAAC,MAAS,UAAyB,CAAC,MAAe;AAC3D,YAAM,EAAE,UAAU,QAAQ,SAAS,IAAI;AACvC,YAAM,gBAAgB,UAAU,KAAK;AACrC,YAAM,kBAAkB,YAAY,cAAc,SAAS;AAG3D,YAAM,OAAO,IAAI,KAAK,MAAM;AAAA,QAC1B,YAAY;AAAA,QACZ,OAAO,cAAc,QAAQ;AAAA,QAC7B,QAAQ;AAAA,QACR,MAAM;AAAA,MACR,CAAC;AACD,WAAK,QAAQ,cAAc,IAAI,EAAE,QAAQ,IAAI;AAG7C,WAAK,SAAS;AAGd,iBAAW,MA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|
package/dist/esm/Node.js
CHANGED
|
@@ -32,10 +32,8 @@ class Node {
|
|
|
32
32
|
this.findNode = (callback) => {
|
|
33
33
|
let found = null;
|
|
34
34
|
this.walk((node) => {
|
|
35
|
-
if (found)
|
|
36
|
-
|
|
37
|
-
if (callback(node))
|
|
38
|
-
found = node;
|
|
35
|
+
if (found) return false;
|
|
36
|
+
if (callback(node)) found = node;
|
|
39
37
|
return !found;
|
|
40
38
|
});
|
|
41
39
|
return found;
|
|
@@ -43,8 +41,7 @@ class Node {
|
|
|
43
41
|
this.findAllNodes = (callback) => {
|
|
44
42
|
const found = [];
|
|
45
43
|
this.walk((node) => {
|
|
46
|
-
if (callback(node))
|
|
47
|
-
found.push(node);
|
|
44
|
+
if (callback(node)) found.push(node);
|
|
48
45
|
return true;
|
|
49
46
|
});
|
|
50
47
|
return found;
|
|
@@ -60,8 +57,7 @@ class Node {
|
|
|
60
57
|
this.getPath = (id) => {
|
|
61
58
|
const path = [];
|
|
62
59
|
const node = this.tree.getNode(id);
|
|
63
|
-
if (!node)
|
|
64
|
-
return path;
|
|
60
|
+
if (!node) return path;
|
|
65
61
|
node.walkParents((parent) => {
|
|
66
62
|
path.push(parent);
|
|
67
63
|
return parent.dsId !== this.dsId;
|
|
@@ -90,8 +86,7 @@ class Node {
|
|
|
90
86
|
this._hash += 1;
|
|
91
87
|
};
|
|
92
88
|
this.removeNode = () => {
|
|
93
|
-
if (!this.parent)
|
|
94
|
-
throw new Error(`Cannot remove root node with id ${this.dsId}`);
|
|
89
|
+
if (!this.parent) throw new Error(`Cannot remove root node with id ${this.dsId}`);
|
|
95
90
|
this.parent.children.splice(this.childIndex, 1);
|
|
96
91
|
this.parent.fixChildIndexes();
|
|
97
92
|
this.walk((child) => {
|
package/dist/esm/Node.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/Node.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-use-before-define */\n/* eslint-disable max-params */\nimport { cloneDeep, omit } from 'lodash';\nimport type { DSTree } from './DSTree.js';\nimport type { Item, NodeConstructorOptions } from './types.js';\n\nexport class Node<T extends Item> {\n dsId: string | number;\n\n plainItem: T;\n\n childIndex: number;\n\n depth: number;\n\n parent: Node<T> | null;\n\n children: Node<T>[];\n\n private tree!: DSTree<T>;\n\n private _hash: number;\n\n constructor(item: T, { childIndex, depth, parent, tree }: NodeConstructorOptions<T>) {\n this.dsId = tree.getUniqueId(item);\n this.childIndex = childIndex;\n this.depth = depth;\n this.parent = parent ?? null;\n this.tree = tree;\n this._hash = 0;\n\n this.children =\n item.subitems?.map(\n (subitem, index) => new Node(subitem as T, { childIndex: index, depth: depth + 1, parent: this, tree }),\n ) ?? [];\n\n // Save the item without the subitems\n this.plainItem = this.getCleanItem(item);\n }\n\n // ===========================================================================\n // INTERNAL METHODS\n // ===========================================================================\n\n fixChildIndexes = (): void => {\n for (let i = 0; i < this.children.length; i++) {\n this.children[i].childIndex = i;\n }\n this._hash += 1;\n };\n\n getCleanItem = (item: T): T => {\n const plainItem = omit(item, ['subitems']);\n return cloneDeep(plainItem as T);\n };\n\n // ===========================================================================\n // READ METHODS\n // ===========================================================================\n\n get hash(): number {\n return this._hash;\n }\n\n walk = (callback: (node: Node<T>) => boolean): void => {\n const shouldContinueWalking = callback(this);\n if (shouldContinueWalking) {\n for (const child of this.children) {\n child.walk(callback);\n }\n }\n };\n\n walkParents = (callback: (node: Node<T>) => boolean): void => {\n const shouldContinueWalking = callback(this);\n if (shouldContinueWalking && this.parent) {\n this.parent.walkParents(callback);\n }\n };\n\n findNode = (callback: (node: Node<T>) => boolean): Node<T> | null => {\n // find first node using walk\n let found: Node<T> | null = null;\n this.walk((node) => {\n // If we already found it, don't look anymore\n if (found) return false;\n\n // Otherwise keep looking\n if (callback(node)) found = node;\n return !found;\n });\n\n return found;\n };\n\n findAllNodes = (callback: (node: Node<T>) => boolean): Node<T>[] => {\n const found: Node<T>[] = [];\n this.walk((node) => {\n if (callback(node)) found.push(node);\n return true;\n });\n return found;\n };\n\n flatten = (): Node<T>[] => {\n const flattened: Node<T>[] = [];\n this.walk((node) => {\n flattened.push(node);\n return true;\n });\n return flattened;\n };\n\n getPath = (id: string | number): Node<T>[] => {\n const path: Node<T>[] = [];\n const node = this.tree.getNode(id);\n if (!node) return path;\n node.walkParents((parent) => {\n path.push(parent);\n return parent.dsId !== this.dsId;\n });\n return path.reverse();\n };\n\n getPathIds = (id: string | number) => this.getPath(id).map((node) => node.dsId);\n\n getJson = (): T => ({\n ...this.plainItem,\n subitems: this.children.map((child) => child.getJson()),\n });\n\n // ===========================================================================\n // WRITE METHODS\n // ===========================================================================\n\n addNode = (node: Node<T>) => {\n // check that the position is valid for that parent\n const position = node.childIndex;\n if (position < 0 || position > this.children.length) {\n throw new Error(`Invalid position ${position} for parent ${this.dsId} with item ${node.dsId}`);\n }\n\n // add the new node\n this.children.splice(position, 0, node);\n\n // fix the childIndex of the nodes after the new one\n this.fixChildIndexes();\n\n // add subtree of the new node to the node dictionary\n node.walk((child) => {\n this.tree.addNodeToNodesDictionary(child);\n return true;\n });\n\n this._hash += 1;\n };\n\n removeNode = () => {\n // if no parent throw error\n if (!this.parent) throw new Error(`Cannot remove root node with id ${this.dsId}`);\n\n // remove from parent\n this.parent.children.splice(this.childIndex, 1);\n\n // fix the childIndex of the nodes of the parent\n this.parent.fixChildIndexes();\n\n // remove subtree from the node dictionary\n this.walk((child) => {\n this.tree.removeNodeFromNodesDictionary(child);\n return true;\n });\n\n this._hash += 1;\n };\n}\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,WAAW,YAAY;AAIzB,MAAM,KAAqB;AAAA,EAiBhC,YAAY,MAAS,EAAE,YAAY,OAAO,QAAQ,KAAK,GAA8B;AAqBrF;AAAA;AAAA;AAAA,2BAAkB,MAAY;AAC5B,eAAS,IAAI,G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node.depth === 0)
|
|
9
|
-
return true;
|
|
8
|
+
if (node.depth === 0) return true;
|
|
10
9
|
const nodeJson = node.getJson();
|
|
11
10
|
const originalNode = structuredClone(nodeJson.originalNodeData);
|
|
12
11
|
const nodeChildrenKey = getChildrenKey(originalNode);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/adapters/arraish-tree/fromDSTreeToTreeishArray.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\nimport type { DSTree } from '../../DSTree.js';\nimport type { Node } from '../../Node.js';\nimport type { OverloadedItem } from '../../types.js';\n\n/*\n * a function that given a DSTree datastructure and some options returns a treeish array that compltely preserves the original data.\n * this is meant to revert the operation done by fromTreeishArrayToDSTree in a seamless way,\n * as such makes, some assumptions:\n * - the original data lives under the \"originalNodeData\" property of the node\n * - the root node is a pseudoRoot node that will not be part of the final treeish array\n * NOTE: This create a deep clone of the node original data, so it's not suitable for large trees and will not preserve any reference in the nodes original data\n * NOTE2: Nodes that have no children will be restored with an empty \"children\" array, this may be a data-loss, but this can't be easily avoided,\n * if this is important for your use-case you should implement your own conversion function with your requirements\n * @param {DSTree} tree - a DSTree datastructure (generated with a structure exactly the same as the one resulting from invoking fromTreeishArrayToDSTree)\n * @param {Object} opts - an object that governs how the treeish array will be converted to a DSTree datastructure\n * @param {Function} opts.getChildrenKey - a function that given a node returns the key used to access the node children\n * @param {Function} opts.getUniqueId - a function that given a node returns a unique string used to identify the node\n * @returns {Array} - a treeish array\n */\n\nexport const fromDSTreeToTreeishArray = <T extends object = object>(args: {\n tree: DSTree<OverloadedItem<T>>;\n opts: {\n getChildrenKey: (node: T) => keyof T;\n getUniqueId: (node: T) => string;\n };\n}): T[] => {\n const { tree, opts } = args;\n const { getChildrenKey, getUniqueId } = opts;\n const root = tree.getRoot();\n const restoredTreeish: T[] = [];\n const callback = (node: Node<OverloadedItem<T>>) => {\n // everytime we step in a node we want to:\n // - understand if the node has a parent\n // - if it does, we want to find the parent in the restoredTreeish array and add the node to the parent's children\n // the \"children\" are stored under the key returned by the getChildrenKey function\n // - if it doesn't, we make the assumption that this is a \"first-level\" node and we add it to the restoredTreeish array\n // - what ends up in the restoredTreeish array are only value from the \"originalNodeData\" property of the node + childrens under the key returned by the getChildrenKey function\n // we skip the root node\n if (node.depth === 0) return true;\n // we create the original node from the originalNodeData property of the node\n const nodeJson = node.getJson();\n const originalNode = structuredClone(nodeJson.originalNodeData);\n const nodeChildrenKey = getChildrenKey(originalNode);\n // we add a \"children\" array, creating it if doesn't exist\n if (!Object.hasOwnProperty.call(originalNode, nodeChildrenKey)) {\n Object.defineProperty(originalNode, nodeChildrenKey, {\n value: [] as T[],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n // if depth is 1, we are dealing with a first-level node, so we add it to the restoredTreeish array as is\n if (node.depth === 1) {\n restoredTreeish.push(originalNode);\n return true;\n }\n // if depth is > 1, we are dealing with a node that has a parent, so we need to find the parent in the restoredTreeish array\n // and add the node to the parent's children\n const parents = root.getPathIds(node.dsId);\n parents.shift(); // we added the pseudo-root, we skip it based on the assumption\n parents.pop(); // getPathIds also include the current searched for at the end of the array, we don't need that\n\n // we now find the parent in the restoredTreeish array\n // if this find fails this is an unrecoverable error, something is wrong in the opts callbacks or at app-level\n // the only other alternative is that the \"walk\" method from DSTree changed the order of the nodes, which would be a breaking change\n let parent = restoredTreeish.find((item: T) => `${getUniqueId(item)}` === parents[0]) as T;\n if (!parent)\n throw new Error(\n `Unable to find parent node with id ${parents[0]}, have you provided the correct getUniqueId function?`,\n );\n let parentChildrenKey = getChildrenKey(parent);\n // we now walk the parents array, skipping the first element (we already found the parent),\n // we must use the for loop to be sure that we are invoking code sequentially\n for (let i = 1; i < parents.length; i++) {\n // if this loop fails this is an unrecoverable error, something is wrong in the opts callbacks or at app-level\n // the only other alternative is that the \"walk\" method from DSTree changed the order of the nodes, which would be a breaking change\n const childrens = parent[parentChildrenKey] as T[];\n if (!childrens)\n throw new Error(\n `Unable to children node with id ${parents[i]}, have you provided the correct getChildrenKey function?`,\n );\n parent = childrens.find((item: T) => `${getUniqueId(item)}` === parents[i]) as T;\n parentChildrenKey = getChildrenKey(parent);\n }\n\n const parentChildrenArray = parent[parentChildrenKey] as T[];\n parentChildrenArray.push(originalNode);\n\n return true; // we will walk all the nodes no matter what\n };\n root.walk(callback);\n\n return restoredTreeish;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACqBhB,MAAM,2BAA2B,CAA4B,SAMzD;AACT,QAAM,EAAE,MAAM,KAAK,IAAI;AACvB,QAAM,EAAE,gBAAgB,YAAY,IAAI;AACxC,QAAM,OAAO,KAAK,QAAQ;AAC1B,QAAM,kBAAuB,CAAC;AAC9B,QAAM,WAAW,CAAC,SAAkC;AAQlD,QAAI,KAAK,UAAU
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACqBhB,MAAM,2BAA2B,CAA4B,SAMzD;AACT,QAAM,EAAE,MAAM,KAAK,IAAI;AACvB,QAAM,EAAE,gBAAgB,YAAY,IAAI;AACxC,QAAM,OAAO,KAAK,QAAQ;AAC1B,QAAM,kBAAuB,CAAC;AAC9B,QAAM,WAAW,CAAC,SAAkC;AAQlD,QAAI,KAAK,UAAU,EAAG,QAAO;AAE7B,UAAM,WAAW,KAAK,QAAQ;AAC9B,UAAM,eAAe,gBAAgB,SAAS,gBAAgB;AAC9D,UAAM,kBAAkB,eAAe,YAAY;AAEnD,QAAI,CAAC,OAAO,eAAe,KAAK,cAAc,eAAe,GAAG;AAC9D,aAAO,eAAe,cAAc,iBAAiB;AAAA,QACnD,OAAO,CAAC;AAAA,QACR,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,cAAc;AAAA,MAChB,CAAC;AAAA,IACH;AAEA,QAAI,KAAK,UAAU,GAAG;AACpB,sBAAgB,KAAK,YAAY;AACjC,aAAO;AAAA,IACT;AAGA,UAAM,UAAU,KAAK,WAAW,KAAK,IAAI;AACzC,YAAQ,MAAM;AACd,YAAQ,IAAI;AAKZ,QAAI,SAAS,gBAAgB,KAAK,CAAC,SAAY,GAAG,YAAY,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC;AACpF,QAAI,CAAC;AACH,YAAM,IAAI;AAAA,QACR,sCAAsC,QAAQ,CAAC,CAAC;AAAA,MAClD;AACF,QAAI,oBAAoB,eAAe,MAAM;AAG7C,aAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AAGvC,YAAM,YAAY,OAAO,iBAAiB;AAC1C,UAAI,CAAC;AACH,cAAM,IAAI;AAAA,UACR,mCAAmC,QAAQ,CAAC,CAAC;AAAA,QAC/C;AACF,eAAS,UAAU,KAAK,CAAC,SAAY,GAAG,YAAY,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC1E,0BAAoB,eAAe,MAAM;AAAA,IAC3C;AAEA,UAAM,sBAAsB,OAAO,iBAAiB;AACpD,wBAAoB,KAAK,YAAY;AAErC,WAAO;AAAA,EACT;AACA,OAAK,KAAK,QAAQ;AAElB,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -30,8 +30,7 @@ const fromTreeishArrayToDSTree = (args) => {
|
|
|
30
30
|
const overloadedGetChildren = (node) => node.subitems;
|
|
31
31
|
const overloadedGetUniqueId = (node) => node.id;
|
|
32
32
|
const callback = (node) => {
|
|
33
|
-
if (node.id === rootId)
|
|
34
|
-
return;
|
|
33
|
+
if (node.id === rootId) return;
|
|
35
34
|
const originalNodeData = structuredClone(node);
|
|
36
35
|
Object.keys(node).forEach((key) => {
|
|
37
36
|
delete node[key];
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/adapters/arraish-tree/fromTreeishArrayToDSTree.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\nimport { DSTree } from '../../DSTree.js';\nimport type { OverloadedItem } from '../../types.js';\n\n// we don't really need a 100% sure unique id, since we prepend a string that is most likely unique already\n// we just need to reduce the risk of collisions\n// we avoid depending on a library for this:\nconst unsecureUuid = () =>\n 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c == 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n\n/*\n * @param {Object} args\n * @param {Function} args.callback - a function that will be called for each node in the treeish data-structure\n * @param {Object} args.node - the node that is being currently visited\n * @param {Object} args.opts - an object that holds the opinions of the caller on how to walk the treeish data-structure\n * @param {Function} args.opts.getChildren - a function that given a node returns an array of children\n * @returns {void}\n */\nconst walkTreeish = <T extends object>({\n callback,\n node,\n opts,\n}: {\n callback: (node: T) => void;\n node: T;\n opts?: {\n getChildren: (node: T) => T[];\n };\n}): void => {\n callback(node);\n const children = opts?.getChildren(node);\n if (Array.isArray(children) && children.length > 0) {\n for (let i = 0; i < children.length; i += 1) {\n walkTreeish<T>({ callback, node: children[i], opts });\n }\n }\n};\n\n/*\n * a function that given a treeish array and some options returns a DSTree datastructure that compltely preserves the treeish array\n * but still allows to use the full power of the DSTree datastructure\n * NOTE: This create a deep clone of the treeish array, so it's not suitable for large trees and will not preserve any reference to the original treeish array\n * @param {Array} treeish - an array of items that rapresents a tree, this will be used to create a DSTree datastructure\n * @param {Object} opts - an object that governs how the treeish array will be converted to a DSTree datastructure\n * @param {Function} opts.getChildrenKey - a function that given a node returns the key used to access the node children\n * @param {Function} opts.getUniqueId - a function that given a node returns a unique string used to identify the node\n * @returns {DSTree} - a DSTree datastructure\n */\nexport const fromTreeishArrayToDSTree = <T extends object = object>(args: {\n treeish: T[];\n opts: {\n getChildrenKey: (node: T) => keyof T;\n getUniqueId: (item: T) => string;\n };\n}): DSTree<OverloadedItem<T>> => {\n // we use crypto to generate a unique id for the root, this is important for reduce the risk of collisions with any user provided id\n const rootId = `_autogenerated-ds-pseudoRoot-${unsecureUuid()}`;\n const { opts, treeish } = args;\n const { getUniqueId, getChildrenKey } = opts;\n\n // a DSTree compatible datastructure has the following characteristics:\n // - it has a \"subitems\" property that contains an array of children\n // - it has a property that holds a unique string used to identify the node (accessed via the getUniqueId function)\n // - it is in an object format\n const pseudoRoot: OverloadedItem<T> = {\n id: rootId,\n subitems: structuredClone(treeish) as unknown as OverloadedItem<T>[],\n originalNodeData: {} as T,\n };\n // we now create an over-charged getChildren function\n // this is because we mutate the object every step during the walk\n //. this function is going to receive the OverloadedItem<T> each step\n const overloadedGetChildren = (node: OverloadedItem<T>) => node.subitems;\n const overloadedGetUniqueId = (node: OverloadedItem<T>) => node.id;\n // we now create a \"callback\" function that will be used when walking the pseudoRoot object.\n // this callback will mutate the pseudoRoot object, making sure that after the mutation it will be compatible with the DSTree datastructure\n // we can't really make an assumption that the subitems key isn't somehow already part of the data from the user,\n // so to avoid any collision we will create an extra-level of nesting, in this layer only 3 properties will be allowed:\n // - id: a unique string used to identify the node, this is already a requirement from the treeish datastructure provided by the user\n // - subitems: an array of children\n // - original: the original data provided by the user\n // we remove the original tree rapresentation from the node, we only want one source of truth for the tree\n // if we don't remove this, when operating the DSTree we would have to somehow also propagate the changes to the original tree\n // the way this is intended to be used is instead to convert back and forth between the DSTree and the treeish array\n // the conversion will restore the treeish structure with the updated tree after operating on the DSTree\n const callback = (node: OverloadedItem<T>) => {\n // we skip the root node\n if (node.id === rootId) return;\n // we safe-keep the original data provided by the user\n const originalNodeData = structuredClone(node) as unknown as T;\n // we now mutate the node, making it compatible with the DSTree datastructure\n // first we clean all the properties\n Object.keys(node).forEach((key) => {\n delete node[key];\n });\n // we now add the properties that are required by the DSTree datastructure\n const overloadedNode = node as unknown as OverloadedItem<T>;\n const childrenKey = getChildrenKey(originalNodeData);\n overloadedNode.id = getUniqueId(originalNodeData);\n overloadedNode.subitems = originalNodeData[childrenKey] as OverloadedItem<T>[];\n delete originalNodeData[childrenKey];\n overloadedNode.originalNodeData = originalNodeData;\n };\n // we now walk the pseudoRoot object, mutating it in the process\n walkTreeish<OverloadedItem<T>>({ callback, node: pseudoRoot, opts: { getChildren: overloadedGetChildren } });\n\n // we know that pseudoRoot is an item after we have walked and mutated it, so we can safely cast it\n return new DSTree<OverloadedItem<T>>(pseudoRoot, { getUniqueId: overloadedGetUniqueId });\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,cAAc;AAMvB,MAAM,eAAe,MACnB,uCAAuC,QAAQ,SAAS,CAAC,MAAM;AAC7D,QAAM,IAAK,KAAK,OAAO,IAAI,KAAM;AACjC,QAAM,IAAI,KAAK,MAAM,IAAK,IAAI,IAAO;AACrC,SAAO,EAAE,SAAS,EAAE;AACtB,CAAC;AAUH,MAAM,cAAc,CAAmB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,MAMY;AACV,WAAS,IAAI;AACb,QAAM,WAAW,MAAM,YAAY,IAAI;AACvC,MAAI,MAAM,QAAQ,QAAQ,KAAK,SAAS,SAAS,GAAG;AAClD,aAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK,GAAG;AAC3C,kBAAe,EAAE,UAAU,MAAM,SAAS,CAAC,GAAG,KAAK,CAAC;AAAA,IACtD;AAAA,EACF;AACF;AAYO,MAAM,2BAA2B,CAA4B,SAMnC;AAE/B,QAAM,SAAS,gCAAgC,aAAa;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,cAAc;AAMvB,MAAM,eAAe,MACnB,uCAAuC,QAAQ,SAAS,CAAC,MAAM;AAC7D,QAAM,IAAK,KAAK,OAAO,IAAI,KAAM;AACjC,QAAM,IAAI,KAAK,MAAM,IAAK,IAAI,IAAO;AACrC,SAAO,EAAE,SAAS,EAAE;AACtB,CAAC;AAUH,MAAM,cAAc,CAAmB;AAAA,EACrC;AAAA,EACA;AAAA,EACA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/build/transpile/react-shim.js", "../../../../src/adapters/treeview/useTreeviewAsDSTree.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport { useArraishAsDSTree } from '../arraish-tree/useArraishAsDSTree.js';\nimport type { UseArraishAsDSTreeT } from '../arraish-tree/react-desc-prop-types.js';\n\ntype TreeviewItem<T extends object = object> = T & {\n id: string | number;\n children?: TreeviewItem[];\n};\n\nexport const useTreeviewAsDSTree = <\n T extends TreeviewItem<UseArraishAsDSTreeT.FirstParameter> = TreeviewItem<UseArraishAsDSTreeT.FirstParameter>,\n>(\n treeData: T[],\n) => {\n const opts = useMemo(\n () => ({\n getChildrenKey: () => 'children',\n getUniqueId: (node: UseArraishAsDSTreeT.FirstParameter) => `${node.id}`,\n }),\n [],\n );\n return useArraishAsDSTree(treeData, opts);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe;AACxB,SAAS,0BAA0B;AAQ5B,MAAM,sBAAsB,CAGjC,aACG;AACH,QAAM,OAAO;AAAA,IACX,OAAO;AAAA,MACL,gBAAgB,MAAM;AAAA,MACtB,aAAa,CAAC,SAA6C,GAAG,KAAK;AAAA,
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe;AACxB,SAAS,0BAA0B;AAQ5B,MAAM,sBAAsB,CAGjC,aACG;AACH,QAAM,OAAO;AAAA,IACX,OAAO;AAAA,MACL,gBAAgB,MAAM;AAAA,MACtB,aAAa,CAAC,SAA6C,GAAG,KAAK,EAAE;AAAA,IACvE;AAAA,IACA,CAAC;AAAA,EACH;AACA,SAAO,mBAAmB,UAAU,IAAI;AAC1C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-use-arraish-as-ds-tree-valid.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { useArraishAsDSTree } from '../adapters/arraish-tree/useArraishAsDSTree.js';\nimport type { UseArraishAsDSTreeT } from '../adapters/arraish-tree/react-desc-prop-types.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype FirstParameterForApp = UseArraishAsDSTreeT.FirstParameter;\ntype FirstParameterInternals = UseArraishAsDSTreeT.FirstParameterInternals;\ntype FirstParameterDefaultProps = UseArraishAsDSTreeT.FirstParameterDefault;\ntype FirstParameterOptionalProps = UseArraishAsDSTreeT.FirstParameterOptional;\ntype FirstParameterRequiredProps = UseArraishAsDSTreeT.FirstParameterRequired;\n\ntype SecondParameterForApp = UseArraishAsDSTreeT.SecondParameter;\ntype SecondParameterInternals = UseArraishAsDSTreeT.SecondParameterInternals;\ntype SecondParameterDefaultProps = UseArraishAsDSTreeT.SecondParameterDefault;\ntype SecondParameterOptionalProps = UseArraishAsDSTreeT.SecondParameterOptional;\ntype SecondParameterRequiredProps = UseArraishAsDSTreeT.SecondParameterRequired;\n\nconst testRequiredPropsFirstParameter: FirstParameterRequiredProps = {};\n\nconst testRequiredPropsSecondParameter: SecondParameterRequiredProps = {\n getUniqueId: (item) => item.id as string,\n getChildrenKey: (item) => `children${item.id}`,\n};\n\nconst testOptionalPropsFirstParameter: FirstParameterOptionalProps = {\n isGroup: true,\n};\n\nconst testOptionalPropsSecondParameter: SecondParameterOptionalProps = {};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaultsFirstParameter: Partial<FirstParameterDefaultProps> = {\n idPart1: 'aa',\n idPart2: 'bb',\n};\n\nconst testPropsFirstParameter: FirstParameterForApp = {\n ...testRequiredPropsFirstParameter,\n ...testOptionalPropsFirstParameter,\n ...testPartialDefaultsFirstParameter,\n};\n\nconst testPropsAsSyntaxFirstParameter = {\n ...testRequiredPropsFirstParameter,\n ...testOptionalPropsFirstParameter,\n ...testPartialDefaultsFirstParameter,\n} as FirstParameterForApp;\n\nconst testPartialDefaultsSecondParameter: Partial<SecondParameterDefaultProps> = {};\n\nconst testPropsSecondParameter: SecondParameterForApp = {\n ...testRequiredPropsSecondParameter,\n ...testOptionalPropsSecondParameter,\n ...testPartialDefaultsSecondParameter,\n};\n\nconst testPropsAsSyntaxSecondParameter = {\n ...testRequiredPropsSecondParameter,\n ...testOptionalPropsSecondParameter,\n ...testPartialDefaultsSecondParameter,\n} as SecondParameterForApp;\n\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaultsFirstParameter: Required<FirstParameterDefaultProps> = {\n id: 'root',\n idPart1: 'root_1',\n idPart2: 'root_2',\n name: '',\n};\n\nconst testInternalPropsFirstParameter: FirstParameterInternals = {\n ...testRequiredPropsFirstParameter,\n ...testOptionalPropsFirstParameter,\n ...testCompleteDefaultsFirstParameter,\n};\n\nconst testInternalPropsAsSyntaxFirstParameter = {\n ...testRequiredPropsFirstParameter,\n ...testOptionalPropsFirstParameter,\n ...testCompleteDefaultsFirstParameter,\n} as FirstParameterInternals;\n\nconst testCompleteDefaultsSecondParameter: Required<SecondParameterDefaultProps> = {};\n\nconst testInternalPropsSecondParameter: SecondParameterInternals = {\n ...testRequiredPropsSecondParameter,\n ...testOptionalPropsSecondParameter,\n ...testCompleteDefaultsSecondParameter,\n};\n\nconst testInternalPropsAsSyntaxSecondParameter = {\n ...testRequiredPropsSecondParameter,\n ...testOptionalPropsSecondParameter,\n ...testCompleteDefaultsSecondParameter,\n} as SecondParameterInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinitionFirstParameter: FirstParameterForApp = {\n id: 'root',\n idPart1: 'root_1',\n idPart2: 'root_2',\n name: '',\n isGroup: false,\n};\n\nconst testExplicitDefinitionSecondParameter: SecondParameterForApp = {\n getUniqueId: (item) => item.id as string,\n getChildrenKey: (item) => `children${item.id}`,\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibilityFirstParameter = {\n id: 'root',\n idPart1: 'root_1',\n idPart2: 'root_2',\n name: '',\n isGroup: false,\n} as FirstParameterForApp;\n\nconst testInferedTypeCompatibilitySecondParameter = {\n getUniqueId: (item) => item.id as string,\n getChildrenKey: (item) => `children${item.id}`,\n} as SecondParameterForApp;\n\nconst testDefinitionAsConstFirstParameter = {\n id: 'root',\n idPart1: 'root_1',\n idPart2: 'root_2',\n name: '',\n isGroup: false,\n} as const;\n\nconst testDefinitionAsConstSecondParameter = {\n getUniqueId: (item: UseArraishAsDSTreeT.FirstParameter) => item.id as string,\n getChildrenKey: (item: UseArraishAsDSTreeT.FirstParameter) => `children${item.id}`,\n} as const;\n\nconst ExampleUsageComponent = () => {\n const {\n addNode,\n findAllNodes,\n findNode,\n flatten,\n getNode,\n getPath,\n getPathIds,\n getRoot,\n hash,\n moveNode,\n removeNode,\n replaceNode,\n walk,\n walkParents,\n } = useArraishAsDSTree([testExplicitDefinitionFirstParameter], testExplicitDefinitionSecondParameter);\n\n const output2 = useArraishAsDSTree(\n [testInferedTypeCompatibilityFirstParameter],\n testInferedTypeCompatibilitySecondParameter,\n );\n\n return <></>;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACiKd;AAhKT,SAAS,0BAA0B;AAgBnC,MAAM,kCAA+D,CAAC;AAEtE,MAAM,mCAAiE;AAAA,EACrE,aAAa,CAAC,SAAS,KAAK;AAAA,EAC5B,gBAAgB,CAAC,SAAS,WAAW,KAAK;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACiKd;AAhKT,SAAS,0BAA0B;AAgBnC,MAAM,kCAA+D,CAAC;AAEtE,MAAM,mCAAiE;AAAA,EACrE,aAAa,CAAC,SAAS,KAAK;AAAA,EAC5B,gBAAgB,CAAC,SAAS,WAAW,KAAK,EAAE;AAC9C;AAEA,MAAM,kCAA+D;AAAA,EACnE,SAAS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AClD,aAAa,CAAC,SAAS,KAAK;AAAA,EAC5B,gBAAgB,CAAC,SAAS,WAAW,KAAK,EAAE;AAC9C;AAEA,MAAM,sCAAsC;AAAA,EAC1C,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AACX;AAEA,MAAM,uCAAuC;AAAA,EAC3C,aAAa,CAAC,SAA6C,KAAK;AAAA,EAChE,gBAAgB,CAAC,SAA6C,WAAW,KAAK,EAAE;AAClF;AAEA,MAAM,wBAAwB,MAAM;AAClC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,mBAAmB,CAAC,oCAAoC,GAAG,qCAAqC;AAEpG,QAAM,UAAU;AAAA,IACd,CAAC,0CAA0C;AAAA,IAC3C;AAAA,EACF;AAEA,SAAO,gCAAE;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-tree-model",
|
|
3
|
-
"version": "3.36.
|
|
3
|
+
"version": "3.36.1-next.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Tree Model",
|
|
6
6
|
"files": [
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"typeSafety": true
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elliemae/ds-props-helpers": "3.36.
|
|
43
|
+
"@elliemae/ds-props-helpers": "3.36.1-next.7"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@elliemae/pui-cli": "~9.0.0-next.31",
|
|
47
|
-
"@elliemae/ds-monorepo-devops": "3.36.
|
|
47
|
+
"@elliemae/ds-monorepo-devops": "3.36.1-next.7"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"lodash": "^4.17.21",
|