@fluentui/react-tree 9.0.0-beta.11 → 9.0.0-beta.12

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 (49) hide show
  1. package/CHANGELOG.json +52 -1
  2. package/CHANGELOG.md +17 -2
  3. package/dist/index.d.ts +73 -45
  4. package/lib/components/Tree/Tree.js.map +1 -1
  5. package/lib/components/Tree/Tree.types.js.map +1 -1
  6. package/lib/components/TreeItem/TreeItem.js +1 -1
  7. package/lib/components/TreeItem/TreeItem.js.map +1 -1
  8. package/lib/components/TreeItem/TreeItem.types.js.map +1 -1
  9. package/lib/components/TreeItem/useTreeItem.js +17 -4
  10. package/lib/components/TreeItem/useTreeItem.js.map +1 -1
  11. package/lib/components/TreeItemLayout/TreeItemLayout.types.js.map +1 -1
  12. package/lib/components/TreeItemLayout/useTreeItemLayout.js +2 -2
  13. package/lib/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
  14. package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js +7 -14
  15. package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js.map +1 -1
  16. package/lib/contexts/treeContext.js.map +1 -1
  17. package/lib/hooks/useFlatTree.js +2 -2
  18. package/lib/hooks/useFlatTree.js.map +1 -1
  19. package/lib/hooks/useFlatTreeNavigation.js +7 -5
  20. package/lib/hooks/useFlatTreeNavigation.js.map +1 -1
  21. package/lib/hooks/useNestedTreeNavigation.js +1 -1
  22. package/lib/hooks/useNestedTreeNavigation.js.map +1 -1
  23. package/lib/hooks/useOpenItemsState.js +2 -3
  24. package/lib/hooks/useOpenItemsState.js.map +1 -1
  25. package/lib/index.js.map +1 -1
  26. package/lib/utils/createFlatTreeItems.js +26 -17
  27. package/lib/utils/createFlatTreeItems.js.map +1 -1
  28. package/lib/utils/flattenTree.js +8 -4
  29. package/lib/utils/flattenTree.js.map +1 -1
  30. package/lib-commonjs/components/TreeItem/TreeItem.js.map +1 -1
  31. package/lib-commonjs/components/TreeItem/useTreeItem.js +17 -5
  32. package/lib-commonjs/components/TreeItem/useTreeItem.js.map +1 -1
  33. package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.js +2 -2
  34. package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
  35. package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js +11 -19
  36. package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js.map +1 -1
  37. package/lib-commonjs/hooks/useFlatTree.js +2 -2
  38. package/lib-commonjs/hooks/useFlatTree.js.map +1 -1
  39. package/lib-commonjs/hooks/useFlatTreeNavigation.js +7 -5
  40. package/lib-commonjs/hooks/useFlatTreeNavigation.js.map +1 -1
  41. package/lib-commonjs/hooks/useNestedTreeNavigation.js +1 -1
  42. package/lib-commonjs/hooks/useNestedTreeNavigation.js.map +1 -1
  43. package/lib-commonjs/hooks/useOpenItemsState.js +2 -3
  44. package/lib-commonjs/hooks/useOpenItemsState.js.map +1 -1
  45. package/lib-commonjs/utils/createFlatTreeItems.js +26 -20
  46. package/lib-commonjs/utils/createFlatTreeItems.js.map +1 -1
  47. package/lib-commonjs/utils/flattenTree.js +8 -4
  48. package/lib-commonjs/utils/flattenTree.js.map +1 -1
  49. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"names":["createFlatTreeItems","flatTreeItemProps","root","createFlatTreeRootItem","itemsPerId","Map","flatTreeRootId","items","index","length","parentId","treeItemProps","nextItemProps","currentParent","get","process","env","NODE_ENV","console","error","id","isLeaf","_currentParent_level","currentLevel","level","currentChildrenSize","childrenSize","flatTreeItem","getTreeItemProps","leaf","set","push","size","getByIndex","value","VisibleFlatTreeItemGenerator","openItems","flatTreeItems","visibleIndex","item","_flatTreeItems_get","parent","isItemVisible","has"],"sources":["../../src/utils/createFlatTreeItems.ts"],"sourcesContent":["import type { TreeItemId } from '../TreeItem';\nimport type { ImmutableSet } from './ImmutableSet';\nimport type { FlatTreeItem, FlatTreeItemProps, MutableFlatTreeItem } from '../hooks/useFlatTree';\n\n/**\n * @internal\n */\nexport type FlatTreeItems = {\n size: number;\n root: FlatTreeItem;\n get(id: string): FlatTreeItem | undefined;\n set(id: string, value: FlatTreeItem): void;\n getByIndex(index: number): FlatTreeItem;\n};\n\n/**\n * creates a list of flat tree items\n * and provides a map to access each item by id\n */\nexport function createFlatTreeItems(flatTreeItemProps: FlatTreeItemProps[]): FlatTreeItems {\n const root = createFlatTreeRootItem();\n const itemsPerId = new Map<string, MutableFlatTreeItem>([[flatTreeRootId, root]]);\n const items: MutableFlatTreeItem[] = [];\n\n for (let index = 0; index < flatTreeItemProps.length; index++) {\n const { parentId = flatTreeRootId, ...treeItemProps } = flatTreeItemProps[index];\n\n const nextItemProps: FlatTreeItemProps | undefined = flatTreeItemProps[index + 1];\n const currentParent = itemsPerId.get(parentId);\n if (!currentParent) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error(\n `useFlatTree: item ${flatTreeItemProps[index].id} is wrongly positioned, did you properly ordered provided item props? make sure provided items are organized`,\n );\n }\n break;\n }\n const isLeaf = nextItemProps?.parentId !== treeItemProps.id;\n const currentLevel = (currentParent.level ?? 0) + 1;\n const currentChildrenSize = ++currentParent.childrenSize;\n\n const flatTreeItem: FlatTreeItem = {\n id: treeItemProps.id,\n getTreeItemProps: () => ({\n ...treeItemProps,\n 'aria-level': currentLevel,\n 'aria-posinset': currentChildrenSize,\n 'aria-setsize': currentParent.childrenSize,\n leaf: isLeaf,\n }),\n level: currentLevel,\n parentId,\n childrenSize: 0,\n index: -1,\n };\n itemsPerId.set(flatTreeItem.id, flatTreeItem);\n items.push(flatTreeItem);\n }\n\n return {\n root,\n size: items.length,\n getByIndex: index => items[index],\n get: id => itemsPerId.get(id),\n set: (id, value) => itemsPerId.set(id, value),\n };\n}\n\nexport const flatTreeRootId = '__fuiFlatTreeRoot';\n\nfunction createFlatTreeRootItem(): FlatTreeItem {\n return {\n id: flatTreeRootId,\n getTreeItemProps: () => {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('useFlatTree: internal error, trying to access treeitem props from invalid root element');\n }\n return { id: flatTreeRootId, 'aria-setsize': -1, 'aria-level': -1, 'aria-posinset': -1, leaf: true };\n },\n childrenSize: 0,\n get index() {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('useFlatTree: internal error, trying to access treeitem props from invalid root element');\n }\n return -1;\n },\n level: 0,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function* VisibleFlatTreeItemGenerator(openItems: ImmutableSet<TreeItemId>, flatTreeItems: FlatTreeItems) {\n for (let index = 0, visibleIndex = 0; index < flatTreeItems.size; index++) {\n const item: MutableFlatTreeItem = flatTreeItems.getByIndex(index);\n const parent = item.parentId ? flatTreeItems.get(item.parentId) ?? flatTreeItems.root : flatTreeItems.root;\n if (isItemVisible(item, openItems, flatTreeItems)) {\n item.index = visibleIndex++;\n yield item;\n } else {\n index += parent.childrenSize - 1 + item.childrenSize;\n }\n }\n}\n\nfunction isItemVisible(item: FlatTreeItem, openItems: ImmutableSet<TreeItemId>, flatTreeItems: FlatTreeItems) {\n if (item.level === 1) {\n return true;\n }\n while (item.parentId && item.parentId !== flatTreeItems.root.id) {\n if (!openItems.has(item.parentId)) {\n return false;\n }\n const parent = flatTreeItems.get(item.parentId);\n if (!parent) {\n return false;\n }\n item = parent;\n }\n return true;\n}\n"],"mappings":"AAeA;;;GAIA,OAAO,SAASA,oBAAoBC,iBAAsC,EAAiB;EACzF,MAAMC,IAAA,GAAOC,sBAAA;EACb,MAAMC,UAAA,GAAa,IAAIC,GAAA,CAAiC,CAAC,CAACC,cAAA,EAAgBJ,IAAA,CAAK,CAAC;EAChF,MAAMK,KAAA,GAA+B,EAAE;EAEvC,KAAK,IAAIC,KAAA,GAAQ,GAAGA,KAAA,GAAQP,iBAAA,CAAkBQ,MAAM,E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I,GAAGmC,aAAA,CAAcnC,IAAI;IAC1G,IAAIwC,aAAA,CAAcH,IAAA,EAAMH,SAAA,EAAWC,aAAA,GAAgB;MACjDE,IAAA,CAAK/B,KAAK,GAAG8B,YAAA;MACb,MAAMC,IAAA;IACR,OAAO;MACL/B,KAAA,IAASiC,MAAA,CAAOf,YAAY,GAAG,IAAIa,IAAA,CAAKb,YAAY;IACtD;EACF;AACF;AAEA,SAASgB,cAAcH,IAAkB,EAAEH,SAAmC,EAAEC,aAA4B,EAAE;EAC5G,IAAIE,IAAA,CAAKf,KAAK,KAAK,GAAG;IACpB,OAAO,IAAI;EACb;EACA,OAAOe,IAAA,CAAK7B,QAAQ,IAAI6B,IAAA,CAAK7B,QAAQ,KAAK2B,aAAA,CAAcnC,IAAI,CAACkB,EAAE,EAAE;IAC/D,IAAI,CAACgB,SAAA,CAAUO,GAAG,CAACJ,IAAA,CAAK7B,QAAQ,GAAG;MACjC,OAAO,KAAK;IACd;IACA,MAAM+B,MAAA,GAASJ,aAAA,CAAcvB,GAAG,CAACyB,IAAA,CAAK7B,QAAQ;IAC9C,IAAI,CAAC+B,MAAA,EAAQ;MACX,OAAO,KAAK;IACd;IACAF,IAAA,GAAOE,MAAA;EACT;EACA,OAAO,IAAI;AACb"}
1
+ {"version":3,"names":["React","createFlatTreeItems","flatTreeItemProps","root","createFlatTreeRootItem","itemsPerValue","Map","flatTreeRootId","items","index","length","parentValue","treeItemProps","nextItemProps","currentParent","get","process","env","NODE_ENV","console","error","id","isLeaf","value","_currentParent_level","currentLevel","level","currentChildrenSize","childrenSize","ref","createRef","flatTreeItem","getTreeItemProps","leaf","undefined","set","push","size","getByIndex","current","VisibleFlatTreeItemGenerator","openItems","flatTreeItems","visibleIndex","item","_flatTreeItems_get","parent","isItemVisible","has"],"sources":["../../src/utils/createFlatTreeItems.ts"],"sourcesContent":["import type { ImmutableSet } from './ImmutableSet';\nimport type { FlatTreeItem, FlatTreeItemProps, MutableFlatTreeItem } from '../hooks/useFlatTree';\nimport * as React from 'react';\n\n/**\n * @internal\n */\nexport type FlatTreeItems<Value = string> = {\n size: number;\n root: FlatTreeItem<Value>;\n get(key: Value): FlatTreeItem<Value> | undefined;\n set(key: Value, value: FlatTreeItem<Value>): void;\n getByIndex(index: number): FlatTreeItem<Value>;\n};\n\n/**\n * creates a list of flat tree items\n * and provides a map to access each item by id\n */\nexport function createFlatTreeItems<Value = string>(\n flatTreeItemProps: FlatTreeItemProps<Value>[],\n): FlatTreeItems<Value> {\n const root = createFlatTreeRootItem<Value>();\n const itemsPerValue = new Map<Value, MutableFlatTreeItem<Value>>([[flatTreeRootId as Value, root]]);\n const items: MutableFlatTreeItem<Value>[] = [];\n\n for (let index = 0; index < flatTreeItemProps.length; index++) {\n const { parentValue = flatTreeRootId as Value, ...treeItemProps } = flatTreeItemProps[index];\n\n const nextItemProps: FlatTreeItemProps<Value> | undefined = flatTreeItemProps[index + 1];\n const currentParent = itemsPerValue.get(parentValue);\n if (!currentParent) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error(\n `useFlatTree: item ${flatTreeItemProps[index].id} is wrongly positioned, did you properly ordered provided item props? make sure provided items are organized`,\n );\n }\n break;\n }\n const isLeaf = nextItemProps?.parentValue !== treeItemProps.value;\n const currentLevel = (currentParent.level ?? 0) + 1;\n const currentChildrenSize = ++currentParent.childrenSize;\n const ref = React.createRef<HTMLDivElement>();\n\n const flatTreeItem: MutableFlatTreeItem<Value> = {\n value: treeItemProps.value,\n getTreeItemProps: () => ({\n ...treeItemProps,\n 'aria-level': currentLevel,\n 'aria-posinset': currentChildrenSize,\n 'aria-setsize': currentParent.childrenSize,\n leaf: isLeaf,\n // a reference to every parent element is necessary to ensure navigation\n ref: flatTreeItem.childrenSize > 0 ? ref : undefined,\n }),\n ref,\n level: currentLevel,\n parentValue,\n childrenSize: 0,\n index: -1,\n };\n itemsPerValue.set(flatTreeItem.value, flatTreeItem);\n items.push(flatTreeItem);\n }\n\n return {\n root,\n size: items.length,\n getByIndex: index => items[index],\n get: id => itemsPerValue.get(id),\n set: (id, value) => itemsPerValue.set(id, value),\n };\n}\n\nexport const flatTreeRootId = '__fuiFlatTreeRoot' as unknown;\n\nfunction createFlatTreeRootItem<Value = string>(): FlatTreeItem<Value> {\n return {\n ref: { current: null },\n value: flatTreeRootId as Value,\n getTreeItemProps: () => {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('useFlatTree: internal error, trying to access treeitem props from invalid root element');\n }\n return { value: flatTreeRootId as Value, 'aria-setsize': -1, 'aria-level': -1, 'aria-posinset': -1, leaf: true };\n },\n childrenSize: 0,\n get index() {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('useFlatTree: internal error, trying to access treeitem props from invalid root element');\n }\n return -1;\n },\n level: 0,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function* VisibleFlatTreeItemGenerator<Value = string>(\n openItems: ImmutableSet<Value>,\n flatTreeItems: FlatTreeItems<Value>,\n) {\n for (let index = 0, visibleIndex = 0; index < flatTreeItems.size; index++) {\n const item: MutableFlatTreeItem<Value> = flatTreeItems.getByIndex(index);\n const parent = item.parentValue ? flatTreeItems.get(item.parentValue) ?? flatTreeItems.root : flatTreeItems.root;\n if (isItemVisible(item, openItems, flatTreeItems)) {\n item.index = visibleIndex++;\n yield item;\n } else {\n index += parent.childrenSize - 1 + item.childrenSize;\n }\n }\n}\n\nfunction isItemVisible<Value>(\n item: FlatTreeItem<Value>,\n openItems: ImmutableSet<Value>,\n flatTreeItems: FlatTreeItems<Value>,\n) {\n if (item.level === 1) {\n return true;\n }\n while (item.parentValue && item.parentValue !== flatTreeItems.root.value) {\n if (!openItems.has(item.parentValue)) {\n return false;\n }\n const parent = flatTreeItems.get(item.parentValue);\n if (!parent) {\n return false;\n }\n item = parent;\n }\n return true;\n}\n"],"mappings":"AAEA,YAAYA,KAAA,MAAW;AAavB;;;;AAIA,OAAO,SAASC,o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,12 +6,14 @@ function flattenTreeRecursive(items, parent, level = 1) {
6
6
  ...item
7
7
  }, index) => {
8
8
  var _item_id;
9
+ const id = (_item_id = item.id) !== null && _item_id !== void 0 ? _item_id : `fui-FlatTreeItem-${count++}`;
10
+ var _item_value;
9
11
  const flatTreeItem = {
10
12
  'aria-level': level,
11
13
  'aria-posinset': index + 1,
12
14
  'aria-setsize': items.length,
13
- parentId: parent === null || parent === void 0 ? void 0 : parent.id,
14
- id: (_item_id = item.id) !== null && _item_id !== void 0 ? _item_id : `fui-FlatTreeItem-${count++}`,
15
+ parentValue: parent === null || parent === void 0 ? void 0 : parent.value,
16
+ value: (_item_value = item.value) !== null && _item_value !== void 0 ? _item_value : id,
15
17
  leaf: subtree === undefined,
16
18
  ...item
17
19
  };
@@ -71,12 +73,14 @@ export const flattenTreeFromElement = (root, parent, level = 1) => {
71
73
  return children.reduce((acc, curr, index) => {
72
74
  const [content, subtree] = React.Children.toArray(curr.props.children);
73
75
  var _curr_props_id;
76
+ const id = (_curr_props_id = curr.props.id) !== null && _curr_props_id !== void 0 ? _curr_props_id : `fui-FlatTreeItem-${count++}`;
77
+ var _curr_props_value;
74
78
  const flatTreeItem = {
75
79
  'aria-level': level,
76
80
  'aria-posinset': index + 1,
77
81
  'aria-setsize': children.length,
78
- parentId: parent === null || parent === void 0 ? void 0 : parent.id,
79
- id: (_curr_props_id = curr.props.id) !== null && _curr_props_id !== void 0 ? _curr_props_id : `fui-FlatTreeItem-${count++}`,
82
+ parentValue: parent === null || parent === void 0 ? void 0 : parent.value,
83
+ value: (_curr_props_value = curr.props.value) !== null && _curr_props_value !== void 0 ? _curr_props_value : id,
80
84
  leaf: subtree === undefined,
81
85
  ...curr.props,
82
86
  children: content
@@ -1 +1 @@
1
- {"version":3,"names":["React","count","flattenTreeRecursive","items","parent","level","reduce","acc","subtree","item","index","_item_id","flatTreeItem","length","parentId","id","leaf","undefined","push","flattenTree_unstable","flattenTreeFromElement","root","children","Children","toArray","props","curr","content","_curr_props_id"],"sources":["../../src/utils/flattenTree.ts"],"sourcesContent":["import * as React from 'react';\nimport { FlatTreeItemProps } from '../hooks/useFlatTree';\nimport { TreeItemProps } from '../TreeItem';\n\nexport type NestedTreeItem = Omit<TreeItemProps, 'subtree'> & {\n subtree?: NestedTreeItem[];\n};\n\nlet count = 1;\nfunction flattenTreeRecursive(items: NestedTreeItem[], parent?: FlatTreeItemProps, level = 1): FlatTreeItemProps[] {\n return items.reduce<FlatTreeItemProps[]>((acc, { subtree, ...item }, index) => {\n const flatTreeItem: FlatTreeItemProps = {\n 'aria-level': level,\n 'aria-posinset': index + 1,\n 'aria-setsize': items.length,\n parentId: parent?.id,\n id: item.id ?? `fui-FlatTreeItem-${count++}`,\n leaf: subtree === undefined,\n ...item,\n };\n acc.push(flatTreeItem);\n if (subtree !== undefined) {\n acc.push(...flattenTreeRecursive(subtree, flatTreeItem, level + 1));\n }\n return acc;\n }, []);\n}\n\n/**\n * Converts a nested structure to a flat one which can be consumed by `useFlatTreeItems`\n * @example\n * ```tsx\n * const defaultItems = flattenTree_unstable([\n * {\n * children: <TreeItemLayout>level 1, item 1</TreeItemLayout>,\n * subtree: [\n * {\n * children: <TreeItemLayout>level 2, item 1</TreeItemLayout>,\n * },\n * {\n * children: <TreeItemLayout>level 2, item 2</TreeItemLayout>,\n * },\n * {\n * children: <TreeItemLayout>level 2, item 3</TreeItemLayout>,\n * },\n * ],\n * },\n * {\n * children: <TreeItemLayout>level 1, item 2</TreeItemLayout>,\n * subtree: [\n * {\n * children: <TreeItemLayout>level 2, item 1</TreeItemLayout>,\n * subtree: [\n * {\n * children: <TreeItemLayout>level 3, item 1</TreeItemLayout>,\n * subtree: [\n * {\n * children: <TreeItemLayout>level 4, item 1</TreeItemLayout>,\n * },\n * ],\n * },\n * ],\n * },\n * ],\n * },\n * ]);\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const flattenTree_unstable = (items: NestedTreeItem[]): FlatTreeItemProps[] => flattenTreeRecursive(items);\n\n/**\n * @internal\n */\nexport const flattenTreeFromElement = (\n root: React.ReactElement<{\n children?: React.ReactElement<TreeItemProps> | React.ReactElement<TreeItemProps>[];\n }>,\n parent?: FlatTreeItemProps,\n level = 1,\n): FlatTreeItemProps[] => {\n const children = React.Children.toArray(root.props.children) as React.ReactElement<TreeItemProps>[];\n return children.reduce<FlatTreeItemProps[]>((acc, curr, index) => {\n const [content, subtree] = React.Children.toArray(curr.props.children) as [\n React.ReactNode,\n typeof root | undefined,\n ];\n const flatTreeItem: FlatTreeItemProps = {\n 'aria-level': level,\n 'aria-posinset': index + 1,\n 'aria-setsize': children.length,\n parentId: parent?.id,\n id: curr.props.id ?? `fui-FlatTreeItem-${count++}`,\n leaf: subtree === undefined,\n ...curr.props,\n children: content,\n };\n acc.push(flatTreeItem);\n if (subtree !== undefined) {\n acc.push(...flattenTreeFromElement(subtree, flatTreeItem, level + 1));\n }\n return acc;\n }, []);\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAQvB,IAAIC,KAAA,GAAQ;AACZ,SAASC,qBAAqBC,KAAuB,EAAEC,MAA0B,EAAEC,KAAA,GAAQ,CAAC,EAAuB;EACjH,OAAOF,KAAA,CAAMG,MAAM,CAAsB,CAACC,GAAA,EAAK;IAAEC,OAAA;IAAS,GAAGC;EAAA,CAAM,EAAEC,KAAA,KAAU;QAMvEC,QAAA;IALN,MAAMC,YAAA,GAAkC;MACtC,cAAcP,KAAA;MACd,iBAAiBK,KAAA,GAAQ;MACzB,gBAAgBP,KAAA,CAAMU,MAAM;MAC5BC,QAAA,EAAUV,MAAA,aAAAA,MAAA,uBAAAA,MAAA,CAAQW,EAAE;MACpBA,EAAA,EAAI,CAAAJ,QAAA,GAAAF,IAAA,CAAKM,EAAE,cAAPJ,QAAA,cAAAA,QAAA,GAAY,oBAAmBV,KAAA,EAAQ,EAAC;MAC5Ce,IAAA,EAAMR,OAAA,KAAYS,SAAA;MAClB,GAAGR;IACL;IACAF,GAAA,CAAIW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AAA,EAAW;MACzBV,GAAA,CAAIW,IAAI,IAAIE,sBAAA,CAAuBZ,OAAA,EAASI,YAAA,EAAcP,KAAA,GAAQ;IACpE;IACA,OAAOE,GAAA;EACT,GAAG,EAAE;AACP"}
1
+ {"version":3,"names":["React","count","flattenTreeRecursive","items","parent","level","reduce","acc","subtree","item","index","_item_id","id","_item_value","flatTreeItem","length","parentValue","value","leaf","undefined","push","flattenTree_unstable","flattenTreeFromElement","root","children","Children","toArray","props","curr","content","_curr_props_id","_curr_props_value"],"sources":["../../src/utils/flattenTree.ts"],"sourcesContent":["import * as React from 'react';\nimport { FlatTreeItemProps } from '../hooks/useFlatTree';\nimport { TreeItemProps } from '../TreeItem';\n\nexport type NestedTreeItem<Value = string> = Omit<TreeItemProps<Value>, 'subtree'> & {\n subtree?: NestedTreeItem<Value>[];\n};\n\nlet count = 1;\nfunction flattenTreeRecursive<Value = string>(\n items: NestedTreeItem<Value>[],\n parent?: FlatTreeItemProps<Value>,\n level = 1,\n): FlatTreeItemProps<Value>[] {\n return items.reduce<FlatTreeItemProps<Value>[]>((acc, { subtree, ...item }, index) => {\n const id = item.id ?? `fui-FlatTreeItem-${count++}`;\n const flatTreeItem: FlatTreeItemProps<Value> = {\n 'aria-level': level,\n 'aria-posinset': index + 1,\n 'aria-setsize': items.length,\n parentValue: parent?.value,\n value: item.value ?? (id as unknown as Value),\n leaf: subtree === undefined,\n ...item,\n };\n acc.push(flatTreeItem);\n if (subtree !== undefined) {\n acc.push(...flattenTreeRecursive(subtree, flatTreeItem, level + 1));\n }\n return acc;\n }, []);\n}\n\n/**\n * Converts a nested structure to a flat one which can be consumed by `useFlatTreeItems`\n * @example\n * ```tsx\n * const defaultItems = flattenTree_unstable([\n * {\n * children: <TreeItemLayout>level 1, item 1</TreeItemLayout>,\n * subtree: [\n * {\n * children: <TreeItemLayout>level 2, item 1</TreeItemLayout>,\n * },\n * {\n * children: <TreeItemLayout>level 2, item 2</TreeItemLayout>,\n * },\n * {\n * children: <TreeItemLayout>level 2, item 3</TreeItemLayout>,\n * },\n * ],\n * },\n * {\n * children: <TreeItemLayout>level 1, item 2</TreeItemLayout>,\n * subtree: [\n * {\n * children: <TreeItemLayout>level 2, item 1</TreeItemLayout>,\n * subtree: [\n * {\n * children: <TreeItemLayout>level 3, item 1</TreeItemLayout>,\n * subtree: [\n * {\n * children: <TreeItemLayout>level 4, item 1</TreeItemLayout>,\n * },\n * ],\n * },\n * ],\n * },\n * ],\n * },\n * ]);\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const flattenTree_unstable = <Value = string>(items: NestedTreeItem<Value>[]): FlatTreeItemProps<Value>[] =>\n flattenTreeRecursive(items);\n\n/**\n * @internal\n */\nexport const flattenTreeFromElement = <Value = string>(\n root: React.ReactElement<{\n children?: React.ReactElement<TreeItemProps<Value>> | React.ReactElement<TreeItemProps<Value>>[];\n }>,\n parent?: FlatTreeItemProps<Value>,\n level = 1,\n): FlatTreeItemProps<Value>[] => {\n const children = React.Children.toArray(root.props.children) as React.ReactElement<TreeItemProps<Value>>[];\n return children.reduce<FlatTreeItemProps<Value>[]>((acc, curr, index) => {\n const [content, subtree] = React.Children.toArray(curr.props.children) as [\n React.ReactNode,\n typeof root | undefined,\n ];\n const id = curr.props.id ?? `fui-FlatTreeItem-${count++}`;\n const flatTreeItem: FlatTreeItemProps<Value> = {\n 'aria-level': level,\n 'aria-posinset': index + 1,\n 'aria-setsize': children.length,\n parentValue: parent?.value,\n value: curr.props.value ?? (id as unknown as Value),\n leaf: subtree === undefined,\n ...curr.props,\n children: content,\n };\n acc.push(flatTreeItem);\n if (subtree !== undefined) {\n acc.push(...flattenTreeFromElement(subtree, flatTreeItem, level + 1));\n }\n return acc;\n }, []);\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAQvB,IAAIC,KAAA,GAAQ;AACZ,SAASC,qBACPC,KAA8B,EAC9BC,MAAiC,EACjCC,KAAA,GAAQ,CAAC,EACmB;EAC5B,OAAOF,K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AAU;IACvE,MAAM,CAACmB,OAAA,EAASrB,OAAA,CAAQ,GAAGR,KAAA,CAAMyB,QAAQ,CAACC,OAAO,CAACE,IAAA,CAAKD,KAAK,CAACH,QAAQ;QAI1DM,cAAA;IAAX,MAAMlB,EAAA,GAAK,CAAAkB,cAAA,GAAAF,IAAA,CAAKD,KAAK,CAACf,EAAE,cAAbkB,cAAA,cAAAA,cAAA,GAAkB,oBAAmB7B,KAAA,EAAQ,EAAC;QAMhD8B,iBAAA;IALT,MAAMjB,YAAA,GAAyC;MAC7C,cAAcT,KAAA;MACd,iBAAiBK,KAAA,GAAQ;MACzB,gBAAgBc,QAAA,CAAST,MAAM;MAC/BC,WAAA,EAAaZ,MAAA,aAAAA,MAAA,uBAAAA,MAAA,CAAQa,KAAK;MAC1BA,KAAA,EAAO,CAAAc,iBAAA,GAAAH,IAAA,CAAKD,KAAK,CAACV,KAAK,cAAhBc,iBAAA,cAAAA,iBAAA,GAAqBnB,EAAuB;MACnDM,IAAA,EAAMV,OAAA,KAAYW,SAAA;MAClB,GAAGS,IAAA,CAAKD,KAAK;MACbH,QAAA,EAAUK;IACZ;IACAtB,GAAA,CAAIa,IAAI,CAACN,YAAA;IACT,IAAIN,OAAA,KAAYW,SAAA,EAAW;MACzBZ,GAAA,CAAIa,IAAI,IAAIE,sBAAA,CAAuBd,OAAA,EAASM,YAAA,EAAcT,KAAA,GAAQ;IACpE;IACA,OAAOE,GAAA;EACT,GAAG,EAAE;AACP"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/components/TreeItem/TreeItem.js"],"sourcesContent":["import * as React from 'react';\nimport { useTreeItem_unstable } from './useTreeItem';\nimport { renderTreeItem_unstable } from './renderTreeItem';\nimport { useTreeItemStyles_unstable } from './useTreeItemStyles';\nimport { useTreeItemContextValues_unstable } from './useTreeItemContextValues';\n/**\n * The `TreeItem` component represents a single item in a tree.\n * It expects a certain order of children to work properly: the first child should be the node itself,\n * and the second child should be a nested subtree in the form of another Tree component or a standalone TreeItem.\n * This order follows the same order as document traversal for the TreeWalker API in JavaScript:\n * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker.\n * The content and layout of a TreeItem can be defined using the TreeItemLayout or TreeItemPersonaLayout component,\n * which should be used as a direct child of TreeItem.\n *\n * When a TreeItem has nsted child subtree, an expand/collapse control is displayed,\n * allowing the user to show or hide the children.\n */\nexport const TreeItem = /*#__PURE__*/React.forwardRef((props, ref) => {\n const state = useTreeItem_unstable(props, ref);\n useTreeItemStyles_unstable(state);\n const contextValues = useTreeItemContextValues_unstable(state);\n return renderTreeItem_unstable(state, contextValues);\n});\nTreeItem.displayName = 'TreeItem';\n//# sourceMappingURL=TreeItem.js.map"],"names":["TreeItem","React","forwardRef","props","ref","state","useTreeItem_unstable","useTreeItemStyles_unstable","contextValues","useTreeItemContextValues_unstable","renderTreeItem_unstable","displayName"],"mappings":";;;;+BAiBaA;;aAAAA;;;6DAjBU;6BACc;gCACG;mCACG;0CACO;AAa3C,MAAMA,WAAW,WAAW,GAAEC,OAAMC,UAAU,CAAC,CAACC,OAAOC,MAAQ;IACpE,MAAMC,QAAQC,IAAAA,iCAAoB,EAACH,OAAOC;IAC1CG,IAAAA,6CAA0B,EAACF;IAC3B,MAAMG,gBAAgBC,IAAAA,2DAAiC,EAACJ;IACxD,OAAOK,IAAAA,uCAAuB,EAACL,OAAOG;AACxC;AACAR,SAASW,WAAW,GAAG,YACvB,oCAAoC"}
1
+ {"version":3,"sources":["../../../lib/components/TreeItem/TreeItem.js"],"sourcesContent":["import * as React from 'react';\nimport { useTreeItem_unstable } from './useTreeItem';\nimport { renderTreeItem_unstable } from './renderTreeItem';\nimport { useTreeItemStyles_unstable } from './useTreeItemStyles';\nimport { useTreeItemContextValues_unstable } from './useTreeItemContextValues';\n/**\n * The `TreeItem` component represents a single item in a tree.\n * It expects a certain order of children to work properly: the first child should be the node itself,\n * and the second child should be a nested subtree in the form of another Tree component or a standalone TreeItem.\n * This order follows the same order as document traversal for the TreeWalker API in JavaScript:\n * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker.\n * The content and layout of a TreeItem can be defined using the TreeItemLayout or TreeItemPersonaLayout component,\n * which should be used as a direct child of TreeItem.\n *\n * When a TreeItem has nested child subtree, an expand/collapse control is displayed,\n * allowing the user to show or hide the children.\n */\nexport const TreeItem = /*#__PURE__*/React.forwardRef((props, ref) => {\n const state = useTreeItem_unstable(props, ref);\n useTreeItemStyles_unstable(state);\n const contextValues = useTreeItemContextValues_unstable(state);\n return renderTreeItem_unstable(state, contextValues);\n});\nTreeItem.displayName = 'TreeItem';\n//# sourceMappingURL=TreeItem.js.map"],"names":["TreeItem","React","forwardRef","props","ref","state","useTreeItem_unstable","useTreeItemStyles_unstable","contextValues","useTreeItemContextValues_unstable","renderTreeItem_unstable","displayName"],"mappings":";;;;+BAiBaA;;aAAAA;;;6DAjBU;6BACc;gCACG;mCACG;0CACO;AAa3C,MAAMA,WAAW,WAAW,GAAEC,OAAMC,UAAU,CAAC,CAACC,OAAOC,MAAQ;IACpE,MAAMC,QAAQC,IAAAA,iCAAoB,EAACH,OAAOC;IAC1CG,IAAAA,6CAA0B,EAACF;IAC3B,MAAMG,gBAAgBC,IAAAA,2DAAiC,EAACJ;IACxD,OAAOK,IAAAA,uCAAuB,EAACL,OAAOG;AACxC;AACAR,SAASW,WAAW,GAAG,YACvB,oCAAoC"}
@@ -16,15 +16,15 @@ const _keyboardKeys = require("@fluentui/keyboard-keys");
16
16
  const _reactPortal = require("@fluentui/react-portal");
17
17
  const _index = require("../../contexts/index");
18
18
  const _tokens = require("../../utils/tokens");
19
- const useTreeItem_unstable = (props, ref)=>{
19
+ function useTreeItem_unstable(props, ref) {
20
20
  const [children, subtreeChildren] = _react.Children.toArray(props.children);
21
21
  const contextLevel = (0, _index.useTreeContext_unstable)((ctx)=>ctx.level);
22
- const { content , subtree , expandIcon , leaf: isLeaf = subtreeChildren === undefined , actions , as ='div' , onClick , onKeyDown , ['aria-level']: level = contextLevel , ...rest } = props;
22
+ const id = (0, _reactUtilities.useId)('fui-TreeItem-', props.id);
23
+ const { content , subtree , expandIcon , leaf: isLeaf = subtreeChildren === undefined , actions , as ='div' , onClick , onKeyDown , ['aria-level']: level = contextLevel , value =id , ...rest } = props;
23
24
  const requestOpenChange = (0, _index.useTreeContext_unstable)((ctx)=>ctx.requestOpenChange);
24
25
  const requestNavigation = (0, _index.useTreeContext_unstable)((ctx)=>ctx.requestNavigation);
25
- const id = (0, _reactUtilities.useId)('fui-TreeItem-', props.id);
26
26
  const isBranch = !isLeaf;
27
- const open = (0, _index.useTreeContext_unstable)((ctx)=>isBranch && ctx.openItems.has(id));
27
+ const open = (0, _index.useTreeContext_unstable)((ctx)=>isBranch && ctx.openItems.has(value));
28
28
  const { dir , targetDocument } = (0, _reactSharedContexts.useFluent_unstable)();
29
29
  const expandIconRotation = open ? 90 : dir !== 'rtl' ? 0 : 180;
30
30
  const actionsRef = _react.useRef(null);
@@ -34,6 +34,7 @@ const useTreeItem_unstable = (props, ref)=>{
34
34
  if (!open && isBranch) {
35
35
  return requestOpenChange({
36
36
  event,
37
+ value,
37
38
  open: true,
38
39
  type: _tokens.treeDataTypes.arrowRight,
39
40
  target: event.currentTarget
@@ -42,6 +43,7 @@ const useTreeItem_unstable = (props, ref)=>{
42
43
  if (open && isBranch) {
43
44
  return requestNavigation({
44
45
  event,
46
+ value,
45
47
  type: _tokens.treeDataTypes.arrowRight,
46
48
  target: event.currentTarget
47
49
  });
@@ -51,6 +53,7 @@ const useTreeItem_unstable = (props, ref)=>{
51
53
  if (open && isBranch) {
52
54
  return requestOpenChange({
53
55
  event,
56
+ value,
54
57
  open: false,
55
58
  type: _tokens.treeDataTypes.arrowLeft,
56
59
  target: event.currentTarget
@@ -59,6 +62,7 @@ const useTreeItem_unstable = (props, ref)=>{
59
62
  if (!open && level > 1) {
60
63
  return requestNavigation({
61
64
  event,
65
+ value,
62
66
  target: event.currentTarget,
63
67
  type: _tokens.treeDataTypes.arrowLeft
64
68
  });
@@ -67,6 +71,7 @@ const useTreeItem_unstable = (props, ref)=>{
67
71
  const handleEnter = (event)=>{
68
72
  requestOpenChange({
69
73
  event,
74
+ value,
70
75
  open: isLeaf ? open : !open,
71
76
  type: _tokens.treeDataTypes.enter,
72
77
  target: event.currentTarget
@@ -85,12 +90,14 @@ const useTreeItem_unstable = (props, ref)=>{
85
90
  const isFromExpandIcon = expandIconRef.current && (0, _reactPortal.elementContains)(expandIconRef.current, event.target);
86
91
  requestOpenChange({
87
92
  event,
93
+ value,
88
94
  open: isLeaf ? open : !open,
89
95
  type: isFromExpandIcon ? _tokens.treeDataTypes.expandIconClick : _tokens.treeDataTypes.click,
90
96
  target: event.currentTarget
91
97
  });
92
98
  requestNavigation({
93
99
  event,
100
+ value,
94
101
  target: event.currentTarget,
95
102
  type: _tokens.treeDataTypes.click
96
103
  });
@@ -113,24 +120,28 @@ const useTreeItem_unstable = (props, ref)=>{
113
120
  case _keyboardKeys.End:
114
121
  return requestNavigation({
115
122
  event,
123
+ value,
116
124
  type: _tokens.treeDataTypes.end,
117
125
  target: event.currentTarget
118
126
  });
119
127
  case _keyboardKeys.Home:
120
128
  return requestNavigation({
121
129
  event,
130
+ value,
122
131
  type: _tokens.treeDataTypes.home,
123
132
  target: event.currentTarget
124
133
  });
125
134
  case _keyboardKeys.ArrowUp:
126
135
  return requestNavigation({
127
136
  event,
137
+ value,
128
138
  type: _tokens.treeDataTypes.arrowUp,
129
139
  target: event.currentTarget
130
140
  });
131
141
  case _keyboardKeys.ArrowDown:
132
142
  return requestNavigation({
133
143
  event,
144
+ value,
134
145
  type: _tokens.treeDataTypes.arrowDown,
135
146
  target: event.currentTarget
136
147
  });
@@ -139,6 +150,7 @@ const useTreeItem_unstable = (props, ref)=>{
139
150
  if (isTypeAheadCharacter) {
140
151
  return requestNavigation({
141
152
  event,
153
+ value,
142
154
  target: event.currentTarget,
143
155
  type: _tokens.treeDataTypes.typeAhead
144
156
  });
@@ -232,6 +244,6 @@ const useTreeItem_unstable = (props, ref)=>{
232
244
  }
233
245
  })
234
246
  };
235
- }; //# sourceMappingURL=useTreeItem.js.map
247
+ } //# sourceMappingURL=useTreeItem.js.map
236
248
 
237
249
  //# sourceMappingURL=useTreeItem.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/components/TreeItem/useTreeItem.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, isResolvedShorthand, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport { ChevronRight12Regular } from '@fluentui/react-icons';\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { expandIconInlineStyles } from './useTreeItemStyles';\nimport { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Home } from '@fluentui/keyboard-keys';\nimport { useMergedRefs } from '@fluentui/react-utilities';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useTreeContext_unstable } from '../../contexts/index';\nimport { treeDataTypes } from '../../utils/tokens';\n/**\n * Create the state required to render TreeItem.\n *\n * The returned state can be modified with hooks such as useTreeItemStyles_unstable,\n * before being passed to renderTreeItem_unstable.\n *\n * @param props - props from this instance of TreeItem\n * @param ref - reference to root HTMLElement of TreeItem\n */\nexport const useTreeItem_unstable = (props, ref) => {\n const [children, subtreeChildren] = React.Children.toArray(props.children);\n const contextLevel = useTreeContext_unstable(ctx => ctx.level);\n const {\n content,\n subtree,\n expandIcon,\n leaf: isLeaf = subtreeChildren === undefined,\n actions,\n as = 'div',\n onClick,\n onKeyDown,\n ['aria-level']: level = contextLevel,\n ...rest\n } = props;\n const requestOpenChange = useTreeContext_unstable(ctx => ctx.requestOpenChange);\n const requestNavigation = useTreeContext_unstable(ctx => ctx.requestNavigation);\n const id = useId('fui-TreeItem-', props.id);\n const isBranch = !isLeaf;\n const open = useTreeContext_unstable(ctx => isBranch && ctx.openItems.has(id));\n const {\n dir,\n targetDocument\n } = useFluent_unstable();\n const expandIconRotation = open ? 90 : dir !== 'rtl' ? 0 : 180;\n const actionsRef = React.useRef(null);\n const expandIconRef = React.useRef(null);\n const subtreeRef = React.useRef(null);\n const handleArrowRight = event => {\n if (!open && isBranch) {\n return requestOpenChange({\n event,\n open: true,\n type: treeDataTypes.arrowRight,\n target: event.currentTarget\n });\n }\n if (open && isBranch) {\n return requestNavigation({\n event,\n type: treeDataTypes.arrowRight,\n target: event.currentTarget\n });\n }\n };\n const handleArrowLeft = event => {\n if (open && isBranch) {\n return requestOpenChange({\n event,\n open: false,\n type: treeDataTypes.arrowLeft,\n target: event.currentTarget\n });\n }\n if (!open && level > 1) {\n return requestNavigation({\n event,\n target: event.currentTarget,\n type: treeDataTypes.arrowLeft\n });\n }\n };\n const handleEnter = event => {\n requestOpenChange({\n event,\n open: isLeaf ? open : !open,\n type: treeDataTypes.enter,\n target: event.currentTarget\n });\n };\n const handleClick = useEventCallback(event => {\n onClick === null || onClick === void 0 ? void 0 : onClick(event);\n const isEventFromActions = actionsRef.current && elementContains(actionsRef.current, event.target);\n if (isEventFromActions) {\n return;\n }\n const isEventFromSubtree = subtreeRef.current && elementContains(subtreeRef.current, event.target);\n if (isEventFromSubtree) {\n return;\n }\n const isFromExpandIcon = expandIconRef.current && elementContains(expandIconRef.current, event.target);\n requestOpenChange({\n event,\n open: isLeaf ? open : !open,\n type: isFromExpandIcon ? treeDataTypes.expandIconClick : treeDataTypes.click,\n target: event.currentTarget\n });\n requestNavigation({\n event,\n target: event.currentTarget,\n type: treeDataTypes.click\n });\n });\n const handleKeyDown = useEventCallback(event => {\n onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);\n if (event.currentTarget !== event.target) {\n return;\n }\n if (event.isDefaultPrevented()) {\n return;\n }\n switch (event.key) {\n case Enter:\n return handleEnter(event);\n case ArrowRight:\n return handleArrowRight(event);\n case ArrowLeft:\n return handleArrowLeft(event);\n case End:\n return requestNavigation({\n event,\n type: treeDataTypes.end,\n target: event.currentTarget\n });\n case Home:\n return requestNavigation({\n event,\n type: treeDataTypes.home,\n target: event.currentTarget\n });\n case ArrowUp:\n return requestNavigation({\n event,\n type: treeDataTypes.arrowUp,\n target: event.currentTarget\n });\n case ArrowDown:\n return requestNavigation({\n event,\n type: treeDataTypes.arrowDown,\n target: event.currentTarget\n });\n }\n const isTypeAheadCharacter = event.key.length === 1 && event.key.match(/\\w/) && !event.altKey && !event.ctrlKey && !event.metaKey;\n if (isTypeAheadCharacter) {\n return requestNavigation({\n event,\n target: event.currentTarget,\n type: treeDataTypes.typeAhead\n });\n }\n });\n const [isActionsVisible, setActionsVisible] = React.useState(false);\n const showActions = useEventCallback(event => {\n const isEventFromSubtree = subtreeRef.current && elementContains(subtreeRef.current, event.target);\n if (!isEventFromSubtree) {\n setActionsVisible(true);\n }\n });\n const hideActions = useEventCallback(event => {\n const isEventFromSubtree = subtreeRef.current && elementContains(subtreeRef.current, event.target);\n if (!isEventFromSubtree) {\n setActionsVisible(false);\n }\n });\n // Listens to focusout event on the document to ensure treeitem actions visibility on portal scenarios\n // TODO: find a better way to ensure this behavior\n React.useEffect(() => {\n if (actionsRef.current) {\n const handleFocusOut = event => {\n setActionsVisible(elementContains(actionsRef.current, event.relatedTarget));\n };\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('focusout', handleFocusOut, {\n passive: true\n });\n return () => {\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('focusout', handleFocusOut);\n };\n }\n }, [targetDocument]);\n return {\n isLeaf,\n open,\n level,\n buttonSize: 'small',\n isActionsVisible: actions ? isActionsVisible : false,\n components: {\n content: 'div',\n root: 'div',\n expandIcon: 'span',\n actions: 'span',\n subtree: 'span'\n },\n subtree: resolveShorthand(subtree, {\n required: Boolean(subtreeChildren),\n defaultProps: {\n children: subtreeChildren,\n ref: useMergedRefs(subtreeRef, isResolvedShorthand(subtree) ? subtree.ref : undefined)\n }\n }),\n content: resolveShorthand(content, {\n required: true,\n defaultProps: {\n children\n }\n }),\n root: getNativeElementProps(as, {\n tabIndex: -1,\n ...rest,\n id,\n ref,\n children: null,\n 'aria-level': level,\n 'aria-expanded': isBranch ? open : undefined,\n role: 'treeitem',\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n onMouseOver: actions ? showActions : undefined,\n onFocus: actions ? showActions : undefined,\n onMouseOut: actions ? hideActions : undefined,\n onBlur: actions ? hideActions : undefined\n }),\n expandIcon: resolveShorthand(expandIcon, {\n required: isBranch,\n defaultProps: {\n children: /*#__PURE__*/React.createElement(ChevronRight12Regular, {\n style: expandIconInlineStyles[expandIconRotation]\n }),\n 'aria-hidden': true,\n ref: useMergedRefs(isResolvedShorthand(expandIcon) ? expandIcon.ref : undefined, expandIconRef)\n }\n }),\n actions: resolveShorthand(actions, {\n defaultProps: {\n ref: useMergedRefs(isResolvedShorthand(actions) ? actions.ref : undefined, actionsRef)\n }\n })\n };\n};\n//# sourceMappingURL=useTreeItem.js.map"],"names":["useTreeItem_unstable","props","ref","children","subtreeChildren","React","Children","toArray","contextLevel","useTreeContext_unstable","ctx","level","content","subtree","expandIcon","leaf","isLeaf","undefined","actions","as","onClick","onKeyDown","rest","requestOpenChange","requestNavigation","id","useId","isBranch","open","openItems","has","dir","targetDocument","useFluent_unstable","expandIconRotation","actionsRef","useRef","expandIconRef","subtreeRef","handleArrowRight","event","type","treeDataTypes","arrowRight","target","currentTarget","handleArrowLeft","arrowLeft","handleEnter","enter","handleClick","useEventCallback","isEventFromActions","current","elementContains","isEventFromSubtree","isFromExpandIcon","expandIconClick","click","handleKeyDown","isDefaultPrevented","key","Enter","ArrowRight","ArrowLeft","End","end","Home","home","ArrowUp","arrowUp","ArrowDown","arrowDown","isTypeAheadCharacter","length","match","altKey","ctrlKey","metaKey","typeAhead","isActionsVisible","setActionsVisible","useState","showActions","hideActions","useEffect","handleFocusOut","relatedTarget","addEventListener","passive","removeEventListener","buttonSize","components","root","resolveShorthand","required","Boolean","defaultProps","useMergedRefs","isResolvedShorthand","getNativeElementProps","tabIndex","role","onMouseOver","onFocus","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AAC5E,mBAAmB;gBACnD;gBACA,eAAe,IAAI;gBACnBhC,KAAKgG,IAAAA,6BAAa,EAACC,IAAAA,mCAAmB,EAACrF,cAAcA,WAAWZ,GAAG,GAAGe,SAAS,EAAEoB;YACnF;QACF;QACAnB,SAAS4E,IAAAA,gCAAgB,EAAC5E,SAAS;YACjC+E,cAAc;gBACZ/F,KAAKgG,IAAAA,6BAAa,EAACC,IAAAA,mCAAmB,EAACjF,WAAWA,QAAQhB,GAAG,GAAGe,SAAS,EAAEkB;YAC7E;QACF;IACF;AACF,GACA,uCAAuC"}
1
+ {"version":3,"sources":["../../../lib/components/TreeItem/useTreeItem.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, isResolvedShorthand, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport { ChevronRight12Regular } from '@fluentui/react-icons';\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { expandIconInlineStyles } from './useTreeItemStyles';\nimport { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Home } from '@fluentui/keyboard-keys';\nimport { useMergedRefs } from '@fluentui/react-utilities';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useTreeContext_unstable } from '../../contexts/index';\nimport { treeDataTypes } from '../../utils/tokens';\n/**\n * Create the state required to render TreeItem.\n *\n * The returned state can be modified with hooks such as useTreeItemStyles_unstable,\n * before being passed to renderTreeItem_unstable.\n *\n * @param props - props from this instance of TreeItem\n * @param ref - reference to root HTMLElement of TreeItem\n */\nexport function useTreeItem_unstable(props, ref) {\n const [children, subtreeChildren] = React.Children.toArray(props.children);\n const contextLevel = useTreeContext_unstable(ctx => ctx.level);\n const id = useId('fui-TreeItem-', props.id);\n const {\n content,\n subtree,\n expandIcon,\n leaf: isLeaf = subtreeChildren === undefined,\n actions,\n as = 'div',\n onClick,\n onKeyDown,\n ['aria-level']: level = contextLevel,\n value = id,\n ...rest\n } = props;\n const requestOpenChange = useTreeContext_unstable(ctx => ctx.requestOpenChange);\n const requestNavigation = useTreeContext_unstable(ctx => ctx.requestNavigation);\n const isBranch = !isLeaf;\n const open = useTreeContext_unstable(ctx => isBranch && ctx.openItems.has(value));\n const {\n dir,\n targetDocument\n } = useFluent_unstable();\n const expandIconRotation = open ? 90 : dir !== 'rtl' ? 0 : 180;\n const actionsRef = React.useRef(null);\n const expandIconRef = React.useRef(null);\n const subtreeRef = React.useRef(null);\n const handleArrowRight = event => {\n if (!open && isBranch) {\n return requestOpenChange({\n event,\n value,\n open: true,\n type: treeDataTypes.arrowRight,\n target: event.currentTarget\n });\n }\n if (open && isBranch) {\n return requestNavigation({\n event,\n value,\n type: treeDataTypes.arrowRight,\n target: event.currentTarget\n });\n }\n };\n const handleArrowLeft = event => {\n if (open && isBranch) {\n return requestOpenChange({\n event,\n value,\n open: false,\n type: treeDataTypes.arrowLeft,\n target: event.currentTarget\n });\n }\n if (!open && level > 1) {\n return requestNavigation({\n event,\n value,\n target: event.currentTarget,\n type: treeDataTypes.arrowLeft\n });\n }\n };\n const handleEnter = event => {\n requestOpenChange({\n event,\n value,\n open: isLeaf ? open : !open,\n type: treeDataTypes.enter,\n target: event.currentTarget\n });\n };\n const handleClick = useEventCallback(event => {\n onClick === null || onClick === void 0 ? void 0 : onClick(event);\n const isEventFromActions = actionsRef.current && elementContains(actionsRef.current, event.target);\n if (isEventFromActions) {\n return;\n }\n const isEventFromSubtree = subtreeRef.current && elementContains(subtreeRef.current, event.target);\n if (isEventFromSubtree) {\n return;\n }\n const isFromExpandIcon = expandIconRef.current && elementContains(expandIconRef.current, event.target);\n requestOpenChange({\n event,\n value,\n open: isLeaf ? open : !open,\n type: isFromExpandIcon ? treeDataTypes.expandIconClick : treeDataTypes.click,\n target: event.currentTarget\n });\n requestNavigation({\n event,\n value,\n target: event.currentTarget,\n type: treeDataTypes.click\n });\n });\n const handleKeyDown = useEventCallback(event => {\n onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);\n if (event.currentTarget !== event.target) {\n return;\n }\n if (event.isDefaultPrevented()) {\n return;\n }\n switch (event.key) {\n case Enter:\n return handleEnter(event);\n case ArrowRight:\n return handleArrowRight(event);\n case ArrowLeft:\n return handleArrowLeft(event);\n case End:\n return requestNavigation({\n event,\n value,\n type: treeDataTypes.end,\n target: event.currentTarget\n });\n case Home:\n return requestNavigation({\n event,\n value,\n type: treeDataTypes.home,\n target: event.currentTarget\n });\n case ArrowUp:\n return requestNavigation({\n event,\n value,\n type: treeDataTypes.arrowUp,\n target: event.currentTarget\n });\n case ArrowDown:\n return requestNavigation({\n event,\n value,\n type: treeDataTypes.arrowDown,\n target: event.currentTarget\n });\n }\n const isTypeAheadCharacter = event.key.length === 1 && event.key.match(/\\w/) && !event.altKey && !event.ctrlKey && !event.metaKey;\n if (isTypeAheadCharacter) {\n return requestNavigation({\n event,\n value,\n target: event.currentTarget,\n type: treeDataTypes.typeAhead\n });\n }\n });\n const [isActionsVisible, setActionsVisible] = React.useState(false);\n const showActions = useEventCallback(event => {\n const isEventFromSubtree = subtreeRef.current && elementContains(subtreeRef.current, event.target);\n if (!isEventFromSubtree) {\n setActionsVisible(true);\n }\n });\n const hideActions = useEventCallback(event => {\n const isEventFromSubtree = subtreeRef.current && elementContains(subtreeRef.current, event.target);\n if (!isEventFromSubtree) {\n setActionsVisible(false);\n }\n });\n // Listens to focusout event on the document to ensure treeitem actions visibility on portal scenarios\n // TODO: find a better way to ensure this behavior\n React.useEffect(() => {\n if (actionsRef.current) {\n const handleFocusOut = event => {\n setActionsVisible(elementContains(actionsRef.current, event.relatedTarget));\n };\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('focusout', handleFocusOut, {\n passive: true\n });\n return () => {\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('focusout', handleFocusOut);\n };\n }\n }, [targetDocument]);\n return {\n isLeaf,\n open,\n level,\n buttonSize: 'small',\n isActionsVisible: actions ? isActionsVisible : false,\n components: {\n content: 'div',\n root: 'div',\n expandIcon: 'span',\n actions: 'span',\n subtree: 'span'\n },\n subtree: resolveShorthand(subtree, {\n required: Boolean(subtreeChildren),\n defaultProps: {\n children: subtreeChildren,\n ref: useMergedRefs(subtreeRef, isResolvedShorthand(subtree) ? subtree.ref : undefined)\n }\n }),\n content: resolveShorthand(content, {\n required: true,\n defaultProps: {\n children\n }\n }),\n root: getNativeElementProps(as, {\n tabIndex: -1,\n ...rest,\n id,\n ref,\n children: null,\n 'aria-level': level,\n 'aria-expanded': isBranch ? open : undefined,\n role: 'treeitem',\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n onMouseOver: actions ? showActions : undefined,\n onFocus: actions ? showActions : undefined,\n onMouseOut: actions ? hideActions : undefined,\n onBlur: actions ? hideActions : undefined\n }),\n expandIcon: resolveShorthand(expandIcon, {\n required: isBranch,\n defaultProps: {\n children: /*#__PURE__*/React.createElement(ChevronRight12Regular, {\n style: expandIconInlineStyles[expandIconRotation]\n }),\n 'aria-hidden': true,\n ref: useMergedRefs(isResolvedShorthand(expandIcon) ? expandIcon.ref : undefined, expandIconRef)\n }\n }),\n actions: resolveShorthand(actions, {\n defaultProps: {\n ref: useMergedRefs(isResolvedShorthand(actions) ? actions.ref : undefined, actionsRef)\n }\n })\n };\n}\n//# sourceMappingURL=useTreeItem.js.map"],"names":["useTreeItem_unstable","props","ref","children","subtreeChildren","React","Children","toArray","contextLevel","useTreeContext_unstable","ctx","level","id","useId","content","subtree","expandIcon","leaf","isLeaf","undefined","actions","as","onClick","onKeyDown","value","rest","requestOpenChange","requestNavigation","isBranch","open","openItems","has","dir","targetDocument","useFluent_unstable","expandIconRotation","actionsRef","useRef","expandIconRef","subtreeRef","handleArrowRight","event","type","treeDataTypes","arrowRight","target","currentTarget","handleArrowLeft","arrowLeft","handleEnter","enter","handleClick","useEventCallback","isEventFromActions","current","elementContains","isEventFromSubtree","isFromExpandIcon","expandIconClick","click","handleKeyDown","isDefaultPrevented","key","Enter","ArrowRight","ArrowLeft","End","end","Home","home","ArrowUp","arrowUp","ArrowDown","arrowDown","isTypeAheadCharacter","length","match","altKey","ctrlKey","metaKey","typeAhead","isActionsVisible","setActionsVisible","useState","showActions","hideActions","useEffect","handleFocusOut","relatedTarget","addEventListener","passive","removeEventListener","buttonSize","components","root","resolveShorthand","required","Boolean","defaultProps","useMergedRefs","isResolvedShorthand","getNativeElementProps","tabIndex","role","onMouseOver","onFocus","onMouseOut","onBlur","createElement","ChevronRight12Regular","style","expandIconInlineStyles"],"mappings":";;;;+BAoBgBA;;aAAAA;;;6DApBO;gCAC6D;4BAC9C;qCACH;mCAEI;8BACqC;6BAE5C;uBACQ;wBACV;AAUvB,SAASA,qBAAqBC,KAAK,EAAEC,GAAG,EAAE;IAC/C,MAAM,CAACC,UAAUC,gBAAgB,GAAGC,OAAMC,QAAQ,CAACC,OAAO,CAACN,MAAME,QAAQ;IACzE,MAAMK,eAAeC,IAAAA,8BAAuB,EAACC,CAAAA,MAAOA,IAAIC,KAAK;IAC7D,MAAMC,KAAKC,IAAAA,qBAAK,EAAC,iBAAiBZ,MAAMW,EAAE;IAC1C,MAAM,EACJE,QAAO,EACPC,QAAO,EACPC,WAAU,EACVC,MAAMC,SAASd,oBAAoBe,SAAS,CAAA,EAC5CC,QAAO,EACPC,IAAK,MAAK,EACVC,QAAO,EACPC,UAAS,EACT,CAAC,aAAa,EAAEZ,QAAQH,YAAY,CAAA,EACpCgB,OAAQZ,GAAE,EACV,GAAGa,MACJ,GAAGxB;IACJ,MAAMyB,oBAAoBjB,IAAAA,8BAAuB,EAACC,CAAAA,MAAOA,IAAIgB,iBAAiB;IAC9E,MAAMC,oBAAoBlB,IAAAA,8BAAuB,EAACC,CAAAA,MAAOA,IAAIiB,iBAAiB;IAC9E,MAAMC,WAAW,CAACV;IAClB,MAAMW,OAAOpB,IAAAA,8BAAuB,EAACC,CAAAA,MAAOkB,YAAYlB,IAAIoB,SAAS,CAACC,GAAG,CAACP;IAC1E,MAAM,EACJQ,I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,OAAOV,SAAS;YAC5CoF,MAAM;YACNjF,SAAS6B;YACT5B,WAAWqC;YACX4C,aAAapF,UAAUgE,cAAcjE,SAAS;YAC9CsF,SAASrF,UAAUgE,cAAcjE,SAAS;YAC1CuF,YAAYtF,UAAUiE,cAAclE,SAAS;YAC7CwF,QAAQvF,UAAUiE,cAAclE,SAAS;QAC3C;QACAH,YAAY+E,IAAAA,gCAAgB,EAAC/E,YAAY;YACvCgF,UAAUpE;YACVsE,cAAc;gBACZ/F,UAAU,WAAW,GAAEE,OAAMuG,aAAa,CAACC,iCAAqB,EAAE;oBAChEC,OAAOC,yCAAsB,CAAC5E,mBAAmB;gBACnD;gBACA,eAAe,IAAI;gBACnBjC,KAAKiG,IAAAA,6BAAa,EAACC,IAAAA,mCAAmB,EAACpF,cAAcA,WAAWd,GAAG,GAAGiB,SAAS,EAAEmB;YACnF;QACF;QACAlB,SAAS2E,IAAAA,gCAAgB,EAAC3E,SAAS;YACjC8E,cAAc;gBACZhG,KAAKiG,IAAAA,6BAAa,EAACC,IAAAA,mCAAmB,EAAChF,WAAWA,QAAQlB,GAAG,GAAGiB,SAAS,EAAEiB;YAC7E;QACF;IACF;AACF,EACA,uCAAuC"}
@@ -11,12 +11,12 @@ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
11
  const _reactUtilities = require("@fluentui/react-utilities");
12
12
  const _treeItemContext = require("../../contexts/treeItemContext");
13
13
  const useTreeItemLayout_unstable = (props, ref)=>{
14
- const { iconAfter , iconBefore , aside , as ='div' } = props;
14
+ const { iconAfter , iconBefore , aside , as ='span' } = props;
15
15
  const treeItemContext = (0, _treeItemContext.useTreeItemContext_unstable)();
16
16
  return {
17
17
  ...treeItemContext,
18
18
  components: {
19
- root: 'div',
19
+ root: 'span',
20
20
  iconBefore: 'span',
21
21
  iconAfter: 'span',
22
22
  aside: 'span'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/components/TreeItemLayout/useTreeItemLayout.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\nimport { useTreeItemContext_unstable } from '../../contexts/treeItemContext';\n/**\n * Create the state required to render TreeItemLayout.\n *\n * The returned state can be modified with hooks such as useTreeItemLayoutStyles_unstable,\n * before being passed to renderTreeItemLayout_unstable.\n *\n * @param props - props from this instance of TreeItemLayout\n * @param ref - reference to root HTMLElement of TreeItemLayout\n */\nexport const useTreeItemLayout_unstable = (props, ref) => {\n const {\n iconAfter,\n iconBefore,\n aside,\n as = 'div'\n } = props;\n const treeItemContext = useTreeItemContext_unstable();\n return {\n ...treeItemContext,\n components: {\n root: 'div',\n iconBefore: 'span',\n iconAfter: 'span',\n aside: 'span'\n },\n root: getNativeElementProps(as, {\n ...props,\n ref\n }),\n iconBefore: resolveShorthand(iconBefore, {\n defaultProps: {\n 'aria-hidden': true\n }\n }),\n iconAfter: resolveShorthand(iconAfter, {\n defaultProps: {\n 'aria-hidden': true\n }\n }),\n aside: resolveShorthand(aside, {\n defaultProps: {\n 'aria-hidden': true\n }\n })\n };\n};\n//# sourceMappingURL=useTreeItemLayout.js.map"],"names":["useTreeItemLayout_unstable","props","ref","iconAfter","iconBefore","aside","as","treeItemContext","useTreeItemContext_unstable","components","root","getNativeElementProps","resolveShorthand","defaultProps"],"mappings":";;;;+BAYaA;;aAAAA;;;6DAZU;gCACiC;iCACZ;AAUrC,MAAMA,6BAA6B,CAACC,OAAOC,MAAQ;IACxD,MAAM,EACJC,UAAS,EACTC,WAAU,EACVC,MAAK,EACLC,IAAK,MAAK,EACX,GAAGL;IACJ,MAAMM,kBAAkBC,IAAAA,4CAA2B;IACnD,OAAO;QACL,GAAGD,eAAe;QAClBE,YAAY;YACVC,MAAM;YACNN,YAAY;YACZD,WAAW;YACXE,OAAO;QACT;QACAK,MAAMC,IAAAA,qCAAqB,EAACL,IAAI;YAC9B,GAAGL,KAAK;YACRC;QACF;QACAE,YAAYQ,IAAAA,gCAAgB,EAACR,YAAY;YACvCS,cAAc;gBACZ,eAAe,IAAI;YACrB;QACF;QACAV,WAAWS,IAAAA,gCAAgB,EAACT,WAAW;YACrCU,cAAc;gBACZ,eAAe,IAAI;YACrB;QACF;QACAR,OAAOO,IAAAA,gCAAgB,EAACP,OAAO;YAC7BQ,cAAc;gBACZ,eAAe,IAAI;YACrB;QACF;IACF;AACF,GACA,6CAA6C"}
1
+ {"version":3,"sources":["../../../lib/components/TreeItemLayout/useTreeItemLayout.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\nimport { useTreeItemContext_unstable } from '../../contexts/treeItemContext';\n/**\n * Create the state required to render TreeItemLayout.\n *\n * The returned state can be modified with hooks such as useTreeItemLayoutStyles_unstable,\n * before being passed to renderTreeItemLayout_unstable.\n *\n * @param props - props from this instance of TreeItemLayout\n * @param ref - reference to root HTMLElement of TreeItemLayout\n */\nexport const useTreeItemLayout_unstable = (props, ref) => {\n const {\n iconAfter,\n iconBefore,\n aside,\n as = 'span'\n } = props;\n const treeItemContext = useTreeItemContext_unstable();\n return {\n ...treeItemContext,\n components: {\n root: 'span',\n iconBefore: 'span',\n iconAfter: 'span',\n aside: 'span'\n },\n root: getNativeElementProps(as, {\n ...props,\n ref\n }),\n iconBefore: resolveShorthand(iconBefore, {\n defaultProps: {\n 'aria-hidden': true\n }\n }),\n iconAfter: resolveShorthand(iconAfter, {\n defaultProps: {\n 'aria-hidden': true\n }\n }),\n aside: resolveShorthand(aside, {\n defaultProps: {\n 'aria-hidden': true\n }\n })\n };\n};\n//# sourceMappingURL=useTreeItemLayout.js.map"],"names":["useTreeItemLayout_unstable","props","ref","iconAfter","iconBefore","aside","as","treeItemContext","useTreeItemContext_unstable","components","root","getNativeElementProps","resolveShorthand","defaultProps"],"mappings":";;;;+BAYaA;;aAAAA;;;6DAZU;gCACiC;iCACZ;AAUrC,MAAMA,6BAA6B,CAACC,OAAOC,MAAQ;IACxD,MAAM,EACJC,UAAS,EACTC,WAAU,EACVC,MAAK,EACLC,IAAK,OAAM,EACZ,GAAGL;IACJ,MAAMM,kBAAkBC,IAAAA,4CAA2B;IACnD,OAAO;QACL,GAAGD,eAAe;QAClBE,YAAY;YACVC,MAAM;YACNN,YAAY;YACZD,WAAW;YACXE,OAAO;QACT;QACAK,MAAMC,IAAAA,qCAAqB,EAACL,IAAI;YAC9B,GAAGL,KAAK;YACRC;QACF;QACAE,YAAYQ,IAAAA,gCAAgB,EAACR,YAAY;YACvCS,cAAc;gBACZ,eAAe,IAAI;YACrB;QACF;QACAV,WAAWS,IAAAA,gCAAgB,EAACT,WAAW;YACrCU,cAAc;gBACZ,eAAe,IAAI;YACrB;QACF;QACAR,OAAOO,IAAAA,gCAAgB,EAACP,OAAO;YAC7BQ,cAAc;gBACZ,eAAe,IAAI;YACrB;QACF;IACF;AACF,GACA,6CAA6C"}
@@ -27,13 +27,21 @@ const treeItemPersonaLayoutClassNames = {
27
27
  base: {
28
28
  a9b677: "fly5x3f",
29
29
  mc9l5x: "f22iagw",
30
- Bt984gj: "f122n59"
30
+ Bt984gj: "f122n59",
31
+ Bahqtrf: "fk6fouc",
32
+ Be2twd7: "fkhj508",
33
+ Bhrd7zp: "figsok6",
34
+ Bg96gwp: "f1i3iumi"
31
35
  }
32
36
  }, {
33
37
  d: [
34
38
  ".fly5x3f{width:100%;}",
35
39
  ".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}",
36
- ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}"
40
+ ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}",
41
+ ".fk6fouc{font-family:var(--fontFamilyBase);}",
42
+ ".fkhj508{font-size:var(--fontSizeBase300);}",
43
+ ".figsok6{font-weight:var(--fontWeightRegular);}",
44
+ ".f1i3iumi{line-height:var(--lineHeightBase300);}"
37
45
  ]
38
46
  });
39
47
  /**
@@ -102,21 +110,6 @@ const useContentStyles = /*#__PURE__*/ (0, _react["__styles"])({
102
110
  ".fws515f{row-gap:var(--spacingHorizontalNone);}"
103
111
  ]
104
112
  });
105
- const useMainStyles = /*#__PURE__*/ (0, _react["__styles"])({
106
- base: {
107
- Bahqtrf: "fk6fouc",
108
- Be2twd7: "fkhj508",
109
- Bhrd7zp: "figsok6",
110
- Bg96gwp: "f1i3iumi"
111
- }
112
- }, {
113
- d: [
114
- ".fk6fouc{font-family:var(--fontFamilyBase);}",
115
- ".fkhj508{font-size:var(--fontSizeBase300);}",
116
- ".figsok6{font-weight:var(--fontWeightRegular);}",
117
- ".f1i3iumi{line-height:var(--lineHeightBase300);}"
118
- ]
119
- });
120
113
  const useDescriptionStyles = /*#__PURE__*/ (0, _react["__styles"])({
121
114
  base: {
122
115
  Bahqtrf: "fk6fouc",
@@ -163,7 +156,6 @@ const useTreeItemPersonaLayoutStyles_unstable = (state)=>{
163
156
  const rootStyles = useRootStyles();
164
157
  const mediaStyles = useMediaStyles();
165
158
  const contentStyles = useContentStyles();
166
- const mainStyles = useMainStyles();
167
159
  const descriptionStyles = useDescriptionStyles();
168
160
  const asideStyles = useAsideStyles();
169
161
  state.root.className = (0, _react.mergeClasses)(treeItemPersonaLayoutClassNames.root, rootStyles.base, state.root.className);
@@ -172,7 +164,7 @@ const useTreeItemPersonaLayoutStyles_unstable = (state)=>{
172
164
  state.content.className = (0, _react.mergeClasses)(treeItemPersonaLayoutClassNames.content, contentStyles.base, state.content.className);
173
165
  }
174
166
  if (state.main) {
175
- state.main.className = (0, _react.mergeClasses)(treeItemPersonaLayoutClassNames.main, mainStyles.base, state.main.className);
167
+ state.main.className = (0, _react.mergeClasses)(treeItemPersonaLayoutClassNames.main, state.main.className);
176
168
  }
177
169
  if (state.description) {
178
170
  state.description.className = (0, _react.mergeClasses)(treeItemPersonaLayoutClassNames.description, descriptionStyles.base, state.description.className);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js"],"sourcesContent":["import { __styles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nexport const treeItemPersonaLayoutClassNames = {\n root: 'fui-TreeItemPersonaLayout',\n media: 'fui-TreeItemPersonaLayout__media',\n content: 'fui-TreeItemPersonaLayout__content',\n description: 'fui-TreeItemPersonaLayout__description',\n aside: 'fui-TreeItemPersonaLayout__aside',\n main: 'fui-TreeItemPersonaLayout__main'\n};\n/**\n * Styles for the root slot\n */\nconst useRootStyles = /*#__PURE__*/__styles({\n base: {\n a9b677: \"fly5x3f\",\n mc9l5x: \"f22iagw\",\n Bt984gj: \"f122n59\"\n }\n}, {\n d: [\".fly5x3f{width:100%;}\", \".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}\", \".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}\"]\n});\n/**\n * Styles for the expand icon slot\n */\nconst useMediaStyles = /*#__PURE__*/__styles({\n base: {\n mc9l5x: \"f22iagw\",\n Bt984gj: \"f122n59\",\n a9b677: \"f1szoe96\",\n Bqenvij: \"f1d2rq10\",\n z8tnut: \"f1g0x7ka\",\n z189sj: [\"f7x41pl\", \"fruq291\"],\n Byoj8tv: \"f1qch9an\",\n uwmqm3: [\"fgiv446\", \"ffczdla\"]\n }\n}, {\n d: [\".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}\", \".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}\", \".f1szoe96{width:32px;}\", \".f1d2rq10{height:32px;}\", \".f1g0x7ka{padding-top:0;}\", \".f7x41pl{padding-right:var(--spacingHorizontalXS);}\", \".fruq291{padding-left:var(--spacingHorizontalXS);}\", \".f1qch9an{padding-bottom:0;}\", \".fgiv446{padding-left:var(--spacingHorizontalXXS);}\", \".ffczdla{padding-right:var(--spacingHorizontalXXS);}\"]\n});\nconst useContentStyles = /*#__PURE__*/__styles({\n base: {\n a9b677: \"fly5x3f\",\n mc9l5x: \"f22iagw\",\n Beiy3e4: \"f1vx9l62\",\n z8tnut: \"f1ngh7ph\",\n z189sj: [\"f7x41pl\", \"fruq291\"],\n Byoj8tv: \"f5o476b\",\n uwmqm3: [\"f1f5gg8d\", \"f1vdfbxk\"],\n i8kkvl: \"f1fps8zv\",\n Belr9w4: \"fws515f\"\n }\n}, {\n d: [\".fly5x3f{width:100%;}\", \".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}\", \".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}\", \".f1ngh7ph{padding-top:var(--spacingVerticalMNudge);}\", \".f7x41pl{padding-right:var(--spacingHorizontalXS);}\", \".fruq291{padding-left:var(--spacingHorizontalXS);}\", \".f5o476b{padding-bottom:var(--spacingVerticalMNudge);}\", \".f1f5gg8d{padding-left:var(--spacingHorizontalS);}\", \".f1vdfbxk{padding-right:var(--spacingHorizontalS);}\", \".f1fps8zv{-webkit-column-gap:var(--spacingVerticalNone);column-gap:var(--spacingVerticalNone);}\", \".fws515f{row-gap:var(--spacingHorizontalNone);}\"]\n});\nconst useMainStyles = /*#__PURE__*/__styles({\n base: {\n Bahqtrf: \"fk6fouc\",\n Be2twd7: \"fkhj508\",\n Bhrd7zp: \"figsok6\",\n Bg96gwp: \"f1i3iumi\"\n }\n}, {\n d: [\".fk6fouc{font-family:var(--fontFamilyBase);}\", \".fkhj508{font-size:var(--fontSizeBase300);}\", \".figsok6{font-weight:var(--fontWeightRegular);}\", \".f1i3iumi{line-height:var(--lineHeightBase300);}\"]\n});\nconst useDescriptionStyles = /*#__PURE__*/__styles({\n base: {\n Bahqtrf: \"fk6fouc\",\n Be2twd7: \"fy9rknc\",\n Bhrd7zp: \"figsok6\",\n Bg96gwp: \"fwrc4pm\"\n }\n}, {\n d: [\".fk6fouc{font-family:var(--fontFamilyBase);}\", \".fy9rknc{font-size:var(--fontSizeBase200);}\", \".figsok6{font-weight:var(--fontWeightRegular);}\", \".fwrc4pm{line-height:var(--lineHeightBase200);}\"]\n});\nconst useAsideStyles = /*#__PURE__*/__styles({\n base: {\n mc9l5x: \"f22iagw\",\n Beiy3e4: \"f1vx9l62\",\n Huce71: \"fz5stix\",\n z189sj: [\"fw5db7e\", \"f1uw59to\"],\n Bahqtrf: \"fk6fouc\",\n Be2twd7: \"fy9rknc\",\n Bhrd7zp: \"figsok6\",\n Bg96gwp: \"fwrc4pm\"\n }\n}, {\n d: [\".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}\", \".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}\", \".fz5stix{white-space:nowrap;}\", \".fw5db7e{padding-right:var(--spacingHorizontalM);}\", \".f1uw59to{padding-left:var(--spacingHorizontalM);}\", \".fk6fouc{font-family:var(--fontFamilyBase);}\", \".fy9rknc{font-size:var(--fontSizeBase200);}\", \".figsok6{font-weight:var(--fontWeightRegular);}\", \".fwrc4pm{line-height:var(--lineHeightBase200);}\"]\n});\n/**\n * Apply styling to the TreeItemPersonaLayout slots based on the state\n */\nexport const useTreeItemPersonaLayoutStyles_unstable = state => {\n const rootStyles = useRootStyles();\n const mediaStyles = useMediaStyles();\n const contentStyles = useContentStyles();\n const mainStyles = useMainStyles();\n const descriptionStyles = useDescriptionStyles();\n const asideStyles = useAsideStyles();\n state.root.className = mergeClasses(treeItemPersonaLayoutClassNames.root, rootStyles.base, state.root.className);\n state.media.className = mergeClasses(treeItemPersonaLayoutClassNames.media, mediaStyles.base, state.media.className);\n if (state.content) {\n state.content.className = mergeClasses(treeItemPersonaLayoutClassNames.content, contentStyles.base, state.content.className);\n }\n if (state.main) {\n state.main.className = mergeClasses(treeItemPersonaLayoutClassNames.main, mainStyles.base, state.main.className);\n }\n if (state.description) {\n state.description.className = mergeClasses(treeItemPersonaLayoutClassNames.description, descriptionStyles.base, state.description.className);\n }\n if (state.aside) {\n state.aside.className = mergeClasses(treeItemPersonaLayoutClassNames.aside, asideStyles.base, state.aside.className);\n }\n return state;\n};\n//# sourceMappingURL=useTreeItemPersonaLayoutStyles.js.map"],"names":["treeItemPersonaLayoutClassNames","useTreeItemPersonaLayoutStyles_unstable","root","media","content","description","aside","main","useRootStyles","__styles","base","a9b677","mc9l5x","Bt984gj","d","useMediaStyles","Bqenvij","z8tnut","z189sj","Byoj8tv","uwmqm3","useContentStyles","Beiy3e4","i8kkvl","Belr9w4","useMainStyles","Bahqtrf","Be2twd7","Bhrd7zp","Bg96gwp","useDescriptionStyles","useAsideStyles","Huce71","state","rootStyles","mediaStyles","contentStyles","mainStyles","descriptionStyles","asideStyles","className","mergeClasses"],"mappings":";;;;;;;;;;;IAEaA,+BAA+B,MAA/BA;IAyFAC,uCAAuC,MAAvCA;;uBA3FsC;AAE5C,MAAMD,kCAAkC;IAC7CE,MAAM;IACNC,OAAO;IACPC,SAAS;IACTC,aAAa;IACbC,OAAO;IACPC,MAAM;AACR;AACA;;CAEC,GACD,MAAMC,gBAAgB,WAAW,GAAEC,IAAAA,kBAAQ,EAAC;IAC1CC,MAAM;QACJC,QAAQ;QACRC,QAAQ;QACRC,SAAS;IACX;AACF,GAAG;IACDC,GAAG;QAAC;QAAyB;QAAwF;KAA0G;AACjO;AACA;;CAEC,GACD,MAAMC,iBAAiB,WAAW,GAAEN,IAAAA,kBAAQ,EAAC;IAC3CC,MAAM;QACJE,QAAQ;QACRC,SAAS;QACTF,QAAQ;QACRK,SAAS;QACTC,QAAQ;QACRC,QAAQ;YAAC;YAAW;SAAU;QAC9BC,SAAS;QACTC,QAAQ;YAAC;YAAW;SAAU;IAChC;AACF,GAAG;IACDN,GAAG;QAAC;QAAwF;QAA2G;QAA0B;QAA2B;QAA6B;QAAuD;QAAsD;QAAgC;QAAuD;KAAuD;AACthB;AACA,MAAMO,mBAAmB,WAAW,GAAEZ,IAAAA,kBAAQ,EAAC;IAC7CC,MAAM;QACJC,QAAQ;QACRC,QAAQ;QACRU,SAAS;QACTL,QA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AM9B,KAAK,CAACqC,SAAS,GAAGC,IAAAA,mBAAY,EAACzC,gCAAgCG,KAAK,EAAEgC,YAAYzB,IAAI,EAAEuB,MAAM9B,KAAK,CAACqC,SAAS;IACnH,IAAIP,MAAM7B,OAAO,EAAE;QACjB6B,MAAM7B,OAAO,CAACoC,SAAS,GAAGC,IAAAA,mBAAY,EAACzC,gCAAgCI,OAAO,EAAEgC,cAAc1B,IAAI,EAAEuB,MAAM7B,OAAO,CAACoC,SAAS;IAC7H,CAAC;IACD,IAAIP,MAAM1B,IAAI,EAAE;QACd0B,MAAM1B,IAAI,CAACiC,SAAS,GAAGC,IAAAA,mBAAY,EAACzC,gCAAgCO,IAAI,EAAE8B,WAAW3B,IAAI,EAAEuB,MAAM1B,IAAI,CAACiC,SAAS;IACjH,CAAC;IACD,IAAIP,MAAM5B,WAAW,EAAE;QACrB4B,MAAM5B,WAAW,CAACmC,SAAS,GAAGC,IAAAA,mBAAY,EAACzC,gCAAgCK,WAAW,EAAEiC,kBAAkB5B,IAAI,EAAEuB,MAAM5B,WAAW,CAACmC,SAAS;IAC7I,CAAC;IACD,IAAIP,MAAM3B,KAAK,EAAE;QACf2B,MAAM3B,KAAK,CAACkC,SAAS,GAAGC,IAAAA,mBAAY,EAACzC,gCAAgCM,KAAK,EAAEiC,YAAY7B,IAAI,EAAEuB,MAAM3B,KAAK,CAACkC,SAAS;IACrH,CAAC;IACD,OAAOP;AACT,GACA,0DAA0D"}
1
+ {"version":3,"sources":["../../../lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js"],"sourcesContent":["import { __styles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nexport const treeItemPersonaLayoutClassNames = {\n root: 'fui-TreeItemPersonaLayout',\n media: 'fui-TreeItemPersonaLayout__media',\n content: 'fui-TreeItemPersonaLayout__content',\n description: 'fui-TreeItemPersonaLayout__description',\n aside: 'fui-TreeItemPersonaLayout__aside',\n main: 'fui-TreeItemPersonaLayout__main'\n};\n/**\n * Styles for the root slot\n */\nconst useRootStyles = /*#__PURE__*/__styles({\n base: {\n a9b677: \"fly5x3f\",\n mc9l5x: \"f22iagw\",\n Bt984gj: \"f122n59\",\n Bahqtrf: \"fk6fouc\",\n Be2twd7: \"fkhj508\",\n Bhrd7zp: \"figsok6\",\n Bg96gwp: \"f1i3iumi\"\n }\n}, {\n d: [\".fly5x3f{width:100%;}\", \".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}\", \".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}\", \".fk6fouc{font-family:var(--fontFamilyBase);}\", \".fkhj508{font-size:var(--fontSizeBase300);}\", \".figsok6{font-weight:var(--fontWeightRegular);}\", \".f1i3iumi{line-height:var(--lineHeightBase300);}\"]\n});\n/**\n * Styles for the expand icon slot\n */\nconst useMediaStyles = /*#__PURE__*/__styles({\n base: {\n mc9l5x: \"f22iagw\",\n Bt984gj: \"f122n59\",\n a9b677: \"f1szoe96\",\n Bqenvij: \"f1d2rq10\",\n z8tnut: \"f1g0x7ka\",\n z189sj: [\"f7x41pl\", \"fruq291\"],\n Byoj8tv: \"f1qch9an\",\n uwmqm3: [\"fgiv446\", \"ffczdla\"]\n }\n}, {\n d: [\".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}\", \".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}\", \".f1szoe96{width:32px;}\", \".f1d2rq10{height:32px;}\", \".f1g0x7ka{padding-top:0;}\", \".f7x41pl{padding-right:var(--spacingHorizontalXS);}\", \".fruq291{padding-left:var(--spacingHorizontalXS);}\", \".f1qch9an{padding-bottom:0;}\", \".fgiv446{padding-left:var(--spacingHorizontalXXS);}\", \".ffczdla{padding-right:var(--spacingHorizontalXXS);}\"]\n});\nconst useContentStyles = /*#__PURE__*/__styles({\n base: {\n a9b677: \"fly5x3f\",\n mc9l5x: \"f22iagw\",\n Beiy3e4: \"f1vx9l62\",\n z8tnut: \"f1ngh7ph\",\n z189sj: [\"f7x41pl\", \"fruq291\"],\n Byoj8tv: \"f5o476b\",\n uwmqm3: [\"f1f5gg8d\", \"f1vdfbxk\"],\n i8kkvl: \"f1fps8zv\",\n Belr9w4: \"fws515f\"\n }\n}, {\n d: [\".fly5x3f{width:100%;}\", \".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}\", \".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}\", \".f1ngh7ph{padding-top:var(--spacingVerticalMNudge);}\", \".f7x41pl{padding-right:var(--spacingHorizontalXS);}\", \".fruq291{padding-left:var(--spacingHorizontalXS);}\", \".f5o476b{padding-bottom:var(--spacingVerticalMNudge);}\", \".f1f5gg8d{padding-left:var(--spacingHorizontalS);}\", \".f1vdfbxk{padding-right:var(--spacingHorizontalS);}\", \".f1fps8zv{-webkit-column-gap:var(--spacingVerticalNone);column-gap:var(--spacingVerticalNone);}\", \".fws515f{row-gap:var(--spacingHorizontalNone);}\"]\n});\nconst useDescriptionStyles = /*#__PURE__*/__styles({\n base: {\n Bahqtrf: \"fk6fouc\",\n Be2twd7: \"fy9rknc\",\n Bhrd7zp: \"figsok6\",\n Bg96gwp: \"fwrc4pm\"\n }\n}, {\n d: [\".fk6fouc{font-family:var(--fontFamilyBase);}\", \".fy9rknc{font-size:var(--fontSizeBase200);}\", \".figsok6{font-weight:var(--fontWeightRegular);}\", \".fwrc4pm{line-height:var(--lineHeightBase200);}\"]\n});\nconst useAsideStyles = /*#__PURE__*/__styles({\n base: {\n mc9l5x: \"f22iagw\",\n Beiy3e4: \"f1vx9l62\",\n Huce71: \"fz5stix\",\n z189sj: [\"fw5db7e\", \"f1uw59to\"],\n Bahqtrf: \"fk6fouc\",\n Be2twd7: \"fy9rknc\",\n Bhrd7zp: \"figsok6\",\n Bg96gwp: \"fwrc4pm\"\n }\n}, {\n d: [\".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}\", \".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}\", \".fz5stix{white-space:nowrap;}\", \".fw5db7e{padding-right:var(--spacingHorizontalM);}\", \".f1uw59to{padding-left:var(--spacingHorizontalM);}\", \".fk6fouc{font-family:var(--fontFamilyBase);}\", \".fy9rknc{font-size:var(--fontSizeBase200);}\", \".figsok6{font-weight:var(--fontWeightRegular);}\", \".fwrc4pm{line-height:var(--lineHeightBase200);}\"]\n});\n/**\n * Apply styling to the TreeItemPersonaLayout slots based on the state\n */\nexport const useTreeItemPersonaLayoutStyles_unstable = state => {\n const rootStyles = useRootStyles();\n const mediaStyles = useMediaStyles();\n const contentStyles = useContentStyles();\n const descriptionStyles = useDescriptionStyles();\n const asideStyles = useAsideStyles();\n state.root.className = mergeClasses(treeItemPersonaLayoutClassNames.root, rootStyles.base, state.root.className);\n state.media.className = mergeClasses(treeItemPersonaLayoutClassNames.media, mediaStyles.base, state.media.className);\n if (state.content) {\n state.content.className = mergeClasses(treeItemPersonaLayoutClassNames.content, contentStyles.base, state.content.className);\n }\n if (state.main) {\n state.main.className = mergeClasses(treeItemPersonaLayoutClassNames.main, state.main.className);\n }\n if (state.description) {\n state.description.className = mergeClasses(treeItemPersonaLayoutClassNames.description, descriptionStyles.base, state.description.className);\n }\n if (state.aside) {\n state.aside.className = mergeClasses(treeItemPersonaLayoutClassNames.aside, asideStyles.base, state.aside.className);\n }\n return state;\n};\n//# sourceMappingURL=useTreeItemPersonaLayoutStyles.js.map"],"names":["treeItemPersonaLayoutClassNames","useTreeItemPersonaLayoutStyles_unstable","root","media","content","description","aside","main","useRootStyles","__styles","base","a9b677","mc9l5x","Bt984gj","Bahqtrf","Be2twd7","Bhrd7zp","Bg96gwp","d","useMediaStyles","Bqenvij","z8tnut","z189sj","Byoj8tv","uwmqm3","useContentStyles","Beiy3e4","i8kkvl","Belr9w4","useDescriptionStyles","useAsideStyles","Huce71","state","rootStyles","mediaStyles","contentStyles","descriptionStyles","asideStyles","className","mergeClasses"],"mappings":";;;;;;;;;;;IAEaA,+BAA+B,MAA/BA;IAmFAC,uCAAuC,MAAvCA;;uBArFsC;AAE5C,MAAMD,kCAAkC;IAC7CE,MAAM;IACNC,OAAO;IACPC,SAAS;IACTC,aAAa;IACbC,OAAO;IACPC,MAAM;AACR;AACA;;CAEC,GACD,MAAMC,gBAAgB,WAAW,GAAEC,IAAAA,kBAAQ,EAAC;IAC1CC,MAAM;QACJC,QAAQ;QACRC,QAAQ;QACRC,SAAS;QACTC,SAAS;QACTC,SAAS;QACTC,SAAS;QACTC,SAAS;IACX;AACF,GAAG;IACDC,GAAG;QAAC;QAAyB;QAAwF;QAA2G;QAAgD;QAA+C;QAAmD;KAAmD;AACva;AACA;;CAEC,GACD,MAAMC,iBAAiB,WAAW,GAAEV,IAAAA,kBAAQ,EAAC;IAC3CC,MAAM;QACJE,QAAQ;QACRC,SAAS;QACTF,QAAQ;QACRS,SAAS;QACTC,QAAQ;QACRC,QAAQ;YAAC;YAAW;SAAU;QAC9BC,SAAS;QACTC,QAAQ;YAAC;YAAW;SAAU;IAChC;AACF,GAAG;IACDN,GAAG;QAAC;QAAwF;QAA2G;QAA0B;QAA2B;QAA6B;QAAuD;QAAsD;QAAgC;QAAuD;KAAuD;AACthB;AACA,MAAMO,mBAAmB,WAAW,GAAEhB,IAAAA,kBAAQ,EAAC;IAC7CC,MAAM;QACJC,QAAQ;QACRC,QAAQ;QACRc,SAAS;QACTL,QAAQ;QACRC,QAAQ;YAAC;YAAW;SAAU;QAC9BC,SAAS;QACTC,QAAQ;YAAC;YAAY;SAAW;QAChCG,QAAQ;QACRC,SAAS;IACX;AACF,GAAG;IACDV,GAAG;QAAC;QAAyB;QAAwF;QAA6F;QAAwD;QAAuD;QAAsD;QAA0D;QAAsD;QAAuD;QAAmG;KAAkD;AACrrB;AACA,MAAMW,uBAAuB,WAAW,GAAEpB,IAAAA,kBAAQ,EAAC;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EAAE;QACrB2B,MAAM3B,WAAW,CAACiC,SAAS,GAAGC,IAAAA,mBAAY,EAACvC,gCAAgCK,WAAW,EAAE+B,kBAAkB1B,IAAI,EAAEsB,MAAM3B,WAAW,CAACiC,SAAS;IAC7I,CAAC;IACD,IAAIN,MAAM1B,KAAK,EAAE;QACf0B,MAAM1B,KAAK,CAACgC,SAAS,GAAGC,IAAAA,mBAAY,EAACvC,gCAAgCM,KAAK,EAAE+B,YAAY3B,IAAI,EAAEsB,MAAM1B,KAAK,CAACgC,SAAS;IACrH,CAAC;IACD,OAAON;AACT,GACA,0DAA0D"}
@@ -36,13 +36,13 @@ function useFlatTree_unstable(flatTreeItemProps, options = {}) {
36
36
  event.preventDefault();
37
37
  });
38
38
  const getNextNavigableItem = (0, _reactUtilities.useEventCallback)((visibleItems, data)=>{
39
- const item = flatTreeItems.get(data.target.id);
39
+ const item = flatTreeItems.get(data.value);
40
40
  if (item) {
41
41
  switch(data.type){
42
42
  case _tokens.treeDataTypes.typeAhead:
43
43
  return item;
44
44
  case _tokens.treeDataTypes.arrowLeft:
45
- return flatTreeItems.get(item.parentId);
45
+ return flatTreeItems.get(item.parentValue);
46
46
  case _tokens.treeDataTypes.arrowRight:
47
47
  return visibleItems[item.index + 1];
48
48
  case _tokens.treeDataTypes.end:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/hooks/useFlatTree.js"],"sourcesContent":["import { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { createFlatTreeItems, VisibleFlatTreeItemGenerator } from '../utils/createFlatTreeItems';\nimport { treeDataTypes } from '../utils/tokens';\nimport { useFlatTreeNavigation } from './useFlatTreeNavigation';\nimport { useOpenItemsState } from './useOpenItemsState';\n/**\n * this hook provides FlatTree API to manage all required mechanisms to convert a list of items into renderable TreeItems\n * in multiple scenarios including virtualization.\n *\n * !!A flat tree is an unofficial spec for tree!!\n *\n * It should be used on cases where more complex interactions with a Tree is required.\n * On simple scenarios it is advised to simply use a nested structure instead.\n *\n * @param flatTreeItemProps - a list of tree items\n * @param options - in case control over the internal openItems is required\n */\nexport function useFlatTree_unstable(flatTreeItemProps, options = {}) {\n const [openItems, updateOpenItems] = useOpenItemsState(options);\n const flatTreeItems = React.useMemo(() => createFlatTreeItems(flatTreeItemProps), [flatTreeItemProps]);\n const [navigate, navigationRef] = useFlatTreeNavigation(flatTreeItems);\n const handleOpenChange = useEventCallback((event, data) => {\n var _options_onOpenChange;\n (_options_onOpenChange = options.onOpenChange) === null || _options_onOpenChange === void 0 ? void 0 : _options_onOpenChange.call(options, event, data);\n if (!event.isDefaultPrevented()) {\n updateOpenItems(data);\n }\n event.preventDefault();\n });\n const handleNavigation = useEventCallback((event, data) => {\n var _options_onNavigation_unstable;\n (_options_onNavigation_unstable = options.onNavigation_unstable) === null || _options_onNavigation_unstable === void 0 ? void 0 : _options_onNavigation_unstable.call(options, event, data);\n if (!event.isDefaultPrevented()) {\n navigate(data);\n }\n event.preventDefault();\n });\n const getNextNavigableItem = useEventCallback((visibleItems, data) => {\n const item = flatTreeItems.get(data.target.id);\n if (item) {\n switch (data.type) {\n case treeDataTypes.typeAhead:\n return item;\n case treeDataTypes.arrowLeft:\n return flatTreeItems.get(item.parentId);\n case treeDataTypes.arrowRight:\n return visibleItems[item.index + 1];\n case treeDataTypes.end:\n return visibleItems[visibleItems.length - 1];\n case treeDataTypes.home:\n return visibleItems[0];\n case treeDataTypes.arrowDown:\n return visibleItems[item.index + 1];\n case treeDataTypes.arrowUp:\n return visibleItems[item.index - 1];\n }\n }\n });\n const getTreeProps = React.useCallback(() => ({\n ref: navigationRef,\n openItems,\n onOpenChange: handleOpenChange,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n onNavigation_unstable: handleNavigation\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [openItems]);\n const items = React.useCallback(() => VisibleFlatTreeItemGenerator(openItems, flatTreeItems), [openItems, flatTreeItems]);\n return React.useMemo(() => ({\n navigate,\n getTreeProps,\n getNextNavigableItem,\n items\n }), [navigate, getTreeProps, getNextNavigableItem, items]);\n}\n//# sourceMappingURL=useFlatTree.js.map"],"names":["useFlatTree_unstable","flatTreeItemProps","options","openItems","updateOpenItems","useOpenItemsState","flatTreeItems","React","useMemo","createFlatTreeItems","navigate","navigationRef","useFlatTreeNavigation","handleOpenChange","useEventCallback","event","data","_options_onOpenChange","onOpenChange","call","isDefaultPrevented","preventDefault","handleNavigation","_options_onNavigation_unstable","onNavigation_unstable","getNextNavigableItem","visibleItems","item","get","target","id","type","treeDataTypes","typeAhead","arrowLeft","parentId","arrowRight","index","end","length","home","arrowDown","arrowUp","getTreeProps","useCallback","ref","items","VisibleFlatTreeItemGenerator"],"mappings":";;;;+BAkBgBA;;aAAAA;;;gCAlBiB;6DACV;qCAC2C;wBACpC;uCACQ;mCACJ;AAa3B,SAASA,qBAAqBC,iBAAiB,EAAEC,UAAU,CAAC,CAAC,EAAE;IACpE,MAAM,CAACC,WAAWC,gBAAgB,GAAGC,IAAAA,oCAAiB,EAACH;IACvD,MAAMI,gBAAgBC,OAAMC,OAAO,CAAC,IAAMC,IAAAA,wCAAmB,EAACR,oBAAoB;QAACA;KAAkB;IACrG,MAAM,CAACS,UAAUC,cAAc,GAAGC,IAAAA,4CAAqB,EAACN;IACxD,MAAMO,mBAAmBC,IAAAA,gCAAgB,EAAC,CAACC,OAAOC,OAAS;QACzD,IAAIC;QACHA,CAAAA,wBAAwBf,QAAQgB,YAAY,AAAD,MAAO,IAAI,IAAID,0BAA0B,KAAK,IAAI,KAAK,IAAIA,sBAAsBE,IAAI,CAACjB,SAASa,OAAOC,KAAK;QACvJ,IAAI,CAACD,MAAMK,kBAAkB,IAAI;YAC/BhB,gBAAgBY;QAClB,CAAC;QACDD,MAAMM,cAAc;IACtB;IACA,MAAMC,mBAAmBR,IAAAA,gCAAgB,EAAC,CAACC,OAAOC,OAAS;QACzD,IAAIO;QACHA,CAAAA,iCAAiCrB,QAAQsB,qBAAqB,AAAD,MAAO,IAAI,I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A;YAC1BE;YACAiC;YACAlB;YACAqB;QACF,CAAA,GAAI;QAACpC;QAAUiC;QAAclB;QAAsBqB;KAAM;AAC3D,EACA,uCAAuC"}
1
+ {"version":3,"sources":["../../lib/hooks/useFlatTree.js"],"sourcesContent":["import { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { createFlatTreeItems, VisibleFlatTreeItemGenerator } from '../utils/createFlatTreeItems';\nimport { treeDataTypes } from '../utils/tokens';\nimport { useFlatTreeNavigation } from './useFlatTreeNavigation';\nimport { useOpenItemsState } from './useOpenItemsState';\n/**\n * this hook provides FlatTree API to manage all required mechanisms to convert a list of items into renderable TreeItems\n * in multiple scenarios including virtualization.\n *\n * !!A flat tree is an unofficial spec for tree!!\n *\n * It should be used on cases where more complex interactions with a Tree is required.\n * On simple scenarios it is advised to simply use a nested structure instead.\n *\n * @param flatTreeItemProps - a list of tree items\n * @param options - in case control over the internal openItems is required\n */\nexport function useFlatTree_unstable(flatTreeItemProps, options = {}) {\n const [openItems, updateOpenItems] = useOpenItemsState(options);\n const flatTreeItems = React.useMemo(() => createFlatTreeItems(flatTreeItemProps), [flatTreeItemProps]);\n const [navigate, navigationRef] = useFlatTreeNavigation(flatTreeItems);\n const handleOpenChange = useEventCallback((event, data) => {\n var _options_onOpenChange;\n (_options_onOpenChange = options.onOpenChange) === null || _options_onOpenChange === void 0 ? void 0 : _options_onOpenChange.call(options, event, data);\n if (!event.isDefaultPrevented()) {\n updateOpenItems(data);\n }\n event.preventDefault();\n });\n const handleNavigation = useEventCallback((event, data) => {\n var _options_onNavigation_unstable;\n (_options_onNavigation_unstable = options.onNavigation_unstable) === null || _options_onNavigation_unstable === void 0 ? void 0 : _options_onNavigation_unstable.call(options, event, data);\n if (!event.isDefaultPrevented()) {\n navigate(data);\n }\n event.preventDefault();\n });\n const getNextNavigableItem = useEventCallback((visibleItems, data) => {\n const item = flatTreeItems.get(data.value);\n if (item) {\n switch (data.type) {\n case treeDataTypes.typeAhead:\n return item;\n case treeDataTypes.arrowLeft:\n return flatTreeItems.get(item.parentValue);\n case treeDataTypes.arrowRight:\n return visibleItems[item.index + 1];\n case treeDataTypes.end:\n return visibleItems[visibleItems.length - 1];\n case treeDataTypes.home:\n return visibleItems[0];\n case treeDataTypes.arrowDown:\n return visibleItems[item.index + 1];\n case treeDataTypes.arrowUp:\n return visibleItems[item.index - 1];\n }\n }\n });\n const getTreeProps = React.useCallback(() => ({\n ref: navigationRef,\n openItems,\n onOpenChange: handleOpenChange,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n onNavigation_unstable: handleNavigation\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [openItems]);\n const items = React.useCallback(() => VisibleFlatTreeItemGenerator(openItems, flatTreeItems), [openItems, flatTreeItems]);\n return React.useMemo(() => ({\n navigate,\n getTreeProps,\n getNextNavigableItem,\n items\n }), [navigate, getTreeProps, getNextNavigableItem, items]);\n}\n//# sourceMappingURL=useFlatTree.js.map"],"names":["useFlatTree_unstable","flatTreeItemProps","options","openItems","updateOpenItems","useOpenItemsState","flatTreeItems","React","useMemo","createFlatTreeItems","navigate","navigationRef","useFlatTreeNavigation","handleOpenChange","useEventCallback","event","data","_options_onOpenChange","onOpenChange","call","isDefaultPrevented","preventDefault","handleNavigation","_options_onNavigation_unstable","onNavigation_unstable","getNextNavigableItem","visibleItems","item","get","value","type","treeDataTypes","typeAhead","arrowLeft","parentValue","arrowRight","index","end","length","home","arrowDown","arrowUp","getTreeProps","useCallback","ref","items","VisibleFlatTreeItemGenerator"],"mappings":";;;;+BAkBgBA;;aAAAA;;;gCAlBiB;6DACV;qCAC2C;wBACpC;uCACQ;mCACJ;AAa3B,SAASA,qBAAqBC,iBAAiB,EAAEC,UAAU,CAAC,CAAC,EAAE;IACpE,MAAM,CAACC,WAAWC,gBAAgB,GAAGC,IAAAA,oCAAiB,EAACH;IACvD,MAAMI,gBAAgBC,OAAMC,OAAO,CAAC,IAAMC,IAAAA,wCAAmB,EAACR,oBAAo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;gBACxB,KAAKK,qBAAa,CAACS,SAAS;oBAC1B,OAAOd,YAAY,CAACC,KAAKS,KAAK,GAAG,EAAE;gBACrC,KAAKL,qBAAa,CAACU,OAAO;oBACxB,OAAOf,YAAY,CAACC,KAAKS,KAAK,GAAG,EAAE;YACvC;QACF,CAAC;IACH;IACA,MAAMM,eAAenC,OAAMoC,WAAW,CAAC,IAAO,CAAA;YAC5CC,KAAKjC;YACLR;YACAe,cAAcL;YACd,gEAAgE;YAChEW,uBAAuBF;QACzB,CAAA,GACA,uDAAuD;IACvD;QAACnB;KAAU;IACX,MAAM0C,QAAQtC,OAAMoC,WAAW,CAAC,IAAMG,IAAAA,iDAA4B,EAAC3C,WAAWG,gBAAgB;QAACH;QAAWG;KAAc;IACxH,OAAOC,OAAMC,OAAO,CAAC,IAAO,CAAA;YAC1BE;YACAgC;YACAjB;YACAoB;QACF,CAAA,GAAI;QAACnC;QAAUgC;QAAcjB;QAAsBoB;KAAM;AAC3D,EACA,uCAAuC"}
@@ -29,7 +29,7 @@ function useFlatTreeNavigation(flatTreeItems) {
29
29
  treeItemWalker.currentElement = data.target;
30
30
  return (0, _nextTypeAheadElement.nextTypeAheadElement)(treeItemWalker, data.event.key);
31
31
  case _tokens.treeDataTypes.arrowLeft:
32
- return parentElement(flatTreeItems, data.target, targetDocument);
32
+ return parentElement(flatTreeItems, data.value);
33
33
  case _tokens.treeDataTypes.arrowRight:
34
34
  treeItemWalker.currentElement = data.target;
35
35
  return firstChild(data.target, treeItemWalker);
@@ -71,10 +71,12 @@ function firstChild(target, treeWalker) {
71
71
  }
72
72
  return null;
73
73
  }
74
- function parentElement(flatTreeItems, target, document) {
75
- const flatTreeItem = flatTreeItems.get(target.id);
76
- if (flatTreeItem && flatTreeItem.parentId) {
77
- return document.getElementById(flatTreeItem.parentId);
74
+ function parentElement(flatTreeItems, value) {
75
+ const flatTreeItem = flatTreeItems.get(value);
76
+ if (flatTreeItem === null || flatTreeItem === void 0 ? void 0 : flatTreeItem.parentValue) {
77
+ const parentItem = flatTreeItems.get(flatTreeItem.parentValue);
78
+ var _parentItem_ref_current;
79
+ return (_parentItem_ref_current = parentItem === null || parentItem === void 0 ? void 0 : parentItem.ref.current) !== null && _parentItem_ref_current !== void 0 ? _parentItem_ref_current : null;
78
80
  }
79
81
  return null;
80
82
  } //# sourceMappingURL=useFlatTreeNavigation.js.map