@fluentui/react-tree 9.0.0 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "@fluentui/react-tree",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 16 Aug 2023 17:38:22 GMT",
5
+ "date": "Thu, 17 Aug 2023 13:49:39 GMT",
6
+ "tag": "@fluentui/react-tree_v9.0.1",
7
+ "version": "9.0.1",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "bernardo.sunderhus@gmail.com",
12
+ "package": "@fluentui/react-tree",
13
+ "commit": "ccd513e9b7c3179bef3588d183be1e3e4b9d7f7d",
14
+ "comment": "bugfix: headless flat tree itemType manual definition"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Wed, 16 Aug 2023 17:41:08 GMT",
6
21
  "tag": "@fluentui/react-tree_v9.0.0",
7
22
  "version": "9.0.0",
8
23
  "comments": {
@@ -17,31 +32,31 @@
17
32
  "author": "beachball",
18
33
  "package": "@fluentui/react-tree",
19
34
  "comment": "Bump @fluentui/react-avatar to v9.5.21",
20
- "commit": "566f22496db20046fbc9ab898580ccf64600fb6b"
35
+ "commit": "b331b368030e157e0ff38a59c9d4aaf1d01d9b6a"
21
36
  },
22
37
  {
23
38
  "author": "beachball",
24
39
  "package": "@fluentui/react-tree",
25
40
  "comment": "Bump @fluentui/react-button to v9.3.31",
26
- "commit": "566f22496db20046fbc9ab898580ccf64600fb6b"
41
+ "commit": "b331b368030e157e0ff38a59c9d4aaf1d01d9b6a"
27
42
  },
28
43
  {
29
44
  "author": "beachball",
30
45
  "package": "@fluentui/react-tree",
31
46
  "comment": "Bump @fluentui/react-checkbox to v9.1.32",
32
- "commit": "566f22496db20046fbc9ab898580ccf64600fb6b"
47
+ "commit": "b331b368030e157e0ff38a59c9d4aaf1d01d9b6a"
33
48
  },
34
49
  {
35
50
  "author": "beachball",
36
51
  "package": "@fluentui/react-tree",
37
52
  "comment": "Bump @fluentui/react-radio to v9.1.32",
38
- "commit": "566f22496db20046fbc9ab898580ccf64600fb6b"
53
+ "commit": "b331b368030e157e0ff38a59c9d4aaf1d01d9b6a"
39
54
  },
40
55
  {
41
56
  "author": "beachball",
42
57
  "package": "@fluentui/react-tree",
43
58
  "comment": "Bump @fluentui/react-jsx-runtime to v9.0.0",
44
- "commit": "566f22496db20046fbc9ab898580ccf64600fb6b"
59
+ "commit": "b331b368030e157e0ff38a59c9d4aaf1d01d9b6a"
45
60
  }
46
61
  ]
47
62
  }
package/CHANGELOG.md CHANGED
@@ -1,22 +1,31 @@
1
1
  # Change Log - @fluentui/react-tree
2
2
 
3
- This log was last generated on Wed, 16 Aug 2023 17:38:22 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 17 Aug 2023 13:49:39 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-tree_v9.0.1)
8
+
9
+ Thu, 17 Aug 2023 13:49:39 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tree_v9.0.0..@fluentui/react-tree_v9.0.1)
11
+
12
+ ### Patches
13
+
14
+ - bugfix: headless flat tree itemType manual definition ([PR #28898](https://github.com/microsoft/fluentui/pull/28898) by bernardo.sunderhus@gmail.com)
15
+
7
16
  ## [9.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tree_v9.0.0)
8
17
 
9
- Wed, 16 Aug 2023 17:38:22 GMT
18
+ Wed, 16 Aug 2023 17:41:08 GMT
10
19
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tree_v9.0.0-beta.33..@fluentui/react-tree_v9.0.0)
11
20
 
12
21
  ### Patches
13
22
 
14
23
  - feat: stable release ([PR #28845](https://github.com/microsoft/fluentui/pull/28845) by bernardo.sunderhus@gmail.com)
15
- - Bump @fluentui/react-avatar to v9.5.21 ([PR #28845](https://github.com/microsoft/fluentui/pull/28845) by beachball)
16
- - Bump @fluentui/react-button to v9.3.31 ([PR #28845](https://github.com/microsoft/fluentui/pull/28845) by beachball)
17
- - Bump @fluentui/react-checkbox to v9.1.32 ([PR #28845](https://github.com/microsoft/fluentui/pull/28845) by beachball)
18
- - Bump @fluentui/react-radio to v9.1.32 ([PR #28845](https://github.com/microsoft/fluentui/pull/28845) by beachball)
19
- - Bump @fluentui/react-jsx-runtime to v9.0.0 ([PR #28845](https://github.com/microsoft/fluentui/pull/28845) by beachball)
24
+ - Bump @fluentui/react-avatar to v9.5.21 ([PR #28885](https://github.com/microsoft/fluentui/pull/28885) by beachball)
25
+ - Bump @fluentui/react-button to v9.3.31 ([PR #28885](https://github.com/microsoft/fluentui/pull/28885) by beachball)
26
+ - Bump @fluentui/react-checkbox to v9.1.32 ([PR #28885](https://github.com/microsoft/fluentui/pull/28885) by beachball)
27
+ - Bump @fluentui/react-radio to v9.1.32 ([PR #28885](https://github.com/microsoft/fluentui/pull/28885) by beachball)
28
+ - Bump @fluentui/react-jsx-runtime to v9.0.0 ([PR #28885](https://github.com/microsoft/fluentui/pull/28885) by beachball)
20
29
 
21
30
  ## [9.0.0-beta.33](https://github.com/microsoft/fluentui/tree/@fluentui/react-tree_v9.0.0-beta.33)
22
31
 
@@ -32,6 +32,7 @@
32
32
  return;
33
33
  }
34
34
  parentItem.itemType = 'branch';
35
+ var _propsWithoutParentValue_itemType;
35
36
  const item = {
36
37
  value: props.value,
37
38
  getTreeItemProps: ()=>({
@@ -41,7 +42,7 @@
41
42
  'aria-setsize': parentItem.childrenValues.length,
42
43
  itemType: item.itemType
43
44
  }),
44
- itemType: 'leaf',
45
+ itemType: (_propsWithoutParentValue_itemType = propsWithoutParentValue.itemType) !== null && _propsWithoutParentValue_itemType !== void 0 ? _propsWithoutParentValue_itemType : 'leaf',
45
46
  level: parentItem.level + 1,
46
47
  parentValue,
47
48
  childrenValues: [],
@@ -1 +1 @@
1
- {"version":3,"sources":["createHeadlessTree.ts"],"sourcesContent":["import { TreeItemProps, TreeItemType, TreeItemValue } from '../TreeItem';\nimport { ImmutableSet } from './ImmutableSet';\n\nexport type HeadlessTreeItemProps = Omit<TreeItemProps, 'itemType' | 'value'> & {\n value: TreeItemValue;\n itemType?: TreeItemType;\n parentValue?: TreeItemValue;\n};\n\n/**\n * The item that is returned by `createHeadlessTree`, it represents a wrapper around the properties provided to\n * `createHeadlessTree` but with extra information that might be useful on virtual tree scenarios\n */\nexport type HeadlessTreeItem<Props extends HeadlessTreeItemProps> = {\n level: number;\n index: number;\n position: number;\n childrenValues: TreeItemValue[];\n value: TreeItemValue;\n parentValue: TreeItemValue | undefined;\n itemType: TreeItemType;\n getTreeItemProps(): Required<Pick<Props, 'value' | 'aria-setsize' | 'aria-level' | 'aria-posinset' | 'itemType'>> &\n Omit<Props, 'parentValue'>;\n};\n\n/**\n * @internal\n */\nexport type HeadlessTree<Props extends HeadlessTreeItemProps> = {\n /**\n * the number of items in the virtual tree\n */\n readonly size: number;\n /**\n * the root item of the virtual tree\n */\n root: HeadlessTreeItem<HeadlessTreeItemProps>;\n /**\n * method to get a virtual tree item by its value\n * @param key the key of the item to get\n */\n get(value: TreeItemValue): HeadlessTreeItem<Props> | undefined;\n /**\n * method to check if a virtual tree item exists by its value\n * @param value the value of the item to check if exists\n */\n has(value: TreeItemValue): boolean;\n /**\n * method to add a new virtual tree item to the virtual tree\n * @param props the props of the item to add\n */\n add(props: Props): void;\n /**\n * method to remove a virtual tree item from the virtual tree.\n * When an item is removed:\n * 1. all its children are also removed\n * 2. all its siblings are repositioned\n * @param value the value of the item to remove\n */\n // remove(value: TreeItemValue): void;\n /**\n * method to get the parent of a virtual tree item by its value\n * @param value the value of the item to get the parent from\n */\n getParent(value: TreeItemValue): HeadlessTreeItem<Props>;\n /**\n * method to get the subtree of a virtual tree item by its value\n * @param value the value of the item to get the subtree from\n */\n subtree(value: TreeItemValue): IterableIterator<HeadlessTreeItem<Props>>;\n /**\n * method to get the children of a virtual tree item by its value\n * @param value the value of the item to get the children from\n */\n children(value: TreeItemValue): IterableIterator<HeadlessTreeItem<Props>>;\n /**\n * method to get the visible items of a virtual tree\n * @param openItems the open items of the tree\n */\n visibleItems(openItems: ImmutableSet<TreeItemValue>): IterableIterator<HeadlessTreeItem<Props>>;\n /**\n * method to get the ancestors of a virtual tree item by its value\n * @param value the value of the item to get the ancestors from\n */\n ancestors(value: TreeItemValue): IterableIterator<HeadlessTreeItem<Props>>;\n};\n\n/**\n * creates a list of virtual tree items\n * and provides a map to access each item by id\n */\nexport function createHeadlessTree<Props extends HeadlessTreeItemProps>(\n initialProps: Props[] = [],\n): HeadlessTree<Props> {\n const root = createHeadlessTreeRootItem();\n const itemsPerValue = new Map<TreeItemValue, HeadlessTreeItem<HeadlessTreeItemProps>>([[root.value, root]]);\n\n const headlessTree: HeadlessTree<HeadlessTreeItemProps> = {\n root,\n get size() {\n return itemsPerValue.size;\n },\n getParent: key => itemsPerValue.get(itemsPerValue.get(key)?.parentValue ?? root.value) ?? root,\n get: key => itemsPerValue.get(key),\n has: key => itemsPerValue.has(key),\n add(props) {\n const { parentValue = headlessTreeRootId, ...propsWithoutParentValue } = props;\n const parentItem = itemsPerValue.get(parentValue);\n if (!parentItem) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error(\n `HeadlessTree: item ${props.value} is wrongly positioned, did you properly ordered provided item props? make sure provided items are organized, parents should come before children`,\n );\n }\n return;\n }\n parentItem.itemType = 'branch';\n\n const item: HeadlessTreeItem<HeadlessTreeItemProps> = {\n value: props.value,\n getTreeItemProps: () => ({\n ...propsWithoutParentValue,\n 'aria-level': item.level,\n 'aria-posinset': item.position,\n 'aria-setsize': parentItem.childrenValues.length,\n itemType: item.itemType,\n }),\n itemType: 'leaf',\n level: parentItem.level + 1,\n parentValue,\n childrenValues: [],\n index: -1,\n position: parentItem.childrenValues.push(props.value),\n };\n itemsPerValue.set(item.value, item);\n },\n // TODO: eventually it would be nice to have this method exported for the user to modify\n // the internal state of the virtual tree\n // remove(value) {\n // const itemToBeRemoved = itemsPerValue.get(value);\n // if (!itemToBeRemoved) {\n // return;\n // }\n // const parentItem = headlessTree.getParent(value);\n // parentItem.childrenValues.splice(itemToBeRemoved.position, 1);\n // itemsPerValue.delete(value);\n // if (parentItem.childrenValues.length === 0) {\n // parentItem.itemType = 'leaf';\n // }\n // for (let index = itemToBeRemoved.position; index < parentItem.childrenValues.length; index++) {\n // const child = itemsPerValue.get(parentItem.childrenValues[index]);\n // if (child) {\n // child.position = index + 1;\n // }\n // }\n // for (const descendant of HeadlessTreeSubtreeGenerator(value, headlessTree)) {\n // itemsPerValue.delete(descendant.value);\n // }\n // },\n subtree: key => HeadlessTreeSubtreeGenerator(key, headlessTree),\n children: key => HeadlessTreeChildrenGenerator(key, headlessTree),\n ancestors: key => HeadlessTreeAncestorsGenerator(key, headlessTree),\n visibleItems: openItems => HeadlessTreeVisibleItemsGenerator(openItems, headlessTree),\n };\n\n initialProps.forEach(headlessTree.add);\n\n return headlessTree as HeadlessTree<Props>;\n}\n\nexport const headlessTreeRootId = '__fuiHeadlessTreeRoot';\n\nfunction createHeadlessTreeRootItem(): HeadlessTreeItem<HeadlessTreeItemProps> {\n return {\n parentValue: undefined,\n value: headlessTreeRootId,\n itemType: 'branch',\n getTreeItemProps: () => {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return {\n id: headlessTreeRootId,\n value: headlessTreeRootId,\n 'aria-setsize': -1,\n 'aria-level': -1,\n 'aria-posinset': -1,\n itemType: 'branch',\n };\n },\n childrenValues: [],\n get index() {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return -1;\n },\n get position() {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return -1;\n },\n level: 0,\n };\n}\n\n/**\n * Generator that returns all subtree of a given virtual tree item\n * @param key the key of the item to get the subtree from\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeSubtreeGenerator<Props extends HeadlessTreeItemProps>(\n key: TreeItemValue,\n virtualTreeItems: HeadlessTree<Props>,\n): Generator<HeadlessTreeItem<Props>, void, void> {\n const item = virtualTreeItems.get(key);\n if (!item || item.childrenValues.length === 0) {\n return;\n }\n for (const childValue of item.childrenValues) {\n yield virtualTreeItems.get(childValue)!;\n yield* HeadlessTreeSubtreeGenerator(childValue, virtualTreeItems);\n }\n}\n\n/**\n * Generator that returns all children of a given virtual tree item\n * @param key the key of the item to get the children from\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeChildrenGenerator<Props extends HeadlessTreeItemProps>(\n key: TreeItemValue,\n virtualTreeItems: HeadlessTree<Props>,\n): Generator<HeadlessTreeItem<Props>, void, void> {\n const item = virtualTreeItems.get(key);\n if (!item || item.childrenValues.length === 0) {\n return;\n }\n for (const childValue of item.childrenValues) {\n yield virtualTreeItems.get(childValue)!;\n }\n}\n\n/**\n * Generator that returns all ancestors of a given virtual tree item\n * @param key the key of the item to get the children from\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeAncestorsGenerator<Props extends HeadlessTreeItemProps>(\n key: TreeItemValue,\n virtualTreeItems: HeadlessTree<Props>,\n): Generator<HeadlessTreeItem<Props>, void, void> {\n let parent = virtualTreeItems.getParent(key);\n while (parent !== virtualTreeItems.root) {\n yield parent;\n parent = virtualTreeItems.getParent(parent.value);\n }\n}\n\n/**\n * Generator that returns all visible items of a given virtual tree\n * @param openItems the open items of the tree\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeVisibleItemsGenerator<Props extends HeadlessTreeItemProps>(\n openItems: ImmutableSet<TreeItemValue>,\n virtualTreeItems: HeadlessTree<Props>,\n): Generator<HeadlessTreeItem<Props>, void, void> {\n let index = 0;\n for (const item of HeadlessTreeSubtreeGenerator(virtualTreeItems.root.value, virtualTreeItems)) {\n if (isItemVisible(item, openItems, virtualTreeItems)) {\n item.index = index++;\n yield item;\n }\n }\n}\n\nfunction isItemVisible(\n item: HeadlessTreeItem<HeadlessTreeItemProps>,\n openItems: ImmutableSet<TreeItemValue>,\n virtualTreeItems: HeadlessTree<HeadlessTreeItemProps>,\n) {\n if (item.level === 1) {\n return true;\n }\n while (item.parentValue && item.parentValue !== virtualTreeItems.root.value) {\n if (!openItems.has(item.parentValue)) {\n return false;\n }\n const parent = virtualTreeItems.get(item.parentValue);\n if (!parent) {\n return false;\n }\n item = parent;\n }\n return true;\n}\n"],"names":["createHeadlessTree","initialProps","root","createHeadlessTreeRootItem","itemsPerValue","Map","value","headlessTree","size","getParent","key","get","parentValue","has","add","props","headlessTreeRootId","propsWithoutParentValue","parentItem","process","env","NODE_ENV","console","error","itemType","item","getTreeItemProps","level","position","childrenValues","length","index","push","set","subtree","HeadlessTreeSubtreeGenerator","children","HeadlessTreeChildrenGenerator","ancestors","HeadlessTreeAncestorsGenerator","visibleItems","openItems","HeadlessTreeVisibleItemsGenerator","forEach","undefined","id","virtualTreeItems","childValue","parent","isItemVisible"],"mappings":"AAuFA;;;CAGC,GACD,OAAO,SAASA,mBACdC,eAAwB,EAAE,EACL;IACrB,MAAMC,OAAOC;IACb,MAAMC,gBAAgB,IAAIC,IAA4D;QAAC;YAACH,KAAKI,KAAK;YAAEJ;SAAK;KAAC;QAOpEE,gCAAlBA;IALpB,MAAMG,eAAoD;QACxDL;QACA,IAAIM,QAAO;YACT,OAAOJ,cAAcI,IAAI;QAC3B;QACAC,WAAWC,CAAAA;gBAAyBN;YAAlBA,OAAAA,CAAAA,qBAAAA,cAAcO,GAAG,CAACP,CAAAA,iCAAAA,CAAAA,sBAAAA,cAAcO,GAAG,CAACD,kBAAlBN,iCAAAA,KAAAA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E;QAC3E,IAAI,CAACmC,UAAU5B,GAAG,CAACY,KAAKb,WAAW,GAAG;YACpC,OAAO,KAAK;QACd,CAAC;QACD,MAAMoC,SAASF,iBAAiBnC,GAAG,CAACc,KAAKb,WAAW;QACpD,IAAI,CAACoC,QAAQ;YACX,OAAO,KAAK;QACd,CAAC;QACDvB,OAAOuB;IACT;IACA,OAAO,IAAI;AACb"}
1
+ {"version":3,"sources":["createHeadlessTree.ts"],"sourcesContent":["import { TreeItemProps, TreeItemType, TreeItemValue } from '../TreeItem';\nimport { ImmutableSet } from './ImmutableSet';\n\nexport type HeadlessTreeItemProps = Omit<TreeItemProps, 'itemType' | 'value'> & {\n value: TreeItemValue;\n itemType?: TreeItemType;\n parentValue?: TreeItemValue;\n};\n\n/**\n * The item that is returned by `createHeadlessTree`, it represents a wrapper around the properties provided to\n * `createHeadlessTree` but with extra information that might be useful on virtual tree scenarios\n */\nexport type HeadlessTreeItem<Props extends HeadlessTreeItemProps> = {\n level: number;\n index: number;\n position: number;\n childrenValues: TreeItemValue[];\n value: TreeItemValue;\n parentValue: TreeItemValue | undefined;\n itemType: TreeItemType;\n getTreeItemProps(): Required<Pick<Props, 'value' | 'aria-setsize' | 'aria-level' | 'aria-posinset' | 'itemType'>> &\n Omit<Props, 'parentValue'>;\n};\n\n/**\n * @internal\n */\nexport type HeadlessTree<Props extends HeadlessTreeItemProps> = {\n /**\n * the number of items in the virtual tree\n */\n readonly size: number;\n /**\n * the root item of the virtual tree\n */\n root: HeadlessTreeItem<HeadlessTreeItemProps>;\n /**\n * method to get a virtual tree item by its value\n * @param key the key of the item to get\n */\n get(value: TreeItemValue): HeadlessTreeItem<Props> | undefined;\n /**\n * method to check if a virtual tree item exists by its value\n * @param value the value of the item to check if exists\n */\n has(value: TreeItemValue): boolean;\n /**\n * method to add a new virtual tree item to the virtual tree\n * @param props the props of the item to add\n */\n add(props: Props): void;\n /**\n * method to remove a virtual tree item from the virtual tree.\n * When an item is removed:\n * 1. all its children are also removed\n * 2. all its siblings are repositioned\n * @param value the value of the item to remove\n */\n // remove(value: TreeItemValue): void;\n /**\n * method to get the parent of a virtual tree item by its value\n * @param value the value of the item to get the parent from\n */\n getParent(value: TreeItemValue): HeadlessTreeItem<Props>;\n /**\n * method to get the subtree of a virtual tree item by its value\n * @param value the value of the item to get the subtree from\n */\n subtree(value: TreeItemValue): IterableIterator<HeadlessTreeItem<Props>>;\n /**\n * method to get the children of a virtual tree item by its value\n * @param value the value of the item to get the children from\n */\n children(value: TreeItemValue): IterableIterator<HeadlessTreeItem<Props>>;\n /**\n * method to get the visible items of a virtual tree\n * @param openItems the open items of the tree\n */\n visibleItems(openItems: ImmutableSet<TreeItemValue>): IterableIterator<HeadlessTreeItem<Props>>;\n /**\n * method to get the ancestors of a virtual tree item by its value\n * @param value the value of the item to get the ancestors from\n */\n ancestors(value: TreeItemValue): IterableIterator<HeadlessTreeItem<Props>>;\n};\n\n/**\n * creates a list of virtual tree items\n * and provides a map to access each item by id\n */\nexport function createHeadlessTree<Props extends HeadlessTreeItemProps>(\n initialProps: Props[] = [],\n): HeadlessTree<Props> {\n const root = createHeadlessTreeRootItem();\n const itemsPerValue = new Map<TreeItemValue, HeadlessTreeItem<HeadlessTreeItemProps>>([[root.value, root]]);\n\n const headlessTree: HeadlessTree<HeadlessTreeItemProps> = {\n root,\n get size() {\n return itemsPerValue.size;\n },\n getParent: key => itemsPerValue.get(itemsPerValue.get(key)?.parentValue ?? root.value) ?? root,\n get: key => itemsPerValue.get(key),\n has: key => itemsPerValue.has(key),\n add(props) {\n const { parentValue = headlessTreeRootId, ...propsWithoutParentValue } = props;\n const parentItem = itemsPerValue.get(parentValue);\n if (!parentItem) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error(\n `HeadlessTree: item ${props.value} is wrongly positioned, did you properly ordered provided item props? make sure provided items are organized, parents should come before children`,\n );\n }\n return;\n }\n parentItem.itemType = 'branch';\n\n const item: HeadlessTreeItem<HeadlessTreeItemProps> = {\n value: props.value,\n getTreeItemProps: () => ({\n ...propsWithoutParentValue,\n 'aria-level': item.level,\n 'aria-posinset': item.position,\n 'aria-setsize': parentItem.childrenValues.length,\n itemType: item.itemType,\n }),\n itemType: propsWithoutParentValue.itemType ?? 'leaf',\n level: parentItem.level + 1,\n parentValue,\n childrenValues: [],\n index: -1,\n position: parentItem.childrenValues.push(props.value),\n };\n itemsPerValue.set(item.value, item);\n },\n // TODO: eventually it would be nice to have this method exported for the user to modify\n // the internal state of the virtual tree\n // remove(value) {\n // const itemToBeRemoved = itemsPerValue.get(value);\n // if (!itemToBeRemoved) {\n // return;\n // }\n // const parentItem = headlessTree.getParent(value);\n // parentItem.childrenValues.splice(itemToBeRemoved.position, 1);\n // itemsPerValue.delete(value);\n // if (parentItem.childrenValues.length === 0) {\n // parentItem.itemType = 'leaf';\n // }\n // for (let index = itemToBeRemoved.position; index < parentItem.childrenValues.length; index++) {\n // const child = itemsPerValue.get(parentItem.childrenValues[index]);\n // if (child) {\n // child.position = index + 1;\n // }\n // }\n // for (const descendant of HeadlessTreeSubtreeGenerator(value, headlessTree)) {\n // itemsPerValue.delete(descendant.value);\n // }\n // },\n subtree: key => HeadlessTreeSubtreeGenerator(key, headlessTree),\n children: key => HeadlessTreeChildrenGenerator(key, headlessTree),\n ancestors: key => HeadlessTreeAncestorsGenerator(key, headlessTree),\n visibleItems: openItems => HeadlessTreeVisibleItemsGenerator(openItems, headlessTree),\n };\n\n initialProps.forEach(headlessTree.add);\n\n return headlessTree as HeadlessTree<Props>;\n}\n\nexport const headlessTreeRootId = '__fuiHeadlessTreeRoot';\n\nfunction createHeadlessTreeRootItem(): HeadlessTreeItem<HeadlessTreeItemProps> {\n return {\n parentValue: undefined,\n value: headlessTreeRootId,\n itemType: 'branch',\n getTreeItemProps: () => {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return {\n id: headlessTreeRootId,\n value: headlessTreeRootId,\n 'aria-setsize': -1,\n 'aria-level': -1,\n 'aria-posinset': -1,\n itemType: 'branch',\n };\n },\n childrenValues: [],\n get index() {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return -1;\n },\n get position() {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return -1;\n },\n level: 0,\n };\n}\n\n/**\n * Generator that returns all subtree of a given virtual tree item\n * @param key the key of the item to get the subtree from\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeSubtreeGenerator<Props extends HeadlessTreeItemProps>(\n key: TreeItemValue,\n virtualTreeItems: HeadlessTree<Props>,\n): Generator<HeadlessTreeItem<Props>, void, void> {\n const item = virtualTreeItems.get(key);\n if (!item || item.childrenValues.length === 0) {\n return;\n }\n for (const childValue of item.childrenValues) {\n yield virtualTreeItems.get(childValue)!;\n yield* HeadlessTreeSubtreeGenerator(childValue, virtualTreeItems);\n }\n}\n\n/**\n * Generator that returns all children of a given virtual tree item\n * @param key the key of the item to get the children from\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeChildrenGenerator<Props extends HeadlessTreeItemProps>(\n key: TreeItemValue,\n virtualTreeItems: HeadlessTree<Props>,\n): Generator<HeadlessTreeItem<Props>, void, void> {\n const item = virtualTreeItems.get(key);\n if (!item || item.childrenValues.length === 0) {\n return;\n }\n for (const childValue of item.childrenValues) {\n yield virtualTreeItems.get(childValue)!;\n }\n}\n\n/**\n * Generator that returns all ancestors of a given virtual tree item\n * @param key the key of the item to get the children from\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeAncestorsGenerator<Props extends HeadlessTreeItemProps>(\n key: TreeItemValue,\n virtualTreeItems: HeadlessTree<Props>,\n): Generator<HeadlessTreeItem<Props>, void, void> {\n let parent = virtualTreeItems.getParent(key);\n while (parent !== virtualTreeItems.root) {\n yield parent;\n parent = virtualTreeItems.getParent(parent.value);\n }\n}\n\n/**\n * Generator that returns all visible items of a given virtual tree\n * @param openItems the open items of the tree\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeVisibleItemsGenerator<Props extends HeadlessTreeItemProps>(\n openItems: ImmutableSet<TreeItemValue>,\n virtualTreeItems: HeadlessTree<Props>,\n): Generator<HeadlessTreeItem<Props>, void, void> {\n let index = 0;\n for (const item of HeadlessTreeSubtreeGenerator(virtualTreeItems.root.value, virtualTreeItems)) {\n if (isItemVisible(item, openItems, virtualTreeItems)) {\n item.index = index++;\n yield item;\n }\n }\n}\n\nfunction isItemVisible(\n item: HeadlessTreeItem<HeadlessTreeItemProps>,\n openItems: ImmutableSet<TreeItemValue>,\n virtualTreeItems: HeadlessTree<HeadlessTreeItemProps>,\n) {\n if (item.level === 1) {\n return true;\n }\n while (item.parentValue && item.parentValue !== virtualTreeItems.root.value) {\n if (!openItems.has(item.parentValue)) {\n return false;\n }\n const parent = virtualTreeItems.get(item.parentValue);\n if (!parent) {\n return false;\n }\n item = parent;\n }\n return true;\n}\n"],"names":["createHeadlessTree","initialProps","root","createHeadlessTreeRootItem","itemsPerValue","Map","value","headlessTree","size","getParent","key","get","parentValue","has","add","props","headlessTreeRootId","propsWithoutParentValue","parentItem","process","env","NODE_ENV","console","error","itemType","item","getTreeItemProps","level","position","childrenValues","length","index","push","set","subtree","HeadlessTreeSubtreeGenerator","children","HeadlessTreeChildrenGenerator","ancestors","HeadlessTreeAncestorsGenerator","visibleItems","openItems","HeadlessTreeVisibleItemsGenerator","forEach","undefined","id","virtualTreeItems","childValue","parent","isItemVisible"],"mappings":"AAuFA;;;CAGC,GACD,OAAO,SAASA,mBACdC,eAAwB,EAAE,EACL;IACrB,MAAMC,OAAOC;IACb,MAAMC,gBAAgB,IAAIC,IAA4D;QAAC;YAACH,KAAKI,KAAK;YAAEJ;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C,kBAAmB;QAC9F,IAAIG,cAAcxB,MAAMgB,WAAWK,mBAAmB;YACpDrB,KAAKM,KAAK,GAAGA;YACb,MAAMN;QACR,CAAC;IACH;AACF;AAEA,SAASwB,cACPxB,IAA6C,EAC7CgB,SAAsC,EACtCK,gBAAqD,EACrD;IACA,IAAIrB,KAAKE,KAAK,KAAK,GAAG;QACpB,OAAO,IAAI;IACb,CAAC;IACD,MAAOF,KAAKb,WAAW,IAAIa,KAAKb,WAAW,KAAKkC,iBAAiB5C,IAAI,CAACI,KAAK,CAAE;QAC3E,IAAI,CAACmC,UAAU5B,GAAG,CAACY,KAAKb,WAAW,GAAG;YACpC,OAAO,KAAK;QACd,CAAC;QACD,MAAMoC,SAASF,iBAAiBnC,GAAG,CAACc,KAAKb,WAAW;QACpD,IAAI,CAACoC,QAAQ;YACX,OAAO,KAAK;QACd,CAAC;QACDvB,OAAOuB;IACT;IACA,OAAO,IAAI;AACb"}
@@ -46,6 +46,7 @@ function createHeadlessTree(initialProps = []) {
46
46
  return;
47
47
  }
48
48
  parentItem.itemType = 'branch';
49
+ var _propsWithoutParentValue_itemType;
49
50
  const item = {
50
51
  value: props.value,
51
52
  getTreeItemProps: ()=>({
@@ -55,7 +56,7 @@ function createHeadlessTree(initialProps = []) {
55
56
  'aria-setsize': parentItem.childrenValues.length,
56
57
  itemType: item.itemType
57
58
  }),
58
- itemType: 'leaf',
59
+ itemType: (_propsWithoutParentValue_itemType = propsWithoutParentValue.itemType) !== null && _propsWithoutParentValue_itemType !== void 0 ? _propsWithoutParentValue_itemType : 'leaf',
59
60
  level: parentItem.level + 1,
60
61
  parentValue,
61
62
  childrenValues: [],
@@ -1 +1 @@
1
- {"version":3,"sources":["createHeadlessTree.js"],"sourcesContent":["/**\n * creates a list of virtual tree items\n * and provides a map to access each item by id\n */ export function createHeadlessTree(initialProps = []) {\n const root = createHeadlessTreeRootItem();\n const itemsPerValue = new Map([\n [\n root.value,\n root\n ]\n ]);\n var _itemsPerValue_get_parentValue, _itemsPerValue_get;\n const headlessTree = {\n root,\n get size () {\n return itemsPerValue.size;\n },\n getParent: (key)=>{\n var _itemsPerValue_get1;\n return (_itemsPerValue_get = itemsPerValue.get((_itemsPerValue_get_parentValue = (_itemsPerValue_get1 = itemsPerValue.get(key)) === null || _itemsPerValue_get1 === void 0 ? void 0 : _itemsPerValue_get1.parentValue) !== null && _itemsPerValue_get_parentValue !== void 0 ? _itemsPerValue_get_parentValue : root.value)) !== null && _itemsPerValue_get !== void 0 ? _itemsPerValue_get : root;\n },\n get: (key)=>itemsPerValue.get(key),\n has: (key)=>itemsPerValue.has(key),\n add (props) {\n const { parentValue =headlessTreeRootId , ...propsWithoutParentValue } = props;\n const parentItem = itemsPerValue.get(parentValue);\n if (!parentItem) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error(`HeadlessTree: item ${props.value} is wrongly positioned, did you properly ordered provided item props? make sure provided items are organized, parents should come before children`);\n }\n return;\n }\n parentItem.itemType = 'branch';\n const item = {\n value: props.value,\n getTreeItemProps: ()=>({\n ...propsWithoutParentValue,\n 'aria-level': item.level,\n 'aria-posinset': item.position,\n 'aria-setsize': parentItem.childrenValues.length,\n itemType: item.itemType\n }),\n itemType: 'leaf',\n level: parentItem.level + 1,\n parentValue,\n childrenValues: [],\n index: -1,\n position: parentItem.childrenValues.push(props.value)\n };\n itemsPerValue.set(item.value, item);\n },\n // TODO: eventually it would be nice to have this method exported for the user to modify\n // the internal state of the virtual tree\n // remove(value) {\n // const itemToBeRemoved = itemsPerValue.get(value);\n // if (!itemToBeRemoved) {\n // return;\n // }\n // const parentItem = headlessTree.getParent(value);\n // parentItem.childrenValues.splice(itemToBeRemoved.position, 1);\n // itemsPerValue.delete(value);\n // if (parentItem.childrenValues.length === 0) {\n // parentItem.itemType = 'leaf';\n // }\n // for (let index = itemToBeRemoved.position; index < parentItem.childrenValues.length; index++) {\n // const child = itemsPerValue.get(parentItem.childrenValues[index]);\n // if (child) {\n // child.position = index + 1;\n // }\n // }\n // for (const descendant of HeadlessTreeSubtreeGenerator(value, headlessTree)) {\n // itemsPerValue.delete(descendant.value);\n // }\n // },\n subtree: (key)=>HeadlessTreeSubtreeGenerator(key, headlessTree),\n children: (key)=>HeadlessTreeChildrenGenerator(key, headlessTree),\n ancestors: (key)=>HeadlessTreeAncestorsGenerator(key, headlessTree),\n visibleItems: (openItems)=>HeadlessTreeVisibleItemsGenerator(openItems, headlessTree)\n };\n initialProps.forEach(headlessTree.add);\n return headlessTree;\n}\nexport const headlessTreeRootId = '__fuiHeadlessTreeRoot';\nfunction createHeadlessTreeRootItem() {\n return {\n parentValue: undefined,\n value: headlessTreeRootId,\n itemType: 'branch',\n getTreeItemProps: ()=>{\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return {\n id: headlessTreeRootId,\n value: headlessTreeRootId,\n 'aria-setsize': -1,\n 'aria-level': -1,\n 'aria-posinset': -1,\n itemType: 'branch'\n };\n },\n childrenValues: [],\n get index () {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return -1;\n },\n get position () {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return -1;\n },\n level: 0\n };\n}\n/**\n * Generator that returns all subtree of a given virtual tree item\n * @param key the key of the item to get the subtree from\n */ // eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeSubtreeGenerator(key, virtualTreeItems) {\n const item = virtualTreeItems.get(key);\n if (!item || item.childrenValues.length === 0) {\n return;\n }\n for (const childValue of item.childrenValues){\n yield virtualTreeItems.get(childValue);\n yield* HeadlessTreeSubtreeGenerator(childValue, virtualTreeItems);\n }\n}\n/**\n * Generator that returns all children of a given virtual tree item\n * @param key the key of the item to get the children from\n */ // eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeChildrenGenerator(key, virtualTreeItems) {\n const item = virtualTreeItems.get(key);\n if (!item || item.childrenValues.length === 0) {\n return;\n }\n for (const childValue of item.childrenValues){\n yield virtualTreeItems.get(childValue);\n }\n}\n/**\n * Generator that returns all ancestors of a given virtual tree item\n * @param key the key of the item to get the children from\n */ // eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeAncestorsGenerator(key, virtualTreeItems) {\n let parent = virtualTreeItems.getParent(key);\n while(parent !== virtualTreeItems.root){\n yield parent;\n parent = virtualTreeItems.getParent(parent.value);\n }\n}\n/**\n * Generator that returns all visible items of a given virtual tree\n * @param openItems the open items of the tree\n */ // eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeVisibleItemsGenerator(openItems, virtualTreeItems) {\n let index = 0;\n for (const item of HeadlessTreeSubtreeGenerator(virtualTreeItems.root.value, virtualTreeItems)){\n if (isItemVisible(item, openItems, virtualTreeItems)) {\n item.index = index++;\n yield item;\n }\n }\n}\nfunction isItemVisible(item, openItems, virtualTreeItems) {\n if (item.level === 1) {\n return true;\n }\n while(item.parentValue && item.parentValue !== virtualTreeItems.root.value){\n if (!openItems.has(item.parentValue)) {\n return false;\n }\n const parent = virtualTreeItems.get(item.parentValue);\n if (!parent) {\n return false;\n }\n item = parent;\n }\n return true;\n}\n"],"names":["createHeadlessTree","headlessTreeRootId","initialProps","root","createHeadlessTreeRootItem","itemsPerValue","Map","value","_itemsPerValue_get_parentValue","_itemsPerValue_get","headlessTree","size","getParent","key","_itemsPerValue_get1","get","parentValue","has","add","props","propsWithoutParentValue","parentItem","process","env","NODE_ENV","console","error","itemType","item","getTreeItemProps","level","position","childrenValues","length","index","push","set","subtree","HeadlessTreeSubtreeGenerator","children","HeadlessTreeChildrenGenerator","ancestors","HeadlessTreeAncestorsGenerator","visibleItems","openItems","HeadlessTreeVisibleItemsGenerator","forEach","undefined","id","virtualTreeItems","childValue","parent","isItemV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AC;QACnC,MAAMgD;QACNA,SAASF,iBAAiBrC,SAAS,CAACuC,OAAO5C,KAAK;IACpD;AACJ;AACA;;;CAGC,GAAG,gEAAgE;AACpE,UAAUsC,kCAAkCD,SAAS,EAAEK,gBAAgB,EAAE;IACrE,IAAIf,QAAQ;IACZ,KAAK,MAAMN,QAAQU,6BAA6BW,iBAAiB9C,IAAI,CAACI,KAAK,EAAE0C,kBAAkB;QAC3F,IAAIG,cAAcxB,MAAMgB,WAAWK,mBAAmB;YAClDrB,KAAKM,KAAK,GAAGA;YACb,MAAMN;QACV,CAAC;IACL;AACJ;AACA,SAASwB,cAAcxB,IAAI,EAAEgB,SAAS,EAAEK,gBAAgB,EAAE;IACtD,IAAIrB,KAAKE,KAAK,KAAK,GAAG;QAClB,OAAO,IAAI;IACf,CAAC;IACD,MAAMF,KAAKZ,WAAW,IAAIY,KAAKZ,WAAW,KAAKiC,iBAAiB9C,IAAI,CAACI,KAAK,CAAC;QACvE,IAAI,CAACqC,UAAU3B,GAAG,CAACW,KAAKZ,WAAW,GAAG;YAClC,OAAO,KAAK;QAChB,CAAC;QACD,MAAMmC,SAASF,iBAAiBlC,GAAG,CAACa,KAAKZ,WAAW;QACpD,IAAI,CAACmC,QAAQ;YACT,OAAO,KAAK;QAChB,CAAC;QACDvB,OAAOuB;IACX;IACA,OAAO,IAAI;AACf"}
1
+ {"version":3,"sources":["createHeadlessTree.js"],"sourcesContent":["/**\n * creates a list of virtual tree items\n * and provides a map to access each item by id\n */ export function createHeadlessTree(initialProps = []) {\n const root = createHeadlessTreeRootItem();\n const itemsPerValue = new Map([\n [\n root.value,\n root\n ]\n ]);\n var _itemsPerValue_get_parentValue, _itemsPerValue_get;\n const headlessTree = {\n root,\n get size () {\n return itemsPerValue.size;\n },\n getParent: (key)=>{\n var _itemsPerValue_get1;\n return (_itemsPerValue_get = itemsPerValue.get((_itemsPerValue_get_parentValue = (_itemsPerValue_get1 = itemsPerValue.get(key)) === null || _itemsPerValue_get1 === void 0 ? void 0 : _itemsPerValue_get1.parentValue) !== null && _itemsPerValue_get_parentValue !== void 0 ? _itemsPerValue_get_parentValue : root.value)) !== null && _itemsPerValue_get !== void 0 ? _itemsPerValue_get : root;\n },\n get: (key)=>itemsPerValue.get(key),\n has: (key)=>itemsPerValue.has(key),\n add (props) {\n const { parentValue =headlessTreeRootId , ...propsWithoutParentValue } = props;\n const parentItem = itemsPerValue.get(parentValue);\n if (!parentItem) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error(`HeadlessTree: item ${props.value} is wrongly positioned, did you properly ordered provided item props? make sure provided items are organized, parents should come before children`);\n }\n return;\n }\n parentItem.itemType = 'branch';\n var _propsWithoutParentValue_itemType;\n const item = {\n value: props.value,\n getTreeItemProps: ()=>({\n ...propsWithoutParentValue,\n 'aria-level': item.level,\n 'aria-posinset': item.position,\n 'aria-setsize': parentItem.childrenValues.length,\n itemType: item.itemType\n }),\n itemType: (_propsWithoutParentValue_itemType = propsWithoutParentValue.itemType) !== null && _propsWithoutParentValue_itemType !== void 0 ? _propsWithoutParentValue_itemType : 'leaf',\n level: parentItem.level + 1,\n parentValue,\n childrenValues: [],\n index: -1,\n position: parentItem.childrenValues.push(props.value)\n };\n itemsPerValue.set(item.value, item);\n },\n // TODO: eventually it would be nice to have this method exported for the user to modify\n // the internal state of the virtual tree\n // remove(value) {\n // const itemToBeRemoved = itemsPerValue.get(value);\n // if (!itemToBeRemoved) {\n // return;\n // }\n // const parentItem = headlessTree.getParent(value);\n // parentItem.childrenValues.splice(itemToBeRemoved.position, 1);\n // itemsPerValue.delete(value);\n // if (parentItem.childrenValues.length === 0) {\n // parentItem.itemType = 'leaf';\n // }\n // for (let index = itemToBeRemoved.position; index < parentItem.childrenValues.length; index++) {\n // const child = itemsPerValue.get(parentItem.childrenValues[index]);\n // if (child) {\n // child.position = index + 1;\n // }\n // }\n // for (const descendant of HeadlessTreeSubtreeGenerator(value, headlessTree)) {\n // itemsPerValue.delete(descendant.value);\n // }\n // },\n subtree: (key)=>HeadlessTreeSubtreeGenerator(key, headlessTree),\n children: (key)=>HeadlessTreeChildrenGenerator(key, headlessTree),\n ancestors: (key)=>HeadlessTreeAncestorsGenerator(key, headlessTree),\n visibleItems: (openItems)=>HeadlessTreeVisibleItemsGenerator(openItems, headlessTree)\n };\n initialProps.forEach(headlessTree.add);\n return headlessTree;\n}\nexport const headlessTreeRootId = '__fuiHeadlessTreeRoot';\nfunction createHeadlessTreeRootItem() {\n return {\n parentValue: undefined,\n value: headlessTreeRootId,\n itemType: 'branch',\n getTreeItemProps: ()=>{\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return {\n id: headlessTreeRootId,\n value: headlessTreeRootId,\n 'aria-setsize': -1,\n 'aria-level': -1,\n 'aria-posinset': -1,\n itemType: 'branch'\n };\n },\n childrenValues: [],\n get index () {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return -1;\n },\n get position () {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('HeadlessTree: internal error, trying to access treeitem props from invalid root element');\n }\n return -1;\n },\n level: 0\n };\n}\n/**\n * Generator that returns all subtree of a given virtual tree item\n * @param key the key of the item to get the subtree from\n */ // eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeSubtreeGenerator(key, virtualTreeItems) {\n const item = virtualTreeItems.get(key);\n if (!item || item.childrenValues.length === 0) {\n return;\n }\n for (const childValue of item.childrenValues){\n yield virtualTreeItems.get(childValue);\n yield* HeadlessTreeSubtreeGenerator(childValue, virtualTreeItems);\n }\n}\n/**\n * Generator that returns all children of a given virtual tree item\n * @param key the key of the item to get the children from\n */ // eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeChildrenGenerator(key, virtualTreeItems) {\n const item = virtualTreeItems.get(key);\n if (!item || item.childrenValues.length === 0) {\n return;\n }\n for (const childValue of item.childrenValues){\n yield virtualTreeItems.get(childValue);\n }\n}\n/**\n * Generator that returns all ancestors of a given virtual tree item\n * @param key the key of the item to get the children from\n */ // eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeAncestorsGenerator(key, virtualTreeItems) {\n let parent = virtualTreeItems.getParent(key);\n while(parent !== virtualTreeItems.root){\n yield parent;\n parent = virtualTreeItems.getParent(parent.value);\n }\n}\n/**\n * Generator that returns all visible items of a given virtual tree\n * @param openItems the open items of the tree\n */ // eslint-disable-next-line @typescript-eslint/naming-convention\nfunction* HeadlessTreeVisibleItemsGenerator(openItems, virtualTreeItems) {\n let index = 0;\n for (const item of HeadlessTreeSubtreeGenerator(virtualTreeItems.root.value, virtualTreeItems)){\n if (isItemVisible(item, openItems, virtualTreeItems)) {\n item.index = index++;\n yield item;\n }\n }\n}\nfunction isItemVisible(item, openItems, virtualTreeItems) {\n if (item.level === 1) {\n return true;\n }\n while(item.parentValue && item.parentValue !== virtualTreeItems.root.value){\n if (!openItems.has(item.parentValue)) {\n return false;\n }\n const parent = virtualTreeItems.get(item.parentValue);\n if (!parent) {\n return false;\n }\n item = parent;\n }\n return true;\n}\n"],"names":["createHeadlessTree","headlessTreeRootId","initialProps","root","createHeadlessTreeRootItem","itemsPerValue","Map","value","_itemsPerValue_get_parentValue","_itemsPerValue_get","headlessTree","size","getParent","key","_itemsPerValue_get1","get","parentValue","has","add","props","propsWithoutParentValue","parentItem","process","env","NODE_ENV","console","error","itemType","_propsWithoutParentValue_itemType","item","getTreeItemProps","level","position","childrenValues","length","index","push","set","subtree","HeadlessTreeSubtreeGenerator","children","HeadlessTreeChildrenGenerator","ancestors","HeadlessTreeAncestorsGenerator","visibleItems","openItems","HeadlessTreeVisibleItemsGenerator","forEach","undefined","id","virtualTreeItems","childValue","parent","isItemVisible"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;IAAmBA,kBAAkB,MAAlBA;I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S,CAACC;IACxC,MAAMuC,WAAWF,iBAAiB/C,IAAI,CAAC;QACnC,MAAMiD;QACNA,SAASF,iBAAiBtC,SAAS,CAACwC,OAAO7C,KAAK;IACpD;AACJ;AACA;;;CAGC,GAAG,gEAAgE;AACpE,UAAUuC,kCAAkCD,SAAS,EAAEK,gBAAgB,EAAE;IACrE,IAAIf,QAAQ;IACZ,KAAK,MAAMN,QAAQU,6BAA6BW,iBAAiB/C,IAAI,CAACI,KAAK,EAAE2C,kBAAkB;QAC3F,IAAIG,cAAcxB,MAAMgB,WAAWK,mBAAmB;YAClDrB,KAAKM,KAAK,GAAGA;YACb,MAAMN;QACV,CAAC;IACL;AACJ;AACA,SAASwB,cAAcxB,IAAI,EAAEgB,SAAS,EAAEK,gBAAgB,EAAE;IACtD,IAAIrB,KAAKE,KAAK,KAAK,GAAG;QAClB,OAAO,IAAI;IACf,CAAC;IACD,MAAMF,KAAKb,WAAW,IAAIa,KAAKb,WAAW,KAAKkC,iBAAiB/C,IAAI,CAACI,KAAK,CAAC;QACvE,IAAI,CAACsC,UAAU5B,GAAG,CAACY,KAAKb,WAAW,GAAG;YAClC,OAAO,KAAK;QAChB,CAAC;QACD,MAAMoC,SAASF,iBAAiBnC,GAAG,CAACc,KAAKb,WAAW;QACpD,IAAI,CAACoC,QAAQ;YACT,OAAO,KAAK;QAChB,CAAC;QACDvB,OAAOuB;IACX;IACA,OAAO,IAAI;AACf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-tree",
3
- "version": "9.0.0",
3
+ "version": "9.0.1",
4
4
  "description": "Tree component for Fluent UI React",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -46,7 +46,7 @@
46
46
  "@fluentui/react-tabster": "^9.12.2",
47
47
  "@fluentui/react-theme": "^9.1.11",
48
48
  "@fluentui/react-utilities": "^9.11.1",
49
- "@fluentui/react-jsx-runtime": "9.0.0",
49
+ "@fluentui/react-jsx-runtime": "^9.0.0",
50
50
  "@griffel/react": "^1.5.14",
51
51
  "@swc/helpers": "^0.4.14"
52
52
  },