@digital-realty/ix-tabs 1.0.25 → 1.0.28-alpha.0
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/dist/IxPrimaryTab.d.ts +8 -8
- package/dist/IxPrimaryTab.js +21 -21
- package/dist/IxSecondaryTab.d.ts +7 -7
- package/dist/IxSecondaryTab.js +17 -17
- package/dist/IxTabs.d.ts +25 -25
- package/dist/IxTabs.js +118 -118
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/ix-primary-tab.d.ts +1 -1
- package/dist/ix-primary-tab.js +2 -2
- package/dist/ix-secondary-tab.d.ts +1 -1
- package/dist/ix-secondary-tab.js +2 -2
- package/dist/ix-tabs.d.ts +1 -1
- package/dist/ix-tabs.js +2 -2
- package/dist/ix-tabs.min.js +1 -1
- package/dist/mdtabs/internal/primary-tab.d.ts +20 -20
- package/dist/mdtabs/internal/primary-tab.js +29 -29
- package/dist/mdtabs/internal/secondary-tab.d.ts +12 -12
- package/dist/mdtabs/internal/secondary-tab.js +15 -15
- package/dist/mdtabs/internal/tab.d.ts +67 -67
- package/dist/mdtabs/internal/tab.js +188 -188
- package/dist/mdtabs/internal/tabs.d.ts +73 -73
- package/dist/mdtabs/internal/tabs.js +280 -280
- package/dist/mdtabs/primary-tab.d.ts +13 -13
- package/dist/mdtabs/primary-tab.js +28 -28
- package/dist/mdtabs/secondary-tab.d.ts +18 -18
- package/dist/mdtabs/secondary-tab.js +23 -23
- package/dist/mdtabs/tabs.d.ts +13 -13
- package/dist/mdtabs/tabs.js +26 -26
- package/dist/react/IxPrimaryTab.d.ts +2 -2
- package/dist/react/IxPrimaryTab.js +9 -9
- package/dist/react/IxSecondaryTab.d.ts +2 -2
- package/dist/react/IxSecondaryTab.js +9 -9
- package/dist/react/IxTabs.d.ts +2 -2
- package/dist/react/IxTabs.js +9 -9
- package/package.json +4 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { Tab } from './tab.js';
|
|
7
|
-
/**
|
|
8
|
-
* A secondary tab component.
|
|
9
|
-
*/
|
|
10
|
-
export declare class SecondaryTab extends Tab {
|
|
11
|
-
protected fullWidthIndicator: boolean;
|
|
12
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Tab } from './tab.js';
|
|
7
|
+
/**
|
|
8
|
+
* A secondary tab component.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SecondaryTab extends Tab {
|
|
11
|
+
protected fullWidthIndicator: boolean;
|
|
12
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { Tab } from './tab.js';
|
|
7
|
-
/**
|
|
8
|
-
* A secondary tab component.
|
|
9
|
-
*/
|
|
10
|
-
export class SecondaryTab extends Tab {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(...arguments);
|
|
13
|
-
this.fullWidthIndicator = true;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Tab } from './tab.js';
|
|
7
|
+
/**
|
|
8
|
+
* A secondary tab component.
|
|
9
|
+
*/
|
|
10
|
+
export class SecondaryTab extends Tab {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.fullWidthIndicator = true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
16
|
//# sourceMappingURL=secondary-tab.js.map
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import '@material/web/elevation/elevation.js';
|
|
7
|
-
import '@material/web/focus/md-focus-ring.js';
|
|
8
|
-
import '@material/web/ripple/ripple.js';
|
|
9
|
-
import { LitElement } from 'lit';
|
|
10
|
-
/**
|
|
11
|
-
* Symbol for tabs to use to animate their indicators based off another tab's
|
|
12
|
-
* indicator.
|
|
13
|
-
*/
|
|
14
|
-
declare const INDICATOR: unique symbol;
|
|
15
|
-
/**
|
|
16
|
-
* Symbol used by the tab bar to request a tab to animate its indicator from a
|
|
17
|
-
* previously selected tab.
|
|
18
|
-
*/
|
|
19
|
-
export declare const ANIMATE_INDICATOR: unique symbol;
|
|
20
|
-
/**
|
|
21
|
-
* Tab component.
|
|
22
|
-
*/
|
|
23
|
-
export declare class Tab extends LitElement {
|
|
24
|
-
/**
|
|
25
|
-
* The attribute `md-tab` indicates that the element is a tab for the parent
|
|
26
|
-
* element, `<md-tabs>`. Make sure if you're implementing your own `md-tab`
|
|
27
|
-
* component that you have an `md-tab` attribute set.
|
|
28
|
-
*/
|
|
29
|
-
readonly isTab = true;
|
|
30
|
-
/**
|
|
31
|
-
* Whether or not the tab is selected.
|
|
32
|
-
*/
|
|
33
|
-
active: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* TODO(b/293476210): remove after migrating
|
|
36
|
-
* @deprecated use `active`
|
|
37
|
-
*/
|
|
38
|
-
get selected(): boolean;
|
|
39
|
-
set selected(active: boolean);
|
|
40
|
-
/**
|
|
41
|
-
* In SSR, set this to true when an icon is present.
|
|
42
|
-
*/
|
|
43
|
-
hasIcon: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* In SSR, set this to true when there is no label and only an icon.
|
|
46
|
-
*/
|
|
47
|
-
iconOnly: boolean;
|
|
48
|
-
readonly [INDICATOR]: HTMLElement | null;
|
|
49
|
-
protected fullWidthIndicator: boolean;
|
|
50
|
-
private readonly assignedDefaultNodes;
|
|
51
|
-
private readonly assignedIcons;
|
|
52
|
-
private readonly internals;
|
|
53
|
-
constructor();
|
|
54
|
-
protected render(): import("lit").TemplateResult<1>;
|
|
55
|
-
protected getContentClasses(): {
|
|
56
|
-
'has-icon': boolean;
|
|
57
|
-
'has-label': boolean;
|
|
58
|
-
};
|
|
59
|
-
protected updated(): void;
|
|
60
|
-
private handleKeydown;
|
|
61
|
-
private handleContentClick;
|
|
62
|
-
[ANIMATE_INDICATOR](previousTab: Tab): void;
|
|
63
|
-
private getKeyframes;
|
|
64
|
-
private handleSlotChange;
|
|
65
|
-
private handleIconSlotChange;
|
|
66
|
-
}
|
|
67
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import '@material/web/elevation/elevation.js';
|
|
7
|
+
import '@material/web/focus/md-focus-ring.js';
|
|
8
|
+
import '@material/web/ripple/ripple.js';
|
|
9
|
+
import { LitElement } from 'lit';
|
|
10
|
+
/**
|
|
11
|
+
* Symbol for tabs to use to animate their indicators based off another tab's
|
|
12
|
+
* indicator.
|
|
13
|
+
*/
|
|
14
|
+
declare const INDICATOR: unique symbol;
|
|
15
|
+
/**
|
|
16
|
+
* Symbol used by the tab bar to request a tab to animate its indicator from a
|
|
17
|
+
* previously selected tab.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ANIMATE_INDICATOR: unique symbol;
|
|
20
|
+
/**
|
|
21
|
+
* Tab component.
|
|
22
|
+
*/
|
|
23
|
+
export declare class Tab extends LitElement {
|
|
24
|
+
/**
|
|
25
|
+
* The attribute `md-tab` indicates that the element is a tab for the parent
|
|
26
|
+
* element, `<md-tabs>`. Make sure if you're implementing your own `md-tab`
|
|
27
|
+
* component that you have an `md-tab` attribute set.
|
|
28
|
+
*/
|
|
29
|
+
readonly isTab = true;
|
|
30
|
+
/**
|
|
31
|
+
* Whether or not the tab is selected.
|
|
32
|
+
*/
|
|
33
|
+
active: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* TODO(b/293476210): remove after migrating
|
|
36
|
+
* @deprecated use `active`
|
|
37
|
+
*/
|
|
38
|
+
get selected(): boolean;
|
|
39
|
+
set selected(active: boolean);
|
|
40
|
+
/**
|
|
41
|
+
* In SSR, set this to true when an icon is present.
|
|
42
|
+
*/
|
|
43
|
+
hasIcon: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* In SSR, set this to true when there is no label and only an icon.
|
|
46
|
+
*/
|
|
47
|
+
iconOnly: boolean;
|
|
48
|
+
readonly [INDICATOR]: HTMLElement | null;
|
|
49
|
+
protected fullWidthIndicator: boolean;
|
|
50
|
+
private readonly assignedDefaultNodes;
|
|
51
|
+
private readonly assignedIcons;
|
|
52
|
+
private readonly internals;
|
|
53
|
+
constructor();
|
|
54
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
55
|
+
protected getContentClasses(): {
|
|
56
|
+
'has-icon': boolean;
|
|
57
|
+
'has-label': boolean;
|
|
58
|
+
};
|
|
59
|
+
protected updated(): void;
|
|
60
|
+
private handleKeydown;
|
|
61
|
+
private handleContentClick;
|
|
62
|
+
[ANIMATE_INDICATOR](previousTab: Tab): void;
|
|
63
|
+
private getKeyframes;
|
|
64
|
+
private handleSlotChange;
|
|
65
|
+
private handleIconSlotChange;
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
var _a;
|
|
7
|
-
import { __decorate } from "tslib";
|
|
8
|
-
import '@material/web/elevation/elevation.js';
|
|
9
|
-
import '@material/web/focus/md-focus-ring.js';
|
|
10
|
-
import '@material/web/ripple/ripple.js';
|
|
11
|
-
import { html, isServer, LitElement, nothing } from 'lit';
|
|
12
|
-
import { property, query, queryAssignedElements, queryAssignedNodes, state, } from 'lit/decorators.js';
|
|
13
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
14
|
-
import { EASING } from '@material/web/internal/motion/animation.js';
|
|
15
|
-
/**
|
|
16
|
-
* Symbol for tabs to use to animate their indicators based off another tab's
|
|
17
|
-
* indicator.
|
|
18
|
-
*/
|
|
19
|
-
const INDICATOR = Symbol('indicator');
|
|
20
|
-
/**
|
|
21
|
-
* Symbol used by the tab bar to request a tab to animate its indicator from a
|
|
22
|
-
* previously selected tab.
|
|
23
|
-
*/
|
|
24
|
-
export const ANIMATE_INDICATOR = Symbol('animateIndicator');
|
|
25
|
-
function shouldReduceMotion() {
|
|
26
|
-
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Tab component.
|
|
30
|
-
*/
|
|
31
|
-
export class Tab extends LitElement {
|
|
32
|
-
/**
|
|
33
|
-
* TODO(b/293476210): remove after migrating
|
|
34
|
-
* @deprecated use `active`
|
|
35
|
-
*/
|
|
36
|
-
get selected() {
|
|
37
|
-
return this.active;
|
|
38
|
-
}
|
|
39
|
-
set selected(active) {
|
|
40
|
-
this.active = active;
|
|
41
|
-
}
|
|
42
|
-
constructor() {
|
|
43
|
-
super();
|
|
44
|
-
/**
|
|
45
|
-
* The attribute `md-tab` indicates that the element is a tab for the parent
|
|
46
|
-
* element, `<md-tabs>`. Make sure if you're implementing your own `md-tab`
|
|
47
|
-
* component that you have an `md-tab` attribute set.
|
|
48
|
-
*/
|
|
49
|
-
this.isTab = true;
|
|
50
|
-
/**
|
|
51
|
-
* Whether or not the tab is selected.
|
|
52
|
-
*/
|
|
53
|
-
this.active = false;
|
|
54
|
-
/**
|
|
55
|
-
* In SSR, set this to true when an icon is present.
|
|
56
|
-
*/
|
|
57
|
-
this.hasIcon = false;
|
|
58
|
-
/**
|
|
59
|
-
* In SSR, set this to true when there is no label and only an icon.
|
|
60
|
-
*/
|
|
61
|
-
this.iconOnly = false;
|
|
62
|
-
this.fullWidthIndicator = true;
|
|
63
|
-
this.internals = this /* needed for closure */
|
|
64
|
-
.attachInternals();
|
|
65
|
-
if (!isServer) {
|
|
66
|
-
this.internals.role = 'tab';
|
|
67
|
-
this.addEventListener('keydown', this.handleKeydown.bind(this));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
render() {
|
|
71
|
-
const indicator = html `<div class="indicator"></div>`;
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
var _a;
|
|
7
|
+
import { __decorate } from "tslib";
|
|
8
|
+
import '@material/web/elevation/elevation.js';
|
|
9
|
+
import '@material/web/focus/md-focus-ring.js';
|
|
10
|
+
import '@material/web/ripple/ripple.js';
|
|
11
|
+
import { html, isServer, LitElement, nothing } from 'lit';
|
|
12
|
+
import { property, query, queryAssignedElements, queryAssignedNodes, state, } from 'lit/decorators.js';
|
|
13
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
14
|
+
import { EASING } from '@material/web/internal/motion/animation.js';
|
|
15
|
+
/**
|
|
16
|
+
* Symbol for tabs to use to animate their indicators based off another tab's
|
|
17
|
+
* indicator.
|
|
18
|
+
*/
|
|
19
|
+
const INDICATOR = Symbol('indicator');
|
|
20
|
+
/**
|
|
21
|
+
* Symbol used by the tab bar to request a tab to animate its indicator from a
|
|
22
|
+
* previously selected tab.
|
|
23
|
+
*/
|
|
24
|
+
export const ANIMATE_INDICATOR = Symbol('animateIndicator');
|
|
25
|
+
function shouldReduceMotion() {
|
|
26
|
+
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Tab component.
|
|
30
|
+
*/
|
|
31
|
+
export class Tab extends LitElement {
|
|
32
|
+
/**
|
|
33
|
+
* TODO(b/293476210): remove after migrating
|
|
34
|
+
* @deprecated use `active`
|
|
35
|
+
*/
|
|
36
|
+
get selected() {
|
|
37
|
+
return this.active;
|
|
38
|
+
}
|
|
39
|
+
set selected(active) {
|
|
40
|
+
this.active = active;
|
|
41
|
+
}
|
|
42
|
+
constructor() {
|
|
43
|
+
super();
|
|
44
|
+
/**
|
|
45
|
+
* The attribute `md-tab` indicates that the element is a tab for the parent
|
|
46
|
+
* element, `<md-tabs>`. Make sure if you're implementing your own `md-tab`
|
|
47
|
+
* component that you have an `md-tab` attribute set.
|
|
48
|
+
*/
|
|
49
|
+
this.isTab = true;
|
|
50
|
+
/**
|
|
51
|
+
* Whether or not the tab is selected.
|
|
52
|
+
*/
|
|
53
|
+
this.active = false;
|
|
54
|
+
/**
|
|
55
|
+
* In SSR, set this to true when an icon is present.
|
|
56
|
+
*/
|
|
57
|
+
this.hasIcon = false;
|
|
58
|
+
/**
|
|
59
|
+
* In SSR, set this to true when there is no label and only an icon.
|
|
60
|
+
*/
|
|
61
|
+
this.iconOnly = false;
|
|
62
|
+
this.fullWidthIndicator = true;
|
|
63
|
+
this.internals = this /* needed for closure */
|
|
64
|
+
.attachInternals();
|
|
65
|
+
if (!isServer) {
|
|
66
|
+
this.internals.role = 'tab';
|
|
67
|
+
this.addEventListener('keydown', this.handleKeydown.bind(this));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
render() {
|
|
71
|
+
const indicator = html `<div class="indicator"></div>`;
|
|
72
72
|
return html ` <div
|
|
73
73
|
class="button"
|
|
74
74
|
role="presentation"
|
|
@@ -86,121 +86,121 @@ export class Tab extends LitElement {
|
|
|
86
86
|
${this.fullWidthIndicator ? nothing : indicator}
|
|
87
87
|
</div>
|
|
88
88
|
${this.fullWidthIndicator ? indicator : nothing}
|
|
89
|
-
</div>`;
|
|
90
|
-
}
|
|
91
|
-
getContentClasses() {
|
|
92
|
-
return {
|
|
93
|
-
'has-icon': this.hasIcon,
|
|
94
|
-
'has-label': !this.iconOnly,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
updated() {
|
|
98
|
-
this.internals.ariaSelected = String(this.active);
|
|
99
|
-
}
|
|
100
|
-
async handleKeydown(event) {
|
|
101
|
-
// Allow event to bubble.
|
|
102
|
-
await 0;
|
|
103
|
-
if (event.defaultPrevented) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
107
|
-
// Prevent default behavior such as scrolling when pressing spacebar.
|
|
108
|
-
event.preventDefault();
|
|
109
|
-
this.click();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
handleContentClick(event) {
|
|
113
|
-
// Ensure the "click" target is always the tab, and not content, by stopping
|
|
114
|
-
// propagation of content clicks and re-clicking the host.
|
|
115
|
-
event.stopPropagation();
|
|
116
|
-
this.click();
|
|
117
|
-
}
|
|
118
|
-
[(_a = INDICATOR, ANIMATE_INDICATOR)](previousTab) {
|
|
119
|
-
var _b;
|
|
120
|
-
if (!this[INDICATOR]) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
this[INDICATOR].getAnimations().forEach(a => {
|
|
124
|
-
a.cancel();
|
|
125
|
-
});
|
|
126
|
-
const previousTabInner = (_b = previousTab === null || previousTab === void 0 ? void 0 : previousTab.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('*');
|
|
127
|
-
const frames = this.getKeyframes(previousTabInner);
|
|
128
|
-
if (frames !== null) {
|
|
129
|
-
this[INDICATOR].animate(frames, {
|
|
130
|
-
duration: 250,
|
|
131
|
-
easing: EASING.EMPHASIZED,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
getKeyframes(previousTab) {
|
|
136
|
-
var _b, _c;
|
|
137
|
-
const reduceMotion = shouldReduceMotion();
|
|
138
|
-
if (!this.active) {
|
|
139
|
-
return reduceMotion ? [{ opacity: 1 }, { transform: 'none' }] : null;
|
|
140
|
-
}
|
|
141
|
-
const from = {};
|
|
142
|
-
const fromRect = (_c = (_b = previousTab[INDICATOR]) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()) !== null && _c !== void 0 ? _c : {};
|
|
143
|
-
const fromPos = fromRect.left;
|
|
144
|
-
const fromExtent = fromRect.width;
|
|
145
|
-
const toRect = this[INDICATOR].getBoundingClientRect();
|
|
146
|
-
const toPos = toRect.left;
|
|
147
|
-
const toExtent = toRect.width;
|
|
148
|
-
const scale = fromExtent / toExtent;
|
|
149
|
-
if (!reduceMotion &&
|
|
150
|
-
fromPos !== undefined &&
|
|
151
|
-
toPos !== undefined &&
|
|
152
|
-
Number(scale)) {
|
|
153
|
-
from.transform = `translateX(${(fromPos - toPos).toFixed(4)}px) scaleX(${scale.toFixed(4)})`;
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
from.opacity = 0;
|
|
157
|
-
}
|
|
158
|
-
// note, including `transform: none` avoids quirky Safari behavior
|
|
159
|
-
// that can hide the animation.
|
|
160
|
-
return [from, { transform: 'none' }];
|
|
161
|
-
}
|
|
162
|
-
handleSlotChange() {
|
|
163
|
-
this.iconOnly = false;
|
|
164
|
-
// Check if there's any label text or elements. If not, then there is only
|
|
165
|
-
// an icon.
|
|
166
|
-
for (const node of this.assignedDefaultNodes) {
|
|
167
|
-
const hasTextContent = node.nodeType === Node.TEXT_NODE &&
|
|
168
|
-
!!node.wholeText.match(/\S/);
|
|
169
|
-
if (node.nodeType === Node.ELEMENT_NODE || hasTextContent) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
this.iconOnly = true;
|
|
174
|
-
}
|
|
175
|
-
handleIconSlotChange() {
|
|
176
|
-
this.hasIcon = this.assignedIcons.length > 0;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
__decorate([
|
|
180
|
-
property({ type: Boolean, reflect: true, attribute: 'md-tab' })
|
|
181
|
-
], Tab.prototype, "isTab", void 0);
|
|
182
|
-
__decorate([
|
|
183
|
-
property({ type: Boolean, reflect: true })
|
|
184
|
-
], Tab.prototype, "active", void 0);
|
|
185
|
-
__decorate([
|
|
186
|
-
property({ type: Boolean })
|
|
187
|
-
], Tab.prototype, "selected", null);
|
|
188
|
-
__decorate([
|
|
189
|
-
property({ type: Boolean, attribute: 'has-icon' })
|
|
190
|
-
], Tab.prototype, "hasIcon", void 0);
|
|
191
|
-
__decorate([
|
|
192
|
-
property({ type: Boolean, attribute: 'icon-only' })
|
|
193
|
-
], Tab.prototype, "iconOnly", void 0);
|
|
194
|
-
__decorate([
|
|
195
|
-
query('.indicator')
|
|
196
|
-
], Tab.prototype, _a, void 0);
|
|
197
|
-
__decorate([
|
|
198
|
-
state()
|
|
199
|
-
], Tab.prototype, "fullWidthIndicator", void 0);
|
|
200
|
-
__decorate([
|
|
201
|
-
queryAssignedNodes({ flatten: true })
|
|
202
|
-
], Tab.prototype, "assignedDefaultNodes", void 0);
|
|
203
|
-
__decorate([
|
|
204
|
-
queryAssignedElements({ slot: 'icon', flatten: true })
|
|
205
|
-
], Tab.prototype, "assignedIcons", void 0);
|
|
89
|
+
</div>`;
|
|
90
|
+
}
|
|
91
|
+
getContentClasses() {
|
|
92
|
+
return {
|
|
93
|
+
'has-icon': this.hasIcon,
|
|
94
|
+
'has-label': !this.iconOnly,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
updated() {
|
|
98
|
+
this.internals.ariaSelected = String(this.active);
|
|
99
|
+
}
|
|
100
|
+
async handleKeydown(event) {
|
|
101
|
+
// Allow event to bubble.
|
|
102
|
+
await 0;
|
|
103
|
+
if (event.defaultPrevented) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
107
|
+
// Prevent default behavior such as scrolling when pressing spacebar.
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
this.click();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
handleContentClick(event) {
|
|
113
|
+
// Ensure the "click" target is always the tab, and not content, by stopping
|
|
114
|
+
// propagation of content clicks and re-clicking the host.
|
|
115
|
+
event.stopPropagation();
|
|
116
|
+
this.click();
|
|
117
|
+
}
|
|
118
|
+
[(_a = INDICATOR, ANIMATE_INDICATOR)](previousTab) {
|
|
119
|
+
var _b;
|
|
120
|
+
if (!this[INDICATOR]) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this[INDICATOR].getAnimations().forEach(a => {
|
|
124
|
+
a.cancel();
|
|
125
|
+
});
|
|
126
|
+
const previousTabInner = (_b = previousTab === null || previousTab === void 0 ? void 0 : previousTab.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('*');
|
|
127
|
+
const frames = this.getKeyframes(previousTabInner);
|
|
128
|
+
if (frames !== null) {
|
|
129
|
+
this[INDICATOR].animate(frames, {
|
|
130
|
+
duration: 250,
|
|
131
|
+
easing: EASING.EMPHASIZED,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
getKeyframes(previousTab) {
|
|
136
|
+
var _b, _c;
|
|
137
|
+
const reduceMotion = shouldReduceMotion();
|
|
138
|
+
if (!this.active) {
|
|
139
|
+
return reduceMotion ? [{ opacity: 1 }, { transform: 'none' }] : null;
|
|
140
|
+
}
|
|
141
|
+
const from = {};
|
|
142
|
+
const fromRect = (_c = (_b = previousTab[INDICATOR]) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()) !== null && _c !== void 0 ? _c : {};
|
|
143
|
+
const fromPos = fromRect.left;
|
|
144
|
+
const fromExtent = fromRect.width;
|
|
145
|
+
const toRect = this[INDICATOR].getBoundingClientRect();
|
|
146
|
+
const toPos = toRect.left;
|
|
147
|
+
const toExtent = toRect.width;
|
|
148
|
+
const scale = fromExtent / toExtent;
|
|
149
|
+
if (!reduceMotion &&
|
|
150
|
+
fromPos !== undefined &&
|
|
151
|
+
toPos !== undefined &&
|
|
152
|
+
Number(scale)) {
|
|
153
|
+
from.transform = `translateX(${(fromPos - toPos).toFixed(4)}px) scaleX(${scale.toFixed(4)})`;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
from.opacity = 0;
|
|
157
|
+
}
|
|
158
|
+
// note, including `transform: none` avoids quirky Safari behavior
|
|
159
|
+
// that can hide the animation.
|
|
160
|
+
return [from, { transform: 'none' }];
|
|
161
|
+
}
|
|
162
|
+
handleSlotChange() {
|
|
163
|
+
this.iconOnly = false;
|
|
164
|
+
// Check if there's any label text or elements. If not, then there is only
|
|
165
|
+
// an icon.
|
|
166
|
+
for (const node of this.assignedDefaultNodes) {
|
|
167
|
+
const hasTextContent = node.nodeType === Node.TEXT_NODE &&
|
|
168
|
+
!!node.wholeText.match(/\S/);
|
|
169
|
+
if (node.nodeType === Node.ELEMENT_NODE || hasTextContent) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
this.iconOnly = true;
|
|
174
|
+
}
|
|
175
|
+
handleIconSlotChange() {
|
|
176
|
+
this.hasIcon = this.assignedIcons.length > 0;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
__decorate([
|
|
180
|
+
property({ type: Boolean, reflect: true, attribute: 'md-tab' })
|
|
181
|
+
], Tab.prototype, "isTab", void 0);
|
|
182
|
+
__decorate([
|
|
183
|
+
property({ type: Boolean, reflect: true })
|
|
184
|
+
], Tab.prototype, "active", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
property({ type: Boolean })
|
|
187
|
+
], Tab.prototype, "selected", null);
|
|
188
|
+
__decorate([
|
|
189
|
+
property({ type: Boolean, attribute: 'has-icon' })
|
|
190
|
+
], Tab.prototype, "hasIcon", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
property({ type: Boolean, attribute: 'icon-only' })
|
|
193
|
+
], Tab.prototype, "iconOnly", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
query('.indicator')
|
|
196
|
+
], Tab.prototype, _a, void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
state()
|
|
199
|
+
], Tab.prototype, "fullWidthIndicator", void 0);
|
|
200
|
+
__decorate([
|
|
201
|
+
queryAssignedNodes({ flatten: true })
|
|
202
|
+
], Tab.prototype, "assignedDefaultNodes", void 0);
|
|
203
|
+
__decorate([
|
|
204
|
+
queryAssignedElements({ slot: 'icon', flatten: true })
|
|
205
|
+
], Tab.prototype, "assignedIcons", void 0);
|
|
206
206
|
//# sourceMappingURL=tab.js.map
|