@momentum-design/components 0.22.2 → 0.22.3
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/browser/index.js +340 -84
- package/dist/browser/index.js.map +4 -4
- package/dist/components/buttonsimple/buttonsimple.component.d.ts +5 -6
- package/dist/components/buttonsimple/buttonsimple.component.js +9 -9
- package/dist/components/tab/index.d.ts +9 -0
- package/dist/components/tab/index.js +6 -0
- package/dist/components/tab/tab.component.d.ts +128 -0
- package/dist/components/tab/tab.component.js +180 -0
- package/dist/components/tab/tab.constants.d.ts +10 -0
- package/dist/components/tab/tab.constants.js +11 -0
- package/dist/components/tab/tab.styles.d.ts +2 -0
- package/dist/components/tab/tab.styles.js +247 -0
- package/dist/components/tab/tab.types.d.ts +3 -0
- package/dist/components/tab/tab.types.js +1 -0
- package/dist/custom-elements.json +905 -253
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/react/tab/index.d.ts +82 -0
- package/dist/react/tab/index.js +91 -0
- package/package.json +1 -1
@@ -63,14 +63,13 @@ declare class Buttonsimple extends Buttonsimple_base {
|
|
63
63
|
get form(): HTMLFormElement | null;
|
64
64
|
constructor();
|
65
65
|
update(changedProperties: PropertyValues): void;
|
66
|
-
|
66
|
+
protected executeAction(): void;
|
67
67
|
/**
|
68
|
-
* Sets the aria-pressed attribute based on the active state.
|
69
|
-
*
|
70
|
-
* @param
|
71
|
-
* @param active - The active state.
|
68
|
+
* Sets the aria-pressed attribute based on the active state of the button.
|
69
|
+
* @param element - The button element
|
70
|
+
* @param active - The active state of the element
|
72
71
|
*/
|
73
|
-
|
72
|
+
protected setActive(element: HTMLElement, active: boolean): void;
|
74
73
|
/**
|
75
74
|
* Sets the soft-disabled attribute for the button.
|
76
75
|
* When soft-disabled, the button looks to be disabled but remains focusable and clickable.
|
@@ -87,7 +87,7 @@ class Buttonsimple extends TabIndexMixin(DisabledMixin(Component)) {
|
|
87
87
|
this.setSoftDisabled(this, this.softDisabled);
|
88
88
|
}
|
89
89
|
if (changedProperties.has('active')) {
|
90
|
-
this.
|
90
|
+
this.setActive(this, this.active);
|
91
91
|
}
|
92
92
|
}
|
93
93
|
executeAction() {
|
@@ -99,12 +99,11 @@ class Buttonsimple extends TabIndexMixin(DisabledMixin(Component)) {
|
|
99
99
|
}
|
100
100
|
}
|
101
101
|
/**
|
102
|
-
* Sets the aria-pressed attribute based on the active state.
|
103
|
-
*
|
104
|
-
* @param
|
105
|
-
* @param active - The active state.
|
102
|
+
* Sets the aria-pressed attribute based on the active state of the button.
|
103
|
+
* @param element - The button element
|
104
|
+
* @param active - The active state of the element
|
106
105
|
*/
|
107
|
-
|
106
|
+
setActive(element, active) {
|
108
107
|
if (active) {
|
109
108
|
element.setAttribute('aria-pressed', 'true');
|
110
109
|
}
|
@@ -144,7 +143,9 @@ class Buttonsimple extends TabIndexMixin(DisabledMixin(Component)) {
|
|
144
143
|
this.tabIndex = -1;
|
145
144
|
}
|
146
145
|
else {
|
147
|
-
this.tabIndex
|
146
|
+
if (this.tabIndex === -1) {
|
147
|
+
this.tabIndex = this.prevTabindex;
|
148
|
+
}
|
148
149
|
element.removeAttribute('aria-disabled');
|
149
150
|
}
|
150
151
|
}
|
@@ -155,7 +156,6 @@ class Buttonsimple extends TabIndexMixin(DisabledMixin(Component)) {
|
|
155
156
|
view: window,
|
156
157
|
});
|
157
158
|
this.dispatchEvent(clickEvent);
|
158
|
-
this.executeAction();
|
159
159
|
}
|
160
160
|
/**
|
161
161
|
* Handles the keydown event on the button.
|
@@ -197,7 +197,7 @@ class Buttonsimple extends TabIndexMixin(DisabledMixin(Component)) {
|
|
197
197
|
Buttonsimple.formAssociated = true;
|
198
198
|
Buttonsimple.styles = [...Component.styles, ...styles];
|
199
199
|
__decorate([
|
200
|
-
property({ type: Boolean }),
|
200
|
+
property({ type: Boolean, reflect: true }),
|
201
201
|
__metadata("design:type", Object)
|
202
202
|
], Buttonsimple.prototype, "active", void 0);
|
203
203
|
__decorate([
|
@@ -0,0 +1,128 @@
|
|
1
|
+
import { CSSResult } from 'lit';
|
2
|
+
import { Variant } from './tab.types';
|
3
|
+
import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
4
|
+
declare const Tab_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & typeof Buttonsimple;
|
5
|
+
/**
|
6
|
+
* `mdc-tab` is Tab component to be used within the Tabgroup.
|
7
|
+
*
|
8
|
+
* Passing in the attribute `text` to the tab component is changing the text displayed in the tab.
|
9
|
+
*
|
10
|
+
* The `slot="badge"` can be used to add a badge to the tab.
|
11
|
+
*
|
12
|
+
* For `icon`, the `mdc-icon` component is used to render the icon.
|
13
|
+
*
|
14
|
+
* @dependency mdc-icon
|
15
|
+
* @dependency mdc-text
|
16
|
+
*
|
17
|
+
* @tagname mdc-tab
|
18
|
+
*
|
19
|
+
* @cssproperty --mdc-tab-content-gap - Gap between the badge(if provided), icon and text.
|
20
|
+
* @cssproperty --mdc-tab-height - Height of the tab.
|
21
|
+
* @cssproperty --mdc-tab-glass-active-background-color-disabled - Background color for active glass tab
|
22
|
+
* in disabled state.
|
23
|
+
* @cssproperty --mdc-tab-glass-active-background-color-hover - Background color for active glass tab in hover state.
|
24
|
+
* @cssproperty --mdc-tab-glass-active-background-color-normal - Background color for active glass tab in rest state.
|
25
|
+
* @cssproperty --mdc-tab-glass-active-background-color-pressed - Background color for active glass tab
|
26
|
+
* in pressed state.
|
27
|
+
* @cssproperty --mdc-tab-glass-active-color - Text and icon color for active glass tab.
|
28
|
+
* @cssproperty --mdc-tab-glass-active-color-disabled - Text and icon color for active glass tab in disabled state.
|
29
|
+
* @cssproperty --mdc-tab-glass-border-radius - Border radius for glass tab.
|
30
|
+
* @cssproperty --mdc-tab-glass-inactive-background-color-disabled - Background color for inactive glass tab
|
31
|
+
* in disabled state.
|
32
|
+
* @cssproperty --mdc-tab-glass-inactive-background-color-hover - Background color for inactive glass tab
|
33
|
+
* in hover state.
|
34
|
+
* @cssproperty --mdc-tab-glass-inactive-background-color-normal - Background color for inactive glass tab
|
35
|
+
* in rest state.
|
36
|
+
* @cssproperty --mdc-tab-glass-inactive-background-color-pressed - Background color for inactive glass tab
|
37
|
+
* in pressed state.
|
38
|
+
* @cssproperty --mdc-tab-glass-inactive-color - Text and icon color for inactive glass tab.
|
39
|
+
* @cssproperty --mdc-tab-glass-inactive-color-disabled - Text and icon color for inactive glass tab in disabled state.
|
40
|
+
* @cssproperty --mdc-tab-line-active-background-color-pressed - Background color for active line tab in pressed state.
|
41
|
+
* @cssproperty --mdc-tab-line-active-background-color-disabled - Background color for active line tab
|
42
|
+
* in disabled state.
|
43
|
+
* @cssproperty --mdc-tab-line-active-background-color-hover - Background color for active line tab in hover state.
|
44
|
+
* @cssproperty --mdc-tab-line-active-background-color-normal - Background color for active line tab in rest state.
|
45
|
+
* @cssproperty --mdc-tab-line-active-color - Text and icon color for active line tab.
|
46
|
+
* @cssproperty --mdc-tab-line-active-color-disabled - Text and icon color for active line tab in disabled state.
|
47
|
+
* @cssproperty --mdc-tab-line-active-indicator-color - color for indicator in active line tab.
|
48
|
+
* @cssproperty --mdc-tab-line-active-indicator-color-disabled - Color for indicator in active line tab
|
49
|
+
* in disabled state.
|
50
|
+
* @cssproperty --mdc-tab-line-active-indicator-height - Height for indicator in active line tab.
|
51
|
+
* @cssproperty --mdc-tab-line-active-indicator-width - Width for indicator in active line tab.
|
52
|
+
* @cssproperty --mdc-tab-line-border-bottom-left-radius - Bottom left border radius for line tab.
|
53
|
+
* @cssproperty --mdc-tab-line-border-bottom-right-radius - Bottom right border radius for line tab.
|
54
|
+
* @cssproperty --mdc-tab-line-border-top-left-radius - Top left border radius for line tab.
|
55
|
+
* @cssproperty --mdc-tab-line-border-top-right-radius - Top right border radius for line tab.
|
56
|
+
* @cssproperty --mdc-tab-line-inactive-background-color-pressed - Background color for inactive line tab
|
57
|
+
* in pressed state.
|
58
|
+
* @cssproperty --mdc-tab-line-inactive-background-color-disabled - Background color for inactive line tab
|
59
|
+
* in disabled state
|
60
|
+
* @cssproperty --mdc-tab-line-inactive-background-color-hover - Background color for inactive line tab in hover state.
|
61
|
+
* @cssproperty --mdc-tab-line-inactive-background-color-normal - Background color for inactive line tab
|
62
|
+
* in rest state.
|
63
|
+
* @cssproperty --mdc-tab-line-inactive-color - Text and icon color for inactive line tab.
|
64
|
+
* @cssproperty --mdc-tab-line-inactive-color-disabled - Text and icon color for inactive line tab in disabled state.
|
65
|
+
* @cssproperty --mdc-tab-padding-left - Padding left for the tab.
|
66
|
+
* @cssproperty --mdc-tab-padding-right - Padding right for the tab.
|
67
|
+
* @cssproperty --mdc-tab-pill-active-background-color-pressed - Background color for active pill tab in pressed state.
|
68
|
+
* @cssproperty --mdc-tab-pill-active-background-color-disabled - Background color for active pill tab
|
69
|
+
* in disabled state.
|
70
|
+
* @cssproperty --mdc-tab-pill-active-background-color-hover - Background color for active pill tab in hover state.
|
71
|
+
* @cssproperty --mdc-tab-pill-active-background-color-normal - Background color for active pill tab in rest state.
|
72
|
+
* @cssproperty --mdc-tab-pill-active-color - Text and icon color for active pill tab.
|
73
|
+
* @cssproperty --mdc-tab-pill-active-color-disabled - Text and icon color for active pill tab in disabled state.
|
74
|
+
* @cssproperty --mdc-tab-pill-border-radius - Border radius for pill tab.
|
75
|
+
* @cssproperty --mdc-tab-pill-inactive-background-color-pressed - Background color for inactive pill tab
|
76
|
+
* in pressed state.
|
77
|
+
* @cssproperty --mdc-tab-pill-inactive-background-color-disabled - Background color for inactive pill tab
|
78
|
+
* in disabled state.
|
79
|
+
* @cssproperty --mdc-tab-pill-inactive-background-color-hover - Background color for inactive pill tab in hover state.
|
80
|
+
* @cssproperty --mdc-tab-pill-inactive-background-color-normal - Background color for inactive pill tab in rest state.
|
81
|
+
* @cssproperty --mdc-tab-pill-inactive-color - Text and icon color for inactive pill tab.
|
82
|
+
* @cssproperty --mdc-tab-pill-inactive-color-disabled - Text and icon color for inactive pill tab in disabled state.
|
83
|
+
*/
|
84
|
+
declare class Tab extends Tab_base {
|
85
|
+
/**
|
86
|
+
* Text to be displayed in the tab.
|
87
|
+
* If no `text` is provided, no text will be rendered,
|
88
|
+
* `aria-label` should be set on the tab.
|
89
|
+
*/
|
90
|
+
text?: string;
|
91
|
+
/**
|
92
|
+
* Tab can have two variants:
|
93
|
+
* - `glass`
|
94
|
+
* - `line`
|
95
|
+
* - `pill`
|
96
|
+
*
|
97
|
+
* It defines the background and foreground color of the tab.
|
98
|
+
* @default pill
|
99
|
+
*/
|
100
|
+
variant: Variant;
|
101
|
+
/**
|
102
|
+
* @internal
|
103
|
+
*/
|
104
|
+
private prevIconName?;
|
105
|
+
constructor();
|
106
|
+
/**
|
107
|
+
* Modifies the icon name based on the active state.
|
108
|
+
* If the tab is active, the icon name is suffixed with '-filled'.
|
109
|
+
* If the tab is inactive, the icon name is restored to its original value.
|
110
|
+
* If '-filled' icon is not available, the icon name remains unchanged.
|
111
|
+
*
|
112
|
+
* @param active - The active state.
|
113
|
+
*/
|
114
|
+
private modifyIconName;
|
115
|
+
/**
|
116
|
+
* Sets the aria-selected attribute based on the active state of the Tab.
|
117
|
+
* If the tab is active, the filled version of the icon is displayed,
|
118
|
+
* else the icon is restored to its original value.
|
119
|
+
*
|
120
|
+
* @param element - The tab element.
|
121
|
+
* @param active - The active state of the tab.
|
122
|
+
*/
|
123
|
+
protected setActive(element: HTMLElement, active: boolean): void;
|
124
|
+
protected executeAction(): void;
|
125
|
+
render(): import("lit-html").TemplateResult<1>;
|
126
|
+
static styles: Array<CSSResult>;
|
127
|
+
}
|
128
|
+
export default Tab;
|
@@ -0,0 +1,180 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html, nothing } from 'lit';
|
11
|
+
import { property } from 'lit/decorators.js';
|
12
|
+
import styles from './tab.styles';
|
13
|
+
import { DEFAULTS } from './tab.constants';
|
14
|
+
import { getIconNameWithoutStyle } from '../button/button.utils';
|
15
|
+
import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
16
|
+
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
17
|
+
import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
|
18
|
+
/**
|
19
|
+
* `mdc-tab` is Tab component to be used within the Tabgroup.
|
20
|
+
*
|
21
|
+
* Passing in the attribute `text` to the tab component is changing the text displayed in the tab.
|
22
|
+
*
|
23
|
+
* The `slot="badge"` can be used to add a badge to the tab.
|
24
|
+
*
|
25
|
+
* For `icon`, the `mdc-icon` component is used to render the icon.
|
26
|
+
*
|
27
|
+
* @dependency mdc-icon
|
28
|
+
* @dependency mdc-text
|
29
|
+
*
|
30
|
+
* @tagname mdc-tab
|
31
|
+
*
|
32
|
+
* @cssproperty --mdc-tab-content-gap - Gap between the badge(if provided), icon and text.
|
33
|
+
* @cssproperty --mdc-tab-height - Height of the tab.
|
34
|
+
* @cssproperty --mdc-tab-glass-active-background-color-disabled - Background color for active glass tab
|
35
|
+
* in disabled state.
|
36
|
+
* @cssproperty --mdc-tab-glass-active-background-color-hover - Background color for active glass tab in hover state.
|
37
|
+
* @cssproperty --mdc-tab-glass-active-background-color-normal - Background color for active glass tab in rest state.
|
38
|
+
* @cssproperty --mdc-tab-glass-active-background-color-pressed - Background color for active glass tab
|
39
|
+
* in pressed state.
|
40
|
+
* @cssproperty --mdc-tab-glass-active-color - Text and icon color for active glass tab.
|
41
|
+
* @cssproperty --mdc-tab-glass-active-color-disabled - Text and icon color for active glass tab in disabled state.
|
42
|
+
* @cssproperty --mdc-tab-glass-border-radius - Border radius for glass tab.
|
43
|
+
* @cssproperty --mdc-tab-glass-inactive-background-color-disabled - Background color for inactive glass tab
|
44
|
+
* in disabled state.
|
45
|
+
* @cssproperty --mdc-tab-glass-inactive-background-color-hover - Background color for inactive glass tab
|
46
|
+
* in hover state.
|
47
|
+
* @cssproperty --mdc-tab-glass-inactive-background-color-normal - Background color for inactive glass tab
|
48
|
+
* in rest state.
|
49
|
+
* @cssproperty --mdc-tab-glass-inactive-background-color-pressed - Background color for inactive glass tab
|
50
|
+
* in pressed state.
|
51
|
+
* @cssproperty --mdc-tab-glass-inactive-color - Text and icon color for inactive glass tab.
|
52
|
+
* @cssproperty --mdc-tab-glass-inactive-color-disabled - Text and icon color for inactive glass tab in disabled state.
|
53
|
+
* @cssproperty --mdc-tab-line-active-background-color-pressed - Background color for active line tab in pressed state.
|
54
|
+
* @cssproperty --mdc-tab-line-active-background-color-disabled - Background color for active line tab
|
55
|
+
* in disabled state.
|
56
|
+
* @cssproperty --mdc-tab-line-active-background-color-hover - Background color for active line tab in hover state.
|
57
|
+
* @cssproperty --mdc-tab-line-active-background-color-normal - Background color for active line tab in rest state.
|
58
|
+
* @cssproperty --mdc-tab-line-active-color - Text and icon color for active line tab.
|
59
|
+
* @cssproperty --mdc-tab-line-active-color-disabled - Text and icon color for active line tab in disabled state.
|
60
|
+
* @cssproperty --mdc-tab-line-active-indicator-color - color for indicator in active line tab.
|
61
|
+
* @cssproperty --mdc-tab-line-active-indicator-color-disabled - Color for indicator in active line tab
|
62
|
+
* in disabled state.
|
63
|
+
* @cssproperty --mdc-tab-line-active-indicator-height - Height for indicator in active line tab.
|
64
|
+
* @cssproperty --mdc-tab-line-active-indicator-width - Width for indicator in active line tab.
|
65
|
+
* @cssproperty --mdc-tab-line-border-bottom-left-radius - Bottom left border radius for line tab.
|
66
|
+
* @cssproperty --mdc-tab-line-border-bottom-right-radius - Bottom right border radius for line tab.
|
67
|
+
* @cssproperty --mdc-tab-line-border-top-left-radius - Top left border radius for line tab.
|
68
|
+
* @cssproperty --mdc-tab-line-border-top-right-radius - Top right border radius for line tab.
|
69
|
+
* @cssproperty --mdc-tab-line-inactive-background-color-pressed - Background color for inactive line tab
|
70
|
+
* in pressed state.
|
71
|
+
* @cssproperty --mdc-tab-line-inactive-background-color-disabled - Background color for inactive line tab
|
72
|
+
* in disabled state
|
73
|
+
* @cssproperty --mdc-tab-line-inactive-background-color-hover - Background color for inactive line tab in hover state.
|
74
|
+
* @cssproperty --mdc-tab-line-inactive-background-color-normal - Background color for inactive line tab
|
75
|
+
* in rest state.
|
76
|
+
* @cssproperty --mdc-tab-line-inactive-color - Text and icon color for inactive line tab.
|
77
|
+
* @cssproperty --mdc-tab-line-inactive-color-disabled - Text and icon color for inactive line tab in disabled state.
|
78
|
+
* @cssproperty --mdc-tab-padding-left - Padding left for the tab.
|
79
|
+
* @cssproperty --mdc-tab-padding-right - Padding right for the tab.
|
80
|
+
* @cssproperty --mdc-tab-pill-active-background-color-pressed - Background color for active pill tab in pressed state.
|
81
|
+
* @cssproperty --mdc-tab-pill-active-background-color-disabled - Background color for active pill tab
|
82
|
+
* in disabled state.
|
83
|
+
* @cssproperty --mdc-tab-pill-active-background-color-hover - Background color for active pill tab in hover state.
|
84
|
+
* @cssproperty --mdc-tab-pill-active-background-color-normal - Background color for active pill tab in rest state.
|
85
|
+
* @cssproperty --mdc-tab-pill-active-color - Text and icon color for active pill tab.
|
86
|
+
* @cssproperty --mdc-tab-pill-active-color-disabled - Text and icon color for active pill tab in disabled state.
|
87
|
+
* @cssproperty --mdc-tab-pill-border-radius - Border radius for pill tab.
|
88
|
+
* @cssproperty --mdc-tab-pill-inactive-background-color-pressed - Background color for inactive pill tab
|
89
|
+
* in pressed state.
|
90
|
+
* @cssproperty --mdc-tab-pill-inactive-background-color-disabled - Background color for inactive pill tab
|
91
|
+
* in disabled state.
|
92
|
+
* @cssproperty --mdc-tab-pill-inactive-background-color-hover - Background color for inactive pill tab in hover state.
|
93
|
+
* @cssproperty --mdc-tab-pill-inactive-background-color-normal - Background color for inactive pill tab in rest state.
|
94
|
+
* @cssproperty --mdc-tab-pill-inactive-color - Text and icon color for inactive pill tab.
|
95
|
+
* @cssproperty --mdc-tab-pill-inactive-color-disabled - Text and icon color for inactive pill tab in disabled state.
|
96
|
+
*/
|
97
|
+
class Tab extends IconNameMixin(Buttonsimple) {
|
98
|
+
constructor() {
|
99
|
+
super();
|
100
|
+
/**
|
101
|
+
* Tab can have two variants:
|
102
|
+
* - `glass`
|
103
|
+
* - `line`
|
104
|
+
* - `pill`
|
105
|
+
*
|
106
|
+
* It defines the background and foreground color of the tab.
|
107
|
+
* @default pill
|
108
|
+
*/
|
109
|
+
this.variant = DEFAULTS.TAB_VARIANT;
|
110
|
+
this.role = 'tab';
|
111
|
+
this.softDisabled = undefined;
|
112
|
+
this.size = undefined;
|
113
|
+
this.type = undefined;
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* Modifies the icon name based on the active state.
|
117
|
+
* If the tab is active, the icon name is suffixed with '-filled'.
|
118
|
+
* If the tab is inactive, the icon name is restored to its original value.
|
119
|
+
* If '-filled' icon is not available, the icon name remains unchanged.
|
120
|
+
*
|
121
|
+
* @param active - The active state.
|
122
|
+
*/
|
123
|
+
modifyIconName(active) {
|
124
|
+
if (this.iconName) {
|
125
|
+
if (active) {
|
126
|
+
this.prevIconName = this.iconName;
|
127
|
+
this.iconName = `${getIconNameWithoutStyle(this.iconName)}-filled`;
|
128
|
+
}
|
129
|
+
else if (this.prevIconName) {
|
130
|
+
this.iconName = this.prevIconName;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
/**
|
135
|
+
* Sets the aria-selected attribute based on the active state of the Tab.
|
136
|
+
* If the tab is active, the filled version of the icon is displayed,
|
137
|
+
* else the icon is restored to its original value.
|
138
|
+
*
|
139
|
+
* @param element - The tab element.
|
140
|
+
* @param active - The active state of the tab.
|
141
|
+
*/
|
142
|
+
setActive(element, active) {
|
143
|
+
element.setAttribute('aria-selected', active ? 'true' : 'false');
|
144
|
+
this.modifyIconName(active);
|
145
|
+
}
|
146
|
+
executeAction() {
|
147
|
+
// Toggle the active state of the tab.
|
148
|
+
this.active = !this.active;
|
149
|
+
}
|
150
|
+
render() {
|
151
|
+
return html `
|
152
|
+
<div part="container">
|
153
|
+
<slot name="badge" part="badge"></slot>
|
154
|
+
${this.iconName
|
155
|
+
? html ` <mdc-icon name="${this.iconName}" size="1" length-unit="rem" part="icon"></mdc-icon>`
|
156
|
+
: nothing}
|
157
|
+
${this.text
|
158
|
+
? html ` <mdc-text
|
159
|
+
type=${this.active ? TYPE.BODY_MIDSIZE_BOLD : TYPE.BODY_MIDSIZE_MEDIUM}
|
160
|
+
tagname=${VALID_TEXT_TAGS.SPAN}
|
161
|
+
data-text=${this.text}
|
162
|
+
part="text"
|
163
|
+
>${this.text}</mdc-text
|
164
|
+
>`
|
165
|
+
: nothing}
|
166
|
+
</div>
|
167
|
+
<div part="indicator"></div>
|
168
|
+
`;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
Tab.styles = [...Buttonsimple.styles, ...styles];
|
172
|
+
__decorate([
|
173
|
+
property({ type: String, reflect: true }),
|
174
|
+
__metadata("design:type", String)
|
175
|
+
], Tab.prototype, "text", void 0);
|
176
|
+
__decorate([
|
177
|
+
property({ type: String, reflect: true }),
|
178
|
+
__metadata("design:type", String)
|
179
|
+
], Tab.prototype, "variant", void 0);
|
180
|
+
export default Tab;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-tab";
|
2
|
+
declare const TAB_VARIANTS: {
|
3
|
+
readonly GLASS: "glass";
|
4
|
+
readonly LINE: "line";
|
5
|
+
readonly PILL: "pill";
|
6
|
+
};
|
7
|
+
declare const DEFAULTS: {
|
8
|
+
readonly TAB_VARIANT: "pill";
|
9
|
+
};
|
10
|
+
export { DEFAULTS, TAG_NAME, TAB_VARIANTS };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
const TAG_NAME = utils.constructTagName('tab');
|
3
|
+
const TAB_VARIANTS = {
|
4
|
+
GLASS: 'glass',
|
5
|
+
LINE: 'line',
|
6
|
+
PILL: 'pill',
|
7
|
+
};
|
8
|
+
const DEFAULTS = {
|
9
|
+
TAB_VARIANT: TAB_VARIANTS.PILL,
|
10
|
+
};
|
11
|
+
export { DEFAULTS, TAG_NAME, TAB_VARIANTS };
|
@@ -0,0 +1,247 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
import { hostFitContentStyles, hostFocusRingStyles } from '../../utils/styles';
|
3
|
+
const styles = [hostFitContentStyles, css `
|
4
|
+
|
5
|
+
:host {
|
6
|
+
--mdc-tab-content-gap: 0.5rem;
|
7
|
+
--mdc-tab-height: 2rem;
|
8
|
+
|
9
|
+
--mdc-tab-glass-active-background-color-disabled: var(--mds-color-theme-button-primary-disabled);
|
10
|
+
--mdc-tab-glass-active-background-color-hover: var(--mds-color-theme-button-primary-hover);
|
11
|
+
--mdc-tab-glass-active-background-color-normal: var(--mds-color-theme-button-primary-normal);
|
12
|
+
--mdc-tab-glass-active-background-color-pressed: var(--mds-color-theme-button-primary-pressed);
|
13
|
+
|
14
|
+
--mdc-tab-glass-active-color: var(--mds-color-theme-inverted-text-primary-normal);
|
15
|
+
--mdc-tab-glass-active-color-disabled: var(--mds-color-theme-inverted-text-primary-disabled);
|
16
|
+
|
17
|
+
--mdc-tab-glass-border-radius: 0.5rem;
|
18
|
+
|
19
|
+
--mdc-tab-glass-inactive-background-color-disabled: var(--mds-color-theme-button-secondary-disabled);
|
20
|
+
--mdc-tab-glass-inactive-background-color-hover: var(--mds-color-theme-button-secondary-hover);
|
21
|
+
--mdc-tab-glass-inactive-background-color-normal: var(--mds-color-theme-button-secondary-normal);
|
22
|
+
--mdc-tab-glass-inactive-background-color-pressed: var(--mds-color-theme-button-secondary-pressed);
|
23
|
+
|
24
|
+
--mdc-tab-glass-inactive-color: var(--mds-color-theme-text-secondary-normal);
|
25
|
+
--mdc-tab-glass-inactive-color-disabled: var(--mds-color-theme-text-primary-disabled);
|
26
|
+
|
27
|
+
--mdc-tab-line-active-background-color-disabled: var(--mds-color-theme-button-secondary-disabled);
|
28
|
+
--mdc-tab-line-active-background-color-hover: var(--mds-color-theme-button-secondary-hover);
|
29
|
+
--mdc-tab-line-active-background-color-normal: var(--mds-color-theme-button-secondary-normal);
|
30
|
+
--mdc-tab-line-active-background-color-pressed: var(--mds-color-theme-button-secondary-pressed);
|
31
|
+
|
32
|
+
--mdc-tab-line-active-color: var(--mds-color-theme-text-primary-normal);
|
33
|
+
--mdc-tab-line-active-color-disabled: var(--mds-color-theme-text-primary-disabled);
|
34
|
+
|
35
|
+
--mdc-tab-line-active-indicator-color: var(--mds-color-theme-outline-input-active);
|
36
|
+
--mdc-tab-line-active-indicator-color-disabled: var(--mds-color-theme-outline-primary-disabled);
|
37
|
+
--mdc-tab-line-active-indicator-height: 0.125rem;
|
38
|
+
--mdc-tab-line-active-indicator-width: 100%;
|
39
|
+
|
40
|
+
--mdc-tab-line-border-bottom-left-radius: 0;
|
41
|
+
--mdc-tab-line-border-bottom-right-radius: 0;
|
42
|
+
--mdc-tab-line-border-top-left-radius: 0.25rem;
|
43
|
+
--mdc-tab-line-border-top-right-radius: 0.25rem;
|
44
|
+
|
45
|
+
--mdc-tab-line-inactive-background-color-disabled: var(--mds-color-theme-button-secondary-disabled);
|
46
|
+
--mdc-tab-line-inactive-background-color-hover: var(--mds-color-theme-button-secondary-hover);
|
47
|
+
--mdc-tab-line-inactive-background-color-normal: var(--mds-color-theme-button-secondary-normal);
|
48
|
+
--mdc-tab-line-inactive-background-color-pressed: var(--mds-color-theme-button-secondary-pressed);
|
49
|
+
|
50
|
+
--mdc-tab-line-inactive-color: var(--mds-color-theme-text-secondary-normal);
|
51
|
+
--mdc-tab-line-inactive-color-disabled: var(--mds-color-theme-text-primary-disabled);
|
52
|
+
|
53
|
+
--mdc-tab-padding-left: 0.75rem;
|
54
|
+
--mdc-tab-padding-right: 0.75rem;
|
55
|
+
|
56
|
+
--mdc-tab-pill-active-background-color-disabled: var(--mds-color-theme-button-secondary-active-normal);
|
57
|
+
--mdc-tab-pill-active-background-color-hover: var(--mds-color-theme-button-secondary-active-hover);
|
58
|
+
--mdc-tab-pill-active-background-color-normal: var(--mds-color-theme-button-secondary-active-normal);
|
59
|
+
--mdc-tab-pill-active-background-color-pressed: var(--mds-color-theme-button-secondary-active-pressed);
|
60
|
+
|
61
|
+
--mdc-tab-pill-active-color: var(--mds-color-theme-text-primary-normal);
|
62
|
+
--mdc-tab-pill-active-color-disabled: var(--mds-color-theme-text-primary-disabled);
|
63
|
+
|
64
|
+
--mdc-tab-pill-border-radius: 0.5rem;
|
65
|
+
|
66
|
+
--mdc-tab-pill-inactive-background-color-disabled: var(--mds-color-theme-button-secondary-disabled);
|
67
|
+
--mdc-tab-pill-inactive-background-color-hover: var(--mds-color-theme-button-secondary-hover);
|
68
|
+
--mdc-tab-pill-inactive-background-color-normal: var(--mds-color-theme-button-secondary-normal);
|
69
|
+
--mdc-tab-pill-inactive-background-color-pressed: var(--mds-color-theme-button-secondary-pressed);
|
70
|
+
|
71
|
+
--mdc-tab-pill-inactive-color: var(--mds-color-theme-text-secondary-normal);
|
72
|
+
--mdc-tab-pill-inactive-color-disabled: var(--mds-color-theme-text-primary-disabled);
|
73
|
+
|
74
|
+
flex-direction: column;
|
75
|
+
height: var(--mdc-tab-height);
|
76
|
+
padding-left: var(--mdc-tab-padding-left);
|
77
|
+
padding-right: var(--mdc-tab-padding-right);
|
78
|
+
position: relative;
|
79
|
+
border: none;
|
80
|
+
}
|
81
|
+
|
82
|
+
:host::part(container) {
|
83
|
+
align-items: center;
|
84
|
+
display: flex;
|
85
|
+
flex-direction: row;
|
86
|
+
gap: var(--mdc-tab-content-gap);
|
87
|
+
justify-content: center;
|
88
|
+
width: fit-content;
|
89
|
+
}
|
90
|
+
|
91
|
+
:host::part(text) {
|
92
|
+
display: flex;
|
93
|
+
flex-direction: column;
|
94
|
+
}
|
95
|
+
|
96
|
+
:host::part(text)::after{
|
97
|
+
content: attr(data-text);
|
98
|
+
height: 0;
|
99
|
+
visibility: hidden;
|
100
|
+
overflow: hidden;
|
101
|
+
user-select: none;
|
102
|
+
pointer-events: none;
|
103
|
+
/* body-midsize-bold font styling */
|
104
|
+
font-size: var(--mds-font-apps-body-midsize-bold-font-size);
|
105
|
+
font-weight: var(--mds-font-apps-body-midsize-bold-font-weight);
|
106
|
+
line-height: var(--mds-font-apps-body-midsize-bold-line-height);
|
107
|
+
text-decoration: var(--mds-font-apps-body-midsize-bold-text-decoration);
|
108
|
+
text-transform: var(--mds-font-apps-body-midsize-bold-text-case);
|
109
|
+
}
|
110
|
+
|
111
|
+
:host::part(indicator) {
|
112
|
+
width: var(--mdc-tab-line-active-indicator-width);
|
113
|
+
height: var(--mdc-tab-line-active-indicator-height);
|
114
|
+
bottom: 0;
|
115
|
+
position: absolute;
|
116
|
+
visibility: hidden;
|
117
|
+
}
|
118
|
+
|
119
|
+
:host([disabled]) {
|
120
|
+
cursor: default;
|
121
|
+
}
|
122
|
+
|
123
|
+
:host([variant="glass"]) {
|
124
|
+
background-color: var(--mdc-tab-glass-inactive-background-color-normal);
|
125
|
+
border-radius: var(--mdc-tab-glass-border-radius);
|
126
|
+
color: var(--mdc-tab-glass-inactive-color);
|
127
|
+
}
|
128
|
+
|
129
|
+
:host([variant="glass"]:hover) {
|
130
|
+
background-color: var(--mdc-tab-glass-inactive-background-color-hover);
|
131
|
+
}
|
132
|
+
|
133
|
+
:host([variant="glass"]:active) {
|
134
|
+
background-color: var(--mdc-tab-glass-inactive-background-color-pressed);
|
135
|
+
}
|
136
|
+
|
137
|
+
:host([variant="glass"][disabled]) {
|
138
|
+
background-color: var(--mdc-tab-glass-inactive-background-color-disabled);
|
139
|
+
color: var(--mdc-tab-glass-inactive-color-disabled);
|
140
|
+
}
|
141
|
+
|
142
|
+
:host([variant="glass"][active]) {
|
143
|
+
background-color: var(--mdc-tab-glass-active-background-color-normal);
|
144
|
+
color: var(--mdc-tab-glass-active-color);
|
145
|
+
}
|
146
|
+
|
147
|
+
:host([variant="glass"][active]:hover) {
|
148
|
+
background-color: var(--mdc-tab-glass-active-background-color-hover);
|
149
|
+
}
|
150
|
+
|
151
|
+
:host([variant="glass"][active]:active) {
|
152
|
+
background-color: var(--mdc-tab-glass-active-background-color-pressed);
|
153
|
+
}
|
154
|
+
|
155
|
+
:host([variant="glass"][active][disabled]) {
|
156
|
+
background-color: var(--mdc-tab-glass-active-background-color-disabled);
|
157
|
+
color: var(--mdc-tab-glass-active-color-disabled);
|
158
|
+
}
|
159
|
+
|
160
|
+
:host([variant="line"]) {
|
161
|
+
background-color: var(--mdc-tab-line-inactive-background-color-normal);
|
162
|
+
border-top-left-radius: var(--mdc-tab-line-border-top-left-radius);
|
163
|
+
border-top-right-radius: var(--mdc-tab-line-border-top-right-radius);
|
164
|
+
border-bottom-left-radius: var(--mdc-tab-line-border-bottom-left-radius);
|
165
|
+
border-bottom-right-radius: var(--mdc-tab-line-border-bottom-right-radius);
|
166
|
+
color: var(--mdc-tab-line-inactive-color);
|
167
|
+
}
|
168
|
+
|
169
|
+
:host([variant="line"]:hover) {
|
170
|
+
background-color: var(--mdc-tab-line-inactive-background-color-hover);
|
171
|
+
}
|
172
|
+
|
173
|
+
:host([variant="line"]:active) {
|
174
|
+
background-color: var(--mdc-tab-line-inactive-background-color-pressed);
|
175
|
+
}
|
176
|
+
|
177
|
+
:host([variant="line"][disabled]) {
|
178
|
+
background-color: var(--mdc-tab-line-inactive-background-color-disabled);
|
179
|
+
color: var(--mdc-tab-line-inactive-color-disabled);
|
180
|
+
}
|
181
|
+
|
182
|
+
:host([variant="line"][active]) {
|
183
|
+
background-color: var(--mdc-tab-line-active-background-color-normal);
|
184
|
+
color: var(--mdc-tab-line-active-color);
|
185
|
+
}
|
186
|
+
|
187
|
+
:host([variant="line"][active])::part(indicator) {
|
188
|
+
background-color:var(--mdc-tab-line-active-indicator-color);
|
189
|
+
visibility: visible;
|
190
|
+
}
|
191
|
+
|
192
|
+
:host([variant="line"][active]:hover) {
|
193
|
+
background-color: var(--mdc-tab-line-active-background-color-hover);
|
194
|
+
}
|
195
|
+
|
196
|
+
:host([variant="line"][active]:active) {
|
197
|
+
background-color: var(--mdc-tab-line-active-background-color-pressed);
|
198
|
+
}
|
199
|
+
|
200
|
+
:host([variant="line"][active][disabled]) {
|
201
|
+
background-color: var(--mdc-tab-line-active-background-color-disabled);
|
202
|
+
color: var(--mdc-tab-line-active-color-disabled);
|
203
|
+
}
|
204
|
+
|
205
|
+
:host([variant="line"][active][disabled])::part(indicator) {
|
206
|
+
background-color:var(--mdc-tab-line-active-indicator-color-disabled);
|
207
|
+
}
|
208
|
+
|
209
|
+
:host([variant="pill"]) {
|
210
|
+
background-color: var(--mdc-tab-pill-inactive-background-color-normal);
|
211
|
+
border-radius: var(--mdc-tab-pill-border-radius);
|
212
|
+
color: var(--mdc-tab-pill-inactive-color);
|
213
|
+
}
|
214
|
+
|
215
|
+
:host([variant="pill"]:hover) {
|
216
|
+
background-color: var(--mdc-tab-pill-inactive-background-color-hover);
|
217
|
+
}
|
218
|
+
|
219
|
+
:host([variant="pill"]:active) {
|
220
|
+
background-color: var(--mdc-tab-pill-inactive-background-color-pressed);
|
221
|
+
}
|
222
|
+
|
223
|
+
:host([variant="pill"][disabled]) {
|
224
|
+
background-color: var(--mdc-tab-pill-inactive-background-color-disabled);
|
225
|
+
color: var(--mdc-tab-pill-inactive-color-disabled);
|
226
|
+
}
|
227
|
+
|
228
|
+
:host([variant="pill"][active]) {
|
229
|
+
background-color: var(--mdc-tab-pill-active-background-color-normal);
|
230
|
+
color: var(--mdc-tab-pill-active-color);
|
231
|
+
}
|
232
|
+
|
233
|
+
:host([variant="pill"][active]:hover) {
|
234
|
+
background-color: var(--mdc-tab-pill-active-background-color-hover);
|
235
|
+
}
|
236
|
+
|
237
|
+
:host([variant="pill"][active]:active) {
|
238
|
+
background-color: var(--mdc-tab-pill-active-background-color-pressed);
|
239
|
+
}
|
240
|
+
|
241
|
+
:host([variant="pill"][active][disabled]) {
|
242
|
+
background-color: var(--mdc-tab-pill-active-background-color-disabled);
|
243
|
+
color: var(--mdc-tab-pill-active-color-disabled);
|
244
|
+
}
|
245
|
+
|
246
|
+
`, ...hostFocusRingStyles()];
|
247
|
+
export default styles;
|