@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
package/CHANGELOG.json CHANGED
@@ -2,7 +2,58 @@
2
2
  "name": "@fluentui/react-tree",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 17 Apr 2023 17:50:12 GMT",
5
+ "date": "Mon, 24 Apr 2023 08:09:19 GMT",
6
+ "tag": "@fluentui/react-tree_v9.0.0-beta.12",
7
+ "version": "9.0.0-beta.12",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "bernardo.sunderhus@gmail.com",
12
+ "package": "@fluentui/react-tree",
13
+ "commit": "85c36e249b33b0bad79be4edd1a943dfc5233b11",
14
+ "comment": "bugfix: remove caret from react-jsx-runtime prerelease dependency"
15
+ },
16
+ {
17
+ "author": "bernardo.sunderhus@gmail.com",
18
+ "package": "@fluentui/react-tree",
19
+ "commit": "acbc5fcb1381e9adcc4e1fa678a374d42a79438b",
20
+ "comment": "bugfix: fix parent navigation after independency from id"
21
+ },
22
+ {
23
+ "author": "bernardo.sunderhus@gmail.com",
24
+ "package": "@fluentui/react-tree",
25
+ "commit": "4dde6727c7e7fe7fbf6fedb4e1619deddbd3e16a",
26
+ "comment": "feat: value property over id"
27
+ },
28
+ {
29
+ "author": "bernardo.sunderhus@gmail.com",
30
+ "package": "@fluentui/react-tree",
31
+ "commit": "ab5e8979917780ec8cf6b3b08b3696fc1b7a83f4",
32
+ "comment": "chore: restructure stories, add separate category for flat tree"
33
+ },
34
+ {
35
+ "author": "beachball",
36
+ "package": "@fluentui/react-tree",
37
+ "comment": "Bump @fluentui/react-avatar to v9.4.10",
38
+ "commit": "948b5bf9871303d1742f1b9a17a3bd4006ce2fea"
39
+ },
40
+ {
41
+ "author": "beachball",
42
+ "package": "@fluentui/react-tree",
43
+ "comment": "Bump @fluentui/react-button to v9.3.10",
44
+ "commit": "948b5bf9871303d1742f1b9a17a3bd4006ce2fea"
45
+ },
46
+ {
47
+ "author": "beachball",
48
+ "package": "@fluentui/react-tree",
49
+ "comment": "Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.2",
50
+ "commit": "948b5bf9871303d1742f1b9a17a3bd4006ce2fea"
51
+ }
52
+ ]
53
+ }
54
+ },
55
+ {
56
+ "date": "Mon, 17 Apr 2023 17:54:01 GMT",
6
57
  "tag": "@fluentui/react-tree_v9.0.0-beta.11",
7
58
  "version": "9.0.0-beta.11",
8
59
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,27 @@
1
1
  # Change Log - @fluentui/react-tree
2
2
 
3
- This log was last generated on Mon, 17 Apr 2023 17:50:12 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 24 Apr 2023 08:09:19 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0-beta.12](https://github.com/microsoft/fluentui/tree/@fluentui/react-tree_v9.0.0-beta.12)
8
+
9
+ Mon, 24 Apr 2023 08:09:19 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tree_v9.0.0-beta.11..@fluentui/react-tree_v9.0.0-beta.12)
11
+
12
+ ### Changes
13
+
14
+ - bugfix: remove caret from react-jsx-runtime prerelease dependency ([PR #27588](https://github.com/microsoft/fluentui/pull/27588) by bernardo.sunderhus@gmail.com)
15
+ - bugfix: fix parent navigation after independency from id ([PR #27642](https://github.com/microsoft/fluentui/pull/27642) by bernardo.sunderhus@gmail.com)
16
+ - feat: value property over id ([PR #27532](https://github.com/microsoft/fluentui/pull/27532) by bernardo.sunderhus@gmail.com)
17
+ - chore: restructure stories, add separate category for flat tree ([PR #27586](https://github.com/microsoft/fluentui/pull/27586) by bernardo.sunderhus@gmail.com)
18
+ - Bump @fluentui/react-avatar to v9.4.10 ([PR #27632](https://github.com/microsoft/fluentui/pull/27632) by beachball)
19
+ - Bump @fluentui/react-button to v9.3.10 ([PR #27632](https://github.com/microsoft/fluentui/pull/27632) by beachball)
20
+ - Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.2 ([PR #27632](https://github.com/microsoft/fluentui/pull/27632) by beachball)
21
+
7
22
  ## [9.0.0-beta.11](https://github.com/microsoft/fluentui/tree/@fluentui/react-tree_v9.0.0-beta.11)
8
23
 
9
- Mon, 17 Apr 2023 17:50:12 GMT
24
+ Mon, 17 Apr 2023 17:54:01 GMT
10
25
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tree_v9.0.0-beta.10..@fluentui/react-tree_v9.0.0-beta.11)
11
26
 
12
27
  ### Changes
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ import { ProviderProps } from 'react';
21
21
  import * as React_2 from 'react';
22
22
  import type { Slot } from '@fluentui/react-utilities';
23
23
  import type { SlotClassNames } from '@fluentui/react-utilities';
24
+ import { SlotRenderFunction } from '@fluentui/react-utilities';
24
25
 
25
26
  /**
26
27
  * Converts a nested structure to a flat one which can be consumed by `useFlatTreeItems`
@@ -62,7 +63,7 @@ import type { SlotClassNames } from '@fluentui/react-utilities';
62
63
  * ]);
63
64
  * ```
64
65
  */
65
- export declare const flattenTree_unstable: (items: NestedTreeItem[]) => FlatTreeItemProps[];
66
+ export declare const flattenTree_unstable: <Value = string>(items: NestedTreeItem<Value>[]) => FlatTreeItemProps<Value>[];
66
67
 
67
68
  /**
68
69
  * FlatTree API to manage all required mechanisms to convert a list of items into renderable TreeItems
@@ -74,13 +75,13 @@ export declare const flattenTree_unstable: (items: NestedTreeItem[]) => FlatTree
74
75
  *
75
76
  * On simple scenarios it is advised to simply use a nested structure instead.
76
77
  */
77
- export declare type FlatTree = {
78
+ export declare type FlatTree<Value = string> = {
78
79
  /**
79
80
  * returns the properties required for the Tree component to work properly.
80
81
  * That includes:
81
82
  * `openItems`, `onOpenChange`, `onNavigation_unstable` and `ref`
82
83
  */
83
- getTreeProps(): FlatTreeProps;
84
+ getTreeProps(): FlatTreeProps<Value>;
84
85
  /**
85
86
  * internal method used to react to an `onNavigation` event.
86
87
  * This method ensures proper navigation on keyboard and mouse interaction.
@@ -104,7 +105,7 @@ export declare type FlatTree = {
104
105
  * };
105
106
  *```
106
107
  */
107
- navigate(data: TreeNavigationData_unstable): void;
108
+ navigate(data: TreeNavigationData_unstable<Value>): void;
108
109
  /**
109
110
  * returns next item to be focused on a navigation.
110
111
  * This method is provided to decouple the element that needs to be focused from
@@ -112,21 +113,21 @@ export declare type FlatTree = {
112
113
  *
113
114
  * On the case of TypeAhead navigation this method returns the current item.
114
115
  */
115
- getNextNavigableItem(visibleItems: FlatTreeItem[], data: TreeNavigationData_unstable): FlatTreeItem | undefined;
116
+ getNextNavigableItem(visibleItems: FlatTreeItem<Value>[], data: TreeNavigationData_unstable<Value>): FlatTreeItem<Value> | undefined;
116
117
  /**
117
118
  * an iterable containing all visually available flat tree items
118
119
  */
119
- items(): IterableIterator<FlatTreeItem>;
120
+ items(): IterableIterator<FlatTreeItem<Value>>;
120
121
  };
121
122
 
122
- export declare type FlatTreeItem = Readonly<MutableFlatTreeItem>;
123
+ export declare type FlatTreeItem<Value = string> = Readonly<MutableFlatTreeItem<Value>>;
123
124
 
124
- export declare type FlatTreeItemProps = TreeItemProps & {
125
- id: TreeItemId;
126
- parentId?: string;
125
+ export declare type FlatTreeItemProps<Value = string> = Omit<TreeItemProps, 'value'> & {
126
+ value: Value;
127
+ parentValue?: Value;
127
128
  };
128
129
 
129
- export declare type FlatTreeProps = Required<Pick<TreeProps, 'openItems' | 'onOpenChange' | 'onNavigation_unstable'> & {
130
+ export declare type FlatTreeProps<Value = string> = Required<Pick<TreeProps<Value>, 'openItems' | 'onOpenChange' | 'onNavigation_unstable'> & {
130
131
  ref: React_2.Ref<HTMLDivElement>;
131
132
  }>;
132
133
 
@@ -161,17 +162,18 @@ declare interface ImmutableSet<Value> {
161
162
  * Used internally on createFlatTreeItems and VisibleFlatTreeItemGenerator
162
163
  * to ensure required properties when building a FlatTreeITem
163
164
  */
164
- declare type MutableFlatTreeItem = {
165
- parentId?: string;
165
+ declare type MutableFlatTreeItem<Value = string> = {
166
+ parentValue?: Value;
166
167
  childrenSize: number;
167
168
  index: number;
168
- id: string;
169
+ value: Value;
169
170
  level: number;
170
- getTreeItemProps(): Required<Pick<TreeItemProps, 'id' | 'aria-setsize' | 'aria-level' | 'aria-posinset' | 'leaf'>> & TreeItemProps;
171
+ ref: React_2.RefObject<HTMLDivElement>;
172
+ getTreeItemProps(): Required<Pick<TreeItemProps<Value>, 'value' | 'aria-setsize' | 'aria-level' | 'aria-posinset' | 'leaf'>> & TreeItemProps<Value>;
171
173
  };
172
174
 
173
- export declare type NestedTreeItem = Omit<TreeItemProps, 'subtree'> & {
174
- subtree?: NestedTreeItem[];
175
+ export declare type NestedTreeItem<Value = string> = Omit<TreeItemProps<Value>, 'subtree'> & {
176
+ subtree?: NestedTreeItem<Value>[];
175
177
  };
176
178
 
177
179
  export declare const renderTree_unstable: (state: TreeState, contextValues: TreeContextValues) => JSX.Element;
@@ -199,7 +201,22 @@ export declare const renderTreeItemPersonaLayout_unstable: (state: TreeItemPerso
199
201
  * an item representing a folder can be expanded to reveal the contents of the folder,
200
202
  * which may be files, folders, or both.
201
203
  */
202
- export declare const Tree: ForwardRefComponent<TreeProps>;
204
+ export declare const Tree: React_2.ForwardRefExoticComponent<Omit<TreeSlots, "root"> & Omit<{
205
+ as?: "div" | undefined;
206
+ } & Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React_2.HTMLAttributes<HTMLDivElement>> & {
207
+ ref?: ((instance: HTMLDivElement | null) => void) | React_2.RefObject<HTMLDivElement> | null | undefined;
208
+ } & {
209
+ children?: React_2.ReactNode | SlotRenderFunction<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React_2.HTMLAttributes<HTMLDivElement>> & {
210
+ ref?: ((instance: HTMLDivElement | null) => void) | React_2.RefObject<HTMLDivElement> | null | undefined;
211
+ }>;
212
+ }, "ref"> & {
213
+ appearance?: "subtle" | "subtle-alpha" | "transparent" | undefined;
214
+ size?: "small" | "medium" | undefined;
215
+ openItems?: Iterable<string> | undefined;
216
+ defaultOpenItems?: Iterable<string> | undefined;
217
+ onOpenChange?(event: React_2.KeyboardEvent<HTMLElement> | React_2.MouseEvent<HTMLElement, MouseEvent>, data: TreeOpenChangeData<string>): void;
218
+ onNavigation_unstable?(event: React_2.KeyboardEvent<HTMLElement> | React_2.MouseEvent<HTMLElement, MouseEvent>, data: TreeNavigationData_unstable<string>): void;
219
+ } & React_2.RefAttributes<HTMLDivElement>> & (<Value = string>(props: TreeProps<Value>) => JSX.Element);
203
220
 
204
221
  export declare const treeClassNames: SlotClassNames<TreeSlots>;
205
222
 
@@ -207,12 +224,12 @@ export declare type TreeContextValue = {
207
224
  level: number;
208
225
  appearance: 'subtle' | 'subtle-alpha' | 'transparent';
209
226
  size: 'small' | 'medium';
210
- openItems: ImmutableSet<TreeItemId>;
227
+ openItems: ImmutableSet<unknown>;
211
228
  /**
212
229
  * Requests dialog main component to update it's internal open state
213
230
  */
214
- requestOpenChange(data: TreeOpenChangeData): void;
215
- requestNavigation(data: TreeNavigationData_unstable): void;
231
+ requestOpenChange(data: TreeOpenChangeData<unknown>): void;
232
+ requestNavigation(data: TreeNavigationData_unstable<unknown>): void;
216
233
  };
217
234
 
218
235
  declare type TreeContextValues = {
@@ -228,10 +245,23 @@ declare type TreeContextValues = {
228
245
  * The content and layout of a TreeItem can be defined using the TreeItemLayout or TreeItemPersonaLayout component,
229
246
  * which should be used as a direct child of TreeItem.
230
247
  *
231
- * When a TreeItem has nsted child subtree, an expand/collapse control is displayed,
248
+ * When a TreeItem has nested child subtree, an expand/collapse control is displayed,
232
249
  * allowing the user to show or hide the children.
233
250
  */
234
- export declare const TreeItem: ForwardRefComponent<TreeItemProps>;
251
+ export declare const TreeItem: React_2.ForwardRefExoticComponent<Omit<Partial<TreeItemSlots>, "root"> & Omit<{
252
+ as?: "div" | undefined;
253
+ } & Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React_2.HTMLAttributes<HTMLDivElement>> & {
254
+ ref?: ((instance: HTMLDivElement | null) => void) | React_2.RefObject<HTMLDivElement> | null | undefined;
255
+ } & {
256
+ children?: React_2.ReactNode | SlotRenderFunction<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React_2.HTMLAttributes<HTMLDivElement>> & {
257
+ ref?: ((instance: HTMLDivElement | null) => void) | React_2.RefObject<HTMLDivElement> | null | undefined;
258
+ }>;
259
+ } & {
260
+ style?: TreeItemCSSProperties | undefined;
261
+ }, "ref"> & {
262
+ value?: string | undefined;
263
+ leaf?: boolean | undefined;
264
+ } & React_2.RefAttributes<HTMLDivElement>> & (<Value = string>(props: TreeItemProps<Value>) => JSX.Element);
235
265
 
236
266
  export declare const treeItemClassNames: SlotClassNames<TreeItemSlots>;
237
267
 
@@ -248,8 +278,6 @@ declare type TreeItemCSSProperties = React_2.CSSProperties & {
248
278
  [treeItemLevelToken]?: string | number;
249
279
  };
250
280
 
251
- export declare type TreeItemId = string;
252
-
253
281
  /**
254
282
  * The `TreeItemLayout` component is used as a child of `TreeItem` to define the content and layout of a tree item.
255
283
  * It provides a consistent visual structure for tree items in a `Tree` component.
@@ -265,7 +293,7 @@ export declare const treeItemLayoutClassNames: SlotClassNames<TreeItemLayoutSlot
265
293
  export declare type TreeItemLayoutProps = ComponentProps<Partial<TreeItemLayoutSlots>>;
266
294
 
267
295
  export declare type TreeItemLayoutSlots = {
268
- root: Slot<'div'>;
296
+ root: Slot<'span'>;
269
297
  /**
270
298
  * Icon slot that renders right before main content
271
299
  */
@@ -274,6 +302,9 @@ export declare type TreeItemLayoutSlots = {
274
302
  * Icon slot that renders right after main content
275
303
  */
276
304
  iconAfter?: Slot<'span'>;
305
+ /**
306
+ * slot that render right after main content and iconAfter
307
+ */
277
308
  aside?: Slot<'span'>;
278
309
  };
279
310
 
@@ -336,7 +367,8 @@ export declare type TreeItemPersonaLayoutState = ComponentState<TreeItemPersonaL
336
367
  /**
337
368
  * TreeItem Props
338
369
  */
339
- export declare type TreeItemProps = ComponentProps<Partial<TreeItemSlots>> & {
370
+ export declare type TreeItemProps<Value = string> = ComponentProps<Partial<TreeItemSlots>> & {
371
+ value?: Value;
340
372
  /**
341
373
  * If a TreeItem is a leaf, it'll not present the `expandIcon` slot by default.
342
374
  * This attribute is used to force the decision if a TreeItem is a leaf or not. By not providing this property
@@ -379,44 +411,40 @@ export declare type TreeItemState = ComponentState<TreeItemSlots> & {
379
411
  isActionsVisible: boolean;
380
412
  };
381
413
 
382
- export declare type TreeNavigationData_unstable = {
383
- event: React_2.MouseEvent<HTMLElement>;
414
+ export declare type TreeNavigationData_unstable<Value = string> = {
415
+ value: Value;
384
416
  target: HTMLElement;
417
+ } & ({
418
+ event: React_2.MouseEvent<HTMLElement>;
385
419
  type: 'Click';
386
420
  } | {
387
421
  event: React_2.KeyboardEvent<HTMLElement>;
388
- target: HTMLElement;
389
422
  type: 'TypeAhead';
390
423
  } | {
391
424
  event: React_2.KeyboardEvent<HTMLElement>;
392
- target: HTMLElement;
393
425
  type: typeof ArrowRight;
394
426
  } | {
395
427
  event: React_2.KeyboardEvent<HTMLElement>;
396
- target: HTMLElement;
397
428
  type: typeof ArrowLeft;
398
429
  } | {
399
430
  event: React_2.KeyboardEvent<HTMLElement>;
400
- target: HTMLElement;
401
431
  type: typeof ArrowUp;
402
432
  } | {
403
433
  event: React_2.KeyboardEvent<HTMLElement>;
404
- target: HTMLElement;
405
434
  type: typeof ArrowDown;
406
435
  } | {
407
436
  event: React_2.KeyboardEvent<HTMLElement>;
408
- target: HTMLElement;
409
437
  type: typeof Home;
410
438
  } | {
411
439
  event: React_2.KeyboardEvent<HTMLElement>;
412
- target: HTMLElement;
413
440
  type: typeof End;
414
- };
441
+ });
415
442
 
416
443
  export declare type TreeNavigationEvent_unstable = TreeNavigationData_unstable['event'];
417
444
 
418
- export declare type TreeOpenChangeData = {
445
+ export declare type TreeOpenChangeData<Value = string> = {
419
446
  open: boolean;
447
+ value: Value;
420
448
  } & ({
421
449
  event: React_2.MouseEvent<HTMLElement>;
422
450
  target: HTMLElement;
@@ -441,7 +469,7 @@ export declare type TreeOpenChangeData = {
441
469
 
442
470
  export declare type TreeOpenChangeEvent = TreeOpenChangeData['event'];
443
471
 
444
- export declare type TreeProps = ComponentProps<TreeSlots> & {
472
+ export declare type TreeProps<Value = string> = ComponentProps<TreeSlots> & {
445
473
  /**
446
474
  * A tree item can have various appearances:
447
475
  * - 'subtle' (default): The default tree item styles.
@@ -460,13 +488,13 @@ export declare type TreeProps = ComponentProps<TreeSlots> & {
460
488
  * Controls the state of the open tree items.
461
489
  * These property is ignored for subtrees.
462
490
  */
463
- openItems?: Iterable<TreeItemId>;
491
+ openItems?: Iterable<Value>;
464
492
  /**
465
493
  * This refers to a list of ids of opened tree items.
466
494
  * Default value for the uncontrolled state of open tree items.
467
495
  * These property is ignored for subtrees.
468
496
  */
469
- defaultOpenItems?: Iterable<TreeItemId>;
497
+ defaultOpenItems?: Iterable<Value>;
470
498
  /**
471
499
  * Callback fired when the component changes value from open state.
472
500
  * These property is ignored for subtrees.
@@ -475,7 +503,7 @@ export declare type TreeProps = ComponentProps<TreeSlots> & {
475
503
  * @param data - A data object with relevant information,
476
504
  * such as open value and type of interaction that created the event.
477
505
  */
478
- onOpenChange?(event: TreeOpenChangeEvent, data: TreeOpenChangeData): void;
506
+ onOpenChange?(event: TreeOpenChangeEvent, data: TreeOpenChangeData<Value>): void;
479
507
  /**
480
508
  * Callback fired when navigation happens inside the component.
481
509
  * These property is ignored for subtrees.
@@ -485,7 +513,7 @@ export declare type TreeProps = ComponentProps<TreeSlots> & {
485
513
  * @param event - a React's Synthetic event
486
514
  * @param data - A data object with relevant information,
487
515
  */
488
- onNavigation_unstable?(event: TreeNavigationEvent_unstable, data: TreeNavigationData_unstable): void;
516
+ onNavigation_unstable?(event: TreeNavigationEvent_unstable, data: TreeNavigationData_unstable<Value>): void;
489
517
  };
490
518
 
491
519
  export declare const TreeProvider: Provider<TreeContextValue | undefined> & FC<ProviderProps<TreeContextValue | undefined>>;
@@ -511,7 +539,7 @@ export declare type TreeState = ComponentState<TreeSlots> & TreeContextValue;
511
539
  * @param flatTreeItemProps - a list of tree items
512
540
  * @param options - in case control over the internal openItems is required
513
541
  */
514
- export declare function useFlatTree_unstable(flatTreeItemProps: FlatTreeItemProps[], options?: Pick<TreeProps, 'openItems' | 'defaultOpenItems' | 'onOpenChange' | 'onNavigation_unstable'>): FlatTree;
542
+ export declare function useFlatTree_unstable<Value = string>(flatTreeItemProps: FlatTreeItemProps<Value>[], options?: Pick<TreeProps<Value>, 'openItems' | 'defaultOpenItems' | 'onOpenChange' | 'onNavigation_unstable'>): FlatTree<Value>;
515
543
 
516
544
  /**
517
545
  * Create the state required to render Tree.
@@ -537,7 +565,7 @@ export declare function useTreeContextValues_unstable(state: TreeState): TreeCon
537
565
  * @param props - props from this instance of TreeItem
538
566
  * @param ref - reference to root HTMLElement of TreeItem
539
567
  */
540
- export declare const useTreeItem_unstable: (props: TreeItemProps, ref: React_2.Ref<HTMLDivElement>) => TreeItemState;
568
+ export declare function useTreeItem_unstable<Value = string>(props: TreeItemProps<Value>, ref: React_2.Ref<HTMLDivElement>): TreeItemState;
541
569
 
542
570
  export declare const useTreeItemContext_unstable: () => TreeItemContextValue;
543
571
 
@@ -1 +1 @@
1
- {"version":3,"names":["React","useTree_unstable","renderTree_unstable","useTreeStyles_unstable","useTreeContextValues_unstable","Tree","forwardRef","props","ref","state","contextValues","displayName"],"sources":["../../../src/components/Tree/Tree.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useTree_unstable } from './useTree';\nimport { renderTree_unstable } from './renderTree';\nimport { useTreeStyles_unstable } from './useTreeStyles';\nimport type { TreeProps } from './Tree.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useTreeContextValues_unstable } from './useTreeContextValues';\n\n/**\n * A tree view widget presents a hierarchical list.\n * Any item in the hierarchy may have child items,\n * and items that have children may be expanded or collapsed to show or hide the children.\n * For example, in a file system navigator that uses a tree view to display folders and files,\n * an item representing a folder can be expanded to reveal the contents of the folder,\n * which may be files, folders, or both.\n */\nexport const Tree: ForwardRefComponent<TreeProps> = React.forwardRef((props, ref) => {\n const state = useTree_unstable(props, ref);\n useTreeStyles_unstable(state);\n const contextValues = useTreeContextValues_unstable(state);\n return renderTree_unstable(state, contextValues);\n});\n\nTree.displayName = 'Tree';\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,gBAAgB,QAAQ;AACjC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,sBAAsB,QAAQ;AAGvC,SAASC,6BAA6B,QAAQ;AAE9C;;;;;;;;AAQA,OAAO,MAAMC,IAAA,gBAAuCL,KAAA,CAAMM,UAAU,CAAC,CAACC,KAAA,EAAOC,GAAA,KAAQ;EACnF,MAAMC,KAAA,GAAQR,gBAAA,CAAiBM,KAAA,EAAOC,GAAA;EACtCL,sBAAA,CAAuBM,KAAA;EACvB,MAAMC,aAAA,GAAgBN,6BAAA,CAA8BK,KAAA;EACpD,OAAOP,mBAAA,CAAoBO,KAAA,EAAOC,aAAA;AACpC;AAEAL,IAAA,CAAKM,WAAW,GAAG"}
1
+ {"version":3,"names":["React","useTree_unstable","renderTree_unstable","useTreeStyles_unstable","useTreeContextValues_unstable","Tree","forwardRef","props","ref","state","contextValues","displayName"],"sources":["../../../src/components/Tree/Tree.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useTree_unstable } from './useTree';\nimport { renderTree_unstable } from './renderTree';\nimport { useTreeStyles_unstable } from './useTreeStyles';\nimport type { TreeProps } from './Tree.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useTreeContextValues_unstable } from './useTreeContextValues';\n\n/**\n * A tree view widget presents a hierarchical list.\n * Any item in the hierarchy may have child items,\n * and items that have children may be expanded or collapsed to show or hide the children.\n * For example, in a file system navigator that uses a tree view to display folders and files,\n * an item representing a folder can be expanded to reveal the contents of the folder,\n * which may be files, folders, or both.\n */\nexport const Tree = React.forwardRef((props, ref) => {\n const state = useTree_unstable(props, ref);\n useTreeStyles_unstable(state);\n const contextValues = useTreeContextValues_unstable(state);\n return renderTree_unstable(state, contextValues);\n}) as ForwardRefComponent<TreeProps> & (<Value = string>(props: TreeProps<Value>) => JSX.Element);\n\nTree.displayName = 'Tree';\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,gBAAgB,QAAQ;AACjC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,sBAAsB,QAAQ;AAGvC,SAASC,6BAA6B,QAAQ;AAE9C;;;;;;;;AAQA,OAAO,MAAMC,IAAA,gBAAOL,KAAA,CAAMM,UAAU,CAAC,CAACC,KAAA,EAAOC,GAAA,KAAQ;EACnD,MAAMC,KAAA,GAAQR,gBAAA,CAAiBM,KAAA,EAAOC,GAAA;EACtCL,sBAAA,CAAuBM,KAAA;EACvB,MAAMC,aAAA,GAAgBN,6BAAA,CAA8BK,KAAA;EACpD,OAAOP,mBAAA,CAAoBO,KAAA,EAAOC,aAAA;AACpC;AAEAL,IAAA,CAAKM,WAAW,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"names":["React"],"sources":["../../../src/components/Tree/Tree.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { TreeContextValue } from '../../contexts/treeContext';\nimport { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Home } from '@fluentui/keyboard-keys';\nimport { TreeItemId } from '../TreeItem/TreeItem.types';\n\nexport type TreeSlots = {\n root: Slot<'div'>;\n};\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type TreeNavigationData_unstable =\n | { event: React.MouseEvent<HTMLElement>; target: HTMLElement; type: 'Click' }\n | { event: React.KeyboardEvent<HTMLElement>; target: HTMLElement; type: 'TypeAhead' }\n | { event: React.KeyboardEvent<HTMLElement>; target: HTMLElement; type: typeof ArrowRight }\n | { event: React.KeyboardEvent<HTMLElement>; target: HTMLElement; type: typeof ArrowLeft }\n | { event: React.KeyboardEvent<HTMLElement>; target: HTMLElement; type: typeof ArrowUp }\n | { event: React.KeyboardEvent<HTMLElement>; target: HTMLElement; type: typeof ArrowDown }\n | { event: React.KeyboardEvent<HTMLElement>; target: HTMLElement; type: typeof Home }\n | { event: React.KeyboardEvent<HTMLElement>; target: HTMLElement; type: typeof End };\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type TreeNavigationEvent_unstable = TreeNavigationData_unstable['event'];\n\nexport type TreeOpenChangeData = { open: boolean } & (\n | {\n event: React.MouseEvent<HTMLElement>;\n target: HTMLElement;\n type: 'ExpandIconClick';\n }\n | {\n event: React.MouseEvent<HTMLElement>;\n target: HTMLElement;\n type: 'Click';\n }\n | {\n event: React.KeyboardEvent<HTMLElement>;\n target: HTMLElement;\n type: typeof Enter;\n }\n | {\n event: React.KeyboardEvent<HTMLElement>;\n target: HTMLElement;\n type: typeof ArrowRight;\n }\n | {\n event: React.KeyboardEvent<HTMLElement>;\n target: HTMLElement;\n type: typeof ArrowLeft;\n }\n);\n\nexport type TreeOpenChangeEvent = TreeOpenChangeData['event'];\n\nexport type TreeContextValues = {\n tree: TreeContextValue;\n};\n\nexport type TreeProps = ComponentProps<TreeSlots> & {\n /**\n * A tree item can have various appearances:\n * - 'subtle' (default): The default tree item styles.\n * - 'subtle-alpha': Minimizes emphasis on hovered or focused states.\n * - 'transparent': Removes background color.\n * @default 'subtle'\n */\n appearance?: 'subtle' | 'subtle-alpha' | 'transparent';\n /**\n * Size of the tree item.\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n /**\n * This refers to a list of ids of opened tree items.\n * Controls the state of the open tree items.\n * These property is ignored for subtrees.\n */\n openItems?: Iterable<TreeItemId>;\n /**\n * This refers to a list of ids of opened tree items.\n * Default value for the uncontrolled state of open tree items.\n * These property is ignored for subtrees.\n */\n defaultOpenItems?: Iterable<TreeItemId>;\n /**\n * Callback fired when the component changes value from open state.\n * These property is ignored for subtrees.\n *\n * @param event - a React's Synthetic event\n * @param data - A data object with relevant information,\n * such as open value and type of interaction that created the event.\n */\n onOpenChange?(event: TreeOpenChangeEvent, data: TreeOpenChangeData): void;\n\n /**\n * Callback fired when navigation happens inside the component.\n * These property is ignored for subtrees.\n *\n * FIXME: This method is not ideal, as navigation should be handled internally by tabster.\n *\n * @param event - a React's Synthetic event\n * @param data - A data object with relevant information,\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n onNavigation_unstable?(event: TreeNavigationEvent_unstable, data: TreeNavigationData_unstable): void;\n};\n\n/**\n * State used in rendering Tree\n */\nexport type TreeState = ComponentState<TreeSlots> & TreeContextValue;\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
1
+ {"version":3,"names":["React"],"sources":["../../../src/components/Tree/Tree.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { TreeContextValue } from '../../contexts/treeContext';\nimport { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Home } from '@fluentui/keyboard-keys';\n\nexport type TreeSlots = {\n root: Slot<'div'>;\n};\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type TreeNavigationData_unstable<Value = string> = { value: Value; target: HTMLElement } & (\n | { event: React.MouseEvent<HTMLElement>; type: 'Click' }\n | { event: React.KeyboardEvent<HTMLElement>; type: 'TypeAhead' }\n | { event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowRight }\n | { event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowLeft }\n | { event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowUp }\n | { event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowDown }\n | { event: React.KeyboardEvent<HTMLElement>; type: typeof Home }\n | { event: React.KeyboardEvent<HTMLElement>; type: typeof End }\n);\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type TreeNavigationEvent_unstable = TreeNavigationData_unstable['event'];\n\nexport type TreeOpenChangeData<Value = string> = { open: boolean; value: Value } & (\n | {\n event: React.MouseEvent<HTMLElement>;\n target: HTMLElement;\n type: 'ExpandIconClick';\n }\n | {\n event: React.MouseEvent<HTMLElement>;\n target: HTMLElement;\n type: 'Click';\n }\n | {\n event: React.KeyboardEvent<HTMLElement>;\n target: HTMLElement;\n type: typeof Enter;\n }\n | {\n event: React.KeyboardEvent<HTMLElement>;\n target: HTMLElement;\n type: typeof ArrowRight;\n }\n | {\n event: React.KeyboardEvent<HTMLElement>;\n target: HTMLElement;\n type: typeof ArrowLeft;\n }\n);\n\nexport type TreeOpenChangeEvent = TreeOpenChangeData['event'];\n\nexport type TreeContextValues = {\n tree: TreeContextValue;\n};\n\nexport type TreeProps<Value = string> = ComponentProps<TreeSlots> & {\n /**\n * A tree item can have various appearances:\n * - 'subtle' (default): The default tree item styles.\n * - 'subtle-alpha': Minimizes emphasis on hovered or focused states.\n * - 'transparent': Removes background color.\n * @default 'subtle'\n */\n appearance?: 'subtle' | 'subtle-alpha' | 'transparent';\n /**\n * Size of the tree item.\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n /**\n * This refers to a list of ids of opened tree items.\n * Controls the state of the open tree items.\n * These property is ignored for subtrees.\n */\n openItems?: Iterable<Value>;\n /**\n * This refers to a list of ids of opened tree items.\n * Default value for the uncontrolled state of open tree items.\n * These property is ignored for subtrees.\n */\n defaultOpenItems?: Iterable<Value>;\n /**\n * Callback fired when the component changes value from open state.\n * These property is ignored for subtrees.\n *\n * @param event - a React's Synthetic event\n * @param data - A data object with relevant information,\n * such as open value and type of interaction that created the event.\n */\n onOpenChange?(event: TreeOpenChangeEvent, data: TreeOpenChangeData<Value>): void;\n\n /**\n * Callback fired when navigation happens inside the component.\n * These property is ignored for subtrees.\n *\n * FIXME: This method is not ideal, as navigation should be handled internally by tabster.\n *\n * @param event - a React's Synthetic event\n * @param data - A data object with relevant information,\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n onNavigation_unstable?(event: TreeNavigationEvent_unstable, data: TreeNavigationData_unstable<Value>): void;\n};\n\n/**\n * State used in rendering Tree\n */\nexport type TreeState = ComponentState<TreeSlots> & TreeContextValue;\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
@@ -12,7 +12,7 @@ import { useTreeItemContextValues_unstable } from './useTreeItemContextValues';
12
12
  * The content and layout of a TreeItem can be defined using the TreeItemLayout or TreeItemPersonaLayout component,
13
13
  * which should be used as a direct child of TreeItem.
14
14
  *
15
- * When a TreeItem has nsted child subtree, an expand/collapse control is displayed,
15
+ * When a TreeItem has nested child subtree, an expand/collapse control is displayed,
16
16
  * allowing the user to show or hide the children.
17
17
  */
18
18
  export const TreeItem = /*#__PURE__*/React.forwardRef((props, ref) => {
@@ -1 +1 @@
1
- {"version":3,"names":["React","useTreeItem_unstable","renderTreeItem_unstable","useTreeItemStyles_unstable","useTreeItemContextValues_unstable","TreeItem","forwardRef","props","ref","state","contextValues","displayName"],"sources":["../../../src/components/TreeItem/TreeItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useTreeItem_unstable } from './useTreeItem';\nimport { renderTreeItem_unstable } from './renderTreeItem';\nimport { useTreeItemStyles_unstable } from './useTreeItemStyles';\nimport type { TreeItemProps } from './TreeItem.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useTreeItemContextValues_unstable } from './useTreeItemContextValues';\n\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: ForwardRefComponent<TreeItemProps> = React.forwardRef((props, ref) => {\n const state = useTreeItem_unstable(props, ref);\n\n useTreeItemStyles_unstable(state);\n const contextValues = useTreeItemContextValues_unstable(state);\n return renderTreeItem_unstable(state, contextValues);\n});\n\nTreeItem.displayName = 'TreeItem';\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,oBAAoB,QAAQ;AACrC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,0BAA0B,QAAQ;AAG3C,SAASC,iCAAiC,QAAQ;AAElD;;;;;;;;;;;;AAYA,OAAO,MAAMC,QAAA,gBAA+CL,KAAA,CAAMM,UAAU,CAAC,CAACC,KAAA,EAAOC,GAAA,KAAQ;EAC3F,MAAMC,KAAA,GAAQR,oBAAA,CAAqBM,KAAA,EAAOC,GAAA;EAE1CL,0BAAA,CAA2BM,KAAA;EAC3B,MAAMC,aAAA,GAAgBN,iCAAA,CAAkCK,KAAA;EACxD,OAAOP,uBAAA,CAAwBO,KAAA,EAAOC,aAAA;AACxC;AAEAL,QAAA,CAASM,WAAW,GAAG"}
1
+ {"version":3,"names":["React","useTreeItem_unstable","renderTreeItem_unstable","useTreeItemStyles_unstable","useTreeItemContextValues_unstable","TreeItem","forwardRef","props","ref","state","contextValues","displayName"],"sources":["../../../src/components/TreeItem/TreeItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useTreeItem_unstable } from './useTreeItem';\nimport { renderTreeItem_unstable } from './renderTreeItem';\nimport { useTreeItemStyles_unstable } from './useTreeItemStyles';\nimport type { TreeItemProps } from './TreeItem.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useTreeItemContextValues_unstable } from './useTreeItemContextValues';\n\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 = React.forwardRef((props, ref) => {\n const state = useTreeItem_unstable(props, ref);\n\n useTreeItemStyles_unstable(state);\n const contextValues = useTreeItemContextValues_unstable(state);\n return renderTreeItem_unstable(state, contextValues);\n}) as ForwardRefComponent<TreeItemProps> & (<Value = string>(props: TreeItemProps<Value>) => JSX.Element);\n\nTreeItem.displayName = 'TreeItem';\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,oBAAoB,QAAQ;AACrC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,0BAA0B,QAAQ;AAG3C,SAASC,iCAAiC,QAAQ;AAElD;;;;;;;;;;;;AAYA,OAAO,MAAMC,QAAA,gBAAWL,KAAA,CAAMM,UAAU,CAAC,CAACC,KAAA,EAAOC,GAAA,KAAQ;EACvD,MAAMC,KAAA,GAAQR,oBAAA,CAAqBM,KAAA,EAAOC,GAAA;EAE1CL,0BAAA,CAA2BM,KAAA;EAC3B,MAAMC,aAAA,GAAgBN,iCAAA,CAAkCK,KAAA;EACxD,OAAOP,uBAAA,CAAwBO,KAAA,EAAOC,aAAA;AACxC;AAEAL,QAAA,CAASM,WAAW,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"names":["React"],"sources":["../../../src/components/TreeItem/TreeItem.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport type { ButtonContextValue } from '@fluentui/react-button';\nimport type { TreeItemContextValue } from '../../contexts';\nimport { treeItemLevelToken } from '../../utils/tokens';\nimport * as React from 'react';\n\nexport type TreeItemCSSProperties = React.CSSProperties & { [treeItemLevelToken]?: string | number };\nexport type TreeItemId = string;\n\nexport type TreeItemSlots = {\n root: Slot<ExtractSlotProps<Slot<'div'> & { style?: TreeItemCSSProperties }>>;\n content: NonNullable<Slot<'div'>>;\n subtree?: Slot<'span'>;\n /**\n * Expand icon slot,\n * by default renders a chevron icon to indicate opening and closing\n */\n expandIcon?: Slot<'span'>;\n /**\n * Actions slot that renders on the end of tree item\n * when the item is hovered/focused\n */\n actions?: Slot<'span'>;\n};\n\nexport type TreeItemContextValues = {\n treeItem: TreeItemContextValue;\n button: ButtonContextValue;\n};\n\n/**\n * TreeItem Props\n */\nexport type TreeItemProps = ComponentProps<Partial<TreeItemSlots>> & {\n /**\n * If a TreeItem is a leaf, it'll not present the `expandIcon` slot by default.\n * This attribute is used to force the decision if a TreeItem is a leaf or not. By not providing this property\n * this will be inferred by the presence of a subtree as part of the TreeItem children.\n */\n leaf?: boolean;\n};\n\n/**\n * State used in rendering TreeItem\n */\nexport type TreeItemState = ComponentState<TreeItemSlots> & {\n open: boolean;\n isLeaf: boolean;\n level: number;\n /**\n * By design, a button included on the actions slot should be small\n */\n buttonSize: 'small';\n isActionsVisible: boolean;\n};\n"],"mappings":"AAIA,YAAYA,KAAA,MAAW"}
1
+ {"version":3,"names":["React"],"sources":["../../../src/components/TreeItem/TreeItem.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport type { ButtonContextValue } from '@fluentui/react-button';\nimport type { TreeItemContextValue } from '../../contexts';\nimport { treeItemLevelToken } from '../../utils/tokens';\nimport * as React from 'react';\n\nexport type TreeItemCSSProperties = React.CSSProperties & { [treeItemLevelToken]?: string | number };\n\nexport type TreeItemSlots = {\n root: Slot<ExtractSlotProps<Slot<'div'> & { style?: TreeItemCSSProperties }>>;\n content: NonNullable<Slot<'div'>>;\n subtree?: Slot<'span'>;\n /**\n * Expand icon slot,\n * by default renders a chevron icon to indicate opening and closing\n */\n expandIcon?: Slot<'span'>;\n /**\n * Actions slot that renders on the end of tree item\n * when the item is hovered/focused\n */\n actions?: Slot<'span'>;\n};\n\nexport type TreeItemContextValues = {\n treeItem: TreeItemContextValue;\n button: ButtonContextValue;\n};\n\n/**\n * TreeItem Props\n */\nexport type TreeItemProps<Value = string> = ComponentProps<Partial<TreeItemSlots>> & {\n value?: Value;\n /**\n * If a TreeItem is a leaf, it'll not present the `expandIcon` slot by default.\n * This attribute is used to force the decision if a TreeItem is a leaf or not. By not providing this property\n * this will be inferred by the presence of a subtree as part of the TreeItem children.\n */\n leaf?: boolean;\n};\n\n/**\n * State used in rendering TreeItem\n */\nexport type TreeItemState = ComponentState<TreeItemSlots> & {\n open: boolean;\n isLeaf: boolean;\n level: number;\n /**\n * By design, a button included on the actions slot should be small\n */\n buttonSize: 'small';\n isActionsVisible: boolean;\n};\n"],"mappings":"AAIA,YAAYA,KAAA,MAAW"}
@@ -18,9 +18,10 @@ import { treeDataTypes } from '../../utils/tokens';
18
18
  * @param props - props from this instance of TreeItem
19
19
  * @param ref - reference to root HTMLElement of TreeItem
20
20
  */
21
- export const useTreeItem_unstable = (props, ref) => {
21
+ export function useTreeItem_unstable(props, ref) {
22
22
  const [children, subtreeChildren] = React.Children.toArray(props.children);
23
23
  const contextLevel = useTreeContext_unstable(ctx => ctx.level);
24
+ const id = useId('fui-TreeItem-', props.id);
24
25
  const {
25
26
  content,
26
27
  subtree,
@@ -31,13 +32,13 @@ export const useTreeItem_unstable = (props, ref) => {
31
32
  onClick,
32
33
  onKeyDown,
33
34
  ['aria-level']: level = contextLevel,
35
+ value = id,
34
36
  ...rest
35
37
  } = props;
36
38
  const requestOpenChange = useTreeContext_unstable(ctx => ctx.requestOpenChange);
37
39
  const requestNavigation = useTreeContext_unstable(ctx => ctx.requestNavigation);
38
- const id = useId('fui-TreeItem-', props.id);
39
40
  const isBranch = !isLeaf;
40
- const open = useTreeContext_unstable(ctx => isBranch && ctx.openItems.has(id));
41
+ const open = useTreeContext_unstable(ctx => isBranch && ctx.openItems.has(value));
41
42
  const {
42
43
  dir,
43
44
  targetDocument
@@ -50,6 +51,7 @@ export const useTreeItem_unstable = (props, ref) => {
50
51
  if (!open && isBranch) {
51
52
  return requestOpenChange({
52
53
  event,
54
+ value,
53
55
  open: true,
54
56
  type: treeDataTypes.arrowRight,
55
57
  target: event.currentTarget
@@ -58,6 +60,7 @@ export const useTreeItem_unstable = (props, ref) => {
58
60
  if (open && isBranch) {
59
61
  return requestNavigation({
60
62
  event,
63
+ value,
61
64
  type: treeDataTypes.arrowRight,
62
65
  target: event.currentTarget
63
66
  });
@@ -67,6 +70,7 @@ export const useTreeItem_unstable = (props, ref) => {
67
70
  if (open && isBranch) {
68
71
  return requestOpenChange({
69
72
  event,
73
+ value,
70
74
  open: false,
71
75
  type: treeDataTypes.arrowLeft,
72
76
  target: event.currentTarget
@@ -75,6 +79,7 @@ export const useTreeItem_unstable = (props, ref) => {
75
79
  if (!open && level > 1) {
76
80
  return requestNavigation({
77
81
  event,
82
+ value,
78
83
  target: event.currentTarget,
79
84
  type: treeDataTypes.arrowLeft
80
85
  });
@@ -83,6 +88,7 @@ export const useTreeItem_unstable = (props, ref) => {
83
88
  const handleEnter = event => {
84
89
  requestOpenChange({
85
90
  event,
91
+ value,
86
92
  open: isLeaf ? open : !open,
87
93
  type: treeDataTypes.enter,
88
94
  target: event.currentTarget
@@ -101,12 +107,14 @@ export const useTreeItem_unstable = (props, ref) => {
101
107
  const isFromExpandIcon = expandIconRef.current && elementContains(expandIconRef.current, event.target);
102
108
  requestOpenChange({
103
109
  event,
110
+ value,
104
111
  open: isLeaf ? open : !open,
105
112
  type: isFromExpandIcon ? treeDataTypes.expandIconClick : treeDataTypes.click,
106
113
  target: event.currentTarget
107
114
  });
108
115
  requestNavigation({
109
116
  event,
117
+ value,
110
118
  target: event.currentTarget,
111
119
  type: treeDataTypes.click
112
120
  });
@@ -129,24 +137,28 @@ export const useTreeItem_unstable = (props, ref) => {
129
137
  case End:
130
138
  return requestNavigation({
131
139
  event,
140
+ value,
132
141
  type: treeDataTypes.end,
133
142
  target: event.currentTarget
134
143
  });
135
144
  case Home:
136
145
  return requestNavigation({
137
146
  event,
147
+ value,
138
148
  type: treeDataTypes.home,
139
149
  target: event.currentTarget
140
150
  });
141
151
  case ArrowUp:
142
152
  return requestNavigation({
143
153
  event,
154
+ value,
144
155
  type: treeDataTypes.arrowUp,
145
156
  target: event.currentTarget
146
157
  });
147
158
  case ArrowDown:
148
159
  return requestNavigation({
149
160
  event,
161
+ value,
150
162
  type: treeDataTypes.arrowDown,
151
163
  target: event.currentTarget
152
164
  });
@@ -155,6 +167,7 @@ export const useTreeItem_unstable = (props, ref) => {
155
167
  if (isTypeAheadCharacter) {
156
168
  return requestNavigation({
157
169
  event,
170
+ value,
158
171
  target: event.currentTarget,
159
172
  type: treeDataTypes.typeAhead
160
173
  });
@@ -246,5 +259,5 @@ export const useTreeItem_unstable = (props, ref) => {
246
259
  }
247
260
  })
248
261
  };
249
- };
262
+ }
250
263
  //# sourceMappingURL=useTreeItem.js.map