@aquera/nile-elements 1.6.7 → 1.6.9
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/README.md +12 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1735 -495
- package/dist/internal/enum.cjs.js +1 -1
- package/dist/internal/enum.cjs.js.map +1 -1
- package/dist/internal/enum.esm.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.css.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.css.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.css.esm.js +0 -3
- package/dist/nile-calendar/nile-calendar.esm.js +2 -2
- package/dist/nile-dropdown/nile-dropdown.cjs.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.cjs.js.map +1 -1
- package/dist/nile-dropdown/nile-dropdown.esm.js +1 -1
- package/dist/nile-inline-sidebar/index.cjs.js +1 -1
- package/dist/nile-inline-sidebar/index.esm.js +1 -1
- package/dist/nile-inline-sidebar/nile-inline-sidebar.cjs.js +1 -1
- package/dist/nile-inline-sidebar/nile-inline-sidebar.cjs.js.map +1 -1
- package/dist/nile-inline-sidebar/nile-inline-sidebar.css.cjs.js +1 -1
- package/dist/nile-inline-sidebar/nile-inline-sidebar.css.cjs.js.map +1 -1
- package/dist/nile-inline-sidebar/nile-inline-sidebar.css.esm.js +76 -19
- package/dist/nile-inline-sidebar/nile-inline-sidebar.esm.js +42 -23
- package/dist/nile-inline-sidebar-group/nile-inline-sidebar-group.css.cjs.js +1 -1
- package/dist/nile-inline-sidebar-group/nile-inline-sidebar-group.css.cjs.js.map +1 -1
- package/dist/nile-inline-sidebar-group/nile-inline-sidebar-group.css.esm.js +8 -9
- package/dist/nile-inline-sidebar-item/index.cjs.js +1 -1
- package/dist/nile-inline-sidebar-item/index.esm.js +1 -1
- package/dist/nile-inline-sidebar-item/nile-inline-sidebar-item.cjs.js +1 -1
- package/dist/nile-inline-sidebar-item/nile-inline-sidebar-item.cjs.js.map +1 -1
- package/dist/nile-inline-sidebar-item/nile-inline-sidebar-item.css.cjs.js +1 -1
- package/dist/nile-inline-sidebar-item/nile-inline-sidebar-item.css.cjs.js.map +1 -1
- package/dist/nile-inline-sidebar-item/nile-inline-sidebar-item.css.esm.js +16 -18
- package/dist/nile-inline-sidebar-item/nile-inline-sidebar-item.esm.js +22 -4
- package/dist/nile-inline-sidebar-item-body/index.cjs.js +2 -0
- package/dist/nile-inline-sidebar-item-body/index.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-item-body/index.esm.js +1 -0
- package/dist/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.cjs.js +2 -0
- package/dist/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.css.cjs.js +2 -0
- package/dist/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.css.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.css.esm.js +53 -0
- package/dist/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.esm.js +13 -0
- package/dist/nile-inline-sidebar-item-header/index.cjs.js +2 -0
- package/dist/nile-inline-sidebar-item-header/index.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-item-header/index.esm.js +1 -0
- package/dist/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.cjs.js +2 -0
- package/dist/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.css.cjs.js +2 -0
- package/dist/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.css.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.css.esm.js +27 -0
- package/dist/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.esm.js +16 -0
- package/dist/nile-inline-sidebar-panel/index.cjs.js +2 -0
- package/dist/nile-inline-sidebar-panel/index.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-panel/index.esm.js +1 -0
- package/dist/nile-inline-sidebar-panel/nile-inline-sidebar-panel.cjs.js +2 -0
- package/dist/nile-inline-sidebar-panel/nile-inline-sidebar-panel.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-panel/nile-inline-sidebar-panel.css.cjs.js +2 -0
- package/dist/nile-inline-sidebar-panel/nile-inline-sidebar-panel.css.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-panel/nile-inline-sidebar-panel.css.esm.js +19 -0
- package/dist/nile-inline-sidebar-panel/nile-inline-sidebar-panel.esm.js +5 -0
- package/dist/nile-inline-sidebar-panel-group/index.cjs.js +2 -0
- package/dist/nile-inline-sidebar-panel-group/index.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-panel-group/index.esm.js +1 -0
- package/dist/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.cjs.js +2 -0
- package/dist/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.css.cjs.js +2 -0
- package/dist/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.css.cjs.js.map +1 -0
- package/dist/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.css.esm.js +30 -0
- package/dist/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.esm.js +12 -0
- package/dist/nile-nav-tab/index.cjs.js +2 -0
- package/dist/nile-nav-tab/index.cjs.js.map +1 -0
- package/dist/nile-nav-tab/index.esm.js +1 -0
- package/dist/nile-nav-tab/nile-nav-tab.cjs.js +2 -0
- package/dist/nile-nav-tab/nile-nav-tab.cjs.js.map +1 -0
- package/dist/nile-nav-tab/nile-nav-tab.css.cjs.js +2 -0
- package/dist/nile-nav-tab/nile-nav-tab.css.cjs.js.map +1 -0
- package/dist/nile-nav-tab/nile-nav-tab.css.esm.js +190 -0
- package/dist/nile-nav-tab/nile-nav-tab.esm.js +36 -0
- package/dist/nile-nav-tab-group/index.cjs.js +2 -0
- package/dist/nile-nav-tab-group/index.cjs.js.map +1 -0
- package/dist/nile-nav-tab-group/index.esm.js +1 -0
- package/dist/nile-nav-tab-group/nile-nav-tab-group.cjs.js +4 -0
- package/dist/nile-nav-tab-group/nile-nav-tab-group.cjs.js.map +1 -0
- package/dist/nile-nav-tab-group/nile-nav-tab-group.css.cjs.js +2 -0
- package/dist/nile-nav-tab-group/nile-nav-tab-group.css.cjs.js.map +1 -0
- package/dist/nile-nav-tab-group/nile-nav-tab-group.css.esm.js +668 -0
- package/dist/nile-nav-tab-group/nile-nav-tab-group.esm.js +61 -0
- package/dist/nile-nav-tab-panel/index.cjs.js +2 -0
- package/dist/nile-nav-tab-panel/index.cjs.js.map +1 -0
- package/dist/nile-nav-tab-panel/index.esm.js +1 -0
- package/dist/nile-nav-tab-panel/nile-nav-tab-panel.cjs.js +2 -0
- package/dist/nile-nav-tab-panel/nile-nav-tab-panel.cjs.js.map +1 -0
- package/dist/nile-nav-tab-panel/nile-nav-tab-panel.css.cjs.js +2 -0
- package/dist/nile-nav-tab-panel/nile-nav-tab-panel.css.cjs.js.map +1 -0
- package/dist/nile-nav-tab-panel/nile-nav-tab-panel.css.esm.js +22 -0
- package/dist/nile-nav-tab-panel/nile-nav-tab-panel.esm.js +8 -0
- package/dist/nile-stepper-item/nile-stepper-item.cjs.js +1 -1
- package/dist/nile-stepper-item/nile-stepper-item.cjs.js.map +1 -1
- package/dist/nile-stepper-item/nile-stepper-item.esm.js +13 -13
- package/dist/nile-vertical-stepper-item/nile-vertical-stepper-item.cjs.js +1 -1
- package/dist/nile-vertical-stepper-item/nile-vertical-stepper-item.cjs.js.map +1 -1
- package/dist/nile-vertical-stepper-item/nile-vertical-stepper-item.esm.js +1 -1
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal/enum.d.ts +6 -0
- package/dist/src/internal/enum.js +7 -0
- package/dist/src/internal/enum.js.map +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.js +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.css.js +0 -3
- package/dist/src/nile-calendar/nile-calendar.css.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.js +2 -2
- package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
- package/dist/src/nile-dropdown/nile-dropdown.d.ts +2 -0
- package/dist/src/nile-dropdown/nile-dropdown.js +21 -5
- package/dist/src/nile-dropdown/nile-dropdown.js.map +1 -1
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.css.d.ts +1 -0
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.css.js +75 -17
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.css.js.map +1 -1
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.d.ts +17 -1
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.js +147 -18
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.js.map +1 -1
- package/dist/src/nile-inline-sidebar-group/nile-inline-sidebar-group.css.d.ts +1 -0
- package/dist/src/nile-inline-sidebar-group/nile-inline-sidebar-group.css.js +7 -7
- package/dist/src/nile-inline-sidebar-group/nile-inline-sidebar-group.css.js.map +1 -1
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.css.d.ts +1 -1
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.css.js +15 -17
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.css.js.map +1 -1
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.d.ts +7 -1
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.js +63 -4
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.js.map +1 -1
- package/dist/src/nile-inline-sidebar-item-body/index.d.ts +1 -0
- package/dist/src/nile-inline-sidebar-item-body/index.js +2 -0
- package/dist/src/nile-inline-sidebar-item-body/index.js.map +1 -0
- package/dist/src/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.css.d.ts +9 -0
- package/dist/src/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.css.js +62 -0
- package/dist/src/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.css.js.map +1 -0
- package/dist/src/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.d.ts +45 -0
- package/dist/src/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.js +110 -0
- package/dist/src/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.js.map +1 -0
- package/dist/src/nile-inline-sidebar-item-header/index.d.ts +1 -0
- package/dist/src/nile-inline-sidebar-item-header/index.js +2 -0
- package/dist/src/nile-inline-sidebar-item-header/index.js.map +1 -0
- package/dist/src/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.css.d.ts +9 -0
- package/dist/src/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.css.js +36 -0
- package/dist/src/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.css.js.map +1 -0
- package/dist/src/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.d.ts +34 -0
- package/dist/src/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.js +68 -0
- package/dist/src/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.js.map +1 -0
- package/dist/src/nile-inline-sidebar-panel/index.d.ts +1 -0
- package/dist/src/nile-inline-sidebar-panel/index.js +2 -0
- package/dist/src/nile-inline-sidebar-panel/index.js.map +1 -0
- package/dist/src/nile-inline-sidebar-panel/nile-inline-sidebar-panel.css.d.ts +9 -0
- package/dist/src/nile-inline-sidebar-panel/nile-inline-sidebar-panel.css.js +28 -0
- package/dist/src/nile-inline-sidebar-panel/nile-inline-sidebar-panel.css.js.map +1 -0
- package/dist/src/nile-inline-sidebar-panel/nile-inline-sidebar-panel.d.ts +35 -0
- package/dist/src/nile-inline-sidebar-panel/nile-inline-sidebar-panel.js +55 -0
- package/dist/src/nile-inline-sidebar-panel/nile-inline-sidebar-panel.js.map +1 -0
- package/dist/src/nile-inline-sidebar-panel-group/index.d.ts +1 -0
- package/dist/src/nile-inline-sidebar-panel-group/index.js +2 -0
- package/dist/src/nile-inline-sidebar-panel-group/index.js.map +1 -0
- package/dist/src/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.css.d.ts +9 -0
- package/dist/src/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.css.js +39 -0
- package/dist/src/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.css.js.map +1 -0
- package/dist/src/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.d.ts +43 -0
- package/dist/src/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.js +93 -0
- package/dist/src/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.js.map +1 -0
- package/dist/src/nile-nav-tab/index.d.ts +1 -0
- package/dist/src/nile-nav-tab/index.js +2 -0
- package/dist/src/nile-nav-tab/index.js.map +1 -0
- package/dist/src/nile-nav-tab/nile-nav-tab.css.d.ts +9 -0
- package/dist/src/nile-nav-tab/nile-nav-tab.css.js +199 -0
- package/dist/src/nile-nav-tab/nile-nav-tab.css.js.map +1 -0
- package/dist/src/nile-nav-tab/nile-nav-tab.d.ts +50 -0
- package/dist/src/nile-nav-tab/nile-nav-tab.js +190 -0
- package/dist/src/nile-nav-tab/nile-nav-tab.js.map +1 -0
- package/dist/src/nile-nav-tab/nile-nav-tab.test.d.ts +1 -0
- package/dist/src/nile-nav-tab/nile-nav-tab.test.js +656 -0
- package/dist/src/nile-nav-tab/nile-nav-tab.test.js.map +1 -0
- package/dist/src/nile-nav-tab-group/index.d.ts +1 -0
- package/dist/src/nile-nav-tab-group/index.js +2 -0
- package/dist/src/nile-nav-tab-group/index.js.map +1 -0
- package/dist/src/nile-nav-tab-group/nile-nav-tab-group.css.d.ts +12 -0
- package/dist/src/nile-nav-tab-group/nile-nav-tab-group.css.js +680 -0
- package/dist/src/nile-nav-tab-group/nile-nav-tab-group.css.js.map +1 -0
- package/dist/src/nile-nav-tab-group/nile-nav-tab-group.d.ts +119 -0
- package/dist/src/nile-nav-tab-group/nile-nav-tab-group.js +765 -0
- package/dist/src/nile-nav-tab-group/nile-nav-tab-group.js.map +1 -0
- package/dist/src/nile-nav-tab-group/nile-nav-tab-group.test.d.ts +3 -0
- package/dist/src/nile-nav-tab-group/nile-nav-tab-group.test.js +838 -0
- package/dist/src/nile-nav-tab-group/nile-nav-tab-group.test.js.map +1 -0
- package/dist/src/nile-nav-tab-panel/index.d.ts +1 -0
- package/dist/src/nile-nav-tab-panel/index.js +2 -0
- package/dist/src/nile-nav-tab-panel/index.js.map +1 -0
- package/dist/src/nile-nav-tab-panel/nile-nav-tab-panel.css.d.ts +15 -0
- package/dist/src/nile-nav-tab-panel/nile-nav-tab-panel.css.js +37 -0
- package/dist/src/nile-nav-tab-panel/nile-nav-tab-panel.css.js.map +1 -0
- package/dist/src/nile-nav-tab-panel/nile-nav-tab-panel.d.ts +37 -0
- package/dist/src/nile-nav-tab-panel/nile-nav-tab-panel.js +75 -0
- package/dist/src/nile-nav-tab-panel/nile-nav-tab-panel.js.map +1 -0
- package/dist/src/nile-nav-tab-panel/nile-nav-tab-panel.test.d.ts +1 -0
- package/dist/src/nile-nav-tab-panel/nile-nav-tab-panel.test.js +534 -0
- package/dist/src/nile-nav-tab-panel/nile-nav-tab-panel.test.js.map +1 -0
- package/dist/src/nile-stepper-item/nile-stepper-item.js +1 -1
- package/dist/src/nile-stepper-item/nile-stepper-item.js.map +1 -1
- package/dist/src/nile-vertical-stepper-item/nile-vertical-stepper-item.js +1 -1
- package/dist/src/nile-vertical-stepper-item/nile-vertical-stepper-item.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -2
- package/src/index.ts +7 -0
- package/src/internal/enum.ts +8 -1
- package/src/nile-auto-complete/nile-auto-complete.ts +1 -1
- package/src/nile-calendar/nile-calendar.css.ts +0 -3
- package/src/nile-calendar/nile-calendar.ts +2 -2
- package/src/nile-dropdown/nile-dropdown.ts +23 -5
- package/src/nile-inline-sidebar/nile-inline-sidebar.css.ts +75 -17
- package/src/nile-inline-sidebar/nile-inline-sidebar.ts +148 -18
- package/src/nile-inline-sidebar-group/nile-inline-sidebar-group.css.ts +7 -7
- package/src/nile-inline-sidebar-item/nile-inline-sidebar-item.css.ts +15 -17
- package/src/nile-inline-sidebar-item/nile-inline-sidebar-item.ts +74 -9
- package/src/nile-inline-sidebar-item-body/index.ts +1 -0
- package/src/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.css.ts +64 -0
- package/src/nile-inline-sidebar-item-body/nile-inline-sidebar-item-body.ts +110 -0
- package/src/nile-inline-sidebar-item-header/index.ts +1 -0
- package/src/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.css.ts +38 -0
- package/src/nile-inline-sidebar-item-header/nile-inline-sidebar-item-header.ts +69 -0
- package/src/nile-inline-sidebar-panel/index.ts +1 -0
- package/src/nile-inline-sidebar-panel/nile-inline-sidebar-panel.css.ts +30 -0
- package/src/nile-inline-sidebar-panel/nile-inline-sidebar-panel.ts +53 -0
- package/src/nile-inline-sidebar-panel-group/index.ts +1 -0
- package/src/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.css.ts +41 -0
- package/src/nile-inline-sidebar-panel-group/nile-inline-sidebar-panel-group.ts +101 -0
- package/src/nile-nav-tab/index.ts +1 -0
- package/src/nile-nav-tab/nile-nav-tab.css.ts +201 -0
- package/src/nile-nav-tab/nile-nav-tab.test.ts +768 -0
- package/src/nile-nav-tab/nile-nav-tab.ts +198 -0
- package/src/nile-nav-tab-group/index.ts +1 -0
- package/src/nile-nav-tab-group/nile-nav-tab-group.css.ts +682 -0
- package/src/nile-nav-tab-group/nile-nav-tab-group.test.ts +1009 -0
- package/src/nile-nav-tab-group/nile-nav-tab-group.ts +845 -0
- package/src/nile-nav-tab-panel/index.ts +1 -0
- package/src/nile-nav-tab-panel/nile-nav-tab-panel.css.ts +39 -0
- package/src/nile-nav-tab-panel/nile-nav-tab-panel.test.ts +797 -0
- package/src/nile-nav-tab-panel/nile-nav-tab-panel.ts +78 -0
- package/src/nile-stepper-item/nile-stepper-item.ts +1 -1
- package/src/nile-vertical-stepper-item/nile-vertical-stepper-item.ts +1 -1
- package/vscode-html-custom-data.json +273 -3
|
@@ -0,0 +1,765 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { __decorate } from "tslib";
|
|
8
|
+
import { html, nothing } from 'lit';
|
|
9
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
10
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
11
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
12
|
+
import { scrollIntoView } from '../internal/scroll';
|
|
13
|
+
import { watch } from '../internal/watch';
|
|
14
|
+
import NileElement from '../internal/nile-element';
|
|
15
|
+
import { styles } from './nile-nav-tab-group.css';
|
|
16
|
+
import { MouseKey } from '../internal/enum';
|
|
17
|
+
import '../nile-icon-button/nile-icon-button';
|
|
18
|
+
/**
|
|
19
|
+
* Tab group navigation component.
|
|
20
|
+
*
|
|
21
|
+
* @tag nile-nav-tab-group
|
|
22
|
+
*
|
|
23
|
+
* @slot - Used for grouping tab panels in the tab group. Must be `<nile-nav-tab-panel>` elements.
|
|
24
|
+
* @slot nav - Used for grouping tabs in the tab group. Must be `<nile-nav-tab>` elements.
|
|
25
|
+
*
|
|
26
|
+
* @csspart base - The component's base wrapper.
|
|
27
|
+
* @csspart nav - The tab group's navigation container where tabs are slotted in.
|
|
28
|
+
* @csspart tabs - The container that wraps the tabs.
|
|
29
|
+
* @csspart active-tab-indicator - The line that highlights the currently selected tab.
|
|
30
|
+
* @csspart toggle-frame - Toggle variant: absolutely positioned ring that draws the group chrome (tabs paint above it).
|
|
31
|
+
* @csspart body - The tab group's body where tab panels are slotted in.
|
|
32
|
+
* @csspart scroll-button - The previous/next scroll buttons that show when tabs are scrollable, an `<nile-icon-button>`.
|
|
33
|
+
* @csspart scroll-button--start - The starting scroll button.
|
|
34
|
+
* @csspart scroll-button--end - The ending scroll button.
|
|
35
|
+
* @csspart scroll-button__base - The scroll button's exported `base` part.
|
|
36
|
+
*
|
|
37
|
+
* @cssproperty --indicator-color - The color of the active tab indicator.
|
|
38
|
+
* @cssproperty --track-color - The color of the indicator's track (the line that separates tabs from panels).
|
|
39
|
+
* @cssproperty --track-width - The width of the indicator's track (the line that separates tabs from panels).
|
|
40
|
+
* @cssproperty --show-indicator-on-hover - Whether to show the indicator on hover.
|
|
41
|
+
*
|
|
42
|
+
* @event nile-close - Bubbled from a closable `<nile-nav-tab>`; re-emitted so parents can listen on this element.
|
|
43
|
+
*/
|
|
44
|
+
let NileNavTabGroup = class NileNavTabGroup extends NileElement {
|
|
45
|
+
constructor() {
|
|
46
|
+
super(...arguments);
|
|
47
|
+
this.pillRepositionTimer = null;
|
|
48
|
+
this.pillTransitionClassTimer = null;
|
|
49
|
+
this.pillReady = false;
|
|
50
|
+
this.observedTabs = new Set();
|
|
51
|
+
this.tabs = [];
|
|
52
|
+
this.panels = [];
|
|
53
|
+
/** Tabs emit `nile-close` on the host; bubble is stopped so we re-emit from the group with `{ panel }` for consumers. */
|
|
54
|
+
this.handleCloseEvent = (e) => {
|
|
55
|
+
if (e.target === this)
|
|
56
|
+
return;
|
|
57
|
+
const tab = e.target;
|
|
58
|
+
const panel = tab?.getAttribute('panel');
|
|
59
|
+
if (!panel)
|
|
60
|
+
return;
|
|
61
|
+
// Other listeners on this host must not see the child event (no `detail`) after we synthesize one.
|
|
62
|
+
e.stopImmediatePropagation();
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
this.syncIndicator();
|
|
65
|
+
this.emit('nile-close', { panel });
|
|
66
|
+
};
|
|
67
|
+
/** Tracks visibility for snapping the indicator when a hidden parent (e.g. dropdown) is reopened. */
|
|
68
|
+
this.tabGroupWasIntersecting = false;
|
|
69
|
+
/** Last measured nav width; used to detect layout resume after display:none / collapse. */
|
|
70
|
+
this.lastNavClientWidth = 0;
|
|
71
|
+
this.hasScrollControls = false;
|
|
72
|
+
/** The placement of the tabs. */
|
|
73
|
+
this.placement = 'top';
|
|
74
|
+
/** The currently active tab value. */
|
|
75
|
+
this.activeTabProp = '';
|
|
76
|
+
/** Track for showing Indicators and Background. */
|
|
77
|
+
this.noTrack = false;
|
|
78
|
+
/** Disables the scroll arrows that appear when tabs overflow. */
|
|
79
|
+
this.noScrollControls = false;
|
|
80
|
+
/** Controls whether tabs are centered and have equal width. */
|
|
81
|
+
this.centered = false;
|
|
82
|
+
this.variant = 'underline';
|
|
83
|
+
this.indicatorPlacement = '';
|
|
84
|
+
this.fullWidth = false;
|
|
85
|
+
this.width = '';
|
|
86
|
+
this.showIndicatorOnHover = false;
|
|
87
|
+
this.activeTabName = '';
|
|
88
|
+
}
|
|
89
|
+
get showScrollControlButtons() {
|
|
90
|
+
return !this.noScrollControls && this.hasScrollControls;
|
|
91
|
+
}
|
|
92
|
+
connectedCallback() {
|
|
93
|
+
super.connectedCallback();
|
|
94
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
95
|
+
this.setScrollControls();
|
|
96
|
+
const nw = this.nav?.clientWidth ?? 0;
|
|
97
|
+
const layoutResumed = this.lastNavClientWidth === 0 && nw > 0;
|
|
98
|
+
this.lastNavClientWidth = nw;
|
|
99
|
+
this.repositionIndicator({ skipTransition: layoutResumed });
|
|
100
|
+
this.debouncedPositionPill();
|
|
101
|
+
});
|
|
102
|
+
this.mutationObserver = new MutationObserver(mutations => {
|
|
103
|
+
if (mutations.some(m => !['aria-labelledby', 'aria-controls'].includes(m.attributeName))) {
|
|
104
|
+
setTimeout(() => this.setAriaLabels());
|
|
105
|
+
}
|
|
106
|
+
if (mutations.some(m => m.attributeName === 'disabled')) {
|
|
107
|
+
this.syncTabsAndPanels();
|
|
108
|
+
}
|
|
109
|
+
if (mutations.some(m => m.attributeName === 'active')) {
|
|
110
|
+
const activeTab = this.getAllTabs({ includeDisabled: false }).find(t => t.active);
|
|
111
|
+
if (activeTab && activeTab.panel !== this.activeTabName) {
|
|
112
|
+
this.activeTabName = activeTab.panel;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (mutations.some(m => m.type === 'childList' || m.type === 'characterData')) {
|
|
116
|
+
this.repositionIndicator();
|
|
117
|
+
this.debouncedPositionPill();
|
|
118
|
+
requestAnimationFrame(() => this.setScrollControls());
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
this.updateComplete.then(async () => {
|
|
122
|
+
this.setScrollControls();
|
|
123
|
+
await Promise.all(this.getAllTabs({ includeDisabled: true }).map(tab => tab.updateComplete));
|
|
124
|
+
await Promise.all(this.getAllPanels().map(panel => panel.updateComplete));
|
|
125
|
+
this.syncTabsAndPanels();
|
|
126
|
+
if (this.activeTabProp) {
|
|
127
|
+
this.activeTabName = this.activeTabProp;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const activeTab = this.getActiveTab();
|
|
131
|
+
this.activeTabName = activeTab ? activeTab.panel : '';
|
|
132
|
+
}
|
|
133
|
+
// First paint: disable indicator transition so it jumps to the correct tab without sliding from (0,0).
|
|
134
|
+
requestAnimationFrame(() => {
|
|
135
|
+
if (this.indicator) {
|
|
136
|
+
this.indicator.style.transition = 'none';
|
|
137
|
+
}
|
|
138
|
+
this.syncIndicator();
|
|
139
|
+
this.positionPill();
|
|
140
|
+
requestAnimationFrame(() => {
|
|
141
|
+
if (this.indicator) {
|
|
142
|
+
this.indicator.style.transition = '';
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
this.mutationObserver.observe(this, { attributes: true, childList: true, subtree: true, characterData: true });
|
|
147
|
+
this.resizeObserver.observe(this.nav);
|
|
148
|
+
this.visibilityObserver = new IntersectionObserver((entries) => {
|
|
149
|
+
const entry = entries[0];
|
|
150
|
+
const nowVisible = entry.isIntersecting && entry.intersectionRatio > 0;
|
|
151
|
+
if (nowVisible) {
|
|
152
|
+
this.setAriaLabels();
|
|
153
|
+
this.debouncedPositionPill();
|
|
154
|
+
const becameVisible = !this.tabGroupWasIntersecting;
|
|
155
|
+
this.tabGroupWasIntersecting = true;
|
|
156
|
+
this.repositionIndicator({ skipTransition: becameVisible });
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
this.tabGroupWasIntersecting = false;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
this.visibilityObserver.observe(this.tabGroup);
|
|
163
|
+
});
|
|
164
|
+
this.addEventListener('nile-close', this.handleCloseEvent);
|
|
165
|
+
this.addEventListener('click', this.handleNavClick);
|
|
166
|
+
this.addEventListener('keydown', this.handleKeyDown);
|
|
167
|
+
}
|
|
168
|
+
disconnectedCallback() {
|
|
169
|
+
this.mutationObserver.disconnect();
|
|
170
|
+
this.resizeObserver.disconnect();
|
|
171
|
+
this.observedTabs.clear();
|
|
172
|
+
this.visibilityObserver?.disconnect();
|
|
173
|
+
this.removeEventListener('nile-close', this.handleCloseEvent);
|
|
174
|
+
this.removeEventListener('click', this.handleNavClick);
|
|
175
|
+
this.removeEventListener('keydown', this.handleKeyDown);
|
|
176
|
+
}
|
|
177
|
+
updated(_changedProperties) {
|
|
178
|
+
let nameChanged = _changedProperties.has('activeTabName');
|
|
179
|
+
if (_changedProperties.has('activeTabProp') && this.activeTabName !== this.activeTabProp) {
|
|
180
|
+
this.activeTabName = this.activeTabProp;
|
|
181
|
+
nameChanged = true;
|
|
182
|
+
}
|
|
183
|
+
if (nameChanged) {
|
|
184
|
+
const tab = this.getActiveTab();
|
|
185
|
+
if (tab) {
|
|
186
|
+
this.setActiveTab(tab, { scrollBehavior: 'smooth' });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (_changedProperties.has('noScrollControls')) {
|
|
190
|
+
requestAnimationFrame(() => this.setScrollControls());
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
syncIndicator() {
|
|
194
|
+
requestAnimationFrame(() => this.setScrollControls());
|
|
195
|
+
if (!this.indicator)
|
|
196
|
+
return;
|
|
197
|
+
const tab = this.getActiveTab();
|
|
198
|
+
if (tab && !tab.disabled) {
|
|
199
|
+
this.indicator.style.display = 'block';
|
|
200
|
+
this.repositionIndicator();
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
this.indicator.style.display = 'none';
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
handleNavClick(event) {
|
|
207
|
+
const tab = event.composedPath().find((el) => el instanceof HTMLElement && el.tagName.toLowerCase() === 'nile-nav-tab');
|
|
208
|
+
if (!tab)
|
|
209
|
+
return;
|
|
210
|
+
const tabsNow = this.getAllTabs({ includeDisabled: true });
|
|
211
|
+
if (!tabsNow.includes(tab))
|
|
212
|
+
return;
|
|
213
|
+
if (tab.hasAttribute('disabled') || tab.disabled)
|
|
214
|
+
return;
|
|
215
|
+
const isModifiedClick = Object.values(MouseKey).some(key => event[key]) || event.button !== 0;
|
|
216
|
+
if (isModifiedClick)
|
|
217
|
+
return;
|
|
218
|
+
this.activeTabProp = tab.panel;
|
|
219
|
+
this.activeTabName = tab.panel;
|
|
220
|
+
tab.focus();
|
|
221
|
+
}
|
|
222
|
+
positionPill(animate = false) {
|
|
223
|
+
const pill = this.shadowRoot?.querySelector('.nav-tab-group__pill');
|
|
224
|
+
if (!pill)
|
|
225
|
+
return;
|
|
226
|
+
if (this.pillTransitionClassTimer) {
|
|
227
|
+
clearTimeout(this.pillTransitionClassTimer);
|
|
228
|
+
this.pillTransitionClassTimer = null;
|
|
229
|
+
}
|
|
230
|
+
const tab = this.getActiveTab();
|
|
231
|
+
if (!tab || tab.disabled) {
|
|
232
|
+
pill.classList.add('nav-tab-group__pill--inactive');
|
|
233
|
+
pill.classList.remove('nav-tab-group__pill--transitioning');
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
pill.classList.remove('nav-tab-group__pill--inactive');
|
|
237
|
+
const target = tab.shadowRoot?.querySelector('.nav-tab-container');
|
|
238
|
+
if (!target)
|
|
239
|
+
return;
|
|
240
|
+
const container = this.shadowRoot?.querySelector('.nav-tab-group__tabs');
|
|
241
|
+
if (!container)
|
|
242
|
+
return;
|
|
243
|
+
if (target.offsetWidth === 0 || target.offsetHeight === 0)
|
|
244
|
+
return;
|
|
245
|
+
const box = this.getLayoutBoxRelativeToContainer(target, container);
|
|
246
|
+
if (!box)
|
|
247
|
+
return;
|
|
248
|
+
const x = box.x;
|
|
249
|
+
const y = box.y;
|
|
250
|
+
const w = box.width;
|
|
251
|
+
const h = box.height;
|
|
252
|
+
const cw = container.clientWidth;
|
|
253
|
+
const rightInset = Math.max(0, cw - x - w);
|
|
254
|
+
if (animate) {
|
|
255
|
+
const ease = 'cubic-bezier(0.4, 0, 0.2, 1)';
|
|
256
|
+
pill.style.transition = `left 400ms ${ease}, right 400ms ${ease}, top 400ms ${ease}, height 400ms ${ease}`;
|
|
257
|
+
if (this.variant === 'toggle') {
|
|
258
|
+
pill.classList.add('nav-tab-group__pill--transitioning');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
pill.style.transition = '';
|
|
263
|
+
if (this.variant === 'toggle') {
|
|
264
|
+
pill.classList.remove('nav-tab-group__pill--transitioning');
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
pill.style.transform = '';
|
|
268
|
+
pill.style.left = `${x}px`;
|
|
269
|
+
pill.style.right = `${rightInset}px`;
|
|
270
|
+
pill.style.width = 'auto';
|
|
271
|
+
pill.style.top = `${y}px`;
|
|
272
|
+
pill.style.height = `${h}px`;
|
|
273
|
+
pill.style.opacity = '1';
|
|
274
|
+
if (!this.pillReady) {
|
|
275
|
+
this.pillReady = true;
|
|
276
|
+
}
|
|
277
|
+
if (animate) {
|
|
278
|
+
const onEnd = () => {
|
|
279
|
+
pill.style.transition = '';
|
|
280
|
+
pill.removeEventListener('transitionend', onEnd);
|
|
281
|
+
};
|
|
282
|
+
pill.addEventListener('transitionend', onEnd);
|
|
283
|
+
if (this.variant === 'toggle') {
|
|
284
|
+
this.pillTransitionClassTimer = setTimeout(() => {
|
|
285
|
+
this.pillTransitionClassTimer = null;
|
|
286
|
+
pill.classList.remove('nav-tab-group__pill--transitioning');
|
|
287
|
+
}, 420);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
debouncedPositionPill() {
|
|
292
|
+
if (this.pillRepositionTimer) {
|
|
293
|
+
clearTimeout(this.pillRepositionTimer);
|
|
294
|
+
}
|
|
295
|
+
this.pillRepositionTimer = setTimeout(() => {
|
|
296
|
+
this.pillRepositionTimer = null;
|
|
297
|
+
this.positionPill();
|
|
298
|
+
}, 150);
|
|
299
|
+
}
|
|
300
|
+
handleTabHover(event) {
|
|
301
|
+
if (!this.showIndicatorOnHover)
|
|
302
|
+
return;
|
|
303
|
+
const tab = event.composedPath().find((el) => el instanceof HTMLElement && el.tagName.toLowerCase() === 'nile-nav-tab');
|
|
304
|
+
if (!tab || tab.disabled || tab.hasAttribute('disabled'))
|
|
305
|
+
return;
|
|
306
|
+
const tabsNow = this.getAllTabs({ includeDisabled: true });
|
|
307
|
+
if (!tabsNow.includes(tab))
|
|
308
|
+
return;
|
|
309
|
+
this.positionHoverIndicator(tab);
|
|
310
|
+
}
|
|
311
|
+
handleTabHoverLeave() {
|
|
312
|
+
if (!this.showIndicatorOnHover || !this.hoverIndicator)
|
|
313
|
+
return;
|
|
314
|
+
this.hoverIndicator.style.opacity = '0';
|
|
315
|
+
}
|
|
316
|
+
positionHoverIndicator(tab) {
|
|
317
|
+
if (!this.hoverIndicator)
|
|
318
|
+
return;
|
|
319
|
+
const container = this.shadowRoot?.querySelector('.nav-tab-group__tabs');
|
|
320
|
+
if (!container)
|
|
321
|
+
return;
|
|
322
|
+
const target = tab.shadowRoot?.querySelector('.nav-tab-container');
|
|
323
|
+
if (!target)
|
|
324
|
+
return;
|
|
325
|
+
const layoutBox = this.getLayoutBoxRelativeToContainer(target, container);
|
|
326
|
+
if (!layoutBox)
|
|
327
|
+
return;
|
|
328
|
+
this.hoverIndicator.style.transition = 'none';
|
|
329
|
+
switch (this.placement) {
|
|
330
|
+
case 'top':
|
|
331
|
+
case 'bottom':
|
|
332
|
+
this.hoverIndicator.style.width = `${target.offsetWidth}px`;
|
|
333
|
+
this.hoverIndicator.style.height = 'auto';
|
|
334
|
+
this.hoverIndicator.style.translate = `${layoutBox.x}px 0px`;
|
|
335
|
+
break;
|
|
336
|
+
case 'start':
|
|
337
|
+
case 'end':
|
|
338
|
+
this.hoverIndicator.style.height = `${target.offsetHeight}px`;
|
|
339
|
+
this.hoverIndicator.style.width = 'auto';
|
|
340
|
+
this.hoverIndicator.style.translate = `0px ${layoutBox.y}px`;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
this.hoverIndicator.style.opacity = '1';
|
|
344
|
+
}
|
|
345
|
+
render() {
|
|
346
|
+
const usesPill = this.variant === 'filled' ||
|
|
347
|
+
this.variant === 'neutral-filled' ||
|
|
348
|
+
this.variant === 'toggle' ||
|
|
349
|
+
this.variant === 'toggle-button';
|
|
350
|
+
const showsIndicator = this.variant !== 'filled' &&
|
|
351
|
+
this.variant !== 'neutral-filled' &&
|
|
352
|
+
this.variant !== 'toggle-button' &&
|
|
353
|
+
this.variant !== 'toggle';
|
|
354
|
+
const toggleVariant = this.variant === 'toggle';
|
|
355
|
+
return html `
|
|
356
|
+
<div
|
|
357
|
+
part="base"
|
|
358
|
+
class=${classMap({
|
|
359
|
+
'nav-tab-group': true,
|
|
360
|
+
'nav-tab-group--top': this.placement === 'top',
|
|
361
|
+
'nav-tab-group--bottom': this.placement === 'bottom',
|
|
362
|
+
'nav-tab-group--start': this.placement === 'start',
|
|
363
|
+
'nav-tab-group--end': this.placement === 'end',
|
|
364
|
+
'nav-tab-group--rtl': true,
|
|
365
|
+
'nav-tab-group--has-scroll-controls': this.showScrollControlButtons,
|
|
366
|
+
'hide__track': this.noTrack,
|
|
367
|
+
})}
|
|
368
|
+
style=${styleMap(this.width ? { '--nav-tab-item-width': this.width } : {})}
|
|
369
|
+
>
|
|
370
|
+
<nav class="nav-tab-group__nav-container" part="nav">
|
|
371
|
+
${toggleVariant
|
|
372
|
+
? html `<div class="nav-tab-group__toggle-frame" part="toggle-frame"></div>`
|
|
373
|
+
: nothing}
|
|
374
|
+
${this.showScrollControlButtons
|
|
375
|
+
? html `
|
|
376
|
+
<nile-icon-button
|
|
377
|
+
part="scroll-button scroll-button--start"
|
|
378
|
+
exportparts="base:scroll-button__base"
|
|
379
|
+
class="nav-tab-group__scroll-button nav-tab-group__scroll-button--start"
|
|
380
|
+
name='var(--nile-icon-arrow-right, var(--ng-icon-chevron-right))'
|
|
381
|
+
library="system"
|
|
382
|
+
label="scrollToStart"
|
|
383
|
+
@click=${this.handleScrollToEnd}
|
|
384
|
+
></nile-icon-button>
|
|
385
|
+
`
|
|
386
|
+
: nothing}
|
|
387
|
+
|
|
388
|
+
<div part="tab-container" class="nav-tab-group__nav">
|
|
389
|
+
<ul part="tabs" class="nav-tab-group__tabs" role="tablist">
|
|
390
|
+
${showsIndicator ? html `
|
|
391
|
+
<div part="active-tab-indicator-path" class="nav-tab-group__indicator__path"></div>
|
|
392
|
+
<div
|
|
393
|
+
part="active-tab-indicator"
|
|
394
|
+
class=${classMap({
|
|
395
|
+
'nav-tab-group__indicator': !this.noTrack,
|
|
396
|
+
})}
|
|
397
|
+
></div>
|
|
398
|
+
` : nothing}
|
|
399
|
+
|
|
400
|
+
${!this.noTrack && showsIndicator && this.showIndicatorOnHover ? html `
|
|
401
|
+
<div class="nav-tab-group__hover-indicator" part="hover-tab-indicator"></div>
|
|
402
|
+
` : nothing}
|
|
403
|
+
|
|
404
|
+
${usesPill ? html `<div class="nav-tab-group__pill" part="active-tab-pill"></div>` : nothing}
|
|
405
|
+
|
|
406
|
+
<slot
|
|
407
|
+
name="nav"
|
|
408
|
+
@mouseover=${this.handleTabHover}
|
|
409
|
+
@mouseleave=${this.handleTabHoverLeave}
|
|
410
|
+
@slotchange=${this.syncTabsAndPanels}
|
|
411
|
+
></slot>
|
|
412
|
+
</ul>
|
|
413
|
+
</div>
|
|
414
|
+
|
|
415
|
+
${this.showScrollControlButtons
|
|
416
|
+
? html `
|
|
417
|
+
<nile-icon-button
|
|
418
|
+
part="scroll-button scroll-button--end"
|
|
419
|
+
exportparts="base:scroll-button__base"
|
|
420
|
+
class="nav-tab-group__scroll-button nav-tab-group__scroll-button--end"
|
|
421
|
+
name='var(--nile-icon-arrow-left, var(--ng-icon-chevron-left))'
|
|
422
|
+
library="system"
|
|
423
|
+
label="scrollToEnd"
|
|
424
|
+
@click=${this.handleScrollToStart}
|
|
425
|
+
></nile-icon-button>
|
|
426
|
+
`
|
|
427
|
+
: nothing}
|
|
428
|
+
</nav>
|
|
429
|
+
|
|
430
|
+
<slot part="body" class="nav-tab-group__body" @slotchange=${this.syncTabsAndPanels}></slot>
|
|
431
|
+
</div>
|
|
432
|
+
`;
|
|
433
|
+
}
|
|
434
|
+
getAllTabs(options = { includeDisabled: true }) {
|
|
435
|
+
const slot = this.shadowRoot.querySelector('slot[name="nav"]');
|
|
436
|
+
const navTabs = slot.assignedElements().filter((el) => el.tagName.toLowerCase() === 'nile-nav-tab');
|
|
437
|
+
return options.includeDisabled ? navTabs : navTabs.filter(tab => !tab.disabled);
|
|
438
|
+
}
|
|
439
|
+
getAllPanels() {
|
|
440
|
+
return [...this.body.assignedElements()].filter(el => el.tagName.toLowerCase() === 'nile-nav-tab-panel');
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Resolves the tab to treat as selected for indicator/pill wiring.
|
|
444
|
+
* Prefer `activeTabName` match; if empty (before init), fall back to `.active` or first usable tab.
|
|
445
|
+
*/
|
|
446
|
+
getActiveTab() {
|
|
447
|
+
return this.tabs.find(el => this.activeTabName ? el.panel === this.activeTabName : el.active) ?? this.tabs.find(el => !el.disabled) ?? this.tabs[0];
|
|
448
|
+
}
|
|
449
|
+
/** Reflects horizontal overflow into `hasScrollControls` (top/bottom only; vertical stacks do not scroll this strip). */
|
|
450
|
+
setScrollControls() {
|
|
451
|
+
if (!this.nav)
|
|
452
|
+
return;
|
|
453
|
+
if (this.noScrollControls) {
|
|
454
|
+
this.hasScrollControls = false;
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
this.hasScrollControls =
|
|
458
|
+
['top', 'bottom'].includes(this.placement) &&
|
|
459
|
+
this.nav.scrollWidth > this.nav.clientWidth;
|
|
460
|
+
}
|
|
461
|
+
handleKeyDown(event) {
|
|
462
|
+
const tab = event.composedPath().find((el) => el instanceof HTMLElement && el.tagName.toLowerCase() === 'nile-nav-tab');
|
|
463
|
+
if (tab?.disabled) {
|
|
464
|
+
event.preventDefault();
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
if (!tab || !this.tabs.includes(tab)) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
471
|
+
event.preventDefault();
|
|
472
|
+
this.activeTabProp = tab.panel;
|
|
473
|
+
this.activeTabName = tab.panel;
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
const navKeys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End'];
|
|
477
|
+
if (!navKeys.includes(event.key))
|
|
478
|
+
return;
|
|
479
|
+
let index = this.tabs.indexOf(tab);
|
|
480
|
+
const isHorizontal = ['top', 'bottom'].includes(this.placement);
|
|
481
|
+
const isRtl = getComputedStyle(this).direction === 'rtl';
|
|
482
|
+
if (event.key === 'Home') {
|
|
483
|
+
index = 0;
|
|
484
|
+
}
|
|
485
|
+
else if (event.key === 'End') {
|
|
486
|
+
index = this.tabs.length - 1;
|
|
487
|
+
}
|
|
488
|
+
else if ((isHorizontal &&
|
|
489
|
+
((isRtl && event.key === 'ArrowRight') || (!isRtl && event.key === 'ArrowLeft'))) ||
|
|
490
|
+
(['start', 'end'].includes(this.placement) && event.key === 'ArrowUp')) {
|
|
491
|
+
index--;
|
|
492
|
+
}
|
|
493
|
+
else if ((isHorizontal &&
|
|
494
|
+
((isRtl && event.key === 'ArrowLeft') || (!isRtl && event.key === 'ArrowRight'))) ||
|
|
495
|
+
(['start', 'end'].includes(this.placement) && event.key === 'ArrowDown')) {
|
|
496
|
+
index++;
|
|
497
|
+
}
|
|
498
|
+
if (index < 0)
|
|
499
|
+
index = this.tabs.length - 1;
|
|
500
|
+
if (index > this.tabs.length - 1)
|
|
501
|
+
index = 0;
|
|
502
|
+
this.tabs[index].focus({ preventScroll: true });
|
|
503
|
+
if (isHorizontal) {
|
|
504
|
+
scrollIntoView(this.tabs[index], this.nav, 'horizontal');
|
|
505
|
+
}
|
|
506
|
+
event.preventDefault();
|
|
507
|
+
}
|
|
508
|
+
handleScrollToStart() {
|
|
509
|
+
this.nav.scroll({
|
|
510
|
+
left: -this.nav.scrollWidth,
|
|
511
|
+
behavior: 'smooth'
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
handleScrollToEnd() {
|
|
515
|
+
this.nav.scroll({
|
|
516
|
+
left: this.nav.scrollWidth,
|
|
517
|
+
behavior: 'smooth'
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
setActiveTab(tab, options) {
|
|
521
|
+
options = {
|
|
522
|
+
emitEvents: true,
|
|
523
|
+
scrollBehavior: 'auto',
|
|
524
|
+
...options
|
|
525
|
+
};
|
|
526
|
+
if (tab !== this.activeTab && !tab.disabled) {
|
|
527
|
+
const previousTab = this.activeTab;
|
|
528
|
+
this.activeTab = tab;
|
|
529
|
+
if (this.activeTabProp !== this.activeTab.panel) {
|
|
530
|
+
this.activeTabProp = this.activeTab.panel;
|
|
531
|
+
}
|
|
532
|
+
this.tabs.forEach(el => (el.active = el === this.activeTab));
|
|
533
|
+
this.panels.forEach(el => (el.active = el.name === this.activeTab?.panel));
|
|
534
|
+
this.syncIndicator();
|
|
535
|
+
this.positionPill(this.pillReady);
|
|
536
|
+
if (['top', 'bottom'].includes(this.placement)) {
|
|
537
|
+
scrollIntoView(this.activeTab, this.nav, 'horizontal', options.scrollBehavior);
|
|
538
|
+
}
|
|
539
|
+
if (options.emitEvents) {
|
|
540
|
+
this.emit('nile-tab-change', {
|
|
541
|
+
value: this.activeTab.panel,
|
|
542
|
+
previousValue: previousTab?.panel ?? null,
|
|
543
|
+
index: this.tabs.indexOf(this.activeTab),
|
|
544
|
+
previousIndex: previousTab ? this.tabs.indexOf(previousTab) : -1,
|
|
545
|
+
link: this.activeTab.link
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
setAriaLabels() {
|
|
551
|
+
const allTabs = this.getAllTabs({ includeDisabled: true });
|
|
552
|
+
for (const tab of allTabs) {
|
|
553
|
+
const panel = this.panels.find(el => el.name === tab.panel);
|
|
554
|
+
if (tab.disabled) {
|
|
555
|
+
tab.removeAttribute('aria-controls');
|
|
556
|
+
if (panel)
|
|
557
|
+
panel.removeAttribute('aria-labelledby');
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
if (!panel)
|
|
561
|
+
continue;
|
|
562
|
+
const panelId = panel.getAttribute('id');
|
|
563
|
+
const tabId = tab.getAttribute('id');
|
|
564
|
+
if (!panelId || !tabId)
|
|
565
|
+
continue;
|
|
566
|
+
tab.setAttribute('aria-controls', panelId);
|
|
567
|
+
panel.setAttribute('aria-labelledby', tabId);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
getRelativeOffsetToAncestor(element, ancestor) {
|
|
571
|
+
let x = 0;
|
|
572
|
+
let y = 0;
|
|
573
|
+
let el = element;
|
|
574
|
+
while (el && el !== ancestor) {
|
|
575
|
+
x += el.offsetLeft;
|
|
576
|
+
y += el.offsetTop;
|
|
577
|
+
el = el.offsetParent;
|
|
578
|
+
}
|
|
579
|
+
return el === ancestor ? { x, y } : null;
|
|
580
|
+
}
|
|
581
|
+
getLayoutBoxRelativeToContainer(target, container) {
|
|
582
|
+
const c = container.getBoundingClientRect();
|
|
583
|
+
const r = target.getBoundingClientRect();
|
|
584
|
+
if (r.width === 0 || r.height === 0)
|
|
585
|
+
return null;
|
|
586
|
+
const scaleX = container.offsetWidth > 0 ? c.width / container.offsetWidth : 1;
|
|
587
|
+
const scaleY = container.offsetHeight > 0 ? c.height / container.offsetHeight : 1;
|
|
588
|
+
if (scaleX > 0 && scaleY > 0 && Number.isFinite(scaleX) && Number.isFinite(scaleY)) {
|
|
589
|
+
const scaleIsUnity = Math.abs(scaleX - 1) < 0.001 && Math.abs(scaleY - 1) < 0.001;
|
|
590
|
+
if (scaleIsUnity) {
|
|
591
|
+
const off = this.getRelativeOffsetToAncestor(target, container);
|
|
592
|
+
if (off) {
|
|
593
|
+
return {
|
|
594
|
+
x: off.x,
|
|
595
|
+
y: off.y,
|
|
596
|
+
width: target.offsetWidth,
|
|
597
|
+
height: target.offsetHeight,
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
const x = (r.left - c.left) / scaleX;
|
|
602
|
+
const y = (r.top - c.top) / scaleY;
|
|
603
|
+
let width = r.width / scaleX;
|
|
604
|
+
let height = r.height / scaleY;
|
|
605
|
+
const ow = target.offsetWidth;
|
|
606
|
+
const oh = target.offsetHeight;
|
|
607
|
+
if (ow > 0)
|
|
608
|
+
width = Math.min(width, ow);
|
|
609
|
+
if (oh > 0)
|
|
610
|
+
height = Math.min(height, oh);
|
|
611
|
+
return { x, y, width, height };
|
|
612
|
+
}
|
|
613
|
+
const offset = this.getRelativeOffsetToAncestor(target, container);
|
|
614
|
+
if (!offset)
|
|
615
|
+
return null;
|
|
616
|
+
return {
|
|
617
|
+
x: offset.x,
|
|
618
|
+
y: offset.y,
|
|
619
|
+
width: target.offsetWidth,
|
|
620
|
+
height: target.offsetHeight,
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
repositionIndicator(options) {
|
|
624
|
+
const currentTab = this.getActiveTab();
|
|
625
|
+
if (!currentTab || !this.indicator)
|
|
626
|
+
return;
|
|
627
|
+
const container = this.shadowRoot?.querySelector('.nav-tab-group__tabs');
|
|
628
|
+
if (!container)
|
|
629
|
+
return;
|
|
630
|
+
const target = currentTab.shadowRoot?.querySelector('.nav-tab-container');
|
|
631
|
+
if (!target)
|
|
632
|
+
return;
|
|
633
|
+
const skipTransition = options?.skipTransition === true;
|
|
634
|
+
if (skipTransition) {
|
|
635
|
+
this.indicator.style.transition = 'none';
|
|
636
|
+
}
|
|
637
|
+
const layoutBox = this.getLayoutBoxRelativeToContainer(target, container);
|
|
638
|
+
if (!layoutBox) {
|
|
639
|
+
if (skipTransition) {
|
|
640
|
+
requestAnimationFrame(() => {
|
|
641
|
+
if (this.indicator)
|
|
642
|
+
this.indicator.style.transition = '';
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
const x = layoutBox.x;
|
|
648
|
+
const y = layoutBox.y;
|
|
649
|
+
switch (this.placement) {
|
|
650
|
+
case 'top':
|
|
651
|
+
case 'bottom':
|
|
652
|
+
this.indicator.style.width = `${layoutBox.width}px`;
|
|
653
|
+
this.indicator.style.height = 'auto';
|
|
654
|
+
this.indicator.style.translate = `${x}px 0px`;
|
|
655
|
+
break;
|
|
656
|
+
case 'start':
|
|
657
|
+
case 'end':
|
|
658
|
+
this.indicator.style.width = 'auto';
|
|
659
|
+
this.indicator.style.height = `${layoutBox.height}px`;
|
|
660
|
+
this.indicator.style.translate = `0px ${y}px`;
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
if (skipTransition) {
|
|
664
|
+
requestAnimationFrame(() => {
|
|
665
|
+
requestAnimationFrame(() => {
|
|
666
|
+
if (this.indicator)
|
|
667
|
+
this.indicator.style.transition = '';
|
|
668
|
+
});
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
syncTabsAndPanels() {
|
|
673
|
+
this.tabs = this.getAllTabs({ includeDisabled: false });
|
|
674
|
+
this.panels = this.getAllPanels();
|
|
675
|
+
const allTabs = this.getAllTabs({ includeDisabled: true });
|
|
676
|
+
const enabledTabs = this.getAllTabs({ includeDisabled: false });
|
|
677
|
+
const size = enabledTabs.length;
|
|
678
|
+
const currentTabs = new Set(allTabs);
|
|
679
|
+
for (const tab of this.observedTabs) {
|
|
680
|
+
if (!currentTabs.has(tab)) {
|
|
681
|
+
this.resizeObserver.unobserve(tab);
|
|
682
|
+
this.observedTabs.delete(tab);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
allTabs.forEach(tab => {
|
|
686
|
+
tab.centered = this.centered;
|
|
687
|
+
if (tab.disabled) {
|
|
688
|
+
tab.removeAttribute('aria-posinset');
|
|
689
|
+
tab.removeAttribute('aria-setsize');
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
const i = enabledTabs.indexOf(tab);
|
|
693
|
+
tab.setAttribute('aria-posinset', String(i + 1));
|
|
694
|
+
tab.setAttribute('aria-setsize', String(size));
|
|
695
|
+
}
|
|
696
|
+
if (!this.observedTabs.has(tab)) {
|
|
697
|
+
this.resizeObserver.observe(tab);
|
|
698
|
+
this.observedTabs.add(tab);
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
this.setScrollControls();
|
|
702
|
+
this.setAriaLabels();
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
NileNavTabGroup.styles = styles;
|
|
706
|
+
__decorate([
|
|
707
|
+
query('.nav-tab-group')
|
|
708
|
+
], NileNavTabGroup.prototype, "tabGroup", void 0);
|
|
709
|
+
__decorate([
|
|
710
|
+
query('.nav-tab-group__body')
|
|
711
|
+
], NileNavTabGroup.prototype, "body", void 0);
|
|
712
|
+
__decorate([
|
|
713
|
+
query('.nav-tab-group__nav')
|
|
714
|
+
], NileNavTabGroup.prototype, "nav", void 0);
|
|
715
|
+
__decorate([
|
|
716
|
+
query('.nav-tab-group__indicator')
|
|
717
|
+
], NileNavTabGroup.prototype, "indicator", void 0);
|
|
718
|
+
__decorate([
|
|
719
|
+
query('.nav-tab-group__hover-indicator')
|
|
720
|
+
], NileNavTabGroup.prototype, "hoverIndicator", void 0);
|
|
721
|
+
__decorate([
|
|
722
|
+
property({ type: Boolean, reflect: true, attribute: true })
|
|
723
|
+
], NileNavTabGroup.prototype, "hasScrollControls", void 0);
|
|
724
|
+
__decorate([
|
|
725
|
+
property()
|
|
726
|
+
], NileNavTabGroup.prototype, "placement", void 0);
|
|
727
|
+
__decorate([
|
|
728
|
+
property({ reflect: true, attribute: 'value', type: String })
|
|
729
|
+
], NileNavTabGroup.prototype, "activeTabProp", void 0);
|
|
730
|
+
__decorate([
|
|
731
|
+
property({ type: Boolean, reflect: true, attribute: 'no-track' })
|
|
732
|
+
], NileNavTabGroup.prototype, "noTrack", void 0);
|
|
733
|
+
__decorate([
|
|
734
|
+
property({ attribute: 'no-scroll-controls', type: Boolean })
|
|
735
|
+
], NileNavTabGroup.prototype, "noScrollControls", void 0);
|
|
736
|
+
__decorate([
|
|
737
|
+
property({ type: Boolean, reflect: true })
|
|
738
|
+
], NileNavTabGroup.prototype, "centered", void 0);
|
|
739
|
+
__decorate([
|
|
740
|
+
property({ type: String, reflect: true })
|
|
741
|
+
], NileNavTabGroup.prototype, "variant", void 0);
|
|
742
|
+
__decorate([
|
|
743
|
+
property({ type: String, reflect: true })
|
|
744
|
+
], NileNavTabGroup.prototype, "indicatorPlacement", void 0);
|
|
745
|
+
__decorate([
|
|
746
|
+
property({ type: Boolean, reflect: true, attribute: true })
|
|
747
|
+
], NileNavTabGroup.prototype, "fullWidth", void 0);
|
|
748
|
+
__decorate([
|
|
749
|
+
property({ type: String, reflect: true })
|
|
750
|
+
], NileNavTabGroup.prototype, "width", void 0);
|
|
751
|
+
__decorate([
|
|
752
|
+
property({ type: Boolean, reflect: true, attribute: true })
|
|
753
|
+
], NileNavTabGroup.prototype, "showIndicatorOnHover", void 0);
|
|
754
|
+
__decorate([
|
|
755
|
+
state()
|
|
756
|
+
], NileNavTabGroup.prototype, "activeTabName", void 0);
|
|
757
|
+
__decorate([
|
|
758
|
+
watch('placement', { waitUntilFirstUpdate: true })
|
|
759
|
+
], NileNavTabGroup.prototype, "syncIndicator", null);
|
|
760
|
+
NileNavTabGroup = __decorate([
|
|
761
|
+
customElement('nile-nav-tab-group')
|
|
762
|
+
], NileNavTabGroup);
|
|
763
|
+
export { NileNavTabGroup };
|
|
764
|
+
export default NileNavTabGroup;
|
|
765
|
+
//# sourceMappingURL=nile-nav-tab-group.js.map
|