@fluentui/react-tree 9.0.0-beta.25 → 9.0.0-beta.26
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 +73 -1
- package/CHANGELOG.md +18 -2
- package/dist/index.d.ts +123 -9
- package/lib/components/Tree/Tree.types.js.map +1 -1
- package/lib/components/Tree/useRootTree.js +24 -8
- package/lib/components/Tree/useRootTree.js.map +1 -1
- package/lib/components/Tree/useSubtree.js +4 -0
- package/lib/components/Tree/useSubtree.js.map +1 -1
- package/lib/components/Tree/useTreeContextValues.js +4 -2
- package/lib/components/Tree/useTreeContextValues.js.map +1 -1
- package/lib/components/TreeItem/TreeItem.types.js.map +1 -1
- package/lib/components/TreeItem/useTreeItem.js +48 -4
- package/lib/components/TreeItem/useTreeItem.js.map +1 -1
- package/lib/components/TreeItem/useTreeItemContextValues.js +5 -3
- 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 +10 -5
- 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/contexts/treeContext.js +3 -0
- package/lib/contexts/treeContext.js.map +1 -1
- package/lib/contexts/treeItemSlotsContext.js.map +1 -1
- package/lib/hooks/index.js +2 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useFlatControllableCheckedItems.js +76 -0
- package/lib/hooks/useFlatControllableCheckedItems.js.map +1 -0
- package/lib/hooks/useFlatTree.js +16 -5
- package/lib/hooks/useFlatTree.js.map +1 -1
- package/lib/hooks/useNestedControllableCheckedItems.js +107 -0
- package/lib/hooks/useNestedControllableCheckedItems.js.map +1 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/ImmutableMap.js +37 -0
- package/lib/utils/ImmutableMap.js.map +1 -0
- package/lib/utils/ImmutableSet.js +3 -2
- package/lib/utils/ImmutableSet.js.map +1 -1
- package/lib/utils/createFlatTreeItems.js +60 -8
- package/lib/utils/createFlatTreeItems.js.map +1 -1
- package/lib/utils/tokens.js +2 -1
- package/lib/utils/tokens.js.map +1 -1
- package/lib-commonjs/components/Tree/useRootTree.js +23 -7
- package/lib-commonjs/components/Tree/useRootTree.js.map +1 -1
- package/lib-commonjs/components/Tree/useSubtree.js +4 -0
- package/lib-commonjs/components/Tree/useSubtree.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/components/TreeItem/useTreeItem.js +48 -4
- package/lib-commonjs/components/TreeItem/useTreeItem.js.map +1 -1
- package/lib-commonjs/components/TreeItem/useTreeItemContextValues.js +5 -3
- 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 +11 -6
- 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/contexts/treeContext.js +3 -0
- package/lib-commonjs/contexts/treeContext.js.map +1 -1
- package/lib-commonjs/hooks/index.js +2 -0
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useFlatControllableCheckedItems.js +91 -0
- package/lib-commonjs/hooks/useFlatControllableCheckedItems.js.map +1 -0
- package/lib-commonjs/hooks/useFlatTree.js +14 -3
- package/lib-commonjs/hooks/useFlatTree.js.map +1 -1
- package/lib-commonjs/hooks/useNestedControllableCheckedItems.js +116 -0
- package/lib-commonjs/hooks/useNestedControllableCheckedItems.js.map +1 -0
- package/lib-commonjs/utils/ImmutableMap.js +45 -0
- package/lib-commonjs/utils/ImmutableMap.js.map +1 -0
- package/lib-commonjs/utils/ImmutableSet.js +3 -2
- package/lib-commonjs/utils/ImmutableSet.js.map +1 -1
- package/lib-commonjs/utils/createFlatTreeItems.js +60 -8
- package/lib-commonjs/utils/createFlatTreeItems.js.map +1 -1
- package/lib-commonjs/utils/tokens.js +2 -1
- package/lib-commonjs/utils/tokens.js.map +1 -1
- package/package.json +9 -7
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,79 @@
|
|
|
2
2
|
"name": "@fluentui/react-tree",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 20 Jul 2023 18:24:27 GMT",
|
|
6
|
+
"tag": "@fluentui/react-tree_v9.0.0-beta.26",
|
|
7
|
+
"version": "9.0.0-beta.26",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
12
|
+
"package": "@fluentui/react-tree",
|
|
13
|
+
"commit": "f5b6134905e28c124b2dc34cc6bd286ca621de6a",
|
|
14
|
+
"comment": "feat: implements selection"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@fluentui/react-tree",
|
|
19
|
+
"comment": "Bump @fluentui/react-aria to v9.3.27",
|
|
20
|
+
"commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@fluentui/react-tree",
|
|
25
|
+
"comment": "Bump @fluentui/react-avatar to v9.5.13",
|
|
26
|
+
"commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "beachball",
|
|
30
|
+
"package": "@fluentui/react-tree",
|
|
31
|
+
"comment": "Bump @fluentui/react-button to v9.3.24",
|
|
32
|
+
"commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "beachball",
|
|
36
|
+
"package": "@fluentui/react-tree",
|
|
37
|
+
"comment": "Bump @fluentui/react-checkbox to v9.1.25",
|
|
38
|
+
"commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"author": "beachball",
|
|
42
|
+
"package": "@fluentui/react-tree",
|
|
43
|
+
"comment": "Bump @fluentui/react-portal to v9.3.2",
|
|
44
|
+
"commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"author": "beachball",
|
|
48
|
+
"package": "@fluentui/react-tree",
|
|
49
|
+
"comment": "Bump @fluentui/react-radio to v9.1.25",
|
|
50
|
+
"commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"author": "beachball",
|
|
54
|
+
"package": "@fluentui/react-tree",
|
|
55
|
+
"comment": "Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.12",
|
|
56
|
+
"commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"date": "Thu, 13 Jul 2023 21:25:48 GMT",
|
|
63
|
+
"tag": "@fluentui/react-tree_v9.0.0-beta.25",
|
|
64
|
+
"version": "9.0.0-beta.25",
|
|
65
|
+
"comments": {
|
|
66
|
+
"none": [
|
|
67
|
+
{
|
|
68
|
+
"author": "martinhochel@microsoft.com",
|
|
69
|
+
"package": "@fluentui/react-tree",
|
|
70
|
+
"commit": "8a9e1018f2abb2c7608c49d32acf44e93c43cba6",
|
|
71
|
+
"comment": "chore: update devDependencies to use * for inner workspace dependencies"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"date": "Tue, 11 Jul 2023 18:46:36 GMT",
|
|
6
78
|
"tag": "@fluentui/react-tree_v9.0.0-beta.25",
|
|
7
79
|
"version": "9.0.0-beta.25",
|
|
8
80
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-tree
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 20 Jul 2023 18:24:27 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-beta.26](https://github.com/microsoft/fluentui/tree/@fluentui/react-tree_v9.0.0-beta.26)
|
|
8
|
+
|
|
9
|
+
Thu, 20 Jul 2023 18:24:27 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tree_v9.0.0-beta.25..@fluentui/react-tree_v9.0.0-beta.26)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- feat: implements selection ([PR #28497](https://github.com/microsoft/fluentui/pull/28497) by bernardo.sunderhus@gmail.com)
|
|
15
|
+
- Bump @fluentui/react-aria to v9.3.27 ([PR #26826](https://github.com/microsoft/fluentui/pull/26826) by beachball)
|
|
16
|
+
- Bump @fluentui/react-avatar to v9.5.13 ([PR #26826](https://github.com/microsoft/fluentui/pull/26826) by beachball)
|
|
17
|
+
- Bump @fluentui/react-button to v9.3.24 ([PR #26826](https://github.com/microsoft/fluentui/pull/26826) by beachball)
|
|
18
|
+
- Bump @fluentui/react-checkbox to v9.1.25 ([PR #26826](https://github.com/microsoft/fluentui/pull/26826) by beachball)
|
|
19
|
+
- Bump @fluentui/react-portal to v9.3.2 ([PR #26826](https://github.com/microsoft/fluentui/pull/26826) by beachball)
|
|
20
|
+
- Bump @fluentui/react-radio to v9.1.25 ([PR #26826](https://github.com/microsoft/fluentui/pull/26826) by beachball)
|
|
21
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.12 ([PR #26826](https://github.com/microsoft/fluentui/pull/26826) by beachball)
|
|
22
|
+
|
|
7
23
|
## [9.0.0-beta.25](https://github.com/microsoft/fluentui/tree/@fluentui/react-tree_v9.0.0-beta.25)
|
|
8
24
|
|
|
9
|
-
Tue, 11 Jul 2023 18:
|
|
25
|
+
Tue, 11 Jul 2023 18:46:36 GMT
|
|
10
26
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tree_v9.0.0-beta.24..@fluentui/react-tree_v9.0.0-beta.25)
|
|
11
27
|
|
|
12
28
|
### Changes
|
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 type { 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,15 +20,29 @@ 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 type { 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.
|
|
@@ -143,7 +159,7 @@ export declare type FlatTree<Props extends FlatTreeItemProps = FlatTreeItemProps
|
|
|
143
159
|
export declare type FlatTreeItem<Props extends FlatTreeItemProps = FlatTreeItemProps> = {
|
|
144
160
|
index: number;
|
|
145
161
|
level: number;
|
|
146
|
-
|
|
162
|
+
childrenValues: TreeItemValue[];
|
|
147
163
|
value: TreeItemValue;
|
|
148
164
|
parentValue: TreeItemValue | undefined;
|
|
149
165
|
getTreeItemProps(): Required<Pick<Props, 'value' | 'aria-setsize' | 'aria-level' | 'aria-posinset' | 'itemType'>> & Omit<Props, 'parentId'>;
|
|
@@ -154,13 +170,49 @@ export declare type FlatTreeItemProps = Omit<TreeItemProps, 'itemType' | 'value'
|
|
|
154
170
|
parentValue?: TreeItemValue;
|
|
155
171
|
};
|
|
156
172
|
|
|
157
|
-
declare type FlatTreeOptions = Pick<TreeProps, 'openItems' | 'defaultOpenItems' | 'onOpenChange' | 'onNavigation_unstable'>;
|
|
173
|
+
declare type FlatTreeOptions = Pick<TreeProps, 'openItems' | 'defaultOpenItems' | 'onOpenChange' | 'onNavigation_unstable' | 'selectionMode' | 'checkedItems' | 'defaultCheckedItems' | 'onCheckedChange'>;
|
|
158
174
|
|
|
159
|
-
export declare type FlatTreeProps = Required<Pick<TreeProps, 'openItems' | 'onOpenChange' | 'onNavigation_unstable'>> & {
|
|
175
|
+
export declare type FlatTreeProps = Required<Pick<TreeProps, 'openItems' | 'onOpenChange' | 'onNavigation_unstable' | 'checkedItems' | 'onCheckedChange'>> & {
|
|
160
176
|
ref: React_2.Ref<HTMLDivElement>;
|
|
161
177
|
openItems: ImmutableSet<TreeItemValue>;
|
|
162
178
|
};
|
|
163
179
|
|
|
180
|
+
declare interface ImmutableMap<Key, Value> {
|
|
181
|
+
clear(): ImmutableMap<Key, Value>;
|
|
182
|
+
delete(key: Key): ImmutableMap<Key, Value>;
|
|
183
|
+
/**
|
|
184
|
+
* 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.
|
|
185
|
+
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
|
|
186
|
+
*/
|
|
187
|
+
get(key: Key): Value | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* @returns boolean indicating whether an element with the specified key exists or not.
|
|
190
|
+
*/
|
|
191
|
+
has(key: Key): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* 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.
|
|
194
|
+
*/
|
|
195
|
+
set(key: Key, value: Value): ImmutableMap<Key, Value>;
|
|
196
|
+
/**
|
|
197
|
+
* @returns the number of elements in the Map.
|
|
198
|
+
*/
|
|
199
|
+
readonly size: number;
|
|
200
|
+
/** Iterates over entries in the Map. */
|
|
201
|
+
[Symbol.iterator](): IterableIterator<[Key, Value]>;
|
|
202
|
+
/**
|
|
203
|
+
* @internal
|
|
204
|
+
* Exposes the internal map used to store values.
|
|
205
|
+
* This is an internal API and should not be used directly.
|
|
206
|
+
*/
|
|
207
|
+
dangerouslyGetInternalMap_unstable(): Map<Key, Value>;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
declare const ImmutableMap: {
|
|
211
|
+
empty: ImmutableMap<never, never>;
|
|
212
|
+
create: typeof createImmutableMap;
|
|
213
|
+
dangerouslyCreate_unstable: typeof dangerouslyCreateImmutableMap;
|
|
214
|
+
};
|
|
215
|
+
|
|
164
216
|
declare interface ImmutableSet<Value> {
|
|
165
217
|
/**
|
|
166
218
|
* The number of (unique) elements in a ImmutableSet.
|
|
@@ -190,15 +242,17 @@ declare interface ImmutableSet<Value> {
|
|
|
190
242
|
* Exposes the internal set used to store values.
|
|
191
243
|
* This is an internal API and should not be used directly.
|
|
192
244
|
*/
|
|
193
|
-
|
|
245
|
+
dangerouslyGetInternalSet_unstable(): Set<Value>;
|
|
194
246
|
}
|
|
195
247
|
|
|
196
248
|
declare const ImmutableSet: {
|
|
197
249
|
empty: ImmutableSet<never>;
|
|
198
250
|
create: typeof createImmutableSet;
|
|
199
|
-
|
|
251
|
+
dangerouslyCreate_unstable: typeof dangerouslyCreateImmutableSet;
|
|
200
252
|
};
|
|
201
253
|
|
|
254
|
+
declare type MultiSelectValue = NonNullable<CheckboxProps['checked']>;
|
|
255
|
+
|
|
202
256
|
export declare type NestedTreeItem<Props extends TreeItemProps> = Omit<Props, 'subtree' | 'itemType'> & {
|
|
203
257
|
value: TreeItemValue;
|
|
204
258
|
subtree?: NestedTreeItem<Props>[];
|
|
@@ -223,6 +277,8 @@ export declare const renderTreeItemLayout_unstable: (state: TreeItemLayoutState)
|
|
|
223
277
|
*/
|
|
224
278
|
export declare const renderTreeItemPersonaLayout_unstable: (state: TreeItemPersonaLayoutState, contextValues: TreeItemPersonaLayoutContextValues) => JSX.Element;
|
|
225
279
|
|
|
280
|
+
declare type SingleSelectValue = NonNullable<RadioProps['checked']>;
|
|
281
|
+
|
|
226
282
|
/**
|
|
227
283
|
* A tree view widget presents a hierarchical list.
|
|
228
284
|
* Any item in the hierarchy may have child items,
|
|
@@ -233,13 +289,30 @@ export declare const renderTreeItemPersonaLayout_unstable: (state: TreeItemPerso
|
|
|
233
289
|
*/
|
|
234
290
|
export declare const Tree: ForwardRefComponent<TreeProps>;
|
|
235
291
|
|
|
292
|
+
export declare type TreeCheckedChangeData = {
|
|
293
|
+
value: TreeItemValue;
|
|
294
|
+
target: HTMLElement;
|
|
295
|
+
event: React_2.ChangeEvent<HTMLElement>;
|
|
296
|
+
type: 'Change';
|
|
297
|
+
} & ({
|
|
298
|
+
selectionMode: 'multiselect';
|
|
299
|
+
checked: MultiSelectValue;
|
|
300
|
+
} | {
|
|
301
|
+
selectionMode: 'single';
|
|
302
|
+
checked: SingleSelectValue;
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
export declare type TreeCheckedChangeEvent = TreeCheckedChangeData['event'];
|
|
306
|
+
|
|
236
307
|
export declare const treeClassNames: SlotClassNames<TreeSlots>;
|
|
237
308
|
|
|
238
309
|
export declare type TreeContextValue = {
|
|
239
310
|
level: number;
|
|
311
|
+
selectionMode: 'none' | SelectionMode_2;
|
|
240
312
|
appearance: 'subtle' | 'subtle-alpha' | 'transparent';
|
|
241
313
|
size: 'small' | 'medium';
|
|
242
314
|
openItems: ImmutableSet<TreeItemValue>;
|
|
315
|
+
checkedItems: ImmutableMap<TreeItemValue, 'mixed' | boolean>;
|
|
243
316
|
/**
|
|
244
317
|
* requests root Tree component to respond to some tree item event,
|
|
245
318
|
*/
|
|
@@ -294,7 +367,7 @@ export declare const TreeItemLayout: ForwardRefComponent<TreeItemLayoutProps>;
|
|
|
294
367
|
|
|
295
368
|
export declare const treeItemLayoutClassNames: SlotClassNames<TreeItemLayoutInternalSlots>;
|
|
296
369
|
|
|
297
|
-
declare type TreeItemLayoutInternalSlots = TreeItemLayoutSlots &
|
|
370
|
+
declare type TreeItemLayoutInternalSlots = TreeItemLayoutSlots & TreeItemSlotsContextValue;
|
|
298
371
|
|
|
299
372
|
/**
|
|
300
373
|
* TreeItemLayout Props
|
|
@@ -382,7 +455,7 @@ export declare const TreeItemProvider: React_2.Provider<TreeItemContextValue | u
|
|
|
382
455
|
|
|
383
456
|
declare type TreeItemRequest = {
|
|
384
457
|
itemType: TreeItemType;
|
|
385
|
-
} & (OmitWithoutExpanding<TreeOpenChangeData, 'open' | '
|
|
458
|
+
} & (OmitWithoutExpanding<TreeOpenChangeData, 'open'> | TreeNavigationData_unstable | OmitWithoutExpanding<TreeCheckedChangeData, 'checked' | 'selectionMode'>);
|
|
386
459
|
|
|
387
460
|
export declare type TreeItemSlots = {
|
|
388
461
|
root: Slot<ExtractSlotProps<Slot<'div'> & {
|
|
@@ -404,9 +477,19 @@ export declare type TreeItemSlots = {
|
|
|
404
477
|
*/
|
|
405
478
|
visible?: boolean;
|
|
406
479
|
}>>;
|
|
480
|
+
/**
|
|
481
|
+
* Selection indicator if selection type is checkbox
|
|
482
|
+
*/
|
|
483
|
+
checkboxIndicator?: Slot<typeof Checkbox>;
|
|
484
|
+
/**
|
|
485
|
+
* Selection indicator if selection type is radio
|
|
486
|
+
*/
|
|
487
|
+
radioIndicator?: Slot<typeof Radio>;
|
|
407
488
|
};
|
|
408
489
|
|
|
409
|
-
declare type TreeItemSlotsContextValue = Pick<TreeItemSlots, 'actions' | 'aside' | 'expandIcon'
|
|
490
|
+
declare type TreeItemSlotsContextValue = Pick<TreeItemSlots, 'actions' | 'aside' | 'expandIcon'> & {
|
|
491
|
+
selector?: Slot<typeof Checkbox> | Slot<typeof Radio>;
|
|
492
|
+
};
|
|
410
493
|
|
|
411
494
|
/**
|
|
412
495
|
* State used in rendering TreeItem
|
|
@@ -455,7 +538,6 @@ export declare type TreeOpenChangeData = {
|
|
|
455
538
|
open: boolean;
|
|
456
539
|
value: TreeItemValue;
|
|
457
540
|
target: HTMLElement;
|
|
458
|
-
openItems: ImmutableSet<TreeItemValue>;
|
|
459
541
|
} & ({
|
|
460
542
|
event: React_2.MouseEvent<HTMLElement>;
|
|
461
543
|
type: 'ExpandIconClick';
|
|
@@ -520,10 +602,42 @@ export declare type TreeProps = ComponentProps<TreeSlots> & {
|
|
|
520
602
|
* @param data - A data object with relevant information,
|
|
521
603
|
*/
|
|
522
604
|
onNavigation_unstable?(event: TreeNavigationEvent_unstable, data: TreeNavigationData_unstable): void;
|
|
605
|
+
/**
|
|
606
|
+
* This refers to the selection mode of the tree.
|
|
607
|
+
* - undefined: No selection can be done.
|
|
608
|
+
* - 'single': Only one tree item can be selected, radio buttons are rendered.
|
|
609
|
+
* - 'multiselect': Multiple tree items can be selected, checkboxes are rendered.
|
|
610
|
+
*
|
|
611
|
+
* @default undefined
|
|
612
|
+
*/
|
|
613
|
+
selectionMode?: SelectionMode_2;
|
|
614
|
+
/**
|
|
615
|
+
* This refers to a list of ids of checked tree items, or a list of tuples of ids and checked state.
|
|
616
|
+
* Controls the state of the checked tree items.
|
|
617
|
+
* These property is ignored for subtrees.
|
|
618
|
+
*/
|
|
619
|
+
checkedItems?: Iterable<TreeItemValue | [TreeItemValue, TreeSelectionValue]>;
|
|
620
|
+
/**
|
|
621
|
+
* This refers to a list of ids of checked tree items, or a list of tuples of ids and checked state.
|
|
622
|
+
* Default value for the uncontrolled state of checked tree items.
|
|
623
|
+
* These property is ignored for subtrees.
|
|
624
|
+
*/
|
|
625
|
+
defaultCheckedItems?: Iterable<TreeItemValue | [TreeItemValue, TreeSelectionValue]>;
|
|
626
|
+
/**
|
|
627
|
+
* Callback fired when the component changes value from checked state.
|
|
628
|
+
* These property is ignored for subtrees.
|
|
629
|
+
*
|
|
630
|
+
* @param event - a React's Synthetic event
|
|
631
|
+
* @param data - A data object with relevant information,
|
|
632
|
+
* such as checked value and type of interaction that created the event.
|
|
633
|
+
*/
|
|
634
|
+
onCheckedChange?(event: TreeCheckedChangeEvent, data: TreeCheckedChangeData): void;
|
|
523
635
|
};
|
|
524
636
|
|
|
525
637
|
export declare const TreeProvider: Provider<TreeContextValue | undefined> & FC<ProviderProps<TreeContextValue | undefined>>;
|
|
526
638
|
|
|
639
|
+
export declare type TreeSelectionValue = MultiSelectValue | SingleSelectValue;
|
|
640
|
+
|
|
527
641
|
export declare type TreeSlots = {
|
|
528
642
|
root: Slot<'div'>;
|
|
529
643
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Tree.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { TreeContextValue } from '../../contexts/treeContext';\nimport type { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Home } from '@fluentui/keyboard-keys';\nimport type { TreeItemValue } from '../TreeItem/TreeItem.types';\nimport {
|
|
1
|
+
{"version":3,"sources":["Tree.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ComponentProps, ComponentState, SelectionMode, Slot } from '@fluentui/react-utilities';\nimport type { TreeContextValue } from '../../contexts/treeContext';\nimport type { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Home } from '@fluentui/keyboard-keys';\nimport type { TreeItemValue } from '../TreeItem/TreeItem.types';\nimport { CheckboxProps } from '@fluentui/react-checkbox';\nimport { RadioProps } from '@fluentui/react-radio';\n\nexport type MultiSelectValue = NonNullable<CheckboxProps['checked']>;\nexport type SingleSelectValue = NonNullable<RadioProps['checked']>;\nexport type TreeSelectionValue = MultiSelectValue | SingleSelectValue;\n\nexport type TreeSlots = {\n root: Slot<'div'>;\n};\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type TreeNavigationData_unstable = { target: HTMLElement; value: TreeItemValue } & (\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 = {\n open: boolean;\n value: TreeItemValue;\n target: HTMLElement;\n} & (\n | { event: React.MouseEvent<HTMLElement>; type: 'ExpandIconClick' }\n | { event: React.MouseEvent<HTMLElement>; type: 'Click' }\n | { event: React.KeyboardEvent<HTMLElement>; type: typeof Enter }\n | { event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowRight }\n | { event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowLeft }\n);\n\nexport type TreeOpenChangeEvent = TreeOpenChangeData['event'];\n\nexport type TreeCheckedChangeData = {\n value: TreeItemValue;\n target: HTMLElement;\n event: React.ChangeEvent<HTMLElement>;\n type: 'Change';\n} & (\n | {\n selectionMode: 'multiselect';\n checked: MultiSelectValue;\n }\n | {\n selectionMode: 'single';\n checked: SingleSelectValue;\n }\n);\n\nexport type TreeCheckedChangeEvent = TreeCheckedChangeData['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<TreeItemValue>;\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<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 * This refers to a list of ids of checked tree items, or a list of tuples of ids and checked state.\n * Default value for the uncontrolled state of checked tree items.\n * These property is ignored for subtrees.\n */\n defaultCheckedItems?: 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\n/**\n * State used in rendering Tree\n */\nexport type TreeState = ComponentState<TreeSlots> &\n TreeContextValue & {\n open: boolean;\n };\n"],"names":[],"mappings":"AAAA,WAyJI"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as ReactDOM from 'react-dom';
|
|
3
3
|
import { getNativeElementProps, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';
|
|
4
|
-
import {
|
|
4
|
+
import { useControllableOpenItems, useNestedTreeNavigation, useNestedControllableCheckedItems, createNextOpenItems } from '../../hooks';
|
|
5
5
|
import { treeDataTypes } from '../../utils/tokens';
|
|
6
6
|
/**
|
|
7
7
|
* Create the state required to render the root level Tree.
|
|
@@ -10,20 +10,24 @@ import { treeDataTypes } from '../../utils/tokens';
|
|
|
10
10
|
* @param ref - reference to root HTMLElement of Tree
|
|
11
11
|
*/ export function useRootTree(props, ref) {
|
|
12
12
|
warnIfNoProperPropsRootTree(props);
|
|
13
|
-
const { appearance ='subtle' , size ='medium' } = props;
|
|
13
|
+
const { appearance ='subtle' , size ='medium' , selectionMode ='none' } = props;
|
|
14
14
|
const [openItems, setOpenItems] = useControllableOpenItems(props);
|
|
15
|
+
const [checkedItems] = useNestedControllableCheckedItems(props);
|
|
15
16
|
const [navigate, navigationRef] = useNestedTreeNavigation();
|
|
16
17
|
const requestOpenChange = (data)=>{
|
|
17
18
|
var _props_onOpenChange;
|
|
18
|
-
|
|
19
|
-
(_props_onOpenChange = props.onOpenChange) === null || _props_onOpenChange === void 0 ? void 0 : _props_onOpenChange.call(props, data.event, {
|
|
20
|
-
...data,
|
|
21
|
-
openItems: nextOpenItems
|
|
22
|
-
});
|
|
19
|
+
(_props_onOpenChange = props.onOpenChange) === null || _props_onOpenChange === void 0 ? void 0 : _props_onOpenChange.call(props, data.event, data);
|
|
23
20
|
if (data.event.isDefaultPrevented()) {
|
|
24
21
|
return;
|
|
25
22
|
}
|
|
26
|
-
return setOpenItems(
|
|
23
|
+
return setOpenItems(createNextOpenItems(data, openItems));
|
|
24
|
+
};
|
|
25
|
+
const requestCheckedChange = (data)=>{
|
|
26
|
+
var _props_onCheckedChange;
|
|
27
|
+
(_props_onCheckedChange = props.onCheckedChange) === null || _props_onCheckedChange === void 0 ? void 0 : _props_onCheckedChange.call(props, data.event, data);
|
|
28
|
+
// TODO:
|
|
29
|
+
// we should implement the logic for nested tree selection
|
|
30
|
+
// return setCheckedItems(checkedItems);
|
|
27
31
|
};
|
|
28
32
|
const requestNavigation = (data)=>{
|
|
29
33
|
var _props_onNavigation_unstable;
|
|
@@ -98,21 +102,33 @@ import { treeDataTypes } from '../../utils/tokens';
|
|
|
98
102
|
...request,
|
|
99
103
|
target: request.event.currentTarget
|
|
100
104
|
});
|
|
105
|
+
case treeDataTypes.Change:
|
|
106
|
+
{
|
|
107
|
+
const previousCheckedValue = checkedItems.get(request.value);
|
|
108
|
+
return requestCheckedChange({
|
|
109
|
+
...request,
|
|
110
|
+
selectionMode: selectionMode,
|
|
111
|
+
checked: previousCheckedValue === 'mixed' ? true : !previousCheckedValue
|
|
112
|
+
});
|
|
113
|
+
}
|
|
101
114
|
}
|
|
102
115
|
});
|
|
103
116
|
return {
|
|
104
117
|
components: {
|
|
105
118
|
root: 'div'
|
|
106
119
|
},
|
|
120
|
+
selectionMode,
|
|
107
121
|
open: true,
|
|
108
122
|
appearance,
|
|
109
123
|
size,
|
|
110
124
|
level: 1,
|
|
111
125
|
openItems,
|
|
126
|
+
checkedItems,
|
|
112
127
|
requestTreeResponse,
|
|
113
128
|
root: getNativeElementProps('div', {
|
|
114
129
|
ref: useMergedRefs(navigationRef, ref),
|
|
115
130
|
role: 'tree',
|
|
131
|
+
'aria-multiselectable': selectionMode === 'multiselect' ? true : undefined,
|
|
116
132
|
...props
|
|
117
133
|
})
|
|
118
134
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useRootTree.ts"],"sourcesContent":["import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { getNativeElementProps, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport
|
|
1
|
+
{"version":3,"sources":["useRootTree.ts"],"sourcesContent":["import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { SelectionMode, getNativeElementProps, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport {\n TreeOpenChangeData,\n TreeProps,\n TreeState,\n TreeNavigationData_unstable,\n TreeCheckedChangeData,\n} from './Tree.types';\nimport {\n useControllableOpenItems,\n useNestedTreeNavigation,\n useNestedControllableCheckedItems,\n createNextOpenItems,\n} from '../../hooks';\nimport { treeDataTypes } from '../../utils/tokens';\nimport { TreeItemRequest } from '../../contexts';\n\n/**\n * Create the state required to render the root level Tree.\n *\n * @param props - props from this instance of Tree\n * @param ref - reference to root HTMLElement of Tree\n */\nexport function useRootTree(props: TreeProps, ref: React.Ref<HTMLElement>): TreeState {\n warnIfNoProperPropsRootTree(props);\n\n const { appearance = 'subtle', size = 'medium', selectionMode = 'none' } = props;\n\n const [openItems, setOpenItems] = useControllableOpenItems(props);\n\n const [checkedItems] = useNestedControllableCheckedItems(props);\n const [navigate, navigationRef] = useNestedTreeNavigation();\n\n const requestOpenChange = (data: TreeOpenChangeData) => {\n props.onOpenChange?.(data.event, data);\n if (data.event.isDefaultPrevented()) {\n return;\n }\n return setOpenItems(createNextOpenItems(data, openItems));\n };\n\n const requestCheckedChange = (data: TreeCheckedChangeData) => {\n props.onCheckedChange?.(data.event, data);\n // TODO:\n // we should implement the logic for nested tree selection\n // return setCheckedItems(checkedItems);\n };\n\n const requestNavigation = (data: TreeNavigationData_unstable) => {\n props.onNavigation_unstable?.(data.event, data);\n if (data.event.isDefaultPrevented()) {\n return;\n }\n navigate(data);\n if (data.type === treeDataTypes.ArrowDown || data.type === treeDataTypes.ArrowUp) {\n data.event.preventDefault();\n }\n };\n\n const requestTreeResponse = useEventCallback((request: TreeItemRequest) => {\n switch (request.type) {\n case treeDataTypes.Click:\n case treeDataTypes.ExpandIconClick: {\n return ReactDOM.unstable_batchedUpdates(() => {\n requestOpenChange({ ...request, open: request.itemType === 'branch' && !openItems.has(request.value) });\n requestNavigation({ ...request, type: treeDataTypes.Click });\n });\n }\n case treeDataTypes.ArrowRight: {\n if (request.itemType === 'leaf') {\n return;\n }\n const open = openItems.has(request.value);\n if (!open) {\n return requestOpenChange({ ...request, open: true });\n }\n return requestNavigation(request);\n }\n case treeDataTypes.Enter: {\n const open = openItems.has(request.value);\n return requestOpenChange({ ...request, open: request.itemType === 'branch' && !open });\n }\n case treeDataTypes.ArrowLeft: {\n const open = openItems.has(request.value);\n if (open && request.itemType === 'branch') {\n return requestOpenChange({ ...request, open: false, type: treeDataTypes.ArrowLeft });\n }\n return requestNavigation({ ...request, type: treeDataTypes.ArrowLeft });\n }\n case treeDataTypes.End:\n case treeDataTypes.Home:\n case treeDataTypes.ArrowUp:\n case treeDataTypes.ArrowDown:\n case treeDataTypes.TypeAhead:\n return requestNavigation({ ...request, target: request.event.currentTarget });\n case treeDataTypes.Change: {\n const previousCheckedValue = checkedItems.get(request.value);\n return requestCheckedChange({\n ...request,\n selectionMode: selectionMode as SelectionMode,\n checked: previousCheckedValue === 'mixed' ? true : !previousCheckedValue,\n });\n }\n }\n });\n\n return {\n components: {\n root: 'div',\n },\n selectionMode,\n open: true,\n appearance,\n size,\n level: 1,\n openItems,\n checkedItems,\n requestTreeResponse,\n root: getNativeElementProps('div', {\n ref: useMergedRefs(navigationRef, ref),\n role: 'tree',\n 'aria-multiselectable': selectionMode === 'multiselect' ? true : undefined,\n ...props,\n }),\n };\n}\n\nfunction warnIfNoProperPropsRootTree(props: Pick<TreeProps, 'aria-label' | 'aria-labelledby'>) {\n if (process.env.NODE_ENV === 'development') {\n if (!props['aria-label'] && !props['aria-labelledby']) {\n // eslint-disable-next-line no-console\n console.warn('Tree must have either a `aria-label` or `aria-labelledby` property defined');\n }\n }\n}\n"],"names":["React","ReactDOM","getNativeElementProps","useEventCallback","useMergedRefs","useControllableOpenItems","useNestedTreeNavigation","useNestedControllableCheckedItems","createNextOpenItems","treeDataTypes","useRootTree","props","ref","warnIfNoProperPropsRootTree","appearance","size","selectionMode","openItems","setOpenItems","checkedItems","navigate","navigationRef","requestOpenChange","data","onOpenChange","event","isDefaultPrevented","requestCheckedChange","onCheckedChange","requestNavigation","onNavigation_unstable","type","ArrowDown","ArrowUp","preventDefault","requestTreeResponse","request","Click","ExpandIconClick","unstable_batchedUpdates","open","itemType","has","value","ArrowRight","Enter","ArrowLeft","End","Home","TypeAhead","target","currentTarget","Change","previousCheckedValue","get","checked","components","root","level","role","undefined","process","env","NODE_ENV","console","warn"],"mappings":"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"}
|
|
@@ -13,7 +13,9 @@ import { useTreeContext_unstable, useTreeItemContext_unstable } from '../../cont
|
|
|
13
13
|
const value = useTreeItemContext_unstable((ctx)=>ctx.value);
|
|
14
14
|
const { appearance =contextAppearance !== null && contextAppearance !== void 0 ? contextAppearance : 'subtle' , size =contextSize !== null && contextSize !== void 0 ? contextSize : 'medium' } = props;
|
|
15
15
|
const parentLevel = useTreeContext_unstable((ctx)=>ctx.level);
|
|
16
|
+
const selectionMode = useTreeContext_unstable((ctx)=>ctx.selectionMode);
|
|
16
17
|
const openItems = useTreeContext_unstable((ctx)=>ctx.openItems);
|
|
18
|
+
const checkedItems = useTreeContext_unstable((ctx)=>ctx.checkedItems);
|
|
17
19
|
const requestTreeResponse = useTreeContext_unstable((ctx)=>ctx.requestTreeResponse);
|
|
18
20
|
const open = openItems.has(value);
|
|
19
21
|
return {
|
|
@@ -23,6 +25,7 @@ import { useTreeContext_unstable, useTreeItemContext_unstable } from '../../cont
|
|
|
23
25
|
},
|
|
24
26
|
appearance,
|
|
25
27
|
size,
|
|
28
|
+
selectionMode,
|
|
26
29
|
level: parentLevel + 1,
|
|
27
30
|
root: getNativeElementProps('div', {
|
|
28
31
|
ref: useMergedRefs(ref, subtreeRef),
|
|
@@ -30,6 +33,7 @@ import { useTreeContext_unstable, useTreeItemContext_unstable } from '../../cont
|
|
|
30
33
|
...props
|
|
31
34
|
}),
|
|
32
35
|
openItems,
|
|
36
|
+
checkedItems,
|
|
33
37
|
requestTreeResponse
|
|
34
38
|
};
|
|
35
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useSubtree.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useMergedRefs } from '@fluentui/react-utilities';\nimport { TreeProps, TreeState } from './Tree.types';\nimport { useTreeContext_unstable, useTreeItemContext_unstable } from '../../contexts';\n\n/**\n * Create the state required to render a sub-level Tree.\n *\n * @param props - props from this instance of Tree\n * @param ref - reference to root HTMLElement of Tree\n */\nexport function useSubtree(props: TreeProps, ref: React.Ref<HTMLElement>): TreeState {\n const contextAppearance = useTreeContext_unstable(ctx => ctx.appearance);\n const contextSize = useTreeContext_unstable(ctx => ctx.size);\n const subtreeRef = useTreeItemContext_unstable(ctx => ctx.subtreeRef);\n const value = useTreeItemContext_unstable(ctx => ctx.value);\n\n const { appearance = contextAppearance ?? 'subtle', size = contextSize ?? 'medium' } = props;\n\n const parentLevel = useTreeContext_unstable(ctx => ctx.level);\n const openItems = useTreeContext_unstable(ctx => ctx.openItems);\n const requestTreeResponse = useTreeContext_unstable(ctx => ctx.requestTreeResponse);\n\n const open = openItems.has(value);\n\n return {\n open,\n components: {\n root: 'div',\n },\n appearance,\n size,\n level: parentLevel + 1,\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, subtreeRef),\n role: 'group',\n ...props,\n }),\n openItems,\n requestTreeResponse,\n };\n}\n"],"names":["React","getNativeElementProps","useMergedRefs","useTreeContext_unstable","useTreeItemContext_unstable","useSubtree","props","ref","contextAppearance","ctx","appearance","contextSize","size","subtreeRef","value","parentLevel","level","openItems","requestTreeResponse","open","has","components","root","role"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,qBAAqB,EAAEC,aAAa,QAAQ,4BAA4B;AAEjF,SAASC,uBAAuB,EAAEC,2BAA2B,QAAQ,iBAAiB;AAEtF;;;;;CAKC,GACD,OAAO,SAASC,WAAWC,KAAgB,EAAEC,GAA2B,EAAa;IACnF,MAAMC,oBAAoBL,wBAAwBM,CAAAA,MAAOA,IAAIC,UAAU;IACvE,MAAMC,cAAcR,wBAAwBM,CAAAA,MAAOA,IAAIG,IAAI;IAC3D,MAAMC,aAAaT,4BAA4BK,CAAAA,MAAOA,IAAII,UAAU;IACpE,MAAMC,QAAQV,4BAA4BK,CAAAA,MAAOA,IAAIK,KAAK;IAE1D,MAAM,EAAEJ,YAAaF,8BAAAA,+BAAAA,oBAAqB,QAAQ,CAAA,EAAEI,MAAOD,wBAAAA,yBAAAA,cAAe,QAAQ,CAAA,EAAE,GAAGL;IAEvF,MAAMS,cAAcZ,wBAAwBM,CAAAA,MAAOA,IAAIO,KAAK;IAC5D,MAAMC,
|
|
1
|
+
{"version":3,"sources":["useSubtree.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useMergedRefs } from '@fluentui/react-utilities';\nimport { TreeProps, TreeState } from './Tree.types';\nimport { useTreeContext_unstable, useTreeItemContext_unstable } from '../../contexts';\n\n/**\n * Create the state required to render a sub-level Tree.\n *\n * @param props - props from this instance of Tree\n * @param ref - reference to root HTMLElement of Tree\n */\nexport function useSubtree(props: TreeProps, ref: React.Ref<HTMLElement>): TreeState {\n const contextAppearance = useTreeContext_unstable(ctx => ctx.appearance);\n const contextSize = useTreeContext_unstable(ctx => ctx.size);\n const subtreeRef = useTreeItemContext_unstable(ctx => ctx.subtreeRef);\n const value = useTreeItemContext_unstable(ctx => ctx.value);\n\n const { appearance = contextAppearance ?? 'subtle', size = contextSize ?? 'medium' } = props;\n\n const parentLevel = useTreeContext_unstable(ctx => ctx.level);\n const selectionMode = useTreeContext_unstable(ctx => ctx.selectionMode);\n const openItems = useTreeContext_unstable(ctx => ctx.openItems);\n const checkedItems = useTreeContext_unstable(ctx => ctx.checkedItems);\n const requestTreeResponse = useTreeContext_unstable(ctx => ctx.requestTreeResponse);\n\n const open = openItems.has(value);\n\n return {\n open,\n components: {\n root: 'div',\n },\n appearance,\n size,\n selectionMode,\n level: parentLevel + 1,\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, subtreeRef),\n role: 'group',\n ...props,\n }),\n openItems,\n checkedItems,\n requestTreeResponse,\n };\n}\n"],"names":["React","getNativeElementProps","useMergedRefs","useTreeContext_unstable","useTreeItemContext_unstable","useSubtree","props","ref","contextAppearance","ctx","appearance","contextSize","size","subtreeRef","value","parentLevel","level","selectionMode","openItems","checkedItems","requestTreeResponse","open","has","components","root","role"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,qBAAqB,EAAEC,aAAa,QAAQ,4BAA4B;AAEjF,SAASC,uBAAuB,EAAEC,2BAA2B,QAAQ,iBAAiB;AAEtF;;;;;CAKC,GACD,OAAO,SAASC,WAAWC,KAAgB,EAAEC,GAA2B,EAAa;IACnF,MAAMC,oBAAoBL,wBAAwBM,CAAAA,MAAOA,IAAIC,UAAU;IACvE,MAAMC,cAAcR,wBAAwBM,CAAAA,MAAOA,IAAIG,IAAI;IAC3D,MAAMC,aAAaT,4BAA4BK,CAAAA,MAAOA,IAAII,UAAU;IACpE,MAAMC,QAAQV,4BAA4BK,CAAAA,MAAOA,IAAIK,KAAK;IAE1D,MAAM,EAAEJ,YAAaF,8BAAAA,+BAAAA,oBAAqB,QAAQ,CAAA,EAAEI,MAAOD,wBAAAA,yBAAAA,cAAe,QAAQ,CAAA,EAAE,GAAGL;IAEvF,MAAMS,cAAcZ,wBAAwBM,CAAAA,MAAOA,IAAIO,KAAK;IAC5D,MAAMC,gBAAgBd,wBAAwBM,CAAAA,MAAOA,IAAIQ,aAAa;IACtE,MAAMC,YAAYf,wBAAwBM,CAAAA,MAAOA,IAAIS,SAAS;IAC9D,MAAMC,eAAehB,wBAAwBM,CAAAA,MAAOA,IAAIU,YAAY;IACpE,MAAMC,sBAAsBjB,wBAAwBM,CAAAA,MAAOA,IAAIW,mBAAmB;IAElF,MAAMC,OAAOH,UAAUI,GAAG,CAACR;IAE3B,OAAO;QACLO;QACAE,YAAY;YACVC,MAAM;QACR;QACAd;QACAE;QACAK;QACAD,OAAOD,cAAc;QACrBS,MAAMvB,sBAAsB,OAAO;YACjCM,KAAKL,cAAcK,KAAKM;YACxBY,MAAM;YACN,GAAGnB,KAAK;QACV;QACAY;QACAC;QACAC;IACF;AACF,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export function useTreeContextValues_unstable(state) {
|
|
2
|
-
const { openItems , level , appearance , size , requestTreeResponse } = state;
|
|
2
|
+
const { openItems , checkedItems , selectionMode , level , appearance , size , requestTreeResponse } = state;
|
|
3
3
|
/**
|
|
4
4
|
* This context is created with "@fluentui/react-context-selector",
|
|
5
5
|
* there is no sense to memoize it
|
|
6
6
|
*/ const tree = {
|
|
7
|
-
appearance,
|
|
8
7
|
size,
|
|
9
8
|
level,
|
|
10
9
|
openItems,
|
|
10
|
+
appearance,
|
|
11
|
+
checkedItems,
|
|
12
|
+
selectionMode,
|
|
11
13
|
requestTreeResponse
|
|
12
14
|
};
|
|
13
15
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTreeContextValues.ts"],"sourcesContent":["import { TreeContextValue } from '../../contexts';\nimport type { TreeContextValues, TreeState } from './Tree.types';\n\nexport function useTreeContextValues_unstable(state: TreeState): TreeContextValues {\n const { openItems, level, appearance, size, requestTreeResponse } = state;\n /**\n * This context is created with \"@fluentui/react-context-selector\",\n * there is no sense to memoize it\n */\n const tree: TreeContextValue = {\n
|
|
1
|
+
{"version":3,"sources":["useTreeContextValues.ts"],"sourcesContent":["import { TreeContextValue } from '../../contexts';\nimport type { TreeContextValues, TreeState } from './Tree.types';\n\nexport function useTreeContextValues_unstable(state: TreeState): TreeContextValues {\n const { openItems, checkedItems, selectionMode, level, appearance, size, requestTreeResponse } = state;\n /**\n * This context is created with \"@fluentui/react-context-selector\",\n * there is no sense to memoize it\n */\n const tree: TreeContextValue = {\n size,\n level,\n openItems,\n appearance,\n checkedItems,\n selectionMode,\n requestTreeResponse,\n };\n\n return { tree };\n}\n"],"names":["useTreeContextValues_unstable","state","openItems","checkedItems","selectionMode","level","appearance","size","requestTreeResponse","tree"],"mappings":"AAGA,OAAO,SAASA,8BAA8BC,KAAgB,EAAqB;IACjF,MAAM,EAAEC,UAAS,EAAEC,aAAY,EAAEC,cAAa,EAAEC,MAAK,EAAEC,WAAU,EAAEC,KAAI,EAAEC,oBAAmB,EAAE,GAAGP;IACjG;;;GAGC,GACD,MAAMQ,OAAyB;QAC7BF;QACAF;QACAH;QACAI;QACAH;QACAC;QACAI;IACF;IAEA,OAAO;QAAEC;IAAK;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["TreeItem.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport type { TreeItemContextValue } from '../../contexts';\nimport { treeItemLevelToken } from '../../utils/tokens';\nimport * as React from 'react';\nimport { TreeItemSlotsContextValue } from '../../contexts/treeItemSlotsContext';\n\nexport type TreeItemCSSProperties = React.CSSProperties & { [treeItemLevelToken]?: string | number };\n\nexport type TreeItemType = 'leaf' | 'branch';\n\nexport type TreeItemSlots = {\n root: Slot<ExtractSlotProps<Slot<'div'> & { style?: TreeItemCSSProperties }>>;\n /**\n * Expand icon slot,\n * by default renders a chevron icon to indicate opening and closing\n */\n expandIcon?: Slot<'div'>;\n aside?: Slot<'div'>;\n /**\n * actionable elements are normally buttons, menus, or other focusable elements.\n * Those elements are only visibly available if the given tree item is currently active.\n */\n actions?: Slot<\n ExtractSlotProps<\n Slot<'div'> & {\n /**\n * Forces visibility of the aside/action content\n */\n visible?: boolean;\n }\n >\n >;\n};\n\nexport type TreeItemInternalSlot = Pick<TreeItemSlots, 'root'>;\n\nexport type TreeItemValue = string | number;\n\nexport type TreeItemContextValues = {\n treeItem: TreeItemContextValue;\n treeItemSlots: TreeItemSlotsContextValue;\n};\n\n/**\n * TreeItem Props\n */\nexport type TreeItemProps = ComponentProps<Partial<TreeItemSlots>> & {\n itemType: TreeItemType;\n value?: TreeItemValue;\n};\n\n/**\n * State used in rendering TreeItem\n */\nexport type TreeItemState = ComponentState<TreeItemInternalSlot> &\n TreeItemContextValue &\n TreeItemSlotsContextValue & {\n level: number;\n itemType: TreeItemType;\n };\n"],"names":["React"],"mappings":"AAGA,YAAYA,WAAW,QAAQ"}
|
|
1
|
+
{"version":3,"sources":["TreeItem.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport type { TreeItemContextValue } from '../../contexts';\nimport { treeItemLevelToken } from '../../utils/tokens';\nimport * as React from 'react';\nimport { TreeItemSlotsContextValue } from '../../contexts/treeItemSlotsContext';\nimport type { Checkbox } from '@fluentui/react-checkbox';\nimport type { Radio } from '@fluentui/react-radio';\n\nexport type TreeItemCSSProperties = React.CSSProperties & { [treeItemLevelToken]?: string | number };\n\nexport type TreeItemType = 'leaf' | 'branch';\n\nexport type TreeItemSlots = {\n root: Slot<ExtractSlotProps<Slot<'div'> & { style?: TreeItemCSSProperties }>>;\n /**\n * Expand icon slot,\n * by default renders a chevron icon to indicate opening and closing\n */\n expandIcon?: Slot<'div'>;\n aside?: Slot<'div'>;\n /**\n * actionable elements are normally buttons, menus, or other focusable elements.\n * Those elements are only visibly available if the given tree item is currently active.\n */\n actions?: Slot<\n ExtractSlotProps<\n Slot<'div'> & {\n /**\n * Forces visibility of the aside/action content\n */\n visible?: boolean;\n }\n >\n >;\n /**\n * Selection indicator if selection type is checkbox\n */\n checkboxIndicator?: Slot<typeof Checkbox>;\n /**\n * Selection indicator if selection type is radio\n */\n radioIndicator?: Slot<typeof Radio>;\n};\n\nexport type TreeItemInternalSlot = Pick<TreeItemSlots, 'root'>;\n\nexport type TreeItemValue = string | number;\n\nexport type TreeItemContextValues = {\n treeItem: TreeItemContextValue;\n treeItemSlots: TreeItemSlotsContextValue;\n};\n\n/**\n * TreeItem Props\n */\nexport type TreeItemProps = ComponentProps<Partial<TreeItemSlots>> & {\n itemType: TreeItemType;\n value?: TreeItemValue;\n};\n\n/**\n * State used in rendering TreeItem\n */\nexport type TreeItemState = ComponentState<TreeItemInternalSlot> &\n TreeItemContextValue &\n TreeItemSlotsContextValue & {\n level: number;\n itemType: TreeItemType;\n };\n"],"names":["React"],"mappings":"AAGA,YAAYA,WAAW,QAAQ"}
|