@momentum-design/components 0.84.2 → 0.84.4
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 +8 -3
- package/dist/browser/index.js +2281 -2339
- package/dist/browser/index.js.map +4 -4
- package/dist/components/alertchip/alertchip.component.d.ts +1 -1
- package/dist/components/alertchip/alertchip.component.js +2 -2
- package/dist/components/alertchip/alertchip.styles.js +22 -23
- package/dist/components/alertchip/alertchip.types.d.ts +1 -1
- package/dist/components/animation/animation.component.js +1 -1
- package/dist/components/animation/animation.styles.js +8 -5
- package/dist/components/appheader/appheader.component.js +12 -13
- package/dist/components/appheader/appheader.styles.js +0 -1
- package/dist/components/avatar/avatar.component.js +3 -16
- package/dist/components/avatar/avatar.constants.d.ts +1 -1
- package/dist/components/avatar/avatar.constants.js +1 -1
- package/dist/components/avatar/avatar.styles.js +129 -122
- package/dist/components/avatar/avatar.types.d.ts +1 -1
- package/dist/components/avatar/avatar.utils.d.ts +1 -1
- package/dist/components/avatar/avatar.utils.js +1 -1
- package/dist/components/avatarbutton/avatarbutton.component.d.ts +2 -2
- package/dist/components/avatarbutton/avatarbutton.component.js +2 -2
- package/dist/components/avatarbutton/avatarbutton.styles.js +34 -30
- package/dist/components/badge/badge.styles.js +9 -7
- package/dist/components/brandvisual/brandvisual.component.js +4 -4
- package/dist/components/bullet/bullet.component.d.ts +1 -1
- package/dist/components/bullet/bullet.component.js +2 -2
- package/dist/components/bullet/bullet.styles.js +3 -3
- package/dist/components/button/button.component.js +10 -4
- package/dist/components/button/button.utils.js +1 -1
- package/dist/components/buttongroup/buttongroup.component.js +1 -1
- package/dist/components/buttongroup/buttongroup.styles.js +68 -68
- package/dist/components/buttonlink/buttonlink.component.d.ts +5 -5
- package/dist/components/buttonlink/buttonlink.component.js +9 -9
- package/dist/components/buttonsimple/buttonsimple.component.js +2 -2
- package/dist/components/buttonsimple/buttonsimple.constants.d.ts +1 -1
- package/dist/components/buttonsimple/buttonsimple.constants.js +1 -1
- package/dist/components/buttonsimple/buttonsimple.styles.js +62 -57
- package/dist/components/card/card.component.d.ts +6 -6
- package/dist/components/card/card.component.js +15 -16
- package/dist/components/card/card.styles.js +24 -22
- package/dist/components/cardbutton/cardbutton.component.js +9 -12
- package/dist/components/cardbutton/cardbutton.styles.js +1 -1
- package/dist/components/cardcheckbox/cardcheckbox.component.d.ts +6 -6
- package/dist/components/cardcheckbox/cardcheckbox.component.js +30 -29
- package/dist/components/cardcheckbox/cardcheckbox.styles.js +10 -10
- package/dist/components/cardradio/cardradio.component.d.ts +12 -12
- package/dist/components/cardradio/cardradio.component.js +27 -30
- package/dist/components/cardradio/cardradio.styles.js +8 -8
- package/dist/components/checkbox/checkbox.component.js +7 -9
- package/dist/components/checkbox/checkbox.styles.js +62 -60
- package/dist/components/chip/chip.component.d.ts +1 -1
- package/dist/components/chip/chip.component.js +6 -11
- package/dist/components/chip/chip.styles.js +4 -2
- package/dist/components/dialog/dialog.component.js +28 -29
- package/dist/components/dialog/dialog.styles.js +10 -12
- package/dist/components/divider/divider.component.js +6 -8
- package/dist/components/divider/divider.constants.d.ts +1 -1
- package/dist/components/divider/divider.constants.js +1 -1
- package/dist/components/divider/divider.styles.js +5 -20
- package/dist/components/filterchip/filterchip.styles.js +4 -2
- package/dist/components/formfieldgroup/formfieldgroup.component.js +1 -4
- package/dist/components/formfieldgroup/formfieldgroup.styles.js +1 -2
- package/dist/components/formfieldwrapper/formfieldwrapper.component.js +19 -17
- package/dist/components/formfieldwrapper/formfieldwrapper.styles.js +2 -1
- package/dist/components/formfieldwrapper/formfieldwrapper.subcomponent.js +4 -4
- package/dist/components/icon/icon.component.js +7 -7
- package/dist/components/icon/icon.utils.d.ts +1 -1
- package/dist/components/icon/icon.utils.js +7 -7
- package/dist/components/iconprovider/iconprovider.component.js +7 -7
- package/dist/components/input/input.component.d.ts +5 -5
- package/dist/components/input/input.component.js +64 -62
- package/dist/components/input/input.styles.js +128 -117
- package/dist/components/inputchip/inputchip.component.js +14 -19
- package/dist/components/inputchip/inputchip.styles.js +5 -3
- package/dist/components/link/link.component.d.ts +1 -1
- package/dist/components/link/link.component.js +4 -8
- package/dist/components/link/link.constants.d.ts +1 -1
- package/dist/components/link/link.constants.js +1 -1
- package/dist/components/link/link.styles.js +12 -12
- package/dist/components/linksimple/linksimple.component.js +2 -4
- package/dist/components/linksimple/linksimple.styles.js +59 -57
- package/dist/components/list/list.component.js +12 -9
- package/dist/components/listitem/listitem.component.js +15 -11
- package/dist/components/listitem/listitem.styles.js +11 -6
- package/dist/components/marker/marker.component.js +1 -1
- package/dist/components/marker/marker.styles.js +2 -2
- package/dist/components/menubar/menubar.component.d.ts +19 -19
- package/dist/components/menubar/menubar.component.js +19 -19
- package/dist/components/menuitem/menuitem.component.js +15 -15
- package/dist/components/menuitem/menuitem.styles.js +3 -2
- package/dist/components/menuitemcheckbox/menuitemcheckbox.component.d.ts +1 -1
- package/dist/components/menuitemcheckbox/menuitemcheckbox.component.js +4 -11
- package/dist/components/menuitemradio/menuitemradio.component.js +1 -1
- package/dist/components/menupopover/menupopover.component.js +11 -11
- package/dist/components/menupopover/menupopover.utils.d.ts +1 -1
- package/dist/components/menupopover/menupopover.utils.js +3 -8
- package/dist/components/navitem/navitem.component.js +11 -19
- package/dist/components/navitem/navitem.styles.js +147 -143
- package/dist/components/navitemlist/navitemlist.component.js +2 -2
- package/dist/components/optgroup/optgroup.component.js +12 -9
- package/dist/components/option/option.component.js +11 -11
- package/dist/components/option/option.styles.js +1 -1
- package/dist/components/popover/popover.component.js +4 -4
- package/dist/components/popover/popover.stack.js +1 -1
- package/dist/components/popover/popover.styles.js +0 -1
- package/dist/components/popover/popover.utils.js +3 -4
- package/dist/components/presence/presence.component.d.ts +4 -4
- package/dist/components/presence/presence.component.js +4 -4
- package/dist/components/progressbar/progressbar.component.js +3 -4
- package/dist/components/progressbar/progressbar.styles.js +77 -71
- package/dist/components/progressspinner/progressspiner.utils.js +4 -4
- package/dist/components/progressspinner/progressspinner.component.js +38 -37
- package/dist/components/progressspinner/progressspinner.styles.js +1 -1
- package/dist/components/radio/radio.component.d.ts +41 -41
- package/dist/components/radio/radio.component.js +84 -83
- package/dist/components/radio/radio.styles.js +77 -75
- package/dist/components/radiogroup/radiogroup.component.js +1 -1
- package/dist/components/screenreaderannouncer/screenreaderannouncer.component.js +2 -2
- package/dist/components/screenreaderannouncer/screenreaderannouncer.styles.js +8 -6
- package/dist/components/searchfield/searchfield.component.js +23 -17
- package/dist/components/searchfield/searchfield.styles.js +11 -13
- package/dist/components/select/select.component.js +20 -23
- package/dist/components/select/select.styles.js +9 -9
- package/dist/components/sidenavigation/sidenavigation.component.d.ts +6 -6
- package/dist/components/sidenavigation/sidenavigation.component.js +39 -29
- package/dist/components/sidenavigation/sidenavigation.context.js +5 -5
- package/dist/components/sidenavigation/sidenavigation.styles.js +53 -53
- package/dist/components/skeleton/skeleton.component.js +1 -4
- package/dist/components/skeleton/skeleton.constants.d.ts +1 -1
- package/dist/components/skeleton/skeleton.constants.js +1 -1
- package/dist/components/skeleton/skeleton.styles.js +4 -4
- package/dist/components/spinner/spinner.component.d.ts +7 -7
- package/dist/components/spinner/spinner.component.js +9 -9
- package/dist/components/spinner/spinner.styles.js +58 -53
- package/dist/components/staticcheckbox/staticcheckbox.component.js +10 -8
- package/dist/components/staticcheckbox/staticcheckbox.styles.js +52 -51
- package/dist/components/staticradio/staticradio.component.d.ts +8 -8
- package/dist/components/staticradio/staticradio.component.js +10 -11
- package/dist/components/staticradio/staticradio.styles.js +77 -75
- package/dist/components/statictoggle/statictoggle.component.d.ts +3 -3
- package/dist/components/statictoggle/statictoggle.component.js +3 -3
- package/dist/components/statictoggle/statictoggle.styles.js +71 -68
- package/dist/components/tab/tab.component.d.ts +1 -1
- package/dist/components/tab/tab.component.js +2 -2
- package/dist/components/tab/tab.styles.js +247 -245
- package/dist/components/tablist/tablist.component.js +11 -15
- package/dist/components/tablist/tablist.styles.js +27 -25
- package/dist/components/tablist/tablist.types.d.ts +1 -1
- package/dist/components/tablist/tablist.utils.js +4 -4
- package/dist/components/text/fonts.styles.js +49 -49
- package/dist/components/text/text.component.js +21 -11
- package/dist/components/text/text.types.d.ts +1 -1
- package/dist/components/textarea/textarea.component.d.ts +31 -31
- package/dist/components/textarea/textarea.component.js +54 -61
- package/dist/components/textarea/textarea.styles.js +123 -122
- package/dist/components/themeprovider/themeprovider.component.js +1 -1
- package/dist/components/themeprovider/themeprovider.styles.js +4 -4
- package/dist/components/toggle/toggle.component.d.ts +35 -35
- package/dist/components/toggle/toggle.component.js +62 -63
- package/dist/components/toggle/toggle.styles.js +77 -69
- package/dist/components/toggletip/toggletip.component.d.ts +7 -7
- package/dist/components/toggletip/toggletip.component.js +3 -2
- package/dist/components/tooltip/tooltip.component.js +1 -1
- package/dist/components/tooltip/tooltip.styles.js +0 -1
- package/dist/components/virtualizedlist/virtualizedlist.component.js +6 -14
- package/dist/components/virtualizedlist/virtualizedlist.helper.test.d.ts +1 -1
- package/dist/components/virtualizedlist/virtualizedlist.helper.test.js +14 -11
- package/dist/components/virtualizedlist/virtualizedlist.styles.js +4 -4
- package/dist/custom-elements.json +572 -551
- package/dist/index.js +1 -0
- package/dist/models/component/index.d.ts +1 -1
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.js +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/utils/mixins/ButtonComponentMixin.js +10 -10
- package/dist/utils/mixins/CardAndDialogFooterMixin.js +21 -22
- package/dist/utils/mixins/FocusTrapMixin.js +26 -16
- package/dist/utils/mixins/IconNameMixin.d.ts +1 -1
- package/dist/utils/mixins/MenuMixin.js +23 -23
- package/dist/utils/mixins/PreventScrollMixin.d.ts +1 -1
- package/dist/utils/styles/index.js +12 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
package/dist/models/index.d.ts
CHANGED
package/dist/models/index.js
CHANGED
package/dist/react/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
+
export { default as AlertChip } from './alertchip';
|
1
2
|
export { default as Animation } from './animation';
|
2
3
|
export { default as Appheader } from './appheader';
|
3
|
-
export { default as AlertChip } from './alertchip';
|
4
4
|
export { default as Avatar } from './avatar';
|
5
5
|
export { default as AvatarButton } from './avatarbutton';
|
6
6
|
export { default as Badge } from './badge';
|
@@ -18,8 +18,8 @@ export { default as Checkbox } from './checkbox';
|
|
18
18
|
export { default as Chip } from './chip';
|
19
19
|
export { default as Coachmark } from './coachmark';
|
20
20
|
export { default as Dialog } from './dialog';
|
21
|
-
export { default as Divider } from './divider';
|
22
21
|
export { default as FilterChip } from './filterchip';
|
22
|
+
export { default as Divider } from './divider';
|
23
23
|
export { default as FormfieldGroup } from './formfieldgroup';
|
24
24
|
export { default as FormfieldWrapper } from './formfieldwrapper';
|
25
25
|
export { default as Icon } from './icon';
|
package/dist/react/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
+
export { default as AlertChip } from './alertchip';
|
1
2
|
export { default as Animation } from './animation';
|
2
3
|
export { default as Appheader } from './appheader';
|
3
|
-
export { default as AlertChip } from './alertchip';
|
4
4
|
export { default as Avatar } from './avatar';
|
5
5
|
export { default as AvatarButton } from './avatarbutton';
|
6
6
|
export { default as Badge } from './badge';
|
@@ -18,8 +18,8 @@ export { default as Checkbox } from './checkbox';
|
|
18
18
|
export { default as Chip } from './chip';
|
19
19
|
export { default as Coachmark } from './coachmark';
|
20
20
|
export { default as Dialog } from './dialog';
|
21
|
-
export { default as Divider } from './divider';
|
22
21
|
export { default as FilterChip } from './filterchip';
|
22
|
+
export { default as Divider } from './divider';
|
23
23
|
export { default as FormfieldGroup } from './formfieldgroup';
|
24
24
|
export { default as FormfieldWrapper } from './formfieldwrapper';
|
25
25
|
export { default as Icon } from './icon';
|
@@ -9,18 +9,18 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
};
|
10
10
|
/* eslint-disable max-classes-per-file */
|
11
11
|
import { property, state } from 'lit/decorators.js';
|
12
|
-
import { BUTTON_COLORS, BUTTON_TYPE_INTERNAL, BUTTON_VARIANTS, DEFAULTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES } from '../../components/button/button.constants';
|
12
|
+
import { BUTTON_COLORS, BUTTON_TYPE_INTERNAL, BUTTON_VARIANTS, DEFAULTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, } from '../../components/button/button.constants';
|
13
13
|
export const ButtonComponentMixin = (superClass) => {
|
14
14
|
class InnerMixinClass extends superClass {
|
15
15
|
constructor() {
|
16
16
|
super(...arguments);
|
17
17
|
/**
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
* There are 3 variants of button: primary, secondary, tertiary. They are styled differently.
|
19
|
+
* - **Primary**: Solid background color.
|
20
|
+
* - **Secondary**: Transparent background with a solid border.
|
21
|
+
* - **Tertiary**: No background or border, appears as plain text but retains all button functionalities.
|
22
|
+
* @default primary
|
23
|
+
*/
|
24
24
|
this.variant = DEFAULTS.VARIANT;
|
25
25
|
/**
|
26
26
|
* There are 5 colors for button: positive, negative, accent, promotional, default.
|
@@ -64,8 +64,8 @@ export const ButtonComponentMixin = (superClass) => {
|
|
64
64
|
setSize(size) {
|
65
65
|
const isIconType = this.typeInternal === BUTTON_TYPE_INTERNAL.ICON;
|
66
66
|
const isValidSize = isIconType
|
67
|
-
? Object.values(ICON_BUTTON_SIZES).includes(size)
|
68
|
-
|
67
|
+
? Object.values(ICON_BUTTON_SIZES).includes(size) &&
|
68
|
+
!(size === ICON_BUTTON_SIZES[20] && this.variant !== BUTTON_VARIANTS.TERTIARY)
|
69
69
|
: Object.values(PILL_BUTTON_SIZES).includes(size);
|
70
70
|
this.setAttribute('size', isValidSize ? `${size}` : `${DEFAULTS.SIZE}`);
|
71
71
|
}
|
@@ -75,7 +75,7 @@ export const ButtonComponentMixin = (superClass) => {
|
|
75
75
|
*/
|
76
76
|
inferButtonType() {
|
77
77
|
var _a, _b;
|
78
|
-
const slot = (_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot')) === null || _b === void 0 ? void 0 : _b.assignedNodes().filter(
|
78
|
+
const slot = (_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot')) === null || _b === void 0 ? void 0 : _b.assignedNodes().filter(node => { var _a; return node.nodeType !== Node.TEXT_NODE || ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim()); }).length;
|
79
79
|
if (slot && (this.prefixIcon || this.postfixIcon)) {
|
80
80
|
this.typeInternal = BUTTON_TYPE_INTERNAL.PILL_WITH_ICON;
|
81
81
|
this.setAttribute('data-btn-type', 'pill-with-icon');
|
@@ -22,7 +22,7 @@ export const CardAndDialogFooterMixin = (superClass) => {
|
|
22
22
|
*/
|
23
23
|
updateFooterButtonColors(variant) {
|
24
24
|
const footerButtons = [...(this.footerButtonPrimary || []), ...(this.footerButtonSecondary || [])];
|
25
|
-
footerButtons === null || footerButtons === void 0 ? void 0 : footerButtons.forEach(
|
25
|
+
footerButtons === null || footerButtons === void 0 ? void 0 : footerButtons.forEach(button => {
|
26
26
|
if (variant === VARIANTS.PROMOTIONAL) {
|
27
27
|
button.setAttribute('color', BUTTON_COLORS.PROMOTIONAL);
|
28
28
|
}
|
@@ -45,21 +45,21 @@ export const CardAndDialogFooterMixin = (superClass) => {
|
|
45
45
|
if (tagname === DEFAULTS.LINK && ((_a = this.footerLink) === null || _a === void 0 ? void 0 : _a.length)) {
|
46
46
|
arrayItems = this.footerLink;
|
47
47
|
}
|
48
|
-
else if (tagname === DEFAULTS.BUTTON
|
49
|
-
|
50
|
-
|
48
|
+
else if (tagname === DEFAULTS.BUTTON &&
|
49
|
+
variant === BUTTON_VARIANTS.PRIMARY &&
|
50
|
+
((_b = this.footerButtonPrimary) === null || _b === void 0 ? void 0 : _b.length)) {
|
51
51
|
arrayItems = this.footerButtonPrimary;
|
52
52
|
}
|
53
|
-
else if (tagname === DEFAULTS.BUTTON
|
54
|
-
|
55
|
-
|
53
|
+
else if (tagname === DEFAULTS.BUTTON &&
|
54
|
+
variant === BUTTON_VARIANTS.SECONDARY &&
|
55
|
+
((_c = this.footerButtonSecondary) === null || _c === void 0 ? void 0 : _c.length)) {
|
56
56
|
arrayItems = this.footerButtonSecondary;
|
57
57
|
}
|
58
58
|
// if there are more than one instance, remove them.
|
59
59
|
for (let i = 1; i < arrayItems.length; i += 1) {
|
60
60
|
arrayItems[i].remove();
|
61
61
|
}
|
62
|
-
arrayItems.forEach(
|
62
|
+
arrayItems.forEach(element => {
|
63
63
|
// remove the element if it doesn't match with the tagname
|
64
64
|
if (!element.matches(tagname)) {
|
65
65
|
element.remove();
|
@@ -76,20 +76,19 @@ export const CardAndDialogFooterMixin = (superClass) => {
|
|
76
76
|
* @returns The footer element
|
77
77
|
*/
|
78
78
|
renderFooter() {
|
79
|
-
return html `
|
80
|
-
<
|
81
|
-
<
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
</slot>`;
|
79
|
+
return html ` <slot name="footer">
|
80
|
+
<div part="footer">
|
81
|
+
<slot name="footer-link" @slotchange=${() => this.handleFooterSlot(DEFAULTS.LINK)}></slot>
|
82
|
+
<slot
|
83
|
+
name="footer-button-secondary"
|
84
|
+
@slotchange=${() => this.handleFooterSlot(DEFAULTS.BUTTON, BUTTON_VARIANTS.SECONDARY)}
|
85
|
+
></slot>
|
86
|
+
<slot
|
87
|
+
name="footer-button-primary"
|
88
|
+
@slotchange=${() => this.handleFooterSlot(DEFAULTS.BUTTON, BUTTON_VARIANTS.PRIMARY)}
|
89
|
+
></slot>
|
90
|
+
</div>
|
91
|
+
</slot>`;
|
93
92
|
}
|
94
93
|
}
|
95
94
|
__decorate([
|
@@ -16,6 +16,9 @@ import { property } from 'lit/decorators.js';
|
|
16
16
|
*
|
17
17
|
* This also makes sure there is only one keydown listener active at a time,
|
18
18
|
* which is necessary to handle focus trapping correctly.
|
19
|
+
*
|
20
|
+
* Handling iFrames is supported, as long as there are focusable elements around the iFrame.
|
21
|
+
* Otherwise it will not work as expected.
|
19
22
|
*/
|
20
23
|
class FocusTrapStack {
|
21
24
|
static get stackArray() {
|
@@ -38,7 +41,7 @@ class FocusTrapStack {
|
|
38
41
|
*/
|
39
42
|
static activate(trap) {
|
40
43
|
// Deactivate all other traps
|
41
|
-
this.stackArray.forEach(
|
44
|
+
this.stackArray.forEach(activeTrap => {
|
42
45
|
if (activeTrap !== trap) {
|
43
46
|
activeTrap.setIsFocusTrapActivated(false);
|
44
47
|
}
|
@@ -163,11 +166,11 @@ export const FocusTrapMixin = (superClass) => {
|
|
163
166
|
* @returns True if the element is hidden.
|
164
167
|
*/
|
165
168
|
isHidden(element) {
|
166
|
-
return (element.hasAttribute('hidden')
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
169
|
+
return (element.hasAttribute('hidden') ||
|
170
|
+
element.getAttribute('aria-hidden') === 'true' ||
|
171
|
+
this.hasHiddenStyle(element) ||
|
172
|
+
this.isNotVisible(element) ||
|
173
|
+
this.hasComputedHidden(element));
|
171
174
|
}
|
172
175
|
/**
|
173
176
|
* Checks if the element is disabled.
|
@@ -204,12 +207,12 @@ export const FocusTrapMixin = (superClass) => {
|
|
204
207
|
if (element instanceof HTMLInputElement && element.type !== 'hidden') {
|
205
208
|
return true;
|
206
209
|
}
|
207
|
-
if ((element instanceof HTMLAudioElement || element instanceof HTMLVideoElement)
|
208
|
-
|
210
|
+
if ((element instanceof HTMLAudioElement || element instanceof HTMLVideoElement) &&
|
211
|
+
element.hasAttribute('controls')) {
|
209
212
|
return true;
|
210
213
|
}
|
211
|
-
if ((element instanceof HTMLImageElement || element instanceof HTMLObjectElement)
|
212
|
-
|
214
|
+
if ((element instanceof HTMLImageElement || element instanceof HTMLObjectElement) &&
|
215
|
+
element.hasAttribute('usemap')) {
|
213
216
|
return true;
|
214
217
|
}
|
215
218
|
if (element.hasAttribute('tabindex') && element.tabIndex > -1) {
|
@@ -253,7 +256,7 @@ export const FocusTrapMixin = (superClass) => {
|
|
253
256
|
}
|
254
257
|
else if (element.tagName === 'SLOT') {
|
255
258
|
const assignedNodes = element.assignedElements({ flatten: true });
|
256
|
-
assignedNodes.forEach(
|
259
|
+
assignedNodes.forEach(node => {
|
257
260
|
if (node instanceof HTMLElement) {
|
258
261
|
this.findFocusable(node, matches);
|
259
262
|
}
|
@@ -335,7 +338,7 @@ export const FocusTrapMixin = (superClass) => {
|
|
335
338
|
* @returns The index of the active element.
|
336
339
|
*/
|
337
340
|
findElement(activeElement) {
|
338
|
-
return this.focusableElements.findIndex(
|
341
|
+
return this.focusableElements.findIndex(element => this.isEqualFocusNode(activeElement, element));
|
339
342
|
}
|
340
343
|
/**
|
341
344
|
* Checks if the active element is equal to the given element.
|
@@ -356,7 +359,7 @@ export const FocusTrapMixin = (superClass) => {
|
|
356
359
|
* @param direction - The direction of the focus trap.
|
357
360
|
* If true, the focus will be trapped in the previous element.
|
358
361
|
*/
|
359
|
-
trapFocus(
|
362
|
+
trapFocus(event) {
|
360
363
|
// calculate the focusable elements
|
361
364
|
this.setFocusableElements();
|
362
365
|
if (this.focusableElements.length === 0) {
|
@@ -364,6 +367,7 @@ export const FocusTrapMixin = (superClass) => {
|
|
364
367
|
}
|
365
368
|
const activeElement = this.getDeepActiveElement();
|
366
369
|
const activeIndex = this.findElement(activeElement);
|
370
|
+
const direction = event.shiftKey;
|
367
371
|
if (direction) {
|
368
372
|
this.focusTrapIndex = this.calculateNextIndex(activeIndex, -1);
|
369
373
|
}
|
@@ -371,8 +375,15 @@ export const FocusTrapMixin = (superClass) => {
|
|
371
375
|
this.focusTrapIndex = this.calculateNextIndex(activeIndex, 1);
|
372
376
|
}
|
373
377
|
const nextElement = this.focusableElements[this.focusTrapIndex];
|
378
|
+
if (nextElement.tagName === 'IFRAME') {
|
379
|
+
// If the next element is an iframe we should not focus it manually
|
380
|
+
// but just let the browser handle it.
|
381
|
+
// this only works if there are focusable elements around the iframe!
|
382
|
+
return;
|
383
|
+
}
|
374
384
|
if (nextElement) {
|
375
|
-
|
385
|
+
event.preventDefault();
|
386
|
+
nextElement.focus();
|
376
387
|
}
|
377
388
|
}
|
378
389
|
/**
|
@@ -386,8 +397,7 @@ export const FocusTrapMixin = (superClass) => {
|
|
386
397
|
return;
|
387
398
|
}
|
388
399
|
if (event.key === 'Tab') {
|
389
|
-
|
390
|
-
this.trapFocus(event.shiftKey);
|
400
|
+
this.trapFocus(event);
|
391
401
|
}
|
392
402
|
}
|
393
403
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { LitElement } from 'lit';
|
2
|
-
import type { Constructor } from './index.types';
|
3
2
|
import type { IconNames } from '../../components/icon/icon.types';
|
3
|
+
import type { Constructor } from './index.types';
|
4
4
|
export interface IconNameMixinInterface {
|
5
5
|
iconName: IconNames;
|
6
6
|
}
|
@@ -31,16 +31,16 @@ export const MenuMixin = (superClass) => {
|
|
31
31
|
var _a;
|
32
32
|
const slot = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
|
33
33
|
const allAssignedElements = ((slot === null || slot === void 0 ? void 0 : slot.assignedElements({ flatten: true })) || []);
|
34
|
-
return allAssignedElements
|
34
|
+
return allAssignedElements
|
35
|
+
.map(node => {
|
35
36
|
if (node.tagName.toLowerCase() === MENUSECTION_TAGNAME) {
|
36
|
-
return Array.from(node.children)
|
37
|
-
.filter((child) => this.isValidMenuItem(child));
|
37
|
+
return Array.from(node.children).filter(child => this.isValidMenuItem(child));
|
38
38
|
}
|
39
39
|
return this.isValidMenuItem(node) ? node : [];
|
40
40
|
})
|
41
41
|
.flat()
|
42
|
-
.filter(
|
43
|
-
.filter(
|
42
|
+
.filter(node => !!node)
|
43
|
+
.filter(node => !node.hasAttribute('disabled'));
|
44
44
|
}
|
45
45
|
firstUpdated(changedProperties) {
|
46
46
|
super.firstUpdated(changedProperties);
|
@@ -70,19 +70,19 @@ export const MenuMixin = (superClass) => {
|
|
70
70
|
* @returns The index of the target element in the menuItems array.
|
71
71
|
*/
|
72
72
|
getCurrentIndex(target) {
|
73
|
-
return this.menuItems.findIndex(
|
73
|
+
return this.menuItems.findIndex(node => node === target || node === target.parentElement);
|
74
74
|
}
|
75
75
|
/**
|
76
76
|
* Updates the placement of the popover based on the aria-orientation property.
|
77
77
|
*/
|
78
78
|
updatePopoverPlacementBasedOnOrientation() {
|
79
79
|
if (this.ariaOrientation === ORIENTATION.HORIZONTAL) {
|
80
|
-
this.menuPopoverItems.forEach(
|
80
|
+
this.menuPopoverItems.forEach(node => {
|
81
81
|
node.setAttribute('placement', POPOVER_PLACEMENT.BOTTOM_START);
|
82
82
|
});
|
83
83
|
}
|
84
84
|
else {
|
85
|
-
this.menuPopoverItems.forEach(
|
85
|
+
this.menuPopoverItems.forEach(node => {
|
86
86
|
node.setAttribute('placement', POPOVER_PLACEMENT.RIGHT_START);
|
87
87
|
});
|
88
88
|
}
|
@@ -113,7 +113,7 @@ export const MenuMixin = (superClass) => {
|
|
113
113
|
* @returns True if the tag name is a valid menu, false otherwise.
|
114
114
|
*/
|
115
115
|
isValidMenu(tagName) {
|
116
|
-
return (
|
116
|
+
return (tagName === null || tagName === void 0 ? void 0 : tagName.toLowerCase()) === MENUBAR_TAGNAME || this.isValidNavItemList(tagName);
|
117
117
|
}
|
118
118
|
/**
|
119
119
|
* Checks if the given tag name is a valid navitemlist tag name.
|
@@ -140,7 +140,7 @@ export const MenuMixin = (superClass) => {
|
|
140
140
|
var _a, _b;
|
141
141
|
if (this.isValidPopover((_b = (_a = this.menuItems[index]) === null || _a === void 0 ? void 0 : _a.nextElementSibling) === null || _b === void 0 ? void 0 : _b.tagName)) {
|
142
142
|
const currentMenuId = this.menuItems[index].getAttribute('id');
|
143
|
-
const result = this.menuPopoverItems.findIndex(
|
143
|
+
const result = this.menuPopoverItems.findIndex(node => node.getAttribute('triggerid') === currentMenuId);
|
144
144
|
if (result !== -1) {
|
145
145
|
if (!this.menuPopoverItems[result].hasAttribute('visible')) {
|
146
146
|
this.menuPopoverItems[result].toggleAttribute('visible');
|
@@ -212,7 +212,7 @@ export const MenuMixin = (superClass) => {
|
|
212
212
|
menu === null || menu === void 0 ? void 0 : menu.toggleAttribute('visible');
|
213
213
|
}
|
214
214
|
if (menu === null || menu === void 0 ? void 0 : menu.children) {
|
215
|
-
const menuChildren = Array.from(menu.children).filter(
|
215
|
+
const menuChildren = Array.from(menu.children).filter(child => this.isValidMenuItem(child));
|
216
216
|
this.resetTabIndexAndSetActiveTabIndex(menuChildren);
|
217
217
|
}
|
218
218
|
if (menu === null || menu === void 0 ? void 0 : menu.parentElement) {
|
@@ -228,8 +228,8 @@ export const MenuMixin = (superClass) => {
|
|
228
228
|
navigateToPrevParentMenuItem(currentIndex, key) {
|
229
229
|
var _a, _b, _c, _d, _e;
|
230
230
|
const parentMenuItem = (_a = this.menuItems[currentIndex].parentElement) === null || _a === void 0 ? void 0 : _a.previousElementSibling;
|
231
|
-
const parentMenuItemsChildren = Array.from(((_b = this.parentElement) === null || _b === void 0 ? void 0 : _b.children) || []).filter(
|
232
|
-
const parentMenuItemIndex = parentMenuItemsChildren.findIndex(
|
231
|
+
const parentMenuItemsChildren = Array.from(((_b = this.parentElement) === null || _b === void 0 ? void 0 : _b.children) || []).filter(node => this.isValidMenuItem(node));
|
232
|
+
const parentMenuItemIndex = parentMenuItemsChildren.findIndex(node => node === parentMenuItem);
|
233
233
|
let newIndex = parentMenuItemIndex;
|
234
234
|
if (key === KEYS.ARROW_LEFT && this.isValidMenu((_c = this.parentElement) === null || _c === void 0 ? void 0 : _c.tagName)) {
|
235
235
|
newIndex = parentMenuItemIndex - 1;
|
@@ -257,7 +257,7 @@ export const MenuMixin = (superClass) => {
|
|
257
257
|
getParentMenuContents(currentMenuItem) {
|
258
258
|
var _a;
|
259
259
|
const parentMenuItemDetails = this.getParentMenuItemDetails('', currentMenuItem);
|
260
|
-
const parentMenuItemsChildren = Array.from(((_a = parentMenuItemDetails.menu) === null || _a === void 0 ? void 0 : _a.children) || []).filter(
|
260
|
+
const parentMenuItemsChildren = Array.from(((_a = parentMenuItemDetails.menu) === null || _a === void 0 ? void 0 : _a.children) || []).filter(node => this.isValidMenuItem(node));
|
261
261
|
return { parentMenuItemDetails, parentMenuItemsChildren };
|
262
262
|
}
|
263
263
|
/**
|
@@ -278,12 +278,12 @@ export const MenuMixin = (superClass) => {
|
|
278
278
|
if (this.isValidMenu(this.tagName))
|
279
279
|
return;
|
280
280
|
// - get the top parent menu items using recursion.
|
281
|
-
const { parentMenuItemDetails, parentMenuItemsChildren
|
281
|
+
const { parentMenuItemDetails, parentMenuItemsChildren } = this.getParentMenuContents(this.menuItems[currentIndex]);
|
282
282
|
if (parentMenuItemsChildren.length === 0 || (parentMenuItemDetails === null || parentMenuItemDetails === void 0 ? void 0 : parentMenuItemDetails.menuChildId) === '') {
|
283
283
|
this.navigateToNextMenuItem(currentIndex, 0, this.menuItems.length - 1, this.ariaOrientation);
|
284
284
|
return;
|
285
285
|
}
|
286
|
-
const parentMenuItemIndex = parentMenuItemsChildren.findIndex(
|
286
|
+
const parentMenuItemIndex = parentMenuItemsChildren.findIndex(node => node.getAttribute('id') === (parentMenuItemDetails === null || parentMenuItemDetails === void 0 ? void 0 : parentMenuItemDetails.menuChildId));
|
287
287
|
const newIndex = parentMenuItemIndex === -1 ? currentIndex + 1 : parentMenuItemIndex + 1;
|
288
288
|
this.updateTabIndexAndFocusNewIndex(parentMenuItemsChildren, parentMenuItemIndex, newIndex);
|
289
289
|
(_b = (_a = parentMenuItemsChildren[newIndex]) === null || _a === void 0 ? void 0 : _a.nextElementSibling) === null || _b === void 0 ? void 0 : _b.toggleAttribute('visible');
|
@@ -296,8 +296,8 @@ export const MenuMixin = (superClass) => {
|
|
296
296
|
isValidMenuItem(menuItem) {
|
297
297
|
const validRoles = [ROLE.MENUITEM, ROLE.MENUITEMCHECKBOX, ROLE.MENUITEMRADIO];
|
298
298
|
const role = menuItem.getAttribute('role');
|
299
|
-
return role !== null
|
300
|
-
|
299
|
+
return (role !== null &&
|
300
|
+
validRoles.includes(role));
|
301
301
|
}
|
302
302
|
/**
|
303
303
|
* Resets all list items tabindex to -1 and sets the tabindex of the
|
@@ -322,8 +322,8 @@ export const MenuMixin = (superClass) => {
|
|
322
322
|
getKeyBasedOnDirection(originalKey) {
|
323
323
|
var _a;
|
324
324
|
let key = originalKey;
|
325
|
-
const isRtl = ((_a = document.querySelector('html')) === null || _a === void 0 ? void 0 : _a.getAttribute('dir')) === 'rtl'
|
326
|
-
|
325
|
+
const isRtl = ((_a = document.querySelector('html')) === null || _a === void 0 ? void 0 : _a.getAttribute('dir')) === 'rtl' ||
|
326
|
+
window.getComputedStyle(this).direction === 'rtl';
|
327
327
|
if (isRtl && (key === KEYS.ARROW_LEFT || key === KEYS.ARROW_RIGHT)) {
|
328
328
|
if (key === KEYS.ARROW_LEFT) {
|
329
329
|
key = KEYS.ARROW_RIGHT;
|
@@ -441,9 +441,9 @@ export const MenuMixin = (superClass) => {
|
|
441
441
|
*/
|
442
442
|
closeAllPopoversExceptCurrent(currentIndex) {
|
443
443
|
this.menuPopoverItems
|
444
|
-
.filter(
|
445
|
-
.filter(
|
446
|
-
.forEach(
|
444
|
+
.filter(node => node !== this.menuItems[currentIndex])
|
445
|
+
.filter(node => node.hasAttribute('visible'))
|
446
|
+
.forEach(node => node.toggleAttribute('visible'));
|
447
447
|
}
|
448
448
|
/**
|
449
449
|
* Handles the mouse click event on the menu items.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { LitElement } from 'lit';
|
2
|
-
import type { Constructor } from './index.types';
|
3
2
|
import type { Component } from '../../models';
|
3
|
+
import type { Constructor } from './index.types';
|
4
4
|
export declare abstract class PreventScrollMixinInterface {
|
5
5
|
protected abstract preventScroll?: boolean;
|
6
6
|
protected activatePreventScroll(): void;
|
@@ -9,19 +9,19 @@ const hostFitContentStyles = css `
|
|
9
9
|
}
|
10
10
|
`;
|
11
11
|
const baseHostStyleVariables = css `
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
:host {
|
13
|
+
--mdc-focus-ring-inner-color: var(--mds-color-theme-focus-default-0);
|
14
|
+
--mdc-focus-ring-middle-color: var(--mds-color-theme-focus-default-1);
|
15
|
+
--mdc-focus-ring-outer-color: var(--mds-color-theme-focus-default-2);
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
--mdc-focus-ring-inner-width: 0.125rem;
|
18
|
+
--mdc-focus-ring-middle-width: calc(2 * var(--mdc-focus-ring-inner-width));
|
19
|
+
--mdc-focus-ring-outer-width: calc(0.0625rem + var(--mdc-focus-ring-middle-width));
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
--mdc-focus-ring-middle-offset: var(--mdc-focus-ring-inner-width);
|
22
|
+
--mdc-focus-ring-outer-offset: calc(var(--mdc-focus-ring-inner-width) + var(--mdc-focus-ring-middle-width));
|
23
|
+
}
|
24
|
+
`;
|
25
25
|
const hostFocusRingStyles = (applyFocusRingOnClass = false) => {
|
26
26
|
const boxShadow = css `0 0 0 var(--mdc-focus-ring-inner-width) var(--mdc-focus-ring-inner-color),
|
27
27
|
0 0 0 var(--mdc-focus-ring-middle-width) var(--mdc-focus-ring-middle-color),
|
@@ -44,7 +44,7 @@ const hostFocusRingStyles = (applyFocusRingOnClass = false) => {
|
|
44
44
|
}
|
45
45
|
/* Remove focus ring from parent when children has its own focus ring.
|
46
46
|
The child element must have class name own-focus-ring */
|
47
|
-
.mdc-focus-ring:has(.own-focus-ring:focus-visible){
|
47
|
+
.mdc-focus-ring:has(.own-focus-ring:focus-visible) {
|
48
48
|
box-shadow: none;
|
49
49
|
}
|
50
50
|
|
package/package.json
CHANGED