@mgdis/mg-components 5.5.0 → 5.7.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-c3450336.js → index-5e7ede97.js} +120 -4
- package/dist/cjs/loader.cjs.js +4 -3
- package/dist/cjs/{mg-badge_30.cjs.entry.js → mg-action-more_31.cjs.entry.js} +1223 -547
- package/dist/cjs/mg-components.cjs.js +7 -3
- package/dist/collection/collection-manifest.json +6 -5
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +13 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +4 -4
- package/dist/collection/components/atoms/mg-button/mg-button.css +9 -22
- package/dist/collection/components/atoms/mg-button/mg-button.js +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.css +13 -6
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +38 -28
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +3 -3
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +6 -6
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +4 -4
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +2 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +14 -17
- package/dist/collection/components/molecules/inputs/MgInput.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +4 -3
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +3 -2
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +5 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +4 -3
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +2 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +8 -4
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +4 -4
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +17 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +27 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +141 -19
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +0 -4
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +48 -21
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +139 -71
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.css +38 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +252 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +2 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +4 -3
- package/dist/collection/components/molecules/mg-message/mg-message.css +7 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +54 -13
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +8 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +19 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +7 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +72 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +64 -7
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +33 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +12 -7
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +105 -57
- package/dist/collection/locales/en/messages.json +10 -1
- package/dist/collection/locales/fr/messages.json +10 -1
- package/dist/collection/locales/index.js +3 -26
- package/dist/collection/styles/a11y.scss +32 -0
- package/dist/collection/styles/components.scss +3 -0
- package/dist/collection/styles/fonts.scss +21 -0
- package/dist/collection/styles/form.scss +3 -0
- package/dist/collection/styles/global.scss +87 -0
- package/dist/collection/styles/layout.scss +29 -0
- package/dist/collection/styles/main.scss +23 -0
- package/dist/collection/styles/mg-icon-animation.scss +6 -0
- package/dist/collection/styles/navigation-button.scss +77 -0
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +9 -0
- package/dist/collection/styles/typography.scss +75 -0
- package/dist/collection/styles/utilities.scss +21 -0
- package/dist/collection/utils/behaviors.utils.js +151 -0
- package/dist/collection/utils/components.utils.js +52 -0
- package/dist/collection/utils/locale.utils.js +28 -6
- package/dist/collection/utils/unit.test.utils.js +65 -32
- package/dist/collection/variables.css +11 -10
- package/dist/components/MgInput.js +6 -1
- package/dist/components/components.utils.js +53 -1
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.js +2 -1
- package/dist/components/index2.js +79 -20
- package/dist/components/mg-action-more.d.ts +11 -0
- package/dist/components/mg-action-more.js +215 -0
- package/dist/components/mg-badge2.js +5 -5
- package/dist/components/mg-button2.js +2 -2
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-form.js +2 -2
- package/dist/components/mg-icon2.js +41 -31
- package/dist/components/mg-illustrated-message.js +4 -3
- package/dist/components/mg-input-checkbox.js +3 -3
- package/dist/components/mg-input-date.js +7 -5
- package/dist/components/mg-input-numeric.js +3 -4
- package/dist/components/mg-input-password.js +1 -1
- package/dist/components/mg-input-radio.js +2 -2
- package/dist/components/mg-input-select2.js +9 -5
- package/dist/components/mg-input-text2.js +1 -1
- package/dist/components/mg-input-textarea.js +2 -2
- package/dist/components/mg-input-toggle.js +1 -1
- package/dist/components/mg-menu-item.js +1 -253
- package/dist/components/mg-menu-item2.js +520 -0
- package/dist/components/mg-menu.js +1 -129
- package/dist/components/mg-menu2.js +247 -0
- package/dist/components/mg-message.js +55 -14
- package/dist/components/mg-modal.js +1 -1
- package/dist/components/mg-pagination.js +3 -1
- package/dist/components/mg-panel.js +3 -3
- package/dist/components/mg-popover.js +1 -190
- package/dist/components/mg-popover2.js +226 -0
- package/dist/components/mg-skip-links.js +16 -2
- package/dist/components/mg-tabs.js +104 -55
- package/dist/components/mg-tag.js +5 -5
- package/dist/components/mg-tooltip2.js +15 -18
- package/dist/esm/{index-78edde1d.js → index-03cceb11.js} +120 -5
- package/dist/esm/loader.js +4 -3
- package/dist/esm/{mg-badge_30.entry.js → mg-action-more_31.entry.js} +1223 -548
- package/dist/esm/mg-components.js +4 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/mg-components/locales/en/messages.json +10 -1
- package/dist/mg-components/locales/fr/messages.json +10 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-4cfd5423.entry.js +1 -0
- package/dist/mg-components/p-e126dd84.js +2 -0
- package/dist/mg-components/styles/a11y.scss +32 -0
- package/dist/mg-components/styles/components.scss +3 -0
- package/dist/mg-components/styles/fonts.scss +21 -0
- package/dist/mg-components/styles/form.scss +3 -0
- package/dist/mg-components/styles/global.scss +87 -0
- package/dist/mg-components/styles/layout.scss +29 -0
- package/dist/mg-components/styles/main.scss +23 -0
- package/dist/mg-components/styles/mg-icon-animation.scss +6 -0
- package/dist/mg-components/styles/navigation-button.scss +77 -0
- package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +9 -0
- package/dist/mg-components/styles/typography.scss +75 -0
- package/dist/mg-components/styles/utilities.scss +21 -0
- package/dist/mg-components/variables.css +11 -10
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +37 -0
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +51 -3
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +0 -8
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +61 -15
- package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +42 -0
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +81 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +21 -4
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +4 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +13 -0
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +1 -1
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +15 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -3
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +22 -12
- package/dist/types/components.d.ts +98 -12
- package/dist/types/locales/index.d.ts +21 -10
- package/dist/types/stencil-public-runtime.d.ts +48 -3
- package/dist/types/utils/behaviors.utils.d.ts +77 -0
- package/dist/types/utils/components.utils.d.ts +14 -0
- package/dist/types/utils/locale.utils.d.ts +16 -3
- package/dist/types/utils/unit.test.utils.d.ts +68 -14
- package/loader/index.d.ts +9 -0
- package/package.json +28 -27
- package/readme.md +22 -31
- package/dist/.storybook/utils.js +0 -24
- package/dist/collection/components/atoms/mg-badge/doc/mg-badge.stories.js +0 -27
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -38
- package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +0 -18
- package/dist/collection/components/atoms/mg-character-left/doc/mg-character-left.stories.js +0 -20
- package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +0 -18
- package/dist/collection/components/atoms/mg-icon/doc/mg-icon.stories.js +0 -41
- package/dist/collection/components/atoms/mg-input-title/doc/mg-input-title.stories.js +0 -21
- package/dist/collection/components/atoms/mg-tag/doc/mg-tag.stories.js +0 -22
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -50
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/doc/mg-input-checkbox.stories.js +0 -50
- package/dist/collection/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.js +0 -43
- package/dist/collection/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.js +0 -68
- package/dist/collection/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.js +0 -46
- package/dist/collection/components/molecules/inputs/mg-input-radio/doc/mg-input-radio.stories.js +0 -59
- package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +0 -77
- package/dist/collection/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.js +0 -110
- package/dist/collection/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.js +0 -54
- package/dist/collection/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.js +0 -51
- package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +0 -87
- package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +0 -39
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +0 -24
- package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +0 -47
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +0 -19
- package/dist/collection/components/molecules/mg-message/doc/mg-message.stories.js +0 -39
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +0 -39
- package/dist/collection/components/molecules/mg-pagination/doc/mg-pagination.stories.js +0 -20
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +0 -22
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -34
- package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +0 -24
- package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +0 -51
- package/dist/collection/stories/grids.stories.js +0 -7
- package/dist/collection/stories/helpers.stories.js +0 -23
- package/dist/collection/stories/icons.stories.js +0 -25
- package/dist/collection/stories/typography.stories.js +0 -24
- package/dist/components/locale.utils.js +0 -40
- package/dist/components/mg-menu.conf.js +0 -10
- package/dist/mg-components/p-125c54ca.js +0 -2
- package/dist/mg-components/p-4961c96c.entry.js +0 -1
- package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +0 -13
- package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +0 -16
- package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-character-left/doc/mg-character-left.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-icon/doc/mg-icon.stories.d.ts +0 -26
- package/dist/types/components/atoms/mg-input-title/doc/mg-input-title.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tag/doc/mg-tag.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -18
- package/dist/types/components/molecules/inputs/mg-input-checkbox/doc/mg-input-checkbox.stories.d.ts +0 -11
- package/dist/types/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.d.ts +0 -12
- package/dist/types/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.d.ts +0 -32
- package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +0 -22
- package/dist/types/components/molecules/inputs/mg-input-radio/doc/mg-input-radio.stories.d.ts +0 -20
- package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +0 -34
- package/dist/types/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.d.ts +0 -39
- package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +0 -19
- package/dist/types/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.d.ts +0 -12
- package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +0 -17
- package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +0 -12
- package/dist/types/components/molecules/mg-details/doc/mg-details.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-form/doc/mg-form.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-message/doc/mg-message.stories.d.ts +0 -26
- package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +0 -13
- package/dist/types/components/molecules/mg-pagination/doc/mg-pagination.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -22
- package/dist/types/components/molecules/mg-skip-links/doc/mg-skip-links.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +0 -20
- package/dist/types/home/runner/work/mg-components/mg-components/.stencil/.storybook/utils.d.ts +0 -1
- package/dist/types/stories/grids.stories.d.ts +0 -5
- package/dist/types/stories/helpers.stories.d.ts +0 -13
- package/dist/types/stories/icons.stories.d.ts +0 -13
- package/dist/types/stories/typography.stories.d.ts +0 -5
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paragraph
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
p {
|
|
6
|
+
margin: 0;
|
|
7
|
+
& + p {
|
|
8
|
+
margin-top: 1rem;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Headings
|
|
14
|
+
*
|
|
15
|
+
* Classes can also be used on element to match attending, for exemples :
|
|
16
|
+
* <h4 class="h3">blu</h4>
|
|
17
|
+
* <div role="heading" aria-level="4" class="h4">blu</div>
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
@for $i from 1 through 6 {
|
|
21
|
+
h#{$i},
|
|
22
|
+
.h#{$i} {
|
|
23
|
+
font-family: var(--font-family-heading);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//h1
|
|
28
|
+
h1,
|
|
29
|
+
.h1 {
|
|
30
|
+
font-size: calc(var(--font-size) * 1.85);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//h2
|
|
34
|
+
h2,
|
|
35
|
+
.h2 {
|
|
36
|
+
font-size: calc(var(--font-size) * 1.65);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//h3
|
|
40
|
+
h3,
|
|
41
|
+
.h3 {
|
|
42
|
+
font-size: calc(var(--font-size) * 1.35);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//h4
|
|
46
|
+
h4,
|
|
47
|
+
.h4 {
|
|
48
|
+
font-size: calc(var(--font-size) * 1.2);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//h5
|
|
52
|
+
h5,
|
|
53
|
+
.h5 {
|
|
54
|
+
font-size: calc(var(--font-size) * 1.1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//h6
|
|
58
|
+
h6,
|
|
59
|
+
.h6 {
|
|
60
|
+
font-size: calc(var(--font-size) * 0.8);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Links
|
|
65
|
+
*/
|
|
66
|
+
a {
|
|
67
|
+
color: hsl(var(--color-primary));
|
|
68
|
+
text-decoration: underline;
|
|
69
|
+
|
|
70
|
+
&:hover,
|
|
71
|
+
&:focus,
|
|
72
|
+
&:active {
|
|
73
|
+
text-decoration: none;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Helper to manage space between elements
|
|
2
|
+
.mg-group-elements {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
flex-wrap: wrap;
|
|
6
|
+
gap: 1rem;
|
|
7
|
+
|
|
8
|
+
// remove default margin
|
|
9
|
+
& > * {
|
|
10
|
+
margin: 0 !important; // I would say important is allowed in utility classes ?
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Align button on right side
|
|
14
|
+
&.mg-group-elements--align-right {
|
|
15
|
+
justify-content: flex-end;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.no-padding {
|
|
20
|
+
padding: 0;
|
|
21
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MgMenuItem type guard
|
|
3
|
+
*
|
|
4
|
+
* @param {HTMLElement} element element to control type
|
|
5
|
+
* @returns {boolean} truthy if element is mg-menu-item
|
|
6
|
+
*/
|
|
7
|
+
const isMgMenuItem = (element) => element.nodeName === 'MG-MENU-ITEM';
|
|
8
|
+
export var OverflowBehaviorElements;
|
|
9
|
+
(function (OverflowBehaviorElements) {
|
|
10
|
+
OverflowBehaviorElements["MORE"] = "data-overflow-more";
|
|
11
|
+
OverflowBehaviorElements["BASE_INDEX"] = "data-overflow-base-index";
|
|
12
|
+
OverflowBehaviorElements["PROXY_INDEX"] = "data-overflow-proxy-index";
|
|
13
|
+
})(OverflowBehaviorElements || (OverflowBehaviorElements = {}));
|
|
14
|
+
export class OverflowBehavior {
|
|
15
|
+
constructor(element, render) {
|
|
16
|
+
this.element = element;
|
|
17
|
+
this.render = render;
|
|
18
|
+
/**********
|
|
19
|
+
* Public *
|
|
20
|
+
**********/
|
|
21
|
+
/**
|
|
22
|
+
* Disconnect ResizeObserver
|
|
23
|
+
*
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*/
|
|
26
|
+
this.disconnect = () => {
|
|
27
|
+
this.resizeObserver.disconnect();
|
|
28
|
+
};
|
|
29
|
+
/************
|
|
30
|
+
* Internal *
|
|
31
|
+
************/
|
|
32
|
+
/**
|
|
33
|
+
* run overflow behavior
|
|
34
|
+
*
|
|
35
|
+
* @param {number} width width of the container
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
38
|
+
this.run = (width) => {
|
|
39
|
+
if (this.moreElement === undefined) {
|
|
40
|
+
// set moreElement
|
|
41
|
+
this.moreElement = this.render();
|
|
42
|
+
this.moreElement.setAttribute(OverflowBehaviorElements.MORE, '');
|
|
43
|
+
// set children
|
|
44
|
+
this.children = Array.from(this.element.children);
|
|
45
|
+
let moreElementChildren;
|
|
46
|
+
const allowedElements = ['MG-MENU-ITEM', 'MG-BUTTON'];
|
|
47
|
+
if (isMgMenuItem(this.moreElement)) {
|
|
48
|
+
moreElementChildren = Array.from(this.moreElement.querySelector('mg-menu').children).filter(element => allowedElements.includes(element.nodeName));
|
|
49
|
+
}
|
|
50
|
+
this.children.forEach((child, index) => {
|
|
51
|
+
child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);
|
|
52
|
+
if (child.getAttribute(OverflowBehaviorElements.MORE) === null) {
|
|
53
|
+
// set moreElement children
|
|
54
|
+
moreElementChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
this.updateDisplayedItems(width);
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Update displayed items in container from a given available space
|
|
62
|
+
*
|
|
63
|
+
* @param {number} availableWidth available width in container to display child items
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*/
|
|
66
|
+
this.updateDisplayedItems = (availableWidth) => {
|
|
67
|
+
this.restoreItems();
|
|
68
|
+
const acc = { accWidth: 0, previousItem: null };
|
|
69
|
+
this.children.forEach((child) => {
|
|
70
|
+
acc.accWidth += child.offsetWidth;
|
|
71
|
+
const isPreviousItemHidden = acc.previousItem !== null && acc.previousItem.getAttribute('hidden') !== null;
|
|
72
|
+
// if previous item is hidden AND is NOT more element we hidde current
|
|
73
|
+
// OR if item has an overflow we hidde current
|
|
74
|
+
// OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item
|
|
75
|
+
// ELSE current is a display item
|
|
76
|
+
this.toggleItem(child, (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden));
|
|
77
|
+
// update previous item with current item
|
|
78
|
+
acc.previousItem = child;
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Utility method to know if item overflow partialy or totaly in the container
|
|
83
|
+
*
|
|
84
|
+
* @param {number} cumulateWidth previous sibling elements cumulate width + item width
|
|
85
|
+
* @param {HTMLElement} item item HTML element
|
|
86
|
+
* @param {number} availableWidth container available width
|
|
87
|
+
* @returns {boolean} truthy if element is overflow
|
|
88
|
+
*/
|
|
89
|
+
this.isOverflowElement = (cumulateWidth, item, availableWidth) => {
|
|
90
|
+
if (item.previousElementSibling === null || this.isMoreElement(item))
|
|
91
|
+
return false;
|
|
92
|
+
else if (!this.isMoreElement(item.nextElementSibling))
|
|
93
|
+
return cumulateWidth + this.moreElement.offsetWidth > availableWidth;
|
|
94
|
+
else
|
|
95
|
+
return cumulateWidth > availableWidth;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Utility method to know if a given element is the 'MORE' element
|
|
99
|
+
*
|
|
100
|
+
* @param {Element} element element to match with 'MORE' element
|
|
101
|
+
* @returns {boolean} truthy if element is the 'MORE' element
|
|
102
|
+
*/
|
|
103
|
+
this.isMoreElement = (element) => element.getAttribute(OverflowBehaviorElements.MORE) !== null;
|
|
104
|
+
/**
|
|
105
|
+
* Toggle display item element
|
|
106
|
+
*
|
|
107
|
+
* @param {HTMLElement} item item to control
|
|
108
|
+
* @param {boolean} isHidden is item hidden
|
|
109
|
+
* @returns {void}
|
|
110
|
+
*/
|
|
111
|
+
this.toggleItem = (item, isHidden) => {
|
|
112
|
+
const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));
|
|
113
|
+
if (this.isMoreElement(item))
|
|
114
|
+
this.toggleElement(this.moreElement, isHidden);
|
|
115
|
+
else if (mgActionMenuindex >= 0) {
|
|
116
|
+
this.toggleElement(item, isHidden);
|
|
117
|
+
this.toggleElement(this.moreElement.querySelector(`[${OverflowBehaviorElements.PROXY_INDEX}="${mgActionMenuindex}"]`), !isHidden);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Toggle element's hidde attribute
|
|
122
|
+
*
|
|
123
|
+
* @param {Element} element element to toggle
|
|
124
|
+
* @param {boolean} isHidden element is hidden
|
|
125
|
+
* @returns {void}
|
|
126
|
+
*/
|
|
127
|
+
this.toggleElement = (element, isHidden) => {
|
|
128
|
+
if (isHidden)
|
|
129
|
+
element.setAttribute('hidden', '');
|
|
130
|
+
else
|
|
131
|
+
element.removeAttribute('hidden');
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Remove hidden attributes on all items
|
|
135
|
+
*
|
|
136
|
+
* @returns {void}
|
|
137
|
+
*/
|
|
138
|
+
this.restoreItems = () => {
|
|
139
|
+
this.children.forEach(item => item.removeAttribute('hidden'));
|
|
140
|
+
};
|
|
141
|
+
if (this.resizeObserver === undefined) {
|
|
142
|
+
// add resize observer
|
|
143
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
144
|
+
entries.forEach(entry => {
|
|
145
|
+
this.run(entry.contentRect.width);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
this.resizeObserver.observe(this.element);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -86,3 +86,55 @@ export const isTagName = (element, tagNames) => {
|
|
|
86
86
|
* Focusable elements query selector
|
|
87
87
|
*/
|
|
88
88
|
export const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param {Window} localWindow the window we are lookink for other windows
|
|
92
|
+
* @returns {Window[]} The list of windows found
|
|
93
|
+
*/
|
|
94
|
+
export const getWindows = (localWindow) => {
|
|
95
|
+
const parentWindows = getParentWindows(localWindow);
|
|
96
|
+
const childWindows = getChildWindows(localWindow);
|
|
97
|
+
return [localWindow, ...parentWindows, ...childWindows];
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Get parent windows
|
|
101
|
+
*
|
|
102
|
+
* @param {Window} localWindow the window we are lookink for parents
|
|
103
|
+
* @param {Window[]} windows The list of allready found windows
|
|
104
|
+
* @returns {Window[]} The list of windows found
|
|
105
|
+
*/
|
|
106
|
+
export const getParentWindows = (localWindow, windows = []) => {
|
|
107
|
+
// Check if is in iframe
|
|
108
|
+
if (localWindow.self !== localWindow.top) {
|
|
109
|
+
// Check if we have permission to access parent
|
|
110
|
+
try {
|
|
111
|
+
const parentWindow = localWindow.parent;
|
|
112
|
+
windows.push(parentWindow);
|
|
113
|
+
return getParentWindows(parentWindow, windows);
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
console.error('Different hosts between iframes:', err);
|
|
117
|
+
return windows;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return windows;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Get child windows
|
|
124
|
+
*
|
|
125
|
+
* @param {Window} localWindow the window we are lookink for children
|
|
126
|
+
* @param {Window[]} windows The list of allready found windows
|
|
127
|
+
* @returns {Window[]} The list of windows found
|
|
128
|
+
*/
|
|
129
|
+
const getChildWindows = (localWindow, windows = []) => {
|
|
130
|
+
if (localWindow.frames.length > 0) {
|
|
131
|
+
// Window.frames is an array-like object, needs a classic for loop
|
|
132
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/frames
|
|
133
|
+
for (let i = 0; i < localWindow.frames.length; i++) {
|
|
134
|
+
const childWindow = localWindow.frames[i];
|
|
135
|
+
windows.push(childWindow);
|
|
136
|
+
getChildWindows(childWindow, windows);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return windows;
|
|
140
|
+
};
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* @param {string} currency currency to apply
|
|
7
7
|
* @returns {string} formatted currency
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export const localeCurrency = (number, locale, currency) => {
|
|
10
10
|
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
12
|
/**
|
|
13
13
|
* Format number to locale
|
|
14
14
|
*
|
|
@@ -16,9 +16,9 @@ export function localeCurrency(number, locale, currency) {
|
|
|
16
16
|
* @param {string} locale locale to apply
|
|
17
17
|
* @returns {string} formatted number
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export const localeNumber = (number, locale) => {
|
|
20
20
|
return new Intl.NumberFormat(locale).format(number);
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
/**
|
|
23
23
|
* Date RegExp
|
|
24
24
|
*/
|
|
@@ -30,9 +30,31 @@ export const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
|
30
30
|
* @param {string} locale locale to apply
|
|
31
31
|
* @returns {string} formatted date
|
|
32
32
|
*/
|
|
33
|
-
export
|
|
33
|
+
export const localeDate = (date, locale) => {
|
|
34
34
|
if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
|
|
35
35
|
return '';
|
|
36
36
|
}
|
|
37
37
|
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
38
|
-
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Get locale and messages
|
|
41
|
+
* We load the defined locale but for now we only support the first subtag for messages
|
|
42
|
+
*
|
|
43
|
+
* @param {HTMLElement} element element we need to get the language
|
|
44
|
+
* @param {unknown} messages messages to use
|
|
45
|
+
* @param {string} defaultLocale default messages locale
|
|
46
|
+
* @returns {{ locale: string; messages: Record<string, unknown> }} messages object
|
|
47
|
+
*/
|
|
48
|
+
export const getLocaleMessages = (element, messages, defaultLocale) => {
|
|
49
|
+
// Get local
|
|
50
|
+
const closestLangAttribute = element.closest('[lang]');
|
|
51
|
+
const closestLang = Intl.NumberFormat.supportedLocalesOf(closestLangAttribute === null || closestLangAttribute === void 0 ? void 0 : closestLangAttribute.lang);
|
|
52
|
+
const locale = closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;
|
|
53
|
+
// Only keep first subtag
|
|
54
|
+
const localeSubtag = locale.split('-').shift();
|
|
55
|
+
// Return
|
|
56
|
+
return {
|
|
57
|
+
locale,
|
|
58
|
+
messages: messages[localeSubtag] || messages[defaultLocale],
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -5,29 +5,6 @@
|
|
|
5
5
|
* @returns {unknown} cloned json
|
|
6
6
|
*/
|
|
7
7
|
export const cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
|
|
8
|
-
/**
|
|
9
|
-
* Utility function that mocks the `MutationObserver` API. Recommended to execute inside `beforeEach`.
|
|
10
|
-
*
|
|
11
|
-
* @param mutationObserverMock - Parameter that is sent to the `Object.defineProperty`
|
|
12
|
-
* overwrite method. `jest.fn()` mock functions can be passed here if the goal is to not only
|
|
13
|
-
* mock the resize observer, but its methods.
|
|
14
|
-
* You can manually fire an intersection entry:
|
|
15
|
-
* @param {Function} mutationObserverMock.disconnect disconnect function
|
|
16
|
-
* @param {Function} mutationObserverMock.observe observe fnuction
|
|
17
|
-
* @param {Function} mutationObserverMock.takeRecords takeRecords fnuction
|
|
18
|
-
* @returns {MutationObserver} Mocked MutationObserver
|
|
19
|
-
* @example
|
|
20
|
-
* ```
|
|
21
|
-
* let fireMo;
|
|
22
|
-
* setupMutationObserverMock({
|
|
23
|
-
* observe: function () {
|
|
24
|
-
* fireMo = this.cb;
|
|
25
|
-
* },
|
|
26
|
-
* });
|
|
27
|
-
* ...
|
|
28
|
-
* fireMo([{ type: 'childList', addedNodes: [AMockElemenet, AnotherMockElemenet], target: yourMockElemenet }]);;
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
8
|
export const setupMutationObserverMock = ({ disconnect, observe, takeRecords }) => {
|
|
32
9
|
class MockMutationObserver {
|
|
33
10
|
constructor(fn) {
|
|
@@ -37,15 +14,71 @@ export const setupMutationObserverMock = ({ disconnect, observe, takeRecords })
|
|
|
37
14
|
this.cb = fn;
|
|
38
15
|
}
|
|
39
16
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
writable: true,
|
|
47
|
-
configurable: true,
|
|
48
|
-
value: MockMutationObserver,
|
|
17
|
+
[window, global].forEach(element => {
|
|
18
|
+
Object.defineProperty(element, 'MutationObserver', {
|
|
19
|
+
writable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
value: MockMutationObserver,
|
|
22
|
+
});
|
|
49
23
|
});
|
|
50
24
|
return MockMutationObserver;
|
|
51
25
|
};
|
|
26
|
+
export const setupResizeObserverMock = ({ disconnect, observe }) => {
|
|
27
|
+
class MockResizeObserver {
|
|
28
|
+
constructor(fn) {
|
|
29
|
+
this.disconnect = disconnect;
|
|
30
|
+
this.observe = observe;
|
|
31
|
+
this.cb = fn;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
[window, global].forEach(element => {
|
|
35
|
+
Object.defineProperty(element, 'ResizeObserver', {
|
|
36
|
+
writable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
value: MockResizeObserver,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
return MockResizeObserver;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* force popover id when component use randomed identifier
|
|
45
|
+
*
|
|
46
|
+
* @param {Element} component element wich include mg-popover
|
|
47
|
+
* @param {string} id new fixed id
|
|
48
|
+
* @param {string} interactiveElement element where attribute 'aria-controls' is set
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
export const forcePopoverId = (component, id, interactiveElement = 'button') => {
|
|
52
|
+
const popover = component.shadowRoot.querySelector('mg-popover');
|
|
53
|
+
if (popover !== null) {
|
|
54
|
+
popover.shadowRoot.querySelector('.mg-popover').setAttribute('id', id);
|
|
55
|
+
component.shadowRoot.querySelector(interactiveElement).setAttribute('aria-controls', id);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* fix popper console.error in test
|
|
60
|
+
* it is generated in @popperjs/core/dist/cjs/popper.js l.1859
|
|
61
|
+
* this is due to internal function isHTMLElement(), so we can not mock it directly.
|
|
62
|
+
* this function check if test DOM element mockHTMLElement instance is 'instanceof HTMLElement'
|
|
63
|
+
* so we only override the console.error side effect for this error
|
|
64
|
+
*
|
|
65
|
+
* @returns {void}
|
|
66
|
+
*/
|
|
67
|
+
export const mockConsoleError = () => {
|
|
68
|
+
jest.spyOn(console, 'error').mockImplementation(error => {
|
|
69
|
+
const compareWith = 'Popper: "arrow" element must be an HTMLElement (not an SVGElement). To use an SVG arrow, wrap it in an HTMLElement that will be used as the arrow.';
|
|
70
|
+
if (error !== compareWith)
|
|
71
|
+
console.log(error);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Add missing window.frames property to test context
|
|
76
|
+
* usefull for component with iframe listeners, ex: mg-popover
|
|
77
|
+
*
|
|
78
|
+
* @returns {void}
|
|
79
|
+
*/
|
|
80
|
+
export const mockWindowFrames = () => {
|
|
81
|
+
Object.defineProperty(window, 'frames', {
|
|
82
|
+
value: { length: 0 },
|
|
83
|
+
});
|
|
84
|
+
};
|
|
@@ -96,12 +96,13 @@
|
|
|
96
96
|
--color-secondary: hsl(var(--color-neutral));
|
|
97
97
|
|
|
98
98
|
/* Shadow */
|
|
99
|
-
--box-shadow: 0 0.3rem 0.8rem 0
|
|
99
|
+
--box-shadow: 0 0.3rem 0.8rem 0 hsl(var(--color-dark), 0.15);
|
|
100
100
|
|
|
101
101
|
/*
|
|
102
102
|
Global
|
|
103
103
|
*/
|
|
104
104
|
--default-size: 3.5rem;
|
|
105
|
+
--mg-disabled-opacity: 0.4;
|
|
105
106
|
|
|
106
107
|
/*
|
|
107
108
|
<mg-icon>
|
|
@@ -117,7 +118,7 @@
|
|
|
117
118
|
|
|
118
119
|
--mg-button-border-radius: 0.3rem;
|
|
119
120
|
--mg-button-icon-border-radius: var(--default-size);
|
|
120
|
-
--mg-button-disabled-opacity:
|
|
121
|
+
--mg-button-disabled-opacity: var(--mg-disabled-opacity);
|
|
121
122
|
--mg-button-gradient: 1; /* Can only be 1 or 0 to enable disable gradient */
|
|
122
123
|
--mg-button-border-variation: 1; /* Can only be 1 or 0 to enable disable border variation */
|
|
123
124
|
|
|
@@ -180,7 +181,7 @@
|
|
|
180
181
|
--mg-panel-box-shadow: var(--box-shadow);
|
|
181
182
|
--mg-panel-content-padding: 1.5rem;
|
|
182
183
|
|
|
183
|
-
|
|
184
|
+
/*
|
|
184
185
|
<mg-illustrated-message>
|
|
185
186
|
*/
|
|
186
187
|
|
|
@@ -189,16 +190,16 @@
|
|
|
189
190
|
/*
|
|
190
191
|
<mg-card>
|
|
191
192
|
*/
|
|
192
|
-
--mg-card-padding: 1.6rem;
|
|
193
|
-
--mg-card-border-radius: 0.5rem;
|
|
194
|
-
--mg-card-background: hsl(var(--color-light));
|
|
195
|
-
--mg-card-border: 0.1rem solid
|
|
196
|
-
--mg-card-box-shadow: var(--box-shadow);
|
|
193
|
+
--mg-card-padding-default: 1.6rem;
|
|
194
|
+
--mg-card-border-radius-default: 0.5rem;
|
|
195
|
+
--mg-card-background-default: hsl(var(--color-light));
|
|
196
|
+
--mg-card-border-default: 0.1rem solid hsl(var(--color-dark), 0.05);
|
|
197
|
+
--mg-card-box-shadow-default: var(--box-shadow);
|
|
197
198
|
|
|
198
199
|
/*
|
|
199
200
|
<mg-divider>
|
|
200
201
|
*/
|
|
201
|
-
--mg-divider-background-color:
|
|
202
|
+
--mg-divider-background-color: hsl(var(--color-dark), 0.15);
|
|
202
203
|
--mg-divider-thickness: 0.1rem;
|
|
203
204
|
--mg-divider-vertical-spacing: 4rem;
|
|
204
205
|
|
|
@@ -245,7 +246,7 @@
|
|
|
245
246
|
--mg-menu-item-focused-background-color-hsl: var(--mg-color-app-hsl);
|
|
246
247
|
--mg-menu-item-border-color-active-hsl: var(--mg-color-app-hsl);
|
|
247
248
|
--mg-menu-item-color-active-hsl: var(--mg-color-app-hsl);
|
|
248
|
-
|
|
249
|
+
|
|
249
250
|
/*
|
|
250
251
|
<mg-tabs>
|
|
251
252
|
*/
|
|
@@ -59,6 +59,11 @@ const MgInput = (props, children, utils) => {
|
|
|
59
59
|
if (props.labelOnTop && props.labelHide) {
|
|
60
60
|
throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide".');
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Set readonly value
|
|
64
|
+
*/
|
|
65
|
+
if (props.readonlyValue === undefined)
|
|
66
|
+
props.readonlyValue = props.value;
|
|
62
67
|
/**
|
|
63
68
|
* Component classes
|
|
64
69
|
*/
|
|
@@ -112,7 +117,7 @@ const MgInput = (props, children, utils) => {
|
|
|
112
117
|
getInputTitle(),
|
|
113
118
|
!props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
|
|
114
119
|
props.readonly ? (h("div", { class: "mg-input__input-container" },
|
|
115
|
-
h("strong", null, props.readonlyValue
|
|
120
|
+
h("strong", null, props.readonlyValue),
|
|
116
121
|
children.filter(child => child.$name$ === 'append-input'))) : (h("div", { class: "mg-input__input-container" },
|
|
117
122
|
h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } },
|
|
118
123
|
applyAriadescribedBy(children, ariaDescribedbyIDs, utils),
|
|
@@ -86,5 +86,57 @@ const isTagName = (element, tagNames) => {
|
|
|
86
86
|
* Focusable elements query selector
|
|
87
87
|
*/
|
|
88
88
|
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param {Window} localWindow the window we are lookink for other windows
|
|
92
|
+
* @returns {Window[]} The list of windows found
|
|
93
|
+
*/
|
|
94
|
+
const getWindows = (localWindow) => {
|
|
95
|
+
const parentWindows = getParentWindows(localWindow);
|
|
96
|
+
const childWindows = getChildWindows(localWindow);
|
|
97
|
+
return [localWindow, ...parentWindows, ...childWindows];
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Get parent windows
|
|
101
|
+
*
|
|
102
|
+
* @param {Window} localWindow the window we are lookink for parents
|
|
103
|
+
* @param {Window[]} windows The list of allready found windows
|
|
104
|
+
* @returns {Window[]} The list of windows found
|
|
105
|
+
*/
|
|
106
|
+
const getParentWindows = (localWindow, windows = []) => {
|
|
107
|
+
// Check if is in iframe
|
|
108
|
+
if (localWindow.self !== localWindow.top) {
|
|
109
|
+
// Check if we have permission to access parent
|
|
110
|
+
try {
|
|
111
|
+
const parentWindow = localWindow.parent;
|
|
112
|
+
windows.push(parentWindow);
|
|
113
|
+
return getParentWindows(parentWindow, windows);
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
console.error('Different hosts between iframes:', err);
|
|
117
|
+
return windows;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return windows;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Get child windows
|
|
124
|
+
*
|
|
125
|
+
* @param {Window} localWindow the window we are lookink for children
|
|
126
|
+
* @param {Window[]} windows The list of allready found windows
|
|
127
|
+
* @returns {Window[]} The list of windows found
|
|
128
|
+
*/
|
|
129
|
+
const getChildWindows = (localWindow, windows = []) => {
|
|
130
|
+
if (localWindow.frames.length > 0) {
|
|
131
|
+
// Window.frames is an array-like object, needs a classic for loop
|
|
132
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/frames
|
|
133
|
+
for (let i = 0; i < localWindow.frames.length; i++) {
|
|
134
|
+
const childWindow = localWindow.frames[i];
|
|
135
|
+
windows.push(childWindow);
|
|
136
|
+
getChildWindows(childWindow, windows);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return windows;
|
|
140
|
+
};
|
|
89
141
|
|
|
90
|
-
export { ClassList as C, allItemsAreString as a, createID as c, focusableElements as f, isTagName as i };
|
|
142
|
+
export { ClassList as C, allItemsAreString as a, createID as c, focusableElements as f, getWindows as g, isTagName as i };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* MgComponents custom elements */
|
|
2
|
+
export { MgActionMore as MgActionMore } from '../types/components/molecules/mg-action-more/mg-action-more';
|
|
2
3
|
export { MgBadge as MgBadge } from '../types/components/atoms/mg-badge/mg-badge';
|
|
3
4
|
export { MgButton as MgButton } from '../types/components/atoms/mg-button/mg-button';
|
|
4
5
|
export { MgCard as MgCard } from '../types/components/atoms/mg-card/mg-card';
|
|
@@ -42,6 +43,15 @@ export { MgTooltip as MgTooltip } from '../types/components/atoms/mg-tooltip/mg-
|
|
|
42
43
|
*/
|
|
43
44
|
export declare const setAssetPath: (path: string) => void;
|
|
44
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Used to specify a nonce value that corresponds with an application's CSP.
|
|
48
|
+
* When set, the nonce will be added to all dynamically created script and style tags at runtime.
|
|
49
|
+
* Alternatively, the nonce value can be set on a meta tag in the DOM head
|
|
50
|
+
* (<meta name="csp-nonce" content="{ nonce value here }" />) which
|
|
51
|
+
* will result in the same behavior.
|
|
52
|
+
*/
|
|
53
|
+
export declare const setNonce: (nonce: string) => void
|
|
54
|
+
|
|
45
55
|
export interface SetPlatformOptions {
|
|
46
56
|
raf?: (c: FrameRequestCallback) => number;
|
|
47
57
|
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
package/dist/components/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|
|
1
|
+
export { setAssetPath, setNonce, setPlatformOptions } from '@stencil/core/internal/client';
|
|
2
|
+
export { MgActionMore, defineCustomElement as defineCustomElementMgActionMore } from './mg-action-more.js';
|
|
2
3
|
export { MgBadge, defineCustomElement as defineCustomElementMgBadge } from './mg-badge.js';
|
|
3
4
|
export { MgButton, defineCustomElement as defineCustomElementMgButton } from './mg-button.js';
|
|
4
5
|
export { MgCard, defineCustomElement as defineCustomElementMgCard } from './mg-card.js';
|