@spectrum-web-components/sidenav 0.12.13 → 0.12.15-devmode.7
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/package.json +41 -14
- package/sp-sidenav-heading.dev.js +3 -0
- package/sp-sidenav-heading.dev.js.map +7 -0
- package/sp-sidenav-heading.js +3 -14
- package/sp-sidenav-heading.js.map +7 -1
- package/sp-sidenav-item.dev.js +3 -0
- package/sp-sidenav-item.dev.js.map +7 -0
- package/sp-sidenav-item.js +3 -14
- package/sp-sidenav-item.js.map +7 -1
- package/sp-sidenav.dev.js +3 -0
- package/sp-sidenav.dev.js.map +7 -0
- package/sp-sidenav.js +3 -14
- package/sp-sidenav.js.map +7 -1
- package/src/Sidenav.d.ts +1 -1
- package/src/Sidenav.dev.js +139 -0
- package/src/Sidenav.dev.js.map +7 -0
- package/src/Sidenav.js +120 -135
- package/src/Sidenav.js.map +7 -1
- package/src/SidenavHeading.dev.js +45 -0
- package/src/SidenavHeading.dev.js.map +7 -0
- package/src/SidenavHeading.js +37 -40
- package/src/SidenavHeading.js.map +7 -1
- package/src/SidenavItem.dev.js +147 -0
- package/src/SidenavItem.dev.js.map +7 -0
- package/src/SidenavItem.js +133 -140
- package/src/SidenavItem.js.map +7 -1
- package/src/index.dev.js +4 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +4 -15
- package/src/index.js.map +7 -1
- package/src/sidenav-heading.css.dev.js +30 -0
- package/src/sidenav-heading.css.dev.js.map +7 -0
- package/src/sidenav-heading.css.js +3 -14
- package/src/sidenav-heading.css.js.map +7 -1
- package/src/sidenav-item.css.dev.js +114 -0
- package/src/sidenav-item.css.dev.js.map +7 -0
- package/src/sidenav-item.css.js +3 -14
- package/src/sidenav-item.css.js.map +7 -1
- package/src/sidenav.css.dev.js +12 -0
- package/src/sidenav.css.dev.js.map +7 -0
- package/src/sidenav.css.js +3 -14
- package/src/sidenav.css.js.map +7 -1
- package/src/spectrum-sidenav-heading.css.dev.js +30 -0
- package/src/spectrum-sidenav-heading.css.dev.js.map +7 -0
- package/src/spectrum-sidenav-heading.css.js +3 -14
- package/src/spectrum-sidenav-heading.css.js.map +7 -1
- package/src/spectrum-sidenav-item.css.dev.js +86 -0
- package/src/spectrum-sidenav-item.css.dev.js.map +7 -0
- package/src/spectrum-sidenav-item.css.js +3 -14
- package/src/spectrum-sidenav-item.css.js.map +7 -1
- package/src/spectrum-sidenav.css.dev.js +8 -0
- package/src/spectrum-sidenav.css.dev.js.map +7 -0
- package/src/spectrum-sidenav.css.js +3 -14
- package/src/spectrum-sidenav.css.js.map +7 -1
- package/stories/sidenav.stories.js +25 -32
- package/stories/sidenav.stories.js.map +7 -1
- package/test/benchmark/test-basic.js +7 -18
- package/test/benchmark/test-basic.js.map +7 -1
- package/test/sidenav-item.test.js +49 -62
- package/test/sidenav-item.test.js.map +7 -1
- package/test/sidenav.test-vrt.js +4 -15
- package/test/sidenav.test-vrt.js.map +7 -1
- package/test/sidenav.test.js +266 -267
- package/test/sidenav.test.js.map +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/sidenav",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.15-devmode.7+8303f3a2a",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,15 +20,42 @@
|
|
|
20
20
|
"module": "./src/index.js",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
|
-
".":
|
|
24
|
-
|
|
23
|
+
".": {
|
|
24
|
+
"development": "./src/index.dev.js",
|
|
25
|
+
"default": "./src/index.js"
|
|
26
|
+
},
|
|
25
27
|
"./package.json": "./package.json",
|
|
26
|
-
"./
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"./
|
|
31
|
-
|
|
28
|
+
"./src/Sidenav.js": {
|
|
29
|
+
"development": "./src/Sidenav.dev.js",
|
|
30
|
+
"default": "./src/Sidenav.js"
|
|
31
|
+
},
|
|
32
|
+
"./src/SidenavHeading.js": {
|
|
33
|
+
"development": "./src/SidenavHeading.dev.js",
|
|
34
|
+
"default": "./src/SidenavHeading.js"
|
|
35
|
+
},
|
|
36
|
+
"./src/SidenavItem.js": {
|
|
37
|
+
"development": "./src/SidenavItem.dev.js",
|
|
38
|
+
"default": "./src/SidenavItem.js"
|
|
39
|
+
},
|
|
40
|
+
"./src/index.js": {
|
|
41
|
+
"development": "./src/index.dev.js",
|
|
42
|
+
"default": "./src/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./src/sidenav-heading.css.js": "./src/sidenav-heading.css.js",
|
|
45
|
+
"./src/sidenav-item.css.js": "./src/sidenav-item.css.js",
|
|
46
|
+
"./src/sidenav.css.js": "./src/sidenav.css.js",
|
|
47
|
+
"./sp-sidenav.js": {
|
|
48
|
+
"development": "./sp-sidenav.dev.js",
|
|
49
|
+
"default": "./sp-sidenav.js"
|
|
50
|
+
},
|
|
51
|
+
"./sp-sidenav-heading.js": {
|
|
52
|
+
"development": "./sp-sidenav-heading.dev.js",
|
|
53
|
+
"default": "./sp-sidenav-heading.js"
|
|
54
|
+
},
|
|
55
|
+
"./sp-sidenav-item.js": {
|
|
56
|
+
"development": "./sp-sidenav-item.dev.js",
|
|
57
|
+
"default": "./sp-sidenav-item.js"
|
|
58
|
+
}
|
|
32
59
|
},
|
|
33
60
|
"scripts": {
|
|
34
61
|
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
|
|
@@ -48,18 +75,18 @@
|
|
|
48
75
|
"lit-html"
|
|
49
76
|
],
|
|
50
77
|
"dependencies": {
|
|
51
|
-
"@spectrum-web-components/base": "^0.5.
|
|
52
|
-
"@spectrum-web-components/reactive-controllers": "^0.2.
|
|
53
|
-
"@spectrum-web-components/shared": "^0.14.
|
|
78
|
+
"@spectrum-web-components/base": "^0.5.9-devmode.31+8303f3a2a",
|
|
79
|
+
"@spectrum-web-components/reactive-controllers": "^0.2.5-devmode.86+8303f3a2a",
|
|
80
|
+
"@spectrum-web-components/shared": "^0.14.5-devmode.7+8303f3a2a",
|
|
54
81
|
"tslib": "^2.0.0"
|
|
55
82
|
},
|
|
56
83
|
"devDependencies": {
|
|
57
|
-
"@spectrum-css/sidenav": "^3.0.
|
|
84
|
+
"@spectrum-css/sidenav": "^3.0.24"
|
|
58
85
|
},
|
|
59
86
|
"types": "./src/index.d.ts",
|
|
60
87
|
"customElements": "custom-elements.json",
|
|
61
88
|
"sideEffects": [
|
|
62
89
|
"./sp-*.js"
|
|
63
90
|
],
|
|
64
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "8303f3a2a90b0aedc15158797662ccfa8f4a2031"
|
|
65
92
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-sidenav-heading.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { SideNavHeading } from './src/SidenavHeading.dev.js'\n\ncustomElements.define('sp-sidenav-heading', SideNavHeading);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-sidenav-heading': SideNavHeading;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,eAAe,OAAO,sBAAsB,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/sp-sidenav-heading.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { SideNavHeading } from './src/SidenavHeading.js';
|
|
13
|
-
customElements.define('sp-sidenav-heading', SideNavHeading);
|
|
14
|
-
//# sourceMappingURL=sp-sidenav-heading.js.map
|
|
1
|
+
import { SideNavHeading } from "./src/SidenavHeading.js";
|
|
2
|
+
customElements.define("sp-sidenav-heading", SideNavHeading);
|
|
3
|
+
//# sourceMappingURL=sp-sidenav-heading.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-sidenav-heading.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { SideNavHeading } from './src/SidenavHeading.js';\n\ncustomElements.define('sp-sidenav-heading', SideNavHeading);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-sidenav-heading': SideNavHeading;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,eAAe,OAAO,sBAAsB,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-sidenav-item.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { SideNavItem } from './src/SidenavItem.dev.js'\n\ncustomElements.define('sp-sidenav-item', SideNavItem);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-sidenav-item': SideNavItem;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,eAAe,OAAO,mBAAmB,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/sp-sidenav-item.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { SideNavItem } from './src/SidenavItem.js';
|
|
13
|
-
customElements.define('sp-sidenav-item', SideNavItem);
|
|
14
|
-
//# sourceMappingURL=sp-sidenav-item.js.map
|
|
1
|
+
import { SideNavItem } from "./src/SidenavItem.js";
|
|
2
|
+
customElements.define("sp-sidenav-item", SideNavItem);
|
|
3
|
+
//# sourceMappingURL=sp-sidenav-item.js.map
|
package/sp-sidenav-item.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-sidenav-item.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { SideNavItem } from './src/SidenavItem.js';\n\ncustomElements.define('sp-sidenav-item', SideNavItem);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-sidenav-item': SideNavItem;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,eAAe,OAAO,mBAAmB,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-sidenav.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { SideNav } from './src/Sidenav.dev.js'\n\ncustomElements.define('sp-sidenav', SideNav);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-sidenav': SideNav;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,eAAe,OAAO,cAAc,OAAO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/sp-sidenav.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { SideNav } from './src/Sidenav.js';
|
|
13
|
-
customElements.define('sp-sidenav', SideNav);
|
|
14
|
-
//# sourceMappingURL=sp-sidenav.js.map
|
|
1
|
+
import { SideNav } from "./src/Sidenav.js";
|
|
2
|
+
customElements.define("sp-sidenav", SideNav);
|
|
3
|
+
//# sourceMappingURL=sp-sidenav.js.map
|
package/sp-sidenav.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-sidenav.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { SideNav } from './src/Sidenav.js';\n\ncustomElements.define('sp-sidenav', SideNav);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-sidenav': SideNav;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,eAAe,OAAO,cAAc,OAAO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/Sidenav.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class SideNav extends Focusable {
|
|
|
28
28
|
private isDisabledChild;
|
|
29
29
|
private handleSlotchange;
|
|
30
30
|
protected render(): TemplateResult;
|
|
31
|
-
protected
|
|
31
|
+
protected willUpdate(): void;
|
|
32
32
|
protected updated(changes: PropertyValues): void;
|
|
33
33
|
}
|
|
34
34
|
declare global {
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
html
|
|
14
|
+
} from "@spectrum-web-components/base";
|
|
15
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
16
|
+
import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
|
|
17
|
+
import sidenavStyles from "./sidenav.css.js";
|
|
18
|
+
import { Focusable } from "@spectrum-web-components/shared";
|
|
19
|
+
import { SideNavItem } from "./SidenavItem.dev.js";
|
|
20
|
+
import { SideNavHeading } from "./SidenavHeading.dev.js";
|
|
21
|
+
export class SideNav extends Focusable {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.items = /* @__PURE__ */ new Set();
|
|
25
|
+
this.rovingTabindexController = new RovingTabindexController(this, {
|
|
26
|
+
focusInIndex: (elements) => {
|
|
27
|
+
return elements.findIndex((el) => {
|
|
28
|
+
return this.value ? !el.disabled && !this.isDisabledChild(el) && el.value === this.value : !el.disabled && !this.isDisabledChild(el);
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
direction: "vertical",
|
|
32
|
+
elements: () => [...this.querySelectorAll("sp-sidenav-item")],
|
|
33
|
+
isFocusableElement: (el) => !el.disabled && !this.isDisabledChild(el)
|
|
34
|
+
});
|
|
35
|
+
this.manageTabIndex = false;
|
|
36
|
+
this.value = void 0;
|
|
37
|
+
}
|
|
38
|
+
static get styles() {
|
|
39
|
+
return [sidenavStyles];
|
|
40
|
+
}
|
|
41
|
+
startTrackingSelectionForItem(item) {
|
|
42
|
+
this.items.add(item);
|
|
43
|
+
this.rovingTabindexController.clearElementCache();
|
|
44
|
+
}
|
|
45
|
+
stopTrackingSelectionForItem(item) {
|
|
46
|
+
this.items.delete(item);
|
|
47
|
+
this.rovingTabindexController.clearElementCache();
|
|
48
|
+
}
|
|
49
|
+
handleSelect(event) {
|
|
50
|
+
event.stopPropagation();
|
|
51
|
+
if (this.value === event.detail.value) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const oldValue = this.value;
|
|
55
|
+
this.value = event.detail.value;
|
|
56
|
+
const applyDefault = this.dispatchEvent(new Event("change", {
|
|
57
|
+
bubbles: true,
|
|
58
|
+
composed: true,
|
|
59
|
+
cancelable: true
|
|
60
|
+
}));
|
|
61
|
+
if (!applyDefault) {
|
|
62
|
+
this.value = oldValue;
|
|
63
|
+
event.target.selected = false;
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
} else {
|
|
66
|
+
this.items.forEach((item) => item.handleSideNavSelect(event));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
focus() {
|
|
70
|
+
this.rovingTabindexController.focus();
|
|
71
|
+
}
|
|
72
|
+
blur() {
|
|
73
|
+
if (this.focusElement === this) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
super.blur();
|
|
77
|
+
}
|
|
78
|
+
click() {
|
|
79
|
+
if (this.focusElement === this) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
super.click();
|
|
83
|
+
}
|
|
84
|
+
get focusElement() {
|
|
85
|
+
return this.rovingTabindexController.focusInElement || this;
|
|
86
|
+
}
|
|
87
|
+
isDisabledChild(child) {
|
|
88
|
+
if (child.disabled) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
let parent = child.parentElement;
|
|
92
|
+
while (parent instanceof SideNavHeading || !parent.disabled && parent instanceof SideNavItem && parent.expanded) {
|
|
93
|
+
parent = parent.parentElement;
|
|
94
|
+
}
|
|
95
|
+
return parent !== this;
|
|
96
|
+
}
|
|
97
|
+
handleSlotchange() {
|
|
98
|
+
if (this.manageTabIndex) {
|
|
99
|
+
this.rovingTabindexController.manage();
|
|
100
|
+
} else {
|
|
101
|
+
this.rovingTabindexController.unmanage();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
render() {
|
|
105
|
+
return html`
|
|
106
|
+
<nav @sidenav-select=${this.handleSelect}>
|
|
107
|
+
<slot
|
|
108
|
+
name="descendant"
|
|
109
|
+
@slotchange=${this.handleSlotchange}
|
|
110
|
+
></slot>
|
|
111
|
+
</nav>
|
|
112
|
+
`;
|
|
113
|
+
}
|
|
114
|
+
willUpdate() {
|
|
115
|
+
if (!this.hasUpdated) {
|
|
116
|
+
const selectedChild = this.querySelector("[selected]");
|
|
117
|
+
if (selectedChild) {
|
|
118
|
+
this.value = selectedChild.value;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
updated(changes) {
|
|
123
|
+
super.updated(changes);
|
|
124
|
+
if (changes.has("manageTabIndex")) {
|
|
125
|
+
if (this.manageTabIndex) {
|
|
126
|
+
this.rovingTabindexController.manage();
|
|
127
|
+
} else {
|
|
128
|
+
this.rovingTabindexController.unmanage();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
__decorateClass([
|
|
134
|
+
property({ type: Boolean, reflect: true, attribute: "manage-tab-index" })
|
|
135
|
+
], SideNav.prototype, "manageTabIndex", 2);
|
|
136
|
+
__decorateClass([
|
|
137
|
+
property({ reflect: true })
|
|
138
|
+
], SideNav.prototype, "value", 2);
|
|
139
|
+
//# sourceMappingURL=Sidenav.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["Sidenav.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\n\nimport sidenavStyles from './sidenav.css.js';\nimport { Focusable } from '@spectrum-web-components/shared';\nimport { SideNavItem } from './SidenavItem.dev.js'\nimport { SideNavHeading } from './SidenavHeading.dev.js'\n\nexport interface SidenavSelectDetail {\n value: string;\n}\n\n/**\n * @element sp-sidenav\n *\n * @slot - the Sidenav Items to display\n * @fires change - Announces a change in the `value` property of the navigation element.\n * This change can be \"canceled\" via `event.preventDefault()`.\n */\nexport class SideNav extends Focusable {\n public static override get styles(): CSSResultArray {\n return [sidenavStyles];\n }\n\n private items = new Set<SideNavItem>();\n\n public startTrackingSelectionForItem(item: SideNavItem): void {\n this.items.add(item);\n this.rovingTabindexController.clearElementCache();\n }\n\n public stopTrackingSelectionForItem(item: SideNavItem): void {\n this.items.delete(item);\n this.rovingTabindexController.clearElementCache();\n }\n\n rovingTabindexController = new RovingTabindexController<SideNavItem>(this, {\n focusInIndex: (elements: SideNavItem[]) => {\n return elements.findIndex((el) => {\n return this.value\n ? !el.disabled &&\n !this.isDisabledChild(el) &&\n el.value === this.value\n : !el.disabled && !this.isDisabledChild(el);\n });\n },\n direction: 'vertical',\n elements: () => [...this.querySelectorAll('sp-sidenav-item')],\n isFocusableElement: (el: SideNavItem) =>\n !el.disabled && !this.isDisabledChild(el),\n });\n\n @property({ type: Boolean, reflect: true, attribute: 'manage-tab-index' })\n public manageTabIndex = false;\n\n @property({ reflect: true })\n public value: string | undefined = undefined;\n\n private handleSelect(\n event: CustomEvent<SidenavSelectDetail> & { target: SideNavItem }\n ): void {\n event.stopPropagation();\n if (this.value === event.detail.value) {\n return;\n }\n const oldValue = this.value;\n this.value = event.detail.value;\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.value = oldValue;\n event.target.selected = false;\n event.preventDefault();\n } else {\n this.items.forEach((item) => item.handleSideNavSelect(event));\n }\n }\n\n public override focus(): void {\n this.rovingTabindexController.focus();\n }\n\n public override blur(): void {\n if (this.focusElement === this) {\n return;\n }\n\n super.blur();\n }\n\n public override click(): void {\n if (this.focusElement === this) {\n return;\n }\n\n super.click();\n }\n\n public override get focusElement(): SideNavItem | SideNav {\n return this.rovingTabindexController.focusInElement || this;\n }\n\n private isDisabledChild(child: SideNavItem): boolean {\n if (child.disabled) {\n return true;\n }\n let parent = child.parentElement as\n | SideNavItem\n | SideNav\n | SideNavHeading;\n while (\n parent instanceof SideNavHeading ||\n (!(parent as SideNavItem).disabled &&\n parent instanceof SideNavItem &&\n parent.expanded)\n ) {\n parent = parent.parentElement as\n | SideNavItem\n | SideNav\n | SideNavHeading;\n }\n return parent !== this;\n }\n\n private handleSlotchange(): void {\n if (this.manageTabIndex) {\n this.rovingTabindexController.manage();\n } else {\n this.rovingTabindexController.unmanage();\n }\n }\n\n protected override render(): TemplateResult {\n return html`\n <nav @sidenav-select=${this.handleSelect}>\n <slot\n name=\"descendant\"\n @slotchange=${this.handleSlotchange}\n ></slot>\n </nav>\n `;\n }\n\n protected override willUpdate(): void {\n if (!this.hasUpdated) {\n const selectedChild = this.querySelector(\n '[selected]'\n ) as SideNavItem;\n if (selectedChild) {\n this.value = selectedChild.value;\n }\n }\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('manageTabIndex')) {\n if (this.manageTabIndex) {\n this.rovingTabindexController.manage();\n } else {\n this.rovingTabindexController.unmanage();\n }\n }\n }\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'sp-sidenav:select': CustomEvent<SidenavSelectDetail>;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAMA;AACA;AAEA;AACA;AACA;AACA;AAaO,aAAM,gBAAgB,UAAU;AAAA,EAAhC;AAAA;AAKK,iBAAQ,oBAAI,IAAiB;AAYrC,oCAA2B,IAAI,yBAAsC,MAAM;AAAA,MACvE,cAAc,CAAC,aAA4B;AACvC,eAAO,SAAS,UAAU,CAAC,OAAO;AAC9B,iBAAO,KAAK,QACN,CAAC,GAAG,YACA,CAAC,KAAK,gBAAgB,EAAE,KACxB,GAAG,UAAU,KAAK,QACtB,CAAC,GAAG,YAAY,CAAC,KAAK,gBAAgB,EAAE;AAAA,QAClD,CAAC;AAAA,MACL;AAAA,MACA,WAAW;AAAA,MACX,UAAU,MAAM,CAAC,GAAG,KAAK,iBAAiB,iBAAiB,CAAC;AAAA,MAC5D,oBAAoB,CAAC,OACjB,CAAC,GAAG,YAAY,CAAC,KAAK,gBAAgB,EAAE;AAAA,IAChD,CAAC;AAGM,0BAAiB;AAGjB,iBAA4B;AAAA;AAAA,aApCR,SAAyB;AAChD,WAAO,CAAC,aAAa;AAAA,EACzB;AAAA,EAIO,8BAA8B,MAAyB;AAC1D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