@fluentui/web-components 3.0.0-beta.85 → 3.0.0-beta.86
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.md +12 -2
- package/dist/dts/tree/index.d.ts +1 -0
- package/dist/dts/tree/tree.base.d.ts +68 -0
- package/dist/dts/tree/tree.d.ts +7 -67
- package/dist/dts/tree-item/index.d.ts +1 -0
- package/dist/dts/tree-item/tree-item.base.d.ts +99 -0
- package/dist/dts/tree-item/tree-item.d.ts +5 -88
- package/dist/dts/tree-item/tree-item.options.d.ts +2 -2
- package/dist/esm/tree/index.js +1 -0
- package/dist/esm/tree/index.js.map +1 -1
- package/dist/esm/tree/tree.base.js +232 -0
- package/dist/esm/tree/tree.base.js.map +1 -0
- package/dist/esm/tree/tree.js +10 -229
- package/dist/esm/tree/tree.js.map +1 -1
- package/dist/esm/tree/tree.template.js +3 -2
- package/dist/esm/tree/tree.template.js.map +1 -1
- package/dist/esm/tree-item/index.js +1 -0
- package/dist/esm/tree-item/index.js.map +1 -1
- package/dist/esm/tree-item/tree-item.base.js +165 -0
- package/dist/esm/tree-item/tree-item.base.js.map +1 -0
- package/dist/esm/tree-item/tree-item.js +13 -149
- package/dist/esm/tree-item/tree-item.js.map +1 -1
- package/dist/esm/tree-item/tree-item.styles.js +8 -21
- package/dist/esm/tree-item/tree-item.styles.js.map +1 -1
- package/dist/esm/tree-item/tree-item.template.js +5 -7
- package/dist/esm/tree-item/tree-item.template.js.map +1 -1
- package/dist/web-components.d.ts +104 -88
- package/dist/web-components.js +851 -800
- package/dist/web-components.min.js +229 -229
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# Change Log - @fluentui/web-components
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 14 Mar 2025 04:06:53 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [3.0.0-beta.86](https://github.com/microsoft/fluentui/tree/@fluentui/web-components_v3.0.0-beta.86)
|
|
8
|
+
|
|
9
|
+
Fri, 14 Mar 2025 04:06:53 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/web-components_v3.0.0-beta.85..@fluentui/web-components_v3.0.0-beta.86)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- refactor out base classes for tree and tree item ([PR #33990](https://github.com/microsoft/fluentui/pull/33990) by jes@microsoft.com)
|
|
15
|
+
- move filtering for tree-items to template ([PR #33989](https://github.com/microsoft/fluentui/pull/33989) by jes@microsoft.com)
|
|
16
|
+
|
|
7
17
|
## [3.0.0-beta.85](https://github.com/microsoft/fluentui/tree/@fluentui/web-components_v3.0.0-beta.85)
|
|
8
18
|
|
|
9
|
-
Thu, 13 Mar 2025 04:07:
|
|
19
|
+
Thu, 13 Mar 2025 04:07:37 GMT
|
|
10
20
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/web-components_v3.0.0-beta.84..@fluentui/web-components_v3.0.0-beta.85)
|
|
11
21
|
|
|
12
22
|
### Changes
|
package/dist/dts/tree/index.d.ts
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { FASTElement } from '@microsoft/fast-element';
|
|
2
|
+
import { BaseTreeItem } from '../tree-item/tree-item.base';
|
|
3
|
+
export declare class BaseTree extends FASTElement {
|
|
4
|
+
/**
|
|
5
|
+
* The currently selected tree item
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
currentSelected: HTMLElement | null;
|
|
9
|
+
/**
|
|
10
|
+
* The tree item that is designated to be in the tab queue.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
private currentFocused;
|
|
15
|
+
/**
|
|
16
|
+
* The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
elementInternals: ElementInternals;
|
|
21
|
+
constructor();
|
|
22
|
+
childTreeItems: BaseTreeItem[];
|
|
23
|
+
childTreeItemsChanged(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Updates current selected when slottedTreeItems changes
|
|
26
|
+
*/
|
|
27
|
+
private updateCurrentSelected;
|
|
28
|
+
/**
|
|
29
|
+
* KeyDown handler
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
keydownHandler(e: KeyboardEvent): boolean | void;
|
|
34
|
+
/**
|
|
35
|
+
* Handle focus events
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
focusHandler(e: FocusEvent): void;
|
|
40
|
+
/**
|
|
41
|
+
* Handle blur events
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
blurHandler(e: FocusEvent): void;
|
|
46
|
+
/**
|
|
47
|
+
* Handles click events bubbling up
|
|
48
|
+
*
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
clickHandler(e: Event): boolean | void;
|
|
52
|
+
/**
|
|
53
|
+
* Handles the selected-changed events bubbling up
|
|
54
|
+
* from child tree items
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
changeHandler(e: Event): boolean | void;
|
|
59
|
+
/**
|
|
60
|
+
* checks if there are any nested tree items
|
|
61
|
+
*/
|
|
62
|
+
private getValidFocusableItem;
|
|
63
|
+
private getVisibleNodes;
|
|
64
|
+
/**
|
|
65
|
+
* Move focus to a tree item based on its offset from the provided item
|
|
66
|
+
*/
|
|
67
|
+
private focusNextNode;
|
|
68
|
+
}
|
package/dist/dts/tree/tree.d.ts
CHANGED
|
@@ -1,25 +1,6 @@
|
|
|
1
|
-
import { FASTElement } from '@microsoft/fast-element';
|
|
2
|
-
import { TreeItem } from '../tree-item/index.js';
|
|
3
1
|
import { TreeItemAppearance, TreeItemSize } from '../tree-item/tree-item.options';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* The currently selected tree item
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
currentSelected: HTMLElement | null;
|
|
10
|
-
/**
|
|
11
|
-
* The tree item that is designated to be in the tab queue.
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
private currentFocused;
|
|
16
|
-
/**
|
|
17
|
-
* The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
|
|
18
|
-
*
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
elementInternals: ElementInternals;
|
|
22
|
-
constructor();
|
|
2
|
+
import { BaseTree } from './tree.base';
|
|
3
|
+
export declare class Tree extends BaseTree {
|
|
23
4
|
/**
|
|
24
5
|
* The size of the tree item element
|
|
25
6
|
* @public
|
|
@@ -34,55 +15,14 @@ export declare class Tree extends FASTElement {
|
|
|
34
15
|
*/
|
|
35
16
|
appearance: TreeItemAppearance;
|
|
36
17
|
private appearanceChanged;
|
|
37
|
-
childTreeItems: TreeItem[];
|
|
38
|
-
protected childTreeItemsChanged(): void;
|
|
39
|
-
/**
|
|
40
|
-
* 1. Update the child items' size based on the tree's size
|
|
41
|
-
* 2. Update the child items' appearance based on the tree's appearance
|
|
42
|
-
*/
|
|
43
|
-
private updateSizeAndAppearance;
|
|
44
|
-
/**
|
|
45
|
-
* Updates current selected when slottedTreeItems changes
|
|
46
|
-
*/
|
|
47
|
-
private updateCurrentSelected;
|
|
48
|
-
/**
|
|
49
|
-
* KeyDown handler
|
|
50
|
-
*
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
|
-
keydownHandler(e: KeyboardEvent): boolean | void;
|
|
54
18
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
19
|
+
* child tree items supered change event
|
|
57
20
|
* @internal
|
|
58
21
|
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Handle blur events
|
|
62
|
-
*
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
blurHandler(e: FocusEvent): void;
|
|
66
|
-
/**
|
|
67
|
-
* Handles click events bubbling up
|
|
68
|
-
*
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
clickHandler(e: Event): boolean | void;
|
|
72
|
-
/**
|
|
73
|
-
* Handles the selected-changed events bubbling up
|
|
74
|
-
* from child tree items
|
|
75
|
-
*
|
|
76
|
-
* @internal
|
|
77
|
-
*/
|
|
78
|
-
changeHandler(e: Event): boolean | void;
|
|
22
|
+
childTreeItemsChanged(): void;
|
|
79
23
|
/**
|
|
80
|
-
*
|
|
81
|
-
|
|
82
|
-
private getValidFocusableItem;
|
|
83
|
-
private getVisibleNodes;
|
|
84
|
-
/**
|
|
85
|
-
* Move focus to a tree item based on its offset from the provided item
|
|
24
|
+
* 1. Update the child items' size based on the tree's size
|
|
25
|
+
* 2. Update the child items' appearance based on the tree's appearance
|
|
86
26
|
*/
|
|
87
|
-
|
|
27
|
+
updateSizeAndAppearance(): void;
|
|
88
28
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { FASTElement } from '@microsoft/fast-element';
|
|
2
|
+
export declare class BaseTreeItem extends FASTElement {
|
|
3
|
+
/**
|
|
4
|
+
* The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
elementInternals: ElementInternals;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* When true, the control will be appear expanded by user interaction.
|
|
12
|
+
* @public
|
|
13
|
+
* HTML Attribute: `expanded`
|
|
14
|
+
*/
|
|
15
|
+
expanded: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Handles changes to the expanded attribute
|
|
18
|
+
* @param prev - the previous state
|
|
19
|
+
* @param next - the next state
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
expandedChanged(prev: boolean, next: boolean): void;
|
|
24
|
+
/**
|
|
25
|
+
* When true, the control will appear selected by user interaction.
|
|
26
|
+
* @public
|
|
27
|
+
* @remarks
|
|
28
|
+
* HTML Attribute: selected
|
|
29
|
+
*/
|
|
30
|
+
selected: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Handles changes to the selected attribute
|
|
33
|
+
* @param prev - the previous state
|
|
34
|
+
* @param next - the next state
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
protected selectedChanged(prev: boolean, next: boolean): void;
|
|
39
|
+
/**
|
|
40
|
+
* When true, the control has no child tree items
|
|
41
|
+
* @public
|
|
42
|
+
* HTML Attribute: empty
|
|
43
|
+
*/
|
|
44
|
+
empty: boolean;
|
|
45
|
+
private styles;
|
|
46
|
+
/**
|
|
47
|
+
* The indent of the tree item element.
|
|
48
|
+
* This is not needed once css attr() is supported (--indent: attr(data-indent type(<number>)));
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
dataIndent: number | undefined;
|
|
52
|
+
private dataIndentChanged;
|
|
53
|
+
childTreeItems: BaseTreeItem[] | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Handles changes to the child tree items
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
childTreeItemsChanged(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Updates the childrens indent
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
updateChildTreeItems(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the indent for each item
|
|
68
|
+
*/
|
|
69
|
+
private setIndent;
|
|
70
|
+
/**
|
|
71
|
+
* Handle focus events
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
focusHandler(e: FocusEvent): void;
|
|
76
|
+
/**
|
|
77
|
+
* Handle blur events
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
blurHandler(e: FocusEvent): void;
|
|
82
|
+
/**
|
|
83
|
+
* Toggle the expansion state of the tree item
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
toggleExpansion(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Toggle the single selection state of the tree item
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
toggleSelection(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Whether the tree is nested
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
get isNestedItem(): boolean;
|
|
99
|
+
}
|
|
@@ -1,48 +1,6 @@
|
|
|
1
|
-
import { FASTElement } from '@microsoft/fast-element';
|
|
2
1
|
import { TreeItemAppearance, TreeItemSize } from './tree-item.options.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
elementInternals: ElementInternals;
|
|
10
|
-
constructor();
|
|
11
|
-
/**
|
|
12
|
-
* When true, the control will be appear expanded by user interaction.
|
|
13
|
-
* @public
|
|
14
|
-
* HTML Attribute: `expanded`
|
|
15
|
-
*/
|
|
16
|
-
expanded: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Handles changes to the expanded attribute
|
|
19
|
-
* @param prev - the previous state
|
|
20
|
-
* @param next - the next state
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
expandedChanged(prev: boolean, next: boolean): void;
|
|
25
|
-
/**
|
|
26
|
-
* When true, the control will appear selected by user interaction.
|
|
27
|
-
* @public
|
|
28
|
-
* @remarks
|
|
29
|
-
* HTML Attribute: selected
|
|
30
|
-
*/
|
|
31
|
-
selected: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Handles changes to the selected attribute
|
|
34
|
-
* @param prev - the previous state
|
|
35
|
-
* @param next - the next state
|
|
36
|
-
*
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
protected selectedChanged(prev: boolean, next: boolean): void;
|
|
40
|
-
/**
|
|
41
|
-
* When true, the control has no child tree items
|
|
42
|
-
* @public
|
|
43
|
-
* HTML Attribute: empty
|
|
44
|
-
*/
|
|
45
|
-
empty: boolean;
|
|
2
|
+
import { BaseTreeItem } from './tree-item.base';
|
|
3
|
+
export declare class TreeItem extends BaseTreeItem {
|
|
46
4
|
/**
|
|
47
5
|
* The size of the tree item element
|
|
48
6
|
* @public
|
|
@@ -65,57 +23,16 @@ export declare class TreeItem extends FASTElement {
|
|
|
65
23
|
* @internal
|
|
66
24
|
*/
|
|
67
25
|
private appearanceChanged;
|
|
68
|
-
private styles;
|
|
69
|
-
/**
|
|
70
|
-
* The indent of the tree item element.
|
|
71
|
-
* This is not needed once css attr() is supported (--indent: attr(data-indent type(<number>)));
|
|
72
|
-
* @public
|
|
73
|
-
*/
|
|
74
|
-
dataIndent: number | undefined;
|
|
75
|
-
private dataIndentChanged;
|
|
76
|
-
childTreeItems: TreeItem[] | undefined;
|
|
77
26
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
27
|
+
* child tree items supered change event
|
|
80
28
|
* @internal
|
|
81
29
|
*/
|
|
82
|
-
|
|
30
|
+
childTreeItemsChanged(): void;
|
|
83
31
|
/**
|
|
84
32
|
* 1. Update the child items' size based on the tree's size
|
|
85
33
|
* 2. Update the child items' appearance based on the tree's appearance
|
|
86
|
-
*/
|
|
87
|
-
private updateChildTreeItems;
|
|
88
|
-
/**
|
|
89
|
-
* Sets the indent for each item
|
|
90
|
-
*/
|
|
91
|
-
private setIndent;
|
|
92
|
-
/**
|
|
93
|
-
* Handle focus events
|
|
94
|
-
*
|
|
95
|
-
* @public
|
|
96
|
-
*/
|
|
97
|
-
focusHandler(e: FocusEvent): void;
|
|
98
|
-
/**
|
|
99
|
-
* Handle blur events
|
|
100
34
|
*
|
|
101
35
|
* @public
|
|
102
36
|
*/
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Toggle the expansion state of the tree item
|
|
106
|
-
*
|
|
107
|
-
* @public
|
|
108
|
-
*/
|
|
109
|
-
toggleExpansion(): void;
|
|
110
|
-
/**
|
|
111
|
-
* Toggle the single selection state of the tree item
|
|
112
|
-
*
|
|
113
|
-
* @public
|
|
114
|
-
*/
|
|
115
|
-
toggleSelection(): void;
|
|
116
|
-
/**
|
|
117
|
-
* Whether the tree is nested
|
|
118
|
-
* @internal
|
|
119
|
-
*/
|
|
120
|
-
get isNestedItem(): boolean;
|
|
37
|
+
updateSizeAndAppearance(): void;
|
|
121
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValuesOf } from '../utils/typings.js';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseTreeItem } from './tree-item.base.js';
|
|
3
3
|
export declare const TreeItemAppearance: {
|
|
4
4
|
readonly subtle: "subtle";
|
|
5
5
|
readonly subtleAlpha: "subtle-alpha";
|
|
@@ -19,4 +19,4 @@ export type TreeItemSize = ValuesOf<typeof TreeItemSize>;
|
|
|
19
19
|
* @returns true if the element is a dropdown.
|
|
20
20
|
* @public
|
|
21
21
|
*/
|
|
22
|
-
export declare function isTreeItem(element?: Node | null, tagName?: string): element is
|
|
22
|
+
export declare function isTreeItem(element?: Node | null, tagName?: string): element is BaseTreeItem;
|
package/dist/esm/tree/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tree/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tree/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { FASTElement, observable } from '@microsoft/fast-element';
|
|
3
|
+
import { isHTMLElement, keyArrowDown, keyArrowLeft, keyArrowRight, keyArrowUp, keyEnd, keyEnter, keyHome, keySpace, } from '@microsoft/fast-web-utilities';
|
|
4
|
+
import { isTreeItem } from '../tree-item/tree-item.options';
|
|
5
|
+
export class BaseTree extends FASTElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
/**
|
|
9
|
+
* The currently selected tree item
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
this.currentSelected = null;
|
|
13
|
+
/**
|
|
14
|
+
* The tree item that is designated to be in the tab queue.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
this.currentFocused = null;
|
|
19
|
+
/**
|
|
20
|
+
* The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
this.elementInternals = this.attachInternals();
|
|
25
|
+
this.childTreeItems = [];
|
|
26
|
+
this.elementInternals.role = 'tree';
|
|
27
|
+
}
|
|
28
|
+
childTreeItemsChanged() {
|
|
29
|
+
this.updateCurrentSelected();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Updates current selected when slottedTreeItems changes
|
|
33
|
+
*/
|
|
34
|
+
updateCurrentSelected() {
|
|
35
|
+
// force single selection
|
|
36
|
+
// defaults to first one found
|
|
37
|
+
const selectedItem = this.querySelector(`[aria-selected='true']`);
|
|
38
|
+
this.currentSelected = selectedItem;
|
|
39
|
+
// invalidate the current focused item if it is no longer valid
|
|
40
|
+
if (this.currentFocused === null || !this.contains(this.currentFocused)) {
|
|
41
|
+
this.currentFocused = this.getValidFocusableItem();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* KeyDown handler
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
keydownHandler(e) {
|
|
50
|
+
if (e.defaultPrevented) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const item = e.target;
|
|
54
|
+
if (!isTreeItem(item) || this.childTreeItems.length < 1) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
const elements = this.getVisibleNodes();
|
|
58
|
+
switch (e.key) {
|
|
59
|
+
case keyHome: {
|
|
60
|
+
if (elements.length) {
|
|
61
|
+
elements[0].focus();
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
case keyEnd: {
|
|
66
|
+
if (elements.length) {
|
|
67
|
+
elements[elements.length - 1].focus();
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
case keyArrowLeft: {
|
|
72
|
+
if (item?.childTreeItems?.length && item.expanded) {
|
|
73
|
+
item.expanded = false;
|
|
74
|
+
}
|
|
75
|
+
else if (isTreeItem(item.parentElement)) {
|
|
76
|
+
item.parentElement.focus();
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
case keyArrowRight: {
|
|
81
|
+
if (item?.childTreeItems?.length) {
|
|
82
|
+
if (!item.expanded) {
|
|
83
|
+
item.expanded = true;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.focusNextNode(1, item);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
case keyArrowDown: {
|
|
92
|
+
this.focusNextNode(1, item);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
case keyArrowUp: {
|
|
96
|
+
this.focusNextNode(-1, item);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
case keyEnter: {
|
|
100
|
+
// In single-select trees where selection does not follow focus (see note below),
|
|
101
|
+
// the default action is typically to select the focused node.
|
|
102
|
+
this.clickHandler(e);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
case keySpace: {
|
|
106
|
+
item.toggleSelection();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// don't prevent default if we took no action
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Handle focus events
|
|
115
|
+
*
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
focusHandler(e) {
|
|
119
|
+
if (this.childTreeItems.length < 1) {
|
|
120
|
+
// no child items, nothing to do
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (e.target === this) {
|
|
124
|
+
if (this.currentFocused === null) {
|
|
125
|
+
this.currentFocused = this.getValidFocusableItem();
|
|
126
|
+
}
|
|
127
|
+
if (this.currentFocused !== null) {
|
|
128
|
+
this.currentFocused.focus();
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (this.contains(e.target)) {
|
|
133
|
+
this.setAttribute('tabindex', '-1');
|
|
134
|
+
this.currentFocused = e.target;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Handle blur events
|
|
139
|
+
*
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
blurHandler(e) {
|
|
143
|
+
if (e.target instanceof HTMLElement && (e.relatedTarget === null || !this.contains(e.relatedTarget))) {
|
|
144
|
+
this.setAttribute('tabindex', '0');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Handles click events bubbling up
|
|
149
|
+
*
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
clickHandler(e) {
|
|
153
|
+
if (e.defaultPrevented) {
|
|
154
|
+
// handled, do nothing
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!isTreeItem(e.target)) {
|
|
158
|
+
// not a tree item, ignore
|
|
159
|
+
// return true, do not prevent default
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
const item = e.target;
|
|
163
|
+
item.toggleExpansion();
|
|
164
|
+
item.toggleSelection();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Handles the selected-changed events bubbling up
|
|
168
|
+
* from child tree items
|
|
169
|
+
*
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
changeHandler(e) {
|
|
173
|
+
if (e.defaultPrevented) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!isTreeItem(e.target)) {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
const item = e.target;
|
|
180
|
+
if (item.selected) {
|
|
181
|
+
// Deselect the prevously selected item
|
|
182
|
+
if (this.currentSelected && this.currentSelected !== item && isTreeItem(this.currentSelected)) {
|
|
183
|
+
this.currentSelected.selected = false;
|
|
184
|
+
}
|
|
185
|
+
// New selected item
|
|
186
|
+
this.currentSelected = item;
|
|
187
|
+
}
|
|
188
|
+
else if (!item.selected && this.currentSelected === item) {
|
|
189
|
+
// Selected item deselected
|
|
190
|
+
this.currentSelected = null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* checks if there are any nested tree items
|
|
195
|
+
*/
|
|
196
|
+
getValidFocusableItem() {
|
|
197
|
+
const elements = this.getVisibleNodes();
|
|
198
|
+
// default to selected element if there is one
|
|
199
|
+
let focusIndex = elements.findIndex(el => el.selected);
|
|
200
|
+
if (focusIndex === -1) {
|
|
201
|
+
// otherwise first focusable tree item
|
|
202
|
+
focusIndex = elements.findIndex(el => isTreeItem(el));
|
|
203
|
+
}
|
|
204
|
+
if (focusIndex !== -1) {
|
|
205
|
+
return elements[focusIndex];
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
getVisibleNodes() {
|
|
210
|
+
return Array.from(this.querySelectorAll('*')).filter(node => isTreeItem(node) && node.offsetParent !== null);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Move focus to a tree item based on its offset from the provided item
|
|
214
|
+
*/
|
|
215
|
+
focusNextNode(delta, item) {
|
|
216
|
+
const visibleNodes = this.getVisibleNodes();
|
|
217
|
+
if (!visibleNodes.length) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const focusItem = visibleNodes[visibleNodes.indexOf(item) + delta];
|
|
221
|
+
if (isHTMLElement(focusItem)) {
|
|
222
|
+
focusItem.focus();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
__decorate([
|
|
227
|
+
observable
|
|
228
|
+
], BaseTree.prototype, "currentSelected", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
observable
|
|
231
|
+
], BaseTree.prototype, "childTreeItems", void 0);
|
|
232
|
+
//# sourceMappingURL=tree.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.base.js","sourceRoot":"","sources":["../../../src/tree/tree.base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,UAAU,E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