@fluentui/react-tree 9.0.0-beta.3 → 9.0.0-beta.30

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 (307) hide show
  1. package/CHANGELOG.json +1566 -1
  2. package/CHANGELOG.md +423 -2
  3. package/dist/index.d.ts +408 -131
  4. package/lib/FlatTree.js +1 -0
  5. package/lib/FlatTree.js.map +1 -0
  6. package/lib/Tree.js +0 -1
  7. package/lib/Tree.js.map +1 -1
  8. package/lib/TreeItem.js +0 -1
  9. package/lib/TreeItem.js.map +1 -1
  10. package/lib/TreeItemLayout.js +0 -1
  11. package/lib/TreeItemLayout.js.map +1 -1
  12. package/lib/TreeItemPersonaLayout.js +0 -1
  13. package/lib/TreeItemPersonaLayout.js.map +1 -1
  14. package/lib/components/FlatTree/FlatTree.js +13 -0
  15. package/lib/components/FlatTree/FlatTree.js.map +1 -0
  16. package/lib/components/FlatTree/FlatTree.types.js +1 -0
  17. package/lib/components/FlatTree/FlatTree.types.js.map +1 -0
  18. package/lib/components/FlatTree/index.js +6 -0
  19. package/lib/components/FlatTree/index.js.map +1 -0
  20. package/lib/components/FlatTree/useFlatControllableCheckedItems.js +63 -0
  21. package/lib/components/FlatTree/useFlatControllableCheckedItems.js.map +1 -0
  22. package/lib/components/FlatTree/useFlatTree.js +3 -0
  23. package/lib/components/FlatTree/useFlatTree.js.map +1 -0
  24. package/lib/components/FlatTree/useFlatTreeNavigation.js +74 -0
  25. package/lib/components/FlatTree/useFlatTreeNavigation.js.map +1 -0
  26. package/lib/components/FlatTree/useFlatTreeStyles.styles.js +20 -0
  27. package/lib/components/FlatTree/useFlatTreeStyles.styles.js.map +1 -0
  28. package/lib/components/FlatTree/useHeadlessFlatTree.js +117 -0
  29. package/lib/components/FlatTree/useHeadlessFlatTree.js.map +1 -0
  30. package/lib/components/Tree/Tree.js +8 -15
  31. package/lib/components/Tree/Tree.js.map +1 -1
  32. package/lib/components/Tree/Tree.types.js +1 -2
  33. package/lib/components/Tree/Tree.types.js.map +1 -1
  34. package/lib/components/Tree/index.js +2 -3
  35. package/lib/components/Tree/index.js.map +1 -1
  36. package/lib/components/Tree/renderTree.js +7 -13
  37. package/lib/components/Tree/renderTree.js.map +1 -1
  38. package/lib/components/Tree/useControllableCheckedItems.js +94 -0
  39. package/lib/components/Tree/useControllableCheckedItems.js.map +1 -0
  40. package/lib/components/Tree/useTree.js +55 -112
  41. package/lib/components/Tree/useTree.js.map +1 -1
  42. package/lib/components/Tree/useTreeContextValues.js +14 -22
  43. package/lib/components/Tree/useTreeContextValues.js.map +1 -1
  44. package/lib/components/Tree/useTreeNavigation.js +52 -0
  45. package/lib/components/Tree/useTreeNavigation.js.map +1 -0
  46. package/lib/components/Tree/{useTreeStyles.js → useTreeStyles.styles.js} +7 -3
  47. package/lib/components/Tree/useTreeStyles.styles.js.map +1 -0
  48. package/lib/components/TreeItem/TreeItem.js +16 -9
  49. package/lib/components/TreeItem/TreeItem.js.map +1 -1
  50. package/lib/components/TreeItem/TreeItem.types.js +1 -2
  51. package/lib/components/TreeItem/TreeItem.types.js.map +1 -1
  52. package/lib/components/TreeItem/index.js +2 -2
  53. package/lib/components/TreeItem/index.js.map +1 -1
  54. package/lib/components/TreeItem/renderTreeItem.js +7 -25
  55. package/lib/components/TreeItem/renderTreeItem.js.map +1 -1
  56. package/lib/components/TreeItem/useTreeItem.js +163 -234
  57. package/lib/components/TreeItem/useTreeItem.js.map +1 -1
  58. package/lib/components/TreeItem/useTreeItemContextValues.js +20 -16
  59. package/lib/components/TreeItem/useTreeItemContextValues.js.map +1 -1
  60. package/lib/components/TreeItem/useTreeItemStyles.styles.js +100 -0
  61. package/lib/components/TreeItem/useTreeItemStyles.styles.js.map +1 -0
  62. package/lib/components/TreeItemChevron.js +24 -0
  63. package/lib/components/TreeItemChevron.js.map +1 -0
  64. package/lib/components/TreeItemLayout/TreeItemLayout.js +8 -8
  65. package/lib/components/TreeItemLayout/TreeItemLayout.js.map +1 -1
  66. package/lib/components/TreeItemLayout/TreeItemLayout.types.js +1 -2
  67. package/lib/components/TreeItemLayout/TreeItemLayout.types.js.map +1 -1
  68. package/lib/components/TreeItemLayout/index.js +1 -2
  69. package/lib/components/TreeItemLayout/index.js.map +1 -1
  70. package/lib/components/TreeItemLayout/renderTreeItemLayout.js +8 -21
  71. package/lib/components/TreeItemLayout/renderTreeItemLayout.js.map +1 -1
  72. package/lib/components/TreeItemLayout/useTreeItemLayout.js +99 -40
  73. package/lib/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
  74. package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.styles.js +237 -0
  75. package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.styles.js.map +1 -0
  76. package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.js +9 -9
  77. package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.js.map +1 -1
  78. package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.js +1 -2
  79. package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.js.map +1 -1
  80. package/lib/components/TreeItemPersonaLayout/index.js +1 -2
  81. package/lib/components/TreeItemPersonaLayout/index.js.map +1 -1
  82. package/lib/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js +10 -27
  83. package/lib/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js.map +1 -1
  84. package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js +40 -48
  85. package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js.map +1 -1
  86. package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.js +9 -10
  87. package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.js.map +1 -1
  88. package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.js +210 -0
  89. package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.js.map +1 -0
  90. package/lib/contexts/index.js +0 -1
  91. package/lib/contexts/index.js.map +1 -1
  92. package/lib/contexts/treeContext.js +13 -15
  93. package/lib/contexts/treeContext.js.map +1 -1
  94. package/lib/contexts/treeItemContext.js +16 -10
  95. package/lib/contexts/treeItemContext.js.map +1 -1
  96. package/lib/hooks/useControllableOpenItems.js +28 -0
  97. package/lib/hooks/useControllableOpenItems.js.map +1 -0
  98. package/lib/hooks/useRootTree.js +139 -0
  99. package/lib/hooks/useRootTree.js.map +1 -0
  100. package/lib/hooks/useRovingTabIndexes.js +30 -49
  101. package/lib/hooks/useRovingTabIndexes.js.map +1 -1
  102. package/lib/hooks/useSubtree.js +39 -0
  103. package/lib/hooks/useSubtree.js.map +1 -0
  104. package/lib/index.js +3 -4
  105. package/lib/index.js.map +1 -1
  106. package/lib/utils/ImmutableMap.js +41 -0
  107. package/lib/utils/ImmutableMap.js.map +1 -0
  108. package/lib/utils/ImmutableSet.js +42 -33
  109. package/lib/utils/ImmutableSet.js.map +1 -1
  110. package/lib/utils/assert.js +5 -5
  111. package/lib/utils/assert.js.map +1 -1
  112. package/lib/utils/createCheckedItems.js +18 -0
  113. package/lib/utils/createCheckedItems.js.map +1 -0
  114. package/lib/utils/createHTMLElementWalker.js +67 -0
  115. package/lib/utils/createHTMLElementWalker.js.map +1 -0
  116. package/lib/utils/createHeadlessTree.js +188 -0
  117. package/lib/utils/createHeadlessTree.js.map +1 -0
  118. package/lib/utils/createOpenItems.js +10 -0
  119. package/lib/utils/createOpenItems.js.map +1 -0
  120. package/lib/utils/flattenTree.js +54 -29
  121. package/lib/utils/flattenTree.js.map +1 -1
  122. package/lib/utils/getTreeItemValueFromElement.js +4 -0
  123. package/lib/utils/getTreeItemValueFromElement.js.map +1 -0
  124. package/lib/utils/nextTypeAheadElement.js +11 -12
  125. package/lib/utils/nextTypeAheadElement.js.map +1 -1
  126. package/lib/utils/normalizeOpenItems.js +6 -5
  127. package/lib/utils/normalizeOpenItems.js.map +1 -1
  128. package/lib/utils/tokens.js +14 -14
  129. package/lib/utils/tokens.js.map +1 -1
  130. package/lib/utils/treeItemFilter.js +2 -3
  131. package/lib/utils/treeItemFilter.js.map +1 -1
  132. package/lib-commonjs/FlatTree.js +6 -0
  133. package/lib-commonjs/FlatTree.js.map +1 -0
  134. package/lib-commonjs/Tree.js +3 -5
  135. package/lib-commonjs/Tree.js.map +1 -1
  136. package/lib-commonjs/TreeItem.js +3 -5
  137. package/lib-commonjs/TreeItem.js.map +1 -1
  138. package/lib-commonjs/TreeItemLayout.js +3 -5
  139. package/lib-commonjs/TreeItemLayout.js.map +1 -1
  140. package/lib-commonjs/TreeItemPersonaLayout.js +3 -5
  141. package/lib-commonjs/TreeItemPersonaLayout.js.map +1 -1
  142. package/lib-commonjs/components/FlatTree/FlatTree.js +20 -0
  143. package/lib-commonjs/components/FlatTree/FlatTree.js.map +1 -0
  144. package/lib-commonjs/components/FlatTree/FlatTree.types.js +4 -0
  145. package/lib-commonjs/components/FlatTree/FlatTree.types.js.map +1 -0
  146. package/lib-commonjs/components/FlatTree/index.js +21 -0
  147. package/lib-commonjs/components/FlatTree/index.js.map +1 -0
  148. package/lib-commonjs/components/FlatTree/useFlatControllableCheckedItems.js +78 -0
  149. package/lib-commonjs/components/FlatTree/useFlatControllableCheckedItems.js.map +1 -0
  150. package/lib-commonjs/components/FlatTree/useFlatTree.js +12 -0
  151. package/lib-commonjs/components/FlatTree/useFlatTree.js.map +1 -0
  152. package/lib-commonjs/components/FlatTree/useFlatTreeNavigation.js +82 -0
  153. package/lib-commonjs/components/FlatTree/useFlatTreeNavigation.js.map +1 -0
  154. package/lib-commonjs/components/FlatTree/useFlatTreeStyles.styles.js +36 -0
  155. package/lib-commonjs/components/FlatTree/useFlatTreeStyles.styles.js.map +1 -0
  156. package/lib-commonjs/components/FlatTree/useHeadlessFlatTree.js +114 -0
  157. package/lib-commonjs/components/FlatTree/useHeadlessFlatTree.js.map +1 -0
  158. package/lib-commonjs/components/Tree/Tree.js +17 -23
  159. package/lib-commonjs/components/Tree/Tree.js.map +1 -1
  160. package/lib-commonjs/components/Tree/Tree.types.js +1 -3
  161. package/lib-commonjs/components/Tree/Tree.types.js.map +1 -1
  162. package/lib-commonjs/components/Tree/index.js +8 -10
  163. package/lib-commonjs/components/Tree/index.js.map +1 -1
  164. package/lib-commonjs/components/Tree/renderTree.js +14 -19
  165. package/lib-commonjs/components/Tree/renderTree.js.map +1 -1
  166. package/lib-commonjs/components/Tree/useControllableCheckedItems.js +103 -0
  167. package/lib-commonjs/components/Tree/useControllableCheckedItems.js.map +1 -0
  168. package/lib-commonjs/components/Tree/useTree.js +61 -116
  169. package/lib-commonjs/components/Tree/useTree.js.map +1 -1
  170. package/lib-commonjs/components/Tree/useTreeContextValues.js +19 -26
  171. package/lib-commonjs/components/Tree/useTreeContextValues.js.map +1 -1
  172. package/lib-commonjs/components/Tree/useTreeNavigation.js +60 -0
  173. package/lib-commonjs/components/Tree/useTreeNavigation.js.map +1 -0
  174. package/lib-commonjs/components/Tree/useTreeStyles.styles.js +41 -0
  175. package/lib-commonjs/components/Tree/useTreeStyles.styles.js.map +1 -0
  176. package/lib-commonjs/components/TreeItem/TreeItem.js +17 -18
  177. package/lib-commonjs/components/TreeItem/TreeItem.js.map +1 -1
  178. package/lib-commonjs/components/TreeItem/TreeItem.types.js +3 -4
  179. package/lib-commonjs/components/TreeItem/TreeItem.types.js.map +1 -1
  180. package/lib-commonjs/components/TreeItem/index.js +8 -9
  181. package/lib-commonjs/components/TreeItem/index.js.map +1 -1
  182. package/lib-commonjs/components/TreeItem/renderTreeItem.js +14 -33
  183. package/lib-commonjs/components/TreeItem/renderTreeItem.js.map +1 -1
  184. package/lib-commonjs/components/TreeItem/useTreeItem.js +172 -250
  185. package/lib-commonjs/components/TreeItem/useTreeItem.js.map +1 -1
  186. package/lib-commonjs/components/TreeItem/useTreeItemContextValues.js +25 -20
  187. package/lib-commonjs/components/TreeItem/useTreeItemContextValues.js.map +1 -1
  188. package/lib-commonjs/components/TreeItem/useTreeItemStyles.styles.js +202 -0
  189. package/lib-commonjs/components/TreeItem/useTreeItemStyles.styles.js.map +1 -0
  190. package/lib-commonjs/components/TreeItemChevron.js +33 -0
  191. package/lib-commonjs/components/TreeItemChevron.js.map +1 -0
  192. package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.js +15 -16
  193. package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.js.map +1 -1
  194. package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.types.js +1 -3
  195. package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.types.js.map +1 -1
  196. package/lib-commonjs/components/TreeItemLayout/index.js +7 -9
  197. package/lib-commonjs/components/TreeItemLayout/index.js.map +1 -1
  198. package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.js +14 -28
  199. package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.js.map +1 -1
  200. package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.js +105 -52
  201. package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
  202. package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.styles.js +392 -0
  203. package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.styles.js.map +1 -0
  204. package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.js +17 -18
  205. package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.js.map +1 -1
  206. package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.js +1 -3
  207. package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.js.map +1 -1
  208. package/lib-commonjs/components/TreeItemPersonaLayout/index.js +7 -9
  209. package/lib-commonjs/components/TreeItemPersonaLayout/index.js.map +1 -1
  210. package/lib-commonjs/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js +17 -35
  211. package/lib-commonjs/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js.map +1 -1
  212. package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js +47 -61
  213. package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js.map +1 -1
  214. package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.js +16 -15
  215. package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.js.map +1 -1
  216. package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.js +379 -0
  217. package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.js.map +1 -0
  218. package/lib-commonjs/contexts/index.js +4 -6
  219. package/lib-commonjs/contexts/index.js.map +1 -1
  220. package/lib-commonjs/contexts/treeContext.js +26 -18
  221. package/lib-commonjs/contexts/treeContext.js.map +1 -1
  222. package/lib-commonjs/contexts/treeItemContext.js +30 -13
  223. package/lib-commonjs/contexts/treeItemContext.js.map +1 -1
  224. package/lib-commonjs/hooks/useControllableOpenItems.js +39 -0
  225. package/lib-commonjs/hooks/useControllableOpenItems.js.map +1 -0
  226. package/lib-commonjs/hooks/useRootTree.js +143 -0
  227. package/lib-commonjs/hooks/useRootTree.js.map +1 -0
  228. package/lib-commonjs/hooks/useRovingTabIndexes.js +36 -55
  229. package/lib-commonjs/hooks/useRovingTabIndexes.js.map +1 -1
  230. package/lib-commonjs/hooks/useSubtree.js +43 -0
  231. package/lib-commonjs/hooks/useSubtree.js.map +1 -0
  232. package/lib-commonjs/index.js +53 -181
  233. package/lib-commonjs/index.js.map +1 -1
  234. package/lib-commonjs/utils/ImmutableMap.js +49 -0
  235. package/lib-commonjs/utils/ImmutableMap.js.map +1 -0
  236. package/lib-commonjs/utils/ImmutableSet.js +47 -38
  237. package/lib-commonjs/utils/ImmutableSet.js.map +1 -1
  238. package/lib-commonjs/utils/assert.js +11 -9
  239. package/lib-commonjs/utils/assert.js.map +1 -1
  240. package/lib-commonjs/utils/createCheckedItems.js +26 -0
  241. package/lib-commonjs/utils/createCheckedItems.js.map +1 -0
  242. package/lib-commonjs/utils/createHTMLElementWalker.js +75 -0
  243. package/lib-commonjs/utils/createHTMLElementWalker.js.map +1 -0
  244. package/lib-commonjs/utils/createHeadlessTree.js +202 -0
  245. package/lib-commonjs/utils/createHeadlessTree.js.map +1 -0
  246. package/lib-commonjs/utils/createOpenItems.js +18 -0
  247. package/lib-commonjs/utils/createOpenItems.js.map +1 -0
  248. package/lib-commonjs/utils/flattenTree.js +21 -34
  249. package/lib-commonjs/utils/flattenTree.js.map +1 -1
  250. package/lib-commonjs/utils/getTreeItemValueFromElement.js +18 -0
  251. package/lib-commonjs/utils/getTreeItemValueFromElement.js.map +1 -0
  252. package/lib-commonjs/utils/nextTypeAheadElement.js +16 -16
  253. package/lib-commonjs/utils/nextTypeAheadElement.js.map +1 -1
  254. package/lib-commonjs/utils/normalizeOpenItems.js +11 -9
  255. package/lib-commonjs/utils/normalizeOpenItems.js.map +1 -1
  256. package/lib-commonjs/utils/tokens.js +29 -20
  257. package/lib-commonjs/utils/tokens.js.map +1 -1
  258. package/lib-commonjs/utils/treeItemFilter.js +7 -7
  259. package/lib-commonjs/utils/treeItemFilter.js.map +1 -1
  260. package/package.json +26 -17
  261. package/lib/components/Tree/useTreeStyles.js.map +0 -1
  262. package/lib/components/TreeItem/useTreeItemStyles.js +0 -203
  263. package/lib/components/TreeItem/useTreeItemStyles.js.map +0 -1
  264. package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.js +0 -98
  265. package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.js.map +0 -1
  266. package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js +0 -115
  267. package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js.map +0 -1
  268. package/lib/hooks/index.js +0 -4
  269. package/lib/hooks/index.js.map +0 -1
  270. package/lib/hooks/useFlatTree.js +0 -49
  271. package/lib/hooks/useFlatTree.js.map +0 -1
  272. package/lib/hooks/useFlatTreeNavigation.js +0 -74
  273. package/lib/hooks/useFlatTreeNavigation.js.map +0 -1
  274. package/lib/hooks/useHTMLElementWalker.js +0 -80
  275. package/lib/hooks/useHTMLElementWalker.js.map +0 -1
  276. package/lib/hooks/useNestedTreeNavigation.js +0 -59
  277. package/lib/hooks/useNestedTreeNavigation.js.map +0 -1
  278. package/lib/hooks/useOpenItemsState.js +0 -22
  279. package/lib/hooks/useOpenItemsState.js.map +0 -1
  280. package/lib/utils/createUnfilteredFlatTree.js +0 -77
  281. package/lib/utils/createUnfilteredFlatTree.js.map +0 -1
  282. package/lib/utils/createVisibleFlatTree.js +0 -80
  283. package/lib/utils/createVisibleFlatTree.js.map +0 -1
  284. package/lib-commonjs/components/Tree/useTreeStyles.js +0 -27
  285. package/lib-commonjs/components/Tree/useTreeStyles.js.map +0 -1
  286. package/lib-commonjs/components/TreeItem/useTreeItemStyles.js +0 -210
  287. package/lib-commonjs/components/TreeItem/useTreeItemStyles.js.map +0 -1
  288. package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.js +0 -105
  289. package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.js.map +0 -1
  290. package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js +0 -122
  291. package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js.map +0 -1
  292. package/lib-commonjs/hooks/index.js +0 -10
  293. package/lib-commonjs/hooks/index.js.map +0 -1
  294. package/lib-commonjs/hooks/useFlatTree.js +0 -56
  295. package/lib-commonjs/hooks/useFlatTree.js.map +0 -1
  296. package/lib-commonjs/hooks/useFlatTreeNavigation.js +0 -81
  297. package/lib-commonjs/hooks/useFlatTreeNavigation.js.map +0 -1
  298. package/lib-commonjs/hooks/useHTMLElementWalker.js +0 -88
  299. package/lib-commonjs/hooks/useHTMLElementWalker.js.map +0 -1
  300. package/lib-commonjs/hooks/useNestedTreeNavigation.js +0 -66
  301. package/lib-commonjs/hooks/useNestedTreeNavigation.js.map +0 -1
  302. package/lib-commonjs/hooks/useOpenItemsState.js +0 -29
  303. package/lib-commonjs/hooks/useOpenItemsState.js.map +0 -1
  304. package/lib-commonjs/utils/createUnfilteredFlatTree.js +0 -84
  305. package/lib-commonjs/utils/createUnfilteredFlatTree.js.map +0 -1
  306. package/lib-commonjs/utils/createVisibleFlatTree.js +0 -87
  307. package/lib-commonjs/utils/createVisibleFlatTree.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,31 +1,174 @@
1
1
  /// <reference types="react" />
2
2
 
3
- import { ArrowDown } from '@fluentui/keyboard-keys';
4
- import { ArrowLeft } from '@fluentui/keyboard-keys';
5
- import { ArrowRight } from '@fluentui/keyboard-keys';
6
- import { ArrowUp } from '@fluentui/keyboard-keys';
3
+ import type { ArrowDown } from '@fluentui/keyboard-keys';
4
+ import type { ArrowLeft } from '@fluentui/keyboard-keys';
5
+ import type { ArrowRight } from '@fluentui/keyboard-keys';
6
+ import type { ArrowUp } from '@fluentui/keyboard-keys';
7
7
  import type { AvatarContextValue } from '@fluentui/react-avatar';
8
8
  import type { AvatarSize } from '@fluentui/react-avatar';
9
- import type { ButtonContextValue } from '@fluentui/react-button';
9
+ import { ButtonContextValue } from '@fluentui/react-button';
10
+ import { Checkbox } from '@fluentui/react-checkbox';
11
+ import { CheckboxProps } from '@fluentui/react-checkbox';
10
12
  import type { ComponentProps } from '@fluentui/react-utilities';
11
13
  import type { ComponentState } from '@fluentui/react-utilities';
12
14
  import { ContextSelector } from '@fluentui/react-context-selector';
13
- import { End } from '@fluentui/keyboard-keys';
14
- import { Enter } from '@fluentui/keyboard-keys';
15
+ import type { End } from '@fluentui/keyboard-keys';
16
+ import type { Enter } from '@fluentui/keyboard-keys';
15
17
  import type { ExtractSlotProps } from '@fluentui/react-utilities';
16
18
  import { FC } from 'react';
17
19
  import type { ForwardRefComponent } from '@fluentui/react-utilities';
18
- import { Home } from '@fluentui/keyboard-keys';
20
+ import type { Home } from '@fluentui/keyboard-keys';
19
21
  import { Provider } from 'react';
20
22
  import { ProviderProps } from 'react';
23
+ import { Radio } from '@fluentui/react-radio';
24
+ import { RadioProps } from '@fluentui/react-radio';
21
25
  import * as React_2 from 'react';
26
+ import { SelectionMode as SelectionMode_2 } from '@fluentui/react-utilities';
22
27
  import type { Slot } from '@fluentui/react-utilities';
23
28
  import type { SlotClassNames } from '@fluentui/react-utilities';
24
29
 
30
+ /**
31
+ * properly creates an ImmutableMap instance from an iterable
32
+ */
33
+ declare function createImmutableMap<Key, Value>(iterable?: Iterable<[Key, Value]>): ImmutableMap<Key, Value>;
34
+
35
+ /**
36
+ * properly creates an ImmutableSet instance from an iterable
37
+ */
38
+ declare function createImmutableSet<Value>(iterable?: Iterable<Value>): ImmutableSet<Value>;
39
+
40
+ /**
41
+ * Avoid using *dangerouslyCreateImmutableMap*, since this method will expose internally used set, use createImmutableMap instead,
42
+ * @param internalMap - a set that is used internally to store values.
43
+ */
44
+ declare function dangerouslyCreateImmutableMap<Key, Value>(internalMap: Map<Key, Value>): ImmutableMap<Key, Value>;
45
+
46
+ /**
47
+ * Avoid using *dangerouslyCreateImmutableSet*, since this method will expose internally used set, use createImmutableSet instead,
48
+ * @param internalSet - a set that is used internally to store values.
49
+ */
50
+ declare function dangerouslyCreateImmutableSet<Value>(internalSet: Set<Value>): ImmutableSet<Value>;
51
+
52
+ declare type FlattenedTreeItem<Props extends TreeItemProps> = HeadlessFlatTreeItemProps & Props;
53
+
25
54
  /**
26
55
  * Converts a nested structure to a flat one which can be consumed by `useFlatTreeItems`
56
+ * @example
57
+ * ```tsx
58
+ * const defaultItems = flattenTree_unstable([
59
+ * {
60
+ * children: <TreeItemLayout>level 1, item 1</TreeItemLayout>,
61
+ * subtree: [
62
+ * {
63
+ * children: <TreeItemLayout>level 2, item 1</TreeItemLayout>,
64
+ * },
65
+ * {
66
+ * children: <TreeItemLayout>level 2, item 2</TreeItemLayout>,
67
+ * },
68
+ * {
69
+ * children: <TreeItemLayout>level 2, item 3</TreeItemLayout>,
70
+ * },
71
+ * ],
72
+ * },
73
+ * {
74
+ * children: <TreeItemLayout>level 1, item 2</TreeItemLayout>,
75
+ * subtree: [
76
+ * {
77
+ * children: <TreeItemLayout>level 2, item 1</TreeItemLayout>,
78
+ * subtree: [
79
+ * {
80
+ * children: <TreeItemLayout>level 3, item 1</TreeItemLayout>,
81
+ * subtree: [
82
+ * {
83
+ * children: <TreeItemLayout>level 4, item 1</TreeItemLayout>,
84
+ * },
85
+ * ],
86
+ * },
87
+ * ],
88
+ * },
89
+ * ],
90
+ * },
91
+ * ]);
92
+ * ```
27
93
  */
28
- export declare const flattenTree_unstable: (items: NestedTreeItem[]) => FlatTreeItemProps[];
94
+ export declare const flattenTree_unstable: <Props extends TreeItemProps>(items: FlattenTreeItem<Props>[]) => FlattenedTreeItem<Props>[];
95
+
96
+ export declare type FlattenTreeItem<Props extends TreeItemProps> = Omit<Props, 'subtree' | 'itemType'> & {
97
+ value: TreeItemValue;
98
+ subtree?: FlattenTreeItem<Props>[];
99
+ };
100
+
101
+ /**
102
+ * FlatTree component - TODO: add more docs
103
+ */
104
+ export declare const FlatTree: ForwardRefComponent<FlatTreeProps>;
105
+
106
+ export declare const flatTreeClassNames: SlotClassNames<TreeSlots>;
107
+
108
+ export declare type FlatTreeProps = ComponentProps<TreeSlots> & {
109
+ /**
110
+ * A tree item can have various appearances:
111
+ * - 'subtle' (default): The default tree item styles.
112
+ * - 'subtle-alpha': Minimizes emphasis on hovered or focused states.
113
+ * - 'transparent': Removes background color.
114
+ * @default 'subtle'
115
+ */
116
+ appearance?: 'subtle' | 'subtle-alpha' | 'transparent';
117
+ /**
118
+ * Size of the tree item.
119
+ * @default 'medium'
120
+ */
121
+ size?: 'small' | 'medium';
122
+ /**
123
+ * This refers to a list of ids of opened tree items.
124
+ * Controls the state of the open tree items.
125
+ * These property is ignored for subtrees.
126
+ */
127
+ openItems?: Iterable<TreeItemValue>;
128
+ /**
129
+ * Callback fired when the component changes value from open state.
130
+ * These property is ignored for subtrees.
131
+ *
132
+ * @param event - a React's Synthetic event
133
+ * @param data - A data object with relevant information,
134
+ * such as open value and type of interaction that created the event.
135
+ */
136
+ onOpenChange?(event: TreeOpenChangeEvent, data: TreeOpenChangeData): void;
137
+ /**
138
+ * Callback fired when navigation happens inside the component.
139
+ * These property is ignored for subtrees.
140
+ *
141
+ * FIXME: This method is not ideal, as navigation should be handled internally by tabster.
142
+ *
143
+ * @param event - a React's Synthetic event
144
+ * @param data - A data object with relevant information,
145
+ */
146
+ onNavigation_unstable?(event: TreeNavigationEvent_unstable, data: TreeNavigationData_unstable): void;
147
+ /**
148
+ * This refers to the selection mode of the tree.
149
+ * - undefined: No selection can be done.
150
+ * - 'single': Only one tree item can be selected, radio buttons are rendered.
151
+ * - 'multiselect': Multiple tree items can be selected, checkboxes are rendered.
152
+ *
153
+ * @default undefined
154
+ */
155
+ selectionMode?: SelectionMode_2;
156
+ /**
157
+ * This refers to a list of ids of checked tree items, or a list of tuples of ids and checked state.
158
+ * Controls the state of the checked tree items.
159
+ * These property is ignored for subtrees.
160
+ */
161
+ checkedItems?: Iterable<TreeItemValue | [TreeItemValue, TreeSelectionValue]>;
162
+ /**
163
+ * Callback fired when the component changes value from checked state.
164
+ * These property is ignored for subtrees.
165
+ *
166
+ * @param event - a React's Synthetic event
167
+ * @param data - A data object with relevant information,
168
+ * such as checked value and type of interaction that created the event.
169
+ */
170
+ onCheckedChange?(event: TreeCheckedChangeEvent, data: TreeCheckedChangeData): void;
171
+ };
29
172
 
30
173
  /**
31
174
  * FlatTree API to manage all required mechanisms to convert a list of items into renderable TreeItems
@@ -37,13 +180,16 @@ export declare const flattenTree_unstable: (items: NestedTreeItem[]) => FlatTree
37
180
  *
38
181
  * On simple scenarios it is advised to simply use a nested structure instead.
39
182
  */
40
- export declare type FlatTree = {
183
+ export declare type HeadlessFlatTree<Props extends HeadlessFlatTreeItemProps> = {
41
184
  /**
42
185
  * returns the properties required for the Tree component to work properly.
43
186
  * That includes:
44
187
  * `openItems`, `onOpenChange`, `onNavigation_unstable` and `ref`
45
188
  */
46
- getTreeProps(): FlatTreeProps;
189
+ getTreeProps(): Required<Pick<FlatTreeProps, 'openItems' | 'onOpenChange' | 'onNavigation_unstable' | 'checkedItems' | 'onCheckedChange'>> & {
190
+ ref: React_2.Ref<HTMLDivElement>;
191
+ openItems: ImmutableSet<TreeItemValue>;
192
+ };
47
193
  /**
48
194
  * internal method used to react to an `onNavigation` event.
49
195
  * This method ensures proper navigation on keyboard and mouse interaction.
@@ -57,7 +203,7 @@ export declare type FlatTree = {
57
203
  * event.preventDefault();
58
204
  * const nextItem = tree.getNextNavigableItem(data);
59
205
  * // scroll to item using virtualization scroll mechanism
60
- * if (nextItem && !targetDocument.getElementById(nextItem.id)) {
206
+ * if (nextItem && tree.getElementFromItem(nextItem)) {
61
207
  * listRef.current.scrollToItem(nextItem.index);
62
208
  * }
63
209
  * // wait for scrolling to happen and then invoke navigate method
@@ -72,34 +218,83 @@ export declare type FlatTree = {
72
218
  * returns next item to be focused on a navigation.
73
219
  * This method is provided to decouple the element that needs to be focused from
74
220
  * the action of focusing it itself.
221
+ *
222
+ * On the case of TypeAhead navigation this method returns the current item.
75
223
  */
76
- getNextNavigableItem(data: TreeNavigationData_unstable): FlatTreeItem | null;
224
+ getNextNavigableItem(visibleItems: HeadlessTreeItem<Props>[], data: TreeNavigationData_unstable): HeadlessTreeItem<Props> | undefined;
77
225
  /**
78
- * returns a single flat tree item by id without iterating over the whole collection
226
+ * similar to getElementById but for FlatTreeItems
79
227
  */
80
- getItem(id: string): FlatTreeItem | null;
228
+ getElementFromItem(item: HeadlessTreeItem<Props>): HTMLElement | null;
81
229
  /**
82
- * returns an iterable containing all visually available flat tree items
230
+ * an iterable containing all visually available flat tree items
83
231
  */
84
- items(): Iterable<FlatTreeItem>;
232
+ items(): IterableIterator<HeadlessTreeItem<Props>>;
85
233
  };
86
234
 
87
- export declare type FlatTreeItem = {
88
- getTreeItemProps(): Required<Pick<TreeItemProps, 'id' | 'aria-setsize' | 'aria-level' | 'aria-posinset' | 'leaf'>> & TreeItemProps;
89
- parentId?: string;
90
- childrenSize: number;
91
- index: number;
92
- id: string;
235
+ export declare type HeadlessFlatTreeItem<Props extends HeadlessFlatTreeItemProps> = HeadlessTreeItem<Props>;
236
+
237
+ export declare type HeadlessFlatTreeItemProps = HeadlessTreeItemProps;
238
+
239
+ export declare type HeadlessFlatTreeOptions = Pick<FlatTreeProps, 'onOpenChange' | 'onNavigation_unstable' | 'selectionMode' | 'onCheckedChange'> & Pick<TreeProps, 'defaultOpenItems' | 'openItems' | 'checkedItems' | 'defaultChecked'>;
240
+
241
+ /**
242
+ * The item that is returned by `createHeadlessTree`, it represents a wrapper around the properties provided to
243
+ * `createHeadlessTree` but with extra information that might be useful on virtual tree scenarios
244
+ */
245
+ declare type HeadlessTreeItem<Props extends HeadlessTreeItemProps> = {
93
246
  level: number;
247
+ index: number;
248
+ position: number;
249
+ childrenValues: TreeItemValue[];
250
+ value: TreeItemValue;
251
+ parentValue: TreeItemValue | undefined;
252
+ itemType: TreeItemType;
253
+ getTreeItemProps(): Required<Pick<Props, 'value' | 'aria-setsize' | 'aria-level' | 'aria-posinset' | 'itemType'>> & Omit<Props, 'parentValue'>;
94
254
  };
95
255
 
96
- export declare type FlatTreeItemProps = Required<Pick<TreeItemProps, 'id'>> & TreeItemProps & {
97
- parentId?: string;
256
+ declare type HeadlessTreeItemProps = Omit<TreeItemProps, 'itemType' | 'value'> & {
257
+ value: TreeItemValue;
258
+ itemType?: TreeItemType;
259
+ parentValue?: TreeItemValue;
98
260
  };
99
261
 
100
- export declare type FlatTreeProps = Required<Pick<TreeProps, 'openItems' | 'onOpenChange' | 'onNavigation_unstable'> & {
101
- ref: React_2.Ref<HTMLDivElement>;
102
- }>;
262
+ declare interface ImmutableMap<Key, Value> {
263
+ clear(): ImmutableMap<Key, Value>;
264
+ delete(key: Key): ImmutableMap<Key, Value>;
265
+ /**
266
+ * Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
267
+ * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
268
+ */
269
+ get(key: Key): Value | undefined;
270
+ /**
271
+ * @returns boolean indicating whether an element with the specified key exists or not.
272
+ */
273
+ has(key: Key): boolean;
274
+ /**
275
+ * Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
276
+ */
277
+ set(key: Key, value: Value): ImmutableMap<Key, Value>;
278
+ /**
279
+ * @returns the number of elements in the Map.
280
+ */
281
+ readonly size: number;
282
+ /** Iterates over entries in the Map. */
283
+ [Symbol.iterator](): IterableIterator<[Key, Value]>;
284
+ /**
285
+ * @internal
286
+ * Exposes the internal map used to store values.
287
+ * This is an internal API and should not be used directly.
288
+ */
289
+ dangerouslyGetInternalMap_unstable(): Map<Key, Value>;
290
+ }
291
+
292
+ declare const ImmutableMap: {
293
+ empty: ImmutableMap<never, never>;
294
+ create: typeof createImmutableMap;
295
+ isImmutableMap: typeof isImmutableMap;
296
+ dangerouslyCreate_unstable: typeof dangerouslyCreateImmutableMap;
297
+ };
103
298
 
104
299
  declare interface ImmutableSet<Value> {
105
300
  /**
@@ -125,13 +320,32 @@ declare interface ImmutableSet<Value> {
125
320
  has(value: Value): boolean;
126
321
  /** Iterates over values in the ImmutableSet. */
127
322
  [Symbol.iterator](): IterableIterator<Value>;
323
+ /**
324
+ * @internal
325
+ * Exposes the internal set used to store values.
326
+ * This is an internal API and should not be used directly.
327
+ */
328
+ dangerouslyGetInternalSet_unstable(): Set<Value>;
128
329
  }
129
330
 
130
- export declare type NestedTreeItem = Omit<TreeItemProps, 'subtree'> & {
131
- subtree?: NestedTreeItem[];
331
+ declare const ImmutableSet: {
332
+ empty: ImmutableSet<never>;
333
+ create: typeof createImmutableSet;
334
+ isImmutableSet: typeof isImmutableSet;
335
+ dangerouslyCreate_unstable: typeof dangerouslyCreateImmutableSet;
132
336
  };
133
337
 
134
- export declare const renderTree_unstable: (state: TreeState, contextValues: TreeContextValues) => JSX.Element;
338
+ declare function isImmutableMap<Key, Value>(value: unknown): value is ImmutableMap<Key, Value>;
339
+
340
+ declare function isImmutableSet<Value>(value: unknown): value is ImmutableSet<Value>;
341
+
342
+ declare type MultiSelectValue = NonNullable<CheckboxProps['checked']>;
343
+
344
+ declare type OmitWithoutExpanding<P, K extends string | number | symbol> = P extends unknown ? Omit<P, K> : P;
345
+
346
+ declare const renderTree_unstable: (state: TreeState, contextValues: TreeContextValues) => JSX.Element;
347
+ export { renderTree_unstable as renderFlatTree_unstable }
348
+ export { renderTree_unstable }
135
349
 
136
350
  /**
137
351
  * Render the final JSX of TreeItem
@@ -148,58 +362,90 @@ export declare const renderTreeItemLayout_unstable: (state: TreeItemLayoutState)
148
362
  */
149
363
  export declare const renderTreeItemPersonaLayout_unstable: (state: TreeItemPersonaLayoutState, contextValues: TreeItemPersonaLayoutContextValues) => JSX.Element;
150
364
 
365
+ declare type SingleSelectValue = NonNullable<RadioProps['checked']>;
366
+
151
367
  /**
152
- * A tree view widget presents a hierarchical list.
153
- * Any item in the hierarchy may have child items,
154
- * and items that have children may be expanded or collapsed to show or hide the children.
155
- * For example, in a file system navigator that uses a tree view to display folders and files,
156
- * an item representing a folder can be expanded to reveal the contents of the folder,
157
- * which may be files, folders, or both.
368
+ * Tree component - TODO: add more docs
158
369
  */
159
370
  export declare const Tree: ForwardRefComponent<TreeProps>;
160
371
 
372
+ export declare type TreeCheckedChangeData = {
373
+ value: TreeItemValue;
374
+ checkedItems: Map<TreeItemValue, TreeSelectionValue>;
375
+ target: HTMLElement;
376
+ event: React_2.ChangeEvent<HTMLElement>;
377
+ type: 'Change';
378
+ } & ({
379
+ selectionMode: 'multiselect';
380
+ checked: MultiSelectValue;
381
+ } | {
382
+ selectionMode: 'single';
383
+ checked: SingleSelectValue;
384
+ });
385
+
386
+ export declare type TreeCheckedChangeEvent = TreeCheckedChangeData['event'];
387
+
161
388
  export declare const treeClassNames: SlotClassNames<TreeSlots>;
162
389
 
163
390
  export declare type TreeContextValue = {
164
391
  level: number;
392
+ selectionMode: 'none' | SelectionMode_2;
165
393
  appearance: 'subtle' | 'subtle-alpha' | 'transparent';
166
394
  size: 'small' | 'medium';
167
- openItems: ImmutableSet<TreeItemId>;
395
+ openItems: ImmutableSet<TreeItemValue>;
396
+ checkedItems: ImmutableMap<TreeItemValue, 'mixed' | boolean>;
168
397
  /**
169
- * Requests dialog main component to update it's internal open state
398
+ * requests root Tree component to respond to some tree item event,
170
399
  */
171
- requestOpenChange(data: TreeOpenChangeData): void;
172
- requestNavigation(data: TreeNavigationData_unstable): void;
400
+ requestTreeResponse(request: TreeItemRequest): void;
173
401
  };
174
402
 
175
- declare type TreeContextValues = {
403
+ export declare type TreeContextValues = {
176
404
  tree: TreeContextValue;
177
405
  };
178
406
 
179
407
  /**
180
- * TreeItem component - TODO: add more docs
408
+ * The `TreeItem` component represents a single item in a tree.
409
+ * It expects a certain order of children to work properly: the first child should be the node itself,
410
+ * and the second child should be a nested subtree in the form of another Tree component or a standalone TreeItem.
411
+ * This order follows the same order as document traversal for the TreeWalker API in JavaScript:
412
+ * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker.
413
+ * The content and layout of a TreeItem can be defined using the TreeItemLayout or TreeItemPersonaLayout component,
414
+ * which should be used as a direct child of TreeItem.
415
+ *
416
+ * When a TreeItem has nested child subtree, an expand/collapse control is displayed,
417
+ * allowing the user to show or hide the children.
181
418
  */
182
419
  export declare const TreeItem: ForwardRefComponent<TreeItemProps>;
183
420
 
184
421
  export declare const treeItemClassNames: SlotClassNames<TreeItemSlots>;
185
422
 
186
- declare type TreeItemContextValue = {
423
+ export declare type TreeItemContextValue = {
187
424
  isActionsVisible: boolean;
425
+ isAsideVisible: boolean;
426
+ selectionRef: React_2.Ref<HTMLInputElement>;
427
+ actionsRef: React_2.Ref<HTMLDivElement>;
428
+ expandIconRef: React_2.Ref<HTMLDivElement>;
429
+ layoutRef: React_2.Ref<HTMLDivElement>;
430
+ subtreeRef: React_2.Ref<HTMLDivElement>;
431
+ itemType: TreeItemType;
432
+ value: TreeItemValue;
433
+ open: boolean;
434
+ checked?: TreeSelectionValue;
188
435
  };
189
436
 
190
437
  declare type TreeItemContextValues = {
191
438
  treeItem: TreeItemContextValue;
192
- button: ButtonContextValue;
193
439
  };
194
440
 
195
441
  declare type TreeItemCSSProperties = React_2.CSSProperties & {
196
442
  [treeItemLevelToken]?: string | number;
197
443
  };
198
444
 
199
- export declare type TreeItemId = string | number;
200
-
201
445
  /**
202
- * TreeItemLayout component - TODO: add more docs
446
+ * The `TreeItemLayout` component is used as a child of `TreeItem` to define the content and layout of a tree item.
447
+ * It provides a consistent visual structure for tree items in a `Tree` component.
448
+ * This component should only be used as a direct child of `TreeItem`.
203
449
  */
204
450
  export declare const TreeItemLayout: ForwardRefComponent<TreeItemLayoutProps>;
205
451
 
@@ -212,26 +458,50 @@ export declare type TreeItemLayoutProps = ComponentProps<Partial<TreeItemLayoutS
212
458
 
213
459
  export declare type TreeItemLayoutSlots = {
214
460
  root: Slot<'div'>;
461
+ /**
462
+ * Content. Children of the root slot are automatically rendered here
463
+ */
464
+ main: NonNullable<Slot<'div'>>;
215
465
  /**
216
466
  * Icon slot that renders right before main content
217
467
  */
218
- iconBefore?: Slot<'span'>;
468
+ iconBefore?: Slot<'div'>;
219
469
  /**
220
470
  * Icon slot that renders right after main content
221
471
  */
222
- iconAfter?: Slot<'span'>;
223
- aside?: Slot<'span'>;
472
+ iconAfter?: Slot<'div'>;
473
+ /**
474
+ * Expand icon slot,
475
+ * by default renders a chevron icon to indicate opening and closing
476
+ */
477
+ expandIcon?: Slot<'div'>;
478
+ aside?: Slot<'div'>;
479
+ /**
480
+ * actionable elements are normally buttons, menus, or other focusable elements.
481
+ * Those elements are only visibly available if the given tree item is currently active.
482
+ */
483
+ actions?: Slot<ExtractSlotProps<Slot<'div'> & {
484
+ /**
485
+ * Forces visibility of the aside/action content
486
+ */
487
+ visible?: boolean;
488
+ }>>;
489
+ selector?: Slot<typeof Checkbox> | Slot<typeof Radio>;
224
490
  };
225
491
 
226
492
  /**
227
493
  * State used in rendering TreeItemLayout
228
494
  */
229
- export declare type TreeItemLayoutState = ComponentState<TreeItemLayoutSlots> & TreeItemContextValue;
495
+ export declare type TreeItemLayoutState = ComponentState<TreeItemLayoutSlots> & {
496
+ buttonContextValue: ButtonContextValue;
497
+ };
230
498
 
231
499
  export declare const treeItemLevelToken: "--fluent-TreeItem--level";
232
500
 
233
501
  /**
234
- * TreeItemPersonaLayout component - TODO: add more docs
502
+ * The `TreeItemPersonaLayout` component is used as a child of `TreeItem` to display a `TreeItem` with a media (typically an avatar) and a description.
503
+ * It provides a more visually appealing representation of a `TreeItem` and is typically used to display a list of people or topics.
504
+ * This component should only be used as a direct child of `TreeItem`.
235
505
  */
236
506
  export declare const TreeItemPersonaLayout: ForwardRefComponent<TreeItemPersonaLayoutProps>;
237
507
 
@@ -246,140 +516,112 @@ declare type TreeItemPersonaLayoutContextValues = {
246
516
  */
247
517
  export declare type TreeItemPersonaLayoutProps = ComponentProps<Partial<TreeItemPersonaLayoutSlots>>;
248
518
 
249
- export declare type TreeItemPersonaLayoutSlots = {
250
- root: Slot<'span'>;
519
+ export declare type TreeItemPersonaLayoutSlots = Pick<TreeItemLayoutSlots, 'actions' | 'aside' | 'expandIcon' | 'selector'> & {
520
+ root: NonNullable<Slot<'div'>>;
251
521
  /**
252
522
  * Avatar to display.
253
523
  */
254
- media: NonNullable<Slot<'span'>>;
255
- /**
256
- * Main text. Children of the root slot are automatically rendered here
257
- */
258
- main: Slot<'span'>;
524
+ media: NonNullable<Slot<'div'>>;
259
525
  /**
260
- * Secondary text that describes or complements the main text
526
+ * Content. Children of the root slot are automatically rendered here
261
527
  */
262
- description?: Slot<'span'>;
528
+ main: NonNullable<Slot<'div'>>;
263
529
  /**
264
- * aside text that works as extra textual information
530
+ * Secondary text that describes or complements the content
265
531
  */
266
- aside?: Slot<'span'>;
267
- /**
268
- * A layout wrapper for the main and description slots
269
- */
270
- content: Slot<'div'>;
532
+ description?: Slot<'div'>;
271
533
  };
272
534
 
273
535
  /**
274
536
  * State used in rendering TreeItemPersonaLayout
275
537
  */
276
- export declare type TreeItemPersonaLayoutState = ComponentState<TreeItemPersonaLayoutSlots> & TreeItemContextValue & {
538
+ export declare type TreeItemPersonaLayoutState = ComponentState<TreeItemPersonaLayoutSlots> & {
277
539
  avatarSize: AvatarSize;
540
+ buttonContextValue: ButtonContextValue;
278
541
  };
279
542
 
280
543
  /**
281
544
  * TreeItem Props
282
545
  */
283
546
  export declare type TreeItemProps = ComponentProps<Partial<TreeItemSlots>> & {
284
- /**
285
- * If a TreeItem is a leaf, it'll not present the `expandIcon` slot by default.
286
- * This attribute is used to force the decision if a TreeItem is a leaf or not. By not providing this property
287
- * this will be inferred by the presence of a subtree as part of the TreeItem children.
288
- */
289
- leaf?: boolean;
547
+ itemType: TreeItemType;
548
+ value?: TreeItemValue;
290
549
  };
291
550
 
292
- export declare const TreeItemProvider: React_2.Provider<TreeItemContextValue | undefined>;
551
+ export declare const TreeItemProvider: React_2.Provider<TreeItemContextValue | undefined> & React_2.FC<React_2.ProviderProps<TreeItemContextValue | undefined>>;
552
+
553
+ declare type TreeItemRequest = {
554
+ itemType: TreeItemType;
555
+ } & (OmitWithoutExpanding<TreeOpenChangeData, 'open' | 'openItems'> | TreeNavigationData_unstable | OmitWithoutExpanding<TreeCheckedChangeData, 'selectionMode' | 'checkedItems'>);
293
556
 
294
557
  export declare type TreeItemSlots = {
295
558
  root: Slot<ExtractSlotProps<Slot<'div'> & {
296
559
  style?: TreeItemCSSProperties;
297
560
  }>>;
298
- content: NonNullable<Slot<'div'>>;
299
- subtree?: Slot<'span'>;
300
- /**
301
- * Expand icon slot,
302
- * by default renders a chevron icon to indicate opening and closing
303
- */
304
- expandIcon?: Slot<'span'>;
305
- /**
306
- * Actions slot that renders on the end of tree item
307
- * when the item is hovered/focused
308
- */
309
- actions?: Slot<'span'>;
310
561
  };
311
562
 
312
563
  /**
313
564
  * State used in rendering TreeItem
314
565
  */
315
- export declare type TreeItemState = ComponentState<TreeItemSlots> & {
316
- open: boolean;
317
- isLeaf: boolean;
566
+ export declare type TreeItemState = ComponentState<TreeItemSlots> & TreeItemContextValue & {
318
567
  level: number;
319
- /**
320
- * By design, a button included on the actions slot should be small
321
- */
322
- buttonSize: 'small';
323
- isActionsVisible: boolean;
568
+ itemType: TreeItemType;
324
569
  };
325
570
 
571
+ declare type TreeItemType = 'leaf' | 'branch';
572
+
573
+ export declare type TreeItemValue = string | number;
574
+
326
575
  export declare type TreeNavigationData_unstable = {
327
- event: React_2.MouseEvent<HTMLElement>;
328
576
  target: HTMLElement;
577
+ value: TreeItemValue;
578
+ } & ({
579
+ event: React_2.MouseEvent<HTMLElement>;
329
580
  type: 'Click';
330
581
  } | {
331
582
  event: React_2.KeyboardEvent<HTMLElement>;
332
- target: HTMLElement;
333
583
  type: 'TypeAhead';
334
584
  } | {
335
585
  event: React_2.KeyboardEvent<HTMLElement>;
336
- target: HTMLElement;
337
586
  type: typeof ArrowRight;
338
587
  } | {
339
588
  event: React_2.KeyboardEvent<HTMLElement>;
340
- target: HTMLElement;
341
589
  type: typeof ArrowLeft;
342
590
  } | {
343
591
  event: React_2.KeyboardEvent<HTMLElement>;
344
- target: HTMLElement;
345
592
  type: typeof ArrowUp;
346
593
  } | {
347
594
  event: React_2.KeyboardEvent<HTMLElement>;
348
- target: HTMLElement;
349
595
  type: typeof ArrowDown;
350
596
  } | {
351
597
  event: React_2.KeyboardEvent<HTMLElement>;
352
- target: HTMLElement;
353
598
  type: typeof Home;
354
599
  } | {
355
600
  event: React_2.KeyboardEvent<HTMLElement>;
356
- target: HTMLElement;
357
601
  type: typeof End;
358
- };
602
+ });
359
603
 
360
604
  export declare type TreeNavigationEvent_unstable = TreeNavigationData_unstable['event'];
361
605
 
362
606
  export declare type TreeOpenChangeData = {
363
607
  open: boolean;
608
+ openItems: Set<TreeItemValue>;
609
+ value: TreeItemValue;
610
+ target: HTMLElement;
364
611
  } & ({
365
612
  event: React_2.MouseEvent<HTMLElement>;
366
- target: HTMLElement;
367
613
  type: 'ExpandIconClick';
368
614
  } | {
369
615
  event: React_2.MouseEvent<HTMLElement>;
370
- target: HTMLElement;
371
616
  type: 'Click';
372
617
  } | {
373
618
  event: React_2.KeyboardEvent<HTMLElement>;
374
- target: HTMLElement;
375
619
  type: typeof Enter;
376
620
  } | {
377
621
  event: React_2.KeyboardEvent<HTMLElement>;
378
- target: HTMLElement;
379
622
  type: typeof ArrowRight;
380
623
  } | {
381
624
  event: React_2.KeyboardEvent<HTMLElement>;
382
- target: HTMLElement;
383
625
  type: typeof ArrowLeft;
384
626
  });
385
627
 
@@ -404,13 +646,12 @@ export declare type TreeProps = ComponentProps<TreeSlots> & {
404
646
  * Controls the state of the open tree items.
405
647
  * These property is ignored for subtrees.
406
648
  */
407
- openItems?: Iterable<TreeItemId>;
649
+ openItems?: Iterable<TreeItemValue>;
408
650
  /**
409
- * This refers to a list of ids of opened tree items.
410
- * Default value for the uncontrolled state of open tree items.
411
- * These property is ignored for subtrees.
651
+ * This refers to a list of ids of default opened items.
652
+ * This property is ignored for subtrees.
412
653
  */
413
- defaultOpenItems?: Iterable<TreeItemId>;
654
+ defaultOpenItems?: Iterable<TreeItemValue>;
414
655
  /**
415
656
  * Callback fired when the component changes value from open state.
416
657
  * These property is ignored for subtrees.
@@ -430,18 +671,59 @@ export declare type TreeProps = ComponentProps<TreeSlots> & {
430
671
  * @param data - A data object with relevant information,
431
672
  */
432
673
  onNavigation_unstable?(event: TreeNavigationEvent_unstable, data: TreeNavigationData_unstable): void;
674
+ /**
675
+ * This refers to the selection mode of the tree.
676
+ * - undefined: No selection can be done.
677
+ * - 'single': Only one tree item can be selected, radio buttons are rendered.
678
+ * - 'multiselect': Multiple tree items can be selected, checkboxes are rendered.
679
+ *
680
+ * @default undefined
681
+ */
682
+ selectionMode?: SelectionMode_2;
683
+ /**
684
+ * This refers to a list of ids of checked tree items, or a list of tuples of ids and checked state.
685
+ * Controls the state of the checked tree items.
686
+ * These property is ignored for subtrees.
687
+ */
688
+ checkedItems?: Iterable<TreeItemValue | [TreeItemValue, TreeSelectionValue]>;
689
+ /**
690
+ * This refers to a list of ids of default checked items, or a list of tuples of ids and checked state.
691
+ * These property is ignored for subtrees.
692
+ */
693
+ defaultCheckedItems?: Iterable<TreeItemValue | [TreeItemValue, TreeSelectionValue]>;
694
+ /**
695
+ * Callback fired when the component changes value from checked state.
696
+ * These property is ignored for subtrees.
697
+ *
698
+ * @param event - a React's Synthetic event
699
+ * @param data - A data object with relevant information,
700
+ * such as checked value and type of interaction that created the event.
701
+ */
702
+ onCheckedChange?(event: TreeCheckedChangeEvent, data: TreeCheckedChangeData): void;
433
703
  };
434
704
 
435
705
  export declare const TreeProvider: Provider<TreeContextValue | undefined> & FC<ProviderProps<TreeContextValue | undefined>>;
436
706
 
437
- export declare type TreeSlots = {
707
+ export declare type TreeSelectionValue = MultiSelectValue | SingleSelectValue;
708
+
709
+ declare type TreeSlots = {
438
710
  root: Slot<'div'>;
439
711
  };
712
+ export { TreeSlots as FlatTreeSlots }
713
+ export { TreeSlots }
440
714
 
441
715
  /**
442
716
  * State used in rendering Tree
443
717
  */
444
- export declare type TreeState = ComponentState<TreeSlots> & TreeContextValue;
718
+ declare type TreeState = ComponentState<TreeSlots> & TreeContextValue & {
719
+ open: boolean;
720
+ };
721
+ export { TreeState as FlatTreeState }
722
+ export { TreeState }
723
+
724
+ export declare const useFlatTree_unstable: (props: FlatTreeProps, ref: React_2.Ref<HTMLElement>) => TreeState;
725
+
726
+ export declare const useFlatTreeStyles_unstable: (state: TreeState) => TreeState;
445
727
 
446
728
  /**
447
729
  * this hook provides FlatTree API to manage all required mechanisms to convert a list of items into renderable TreeItems
@@ -452,25 +734,18 @@ export declare type TreeState = ComponentState<TreeSlots> & TreeContextValue;
452
734
  * It should be used on cases where more complex interactions with a Tree is required.
453
735
  * On simple scenarios it is advised to simply use a nested structure instead.
454
736
  *
455
- * @param items - a list of tree items
737
+ * @param props - a list of tree items
456
738
  * @param options - in case control over the internal openItems is required
457
739
  */
458
- export declare function useFlatTree_unstable(items: FlatTreeItemProps[], options?: Pick<TreeProps, 'openItems' | 'defaultOpenItems'>): FlatTree;
740
+ export declare function useHeadlessFlatTree_unstable<Props extends HeadlessTreeItemProps>(props: Props[], options?: HeadlessFlatTreeOptions): HeadlessFlatTree<Props>;
459
741
 
460
- /**
461
- * Create the state required to render Tree.
462
- *
463
- * The returned state can be modified with hooks such as useTreeStyles_unstable,
464
- * before being passed to renderTree_unstable.
465
- *
466
- * @param props - props from this instance of Tree
467
- * @param ref - reference to root HTMLElement of Tree
468
- */
469
742
  export declare const useTree_unstable: (props: TreeProps, ref: React_2.Ref<HTMLElement>) => TreeState;
470
743
 
471
744
  export declare const useTreeContext_unstable: <T>(selector: ContextSelector<TreeContextValue, T>) => T;
472
745
 
473
- export declare function useTreeContextValues_unstable(state: TreeState): TreeContextValues;
746
+ declare function useTreeContextValues_unstable(state: TreeState): TreeContextValues;
747
+ export { useTreeContextValues_unstable as useFlatTreeContextValues_unstable }
748
+ export { useTreeContextValues_unstable }
474
749
 
475
750
  /**
476
751
  * Create the state required to render TreeItem.
@@ -481,9 +756,11 @@ export declare function useTreeContextValues_unstable(state: TreeState): TreeCon
481
756
  * @param props - props from this instance of TreeItem
482
757
  * @param ref - reference to root HTMLElement of TreeItem
483
758
  */
484
- export declare const useTreeItem_unstable: (props: TreeItemProps, ref: React_2.Ref<HTMLDivElement>) => TreeItemState;
759
+ export declare function useTreeItem_unstable(props: TreeItemProps, ref: React_2.Ref<HTMLDivElement>): TreeItemState;
760
+
761
+ export declare const useTreeItemContext_unstable: <T>(selector: ContextSelector<TreeItemContextValue, T>) => T;
485
762
 
486
- export declare const useTreeItemContext_unstable: () => TreeItemContextValue;
763
+ export declare function useTreeItemContextValues_unstable(state: TreeItemState): TreeItemContextValues;
487
764
 
488
765
  /**
489
766
  * Create the state required to render TreeItemLayout.