@scania/tegel 1.26.0 → 1.27.0-allow-numbers-and-zero-values-beta.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/cjs/index-ca8040ad.js +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/tds-banner.cjs.entry.js +1 -1
- package/dist/cjs/tds-checkbox.cjs.entry.js +10 -3
- package/dist/cjs/tds-chip.cjs.entry.js +7 -2
- package/dist/cjs/tds-dropdown_2.cjs.entry.js +74 -45
- package/dist/cjs/tds-folder-tab.cjs.entry.js +21 -2
- package/dist/cjs/tds-folder-tabs.cjs.entry.js +4 -2
- package/dist/cjs/tds-icon.cjs.entry.js +1 -1
- package/dist/cjs/tds-inline-tab.cjs.entry.js +21 -2
- package/dist/cjs/tds-inline-tabs.cjs.entry.js +4 -2
- package/dist/cjs/tds-link.cjs.entry.js +17 -3
- package/dist/cjs/tds-message.cjs.entry.js +15 -3
- package/dist/cjs/tds-modal.cjs.entry.js +74 -2
- package/dist/cjs/tds-navigation-tab.cjs.entry.js +21 -2
- package/dist/cjs/tds-navigation-tabs.cjs.entry.js +6 -4
- package/dist/cjs/tds-popover-core.cjs.entry.js +1 -1
- package/dist/cjs/tds-text-field.cjs.entry.js +13 -7
- package/dist/cjs/tds-textarea.cjs.entry.js +21 -9
- package/dist/cjs/tds-toast.cjs.entry.js +4 -4
- package/dist/cjs/tds-toggle.cjs.entry.js +2 -2
- package/dist/cjs/tds-tooltip.cjs.entry.js +14 -4
- package/dist/cjs/tegel.cjs.js +1 -1
- package/dist/collection/components/banner/banner.css +1 -1
- package/dist/collection/components/banner/banner.js +1 -1
- package/dist/collection/components/checkbox/checkbox.js +44 -3
- package/dist/collection/components/chip/chip.js +24 -2
- package/dist/collection/components/dropdown/dropdown-option/dropdown-option.js +2 -2
- package/dist/collection/components/dropdown/dropdown.js +89 -43
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/icon/iconsArray.js +96 -1
- package/dist/collection/components/link/link.js +17 -3
- package/dist/collection/components/message/message.css +44 -26
- package/dist/collection/components/message/message.js +49 -2
- package/dist/collection/components/modal/modal.js +103 -3
- package/dist/collection/components/popover-core/tds-popover-core.css +596 -53
- package/dist/collection/components/tabs/folder-tabs/folder-tab/folder-tab.js +21 -2
- package/dist/collection/components/tabs/folder-tabs/folder-tabs.js +40 -2
- package/dist/collection/components/tabs/inline-tabs/inline-tab/inline-tab.js +21 -2
- package/dist/collection/components/tabs/inline-tabs/inline-tabs.js +40 -2
- package/dist/collection/components/tabs/navigation-tabs/navigation-tab/navigation-tab.js +21 -2
- package/dist/collection/components/tabs/navigation-tabs/navigation-tabs.js +42 -4
- package/dist/collection/components/text-field/text-field.js +31 -8
- package/dist/collection/components/textarea/textarea.css +11 -6
- package/dist/collection/components/textarea/textarea.js +38 -8
- package/dist/collection/components/toast/toast.css +1 -1
- package/dist/collection/components/toast/toast.js +3 -3
- package/dist/collection/components/toggle/toggle.js +2 -2
- package/dist/collection/components/tooltip/tooltip.js +40 -4
- package/dist/collection/utils/axeHelpers.js +1 -1
- package/dist/components/{p-c65351ab.js → p-14ab9663.js} +12 -3
- package/dist/components/p-17338bcb.js +115 -0
- package/dist/components/{p-2a43e410.js → p-2d93a742.js} +5 -5
- package/dist/components/p-4487c541.js +65 -0
- package/dist/components/{p-29d19dc8.js → p-60ff84f2.js} +1 -1
- package/dist/components/{p-a64dc22e.js → p-797c8dce.js} +75 -45
- package/dist/components/{p-4c1e3344.js → p-83db8b35.js} +1 -1
- package/dist/components/{p-b1d21573.js → p-a1181b1f.js} +1 -1
- package/dist/components/p-e71e3b2e.js +2052 -0
- package/dist/components/tds-accordion-item.js +1 -1
- package/dist/components/tds-banner.js +2 -2
- package/dist/components/tds-checkbox.js +1 -1
- package/dist/components/tds-chip.js +9 -3
- package/dist/components/tds-datetime.js +1 -1
- package/dist/components/tds-dropdown-option.js +1 -1
- package/dist/components/tds-dropdown.js +1 -1
- package/dist/components/tds-folder-tab.js +21 -2
- package/dist/components/tds-folder-tabs.js +7 -3
- package/dist/components/tds-footer-group.js +1 -1
- package/dist/components/tds-header-cell.js +1 -1
- package/dist/components/tds-header-dropdown.js +3 -3
- package/dist/components/tds-header-hamburger.js +1 -1
- package/dist/components/tds-header-launcher-button.js +1 -1
- package/dist/components/tds-header-launcher.js +4 -4
- package/dist/components/tds-icon.js +1 -1
- package/dist/components/tds-inline-tab.js +21 -2
- package/dist/components/tds-inline-tabs.js +7 -3
- package/dist/components/tds-link.js +17 -3
- package/dist/components/tds-message.js +19 -5
- package/dist/components/tds-modal.js +78 -4
- package/dist/components/tds-navigation-tab.js +21 -2
- package/dist/components/tds-navigation-tabs.js +9 -5
- package/dist/components/tds-popover-canvas.js +1 -1
- package/dist/components/tds-popover-core.js +1 -1
- package/dist/components/tds-popover-menu.js +1 -1
- package/dist/components/tds-side-menu-close-button.js +1 -1
- package/dist/components/tds-side-menu-dropdown.js +1 -1
- package/dist/components/tds-slider.js +1 -1
- package/dist/components/tds-step.js +1 -1
- package/dist/components/tds-table-body-input-wrapper.js +1 -1
- package/dist/components/tds-table-body-row.js +1 -1
- package/dist/components/tds-table-footer.js +4 -4
- package/dist/components/tds-table-header-input-wrapper.js +1 -1
- package/dist/components/tds-table-header.js +1 -1
- package/dist/components/tds-table-toolbar.js +1 -1
- package/dist/components/tds-text-field.js +15 -8
- package/dist/components/tds-textarea.js +36 -11
- package/dist/components/tds-toast.js +5 -5
- package/dist/components/tds-toggle.js +2 -2
- package/dist/components/tds-tooltip.js +1 -102
- package/dist/esm/index-51d04e39.js +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tds-banner.entry.js +1 -1
- package/dist/esm/tds-checkbox.entry.js +10 -3
- package/dist/esm/tds-chip.entry.js +7 -2
- package/dist/esm/tds-dropdown_2.entry.js +74 -45
- package/dist/esm/tds-folder-tab.entry.js +22 -3
- package/dist/esm/tds-folder-tabs.entry.js +4 -2
- package/dist/esm/tds-icon.entry.js +1 -1
- package/dist/esm/tds-inline-tab.entry.js +22 -3
- package/dist/esm/tds-inline-tabs.entry.js +4 -2
- package/dist/esm/tds-link.entry.js +17 -3
- package/dist/esm/tds-message.entry.js +15 -3
- package/dist/esm/tds-modal.entry.js +74 -2
- package/dist/esm/tds-navigation-tab.entry.js +22 -3
- package/dist/esm/tds-navigation-tabs.entry.js +6 -4
- package/dist/esm/tds-popover-core.entry.js +1 -1
- package/dist/esm/tds-text-field.entry.js +13 -7
- package/dist/esm/tds-textarea.entry.js +21 -9
- package/dist/esm/tds-toast.entry.js +4 -4
- package/dist/esm/tds-toggle.entry.js +2 -2
- package/dist/esm/tds-tooltip.entry.js +14 -4
- package/dist/esm/tegel.js +1 -1
- package/dist/tegel/p-0f2c9507.entry.js +1 -0
- package/dist/tegel/p-125a6b06.entry.js +1 -0
- package/dist/tegel/p-28517288.entry.js +1 -0
- package/dist/tegel/p-2af57972.entry.js +1 -0
- package/dist/tegel/p-3e9ca19a.entry.js +1 -0
- package/dist/tegel/{p-be1d1345.entry.js → p-4465f687.entry.js} +1 -1
- package/dist/tegel/p-668b7662.entry.js +1 -0
- package/dist/tegel/{p-4e298888.entry.js → p-66f394a2.entry.js} +1 -1
- package/dist/tegel/p-754a4921.entry.js +1 -0
- package/dist/tegel/{p-46205cfb.entry.js → p-769d0503.entry.js} +1 -1
- package/dist/tegel/p-843413ba.entry.js +1 -0
- package/dist/tegel/p-97f10223.entry.js +1 -0
- package/dist/tegel/p-a21250b8.entry.js +1 -0
- package/dist/tegel/p-aadb2553.entry.js +1 -0
- package/dist/tegel/p-b08886e3.entry.js +1 -0
- package/dist/tegel/p-b114ec3d.entry.js +1 -0
- package/dist/tegel/p-c3607f10.entry.js +1 -0
- package/dist/tegel/p-ddda64eb.entry.js +1 -0
- package/dist/tegel/p-eaa279dd.entry.js +1 -0
- package/dist/tegel/p-ee960089.entry.js +1 -0
- package/dist/tegel/tegel.css +13 -3
- package/dist/tegel/tegel.esm.js +1 -1
- package/dist/types/components/checkbox/checkbox.d.ts +5 -0
- package/dist/types/components/chip/chip.d.ts +3 -0
- package/dist/types/components/dropdown/dropdown.d.ts +5 -0
- package/dist/types/components/message/message.d.ts +5 -0
- package/dist/types/components/modal/modal.d.ts +6 -0
- package/dist/types/components/tabs/folder-tabs/folder-tab/folder-tab.d.ts +2 -0
- package/dist/types/components/tabs/folder-tabs/folder-tabs.d.ts +4 -0
- package/dist/types/components/tabs/inline-tabs/inline-tab/inline-tab.d.ts +2 -0
- package/dist/types/components/tabs/inline-tabs/inline-tabs.d.ts +4 -0
- package/dist/types/components/tabs/navigation-tabs/navigation-tab/navigation-tab.d.ts +2 -0
- package/dist/types/components/tabs/navigation-tabs/navigation-tabs.d.ts +4 -0
- package/dist/types/components/text-field/text-field.d.ts +4 -1
- package/dist/types/components/textarea/textarea.d.ts +7 -4
- package/dist/types/components/tooltip/tooltip.d.ts +3 -0
- package/dist/types/components.d.ts +130 -2
- package/dist/types/types/Icons.d.ts +1 -1
- package/dist/types/utils/axeHelpers.d.ts +1 -2
- package/package.json +1 -1
- package/dist/components/p-4764a1d5.js +0 -2052
- package/dist/components/p-a2b7bdef.js +0 -65
- package/dist/tegel/p-065d6f83.entry.js +0 -1
- package/dist/tegel/p-0c1e632d.entry.js +0 -1
- package/dist/tegel/p-168122a7.entry.js +0 -1
- package/dist/tegel/p-19eb4ae1.entry.js +0 -1
- package/dist/tegel/p-4e33cbda.entry.js +0 -1
- package/dist/tegel/p-4ee344e5.entry.js +0 -1
- package/dist/tegel/p-64c80f14.entry.js +0 -1
- package/dist/tegel/p-72fd0083.entry.js +0 -1
- package/dist/tegel/p-93a4bd11.entry.js +0 -1
- package/dist/tegel/p-9e0b31a1.entry.js +0 -1
- package/dist/tegel/p-a0fc0cc2.entry.js +0 -1
- package/dist/tegel/p-b35e7208.entry.js +0 -1
- package/dist/tegel/p-b6526302.entry.js +0 -1
- package/dist/tegel/p-b686f1ad.entry.js +0 -1
- package/dist/tegel/p-cca85da0.entry.js +0 -1
- package/dist/tegel/p-d0abf078.entry.js +0 -1
- package/dist/tegel/p-dcbc35af.entry.js +0 -1
|
@@ -9,14 +9,28 @@ export class TdsLink {
|
|
|
9
9
|
this.standalone = false;
|
|
10
10
|
}
|
|
11
11
|
connectedCallback() {
|
|
12
|
-
this.host.
|
|
12
|
+
const links = this.host.querySelectorAll('a');
|
|
13
|
+
if (links.length > 1) {
|
|
14
|
+
console.warn('tds-link is only intended to wrap one <a> tag');
|
|
15
|
+
}
|
|
16
|
+
const link = links[0];
|
|
17
|
+
if (link) {
|
|
18
|
+
if (this.disabled) {
|
|
19
|
+
link.setAttribute('tabindex', '-1');
|
|
20
|
+
link.setAttribute('aria-disabled', 'true');
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
link.removeAttribute('tabindex');
|
|
24
|
+
link.removeAttribute('aria-disabled');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
13
27
|
}
|
|
14
28
|
render() {
|
|
15
|
-
return (h("span", { key: '
|
|
29
|
+
return (h("span", { key: '1183de952c2fd6cb1193e9e0dec419f37bf07dee', class: {
|
|
16
30
|
'disabled': this.disabled,
|
|
17
31
|
'no-underline': !this.underline,
|
|
18
32
|
'standalone': this.standalone,
|
|
19
|
-
} }, h("slot", { key: '
|
|
33
|
+
} }, h("slot", { key: 'e019a83d2335cd0a7d682e79a6bf0148452c3e71' })));
|
|
20
34
|
}
|
|
21
35
|
static get is() { return "tds-link"; }
|
|
22
36
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/* Typography Usage mixins */
|
|
2
|
+
/* Centralized map of typography types */
|
|
3
|
+
/* Utility mixin */
|
|
4
|
+
:host {
|
|
5
|
+
/* Default values */
|
|
6
|
+
--tds-message-background: var(--background-elevation-layer-03);
|
|
7
|
+
/* Variant values */
|
|
8
|
+
}
|
|
9
|
+
:host .tds-mode-variant-primary {
|
|
10
|
+
--tds-message-background: var(--background-elevation-layer-03);
|
|
11
|
+
}
|
|
12
|
+
:host .tds-mode-variant-secondary {
|
|
13
|
+
--tds-message-background: var(--background-elevation-layer-02);
|
|
14
|
+
}
|
|
1
15
|
:host .wrapper {
|
|
2
16
|
display: flex;
|
|
3
17
|
padding: 16px;
|
|
@@ -5,43 +19,45 @@
|
|
|
5
19
|
border-radius: 4px;
|
|
6
20
|
}
|
|
7
21
|
:host .wrapper.information {
|
|
8
|
-
border-left: 4px solid var(--
|
|
22
|
+
border-left: 4px solid var(--system-info-default);
|
|
9
23
|
}
|
|
10
24
|
:host .wrapper.information tds-icon {
|
|
11
|
-
color: var(--
|
|
25
|
+
color: var(--system-info-default);
|
|
12
26
|
}
|
|
13
27
|
:host .wrapper.success {
|
|
14
|
-
border-left: 4px solid var(--
|
|
28
|
+
border-left: 4px solid var(--system-success-default);
|
|
15
29
|
}
|
|
16
30
|
:host .wrapper.success tds-icon {
|
|
17
|
-
color: var(--
|
|
31
|
+
color: var(--system-success-default);
|
|
18
32
|
}
|
|
19
33
|
:host .wrapper.error {
|
|
20
|
-
background-color: var(--
|
|
21
|
-
border-left: 4px solid var(--
|
|
34
|
+
background-color: var(--system-danger-subtle);
|
|
35
|
+
border-left: 4px solid var(--system-danger-default);
|
|
22
36
|
}
|
|
23
37
|
:host .wrapper.error tds-icon {
|
|
24
|
-
color: var(--
|
|
38
|
+
color: var(--system-danger-default);
|
|
25
39
|
}
|
|
26
40
|
:host .wrapper.warning {
|
|
27
|
-
border-left: 4px solid var(--
|
|
41
|
+
border-left: 4px solid var(--system-warning-default);
|
|
28
42
|
}
|
|
29
43
|
:host .wrapper.warning tds-icon {
|
|
30
|
-
color: var(--
|
|
44
|
+
color: var(--system-warning-default);
|
|
31
45
|
}
|
|
32
46
|
:host .wrapper.minimal {
|
|
33
47
|
border: none;
|
|
34
|
-
display: flex;
|
|
35
|
-
align-items: center;
|
|
36
48
|
padding: 0;
|
|
37
49
|
background-color: transparent;
|
|
38
50
|
}
|
|
39
51
|
:host .wrapper.minimal .header {
|
|
40
|
-
font: var(--
|
|
41
|
-
|
|
52
|
+
font-family: var(--detail-02-font-family);
|
|
53
|
+
font-size: var(--detail-02-font-size);
|
|
54
|
+
line-height: var(--detail-02-line-height);
|
|
55
|
+
font-weight: var(--detail-02-font-weight);
|
|
56
|
+
letter-spacing: var(--detail-02-letter-spacing);
|
|
57
|
+
text-transform: var(--detail-02-text-transform);
|
|
42
58
|
}
|
|
43
59
|
:host .wrapper.minimal.error .header {
|
|
44
|
-
color: var(--
|
|
60
|
+
color: var(--system-danger-default);
|
|
45
61
|
}
|
|
46
62
|
:host tds-icon {
|
|
47
63
|
padding-right: 16px;
|
|
@@ -50,21 +66,23 @@
|
|
|
50
66
|
display: flex;
|
|
51
67
|
flex-direction: column;
|
|
52
68
|
gap: 4px;
|
|
53
|
-
color: var(--
|
|
69
|
+
color: var(--foreground-text-strong);
|
|
54
70
|
padding: 2px 0;
|
|
55
71
|
}
|
|
56
72
|
:host .content .header {
|
|
57
|
-
font: var(--
|
|
58
|
-
|
|
73
|
+
font-family: var(--headline-07-font-family);
|
|
74
|
+
font-size: var(--headline-07-font-size);
|
|
75
|
+
line-height: var(--headline-07-line-height);
|
|
76
|
+
font-weight: var(--headline-07-font-weight);
|
|
77
|
+
letter-spacing: var(--headline-07-letter-spacing);
|
|
78
|
+
text-transform: var(--headline-07-text-transform);
|
|
59
79
|
}
|
|
60
80
|
:host .content .extended-message {
|
|
61
|
-
color: var(--
|
|
62
|
-
font: var(--
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
:host .tds-mode-variant-secondary {
|
|
69
|
-
--tds-message-background: var(--tds-message-background-secondary);
|
|
81
|
+
color: var(--foreground-text-strong);
|
|
82
|
+
font-family: var(--detail-02-font-family);
|
|
83
|
+
font-size: var(--detail-02-font-size);
|
|
84
|
+
line-height: var(--detail-02-line-height);
|
|
85
|
+
font-weight: var(--detail-02-font-weight);
|
|
86
|
+
letter-spacing: var(--detail-02-letter-spacing);
|
|
87
|
+
text-transform: var(--detail-02-text-transform);
|
|
70
88
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
+
import generateUniqueId from "../../utils/generateUniqueId";
|
|
2
3
|
/**
|
|
3
4
|
* @slot <default> - <b>Unnamed slot.</b> For the extended message. Not visible on minimal messages.
|
|
4
5
|
*/
|
|
@@ -23,14 +24,25 @@ export class TdsMessage {
|
|
|
23
24
|
this.variant = 'information';
|
|
24
25
|
this.noIcon = false;
|
|
25
26
|
this.minimal = false;
|
|
27
|
+
this.tdsAlertDialog = 'dialog';
|
|
28
|
+
this.tdsAriaLabel = undefined;
|
|
29
|
+
}
|
|
30
|
+
getAriaLabel() {
|
|
31
|
+
if (this.header) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const variantLabel = `${this.variant} message`;
|
|
35
|
+
return this.tdsAriaLabel || variantLabel;
|
|
26
36
|
}
|
|
27
37
|
render() {
|
|
28
|
-
|
|
38
|
+
const headerId = this.header ? `tds-message-header-${generateUniqueId()}` : undefined;
|
|
39
|
+
const contentId = !this.minimal ? `tds-message-content-${generateUniqueId()}` : undefined;
|
|
40
|
+
return (h(Host, { key: 'b28d7e5de5b3cb612e78f83650fa5c0621107dda', role: this.tdsAlertDialog, "aria-labelledby": headerId, "aria-describedby": contentId, "aria-label": this.getAriaLabel() }, h("div", { key: 'a3d7470a99af752df3516009d39f7e1c4bbed096', class: {
|
|
29
41
|
wrapper: true,
|
|
30
42
|
[this.variant]: true,
|
|
31
43
|
minimal: this.minimal,
|
|
32
44
|
[`tds-mode-variant-${this.modeVariant}`]: this.modeVariant !== null,
|
|
33
|
-
} }, !this.noIcon && h("tds-icon", { key: '
|
|
45
|
+
} }, !this.noIcon && (h("tds-icon", { key: '5ce066cccec225e2707e660f73396f24197d024d', "aria-label": `${this.variant}`, svgTitle: `${this.variant}`, name: this.getIconName(), size: "20px" })), h("div", { key: 'ec0101d39dd0354b163219b732fd9dfa9cd66e60', class: `content` }, this.header && (h("div", { key: '434be3923b805cc8bd77d232a8cdbf847f9793c8', class: "header", id: headerId }, this.header)), !this.minimal && (h("div", { key: '14f5ead963e55d7e3bad6abc69e97ba9f994316f', class: "extended-message", id: contentId }, h("slot", { key: '37c61ef3a396e37a7cb130951d44af9454163699' })))))));
|
|
34
46
|
}
|
|
35
47
|
static get is() { return "tds-message"; }
|
|
36
48
|
static get encapsulation() { return "shadow"; }
|
|
@@ -134,6 +146,41 @@ export class TdsMessage {
|
|
|
134
146
|
"attribute": "minimal",
|
|
135
147
|
"reflect": false,
|
|
136
148
|
"defaultValue": "false"
|
|
149
|
+
},
|
|
150
|
+
"tdsAlertDialog": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"mutable": false,
|
|
153
|
+
"complexType": {
|
|
154
|
+
"original": "'alertdialog' | 'dialog'",
|
|
155
|
+
"resolved": "\"alertdialog\" | \"dialog\"",
|
|
156
|
+
"references": {}
|
|
157
|
+
},
|
|
158
|
+
"required": false,
|
|
159
|
+
"optional": false,
|
|
160
|
+
"docs": {
|
|
161
|
+
"tags": [],
|
|
162
|
+
"text": "Role of the message component. Can be either 'alertdialog' for important messages that require immediate attention, or 'dialog' for regular messages."
|
|
163
|
+
},
|
|
164
|
+
"attribute": "tds-alert-dialog",
|
|
165
|
+
"reflect": false,
|
|
166
|
+
"defaultValue": "'dialog'"
|
|
167
|
+
},
|
|
168
|
+
"tdsAriaLabel": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"mutable": false,
|
|
171
|
+
"complexType": {
|
|
172
|
+
"original": "string",
|
|
173
|
+
"resolved": "string",
|
|
174
|
+
"references": {}
|
|
175
|
+
},
|
|
176
|
+
"required": false,
|
|
177
|
+
"optional": false,
|
|
178
|
+
"docs": {
|
|
179
|
+
"tags": [],
|
|
180
|
+
"text": "Provides an accessible name for the message component when no header is present. This ensures proper screen reader support for dialog/alertdialog roles."
|
|
181
|
+
},
|
|
182
|
+
"attribute": "tds-aria-label",
|
|
183
|
+
"reflect": false
|
|
137
184
|
}
|
|
138
185
|
};
|
|
139
186
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h, Host, } from "@stencil/core";
|
|
2
2
|
import hasSlot from "../../utils/hasSlot";
|
|
3
|
+
import generateUniqueId from "../../utils/generateUniqueId";
|
|
3
4
|
/**
|
|
4
5
|
* @slot header - Slot for header text
|
|
5
6
|
* @slot body - Slot for main content of modal
|
|
@@ -9,6 +10,7 @@ export class TdsModal {
|
|
|
9
10
|
constructor() {
|
|
10
11
|
this.handleClose = (event) => {
|
|
11
12
|
const closeEvent = this.tdsClose.emit(event);
|
|
13
|
+
this.returnFocusOnClose();
|
|
12
14
|
if (!closeEvent.defaultPrevented) {
|
|
13
15
|
this.isShown = false;
|
|
14
16
|
}
|
|
@@ -57,15 +59,26 @@ export class TdsModal {
|
|
|
57
59
|
this.referenceEl = undefined;
|
|
58
60
|
this.show = undefined;
|
|
59
61
|
this.closable = true;
|
|
62
|
+
this.tdsAlertDialog = 'dialog';
|
|
60
63
|
this.isShown = false;
|
|
64
|
+
this.activeElementIndex = 0;
|
|
61
65
|
}
|
|
62
66
|
/** Shows the Modal. */
|
|
63
67
|
async showModal() {
|
|
64
68
|
this.isShown = true;
|
|
69
|
+
// Set focus on first element when opened
|
|
70
|
+
requestAnimationFrame(() => {
|
|
71
|
+
const focusableElements = this.getFocusableElements();
|
|
72
|
+
if (focusableElements.length > 0) {
|
|
73
|
+
focusableElements[0].focus();
|
|
74
|
+
this.activeElementIndex = 0;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
65
77
|
}
|
|
66
78
|
/** Closes the Modal. */
|
|
67
79
|
async closeModal() {
|
|
68
80
|
this.isShown = false;
|
|
81
|
+
this.returnFocusOnClose();
|
|
69
82
|
}
|
|
70
83
|
connectedCallback() {
|
|
71
84
|
if (this.closable === undefined) {
|
|
@@ -103,6 +116,63 @@ export class TdsModal {
|
|
|
103
116
|
dismissButton.removeEventListener('click', this.handleClose);
|
|
104
117
|
});
|
|
105
118
|
}
|
|
119
|
+
returnFocusOnClose() {
|
|
120
|
+
var _a;
|
|
121
|
+
let referenceEl = (_a = this.referenceEl) !== null && _a !== void 0 ? _a : document.querySelector(this.selector);
|
|
122
|
+
const potentialReferenceElements = ['BUTTON', 'A', 'INPUT'];
|
|
123
|
+
// If referenced element is a custom element eg: tds-button we find the interactive element inside
|
|
124
|
+
if (potentialReferenceElements.indexOf(referenceEl.tagName) < 0) {
|
|
125
|
+
referenceEl = referenceEl.querySelectorAll(potentialReferenceElements.join(','))[0];
|
|
126
|
+
}
|
|
127
|
+
referenceEl.focus();
|
|
128
|
+
}
|
|
129
|
+
getFocusableElements() {
|
|
130
|
+
const focusableSelectors = [
|
|
131
|
+
'a[href]',
|
|
132
|
+
'button:not([disabled])',
|
|
133
|
+
'textarea:not([disabled])',
|
|
134
|
+
'input:not([disabled])',
|
|
135
|
+
'select:not([disabled])',
|
|
136
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
137
|
+
].join(',');
|
|
138
|
+
const focusableInShadowRoot = Array.from(this.host.shadowRoot.querySelectorAll(focusableSelectors));
|
|
139
|
+
const focusableInSlots = Array.from(this.host.querySelectorAll(focusableSelectors));
|
|
140
|
+
/** Focusable elements */
|
|
141
|
+
return [...focusableInShadowRoot, ...focusableInSlots];
|
|
142
|
+
}
|
|
143
|
+
handleFocusTrap(event) {
|
|
144
|
+
if (event.key === 'Escape' && this.isShown && !this.prevent) {
|
|
145
|
+
this.handleClose(event);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
// Only trap focus if the modal is open
|
|
149
|
+
if (!this.isShown)
|
|
150
|
+
return;
|
|
151
|
+
// We care only about the Tab key
|
|
152
|
+
if (event.key !== 'Tab')
|
|
153
|
+
return;
|
|
154
|
+
const focusableElements = this.getFocusableElements();
|
|
155
|
+
// If there are no focusable elements
|
|
156
|
+
if (focusableElements.length === 0)
|
|
157
|
+
return;
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
// Going backwards (Shift + Tab) on the first element => move to last
|
|
160
|
+
if (event.shiftKey) {
|
|
161
|
+
this.activeElementIndex -= 1;
|
|
162
|
+
if (this.activeElementIndex === -1) {
|
|
163
|
+
this.activeElementIndex = focusableElements.length - 1;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// // Going forwards (Tab) on the last element => move to first
|
|
167
|
+
if (!event.shiftKey) {
|
|
168
|
+
this.activeElementIndex += 1;
|
|
169
|
+
if (this.activeElementIndex === focusableElements.length) {
|
|
170
|
+
this.activeElementIndex = 0;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const nextElement = focusableElements[this.activeElementIndex];
|
|
174
|
+
nextElement.focus();
|
|
175
|
+
}
|
|
106
176
|
/** Adds an event listener to the dismiss buttons that closes the Modal. */
|
|
107
177
|
setDismissButtons() {
|
|
108
178
|
this.host.querySelectorAll('[data-dismiss-modal]').forEach((dismissButton) => {
|
|
@@ -112,10 +182,12 @@ export class TdsModal {
|
|
|
112
182
|
render() {
|
|
113
183
|
const usesHeaderSlot = hasSlot('header', this.host);
|
|
114
184
|
const usesActionsSlot = hasSlot('actions', this.host);
|
|
115
|
-
|
|
185
|
+
const headerId = this.header ? `tds-modal-header-${generateUniqueId()}` : undefined;
|
|
186
|
+
const bodyId = `tds-modal-body-${generateUniqueId()}`;
|
|
187
|
+
return (h(Host, { key: '398809ea45126dd70b95422f2f7a08a481a22d53', role: this.tdsAlertDialog, "aria-modal": "true", "aria-describedby": bodyId, "aria-labelledby": headerId, class: {
|
|
116
188
|
show: this.isShown,
|
|
117
189
|
hide: !this.isShown,
|
|
118
|
-
}, onClick: (event) => this.handleOverlayClick(event) }, h("div", { key: '
|
|
190
|
+
}, onClick: (event) => this.handleOverlayClick(event) }, h("div", { key: '96e964cc4f3c6d9613fb53e340e0aa5dcd8b6d81', class: "tds-modal-backdrop" }), h("div", { key: 'af7ddc896ef35b6116ae70524d10c4b7b952e20a', class: `tds-modal tds-modal__actions-${this.actionsPosition} tds-modal-${this.size}` }, h("div", { key: '9dfcf95fcc8925cd5c97f10f29edc6cef183a0ca', id: headerId, class: "header" }, this.header && h("div", { key: '42533c25b07e696a0c61504556150018f8d3583a', class: "header-text" }, this.header), usesHeaderSlot && h("slot", { key: 'd9855a20e1763ad17d6c8b80df85796d8f6027a8', name: "header" }), this.closable && (h("button", { key: '3e99b76da7bcf39eaecbe2906e0674fd20ebe9a6', class: "tds-modal-close", "aria-label": "close", onClick: (event) => this.handleClose(event) }, h("tds-icon", { key: 'f6463437fb98ae280afe358d50a2f960914014ea', name: "cross", size: "20px" })))), h("div", { key: 'ba8ca2e65f5eac8103e6f3c431e3ae9aab2b5f72', id: bodyId, class: "body" }, h("slot", { key: '9e08cbdd00e1a60826588b15cb6ed23fc4b5b0d7', name: "body" })), usesActionsSlot && h("slot", { key: 'aeb50dfcbf6c12e80a8904d149bb15892c691d88', name: "actions" }))));
|
|
119
191
|
}
|
|
120
192
|
static get is() { return "tds-modal"; }
|
|
121
193
|
static get encapsulation() { return "shadow"; }
|
|
@@ -273,12 +345,31 @@ export class TdsModal {
|
|
|
273
345
|
"attribute": "closable",
|
|
274
346
|
"reflect": false,
|
|
275
347
|
"defaultValue": "true"
|
|
348
|
+
},
|
|
349
|
+
"tdsAlertDialog": {
|
|
350
|
+
"type": "string",
|
|
351
|
+
"mutable": false,
|
|
352
|
+
"complexType": {
|
|
353
|
+
"original": "'alertdialog' | 'dialog'",
|
|
354
|
+
"resolved": "\"alertdialog\" | \"dialog\"",
|
|
355
|
+
"references": {}
|
|
356
|
+
},
|
|
357
|
+
"required": false,
|
|
358
|
+
"optional": false,
|
|
359
|
+
"docs": {
|
|
360
|
+
"tags": [],
|
|
361
|
+
"text": "Role of the modal component. Can be either 'alertdialog' for important messages that require immediate attention, or 'dialog' for regular messages."
|
|
362
|
+
},
|
|
363
|
+
"attribute": "tds-alert-dialog",
|
|
364
|
+
"reflect": false,
|
|
365
|
+
"defaultValue": "'dialog'"
|
|
276
366
|
}
|
|
277
367
|
};
|
|
278
368
|
}
|
|
279
369
|
static get states() {
|
|
280
370
|
return {
|
|
281
|
-
"isShown": {}
|
|
371
|
+
"isShown": {},
|
|
372
|
+
"activeElementIndex": {}
|
|
282
373
|
};
|
|
283
374
|
}
|
|
284
375
|
static get events() {
|
|
@@ -372,4 +463,13 @@ export class TdsModal {
|
|
|
372
463
|
};
|
|
373
464
|
}
|
|
374
465
|
static get elementRef() { return "host"; }
|
|
466
|
+
static get listeners() {
|
|
467
|
+
return [{
|
|
468
|
+
"name": "keydown",
|
|
469
|
+
"method": "handleFocusTrap",
|
|
470
|
+
"target": "window",
|
|
471
|
+
"capture": true,
|
|
472
|
+
"passive": false
|
|
473
|
+
}];
|
|
474
|
+
}
|
|
375
475
|
}
|