@momentum-design/components 0.61.0 → 0.61.2
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 +104 -91
- package/dist/browser/index.js.map +3 -3
- package/dist/components/button/button.component.d.ts +8 -0
- package/dist/components/button/button.component.js +12 -0
- package/dist/components/button/button.constants.d.ts +1 -0
- package/dist/components/button/button.constants.js +1 -0
- package/dist/components/button/button.styles.js +9 -0
- package/dist/components/buttonsimple/buttonsimple.component.js +6 -4
- package/dist/components/tablist/index.d.ts +0 -1
- package/dist/components/tablist/index.js +0 -1
- package/dist/components/tablist/tablist.component.d.ts +2 -20
- package/dist/components/tablist/tablist.component.js +12 -36
- package/dist/custom-elements.json +323 -313
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/tablist/index.d.ts +1 -3
- package/dist/react/tablist/index.js +1 -3
- package/package.json +1 -1
@@ -44,6 +44,14 @@ declare class Button extends Button_base {
|
|
44
44
|
* @default 32
|
45
45
|
*/
|
46
46
|
size: PillButtonSize | IconButtonSize;
|
47
|
+
/**
|
48
|
+
* The button color can be inverted by setting the inverted attribute to true.
|
49
|
+
*
|
50
|
+
* Only applies when variant is set to `primary`, color is set to `default`
|
51
|
+
* and button is not `active`.
|
52
|
+
* @default false
|
53
|
+
*/
|
54
|
+
inverted: boolean;
|
47
55
|
/**
|
48
56
|
* This property defines the ARIA role for the element. By default, it is set to 'button'.
|
49
57
|
* Consumers should override this role when:
|
@@ -57,6 +57,14 @@ class Button extends ButtonComponentMixin(Buttonsimple) {
|
|
57
57
|
* @default 32
|
58
58
|
*/
|
59
59
|
this.size = DEFAULTS.SIZE;
|
60
|
+
/**
|
61
|
+
* The button color can be inverted by setting the inverted attribute to true.
|
62
|
+
*
|
63
|
+
* Only applies when variant is set to `primary`, color is set to `default`
|
64
|
+
* and button is not `active`.
|
65
|
+
* @default false
|
66
|
+
*/
|
67
|
+
this.inverted = DEFAULTS.INVERTED;
|
60
68
|
/**
|
61
69
|
* This property defines the ARIA role for the element. By default, it is set to 'button'.
|
62
70
|
* Consumers should override this role when:
|
@@ -128,6 +136,10 @@ __decorate([
|
|
128
136
|
property({ type: Number }),
|
129
137
|
__metadata("design:type", Number)
|
130
138
|
], Button.prototype, "size", void 0);
|
139
|
+
__decorate([
|
140
|
+
property({ type: Boolean, reflect: true }),
|
141
|
+
__metadata("design:type", Boolean)
|
142
|
+
], Button.prototype, "inverted", void 0);
|
131
143
|
__decorate([
|
132
144
|
property({ type: String, reflect: true }),
|
133
145
|
__metadata("design:type", Object)
|
@@ -36,5 +36,6 @@ const DEFAULTS = {
|
|
36
36
|
COLOR: BUTTON_COLORS.DEFAULT,
|
37
37
|
TYPE_INTERNAL: BUTTON_TYPE_INTERNAL.ICON,
|
38
38
|
TYPE: BUTTON_TYPE.BUTTON,
|
39
|
+
INVERTED: false,
|
39
40
|
};
|
40
41
|
export { TAG_NAME, DEFAULTS, BUTTON_VARIANTS, PILL_BUTTON_SIZES, ICON_BUTTON_SIZES, BUTTON_COLORS, BUTTON_TYPE_INTERNAL, BUTTON_TYPE, };
|
@@ -226,5 +226,14 @@ const styles = css `
|
|
226
226
|
--mdc-button-secondary-hover-background-color: var(--mds-color-theme-button-secondary-hover);
|
227
227
|
--mdc-button-secondary-pressed-background-color: var(--mds-color-theme-button-secondary-pressed);
|
228
228
|
}
|
229
|
+
|
230
|
+
:host([inverted][variant='primary'][color='default']) {
|
231
|
+
--mdc-button-primary-color: var(--mds-color-theme-text-primary-normal);
|
232
|
+
--mdc-button-primary-background-color: var(--mds-color-theme-inverted-button-primary-normal);
|
233
|
+
--mdc-button-primary-hover-background-color: var(--mds-color-theme-inverted-button-primary-hover);
|
234
|
+
--mdc-button-primary-pressed-background-color: var(--mds-color-theme-inverted-button-primary-pressed);
|
235
|
+
--mdc-button-primary-disabled-background-color: var(--mds-color-theme-inverted-button-primary-disabled);
|
236
|
+
--mdc-button-primary-disabled-color: var(--mds-color-theme-inverted-text-primary-disabled);
|
237
|
+
}
|
229
238
|
`;
|
230
239
|
export default [styles];
|
@@ -185,9 +185,11 @@ class Buttonsimple extends TabIndexMixin(DisabledMixin(Component)) {
|
|
185
185
|
if (event.key === 'Enter') {
|
186
186
|
this.triggerClickEvent();
|
187
187
|
}
|
188
|
-
|
189
|
-
|
190
|
-
|
188
|
+
// preventing the default event behavior for space key
|
189
|
+
// to avoid scrolling etc in the host application
|
190
|
+
// preventing the default event behavior for enter key
|
191
|
+
// to avoid the keyup event to be triggered
|
192
|
+
event.preventDefault();
|
191
193
|
}
|
192
194
|
}
|
193
195
|
/**
|
@@ -217,7 +219,7 @@ __decorate([
|
|
217
219
|
__metadata("design:type", Boolean)
|
218
220
|
], Buttonsimple.prototype, "active", void 0);
|
219
221
|
__decorate([
|
220
|
-
property({ type: Boolean, attribute: 'soft-disabled' }),
|
222
|
+
property({ type: Boolean, attribute: 'soft-disabled', reflect: true }),
|
221
223
|
__metadata("design:type", Boolean)
|
222
224
|
], Buttonsimple.prototype, "softDisabled", void 0);
|
223
225
|
__decorate([
|
@@ -20,9 +20,7 @@ import { Component } from '../../models';
|
|
20
20
|
* **Accessibility notes for consuming (have to be explicitly set when you consume the component)**
|
21
21
|
*
|
22
22
|
* - Each element that contains the `content panel` for a `tab` has role `tabpanel`.
|
23
|
-
* -
|
24
|
-
* the element with role `tablist` has `aria-labelledby` needs to be a value that refers to the labelling element.
|
25
|
-
* Otherwise, the `tablist` element needs to have a label provided by `aria-label`.
|
23
|
+
* - The `tablist` element needs to have a label provided by `data-aria-label`.
|
26
24
|
* - Each element with role `tab` has the property `aria-controls`
|
27
25
|
* that should refer to its associated `tabpanel` element.
|
28
26
|
* - Each element with role `tabpanel` has the property `aria-labelledby` referring to its associated `tab` element.
|
@@ -52,16 +50,8 @@ declare class TabList extends Component {
|
|
52
50
|
*/
|
53
51
|
activeTabId?: string;
|
54
52
|
/**
|
55
|
-
*
|
56
|
-
*/
|
57
|
-
dataAriaLabelledby?: string;
|
58
|
-
/**
|
59
|
-
* Label for the tablist in case aria-labelledby is not provided.
|
53
|
+
* Label for the tablist.
|
60
54
|
* This is used when the tablist does not have a visible label.
|
61
|
-
* Defaults to 'Tab List'.
|
62
|
-
* <br/>
|
63
|
-
* Note: If both `data-aria-labelledby` and `data-aria-label` are provided,
|
64
|
-
* the `data-aria-labelledby` will be used.
|
65
55
|
*/
|
66
56
|
dataAriaLabel?: string;
|
67
57
|
/**
|
@@ -120,14 +110,6 @@ declare class TabList extends Component {
|
|
120
110
|
* @param changedProperties - Map of changed properties with old values.
|
121
111
|
*/
|
122
112
|
update(changedProperties: PropertyValues<this>): Promise<void>;
|
123
|
-
/**
|
124
|
-
* Set aria-labelledby attribute on the tablist element.
|
125
|
-
* If it does not exist, set aria-label attribute.
|
126
|
-
* As fallback, set aria-label to 'Tab List'.
|
127
|
-
*
|
128
|
-
* @internal
|
129
|
-
*/
|
130
|
-
private setAriaLabelledByOrAriaLabel;
|
131
113
|
/**
|
132
114
|
* Dispatch the change event.
|
133
115
|
*
|
@@ -9,6 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
};
|
10
10
|
import { html, nothing } from 'lit';
|
11
11
|
import { property, query, queryAssignedElements, state } from 'lit/decorators.js';
|
12
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
12
13
|
import styles from './tablist.styles';
|
13
14
|
import { Component } from '../../models';
|
14
15
|
import { ARROW_BUTTON_DIRECTION, KEYCODES } from './tablist.constants';
|
@@ -34,9 +35,7 @@ import { getFirstTab, getLastTab, getNextTab, getPreviousTab, findTab, getActive
|
|
34
35
|
* **Accessibility notes for consuming (have to be explicitly set when you consume the component)**
|
35
36
|
*
|
36
37
|
* - Each element that contains the `content panel` for a `tab` has role `tabpanel`.
|
37
|
-
* -
|
38
|
-
* the element with role `tablist` has `aria-labelledby` needs to be a value that refers to the labelling element.
|
39
|
-
* Otherwise, the `tablist` element needs to have a label provided by `aria-label`.
|
38
|
+
* - The `tablist` element needs to have a label provided by `data-aria-label`.
|
40
39
|
* - Each element with role `tab` has the property `aria-controls`
|
41
40
|
* that should refer to its associated `tabpanel` element.
|
42
41
|
* - Each element with role `tabpanel` has the property `aria-labelledby` referring to its associated `tab` element.
|
@@ -81,24 +80,6 @@ class TabList extends Component {
|
|
81
80
|
* @internal
|
82
81
|
*/
|
83
82
|
this.isRtl = () => { var _a; return ((_a = document.querySelector('html')) === null || _a === void 0 ? void 0 : _a.getAttribute('dir')) === 'rtl' || window.getComputedStyle(this).direction === 'rtl'; };
|
84
|
-
/**
|
85
|
-
* Set aria-labelledby attribute on the tablist element.
|
86
|
-
* If it does not exist, set aria-label attribute.
|
87
|
-
* As fallback, set aria-label to 'Tab List'.
|
88
|
-
*
|
89
|
-
* @internal
|
90
|
-
*/
|
91
|
-
this.setAriaLabelledByOrAriaLabel = () => {
|
92
|
-
var _a, _b, _c, _d;
|
93
|
-
if (this.dataAriaLabelledby) {
|
94
|
-
(_a = this.tabsContainer) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-labelledby', this.dataAriaLabelledby);
|
95
|
-
(_b = this.tabsContainer) === null || _b === void 0 ? void 0 : _b.removeAttribute('aria-label');
|
96
|
-
}
|
97
|
-
else {
|
98
|
-
(_c = this.tabsContainer) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-label', this.dataAriaLabel || 'Tab List');
|
99
|
-
(_d = this.tabsContainer) === null || _d === void 0 ? void 0 : _d.removeAttribute('aria-labelledby');
|
100
|
-
}
|
101
|
-
};
|
102
83
|
/**
|
103
84
|
* Dispatch the change event.
|
104
85
|
*
|
@@ -108,7 +89,7 @@ class TabList extends Component {
|
|
108
89
|
*/
|
109
90
|
this.fireTabChangeEvent = (newTab) => {
|
110
91
|
const event = new CustomEvent('change', {
|
111
|
-
detail: newTab.tabId,
|
92
|
+
detail: { tabId: newTab.tabId },
|
112
93
|
});
|
113
94
|
this.dispatchEvent(event);
|
114
95
|
};
|
@@ -160,6 +141,7 @@ class TabList extends Component {
|
|
160
141
|
* @param event - Custom Event fired from the nested tab.
|
161
142
|
*/
|
162
143
|
this.handleNestedTabActiveChange = async (event) => {
|
144
|
+
event.stopPropagation();
|
163
145
|
const tab = event.target;
|
164
146
|
if (!(tab instanceof Tab)) {
|
165
147
|
return;
|
@@ -209,11 +191,10 @@ class TabList extends Component {
|
|
209
191
|
* @param tab - Tab to set focus on.
|
210
192
|
*/
|
211
193
|
this.focusTab = async (tab) => {
|
212
|
-
var _a;
|
213
194
|
if (!(tab instanceof Tab)) {
|
214
195
|
return;
|
215
196
|
}
|
216
|
-
if (tab !== (
|
197
|
+
if (tab !== (document === null || document === void 0 ? void 0 : document.activeElement)) {
|
217
198
|
this.resetTabIndexAndSetNewTabIndex(tab);
|
218
199
|
tab.focus();
|
219
200
|
}
|
@@ -399,10 +380,8 @@ class TabList extends Component {
|
|
399
380
|
this.onerror('The tabs inside the tab list must have unique tab ids');
|
400
381
|
}
|
401
382
|
}
|
402
|
-
this.setAriaLabelledByOrAriaLabel();
|
403
383
|
const resizeObserver = new ResizeObserver(async () => {
|
404
|
-
|
405
|
-
const activeElement = (_b = (_a = this.tabsContainer) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.activeElement;
|
384
|
+
const { activeElement } = document;
|
406
385
|
/**
|
407
386
|
* Keep the focused element in view.
|
408
387
|
*/
|
@@ -433,9 +412,6 @@ class TabList extends Component {
|
|
433
412
|
*/
|
434
413
|
async update(changedProperties) {
|
435
414
|
super.update(changedProperties);
|
436
|
-
if (changedProperties.has('dataAriaLabelledby') || changedProperties.has('dataAriaLabel')) {
|
437
|
-
this.setAriaLabelledByOrAriaLabel();
|
438
|
-
}
|
439
415
|
if (changedProperties.has('activeTabId')) {
|
440
416
|
if (!this.tabs || !this.activeTabId) {
|
441
417
|
return;
|
@@ -446,7 +422,7 @@ class TabList extends Component {
|
|
446
422
|
}
|
447
423
|
this.setActiveTab(newTab);
|
448
424
|
/**
|
449
|
-
* If the previous activeTabId was not undefined,
|
425
|
+
* If the previous activeTabId was not undefined, focus the new tab.
|
450
426
|
*
|
451
427
|
* Otherwise, reset the tabindex of all tabs and set the new tabindex.
|
452
428
|
*/
|
@@ -475,7 +451,11 @@ class TabList extends Component {
|
|
475
451
|
></mdc-button>`
|
476
452
|
: nothing}`;
|
477
453
|
return html ` ${arrowButton('backward')}
|
478
|
-
<div
|
454
|
+
<div
|
455
|
+
class="container"
|
456
|
+
role="tablist"
|
457
|
+
tabindex="-1"
|
458
|
+
aria-label="${ifDefined(this.dataAriaLabel)}">
|
479
459
|
<slot></slot>
|
480
460
|
</div>
|
481
461
|
${arrowButton(ARROW_BUTTON_DIRECTION.FORWARD)}`;
|
@@ -486,10 +466,6 @@ __decorate([
|
|
486
466
|
property({ type: String, attribute: 'active-tab-id', reflect: true }),
|
487
467
|
__metadata("design:type", String)
|
488
468
|
], TabList.prototype, "activeTabId", void 0);
|
489
|
-
__decorate([
|
490
|
-
property({ type: String, attribute: 'data-aria-labelledby' }),
|
491
|
-
__metadata("design:type", String)
|
492
|
-
], TabList.prototype, "dataAriaLabelledby", void 0);
|
493
469
|
__decorate([
|
494
470
|
property({ type: String, attribute: 'data-aria-label' }),
|
495
471
|
__metadata("design:type", String)
|