@elliemae/ds-tree-model 3.41.2-rc.1 → 3.42.0-rc.0

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 (35) hide show
  1. package/dist/cjs/DSTree.js.map +2 -2
  2. package/dist/cjs/Node.js +11 -5
  3. package/dist/cjs/Node.js.map +2 -2
  4. package/dist/cjs/adapters/arraish-tree/fromDSTreeToTreeishArray.js +1 -1
  5. package/dist/cjs/adapters/arraish-tree/fromDSTreeToTreeishArray.js.map +2 -2
  6. package/dist/cjs/adapters/arraish-tree/fromTreeishArrayToDSTree.js +2 -2
  7. package/dist/cjs/adapters/arraish-tree/fromTreeishArrayToDSTree.js.map +2 -2
  8. package/dist/cjs/react-desc-prop-types.js.map +2 -2
  9. package/dist/cjs/types.js.map +1 -1
  10. package/dist/cjs/typescript-testing/typescript-use-arraish-as-ds-tree-valid.js +1 -2
  11. package/dist/cjs/typescript-testing/typescript-use-arraish-as-ds-tree-valid.js.map +2 -2
  12. package/dist/cjs/typescript-testing/typescript-use-ds-tree-valid.js +40 -73
  13. package/dist/cjs/typescript-testing/typescript-use-ds-tree-valid.js.map +2 -2
  14. package/dist/cjs/useDSTree.js +1 -1
  15. package/dist/cjs/useDSTree.js.map +2 -2
  16. package/dist/esm/DSTree.js.map +2 -2
  17. package/dist/esm/Node.js +11 -5
  18. package/dist/esm/Node.js.map +2 -2
  19. package/dist/esm/adapters/arraish-tree/fromDSTreeToTreeishArray.js +1 -1
  20. package/dist/esm/adapters/arraish-tree/fromDSTreeToTreeishArray.js.map +2 -2
  21. package/dist/esm/adapters/arraish-tree/fromTreeishArrayToDSTree.js +2 -2
  22. package/dist/esm/adapters/arraish-tree/fromTreeishArrayToDSTree.js.map +2 -2
  23. package/dist/esm/react-desc-prop-types.js.map +2 -2
  24. package/dist/esm/typescript-testing/typescript-use-arraish-as-ds-tree-valid.js +1 -2
  25. package/dist/esm/typescript-testing/typescript-use-arraish-as-ds-tree-valid.js.map +2 -2
  26. package/dist/esm/typescript-testing/typescript-use-ds-tree-valid.js +40 -73
  27. package/dist/esm/typescript-testing/typescript-use-ds-tree-valid.js.map +2 -2
  28. package/dist/esm/useDSTree.js +1 -1
  29. package/dist/esm/useDSTree.js.map +2 -2
  30. package/dist/types/DSTree.d.ts +20 -20
  31. package/dist/types/Node.d.ts +15 -15
  32. package/dist/types/react-desc-prop-types.d.ts +21 -40
  33. package/dist/types/types.d.ts +25 -20
  34. package/dist/types/useDSTree.d.ts +4 -2
  35. package/package.json +3 -3
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/DSTree.ts", "../../../../../scripts/build/transpile/react-shim.js"],
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,MAA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AAqB,MAAS,UAA4B,CAAC,MAAe;AACvF,YAAM,cAAc,KAAK,WAAW,EAAE;AACtC,YAAM,OAAO,KAAK,QAAQ,MAAM,EAAE,QAAQ,YAAY,QAAQ,UAAU,YAAY,WAAW,CAAC;AAEhG,WAAK,SAAS;AAGd,cAAQ,WAAW,MAAM,IAAI;AAE7B,aAAO;AAAA,IACT;AAEA,mBAAU,CAAC,OAAmC,KAAK,QAAQ,EAAE,QAAQ,EAAE;AAEvE,sBAAa,CAAC,OAAwB,KAAK,QAAQ,EAAE,WAAW,EAAE;AA/GhE,SAAK,cAAc,QAAQ;AAC3B,SAAK,OAAO,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;",
4
+ "sourcesContent": ["/* eslint-disable no-underscore-dangle */\nimport type {\n AddOptions,\n AnyObjectWithoutReservedKeys,\n MoveOptions,\n MutateOptions,\n RemoveOptions,\n JSONThatCanContrusctATree,\n Item,\n} from './types.js';\nimport { Node } from './Node.js';\n\nexport class DSTree<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> {\n private root: Node<AppInterface>;\n\n private _hash: number;\n\n private nodes: Record<string | number, Node<AppInterface>>;\n\n getUniqueId: (item: Item<AppInterface>) => string | number;\n\n constructor(\n item: JSONThatCanContrusctATree<AppInterface>,\n options: { getUniqueId: (item: Item<AppInterface>) => string | number },\n ) {\n this.getUniqueId = options.getUniqueId;\n this.root = new Node<AppInterface>(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<AppInterface>): 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<AppInterface>): void {\n delete this.nodes[node.dsId];\n }\n\n get hash(): number {\n return this._hash;\n }\n\n getRoot = (): Node<AppInterface> => this.root;\n\n getNode = (id: string | number): Node<AppInterface> => this.nodes[id];\n\n getNodes = (): Record<string, Node<AppInterface>> => this.nodes;\n\n walk = (callback: (node: Node<AppInterface>) => boolean): void => {\n this.root.walk(callback);\n };\n\n walkParents = (callback: (node: Node<AppInterface>) => boolean): void => {\n this.root.walkParents(callback);\n };\n\n findNode = (callback: (node: Node<AppInterface>) => boolean): Node<AppInterface> | null =>\n this.root.findNode(callback);\n\n findAllNodes = (callback: (node: Node<AppInterface>) => boolean): Node<AppInterface>[] =>\n this.root.findAllNodes(callback);\n\n flatten = (): Node<AppInterface>[] => this.root.flatten();\n\n addNode = (\n item: JSONThatCanContrusctATree<AppInterface>,\n options: AddOptions<AppInterface> = {},\n ): Node<AppInterface> => {\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<AppInterface>(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<AppInterface> = {}): Node<AppInterface> => {\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<AppInterface> = {}): Node<AppInterface> => {\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 = (\n id: string | number,\n item: JSONThatCanContrusctATree<AppInterface>,\n options: MutateOptions<AppInterface> = {},\n ): Node<AppInterface> => {\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<AppInterface>[] => 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;ADUvB,kBAAqB;AAEd,MAAM,OAAoF;AAAA,EAS/F,YACE,MACA,SACA;AA+BF,mBAAU,MAA0B,KAAK;AAEzC,mBAAU,CAAC,OAA4C,KAAK,MAAM,EAAE;AAEpE,oBAAW,MAA0C,KAAK;AAE1D,gBAAO,CAAC,aAA0D;AAChE,WAAK,KAAK,KAAK,QAAQ;AAAA,IACzB;AAEA,uBAAc,CAAC,aAA0D;AACvE,WAAK,KAAK,YAAY,QAAQ;AAAA,IAChC;AAEA,oBAAW,CAAC,aACV,KAAK,KAAK,SAAS,QAAQ;AAE7B,wBAAe,CAAC,aACd,KAAK,KAAK,aAAa,QAAQ;AAEjC,mBAAU,MAA4B,KAAK,KAAK,QAAQ;A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3B,SAAK,OAAO,IAAI,iBAAmB,MAAM,EAAE,YAAY,GAAG,OAAO,GAAG,MAAM,KAAK,CAAC;AAChF,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,MAAgC;AAEvD,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,MAAgC;AAC5D,WAAO,KAAK,MAAM,KAAK,IAAI;AAAA,EAC7B;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,KAAK;AAAA,EACd;AA6FF;",
6
6
  "names": []
7
7
  }
package/dist/cjs/Node.js CHANGED
@@ -39,7 +39,7 @@ class Node {
39
39
  // INTERNAL METHODS
40
40
  // ===========================================================================
41
41
  this.fixChildIndexes = () => {
42
- for (let i = 0; i < this.children.length; i++) {
42
+ for (let i = 0; i < this.children.length; i += 1) {
43
43
  this.children[i].childIndex = i;
44
44
  }
45
45
  this._hash += 1;
@@ -100,7 +100,7 @@ class Node {
100
100
  this.getPathIds = (id) => this.getPath(id).map((node) => node.dsId);
101
101
  this.getJson = () => ({
102
102
  ...this.plainItem,
103
- subitems: this.children.map((child) => child.getJson())
103
+ subitems: this.children?.map?.((child) => child.getJson()) ?? void 0
104
104
  });
105
105
  // ===========================================================================
106
106
  // WRITE METHODS
@@ -128,16 +128,22 @@ class Node {
128
128
  });
129
129
  this._hash += 1;
130
130
  };
131
- this.dsId = tree.getUniqueId(item);
131
+ const itemCasted = item;
132
+ this.dsId = tree.getUniqueId(itemCasted);
132
133
  this.childIndex = childIndex;
133
134
  this.depth = depth;
134
135
  this.parent = parent ?? null;
135
136
  this.tree = tree;
136
137
  this._hash = 0;
137
138
  this.children = item.subitems?.map(
138
- (subitem, index) => new Node(subitem, { childIndex: index, depth: depth + 1, parent: this, tree })
139
+ (subitem, index) => new Node(subitem, {
140
+ childIndex: index,
141
+ depth: depth + 1,
142
+ parent: this,
143
+ tree
144
+ })
139
145
  ) ?? [];
140
- this.plainItem = this.getCleanItem(item);
146
+ this.plainItem = this.getCleanItem(itemCasted);
141
147
  }
142
148
  // ===========================================================================
143
149
  // READ METHODS
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Node.ts", "../../../../../scripts/build/transpile/react-shim.js"],
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;AAC5B,WAAK,KAAK,CAAC,SAAS;AAElB,YAAI,MAAO,QAAO;AAGlB,YAAI,SAAS,IAAI,EAAG,SAAQ;AAC5B,eAAO,CAAC;AAAA,MACV,CAAC;AAED,aAAO;AAAA,IACT;AAEA,wBAAe,CAAC,aAAoD;AAClE,YAAM,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AAM,mCAAmC,KAAK,IAAI,EAAE;AAGhF,WAAK,OAAO,SAAS,OAAO,KAAK,YAAY,CAAC;AAG9C,WAAK,OAAO,gBAAgB;AAG5B,WAAK,KAAK,CAAC,UAAU;AACnB,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;",
4
+ "sourcesContent": ["/* eslint-disable no-underscore-dangle */\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 { NodeConstructorOptions, AnyObjectWithoutReservedKeys, JSONThatCanContrusctATree, Item } from './types.js';\n\nexport class Node<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> {\n dsId: string | number;\n\n childIndex: number;\n\n depth: number;\n\n plainItem: Omit<Item<AppInterface>, 'subitems'>;\n\n parent: Node<AppInterface> | null;\n\n children: Node<AppInterface>[];\n\n private tree!: DSTree<AppInterface>;\n\n private _hash: number;\n\n constructor(\n item: JSONThatCanContrusctATree<AppInterface>,\n { childIndex, depth, parent, tree }: NodeConstructorOptions<AppInterface>,\n ) {\n const itemCasted = item as Item<AppInterface>;\n this.dsId = tree.getUniqueId(itemCasted);\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) =>\n new Node<AppInterface>(subitem, {\n childIndex: index,\n depth: depth + 1,\n parent: this,\n tree,\n }),\n ) ?? ([] as Node<AppInterface>[]);\n\n // Save the item without the subitems\n this.plainItem = this.getCleanItem(itemCasted);\n }\n\n // ===========================================================================\n // INTERNAL METHODS\n // ===========================================================================\n\n fixChildIndexes = (): void => {\n for (let i = 0; i < this.children.length; i += 1) {\n this.children[i].childIndex = i;\n }\n this._hash += 1;\n };\n\n getCleanItem = (item: Item<AppInterface>): Omit<Item<AppInterface>, 'subitems'> => {\n const plainItem = omit(item, ['subitems']);\n return cloneDeep(plainItem);\n };\n\n // ===========================================================================\n // READ METHODS\n // ===========================================================================\n\n get hash(): number {\n return this._hash;\n }\n\n walk = (callback: (node: Node<AppInterface>) => boolean): void => {\n const shouldContinueWalking = callback(this);\n if (shouldContinueWalking) {\n // eslint-disable-next-line no-restricted-syntax\n for (const child of this.children) {\n child.walk(callback);\n }\n }\n };\n\n walkParents = (callback: (node: Node<AppInterface>) => 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<AppInterface>) => boolean): Node<AppInterface> | null => {\n // find first node using walk\n let found: Node<AppInterface> | 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<AppInterface>) => boolean): Node<AppInterface>[] => {\n const found: Node<AppInterface>[] = [];\n this.walk((node) => {\n if (callback(node)) found.push(node);\n return true;\n });\n return found;\n };\n\n flatten = (): Node<AppInterface>[] => {\n const flattened: Node<AppInterface>[] = [];\n this.walk((node) => {\n flattened.push(node);\n return true;\n });\n return flattened;\n };\n\n getPath = (id: string | number): Node<AppInterface>[] => {\n const path: Node<AppInterface>[] = [];\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 = (): JSONThatCanContrusctATree<AppInterface> =>\n ({\n ...this.plainItem,\n subitems: this.children?.map?.((child) => child.getJson()) ?? undefined,\n }) as JSONThatCanContrusctATree<AppInterface>;\n\n // ===========================================================================\n // WRITE METHODS\n // ===========================================================================\n\n addNode = (node: Node<AppInterface>) => {\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;ADGvB,oBAAgC;AAIzB,MAAM,KAAkF;AAAA,EAiB7F,YACE,MACA,EAAE,YAAY,OAAO,QAAQ,KAAK,GAClC;AA4BF;AAAA;AAAA;AAAA,2BAAkB,MAAY;AAC5B,eAAS,IAAI,GAAG,IAAI,KAAK,SAAS,QAAQ,KAAK,GAAG;AAChD,aAAK,SAAS,CAAC,EAAE,aAAa;AAAA,MAChC;A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R;AAAA,MACF,CAAC;AAAA,IACL,KAAM,CAAC;AAGT,SAAK,YAAY,KAAK,aAAa,UAAU;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAsBA,IAAI,OAAe;AACjB,WAAO,KAAK;AAAA,EACd;AAmHF;",
6
6
  "names": []
7
7
  }
@@ -63,7 +63,7 @@ const fromDSTreeToTreeishArray = (args) => {
63
63
  `Unable to find parent node with id ${parents[0]}, have you provided the correct getUniqueId function?`
64
64
  );
65
65
  let parentChildrenKey = getChildrenKey(parent);
66
- for (let i = 1; i < parents.length; i++) {
66
+ for (let i = 1; i < parents.length; i += 1) {
67
67
  const childrens = parent[parentChildrenKey];
68
68
  if (!childrens)
69
69
  throw new Error(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/adapters/arraish-tree/fromDSTreeToTreeishArray.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
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,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;",
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 += 1) {\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,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,GAAG;AAG1C,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
  }
@@ -34,8 +34,8 @@ module.exports = __toCommonJS(fromTreeishArrayToDSTree_exports);
34
34
  var React = __toESM(require("react"));
35
35
  var import_DSTree = require("../../DSTree.js");
36
36
  const unsecureUuid = () => "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
37
- const r = Math.random() * 16 | 0;
38
- const v = c == "x" ? r : r & 3 | 8;
37
+ const r = Math.random() * 16 || 0;
38
+ const v = c === "x" ? r : r & 3 || 8;
39
39
  return v.toString(16);
40
40
  });
41
41
  const walkTreeish = ({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/adapters/arraish-tree/fromTreeishArrayToDSTree.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
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,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,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;",
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 // eslint-disable-next-line no-bitwise\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 // @ts-expect-error this is an extremely opinionated algorithm that was built as a one-off, we are not spending time to make it typesafe\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 // @ts-expect-error this is an extremely opinionated algorithm that was built as a one-off, we are not spending time to make it typesafe\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 // @ts-expect-error this is an extremely opinionated algorithm that was built as a one-off, we are not spending time to make it typesafe\n return new DSTree<OverloadedItem<T>>(pseudoRoot, { getUniqueId: overloadedG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c,eAAe,gBAAgB;AACnD,mBAAe,KAAK,YAAY,gBAAgB;AAChD,mBAAe,WAAW,iBAAiB,WAAW;AACtD,WAAO,iBAAiB,WAAW;AACnC,mBAAe,mBAAmB;AAAA,EACpC;AAGA,cAA+B,EAAE,UAAU,MAAM,YAAY,MAAM,EAAE,aAAa,sBAAsB,EAAE,CAAC;AAI3G,SAAO,IAAI,qBAA0B,YAAY,EAAE,aAAa,sBAAsB,CAAC;AACzF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/react-desc-prop-types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import type { AddOptions, MoveOptions, MutateOptions, RemoveOptions } from './types.js';\nimport type { Node } from './Node.js';\nimport { PropTypes, type ValidationMap } from '@elliemae/ds-props-helpers';\n\nexport declare namespace UseDSTreeT {\n // First Parameter\n export interface FirstParameterRequired {\n dsId: string | number;\n }\n export interface FirstParameterDefault {\n label: string;\n [key: string]: unknown;\n }\n export interface FirstParameterOptional {\n subitems?: FirstParameter[];\n }\n export interface FirstParameter\n extends Partial<FirstParameterDefault>,\n FirstParameterOptional,\n FirstParameterRequired {}\n export interface FirstParameterInternals\n extends FirstParameterDefault,\n FirstParameterOptional,\n FirstParameterRequired {}\n\n // Second Parameter\n export interface SecondParameterRequired {\n getUniqueId: (item: FirstParameter) => string | number;\n }\n export interface SecondParameterDefault {}\n export interface SecondParameterOptional {}\n export interface SecondParameter\n extends Partial<SecondParameterDefault>,\n SecondParameterOptional,\n SecondParameterRequired {}\n export interface SecondParameterInternals\n extends SecondParameterDefault,\n SecondParameterOptional,\n SecondParameterRequired {}\n\n export interface OutputT {\n hash: number;\n getRoot: () => Node<FirstParameter>;\n getNode: (id: string | number) => Node<FirstParameter>;\n walk: (callback: (node: Node<FirstParameter>) => boolean) => void;\n walkParents: (callback: (node: Node<FirstParameter>) => boolean) => void;\n findNode: (callback: (node: Node<FirstParameter>) => boolean) => Node<FirstParameter> | null;\n findAllNodes: (callback: (node: Node<FirstParameter>) => boolean) => Node<FirstParameter>[];\n flatten: () => Node<FirstParameter>[];\n addNode: (item: FirstParameter, options?: AddOptions<FirstParameter> | undefined) => Node<FirstParameter>;\n removeNode: (id: string, options?: RemoveOptions<FirstParameter> | undefined) => Node<FirstParameter>;\n moveNode: (id: string, options?: MoveOptions<FirstParameter> | undefined) => Node<FirstParameter>;\n replaceNode: (\n id: string,\n item: FirstParameter,\n options?: MutateOptions<FirstParameter> | undefined,\n ) => Node<FirstParameter>;\n getPath: (id: string | number) => Node<FirstParameter>[];\n getPathIds: (id: string | number) => (string | number)[];\n }\n}\n\nconst itemShape = {\n dsId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('Id of the root item.'),\n label: PropTypes.string.description('Item label.'),\n '[key]': PropTypes.string.description('Any custom key you want to add to the item.'),\n};\n\nexport const UseDSTreePropTypes = {\n rootItem: PropTypes.shape({\n ...itemShape,\n subitems: PropTypes.arrayOf(PropTypes.shape(itemShape)).description(\n 'Array of subitems. Each subitem can also have subitems.',\n ),\n }).description('First parameter.').isRequired,\n opts: PropTypes.shape({\n getUniqueId: PropTypes.func\n .signature('(item) => string | number')\n .description('Callback to get the id of each item.').isRequired,\n }).description('Second parameter.').isRequired,\n} as ValidationMap<unknown>;\n\nexport const UseDSTreeReturnType = {\n hash: PropTypes.number.description('Tree hash value.'),\n getRoot: PropTypes.func.signature('() => rootItem').description('Callback to get the root item.'),\n getNode: PropTypes.func.signature('(id: string | number) => item').description('Callback to get an item by id.'),\n walk: PropTypes.func\n .signature('(callback: (item: FirstParameter) => boolean) => void')\n .description('Callback applied to each item to determine whether to continue walking or not.'),\n walkParents: PropTypes.func\n .signature('(callback: (item: FirstParameter) => boolean) => void')\n .description(\"Callback applied to each item to determine whether to continue walking the item's parents or not.\"),\n findNode: PropTypes.func\n .signature('(callback: (item: FirstParameter) => boolean) => FirstParameter | null')\n .description('Callback to find an item that matches the condition.'),\n findAllNodes: PropTypes.func\n .signature('(callback: (item: FirstParameter) => boolean) => FirstParameter[]')\n .description('Callback to find all the items that matches the condition.'),\n flatten: PropTypes.func.signature('() => item[]').description('Returns an array of hte tree items.'),\n addNode: PropTypes.func\n .signature('(item: FirstParameter, options?: AddOptions<FirstParameter> | undefined) => FirstParameter')\n .description('Adds an item to the tree.'),\n removeNode: PropTypes.func\n .signature('(id: string, options?: RemoveOptions<FirstParameter> | undefined) => FirstParameter')\n .description('Removes an item from the tree.'),\n moveNode: PropTypes.func\n .signature('(id: string, options?: MoveOptions<FirstParameter> | undefined) => FirstParameter')\n .description('Move an item within the tree.'),\n replaceNode: PropTypes.func\n .signature(\n 'id: string, item: FirstParameter, options?: MutateOptions<FirstParameter> | undefined) => FirstParameter',\n )\n .description('Replace a noe within the tree.'),\n getPath: PropTypes.func\n .signature('(id: string | number) => FirstParameter[]')\n .description(\"Get the path to an item given the item's id.\"),\n getPathIds: PropTypes.func\n .signature('(id: string | number) => (string | number)[]')\n .description(\"Get the path ids to an item given the item's id.\"),\n} as ValidationMap<unknown>;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,8BAA8C;AA4D9C,MAAM,YAAY;AAAA,EAChB,MAAM,kCAAU,UAAU,CAAC,kCAAU,QAAQ,kCAAU,MAAM,CAAC,EAAE,YAAY,sBAAsB;AAAA,EAClG,OAAO,kCAAU,OAAO,YAAY,aAAa;AAAA,EACjD,SAAS,kCAAU,OAAO,YAAY,6CAA6C;AACrF;AAEO,MAAM,qBAAqB;AAAA,EAChC,UAAU,kCAAU,MAAM;AAAA,IACxB,GAAG;AAAA,IACH,UAAU,kCAAU,QAAQ,kCAAU,MAAM,SAAS,CAAC,EAAE;AAAA,MACtD;AAAA,IACF;AAAA,EACF,CAAC,EAAE,YAAY,kBAAkB,EAAE;AAAA,EACnC,MAAM,kCAAU,MAAM;AAAA,IACpB,aAAa,kCAAU,KACpB,UAAU,2BAA2B,EACrC,YAAY,sCAAsC,EAAE;AAAA,EACzD,CAAC,EAAE,YAAY,mBAAmB,EAAE;AACtC;AAEO,MAAM,sBAAsB;AAAA,EACjC,MAAM,kCAAU,OAAO,YAAY,kBAAkB;AAAA,EACrD,SAAS,kCAAU,KAAK,UAAU,gBAAgB,EAAE,YAAY,gCAAgC;AAAA,EAChG,SAAS,kCAAU,KAAK,UAAU,+BAA+B,EAAE,YAAY,gCAAgC;AAAA,EAC/G,MAAM,kCAAU,KACb,UAAU,uDAAuD,EACjE,YAAY,gFAAgF;AAAA,EAC/F,aAAa,kCAAU,KACpB,UAAU,uDAAuD,EACjE,YAAY,mGAAmG;AAAA,EAClH,UAAU,kCAAU,KACjB,UAAU,wEAAwE,EAClF,YAAY,sDAAsD;AAAA,EACrE,cAAc,kCAAU,KACrB,UAAU,mEAAmE,EAC7E,YAAY,4DAA4D;AAAA,EAC3E,SAAS,kCAAU,KAAK,UAAU,cAAc,EAAE,YAAY,qCAAqC;AAAA,EACnG,SAAS,kCAAU,KAChB,UAAU,4FAA4F,EACtG,YAAY,2BAA2B;AAAA,EAC1C,YAAY,kCAAU,KACnB,UAAU,qFAAqF,EAC/F,YAAY,gCAAgC;AAAA,EAC/C,UAAU,kCAAU,KACjB,UAAU,mFAAmF,EAC7F,YAAY,+BAA+B;AAAA,EAC9C,aAAa,kCAAU,KACpB;AAAA,IACC;AAAA,EACF,EACC,YAAY,gCAAgC;AAAA,EAC/C,SAAS,kCAAU,KAChB,UAAU,2CAA2C,EACrD,YAAY,8CAA8C;AAAA,EAC7D,YAAY,kCAAU,KACnB,UAAU,8CAA8C,EACxD,YAAY,kDAAkD;AACnE;",
4
+ "sourcesContent": ["import { PropTypes, type ValidationMap } from '@elliemae/ds-props-helpers';\nimport type { Node } from './Node.js';\nimport type {\n AddOptions,\n MoveOptions,\n MutateOptions,\n RemoveOptions,\n Item,\n AnyObjectWithoutReservedKeys,\n JSONThatCanContrusctATree,\n} from './types.js';\n\nexport declare namespace UseDSTreeT {\n export type TreeNode<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> =\n Node<AppInterface>;\n export type TreeItem<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> =\n Item<AppInterface>;\n export type FirstParameter<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> =\n TreeItem<AppInterface>;\n\n export type SecondParameter<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> = {\n getUniqueId: (item: TreeItem<AppInterface>) => string | number;\n };\n\n export interface OutputT<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> {\n hash: number;\n getRoot: () => Node<AppInterface>;\n getNode: (id: string | number) => Node<AppInterface>;\n walk: (callback: (node: Node<AppInterface>) => boolean) => void;\n walkParents: (callback: (node: Node<AppInterface>) => boolean) => void;\n findNode: (callback: (node: Node<AppInterface>) => boolean) => Node<AppInterface> | null;\n findAllNodes: (callback: (node: Node<AppInterface>) => boolean) => Node<AppInterface>[];\n flatten: () => Node<AppInterface>[];\n addNode: (item: JSONThatCanContrusctATree<AppInterface>, options?: AddOptions<AppInterface>) => Node<AppInterface>;\n removeNode: (id: string | number, options?: RemoveOptions<AppInterface>) => Node<AppInterface>;\n moveNode: (id: string | number, options?: MoveOptions<AppInterface>) => Node<AppInterface>;\n replaceNode: (\n id: string | number,\n item: JSONThatCanContrusctATree<AppInterface>,\n options?: MutateOptions<AppInterface>,\n ) => Node<AppInterface>;\n getPath: (id: string | number) => Node<AppInterface>[];\n getPathIds: (id: string | number) => (string | number)[];\n }\n}\n\nconst itemShape = {\n dsId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('Id of the root item.'),\n label: PropTypes.string.description('Item label.'),\n '[key]': PropTypes.string.description('Any custom key you want to add to the item.'),\n};\n\nexport const UseDSTreePropTypes = {\n rootItem: PropTypes.shape({\n ...itemShape,\n subitems: PropTypes.arrayOf(PropTypes.shape(itemShape)).description(\n 'Array of subitems. Each subitem can also have subitems.',\n ),\n }).description('First parameter.').isRequired,\n opts: PropTypes.shape({\n getUniqueId: PropTypes.func\n .signature('(item) => string | number')\n .description('Callback to get the id of each item.').isRequired,\n }).description('Second parameter.').isRequired,\n} as ValidationMap<unknown>;\n\nexport const UseDSTreeReturnType = {\n hash: PropTypes.number.description('Tree hash value.'),\n getRoot: PropTypes.func.signature('() => rootItem').description('Callback to get the root item.'),\n getNode: PropTypes.func.signature('(id: string | number) => item').description('Callback to get an item by id.'),\n walk: PropTypes.func\n .signature('(callback: (item: FirstParameter) => boolean) => void')\n .description('Callback applied to each item to determine whether to continue walking or not.'),\n walkParents: PropTypes.func\n .signature('(callback: (item: FirstParameter) => boolean) => void')\n .description(\"Callback applied to each item to determine whether to continue walking the item's parents or not.\"),\n findNode: PropTypes.func\n .signature('(callback: (item: FirstParameter) => boolean) => FirstParameter | null')\n .description('Callback to find an item that matches the condition.'),\n findAllNodes: PropTypes.func\n .signature('(callback: (item: FirstParameter) => boolean) => FirstParameter[]')\n .description('Callback to find all the items that matches the condition.'),\n flatten: PropTypes.func.signature('() => item[]').description('Returns an array of hte tree items.'),\n addNode: PropTypes.func\n .signature('(item: FirstParameter, options?: AddOptions<FirstParameter> | undefined) => FirstParameter')\n .description('Adds an item to the tree.'),\n removeNode: PropTypes.func\n .signature('(id: string, options?: RemoveOptions<FirstParameter> | undefined) => FirstParameter')\n .description('Removes an item from the tree.'),\n moveNode: PropTypes.func\n .signature('(id: string, options?: MoveOptions<FirstParameter> | undefined) => FirstParameter')\n .description('Move an item within the tree.'),\n replaceNode: PropTypes.func\n .signature(\n 'id: string, item: FirstParameter, options?: MutateOptions<FirstParameter> | undefined) => FirstParameter',\n )\n .description('Replace a noe within the tree.'),\n getPath: PropTypes.func\n .signature('(id: string | number) => FirstParameter[]')\n .description(\"Get the path to an item given the item's id.\"),\n getPathIds: PropTypes.func\n .signature('(id: string | number) => (string | number)[]')\n .description(\"Get the path ids to an item given the item's id.\"),\n} as ValidationMap<unknown>;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAA8C;AA8C9C,MAAM,YAAY;AAAA,EAChB,MAAM,kCAAU,UAAU,CAAC,kCAAU,QAAQ,kCAAU,MAAM,CAAC,EAAE,YAAY,sBAAsB;AAAA,EAClG,OAAO,kCAAU,OAAO,YAAY,aAAa;AAAA,EACjD,SAAS,kCAAU,OAAO,YAAY,6CAA6C;AACrF;AAEO,MAAM,qBAAqB;AAAA,EAChC,UAAU,kCAAU,MAAM;AAAA,IACxB,GAAG;AAAA,IACH,UAAU,kCAAU,QAAQ,kCAAU,MAAM,SAAS,CAAC,EAAE;AAAA,MACtD;AAAA,IACF;AAAA,EACF,CAAC,EAAE,YAAY,kBAAkB,EAAE;AAAA,EACnC,MAAM,kCAAU,MAAM;AAAA,IACpB,aAAa,kCAAU,KACpB,UAAU,2BAA2B,EACrC,YAAY,sCAAsC,EAAE;AAAA,EACzD,CAAC,EAAE,YAAY,mBAAmB,EAAE;AACtC;AAEO,MAAM,sBAAsB;AAAA,EACjC,MAAM,kCAAU,OAAO,YAAY,kBAAkB;AAAA,EACrD,SAAS,kCAAU,KAAK,UAAU,gBAAgB,EAAE,YAAY,gCAAgC;AAAA,EAChG,SAAS,kCAAU,KAAK,UAAU,+BAA+B,EAAE,YAAY,gCAAgC;AAAA,EAC/G,MAAM,kCAAU,KACb,UAAU,uDAAuD,EACjE,YAAY,gFAAgF;AAAA,EAC/F,aAAa,kCAAU,KACpB,UAAU,uDAAuD,EACjE,YAAY,mGAAmG;AAAA,EAClH,UAAU,kCAAU,KACjB,UAAU,wEAAwE,EAClF,YAAY,sDAAsD;AAAA,EACrE,cAAc,kCAAU,KACrB,UAAU,mEAAmE,EAC7E,YAAY,4DAA4D;AAAA,EAC3E,SAAS,kCAAU,KAAK,UAAU,cAAc,EAAE,YAAY,qCAAqC;AAAA,EACnG,SAAS,kCAAU,KAChB,UAAU,4FAA4F,EACtG,YAAY,2BAA2B;AAAA,EAC1C,YAAY,kCAAU,KACnB,UAAU,qFAAqF,EAC/F,YAAY,gCAAgC;AAAA,EAC/C,UAAU,kCAAU,KACjB,UAAU,mFAAmF,EAC7F,YAAY,+BAA+B;AAAA,EAC9C,aAAa,kCAAU,KACpB;AAAA,IACC;AAAA,EACF,EACC,YAAY,gCAAgC;AAAA,EAC/C,SAAS,kCAAU,KAChB,UAAU,2CAA2C,EACrD,YAAY,8CAA8C;AAAA,EAC7D,YAAY,kCAAU,KACnB,UAAU,8CAA8C,EACxD,YAAY,kDAAkD;AACnE;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import type { DSTree } from './DSTree.js';\nimport type { Node } from './Node.js';\n\nexport interface Item {\n subitems?: Item[];\n [key: string]: unknown;\n}\n\nexport interface NodeConstructorOptions<T extends Item> {\n childIndex: number;\n depth: number;\n tree: DSTree<T>;\n parent?: Node<T> | null;\n}\n\nexport interface AddOptions<T extends Item> {\n position?: number;\n parent?: Node<T> | null;\n callback?: (node: Node<T>, tree: DSTree<T>) => void;\n}\n\nexport interface RemoveOptions<T extends Item> {\n callback?: (node: Node<T>, tree: DSTree<T>) => void;\n}\n\nexport interface MoveOptions<T extends Item> {\n position?: number;\n parent?: Node<T>;\n callback?: (node: Node<T>, tree: DSTree<T>) => void;\n}\n\nexport interface MutateOptions<T extends Item> {\n callback?: (node: Node<T>, tree: DSTree<T>) => void;\n}\nexport interface OverloadedItem<T extends object = object> extends Item {\n id: string;\n subitems: OverloadedItem<T>[];\n originalNodeData: T;\n}\n", "import * as React from 'react';\nexport { React };\n"],
4
+ "sourcesContent": ["import type { DSTree } from './DSTree.js';\nimport type { Node } from './Node.js';\n\nexport type AnyObjectWithoutReservedKeys = Omit<Record<string, unknown>, 'dsId' | 'subitems'>;\nexport type JSONThatCanContrusctATree<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> =\n AppInterface & {\n dsId: string | number;\n subitems?: JSONThatCanContrusctATree<AppInterface>[] | ReadonlyArray<JSONThatCanContrusctATree<AppInterface>>;\n };\n\nexport type Item<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> = Omit<\n AppInterface,\n 'dsId' | 'subitems'\n> & {\n dsId: string | number;\n subitems?: Item<AppInterface>[] | ReadonlyArray<Item<AppInterface>>;\n};\n\nexport interface NodeConstructorOptions<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> {\n childIndex: number;\n depth: number;\n tree: DSTree<AppInterface>;\n parent?: Node<AppInterface> | null;\n}\n\nexport interface AddOptions<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> {\n position?: number;\n parent?: Node<AppInterface> | null;\n callback?: (node: Node<AppInterface>, tree: DSTree<AppInterface>) => void;\n}\n\nexport interface RemoveOptions<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> {\n callback?: (node: Node<AppInterface>, tree: DSTree<AppInterface>) => void;\n}\n\nexport interface MoveOptions<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> {\n position?: number;\n parent?: Node<AppInterface>;\n callback?: (node: Node<AppInterface>, tree: DSTree<AppInterface>) => void;\n}\n\nexport interface MutateOptions<AppInterface extends AnyObjectWithoutReservedKeys = Record<string, unknown>> {\n callback?: (node: Node<AppInterface>, tree: DSTree<AppInterface>) => void;\n}\nexport interface OverloadedItem<AppTypedItem extends object = object> extends Item {\n id: string;\n subitems: OverloadedItem<AppTypedItem>[] | ReadonlyArray<OverloadedItem<AppTypedItem>>;\n originalNodeData: AppTypedItem;\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
6
6
  "names": []
7
7
  }
@@ -22,7 +22,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
  var React = __toESM(require("react"));
25
- var import_jsx_runtime = require("react/jsx-runtime");
26
25
  var import_useArraishAsDSTree = require("../adapters/arraish-tree/useArraishAsDSTree.js");
27
26
  const testRequiredPropsFirstParameter = {};
28
27
  const testRequiredPropsSecondParameter = {
@@ -139,6 +138,6 @@ const ExampleUsageComponent = () => {
139
138
  [testInferedTypeCompatibilityFirstParameter],
140
139
  testInferedTypeCompatibilitySecondParameter
141
140
  );
142
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
141
+ return null;
143
142
  };
144
143
  //# sourceMappingURL=typescript-use-arraish-as-ds-tree-valid.js.map
@@ -1,7 +1,7 @@
1
1
  {
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
- "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,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,MAAM,kCAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,qCAA2E,CAAC;AAElF,MAAM,2BAAkD;AAAA,EACtD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,mCAAmC;AAAA,EACvC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,qCAA2E;AAAA,EAC/E,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AACR;AAEA,MAAM,kCAA2D;AAAA,EAC/D,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,0CAA0C;AAAA,EAC9C,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,sCAA6E,CAAC;AAEpF,MAAM,mCAA6D;AAAA,EACjE,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,2CAA2C;AAAA,EAC/C,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,uCAA6D;AAAA,EACjE,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AACX;AAEA,MAAM,wCAA+D;AAAA,EACnE,aAAa,CAAC,SAAS,KAAK;AAAA,EAC5B,gBAAgB,CAAC,SAAS,WAAW,KAAK,EAAE;AAC9C;AAGA,MAAM,6CAA6C;AAAA,EACjD,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AACX;AAEA,MAAM,8CAA8C;AAAA,EAClD,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,QAAI,8CAAmB,CAAC,oCAAoC,GAAG,qCAAqC;AAEpG,QAAM,cAAU;AAAA,IACd,CAAC,0CAA0C;AAAA,IAC3C;AAAA,EACF;AAEA,SAAO,2EAAE;AACX;",
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 null;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACCvB,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,MAAM,kCAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,qCAA2E,CAAC;AAElF,MAAM,2BAAkD;AAAA,EACtD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;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C,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;AACT;",
6
6
  "names": []
7
7
  }
@@ -22,85 +22,35 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
  var React = __toESM(require("react"));
25
- var import_jsx_runtime = require("react/jsx-runtime");
26
25
  var import__ = require("../index.js");
27
- const testRequiredPropsFirstParameter = {
28
- dsId: ""
29
- };
30
- const testRequiredPropsSecondParameter = {
31
- getUniqueId: (item) => item.dsId
32
- };
33
- const testOptionalPropsFirstParameter = {
34
- subitems: [{ dsId: "_root", label: "root", subitems: [] }]
35
- };
36
- const testOptionalPropsSecondParameter = {};
37
- const testPartialDefaultsFirstParameter = {
38
- label: "root"
39
- };
40
- const testPropsFirstParameter = {
41
- ...testRequiredPropsFirstParameter,
42
- ...testOptionalPropsFirstParameter,
43
- ...testPartialDefaultsFirstParameter
44
- };
45
- const testPropsAsSyntaxFirstParameter = {
46
- ...testRequiredPropsFirstParameter,
47
- ...testOptionalPropsFirstParameter,
48
- ...testPartialDefaultsFirstParameter
49
- };
50
- const testPartialDefaultsSecondParameter = {};
51
- const testPropsSecondParameter = {
52
- ...testRequiredPropsSecondParameter,
53
- ...testOptionalPropsSecondParameter,
54
- ...testPartialDefaultsSecondParameter
55
- };
56
- const testPropsAsSyntaxSecondParameter = {
57
- ...testRequiredPropsSecondParameter,
58
- ...testOptionalPropsSecondParameter,
59
- ...testPartialDefaultsSecondParameter
60
- };
61
- const testCompleteDefaultsFirstParameter = {
62
- label: "root"
63
- };
64
- const testInternalPropsFirstParameter = {
65
- ...testRequiredPropsFirstParameter,
66
- ...testOptionalPropsFirstParameter,
67
- ...testCompleteDefaultsFirstParameter
68
- };
69
- const testInternalPropsAsSyntaxFirstParameter = {
70
- ...testRequiredPropsFirstParameter,
71
- ...testOptionalPropsFirstParameter,
72
- ...testCompleteDefaultsFirstParameter
73
- };
74
- const testCompleteDefaultsSecondParameter = {};
75
- const testInternalPropsSecondParameter = {
76
- ...testRequiredPropsSecondParameter,
77
- ...testOptionalPropsSecondParameter,
78
- ...testCompleteDefaultsSecondParameter
79
- };
80
- const testInternalPropsAsSyntaxSecondParameter = {
81
- ...testRequiredPropsSecondParameter,
82
- ...testOptionalPropsSecondParameter,
83
- ...testCompleteDefaultsSecondParameter
26
+ const testPropsInferedFirstParameter = {
27
+ dsId: "_root",
28
+ zipcode: 4444,
29
+ subitems: [{ dsId: "sub_item_id1", zipcode: 4444 }]
84
30
  };
85
31
  const testExplicitDefinitionFirstParameter = {
86
32
  dsId: "_root",
87
- label: "root",
88
- subitems: [{ dsId: "sub_item_id1", label: "sub_item_1" }]
33
+ zipcode: 4444,
34
+ subitems: [{ dsId: "sub_item_id1", zipcode: 4444 }]
89
35
  };
90
- const testExplicitDefinitionSecondParameter = {
91
- getUniqueId: (item) => item.dsId
36
+ const testExplicitAsDefinitionFirstParameter = {
37
+ dsId: "_root",
38
+ zipcode: 4444,
39
+ subitems: [{ dsId: "sub_item_id1", zipcode: 4444, createdAt: "2021-01-01", likesIceCream: true }]
92
40
  };
93
- const testInferedTypeCompatibilityFirstParameter = {
41
+ const testDefinitionAsConstFirstParameter = {
94
42
  dsId: "_root",
95
- label: "root",
96
- subitems: [{ dsId: "sub_item_id1", label: "sub_item_1" }]
43
+ zipcode: 4444,
44
+ subitems: [{ dsId: "sub_item_id1", zipcode: 4444 }]
97
45
  };
98
- const testInferedTypeCompatibilitySecondParameter = {
46
+ const testPropsInferedSecondParameter = {
99
47
  getUniqueId: (item) => item.dsId
100
48
  };
101
- const testDefinitionAsConstFirstParameter = {
102
- dsId: "_root",
103
- label: "root"
49
+ const testPropsExplicitSecondParameter = {
50
+ getUniqueId: (item) => item.dsId
51
+ };
52
+ const testPropsExplicitAsSecondParameter = {
53
+ getUniqueId: (item) => item.dsId
104
54
  };
105
55
  const testDefinitionAsConstSecondParameter = {
106
56
  getUniqueId: (item) => item.dsId
@@ -121,9 +71,26 @@ const ExampleUsageComponent = () => {
121
71
  replaceNode,
122
72
  walk,
123
73
  walkParents
124
- } = (0, import__.useDSTree)(testExplicitDefinitionFirstParameter, testExplicitDefinitionSecondParameter);
125
- const output2 = (0, import__.useDSTree)(testInferedTypeCompatibilityFirstParameter, testInferedTypeCompatibilitySecondParameter);
126
- const output3 = (0, import__.useDSTree)(testDefinitionAsConstFirstParameter, testDefinitionAsConstSecondParameter);
127
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
74
+ } = (0, import__.useDSTree)(testExplicitDefinitionFirstParameter, testPropsExplicitSecondParameter);
75
+ addNode({ dsId: "sub_item_id2", zipcode: 4444 });
76
+ findAllNodes((node) => node.plainItem.zipcode === 4444);
77
+ findNode((node) => node.plainItem.zipcode === 4444);
78
+ const nodes = flatten();
79
+ const newlyAddedNode = getNode("sub_item_id2");
80
+ const path = getPath("sub_item_id2");
81
+ const pathIds = getPathIds("sub_item_id2");
82
+ const root = getRoot();
83
+ moveNode("sub_item_id1", { position: 0, parent: newlyAddedNode });
84
+ removeNode("sub_item_id1");
85
+ replaceNode("sub_item_id2", { dsId: "sub_item_id2", zipcode: 4433 });
86
+ walk((node) => node.plainItem.zipcode === 4433);
87
+ walkParents((node) => node.plainItem.zipcode === 4433);
88
+ const outputExplicitAs = (0, import__.useDSTree)(
89
+ testExplicitAsDefinitionFirstParameter,
90
+ testPropsExplicitAsSecondParameter
91
+ );
92
+ const outputConst = (0, import__.useDSTree)(testDefinitionAsConstFirstParameter, testDefinitionAsConstSecondParameter);
93
+ const outputInfered = (0, import__.useDSTree)(testPropsInferedFirstParameter, testPropsInferedSecondParameter);
94
+ return null;
128
95
  };
129
96
  //# sourceMappingURL=typescript-use-ds-tree-valid.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-use-ds-tree-valid.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { useDSTree } from '../index.js';\nimport type { UseDSTreeT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype FirstParameterForApp = UseDSTreeT.FirstParameter;\ntype FirstParameterInternals = UseDSTreeT.FirstParameterInternals;\ntype FirstParameterDefaultProps = UseDSTreeT.FirstParameterDefault;\ntype FirstParameterOptionalProps = UseDSTreeT.FirstParameterOptional;\ntype FirstParameterRequiredProps = UseDSTreeT.FirstParameterRequired;\n\ntype SecondParameterForApp = UseDSTreeT.SecondParameter;\ntype SecondParameterInternals = UseDSTreeT.SecondParameterInternals;\ntype SecondParameterDefaultProps = UseDSTreeT.SecondParameterDefault;\ntype SecondParameterOptionalProps = UseDSTreeT.SecondParameterOptional;\ntype SecondParameterRequiredProps = UseDSTreeT.SecondParameterRequired;\n\nconst testRequiredPropsFirstParameter: FirstParameterRequiredProps = {\n dsId: '',\n};\n\nconst testRequiredPropsSecondParameter: SecondParameterRequiredProps = {\n getUniqueId: (item) => item.dsId,\n};\n\nconst testOptionalPropsFirstParameter: FirstParameterOptionalProps = {\n subitems: [{ dsId: '_root', label: 'root', subitems: [] }],\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 label: 'root',\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 label: 'root',\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 dsId: '_root',\n label: 'root',\n subitems: [{ dsId: 'sub_item_id1', label: 'sub_item_1' }],\n};\n\nconst testExplicitDefinitionSecondParameter: SecondParameterForApp = {\n getUniqueId: (item) => item.dsId,\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 dsId: '_root',\n label: 'root',\n subitems: [{ dsId: 'sub_item_id1', label: 'sub_item_1' }],\n} as FirstParameterForApp;\n\nconst testInferedTypeCompatibilitySecondParameter = {\n getUniqueId: (item) => item.dsId,\n} as SecondParameterForApp;\n\nconst testDefinitionAsConstFirstParameter = {\n dsId: '_root',\n label: 'root',\n} as const;\n\nconst testDefinitionAsConstSecondParameter = {\n getUniqueId: (item: FirstParameterForApp) => item.dsId,\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 } = useDSTree(testExplicitDefinitionFirstParameter, testExplicitDefinitionSecondParameter);\n\n const output2 = useDSTree(testInferedTypeCompatibilityFirstParameter, testInferedTypeCompatibilitySecondParameter);\n\n const output3 = useDSTree(testDefinitionAsConstFirstParameter, testDefinitionAsConstSecondParameter);\n\n return <></>;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACmJd;AAlJT,eAA0B;AAgB1B,MAAM,kCAA+D;AAAA,EACnE,MAAM;AACR;AAEA,MAAM,mCAAiE;AAAA,EACrE,aAAa,CAAC,SAAS,KAAK;AAC9B;AAEA,MAAM,kCAA+D;AAAA,EACnE,UAAU,CAAC,EAAE,MAAM,SAAS,OAAO,QAAQ,UAAU,CAAC,EAAE,CAAC;AAC3D;AAEA,MAAM,mCAAiE,CAAC;AAIxE,MAAM,oCAAyE;AAAA,EAC7E,OAAO;AACT;AAEA,MAAM,0BAAgD;AAAA,EACpD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,kCAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA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AAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,oBAAU,sCAAsC,qCAAqC;AAEzF,QAAM,cAAU,oBAAU,4CAA4C,2CAA2C;AAEjH,QAAM,cAAU,oBAAU,qCAAqC,oCAAoC;AAEnG,SAAO,2EAAE;AACX;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { useDSTree } from '../index.js';\nimport type { UseDSTreeT } from '../index.js';\n\n// for the sake of this API, it's important that the app devs can pass their own interface for the item\ntype AppItemT = {\n zipcode: number;\n createdAt?: string;\n likesIceCream?: boolean;\n};\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype AppTypedItem = UseDSTreeT.TreeItem<AppItemT>;\n\nconst testPropsInferedFirstParameter = {\n dsId: '_root',\n zipcode: 4444,\n subitems: [{ dsId: 'sub_item_id1', zipcode: 4444 }],\n};\n\nconst testExplicitDefinitionFirstParameter: AppTypedItem = {\n dsId: '_root',\n zipcode: 4444,\n subitems: [{ dsId: 'sub_item_id1', zipcode: 4444 }],\n};\n\nconst testExplicitAsDefinitionFirstParameter = {\n dsId: '_root',\n zipcode: 4444,\n subitems: [{ dsId: 'sub_item_id1', zipcode: 4444, createdAt: '2021-01-01', likesIceCream: true }],\n} as AppTypedItem;\n\nconst testDefinitionAsConstFirstParameter = {\n dsId: '_root',\n zipcode: 4444,\n subitems: [{ dsId: 'sub_item_id1', zipcode: 4444 }],\n} as const;\n\nconst testPropsInferedSecondParameter = {\n getUniqueId: (item: AppTypedItem) => item.dsId,\n};\nconst testPropsExplicitSecondParameter: UseDSTreeT.SecondParameter<AppTypedItem> = {\n getUniqueId: (item) => item.dsId,\n};\n\nconst testPropsExplicitAsSecondParameter = {\n getUniqueId: (item: AppTypedItem) => item.dsId,\n} as UseDSTreeT.SecondParameter<AppTypedItem>;\n\nconst testDefinitionAsConstSecondParameter = {\n getUniqueId: (item: AppTypedItem) => item.dsId,\n} as const;\n\n// this is an helper to be able to check the type of the output of getPathIds\ntype IdsArrayTypeChecker = (string | number)[];\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 } = useDSTree<AppItemT>(testExplicitDefinitionFirstParameter, testPropsExplicitSecondParameter);\n addNode({ dsId: 'sub_item_id2', zipcode: 4444 });\n findAllNodes((node) => node.plainItem.zipcode === 4444);\n findNode((node) => node.plainItem.zipcode === 4444);\n const nodes = flatten() as UseDSTreeT.TreeNode<AppItemT>[];\n\n const newlyAddedNode = getNode('sub_item_id2') as UseDSTreeT.TreeNode<AppItemT>;\n const path = getPath('sub_item_id2') as UseDSTreeT.TreeNode<AppItemT>[];\n const pathIds = getPathIds('sub_item_id2') as IdsArrayTypeChecker;\n const root = getRoot() as UseDSTreeT.TreeNode<AppItemT>;\n moveNode('sub_item_id1', { position: 0, parent: newlyAddedNode });\n removeNode('sub_item_id1');\n replaceNode('sub_item_id2', { dsId: 'sub_item_id2', zipcode: 4433 });\n walk((node) => node.plainItem.zipcode === 4433);\n walkParents((node) => node.plainItem.zipcode === 4433);\n\n const outputExplicitAs = useDSTree<AppItemT>(\n testExplicitAsDefinitionFirstParameter,\n testPropsExplicitAsSecondParameter,\n );\n const outputConst = useDSTree<AppItemT>(testDefinitionAsConstFirstParameter, testDefinitionAsConstSecondParameter);\n\n const outputInfered = useDSTree<AppItemT>(testPropsInferedFirstParameter, testPropsInferedSecondParameter);\n\n return null;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACCvB,eAA0B;AAa1B,MAAM,iCAAiC;AAAA,EACrC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,EAAE,MAAM,gBAAgB,SAAS,KAAK,CAAC;AACpD;AAEA,MAAM,uCAAqD;AAAA,EACzD,MAAM;AAAA,EACN,SAAS;AAAA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M,gBAAgB,SAAS,KAAK,CAAC;AACnE,OAAK,CAAC,SAAS,KAAK,UAAU,YAAY,IAAI;AAC9C,cAAY,CAAC,SAAS,KAAK,UAAU,YAAY,IAAI;AAErD,QAAM,uBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACA,QAAM,kBAAc,oBAAoB,qCAAqC,oCAAoC;AAEjH,QAAM,oBAAgB,oBAAoB,gCAAgC,+BAA+B;AAEzG,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -33,10 +33,10 @@ __export(useDSTree_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(useDSTree_exports);
35
35
  var React = __toESM(require("react"));
36
+ var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
36
37
  var import_react = require("react");
37
38
  var import_DSTree = require("./DSTree.js");
38
39
  var import_react_desc_prop_types = require("./react-desc-prop-types.js");
39
- var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
40
40
  const useDSTree = (rootItem, opts) => {
41
41
  const tree = (0, import_react.useMemo)(() => new import_DSTree.DSTree(rootItem, opts), [opts, rootItem]);
42
42
  const [hash, setHash] = (0, import_react.useState)(tree.hash);