@fluentui/react-tree 9.0.0-beta.25 → 9.0.0-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +136 -1
- package/CHANGELOG.md +35 -2
- package/dist/index.d.ts +261 -83
- package/lib/FlatTree.js +1 -0
- package/lib/FlatTree.js.map +1 -0
- package/lib/components/FlatTree/FlatTree.js +13 -0
- package/lib/components/FlatTree/FlatTree.js.map +1 -0
- package/lib/components/FlatTree/FlatTree.types.js +1 -0
- package/lib/components/FlatTree/FlatTree.types.js.map +1 -0
- package/lib/components/FlatTree/index.js +6 -0
- package/lib/components/FlatTree/index.js.map +1 -0
- package/lib/components/FlatTree/useFlatControllableCheckedItems.js +63 -0
- package/lib/components/FlatTree/useFlatControllableCheckedItems.js.map +1 -0
- package/lib/components/FlatTree/useFlatTree.js +3 -0
- package/lib/components/FlatTree/useFlatTree.js.map +1 -0
- package/lib/{hooks → components/FlatTree}/useFlatTreeNavigation.js +12 -12
- package/lib/components/FlatTree/useFlatTreeNavigation.js.map +1 -0
- package/lib/components/FlatTree/useFlatTreeStyles.styles.js +30 -0
- package/lib/components/FlatTree/useFlatTreeStyles.styles.js.map +1 -0
- package/lib/{hooks/useFlatTree.js → components/FlatTree/useHeadlessFlatTree.js} +21 -16
- package/lib/components/FlatTree/useHeadlessFlatTree.js.map +1 -0
- package/lib/components/Tree/Tree.js +4 -9
- package/lib/components/Tree/Tree.js.map +1 -1
- package/lib/components/Tree/Tree.types.js.map +1 -1
- package/lib/components/Tree/index.js +2 -2
- package/lib/components/Tree/index.js.map +1 -1
- package/lib/components/Tree/renderTree.js.map +1 -1
- package/lib/components/Tree/useControllableCheckedItems.js +94 -0
- package/lib/components/Tree/useControllableCheckedItems.js.map +1 -0
- package/lib/components/Tree/useTree.js +38 -14
- package/lib/components/Tree/useTree.js.map +1 -1
- package/lib/components/Tree/useTreeContextValues.js +4 -2
- package/lib/components/Tree/useTreeContextValues.js.map +1 -1
- package/lib/{hooks/useNestedTreeNavigation.js → components/Tree/useTreeNavigation.js} +6 -6
- package/lib/components/Tree/useTreeNavigation.js.map +1 -0
- package/lib/components/Tree/useTreeStyles.styles.js +2 -2
- package/lib/components/Tree/useTreeStyles.styles.js.map +1 -1
- package/lib/components/TreeItem/TreeItem.types.js.map +1 -1
- package/lib/components/TreeItem/renderTreeItem.js +2 -4
- package/lib/components/TreeItem/renderTreeItem.js.map +1 -1
- package/lib/components/TreeItem/useTreeItem.js +49 -51
- package/lib/components/TreeItem/useTreeItem.js.map +1 -1
- package/lib/components/TreeItem/useTreeItemContextValues.js +8 -14
- package/lib/components/TreeItem/useTreeItemContextValues.js.map +1 -1
- package/lib/components/TreeItemLayout/TreeItemLayout.types.js.map +1 -1
- package/lib/components/TreeItemLayout/renderTreeItemLayout.js +1 -1
- package/lib/components/TreeItemLayout/renderTreeItemLayout.js.map +1 -1
- package/lib/components/TreeItemLayout/useTreeItemLayout.js +55 -8
- package/lib/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
- package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.styles.js +15 -8
- package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.styles.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js +1 -1
- package/lib/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js +6 -1
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.js +5 -1
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.js.map +1 -1
- package/lib/contexts/index.js +0 -1
- package/lib/contexts/index.js.map +1 -1
- package/lib/contexts/treeContext.js +3 -0
- package/lib/contexts/treeContext.js.map +1 -1
- package/lib/contexts/treeItemContext.js +5 -0
- package/lib/contexts/treeItemContext.js.map +1 -1
- package/lib/hooks/useControllableOpenItems.js +6 -3
- package/lib/hooks/useControllableOpenItems.js.map +1 -1
- package/lib/{components/Tree → hooks}/useRootTree.js +34 -25
- package/lib/hooks/useRootTree.js.map +1 -0
- package/lib/{components/Tree → hooks}/useSubtree.js +8 -4
- package/lib/hooks/useSubtree.js.map +1 -0
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/utils/ImmutableMap.js +41 -0
- package/lib/utils/ImmutableMap.js.map +1 -0
- package/lib/utils/ImmutableSet.js +7 -2
- package/lib/utils/ImmutableSet.js.map +1 -1
- package/lib/utils/createCheckedItems.js +18 -0
- package/lib/utils/createCheckedItems.js.map +1 -0
- package/lib/utils/createHeadlessTree.js +165 -0
- package/lib/utils/createHeadlessTree.js.map +1 -0
- package/lib/utils/createOpenItems.js +10 -0
- package/lib/utils/createOpenItems.js.map +1 -0
- package/lib/utils/flattenTree.js.map +1 -1
- package/lib/utils/tokens.js +2 -1
- package/lib/utils/tokens.js.map +1 -1
- package/lib-commonjs/FlatTree.js +6 -0
- package/lib-commonjs/FlatTree.js.map +1 -0
- package/lib-commonjs/components/FlatTree/FlatTree.js +20 -0
- package/lib-commonjs/components/FlatTree/FlatTree.js.map +1 -0
- package/lib-commonjs/components/FlatTree/FlatTree.types.js +4 -0
- package/lib-commonjs/components/FlatTree/FlatTree.types.js.map +1 -0
- package/lib-commonjs/components/FlatTree/index.js +21 -0
- package/lib-commonjs/components/FlatTree/index.js.map +1 -0
- package/lib-commonjs/components/FlatTree/useFlatControllableCheckedItems.js +78 -0
- package/lib-commonjs/components/FlatTree/useFlatControllableCheckedItems.js.map +1 -0
- package/lib-commonjs/components/FlatTree/useFlatTree.js +12 -0
- package/lib-commonjs/components/FlatTree/useFlatTree.js.map +1 -0
- package/lib-commonjs/{hooks → components/FlatTree}/useFlatTreeNavigation.js +12 -12
- package/lib-commonjs/components/FlatTree/useFlatTreeNavigation.js.map +1 -0
- package/lib-commonjs/components/FlatTree/useFlatTreeStyles.styles.js +53 -0
- package/lib-commonjs/components/FlatTree/useFlatTreeStyles.styles.js.map +1 -0
- package/lib-commonjs/{hooks/useFlatTree.js → components/FlatTree/useHeadlessFlatTree.js} +23 -18
- package/lib-commonjs/components/FlatTree/useHeadlessFlatTree.js.map +1 -0
- package/lib-commonjs/components/Tree/Tree.js +3 -3
- package/lib-commonjs/components/Tree/Tree.js.map +1 -1
- package/lib-commonjs/components/Tree/index.js +2 -2
- package/lib-commonjs/components/Tree/index.js.map +1 -1
- package/lib-commonjs/components/Tree/useControllableCheckedItems.js +103 -0
- package/lib-commonjs/components/Tree/useControllableCheckedItems.js.map +1 -0
- package/lib-commonjs/components/Tree/useTree.js +38 -6
- package/lib-commonjs/components/Tree/useTree.js.map +1 -1
- package/lib-commonjs/components/Tree/useTreeContextValues.js +4 -2
- package/lib-commonjs/components/Tree/useTreeContextValues.js.map +1 -1
- package/lib-commonjs/{hooks/useNestedTreeNavigation.js → components/Tree/useTreeNavigation.js} +8 -8
- package/lib-commonjs/components/Tree/useTreeNavigation.js.map +1 -0
- package/lib-commonjs/components/Tree/useTreeStyles.styles.js +2 -2
- package/lib-commonjs/components/Tree/useTreeStyles.styles.js.map +1 -1
- package/lib-commonjs/components/TreeItem/renderTreeItem.js +1 -3
- package/lib-commonjs/components/TreeItem/renderTreeItem.js.map +1 -1
- package/lib-commonjs/components/TreeItem/useTreeItem.js +48 -50
- package/lib-commonjs/components/TreeItem/useTreeItem.js.map +1 -1
- package/lib-commonjs/components/TreeItem/useTreeItemContextValues.js +8 -15
- package/lib-commonjs/components/TreeItem/useTreeItemContextValues.js.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.js +1 -1
- package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.js.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.js +55 -8
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.styles.js +12 -8
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.styles.js.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js +6 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.js +5 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.js.map +1 -1
- package/lib-commonjs/contexts/index.js +0 -1
- package/lib-commonjs/contexts/index.js.map +1 -1
- package/lib-commonjs/contexts/treeContext.js +3 -0
- package/lib-commonjs/contexts/treeContext.js.map +1 -1
- package/lib-commonjs/contexts/treeItemContext.js +5 -0
- package/lib-commonjs/contexts/treeItemContext.js.map +1 -1
- package/lib-commonjs/hooks/useControllableOpenItems.js +3 -2
- package/lib-commonjs/hooks/useControllableOpenItems.js.map +1 -1
- package/lib-commonjs/{components/Tree → hooks}/useRootTree.js +31 -22
- package/lib-commonjs/hooks/useRootTree.js.map +1 -0
- package/lib-commonjs/{components/Tree → hooks}/useSubtree.js +12 -8
- package/lib-commonjs/hooks/useSubtree.js.map +1 -0
- package/lib-commonjs/index.js +10 -4
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/ImmutableMap.js +49 -0
- package/lib-commonjs/utils/ImmutableMap.js.map +1 -0
- package/lib-commonjs/utils/ImmutableSet.js +7 -2
- package/lib-commonjs/utils/ImmutableSet.js.map +1 -1
- package/lib-commonjs/utils/createCheckedItems.js +26 -0
- package/lib-commonjs/utils/createCheckedItems.js.map +1 -0
- package/lib-commonjs/utils/createHeadlessTree.js +179 -0
- package/lib-commonjs/utils/createHeadlessTree.js.map +1 -0
- package/lib-commonjs/utils/createOpenItems.js +18 -0
- package/lib-commonjs/utils/createOpenItems.js.map +1 -0
- package/lib-commonjs/utils/tokens.js +2 -1
- package/lib-commonjs/utils/tokens.js.map +1 -1
- package/package.json +11 -9
- package/lib/components/Tree/useRootTree.js.map +0 -1
- package/lib/components/Tree/useSubtree.js.map +0 -1
- package/lib/contexts/treeItemSlotsContext.js +0 -9
- package/lib/contexts/treeItemSlotsContext.js.map +0 -1
- package/lib/hooks/index.js +0 -3
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/useFlatTree.js.map +0 -1
- package/lib/hooks/useFlatTreeNavigation.js.map +0 -1
- package/lib/hooks/useNestedTreeNavigation.js.map +0 -1
- package/lib/utils/createFlatTreeItems.js +0 -113
- package/lib/utils/createFlatTreeItems.js.map +0 -1
- package/lib-commonjs/components/Tree/useRootTree.js.map +0 -1
- package/lib-commonjs/components/Tree/useSubtree.js.map +0 -1
- package/lib-commonjs/contexts/treeItemSlotsContext.js +0 -25
- package/lib-commonjs/contexts/treeItemSlotsContext.js.map +0 -1
- package/lib-commonjs/hooks/index.js +0 -8
- package/lib-commonjs/hooks/index.js.map +0 -1
- package/lib-commonjs/hooks/useFlatTree.js.map +0 -1
- package/lib-commonjs/hooks/useFlatTreeNavigation.js.map +0 -1
- package/lib-commonjs/hooks/useNestedTreeNavigation.js.map +0 -1
- package/lib-commonjs/utils/createFlatTreeItems.js +0 -127
- package/lib-commonjs/utils/createFlatTreeItems.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ 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
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';
|
|
@@ -18,22 +20,36 @@ import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
|
18
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
|
+
|
|
25
35
|
/**
|
|
26
36
|
* properly creates an ImmutableSet instance from an iterable
|
|
27
37
|
*/
|
|
28
38
|
declare function createImmutableSet<Value>(iterable?: Iterable<Value>): ImmutableSet<Value>;
|
|
29
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
|
+
|
|
30
46
|
/**
|
|
31
47
|
* Avoid using *dangerouslyCreateImmutableSet*, since this method will expose internally used set, use createImmutableSet instead,
|
|
32
48
|
* @param internalSet - a set that is used internally to store values.
|
|
33
49
|
*/
|
|
34
50
|
declare function dangerouslyCreateImmutableSet<Value>(internalSet: Set<Value>): ImmutableSet<Value>;
|
|
35
51
|
|
|
36
|
-
declare type FlattenedTreeItem<Props extends TreeItemProps> =
|
|
52
|
+
declare type FlattenedTreeItem<Props extends TreeItemProps> = HeadlessFlatTreeItemProps & Props;
|
|
37
53
|
|
|
38
54
|
/**
|
|
39
55
|
* Converts a nested structure to a flat one which can be consumed by `useFlatTreeItems`
|
|
@@ -75,7 +91,84 @@ declare type FlattenedTreeItem<Props extends TreeItemProps> = FlatTreeItemProps
|
|
|
75
91
|
* ]);
|
|
76
92
|
* ```
|
|
77
93
|
*/
|
|
78
|
-
export declare const flattenTree_unstable: <Props extends TreeItemProps>(items:
|
|
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
|
+
};
|
|
79
172
|
|
|
80
173
|
/**
|
|
81
174
|
* FlatTree API to manage all required mechanisms to convert a list of items into renderable TreeItems
|
|
@@ -87,13 +180,16 @@ export declare const flattenTree_unstable: <Props extends TreeItemProps>(items:
|
|
|
87
180
|
*
|
|
88
181
|
* On simple scenarios it is advised to simply use a nested structure instead.
|
|
89
182
|
*/
|
|
90
|
-
export declare type
|
|
183
|
+
export declare type HeadlessFlatTree<Props extends HeadlessFlatTreeItemProps> = {
|
|
91
184
|
/**
|
|
92
185
|
* returns the properties required for the Tree component to work properly.
|
|
93
186
|
* That includes:
|
|
94
187
|
* `openItems`, `onOpenChange`, `onNavigation_unstable` and `ref`
|
|
95
188
|
*/
|
|
96
|
-
getTreeProps(): FlatTreeProps
|
|
189
|
+
getTreeProps(): Required<Pick<FlatTreeProps, 'openItems' | 'onOpenChange' | 'onNavigation_unstable' | 'checkedItems' | 'onCheckedChange'>> & {
|
|
190
|
+
ref: React_2.Ref<HTMLDivElement>;
|
|
191
|
+
openItems: ImmutableSet<TreeItemValue>;
|
|
192
|
+
};
|
|
97
193
|
/**
|
|
98
194
|
* internal method used to react to an `onNavigation` event.
|
|
99
195
|
* This method ensures proper navigation on keyboard and mouse interaction.
|
|
@@ -125,40 +221,77 @@ export declare type FlatTree<Props extends FlatTreeItemProps = FlatTreeItemProps
|
|
|
125
221
|
*
|
|
126
222
|
* On the case of TypeAhead navigation this method returns the current item.
|
|
127
223
|
*/
|
|
128
|
-
getNextNavigableItem(visibleItems:
|
|
224
|
+
getNextNavigableItem(visibleItems: HeadlessTreeItem<Props>[], data: TreeNavigationData_unstable): HeadlessTreeItem<Props> | undefined;
|
|
129
225
|
/**
|
|
130
226
|
* similar to getElementById but for FlatTreeItems
|
|
131
227
|
*/
|
|
132
|
-
getElementFromItem(item:
|
|
228
|
+
getElementFromItem(item: HeadlessTreeItem<Props>): HTMLElement | null;
|
|
133
229
|
/**
|
|
134
230
|
* an iterable containing all visually available flat tree items
|
|
135
231
|
*/
|
|
136
|
-
items(): IterableIterator<
|
|
232
|
+
items(): IterableIterator<HeadlessTreeItem<Props>>;
|
|
137
233
|
};
|
|
138
234
|
|
|
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
|
+
|
|
139
241
|
/**
|
|
140
|
-
* The item that is returned by `
|
|
141
|
-
* `
|
|
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
|
|
142
244
|
*/
|
|
143
|
-
|
|
245
|
+
declare type HeadlessTreeItem<Props extends HeadlessTreeItemProps> = {
|
|
144
246
|
index: number;
|
|
145
247
|
level: number;
|
|
146
|
-
|
|
248
|
+
childrenValues: TreeItemValue[];
|
|
147
249
|
value: TreeItemValue;
|
|
148
250
|
parentValue: TreeItemValue | undefined;
|
|
149
|
-
getTreeItemProps(): Required<Pick<Props, 'value' | 'aria-setsize' | 'aria-level' | 'aria-posinset' | 'itemType'>> & Omit<Props, '
|
|
251
|
+
getTreeItemProps(): Required<Pick<Props, 'value' | 'aria-setsize' | 'aria-level' | 'aria-posinset' | 'itemType'>> & Omit<Props, 'parentValue'>;
|
|
150
252
|
};
|
|
151
253
|
|
|
152
|
-
|
|
254
|
+
declare type HeadlessTreeItemProps = Omit<TreeItemProps, 'itemType' | 'value'> & {
|
|
153
255
|
value: TreeItemValue;
|
|
256
|
+
itemType?: TreeItemType;
|
|
154
257
|
parentValue?: TreeItemValue;
|
|
155
258
|
};
|
|
156
259
|
|
|
157
|
-
declare
|
|
260
|
+
declare interface ImmutableMap<Key, Value> {
|
|
261
|
+
clear(): ImmutableMap<Key, Value>;
|
|
262
|
+
delete(key: Key): ImmutableMap<Key, Value>;
|
|
263
|
+
/**
|
|
264
|
+
* 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.
|
|
265
|
+
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
|
|
266
|
+
*/
|
|
267
|
+
get(key: Key): Value | undefined;
|
|
268
|
+
/**
|
|
269
|
+
* @returns boolean indicating whether an element with the specified key exists or not.
|
|
270
|
+
*/
|
|
271
|
+
has(key: Key): boolean;
|
|
272
|
+
/**
|
|
273
|
+
* 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.
|
|
274
|
+
*/
|
|
275
|
+
set(key: Key, value: Value): ImmutableMap<Key, Value>;
|
|
276
|
+
/**
|
|
277
|
+
* @returns the number of elements in the Map.
|
|
278
|
+
*/
|
|
279
|
+
readonly size: number;
|
|
280
|
+
/** Iterates over entries in the Map. */
|
|
281
|
+
[Symbol.iterator](): IterableIterator<[Key, Value]>;
|
|
282
|
+
/**
|
|
283
|
+
* @internal
|
|
284
|
+
* Exposes the internal map used to store values.
|
|
285
|
+
* This is an internal API and should not be used directly.
|
|
286
|
+
*/
|
|
287
|
+
dangerouslyGetInternalMap_unstable(): Map<Key, Value>;
|
|
288
|
+
}
|
|
158
289
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
290
|
+
declare const ImmutableMap: {
|
|
291
|
+
empty: ImmutableMap<never, never>;
|
|
292
|
+
create: typeof createImmutableMap;
|
|
293
|
+
isImmutableMap: typeof isImmutableMap;
|
|
294
|
+
dangerouslyCreate_unstable: typeof dangerouslyCreateImmutableMap;
|
|
162
295
|
};
|
|
163
296
|
|
|
164
297
|
declare interface ImmutableSet<Value> {
|
|
@@ -190,23 +323,27 @@ declare interface ImmutableSet<Value> {
|
|
|
190
323
|
* Exposes the internal set used to store values.
|
|
191
324
|
* This is an internal API and should not be used directly.
|
|
192
325
|
*/
|
|
193
|
-
|
|
326
|
+
dangerouslyGetInternalSet_unstable(): Set<Value>;
|
|
194
327
|
}
|
|
195
328
|
|
|
196
329
|
declare const ImmutableSet: {
|
|
197
330
|
empty: ImmutableSet<never>;
|
|
198
331
|
create: typeof createImmutableSet;
|
|
199
|
-
|
|
332
|
+
isImmutableSet: typeof isImmutableSet;
|
|
333
|
+
dangerouslyCreate_unstable: typeof dangerouslyCreateImmutableSet;
|
|
200
334
|
};
|
|
201
335
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
336
|
+
declare function isImmutableMap<Key, Value>(value: unknown): value is ImmutableMap<Key, Value>;
|
|
337
|
+
|
|
338
|
+
declare function isImmutableSet<Value>(value: unknown): value is ImmutableSet<Value>;
|
|
339
|
+
|
|
340
|
+
declare type MultiSelectValue = NonNullable<CheckboxProps['checked']>;
|
|
206
341
|
|
|
207
342
|
declare type OmitWithoutExpanding<P, K extends string | number | symbol> = P extends unknown ? Omit<P, K> : P;
|
|
208
343
|
|
|
209
|
-
|
|
344
|
+
declare const renderTree_unstable: (state: TreeState, contextValues: TreeContextValues) => JSX.Element;
|
|
345
|
+
export { renderTree_unstable as renderFlatTree_unstable }
|
|
346
|
+
export { renderTree_unstable }
|
|
210
347
|
|
|
211
348
|
/**
|
|
212
349
|
* Render the final JSX of TreeItem
|
|
@@ -223,30 +360,44 @@ export declare const renderTreeItemLayout_unstable: (state: TreeItemLayoutState)
|
|
|
223
360
|
*/
|
|
224
361
|
export declare const renderTreeItemPersonaLayout_unstable: (state: TreeItemPersonaLayoutState, contextValues: TreeItemPersonaLayoutContextValues) => JSX.Element;
|
|
225
362
|
|
|
363
|
+
declare type SingleSelectValue = NonNullable<RadioProps['checked']>;
|
|
364
|
+
|
|
226
365
|
/**
|
|
227
|
-
*
|
|
228
|
-
* Any item in the hierarchy may have child items,
|
|
229
|
-
* and items that have children may be expanded or collapsed to show or hide the children.
|
|
230
|
-
* For example, in a file system navigator that uses a tree view to display folders and files,
|
|
231
|
-
* an item representing a folder can be expanded to reveal the contents of the folder,
|
|
232
|
-
* which may be files, folders, or both.
|
|
366
|
+
* Tree component - TODO: add more docs
|
|
233
367
|
*/
|
|
234
368
|
export declare const Tree: ForwardRefComponent<TreeProps>;
|
|
235
369
|
|
|
370
|
+
export declare type TreeCheckedChangeData = {
|
|
371
|
+
value: TreeItemValue;
|
|
372
|
+
target: HTMLElement;
|
|
373
|
+
event: React_2.ChangeEvent<HTMLElement>;
|
|
374
|
+
type: 'Change';
|
|
375
|
+
} & ({
|
|
376
|
+
selectionMode: 'multiselect';
|
|
377
|
+
checked: MultiSelectValue;
|
|
378
|
+
} | {
|
|
379
|
+
selectionMode: 'single';
|
|
380
|
+
checked: SingleSelectValue;
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
export declare type TreeCheckedChangeEvent = TreeCheckedChangeData['event'];
|
|
384
|
+
|
|
236
385
|
export declare const treeClassNames: SlotClassNames<TreeSlots>;
|
|
237
386
|
|
|
238
387
|
export declare type TreeContextValue = {
|
|
239
388
|
level: number;
|
|
389
|
+
selectionMode: 'none' | SelectionMode_2;
|
|
240
390
|
appearance: 'subtle' | 'subtle-alpha' | 'transparent';
|
|
241
391
|
size: 'small' | 'medium';
|
|
242
392
|
openItems: ImmutableSet<TreeItemValue>;
|
|
393
|
+
checkedItems: ImmutableMap<TreeItemValue, 'mixed' | boolean>;
|
|
243
394
|
/**
|
|
244
395
|
* requests root Tree component to respond to some tree item event,
|
|
245
396
|
*/
|
|
246
397
|
requestTreeResponse(request: TreeItemRequest): void;
|
|
247
398
|
};
|
|
248
399
|
|
|
249
|
-
declare type TreeContextValues = {
|
|
400
|
+
export declare type TreeContextValues = {
|
|
250
401
|
tree: TreeContextValue;
|
|
251
402
|
};
|
|
252
403
|
|
|
@@ -264,27 +415,29 @@ declare type TreeContextValues = {
|
|
|
264
415
|
*/
|
|
265
416
|
export declare const TreeItem: ForwardRefComponent<TreeItemProps>;
|
|
266
417
|
|
|
267
|
-
export declare const treeItemClassNames: SlotClassNames<
|
|
418
|
+
export declare const treeItemClassNames: SlotClassNames<TreeItemSlots>;
|
|
268
419
|
|
|
269
|
-
declare type TreeItemContextValue = {
|
|
420
|
+
export declare type TreeItemContextValue = {
|
|
421
|
+
isActionsVisible: boolean;
|
|
422
|
+
isAsideVisible: boolean;
|
|
423
|
+
selectionRef: React_2.Ref<HTMLInputElement>;
|
|
424
|
+
actionsRef: React_2.Ref<HTMLDivElement>;
|
|
425
|
+
expandIconRef: React_2.Ref<HTMLDivElement>;
|
|
270
426
|
layoutRef: React_2.Ref<HTMLDivElement>;
|
|
271
427
|
subtreeRef: React_2.Ref<HTMLDivElement>;
|
|
272
428
|
itemType: TreeItemType;
|
|
273
|
-
value:
|
|
429
|
+
value: TreeItemValue;
|
|
274
430
|
open: boolean;
|
|
275
431
|
};
|
|
276
432
|
|
|
277
433
|
declare type TreeItemContextValues = {
|
|
278
434
|
treeItem: TreeItemContextValue;
|
|
279
|
-
treeItemSlots: TreeItemSlotsContextValue;
|
|
280
435
|
};
|
|
281
436
|
|
|
282
437
|
declare type TreeItemCSSProperties = React_2.CSSProperties & {
|
|
283
438
|
[treeItemLevelToken]?: string | number;
|
|
284
439
|
};
|
|
285
440
|
|
|
286
|
-
declare type TreeItemInternalSlot = Pick<TreeItemSlots, 'root'>;
|
|
287
|
-
|
|
288
441
|
/**
|
|
289
442
|
* The `TreeItemLayout` component is used as a child of `TreeItem` to define the content and layout of a tree item.
|
|
290
443
|
* It provides a consistent visual structure for tree items in a `Tree` component.
|
|
@@ -292,9 +445,7 @@ declare type TreeItemInternalSlot = Pick<TreeItemSlots, 'root'>;
|
|
|
292
445
|
*/
|
|
293
446
|
export declare const TreeItemLayout: ForwardRefComponent<TreeItemLayoutProps>;
|
|
294
447
|
|
|
295
|
-
export declare const treeItemLayoutClassNames: SlotClassNames<
|
|
296
|
-
|
|
297
|
-
declare type TreeItemLayoutInternalSlots = TreeItemLayoutSlots & Pick<TreeItemSlots, 'actions' | 'aside' | 'expandIcon'>;
|
|
448
|
+
export declare const treeItemLayoutClassNames: SlotClassNames<TreeItemLayoutSlots>;
|
|
298
449
|
|
|
299
450
|
/**
|
|
300
451
|
* TreeItemLayout Props
|
|
@@ -315,12 +466,29 @@ export declare type TreeItemLayoutSlots = {
|
|
|
315
466
|
* Icon slot that renders right after main content
|
|
316
467
|
*/
|
|
317
468
|
iconAfter?: Slot<'div'>;
|
|
469
|
+
/**
|
|
470
|
+
* Expand icon slot,
|
|
471
|
+
* by default renders a chevron icon to indicate opening and closing
|
|
472
|
+
*/
|
|
473
|
+
expandIcon?: Slot<'div'>;
|
|
474
|
+
aside?: Slot<'div'>;
|
|
475
|
+
/**
|
|
476
|
+
* actionable elements are normally buttons, menus, or other focusable elements.
|
|
477
|
+
* Those elements are only visibly available if the given tree item is currently active.
|
|
478
|
+
*/
|
|
479
|
+
actions?: Slot<ExtractSlotProps<Slot<'div'> & {
|
|
480
|
+
/**
|
|
481
|
+
* Forces visibility of the aside/action content
|
|
482
|
+
*/
|
|
483
|
+
visible?: boolean;
|
|
484
|
+
}>>;
|
|
485
|
+
selector?: Slot<typeof Checkbox> | Slot<typeof Radio>;
|
|
318
486
|
};
|
|
319
487
|
|
|
320
488
|
/**
|
|
321
489
|
* State used in rendering TreeItemLayout
|
|
322
490
|
*/
|
|
323
|
-
export declare type TreeItemLayoutState = ComponentState<
|
|
491
|
+
export declare type TreeItemLayoutState = ComponentState<TreeItemLayoutSlots> & {
|
|
324
492
|
buttonContextValue: ButtonContextValue;
|
|
325
493
|
};
|
|
326
494
|
|
|
@@ -333,20 +501,18 @@ export declare const treeItemLevelToken: "--fluent-TreeItem--level";
|
|
|
333
501
|
*/
|
|
334
502
|
export declare const TreeItemPersonaLayout: ForwardRefComponent<TreeItemPersonaLayoutProps>;
|
|
335
503
|
|
|
336
|
-
export declare const treeItemPersonaLayoutClassNames: SlotClassNames<
|
|
504
|
+
export declare const treeItemPersonaLayoutClassNames: SlotClassNames<TreeItemPersonaLayoutSlots>;
|
|
337
505
|
|
|
338
506
|
declare type TreeItemPersonaLayoutContextValues = {
|
|
339
507
|
avatar: AvatarContextValue;
|
|
340
508
|
};
|
|
341
509
|
|
|
342
|
-
declare type TreeItemPersonaLayoutInternalSlots = TreeItemPersonaLayoutSlots & Pick<TreeItemSlots, 'actions' | 'aside' | 'expandIcon'>;
|
|
343
|
-
|
|
344
510
|
/**
|
|
345
511
|
* TreeItemPersonaLayout Props
|
|
346
512
|
*/
|
|
347
513
|
export declare type TreeItemPersonaLayoutProps = ComponentProps<Partial<TreeItemPersonaLayoutSlots>>;
|
|
348
514
|
|
|
349
|
-
export declare type TreeItemPersonaLayoutSlots = {
|
|
515
|
+
export declare type TreeItemPersonaLayoutSlots = Pick<TreeItemLayoutSlots, 'actions' | 'aside' | 'expandIcon' | 'selector'> & {
|
|
350
516
|
root: NonNullable<Slot<'div'>>;
|
|
351
517
|
/**
|
|
352
518
|
* Avatar to display.
|
|
@@ -365,7 +531,7 @@ export declare type TreeItemPersonaLayoutSlots = {
|
|
|
365
531
|
/**
|
|
366
532
|
* State used in rendering TreeItemPersonaLayout
|
|
367
533
|
*/
|
|
368
|
-
export declare type TreeItemPersonaLayoutState = ComponentState<
|
|
534
|
+
export declare type TreeItemPersonaLayoutState = ComponentState<TreeItemPersonaLayoutSlots> & {
|
|
369
535
|
avatarSize: AvatarSize;
|
|
370
536
|
buttonContextValue: ButtonContextValue;
|
|
371
537
|
};
|
|
@@ -382,36 +548,18 @@ export declare const TreeItemProvider: React_2.Provider<TreeItemContextValue | u
|
|
|
382
548
|
|
|
383
549
|
declare type TreeItemRequest = {
|
|
384
550
|
itemType: TreeItemType;
|
|
385
|
-
} & (OmitWithoutExpanding<TreeOpenChangeData, 'open' | '
|
|
551
|
+
} & (OmitWithoutExpanding<TreeOpenChangeData, 'open'> | TreeNavigationData_unstable | OmitWithoutExpanding<TreeCheckedChangeData, 'checked' | 'selectionMode'>);
|
|
386
552
|
|
|
387
553
|
export declare type TreeItemSlots = {
|
|
388
554
|
root: Slot<ExtractSlotProps<Slot<'div'> & {
|
|
389
555
|
style?: TreeItemCSSProperties;
|
|
390
556
|
}>>;
|
|
391
|
-
/**
|
|
392
|
-
* Expand icon slot,
|
|
393
|
-
* by default renders a chevron icon to indicate opening and closing
|
|
394
|
-
*/
|
|
395
|
-
expandIcon?: Slot<'div'>;
|
|
396
|
-
aside?: Slot<'div'>;
|
|
397
|
-
/**
|
|
398
|
-
* actionable elements are normally buttons, menus, or other focusable elements.
|
|
399
|
-
* Those elements are only visibly available if the given tree item is currently active.
|
|
400
|
-
*/
|
|
401
|
-
actions?: Slot<ExtractSlotProps<Slot<'div'> & {
|
|
402
|
-
/**
|
|
403
|
-
* Forces visibility of the aside/action content
|
|
404
|
-
*/
|
|
405
|
-
visible?: boolean;
|
|
406
|
-
}>>;
|
|
407
557
|
};
|
|
408
558
|
|
|
409
|
-
declare type TreeItemSlotsContextValue = Pick<TreeItemSlots, 'actions' | 'aside' | 'expandIcon'>;
|
|
410
|
-
|
|
411
559
|
/**
|
|
412
560
|
* State used in rendering TreeItem
|
|
413
561
|
*/
|
|
414
|
-
export declare type TreeItemState = ComponentState<
|
|
562
|
+
export declare type TreeItemState = ComponentState<TreeItemSlots> & TreeItemContextValue & {
|
|
415
563
|
level: number;
|
|
416
564
|
itemType: TreeItemType;
|
|
417
565
|
};
|
|
@@ -455,7 +603,6 @@ export declare type TreeOpenChangeData = {
|
|
|
455
603
|
open: boolean;
|
|
456
604
|
value: TreeItemValue;
|
|
457
605
|
target: HTMLElement;
|
|
458
|
-
openItems: ImmutableSet<TreeItemValue>;
|
|
459
606
|
} & ({
|
|
460
607
|
event: React_2.MouseEvent<HTMLElement>;
|
|
461
608
|
type: 'ExpandIconClick';
|
|
@@ -496,9 +643,8 @@ export declare type TreeProps = ComponentProps<TreeSlots> & {
|
|
|
496
643
|
*/
|
|
497
644
|
openItems?: Iterable<TreeItemValue>;
|
|
498
645
|
/**
|
|
499
|
-
* This refers to a list of ids of opened
|
|
500
|
-
*
|
|
501
|
-
* These property is ignored for subtrees.
|
|
646
|
+
* This refers to a list of ids of default opened items.
|
|
647
|
+
* This property is ignored for subtrees.
|
|
502
648
|
*/
|
|
503
649
|
defaultOpenItems?: Iterable<TreeItemValue>;
|
|
504
650
|
/**
|
|
@@ -520,20 +666,59 @@ export declare type TreeProps = ComponentProps<TreeSlots> & {
|
|
|
520
666
|
* @param data - A data object with relevant information,
|
|
521
667
|
*/
|
|
522
668
|
onNavigation_unstable?(event: TreeNavigationEvent_unstable, data: TreeNavigationData_unstable): void;
|
|
669
|
+
/**
|
|
670
|
+
* This refers to the selection mode of the tree.
|
|
671
|
+
* - undefined: No selection can be done.
|
|
672
|
+
* - 'single': Only one tree item can be selected, radio buttons are rendered.
|
|
673
|
+
* - 'multiselect': Multiple tree items can be selected, checkboxes are rendered.
|
|
674
|
+
*
|
|
675
|
+
* @default undefined
|
|
676
|
+
*/
|
|
677
|
+
selectionMode?: SelectionMode_2;
|
|
678
|
+
/**
|
|
679
|
+
* This refers to a list of ids of checked tree items, or a list of tuples of ids and checked state.
|
|
680
|
+
* Controls the state of the checked tree items.
|
|
681
|
+
* These property is ignored for subtrees.
|
|
682
|
+
*/
|
|
683
|
+
checkedItems?: Iterable<TreeItemValue | [TreeItemValue, TreeSelectionValue]>;
|
|
684
|
+
/**
|
|
685
|
+
* This refers to a list of ids of default checked items, or a list of tuples of ids and checked state.
|
|
686
|
+
* These property is ignored for subtrees.
|
|
687
|
+
*/
|
|
688
|
+
defaultCheckedItems?: Iterable<TreeItemValue | [TreeItemValue, TreeSelectionValue]>;
|
|
689
|
+
/**
|
|
690
|
+
* Callback fired when the component changes value from checked state.
|
|
691
|
+
* These property is ignored for subtrees.
|
|
692
|
+
*
|
|
693
|
+
* @param event - a React's Synthetic event
|
|
694
|
+
* @param data - A data object with relevant information,
|
|
695
|
+
* such as checked value and type of interaction that created the event.
|
|
696
|
+
*/
|
|
697
|
+
onCheckedChange?(event: TreeCheckedChangeEvent, data: TreeCheckedChangeData): void;
|
|
523
698
|
};
|
|
524
699
|
|
|
525
700
|
export declare const TreeProvider: Provider<TreeContextValue | undefined> & FC<ProviderProps<TreeContextValue | undefined>>;
|
|
526
701
|
|
|
527
|
-
export declare type
|
|
702
|
+
export declare type TreeSelectionValue = MultiSelectValue | SingleSelectValue;
|
|
703
|
+
|
|
704
|
+
declare type TreeSlots = {
|
|
528
705
|
root: Slot<'div'>;
|
|
529
706
|
};
|
|
707
|
+
export { TreeSlots as FlatTreeSlots }
|
|
708
|
+
export { TreeSlots }
|
|
530
709
|
|
|
531
710
|
/**
|
|
532
711
|
* State used in rendering Tree
|
|
533
712
|
*/
|
|
534
|
-
|
|
713
|
+
declare type TreeState = ComponentState<TreeSlots> & TreeContextValue & {
|
|
535
714
|
open: boolean;
|
|
536
715
|
};
|
|
716
|
+
export { TreeState as FlatTreeState }
|
|
717
|
+
export { TreeState }
|
|
718
|
+
|
|
719
|
+
export declare const useFlatTree_unstable: (props: FlatTreeProps, ref: React_2.Ref<HTMLElement>) => TreeState;
|
|
720
|
+
|
|
721
|
+
export declare const useFlatTreeStyles_unstable: (state: TreeState) => TreeState;
|
|
537
722
|
|
|
538
723
|
/**
|
|
539
724
|
* this hook provides FlatTree API to manage all required mechanisms to convert a list of items into renderable TreeItems
|
|
@@ -547,22 +732,15 @@ export declare type TreeState = ComponentState<TreeSlots> & TreeContextValue & {
|
|
|
547
732
|
* @param flatTreeItemProps - a list of tree items
|
|
548
733
|
* @param options - in case control over the internal openItems is required
|
|
549
734
|
*/
|
|
550
|
-
export declare function
|
|
735
|
+
export declare function useHeadlessFlatTree_unstable<Props extends HeadlessTreeItemProps>(flatTreeItemProps: Props[], options?: HeadlessFlatTreeOptions): HeadlessFlatTree<Props>;
|
|
551
736
|
|
|
552
|
-
/**
|
|
553
|
-
* Create the state required to render Tree.
|
|
554
|
-
*
|
|
555
|
-
* The returned state can be modified with hooks such as useTreeStyles_unstable,
|
|
556
|
-
* before being passed to renderTree_unstable.
|
|
557
|
-
*
|
|
558
|
-
* @param props - props from this instance of Tree
|
|
559
|
-
* @param ref - reference to root HTMLElement of Tree
|
|
560
|
-
*/
|
|
561
737
|
export declare const useTree_unstable: (props: TreeProps, ref: React_2.Ref<HTMLElement>) => TreeState;
|
|
562
738
|
|
|
563
739
|
export declare const useTreeContext_unstable: <T>(selector: ContextSelector<TreeContextValue, T>) => T;
|
|
564
740
|
|
|
565
|
-
|
|
741
|
+
declare function useTreeContextValues_unstable(state: TreeState): TreeContextValues;
|
|
742
|
+
export { useTreeContextValues_unstable as useFlatTreeContextValues_unstable }
|
|
743
|
+
export { useTreeContextValues_unstable }
|
|
566
744
|
|
|
567
745
|
/**
|
|
568
746
|
* Create the state required to render TreeItem.
|
package/lib/FlatTree.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/FlatTree/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["FlatTree.ts"],"sourcesContent":["export * from './components/FlatTree/index';\n"],"names":[],"mappings":"AAAA,cAAc,8BAA8B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useTreeContextValues_unstable as useFlatTreeContextValues_unstable, renderTree_unstable as renderFlatTree_unstable } from '../Tree/index';
|
|
3
|
+
import { useFlatTree_unstable } from './useFlatTree';
|
|
4
|
+
import { useFlatTreeStyles_unstable } from './useFlatTreeStyles.styles';
|
|
5
|
+
/**
|
|
6
|
+
* FlatTree component - TODO: add more docs
|
|
7
|
+
*/ export const FlatTree = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
8
|
+
const state = useFlatTree_unstable(props, ref);
|
|
9
|
+
const contextValues = useFlatTreeContextValues_unstable(state);
|
|
10
|
+
useFlatTreeStyles_unstable(state);
|
|
11
|
+
return renderFlatTree_unstable(state, contextValues);
|
|
12
|
+
});
|
|
13
|
+
FlatTree.displayName = 'FlatTree';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["FlatTree.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport type { FlatTreeProps } from './FlatTree.types';\nimport {\n useTreeContextValues_unstable as useFlatTreeContextValues_unstable,\n renderTree_unstable as renderFlatTree_unstable,\n} from '../Tree/index';\nimport { useFlatTree_unstable } from './useFlatTree';\nimport { useFlatTreeStyles_unstable } from './useFlatTreeStyles.styles';\n\n/**\n * FlatTree component - TODO: add more docs\n */\nexport const FlatTree: ForwardRefComponent<FlatTreeProps> = React.forwardRef((props, ref) => {\n const state = useFlatTree_unstable(props, ref);\n const contextValues = useFlatTreeContextValues_unstable(state);\n useFlatTreeStyles_unstable(state);\n return renderFlatTree_unstable(state, contextValues);\n});\n\nFlatTree.displayName = 'FlatTree';\n"],"names":["React","useTreeContextValues_unstable","useFlatTreeContextValues_unstable","renderTree_unstable","renderFlatTree_unstable","useFlatTree_unstable","useFlatTreeStyles_unstable","FlatTree","forwardRef","props","ref","state","contextValues","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B,SACEC,iCAAiCC,iCAAiC,EAClEC,uBAAuBC,uBAAuB,QACzC,gBAAgB;AACvB,SAASC,oBAAoB,QAAQ,gBAAgB;AACrD,SAASC,0BAA0B,QAAQ,6BAA6B;AAExE;;CAEC,GACD,OAAO,MAAMC,yBAA+CP,MAAMQ,UAAU,CAAC,CAACC,OAAOC,MAAQ;IAC3F,MAAMC,QAAQN,qBAAqBI,OAAOC;IAC1C,MAAME,gBAAgBV,kCAAkCS;IACxDL,2BAA2BK;IAC3B,OAAOP,wBAAwBO,OAAOC;AACxC,GAAG;AAEHL,SAASM,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["FlatTree.types.ts"],"sourcesContent":["import type { ComponentProps, SelectionMode } from '@fluentui/react-utilities';\nimport type {\n TreeSlots,\n TreeState,\n TreeCheckedChangeData,\n TreeCheckedChangeEvent,\n TreeNavigationData_unstable,\n TreeNavigationEvent_unstable,\n TreeOpenChangeData,\n TreeOpenChangeEvent,\n TreeSelectionValue,\n} from '../Tree/index';\nimport type { TreeItemValue } from '../TreeItem/index';\n\nexport { TreeSlots as FlatTreeSlots, TreeState as FlatTreeState };\n\nexport type FlatTreeProps = 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<TreeItemValue>;\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 * This refers to the selection mode of the tree.\n * - undefined: No selection can be done.\n * - 'single': Only one tree item can be selected, radio buttons are rendered.\n * - 'multiselect': Multiple tree items can be selected, checkboxes are rendered.\n *\n * @default undefined\n */\n selectionMode?: SelectionMode;\n /**\n * This refers to a list of ids of checked tree items, or a list of tuples of ids and checked state.\n * Controls the state of the checked tree items.\n * These property is ignored for subtrees.\n */\n checkedItems?: Iterable<TreeItemValue | [TreeItemValue, TreeSelectionValue]>;\n /**\n * Callback fired when the component changes value from checked 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 checked value and type of interaction that created the event.\n */\n onCheckedChange?(event: TreeCheckedChangeEvent, data: TreeCheckedChangeData): void;\n};\n"],"names":[],"mappings":"AAAA,WAkFE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './FlatTree';
|
|
2
|
+
export * from './FlatTree.types';
|
|
3
|
+
export { renderTree_unstable as renderFlatTree_unstable, useTreeContextValues_unstable as useFlatTreeContextValues_unstable } from '../Tree/index';
|
|
4
|
+
export * from './useHeadlessFlatTree';
|
|
5
|
+
export * from './useFlatTree';
|
|
6
|
+
export * from './useFlatTreeStyles.styles';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './FlatTree';\nexport * from './FlatTree.types';\nexport {\n renderTree_unstable as renderFlatTree_unstable,\n useTreeContextValues_unstable as useFlatTreeContextValues_unstable,\n} from '../Tree/index';\nexport * from './useHeadlessFlatTree';\nexport * from './useFlatTree';\nexport * from './useFlatTreeStyles.styles';\n"],"names":["renderTree_unstable","renderFlatTree_unstable","useTreeContextValues_unstable","useFlatTreeContextValues_unstable"],"mappings":"AAAA,cAAc,aAAa;AAC3B,cAAc,mBAAmB;AACjC,SACEA,uBAAuBC,uBAAuB,EAC9CC,iCAAiCC,iCAAiC,QAC7D,gBAAgB;AACvB,cAAc,wBAAwB;AACtC,cAAc,gBAAgB;AAC9B,cAAc,6BAA6B"}
|