@mgdis/mg-components 5.4.0 → 5.6.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-94497267.js → index-4dcc1812.js} +11 -1
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{mg-badge_29.cjs.entry.js → mg-badge_30.cjs.entry.js} +1112 -859
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +5 -4
- package/dist/collection/components/atoms/mg-badge/doc/mg-badge.stories.js +0 -7
- 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 +7 -10
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -7
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.css +15 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +12 -29
- package/dist/collection/components/atoms/mg-card/mg-card.css +17 -5
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +2 -3
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +0 -6
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +13 -3
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +5 -12
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +4 -8
- package/dist/collection/components/atoms/mg-tag/doc/mg-tag.stories.js +1 -9
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +58 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +61 -16
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +2 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +9 -22
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +17 -33
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +21 -26
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +24 -47
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +17 -29
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +18 -33
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +30 -36
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +23 -41
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +23 -45
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +16 -33
- package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +43 -11
- 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 +145 -25
- package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +7 -5
- 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 +51 -21
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +129 -92
- package/dist/collection/components/molecules/mg-details/mg-details.js +4 -8
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -22
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css +2 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +4 -9
- package/dist/collection/components/molecules/mg-message/mg-message.css +20 -19
- package/dist/collection/components/molecules/mg-message/mg-message.js +55 -33
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +20 -8
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -26
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +4 -13
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +17 -5
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +11 -22
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +82 -20
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +54 -26
- package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +24 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.conf.js +1 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.css +28 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +108 -0
- package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +5 -3
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +11 -7
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +109 -75
- package/dist/collection/locales/en/messages.json +7 -0
- package/dist/collection/locales/fr/messages.json +7 -0
- package/dist/collection/locales/index.js +2 -25
- 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/navigation-button.scss +76 -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 +169 -0
- package/dist/collection/utils/components.utils.js +50 -0
- package/dist/collection/utils/locale.utils.js +22 -0
- package/dist/collection/utils/unit.test.utils.js +37 -32
- package/dist/collection/variables.css +9 -9
- package/dist/components/components.utils.js +51 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +73 -18
- package/dist/components/mg-badge2.js +8 -11
- package/dist/components/mg-button2.js +13 -30
- package/dist/components/mg-card.js +1 -37
- package/dist/components/mg-card2.js +39 -0
- package/dist/components/mg-character-left2.js +2 -3
- package/dist/components/mg-details.js +4 -8
- package/dist/components/mg-divider.js +0 -6
- package/dist/components/mg-form.js +8 -22
- package/dist/components/mg-icon2.js +18 -15
- package/dist/components/mg-illustrated-message.js +5 -10
- package/dist/components/mg-input-checkbox.js +17 -33
- package/dist/components/mg-input-date.js +23 -29
- package/dist/components/mg-input-numeric.js +26 -50
- package/dist/components/mg-input-password.js +18 -30
- package/dist/components/mg-input-radio.js +18 -33
- package/dist/components/mg-input-select2.js +32 -38
- package/dist/components/mg-input-text2.js +24 -42
- package/dist/components/mg-input-textarea.js +24 -46
- package/dist/components/mg-input-title2.js +4 -8
- package/dist/components/mg-input-toggle.js +16 -33
- package/dist/components/mg-menu-item.js +1 -264
- package/dist/components/mg-menu-item2.js +517 -0
- package/dist/components/mg-menu.js +142 -28
- package/dist/components/mg-message.js +64 -36
- package/dist/components/mg-modal.js +18 -30
- package/dist/components/mg-pagination.js +4 -13
- package/dist/components/mg-panel.js +20 -25
- package/dist/components/mg-popover.js +1 -200
- package/dist/components/mg-popover2.js +212 -0
- package/dist/components/mg-skip-links.d.ts +11 -0
- package/dist/components/mg-skip-links.js +80 -0
- package/dist/components/mg-tabs.js +108 -73
- package/dist/components/mg-tag.js +35 -13
- package/dist/components/mg-tooltip2.js +10 -23
- package/dist/esm/{index-aad0184c.js → index-dc9a2348.js} +11 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{mg-badge_29.entry.js → mg-badge_30.entry.js} +1112 -860
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/mg-components/locales/en/messages.json +7 -0
- package/dist/mg-components/locales/fr/messages.json +7 -0
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-3899d5d2.js → p-182bd802.js} +2 -2
- package/dist/mg-components/p-f7da9dd2.entry.js +1 -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/navigation-button.scss +76 -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 +9 -9
- package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +0 -11
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +1 -1
- package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +0 -11
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +4 -4
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +6 -6
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-tag/doc/mg-tag.stories.d.ts +0 -13
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +5 -1
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +27 -6
- 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-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +5 -0
- 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/doc/mg-menu-item.stories.d.ts +1 -0
- 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 +55 -15
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +22 -5
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +1 -1
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +12 -0
- package/dist/types/components/molecules/mg-skip-links/doc/mg-skip-links.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +7 -0
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +49 -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 +24 -14
- package/dist/types/components.d.ts +81 -18
- package/dist/types/locales/index.d.ts +16 -9
- package/dist/types/stencil-public-runtime.d.ts +44 -3
- package/dist/types/utils/behaviors.utils.d.ts +83 -0
- package/dist/types/utils/components.utils.d.ts +14 -0
- package/dist/types/utils/locale.utils.d.ts +13 -0
- package/dist/types/utils/unit.test.utils.d.ts +78 -0
- package/package.json +51 -46
- package/readme.md +25 -14
- package/dist/components/locale.utils.js +0 -40
- package/dist/components/mg-menu.conf.js +0 -10
- package/dist/mg-components/p-059a9a59.entry.js +0 -1
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-4dcc1812.js');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* List of all possibles variants
|
|
9
9
|
*/
|
|
10
|
-
const variants$4 = ['info', 'primary', 'secondary', 'success', 'warning', 'danger'];
|
|
10
|
+
const variants$4 = ['info', 'primary', 'secondary', 'success', 'warning', 'danger', 'text-color'];
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Create random ID
|
|
@@ -97,8 +97,58 @@ const isTagName = (element, tagNames) => {
|
|
|
97
97
|
* Focusable elements query selector
|
|
98
98
|
*/
|
|
99
99
|
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param {Window} localWindow the window we are lookink for other windows
|
|
103
|
+
* @returns {Window[]} The list of windows found
|
|
104
|
+
*/
|
|
105
|
+
const getWindows = (localWindow) => {
|
|
106
|
+
const parentWindows = getParentWindows(localWindow);
|
|
107
|
+
const childWindows = getChildWindows(localWindow);
|
|
108
|
+
return [localWindow, ...parentWindows, ...childWindows];
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Get parent windows
|
|
112
|
+
*
|
|
113
|
+
* @param {Window} localWindow the window we are lookink for parents
|
|
114
|
+
* @param {Window[]} windows The list of allready found windows
|
|
115
|
+
* @returns {Window[]} The list of windows found
|
|
116
|
+
*/
|
|
117
|
+
const getParentWindows = (localWindow, windows = []) => {
|
|
118
|
+
// Check if is in iframe
|
|
119
|
+
if (localWindow.self !== localWindow.top) {
|
|
120
|
+
// Check if we have permission to access parent
|
|
121
|
+
try {
|
|
122
|
+
const parentWindow = localWindow.parent;
|
|
123
|
+
windows.push(parentWindow);
|
|
124
|
+
return getParentWindows(parentWindow, windows);
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
console.error('Different hosts between iframes:', err);
|
|
128
|
+
return windows;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return windows;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Get child windows
|
|
135
|
+
*
|
|
136
|
+
* @param {Window} localWindow the window we are lookink for children
|
|
137
|
+
* @param {Window[]} windows The list of allready found windows
|
|
138
|
+
* @returns {Window[]} The list of windows found
|
|
139
|
+
*/
|
|
140
|
+
const getChildWindows = (localWindow, windows = []) => {
|
|
141
|
+
if (localWindow.frames.length > 0) {
|
|
142
|
+
for (let i = 0; i < localWindow.frames.length; i++) {
|
|
143
|
+
const childWindow = localWindow.frames[i];
|
|
144
|
+
windows.push(childWindow);
|
|
145
|
+
windows.concat(getChildWindows(childWindow, windows));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return windows;
|
|
149
|
+
};
|
|
100
150
|
|
|
101
|
-
const mgBadgeCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-badge{padding:0 0.4rem;height:var(--mg-badge-size);min-width:var(--mg-badge-size);box-sizing:border-box;border:0.1rem solid;border-radius:calc(var(--mg-badge-size) / 2);font-size:var(--mg-badge-font-size);font-weight:600;text-align:center;line-height:var(--mg-badge-size)}.mg-badge.mg-badge--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-badge.mg-badge--primary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-badge.mg-badge--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-badge.mg-badge--success.mg-badge--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-badge.mg-badge--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-badge.mg-badge--warning.mg-badge--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-badge.mg-badge--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-badge.mg-badge--danger.mg-badge--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-badge.mg-badge--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-badge.mg-badge--info.mg-badge--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-badge,mg-badge{display:inline-flex;align-items:center;justify-content:center}";
|
|
151
|
+
const mgBadgeCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-badge{padding:0 0.4rem;height:var(--mg-badge-size);min-width:var(--mg-badge-size);box-sizing:border-box;border:0.1rem solid;border-radius:calc(var(--mg-badge-size) / 2);font-size:var(--mg-badge-font-size);font-weight:600;text-align:center;line-height:var(--mg-badge-size)}.mg-badge.mg-badge--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-badge.mg-badge--primary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-badge.mg-badge--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-badge.mg-badge--success.mg-badge--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-badge.mg-badge--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-badge.mg-badge--warning.mg-badge--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-badge.mg-badge--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-badge.mg-badge--danger.mg-badge--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-badge.mg-badge--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-badge.mg-badge--info.mg-badge--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-badge.mg-badge--text-color{background-color:currentColor;border-color:currentColor}.mg-badge.mg-badge--text-color .mg-badge__value{color:hsl(var(--mg-badge-text-color, var(--color-light)))}.mg-badge.mg-badge--text-color.mg-badge--outline{background-color:transparent}.mg-badge.mg-badge--text-color.mg-badge--outline .mg-badge__value{color:currentColor}.mg-badge,mg-badge{display:inline-flex;align-items:center;justify-content:center}";
|
|
102
152
|
|
|
103
153
|
const MgBadge = class {
|
|
104
154
|
constructor(hostRef) {
|
|
@@ -108,18 +158,15 @@ const MgBadge = class {
|
|
|
108
158
|
************/
|
|
109
159
|
// Classes
|
|
110
160
|
this.classOutline = `mg-badge--outline`;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.
|
|
115
|
-
/**
|
|
116
|
-
* Component classes
|
|
117
|
-
*/
|
|
161
|
+
this.value = undefined;
|
|
162
|
+
this.label = undefined;
|
|
163
|
+
this.variant = variants$4[0];
|
|
164
|
+
this.outline = undefined;
|
|
118
165
|
this.classList = new ClassList(['mg-badge']);
|
|
119
166
|
}
|
|
120
167
|
validateValue(newValue) {
|
|
121
168
|
if (`${newValue}`.match(/^(\d+\+*|[?*!a-z])$/i) === null) {
|
|
122
|
-
throw new Error('<mg-badge> prop "value" must be
|
|
169
|
+
throw new Error('<mg-badge> prop "value" must be integer or ponctuation character.');
|
|
123
170
|
}
|
|
124
171
|
}
|
|
125
172
|
validateLabel(newValue) {
|
|
@@ -161,7 +208,7 @@ const MgBadge = class {
|
|
|
161
208
|
* @returns {HTMLElement} HTML Element
|
|
162
209
|
*/
|
|
163
210
|
render() {
|
|
164
|
-
return (index.h("span", { class: this.classList.join() }, this.value, index.h("span", { class: "sr-only" }, this.label)));
|
|
211
|
+
return (index.h("span", { class: this.classList.join() }, index.h("span", { class: "mg-badge__value" }, this.value), index.h("span", { class: "sr-only" }, this.label)));
|
|
165
212
|
}
|
|
166
213
|
static get watchers() { return {
|
|
167
214
|
"value": ["validateValue"],
|
|
@@ -175,9 +222,9 @@ MgBadge.style = mgBadgeCss;
|
|
|
175
222
|
/**
|
|
176
223
|
* List of all possibles variants
|
|
177
224
|
*/
|
|
178
|
-
const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success'];
|
|
225
|
+
const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success', 'link'];
|
|
179
226
|
|
|
180
|
-
const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button{outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:0.2rem}:host(:hover) .mg-button--flat:not(.mg-button--disabled),:host(:focus) .mg-button--flat:not(.mg-button--disabled),:host(:active) .mg-button--flat:not(.mg-button--disabled){background:
|
|
227
|
+
const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button{outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:0.2rem}:host(:hover) .mg-button--flat:not(.mg-button--disabled),:host(:focus) .mg-button--flat:not(.mg-button--disabled),:host(:active) .mg-button--flat:not(.mg-button--disabled){background:hsl(var(--color-dark), 0.1)}:host([full-width]){display:block}:host([disabled]),:host([aria-disabled=true]){pointer-events:none}.mg-button.mg-button--primary{border-color:hsl(var(--mg-button-primary-border-color, var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-primary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--primary:not(.mg-button--disabled),:host(:focus) .mg-button--primary:not(.mg-button--disabled),:host(:active) .mg-button--primary:not(.mg-button--disabled){background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))}.mg-button.mg-button--secondary{border-color:hsl(var(--mg-button-secondary-border-color, var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-secondary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--secondary:not(.mg-button--disabled),:host(:focus) .mg-button--secondary:not(.mg-button--disabled),:host(:active) .mg-button--secondary:not(.mg-button--disabled){background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))}.mg-button.mg-button--danger{border-color:hsl(var(--mg-button-danger-border-color, var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger:not(.mg-button--disabled),:host(:focus) .mg-button--danger:not(.mg-button--disabled),:host(:active) .mg-button--danger:not(.mg-button--disabled){background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-button.mg-button--danger-alt{border-color:hsl(var(--mg-button-danger-alt-border-color, var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-danger));background:linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger-alt:not(.mg-button--disabled),:host(:focus) .mg-button--danger-alt:not(.mg-button--disabled),:host(:active) .mg-button--danger-alt:not(.mg-button--disabled){background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))}.mg-button.mg-button--info{border-color:hsl(var(--mg-button-info-border-color, var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--info:not(.mg-button--disabled),:host(:focus) .mg-button--info:not(.mg-button--disabled),:host(:active) .mg-button--info:not(.mg-button--disabled){background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-button.mg-button--success{border-color:hsl(var(--mg-button-success-border-color, var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-dark));background:linear-gradient(to bottom, hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l)), hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--success:not(.mg-button--disabled),:host(:focus) .mg-button--success:not(.mg-button--disabled),:host(:active) .mg-button--success:not(.mg-button--disabled){background:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-button{position:relative;display:inline-flex;align-items:center;column-gap:0.6rem;padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;min-height:var(--default-size);box-sizing:border-box;border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));cursor:pointer;background-image:none;border-top-width:var(--mg-button-border-top-width, 0.1rem);border-right-width:var(--mg-button-border-right-width, 0.1rem);border-bottom-width:var(--mg-button-border-bottom-width, 0.1rem);border-left-width:var(--mg-button-border-left-width, 0.1rem);border-style:solid;text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);touch-action:manipulation}.mg-button.mg-button--disabled{opacity:var(--mg-button-disabled-opacity);cursor:default}.mg-button.mg-button--icon{padding:0;justify-content:center;width:var(--default-size);height:var(--default-size);border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-icon-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-icon-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-icon-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-icon-border-radius));font-size:var(--font-size);line-height:var(--font-size)}.mg-button.mg-button--flat{background:none;border:none}.mg-button.mg-button--link{padding:unset;min-height:unset;background:unset;border:unset;border-radius:unset;text-decoration:underline}.mg-button.mg-button--link slot{font-weight:600}.mg-button.mg-button--link:hover{text-decoration:none}.mg-button.mg-button--full-width{display:flex;justify-content:center}.mg-button.mg-button--loading>mg-icon:first-of-type{position:absolute;left:50%;top:50%;transform:translate(-50%, -50%)}.mg-button.mg-button--loading .mg-button__content{opacity:0}.mg-button mg-icon:only-child,.mg-button ::slotted(mg-icon){display:inline-flex;flex-shrink:0;line-height:1;margin:auto 0}.mg-button slot,.mg-button ::slotted(*:not(mg-icon)){text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);display:flex;align-items:center;column-gap:0.6rem}";
|
|
181
228
|
|
|
182
229
|
const MgButton = class {
|
|
183
230
|
constructor(hostRef) {
|
|
@@ -189,34 +236,6 @@ const MgButton = class {
|
|
|
189
236
|
this.classDisabled = 'mg-button--disabled';
|
|
190
237
|
this.classLoading = 'mg-button--loading';
|
|
191
238
|
this.classFullWidth = 'mg-button--full-width';
|
|
192
|
-
/**
|
|
193
|
-
* Define button variant
|
|
194
|
-
*/
|
|
195
|
-
this.variant = variants$3[0]; // Primary
|
|
196
|
-
/**
|
|
197
|
-
* Set button to full-width
|
|
198
|
-
*/
|
|
199
|
-
this.fullWidth = false;
|
|
200
|
-
/**
|
|
201
|
-
* Define if button is round.
|
|
202
|
-
* Used for icon button.
|
|
203
|
-
*/
|
|
204
|
-
this.isIcon = false;
|
|
205
|
-
/**
|
|
206
|
-
* Option to set input disable on click, in order to prevent multi-click.
|
|
207
|
-
* Parent component have to remove the attribute 'disabled' when the process ends.
|
|
208
|
-
*/
|
|
209
|
-
this.disableOnClick = false;
|
|
210
|
-
/**
|
|
211
|
-
* Define if button is loading, default to false.
|
|
212
|
-
* Trigger when button is clicked or key-up ['enter', 'space], then value change to true.
|
|
213
|
-
* It's required to reset to false when action/promise in parent is done to stop the loading state
|
|
214
|
-
*/
|
|
215
|
-
this.loading = false;
|
|
216
|
-
/**
|
|
217
|
-
* Component classes
|
|
218
|
-
*/
|
|
219
|
-
this.classList = new ClassList(['mg-button']);
|
|
220
239
|
/**
|
|
221
240
|
* Trigger actions onClick event
|
|
222
241
|
*
|
|
@@ -259,6 +278,17 @@ const MgButton = class {
|
|
|
259
278
|
this.element.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
260
279
|
}
|
|
261
280
|
};
|
|
281
|
+
this.variant = variants$3[0];
|
|
282
|
+
this.identifier = undefined;
|
|
283
|
+
this.label = undefined;
|
|
284
|
+
this.type = undefined;
|
|
285
|
+
this.fullWidth = false;
|
|
286
|
+
this.form = undefined;
|
|
287
|
+
this.disabled = undefined;
|
|
288
|
+
this.isIcon = false;
|
|
289
|
+
this.disableOnClick = false;
|
|
290
|
+
this.loading = false;
|
|
291
|
+
this.classList = new ClassList(['mg-button']);
|
|
262
292
|
}
|
|
263
293
|
validateVariant(newValue, oldValue) {
|
|
264
294
|
if (!variants$3.includes(newValue)) {
|
|
@@ -343,7 +373,7 @@ const MgButton = class {
|
|
|
343
373
|
};
|
|
344
374
|
MgButton.style = mgButtonCss;
|
|
345
375
|
|
|
346
|
-
const mgCardCss = ".mg-card{padding:var(--mg-card-padding);border-radius:var(--mg-card-border-radius);
|
|
376
|
+
const mgCardCss = ".mg-card{position:relative;width:100%;padding:var(--mg-card-padding, var(--mg-card-padding-default));overflow:var(--mg-card-overflow, var(--mg-card-overflow-default));box-sizing:border-box;z-index:inherit;background:var(--mg-card-background, var(--mg-card-background-default));border:var(--mg-card-border, var(--mg-card-border-default));border-radius:var(--mg-card-border-radius, var(--mg-card-border-radius-default));box-shadow:var(--mg-card-box-shadow, var(--mg-card-box-shadow-default))}.mg-card ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default)}";
|
|
347
377
|
|
|
348
378
|
const MgCard = class {
|
|
349
379
|
constructor(hostRef) {
|
|
@@ -404,6 +434,9 @@ const pagination$1 = {
|
|
|
404
434
|
const panel$1 = {
|
|
405
435
|
editLabel: "Edit section title."
|
|
406
436
|
};
|
|
437
|
+
const skipLinks$1 = {
|
|
438
|
+
navLabel: "Quick access"
|
|
439
|
+
};
|
|
407
440
|
const general$1 = {
|
|
408
441
|
confirm: "Confirm",
|
|
409
442
|
cancel: "Cancel",
|
|
@@ -411,6 +444,10 @@ const general$1 = {
|
|
|
411
444
|
next: "next",
|
|
412
445
|
previous: "previous"
|
|
413
446
|
};
|
|
447
|
+
const plusMenu$1 = {
|
|
448
|
+
moreLabel: "Additional menu",
|
|
449
|
+
badgeLabel: "Include notification(s)"
|
|
450
|
+
};
|
|
414
451
|
const en = {
|
|
415
452
|
errors: errors$1,
|
|
416
453
|
nbCharLeft: nbCharLeft$1,
|
|
@@ -420,7 +457,9 @@ const en = {
|
|
|
420
457
|
modal: modal$1,
|
|
421
458
|
pagination: pagination$1,
|
|
422
459
|
panel: panel$1,
|
|
423
|
-
|
|
460
|
+
skipLinks: skipLinks$1,
|
|
461
|
+
general: general$1,
|
|
462
|
+
plusMenu: plusMenu$1
|
|
424
463
|
};
|
|
425
464
|
|
|
426
465
|
const errors = {
|
|
@@ -464,6 +503,9 @@ const pagination = {
|
|
|
464
503
|
const panel = {
|
|
465
504
|
editLabel: "Modifier le titre de la section."
|
|
466
505
|
};
|
|
506
|
+
const skipLinks = {
|
|
507
|
+
navLabel: "Accès rapide"
|
|
508
|
+
};
|
|
467
509
|
const general = {
|
|
468
510
|
confirm: "Valider",
|
|
469
511
|
cancel: "Annuler",
|
|
@@ -471,6 +513,10 @@ const general = {
|
|
|
471
513
|
next: "suivant",
|
|
472
514
|
previous: "précédent"
|
|
473
515
|
};
|
|
516
|
+
const plusMenu = {
|
|
517
|
+
moreLabel: "Menu complémentaire",
|
|
518
|
+
badgeLabel: "Notification(s) incluse(s)"
|
|
519
|
+
};
|
|
474
520
|
const fr = {
|
|
475
521
|
errors: errors,
|
|
476
522
|
nbCharLeft: nbCharLeft,
|
|
@@ -480,34 +526,63 @@ const fr = {
|
|
|
480
526
|
modal: modal,
|
|
481
527
|
pagination: pagination,
|
|
482
528
|
panel: panel,
|
|
483
|
-
|
|
529
|
+
skipLinks: skipLinks,
|
|
530
|
+
general: general,
|
|
531
|
+
plusMenu: plusMenu
|
|
484
532
|
};
|
|
485
533
|
|
|
486
|
-
const defaultLocale = 'en';
|
|
487
|
-
const messages = { en, fr };
|
|
488
534
|
/**
|
|
489
|
-
*
|
|
535
|
+
* Format number to the locale currency
|
|
490
536
|
*
|
|
491
|
-
* @param {
|
|
492
|
-
* @
|
|
537
|
+
* @param {number} number number to format
|
|
538
|
+
* @param {string} locale locale to apply
|
|
539
|
+
* @param {string} currency currency to apply
|
|
540
|
+
* @returns {string} formatted currency
|
|
493
541
|
*/
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
const closestLang = Intl.NumberFormat.supportedLocalesOf((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang);
|
|
498
|
-
return closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;
|
|
499
|
-
};
|
|
542
|
+
function localeCurrency(number, locale, currency) {
|
|
543
|
+
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
|
|
544
|
+
}
|
|
500
545
|
/**
|
|
501
|
-
*
|
|
546
|
+
* Format number to locale
|
|
547
|
+
*
|
|
548
|
+
* @param {number} number number to format
|
|
549
|
+
* @param {string} locale locale to apply
|
|
550
|
+
* @returns {string} formatted number
|
|
551
|
+
*/
|
|
552
|
+
function localeNumber(number, locale) {
|
|
553
|
+
return new Intl.NumberFormat(locale).format(number);
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Date RegExp
|
|
557
|
+
*/
|
|
558
|
+
const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
559
|
+
/**
|
|
560
|
+
* Locale date format
|
|
561
|
+
*
|
|
562
|
+
* @param {string} date date to format
|
|
563
|
+
* @param {string} locale locale to apply
|
|
564
|
+
* @returns {string} formatted date
|
|
565
|
+
*/
|
|
566
|
+
function localeDate(date, locale) {
|
|
567
|
+
if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
|
|
568
|
+
return '';
|
|
569
|
+
}
|
|
570
|
+
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Get locale and messages
|
|
502
574
|
* We load the defined locale but for now we only support the first subtag for messages
|
|
503
575
|
*
|
|
504
576
|
* @param {HTMLElement} element element we need to get the language
|
|
577
|
+
* @param {unknown} messages messages to use
|
|
578
|
+
* @param {string} defaultLocale default messages locale
|
|
505
579
|
* @returns {{ locale: string; messages: unknown }} messages object
|
|
506
580
|
*/
|
|
507
|
-
|
|
508
|
-
|
|
581
|
+
const getLocaleMessages = (element, messages, defaultLocale) => {
|
|
582
|
+
var _a;
|
|
509
583
|
// Get local
|
|
510
|
-
const
|
|
584
|
+
const closestLang = Intl.NumberFormat.supportedLocalesOf((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang);
|
|
585
|
+
const locale = closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;
|
|
511
586
|
// Only keep first subtag
|
|
512
587
|
const localeSubtag = locale.split('-').shift();
|
|
513
588
|
// Return
|
|
@@ -517,15 +592,24 @@ const initLocales = (element) => {
|
|
|
517
592
|
};
|
|
518
593
|
};
|
|
519
594
|
|
|
595
|
+
const defaultLocale = 'en';
|
|
596
|
+
const messages = { en, fr };
|
|
597
|
+
/**
|
|
598
|
+
* Get Intl object
|
|
599
|
+
*
|
|
600
|
+
* @param {HTMLElement} element element we need to get the language
|
|
601
|
+
* @returns {{ locale: string; messages: unknown }} messages object
|
|
602
|
+
*/
|
|
603
|
+
const initLocales = (element) => getLocaleMessages(element, messages, defaultLocale);
|
|
604
|
+
|
|
520
605
|
const mgCharacterLeftCss = "mg-character-left.sc-mg-character-left{display:block}";
|
|
521
606
|
|
|
522
607
|
const MgCharacterLeft = class {
|
|
523
608
|
constructor(hostRef) {
|
|
524
609
|
index.registerInstance(this, hostRef);
|
|
525
|
-
|
|
526
|
-
* Sets the characters to count
|
|
527
|
-
*/
|
|
610
|
+
this.identifier = undefined;
|
|
528
611
|
this.characters = '';
|
|
612
|
+
this.maxlength = undefined;
|
|
529
613
|
}
|
|
530
614
|
validateMaxlength(newValue) {
|
|
531
615
|
if (typeof newValue !== 'number') {
|
|
@@ -565,14 +649,6 @@ const MgDetails = class {
|
|
|
565
649
|
constructor(hostRef) {
|
|
566
650
|
index.registerInstance(this, hostRef);
|
|
567
651
|
this.expandedChange = index.createEvent(this, "expanded-change", 7);
|
|
568
|
-
/**
|
|
569
|
-
* Hide summary element
|
|
570
|
-
*/
|
|
571
|
-
this.hideSummary = false;
|
|
572
|
-
/**
|
|
573
|
-
* Define if details are diplayed
|
|
574
|
-
*/
|
|
575
|
-
this.expanded = false;
|
|
576
652
|
/**
|
|
577
653
|
* Handle details toggle
|
|
578
654
|
*
|
|
@@ -581,6 +657,10 @@ const MgDetails = class {
|
|
|
581
657
|
this.handleToggle = () => {
|
|
582
658
|
this.expanded = this.details.open;
|
|
583
659
|
};
|
|
660
|
+
this.toggleClosed = undefined;
|
|
661
|
+
this.toggleOpened = undefined;
|
|
662
|
+
this.hideSummary = false;
|
|
663
|
+
this.expanded = false;
|
|
584
664
|
}
|
|
585
665
|
validateTitles(newValue) {
|
|
586
666
|
if (newValue === undefined || newValue.trim() === '') {
|
|
@@ -623,12 +703,6 @@ const mgDividerCss = ".mg-divider{margin:var(--mg-divider-vertical-spacing) auto
|
|
|
623
703
|
const MgDivider = class {
|
|
624
704
|
constructor(hostRef) {
|
|
625
705
|
index.registerInstance(this, hostRef);
|
|
626
|
-
/**************
|
|
627
|
-
* Decorators *
|
|
628
|
-
**************/
|
|
629
|
-
/**
|
|
630
|
-
* Define component size
|
|
631
|
-
*/
|
|
632
706
|
this.size = 'regular';
|
|
633
707
|
}
|
|
634
708
|
/**
|
|
@@ -654,28 +728,6 @@ const MgForm = class {
|
|
|
654
728
|
this.formSubmit = index.createEvent(this, "form-submit", 7);
|
|
655
729
|
// Classes
|
|
656
730
|
this.classAllRequired = 'mg-form--all-required';
|
|
657
|
-
/**
|
|
658
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
659
|
-
* If not set, it will be created.
|
|
660
|
-
*/
|
|
661
|
-
this.identifier = createID('mg-form');
|
|
662
|
-
/**
|
|
663
|
-
* Input name
|
|
664
|
-
* If not set the value equals the identifier
|
|
665
|
-
*/
|
|
666
|
-
this.name = this.identifier;
|
|
667
|
-
/**
|
|
668
|
-
* Define if form is readonly
|
|
669
|
-
*/
|
|
670
|
-
this.readonly = false;
|
|
671
|
-
/**
|
|
672
|
-
* Define if form is disabled
|
|
673
|
-
*/
|
|
674
|
-
this.disabled = false;
|
|
675
|
-
/**
|
|
676
|
-
* Component classes
|
|
677
|
-
*/
|
|
678
|
-
this.classList = new ClassList(['mg-form']);
|
|
679
731
|
/**
|
|
680
732
|
* Define required message based on mg-inputs required elements
|
|
681
733
|
* Also
|
|
@@ -745,6 +797,14 @@ const MgForm = class {
|
|
|
745
797
|
input.addEventListener('input-valid', this.checkValidity);
|
|
746
798
|
});
|
|
747
799
|
};
|
|
800
|
+
this.identifier = createID('mg-form');
|
|
801
|
+
this.name = this.identifier;
|
|
802
|
+
this.readonly = false;
|
|
803
|
+
this.disabled = false;
|
|
804
|
+
this.valid = undefined;
|
|
805
|
+
this.invalid = undefined;
|
|
806
|
+
this.classList = new ClassList(['mg-form']);
|
|
807
|
+
this.requiredMessage = undefined;
|
|
748
808
|
}
|
|
749
809
|
handleAttributeChange() {
|
|
750
810
|
this.setMgInputs();
|
|
@@ -842,6 +902,7 @@ const icons = {
|
|
|
842
902
|
'archive': () => (index.h("path", { fill: "currentColor", d: "M3 6v6.96c0 .57.46 1.04 1.04 1.04H12c.55 0 1-.45 1-1V6H3Zm7 2H6V7h4v1Zm3-3H3c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h10c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1Z" })),
|
|
843
903
|
'archive-outline': () => (index.h("path", { fill: "currentColor", d: "M13 2H3c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1v6.96c0 .57.46 1.04 1.04 1.04H12c.55 0 1-.45 1-1V6c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1Zm-1 11H4.04S4 12.98 4 12.96V6h8v7Zm1-8H3V3h10v2Zm-3 3H6V7h4v1Z" })),
|
|
844
904
|
'arrow-down': () => (index.h("path", { fill: "currentColor", d: "M13,10.1H10.23a.31.31,0,0,1-.32-.28h0V.94A.3.3,0,0,0,9.59.65H6.37A.32.32,0,0,0,6,.94H6V9.81a.29.29,0,0,1-.31.29H3a.3.3,0,0,0-.31.29.27.27,0,0,0,.08.22l5.06,4.58a.36.36,0,0,0,.46,0l5-4.58a.29.29,0,0,0,0-.42C13.22,10.1,13.12,10.1,13,10.1Z" })),
|
|
905
|
+
'arrow-down-a-z': () => (index.h("path", { fill: "currentColor", d: "m6.53 10.9-1.41 1.41-.71.71-2.12-2.12.71-.71.88.88V3.02h1v8.12l.95-.95.71.71ZM12.29 6H10.5l-.36 1H9.08l1.79-5h1.05l1.79 5h-1.06l-.36-1Zm-.36-1.02-.53-1.49-.53 1.49h1.06Zm1.79 5.18V9H9.09v1h3.29l-3.29 2.84V14h4.63v-1h-3.29l3.29-2.84Z" })),
|
|
845
906
|
'arrow-down-right': () => (index.h("path", { fill: "currentColor", d: "m1.98 3.47 8.75 8.75H6.94c-.58 0-1.05.47-1.05 1.06s.47 1.05 1.05 1.05h6.33c.58 0 1.05-.47 1.05-1.05V6.94a1.05 1.05 0 1 0-2.1 0v3.79L3.47 1.98c-.41-.41-1.08-.41-1.49 0-.41.41-.41 1.08 0 1.49Z" })),
|
|
846
907
|
'arrow-left': () => (index.h("path", { fill: "currentColor", d: "M5.88,12.93V10.18a.3.3,0,0,1,.28-.32H15a.31.31,0,0,0,.29-.33h0V6.32A.31.31,0,0,0,15,6H6.17a.32.32,0,0,1-.29-.31h0V2.93a.3.3,0,0,0-.28-.32.32.32,0,0,0-.23.09L.79,7.76a.36.36,0,0,0,0,.46l4.58,5a.31.31,0,0,0,.43,0A.4.4,0,0,0,5.88,12.93Z" })),
|
|
847
908
|
'arrow-right': () => (index.h("path", { fill: "currentColor", d: "M10.16,3V5.75a.3.3,0,0,1-.28.32H1a.31.31,0,0,0-.29.33h0V9.61A.31.31,0,0,0,1,9.94H9.87a.29.29,0,0,1,.29.31h0V13a.3.3,0,0,0,.28.32.32.32,0,0,0,.23-.09l4.58-5.06a.36.36,0,0,0,0-.46l-4.58-5a.3.3,0,0,0-.42,0C10.16,2.76,10.16,2.87,10.16,3Z" })),
|
|
@@ -850,6 +911,7 @@ const icons = {
|
|
|
850
911
|
'arrow-up': () => (index.h("path", { fill: "currentColor", d: "M3.06,5.82H5.81a.31.31,0,0,1,.32.28h0V15a.31.31,0,0,0,.33.29H9.67A.3.3,0,0,0,10,15h0V6.11a.3.3,0,0,1,.31-.29h2.75a.3.3,0,0,0,.23-.51L8.23.73a.36.36,0,0,0-.46,0l-5,4.58a.3.3,0,0,0,0,.43C2.82,5.83,2.92,5.82,3.06,5.82Z" })),
|
|
851
912
|
'arrow-up-right': () => (index.h("path", { fill: "currentColor", d: "m3.47 14.02 8.75-8.75v3.78c0 .58.47 1.05 1.06 1.05s1.05-.47 1.05-1.05V2.72c0-.58-.47-1.05-1.05-1.05H6.94a1.05 1.05 0 1 0 0 2.1h3.78l-8.74 8.76c-.41.41-.41 1.08 0 1.49s1.08.41 1.49 0Z" })),
|
|
852
913
|
'arrow-up-right-square': () => (index.h("path", { fill: "currentColor", d: "M14.33 3v10A1.34 1.34 0 0 1 13 14.33H3A1.34 1.34 0 0 1 1.67 13V3A1.34 1.34 0 0 1 3 1.67h10A1.34 1.34 0 0 1 14.33 3Zm-2.48.46H8.68a.67.67 0 0 0-.68.7.63.63 0 0 0 .2.47l.91.91-5.53 5.53a.33.33 0 0 0 0 .48l.87.87a.33.33 0 0 0 .48 0l5.53-5.52.91.9a.69.69 0 0 0 1 0 .71.71 0 0 0 .19-.48V4.15a.67.67 0 0 0-.67-.67Z" })),
|
|
914
|
+
'arrow-up-z-a': () => (index.h("path", { fill: "currentColor", d: "m5.82 5.85-.94-.94v8.11h-1V4.96l-.89.89-.71-.71 1.41-1.41.71-.71.71.71 1.41 1.41-.71.71ZM12.29 13H10.5l-.36 1H9.08l1.79-5h1.05l1.79 5h-1.06l-.36-1Zm-.36-1.02-.53-1.49-.53 1.49h1.06Zm1.79-8.82V2H9.09v1h3.29L9.09 5.84V7h4.63V6h-3.29l3.29-2.84Z" })),
|
|
853
915
|
'arrows-compare': () => index.h("path", { fill: "currentColor", d: "M5.81 9.47H.67v1.47h5.14v2.2l2.93-2.93-2.93-2.93v2.2Zm4.39-.73v-2.2h5.14V5.07H10.2v-2.2L7.27 5.8l2.93 2.93Z" }),
|
|
854
916
|
'arrows-right-down': () => (index.h("path", { fill: "currentColor", d: "M10.68 10.78c.16.17.16.45-.02.61l-2.8 2.78a.43.43 0 0 1-.31.12.42.42 0 0 1-.31-.12l-2.8-2.78a.44.44 0 0 1 0-.62.44.44 0 0 1 .62 0l2.06 2.05V5.38H2.11c-.24 0-.44-.19-.44-.44 0-.24.2-.44.44-.44H8v8.32l2.06-2.05a.44.44 0 0 1 .62 0Zm3.53-6.14-2.78-2.8a.438.438 0 0 0-.61-.02.44.44 0 0 0 0 .62l2.05 2.06H8.89v.88h3.98l-2.05 2.06a.44.44 0 0 0 0 .62c.17.17.45.17.62 0l2.78-2.8s.07-.09.09-.14c.02-.05.03-.11.03-.17 0-.11-.04-.23-.12-.31Z" })),
|
|
855
917
|
'arrows-right-left': () => (index.h("path", { fill: "currentColor", d: "M.73,5.65V5.23a.64.64,0,0,1,.64-.64H12V3.31a.64.64,0,0,1,.64-.64.63.63,0,0,1,.45.18L15.19,5a.63.63,0,0,1,0,.9L13.05,8A.65.65,0,0,1,12,7.57V6.29H1.37a.64.64,0,0,1-.64-.64Zm14,4.06H4.09V8.43A.64.64,0,0,0,3,8L.87,10.11a.63.63,0,0,0,0,.9L3,13.15a.64.64,0,0,0,.91,0,.61.61,0,0,0,.18-.45V11.41H14.73a.63.63,0,0,0,.64-.64h0v-.42a.63.63,0,0,0-.64-.64Z" })),
|
|
@@ -860,8 +922,13 @@ const icons = {
|
|
|
860
922
|
'briefcase': () => (index.h("path", { fill: "currentColor", d: "M14 4.5h-3v-1c0-.55-.45-1-1-1H6c-.55 0-1 .45-1 1v1H2c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-7c0-.55-.45-1-1-1Zm-8-1h4v1H6v-1Z" })),
|
|
861
923
|
'briefcase-outline': () => (index.h("path", { fill: "currentColor", d: "M14 4.5h-3v-1c0-.55-.45-1-1-1H6c-.55 0-1 .45-1 1v1H2c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-7c0-.55-.45-1-1-1Zm-8-1h4v1H6v-1Zm8 9H2v-7h12v7Z" })),
|
|
862
924
|
'calculator': () => (index.h("path", { fill: "currentColor", d: "M12.83.67H3.17a.5.5 0 0 0-.5.5v13.66a.5.5 0 0 0 .5.5h9.66a.5.5 0 0 0 .5-.5V1.17a.5.5 0 0 0-.5-.5ZM5.58 13.39a.29.29 0 0 1-.28.3H4.1a.29.29 0 0 1-.3-.28v-1.2a.29.29 0 0 1 .28-.3h1.2a.29.29 0 0 1 .3.28v1.2Zm0-3.28a.29.29 0 0 1-.3.3H4.1a.29.29 0 0 1-.3-.3V8.93a.29.29 0 0 1 .28-.3h1.2a.29.29 0 0 1 .3.28v1.2Zm3.29 3.28a.29.29 0 0 1-.3.3H7.38a.29.29 0 0 1-.3-.3v-1.18a.29.29 0 0 1 .3-.3h1.19a.29.29 0 0 1 .3.3Zm0-3.28a.32.32 0 0 1-.3.3H7.38a.32.32 0 0 1-.3-.3V8.93a.29.29 0 0 1 .3-.3h1.19a.29.29 0 0 1 .3.3Zm3.33 3.28a.29.29 0 0 1-.28.3h-1.25a.29.29 0 0 1-.3-.28V8.93a.29.29 0 0 1 .28-.3h1.25a.29.29 0 0 1 .3.28v4.48Zm0-7.15a.29.29 0 0 1-.3.3H4.1a.29.29 0 0 1-.3-.3V2.61a.29.29 0 0 1 .28-.3h7.82a.29.29 0 0 1 .3.28v3.65Z" })),
|
|
863
|
-
'calendar': () => (index.h("path", { fill: "currentColor", d: "M14
|
|
864
|
-
'calendar-
|
|
925
|
+
'calendar': () => (index.h("path", { fill: "currentColor", d: "M14 3.5c0-.55-.45-1-1-1h-1v-1h-1v1H5v-1H4v1H3c-.55 0-1 .45-1 1v.98s0 .02.02.02H2v9c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-9h-.02s.02 0 .02-.02V3.5Zm-11 10v-8h10v8H3Z" })),
|
|
926
|
+
'calendar-outline': () => (index.h("path", { fill: "currentColor", d: "M13 2.5h-1v-1h-1v1H5v-1H4v1H3c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-10c0-.55-.45-1-1-1Zm-10 11v-8h10v8H3Zm0-9v-1h10v1H3Z" })),
|
|
927
|
+
'calendar-euro': () => [
|
|
928
|
+
index.h("path", { d: "M13 2.5h-1v-1h-1v1H5v-1H4v1H3c-.6 0-1 .4-1 1v10c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-10c0-.6-.4-1-1-1Zm-10 11v-8h10v8H3Z" }),
|
|
929
|
+
index.h("path", { d: "m9.79 11.03.71.71c-.53.48-1.23.78-2 .78-1.31 0-2.43-.85-2.83-2.02H4.5v-.75h1.02c-.02-.07-.02-.15-.02-.23 0-.09 0-.18.02-.27H4.5V8.5h1.19a2.974 2.974 0 0 1 4.81-1.2l-.71.71c-.35-.3-.8-.49-1.29-.49-.73 0-1.37.39-1.72.98h1.75v.75H6.52c-.01.09-.02.18-.02.27 0 .08 0 .16.01.23h2.02v.75H6.76c.34.61 1 1.02 1.74 1.02.49 0 .94-.19 1.29-.49Z" }),
|
|
930
|
+
],
|
|
931
|
+
'calendar-euro-outline': () => (index.h("path", { d: "m9.79 11.02.71.71a2.976 2.976 0 0 1-4.83-1.24H4.5v-.75h1.01c-.01-.08-.01-.15-.01-.23 0-.09 0-.18.02-.27H4.5v-.75h1.19a2.974 2.974 0 0 1 4.81-1.2L9.79 8c-.35-.3-.8-.49-1.29-.49-.73 0-1.37.39-1.72.98h1.75v.75H6.52c-.01.09-.02.18-.02.27 0 .08 0 .16.01.23h2.02v.75H6.76c.34.61 1 1.02 1.74 1.02.49 0 .94-.19 1.29-.49ZM13 3.5v1H3v-1h10m-1-2h-1v1H5v-1H4v1H3c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-10c0-.55-.45-1-1-1h-1v-1Zm-9 12v-8h10v8H3Z" })),
|
|
865
932
|
'check': () => (index.h("path", { fill: "currentColor", d: "m15.27 4.23-1.11-1.18c-.11-.1-.27-.1-.38 0L6 10.36l-3.76-4a.187.187 0 0 0-.26 0L.71 7.6c-.07.07-.07.19 0 .26l5.12 5.41c.07.07.18.07.25 0l1.3-1.23 7.87-7.45c.1-.1.11-.26.01-.37h.01Z" })),
|
|
866
933
|
'check-circle': () => (index.h("path", { fill: "currentColor", d: "M15.33 8A7.33 7.33 0 1 1 8 .67 7.33 7.33 0 0 1 15.33 8Zm-8.18 3.88 5.44-5.44a.46.46 0 0 0 0-.65l-.67-.67a.48.48 0 0 0-.67 0L6.82 9.54 4.75 7.47a.46.46 0 0 0-.65 0l-.67.67a.46.46 0 0 0 0 .65l3.07 3.07a.46.46 0 0 0 .65 0Z" })),
|
|
867
934
|
'chevron-down': () => (index.h("path", { fill: "currentColor", d: "M7.43,12.21.9,5.69a.81.81,0,0,1,0-1.14h0l.76-.77a.81.81,0,0,1,1.14,0L8,9l5.2-5.18a.81.81,0,0,1,1.14,0l.76.77a.8.8,0,0,1,0,1.13h0L8.57,12.21a.79.79,0,0,1-1.13,0Z" })),
|
|
@@ -873,6 +940,8 @@ const icons = {
|
|
|
873
940
|
'chevron-up': () => (index.h("path", { fill: "currentColor", d: "M8.57,3.79l6.53,6.52a.81.81,0,0,1,0,1.14h0l-.76.77a.81.81,0,0,1-1.14,0L8,7,2.8,12.22a.81.81,0,0,1-1.14,0L.9,11.45a.8.8,0,0,1,0-1.13h0L7.43,3.79a.79.79,0,0,1,1.13,0Z" })),
|
|
874
941
|
'chevron-up-circle': () => (index.h("path", { fill: "currentColor", d: "M.67 8C.67 3.95 3.95.67 8 .67S15.33 3.95 15.33 8 12.05 15.33 8 15.33C3.95 15.33.67 12.05.67 8ZM7.5 4.63l-4 4c-.28.27-.28.71-.01.99h.01l.5.53c.28.27.72.27 1 0l3-3 3 3c.28.27.72.27 1 0l.5-.51c.28-.27.28-.71.01-.99h-.01l-4-4.01a.697.697 0 0 0-.99-.01H7.5Z" })),
|
|
875
942
|
'clock': () => (index.h("path", { fill: "currentColor", d: "M8,.67C3.95,.67,.67,3.95,.67,8s3.28,7.33,7.33,7.33,7.33-3.28,7.33-7.33h0C15.33,3.95,12.05,.67,8,.67h0Zm1.69,10.33l-2.61-1.88c-.09-.07-.14-.17-.14-.28V3.84c0-.19,.16-.35,.35-.36h1.42c.2,0,.35,.16,.36,.36V7.93l1.87,1.37c.16,.1,.2,.32,.09,.47v.02h-.01l-.83,1.15c-.12,.15-.34,.18-.5,.06Z" })),
|
|
943
|
+
'clock-outline': () => (index.h("path", { fill: "currentColor", d: "m10.95 10.04-.71.71L7.5 8.01v-4h1V7.6l2.45 2.45ZM8 2C4.69 2 2 4.69 2 8s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6m0-1c3.87 0 7 3.13 7 7s-3.13 7-7 7-7-3.13-7-7 3.13-7 7-7Z" })),
|
|
944
|
+
'code-square-outline': () => (index.h("path", { fill: "currentColor", d: "m6.32 10.28.73-.73L5.5 8l1.53-1.53-.73-.73-2.27 2.27 2.28 2.28Zm3.37 0L11.97 8 9.69 5.72l-.73.73L10.51 8 8.96 9.55l.73.73ZM3.01 14c-.27 0-.5-.1-.7-.3-.2-.2-.3-.43-.3-.7V3c0-.27.1-.5.3-.7.2-.2.43-.3.7-.3h10c.27 0 .5.1.7.3.2.2.3.43.3.7v10c0 .27-.1.5-.3.7-.2.2-.43.3-.7.3H3Zm0-1h10V3H3v10Zm0-10v10V3Z" })),
|
|
876
945
|
'conversation': () => (index.h("path", { fill: "currentColor", d: "M11.22,6.48c0-2.11-2.36-3.81-5.28-3.81S.67,4.37.67,6.48a3.15,3.15,0,0,0,1,2.19A5.17,5.17,0,0,1,.72,10a.2.2,0,0,0,0,.21.23.23,0,0,0,.19.12,4.79,4.79,0,0,0,2.25-.6,6.84,6.84,0,0,0,2.82.6C8.86,10.29,11.22,8.58,11.22,6.48Zm3.1,5.23a3.08,3.08,0,0,0,1-2.19C15.28,7.93,14,6.57,12,6a3.84,3.84,0,0,1,0,.48C12,9,9.3,11.05,6,11.05a7.16,7.16,0,0,1-.8-.05A5.6,5.6,0,0,0,10,13.33a6.7,6.7,0,0,0,2.82-.59,4.66,4.66,0,0,0,2.25.59.21.21,0,0,0,.19-.11.2.2,0,0,0,0-.21,5.15,5.15,0,0,1-.91-1.3Z" })),
|
|
877
946
|
'conversation-outline': () => [
|
|
878
947
|
index.h("path", { fill: "currentColor", d: "M15 8.5c0 .79-.39 1.51-1.01 2.09v1.91a.508.508 0 0 1-.68.47l-2.26-1.05c-.34.05-.69.08-1.05.08-.23 0-.47-.01-.69-.04-.18 0-.35-.03-.52-.07-.02 0-.03 0-.05-.01-.16-.02-.31-.06-.46-.1-.42-.1-.82-.25-1.18-.43l-.42-.24c-.06-.04-.12-.08-.18-.13.58-.03 1.13-.12 1.64-.27.56.19 1.19.29 1.86.29.29 0 .6-.02.91-.07l.29-.04.28.12 1.5.7v-1.12l.01-.43.31-.3c.32-.29.7-.77.7-1.36 0-.91-.82-1.72-2.01-2.15-.01-.39-.09-.77-.23-1.13.06.02.12.04.19.06.25.08.5.17.73.27.11.05.23.11.34.17.11.06.21.12.31.18.11.07.2.13.3.2.48.35.86.78 1.1 1.26a2.288 2.288 0 0 1 .17.45c.03.11.06.22.07.33.02.12.03.24.03.36Z" }),
|
|
@@ -890,9 +959,10 @@ const icons = {
|
|
|
890
959
|
'download': () => (index.h("path", { fill: "currentColor", d: "M6.4 2v4.1c0 .2-.1.3-.3.3H4c-.2 0-.3.1-.3.3 0 .1 0 .2.1.2l4 4c.1.1.3.1.4 0l4-4c.1-.1.1-.3 0-.4-.1-.1-.1-.1-.2-.1H9.9c-.2 0-.3-.1-.3-.3V2c0-.2-.1-.3-.3-.3H6.7c-.1 0-.3.1-.3.3zm7.9 11v1c0 .2-.1.3-.3.3H2c-.2 0-.3-.1-.3-.3v-1c0-.2.1-.3.3-.3h12c.2 0 .3.1.3.3z" })),
|
|
891
960
|
'ellipsis': () => (index.h("path", { fill: "currentColor", d: "M2.5 6.17A1.83 1.83 0 1 0 4.33 8c0-1.01-.82-1.83-1.83-1.83Zm11 0A1.83 1.83 0 1 0 15.33 8c0-1.01-.82-1.83-1.83-1.83Zm-5.5 0A1.83 1.83 0 1 0 9.83 8c0-1.01-.82-1.83-1.83-1.83Z" })),
|
|
892
961
|
'ellipsis-vertical': () => (index.h("path", { fill: "currentColor", d: "M6.17 13.5A1.83 1.83 0 1 0 8 11.67c-1.01 0-1.83.82-1.83 1.83Zm0-11A1.83 1.83 0 1 0 8 .67c-1.01 0-1.83.82-1.83 1.83Zm0 5.5A1.83 1.83 0 1 0 8 6.17c-1.01 0-1.83.82-1.83 1.83Z" })),
|
|
893
|
-
'euro': () => (index.h("path", { fill: "currentColor", d: "
|
|
962
|
+
'euro': () => (index.h("path", { fill: "currentColor", d: "m12.1 11.02 1.4 1.42a5.948 5.948 0 0 1-4 1.56c-2.64 0-4.86-1.68-5.66-4.04H1.5v-1.5h2.02C3.5 8.3 3.5 8.16 3.5 8c0-.18 0-.36.04-.54H1.5v-1.5h2.38C4.7 3.66 6.9 2 9.5 2c1.54 0 2.94.6 4 1.56l-1.4 1.42c-.7-.6-1.6-.98-2.6-.98-1.46 0-2.74.78-3.44 1.96h3.5v1.5H5.54c-.02.18-.04.36-.04.54 0 .16 0 .32.02.46h4.04v1.5H6.02C6.7 11.18 8.02 12 9.5 12c1 0 1.9-.38 2.6-.98Z" })),
|
|
894
963
|
'euro-circle': () => (index.h("path", { fill: "currentColor", d: "M8 .67C3.95.67.67 3.95.67 8S3.95 15.33 8 15.33s7.33-3.28 7.33-7.33S12.05.67 8 .67Zm2.27 11.4c-.38.09-.76.14-1.15.14a4.038 4.038 0 0 1-3.99-2.92h-.58c-.13 0-.23-.1-.23-.22v-.54c0-.12.11-.22.23-.22h.41a5.34 5.34 0 0 1 0-.8h-.41c-.13 0-.23-.1-.23-.22v-.58c0-.13.11-.22.23-.22h.63c.6-1.65 2.18-2.74 3.94-2.71.34 0 .68.03 1.02.1.12.03.19.16.16.28l-.23.84c-.03.12-.15.19-.27.17-.24-.05-.48-.08-.73-.08A2.42 2.42 0 0 0 6.81 6.5h2.71c.12.03.2.15.17.27l-.13.58c-.02.1-.12.18-.22.18H6.52c-.03.26-.03.53 0 .8h2.63c.12.03.2.15.17.27l-.11.52c-.03.1-.12.18-.22.18H6.8c.36.96 1.28 1.6 2.31 1.61.3 0 .59-.04.88-.1.12-.02.24.05.27.18l.17.84c.02.12-.05.24-.17.27v-.03Z" })),
|
|
895
964
|
'exclamation-circle': () => (index.h("path", { fill: "currentColor", d: "M8 15.33c4.05 0 7.33-3.28 7.33-7.33S12.05.67 8 .67.67 3.95.67 8 3.95 15.33 8 15.33Zm.95-3.3c0 .15-.12.27-.28.27h-1.4c-.15 0-.28-.12-.28-.27v-1.31c0-.15.12-.28.28-.28h1.4c.15 0 .28.12.28.28v1.31ZM7 3.96c0-.14.11-.25.25-.25H8.7c.14 0 .25.11.25.25v4.8c0 .14-.11.25-.25.25H7.25c-.14 0-.25-.11-.25-.25V3.95Z" })),
|
|
965
|
+
'exclamation-stamp': () => (index.h("path", { fill: "currentColor", d: "m15 8-1.55-1.86.22-2.46-2.3-.55L10.17 1 8 1.98 5.84 1 4.63 3.13l-2.29.54.22 2.46L1.01 8l1.55 1.86-.22 2.47 2.3.55 1.2 2.13L8 14.03l2.17.98 1.2-2.13 2.3-.55-.22-2.46L15 8.01Zm-6.36 3.35H7.36v-1.34h1.28v1.34Zm0-2.67H7.36V4.67h1.28v4.01Z" })),
|
|
896
966
|
'exclamation-triangle': () => (index.h("path", { fill: "currentColor", d: "m14.3 13.88-6-12a.32.32 0 0 0-.41-.15.31.31 0 0 0-.15.15l-6 12a.31.31 0 0 0 .14.42.32.32 0 0 0 .14 0H14a.31.31 0 0 0 .33-.29.23.23 0 0 0-.03-.13ZM7 6a.28.28 0 0 1 .28-.28h1.46A.28.28 0 0 1 9 6v4a.29.29 0 0 1-.28.29H7.3A.29.29 0 0 1 7 10Zm2 7a.31.31 0 0 1-.31.32H7.34A.32.32 0 0 1 7 13v-1.37a.31.31 0 0 1 .32-.31h1.39a.31.31 0 0 1 .31.31Z" })),
|
|
897
967
|
'eye': () => [
|
|
898
968
|
index.h("circle", { fill: "currentColor", cx: "8.01", cy: "7.96", r: "2.44" }),
|
|
@@ -1015,24 +1085,17 @@ const mgIconCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !i
|
|
|
1015
1085
|
const MgIcon = class {
|
|
1016
1086
|
constructor(hostRef) {
|
|
1017
1087
|
index.registerInstance(this, hostRef);
|
|
1018
|
-
/**
|
|
1019
|
-
* Define icon size
|
|
1020
|
-
*/
|
|
1021
|
-
this.size = 'regular';
|
|
1022
|
-
/**
|
|
1023
|
-
* Make the icon spin
|
|
1024
|
-
*/
|
|
1025
|
-
this.spin = false;
|
|
1026
|
-
/**
|
|
1027
|
-
* Component classes
|
|
1028
|
-
*/
|
|
1029
|
-
this.classList = new ClassList(['mg-icon']);
|
|
1030
1088
|
/**
|
|
1031
1089
|
* getIcon
|
|
1032
1090
|
*
|
|
1033
1091
|
* @returns {HTMLElement} icon html
|
|
1034
1092
|
*/
|
|
1035
1093
|
this.getIcon = () => icons[this.icon]();
|
|
1094
|
+
this.icon = undefined;
|
|
1095
|
+
this.size = 'regular';
|
|
1096
|
+
this.variant = undefined;
|
|
1097
|
+
this.spin = false;
|
|
1098
|
+
this.classList = new ClassList(['mg-icon']);
|
|
1036
1099
|
}
|
|
1037
1100
|
validateIcon(newValue, oldValue) {
|
|
1038
1101
|
if (!Object.keys(icons).includes(newValue)) {
|
|
@@ -1105,18 +1168,12 @@ const MgIcon = class {
|
|
|
1105
1168
|
};
|
|
1106
1169
|
MgIcon.style = mgIconCss;
|
|
1107
1170
|
|
|
1108
|
-
const mgIllustratedMessageCss = ".mg-illustrated-message{display:flex;flex-direction:column;justify-content:center;gap:3em 7rem;margin:auto;padding:var(--mg-illustrated-message-padding-vertical) 1.5rem;max-width:47.5rem;box-sizing:border-box;text-align:center}.mg-illustrated-message.mg-illustrated-message--horizontal{flex-direction:row;flex-wrap:wrap;align-items:center;max-width:unset}.mg-illustrated-message.mg-illustrated-message--horizontal .mg-illustrated-message__slots,.mg-illustrated-message.mg-illustrated-message--horizontal .mg-illustrated-message__illustration{max-width:47.5rem}.mg-illustrated-message__illustration{max-height:
|
|
1171
|
+
const mgIllustratedMessageCss = ".mg-illustrated-message{display:flex;flex-direction:column;justify-content:center;gap:3em 7rem;margin:auto;padding:var(--mg-illustrated-message-padding-vertical) 1.5rem;max-width:47.5rem;box-sizing:border-box;text-align:center}.mg-illustrated-message.mg-illustrated-message--horizontal{flex-direction:row;flex-wrap:wrap;align-items:center;max-width:unset}.mg-illustrated-message.mg-illustrated-message--horizontal .mg-illustrated-message__slots,.mg-illustrated-message.mg-illustrated-message--horizontal .mg-illustrated-message__illustration{max-width:47.5rem}.mg-illustrated-message__illustration{max-height:18.4rem}.mg-illustrated-message__illustration ::slotted([slot=illustration]){width:auto;height:auto;max-width:100%;max-height:18.4rem}.mg-illustrated-message__illustration.mg-illustrated-message__illustration--small{max-height:6rem}.mg-illustrated-message__illustration.mg-illustrated-message__illustration--small ::slotted([slot=illustration]){max-height:6rem}.mg-illustrated-message__title ::slotted([slot=title]){margin:0;font-size:2rem !important;font-family:var(--font-family) !important;font-weight:400}.mg-illustrated-message__details ::slotted([slot=details]){margin:2rem 0 0}";
|
|
1109
1172
|
|
|
1110
1173
|
const MgIllustratedMessage = class {
|
|
1111
1174
|
constructor(hostRef) {
|
|
1112
1175
|
index.registerInstance(this, hostRef);
|
|
1113
|
-
/**
|
|
1114
|
-
* Define illustration size
|
|
1115
|
-
*/
|
|
1116
1176
|
this.size = 'regular';
|
|
1117
|
-
/**
|
|
1118
|
-
* Define component orientation
|
|
1119
|
-
*/
|
|
1120
1177
|
this.direction = 'vertical';
|
|
1121
1178
|
}
|
|
1122
1179
|
/*************
|
|
@@ -1129,13 +1186,14 @@ const MgIllustratedMessage = class {
|
|
|
1129
1186
|
*/
|
|
1130
1187
|
componentDidLoad() {
|
|
1131
1188
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
1132
|
-
const
|
|
1189
|
+
const slottedIllustrations = this.element.querySelectorAll('[slot="illustration"]');
|
|
1133
1190
|
if (!isTagName(this.element.querySelector('[slot="title"]'), headingTags)) {
|
|
1134
1191
|
throw new Error(`<mg-illustrated-message> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
1135
1192
|
}
|
|
1136
|
-
else if (
|
|
1137
|
-
throw new Error(
|
|
1193
|
+
else if (slottedIllustrations.length !== 1) {
|
|
1194
|
+
throw new Error('<mg-illustrated-message> Slotted illustration must be present and unique.');
|
|
1138
1195
|
}
|
|
1196
|
+
slottedIllustrations[0].setAttribute('aria-hidden', 'true');
|
|
1139
1197
|
}
|
|
1140
1198
|
/**
|
|
1141
1199
|
* Render
|
|
@@ -1297,39 +1355,6 @@ const MgInputCheckbox = class {
|
|
|
1297
1355
|
this.inputs = [];
|
|
1298
1356
|
// hasDisplayedError (triggered by blur event)
|
|
1299
1357
|
this.hasDisplayedError = false;
|
|
1300
|
-
/**
|
|
1301
|
-
* Input name
|
|
1302
|
-
* If not set the value equals the identifier
|
|
1303
|
-
*/
|
|
1304
|
-
this.name = this.identifier;
|
|
1305
|
-
/**
|
|
1306
|
-
* Define if label is visible
|
|
1307
|
-
*/
|
|
1308
|
-
this.labelHide = false;
|
|
1309
|
-
/**
|
|
1310
|
-
* Define if inputs are display verticaly
|
|
1311
|
-
*/
|
|
1312
|
-
this.inputVerticalList = false;
|
|
1313
|
-
/**
|
|
1314
|
-
* Define if input is required
|
|
1315
|
-
*/
|
|
1316
|
-
this.required = false;
|
|
1317
|
-
/**
|
|
1318
|
-
* Define if input is readonly
|
|
1319
|
-
*/
|
|
1320
|
-
this.readonly = false;
|
|
1321
|
-
/**
|
|
1322
|
-
* Define if input is disabled
|
|
1323
|
-
*/
|
|
1324
|
-
this.disabled = false;
|
|
1325
|
-
/**
|
|
1326
|
-
* Component classes
|
|
1327
|
-
*/
|
|
1328
|
-
this.classList = new ClassList(['mg-input--checkbox']);
|
|
1329
|
-
/**
|
|
1330
|
-
* Formated value for display
|
|
1331
|
-
*/
|
|
1332
|
-
this.checkboxItems = [];
|
|
1333
1358
|
/**
|
|
1334
1359
|
* Handle input event
|
|
1335
1360
|
*
|
|
@@ -1379,6 +1404,23 @@ const MgInputCheckbox = class {
|
|
|
1379
1404
|
this.errorMessage = this.messages.errors.required;
|
|
1380
1405
|
}
|
|
1381
1406
|
};
|
|
1407
|
+
this.value = undefined;
|
|
1408
|
+
this.identifier = undefined;
|
|
1409
|
+
this.name = this.identifier;
|
|
1410
|
+
this.label = undefined;
|
|
1411
|
+
this.labelOnTop = undefined;
|
|
1412
|
+
this.labelHide = false;
|
|
1413
|
+
this.inputVerticalList = false;
|
|
1414
|
+
this.required = false;
|
|
1415
|
+
this.readonly = false;
|
|
1416
|
+
this.disabled = false;
|
|
1417
|
+
this.tooltip = undefined;
|
|
1418
|
+
this.helpText = undefined;
|
|
1419
|
+
this.valid = undefined;
|
|
1420
|
+
this.invalid = undefined;
|
|
1421
|
+
this.classList = new ClassList(['mg-input--checkbox']);
|
|
1422
|
+
this.errorMessage = undefined;
|
|
1423
|
+
this.checkboxItems = [];
|
|
1382
1424
|
}
|
|
1383
1425
|
validateValue(newValue) {
|
|
1384
1426
|
if (newValue && newValue.every(item => isCheckboxItem(item))) {
|
|
@@ -1467,46 +1509,7 @@ var InputError$1;
|
|
|
1467
1509
|
InputError["REQUIRED"] = "required";
|
|
1468
1510
|
})(InputError$1 || (InputError$1 = {}));
|
|
1469
1511
|
|
|
1470
|
-
|
|
1471
|
-
* Format number to the locale currency
|
|
1472
|
-
*
|
|
1473
|
-
* @param {number} number number to format
|
|
1474
|
-
* @param {string} locale locale to apply
|
|
1475
|
-
* @param {string} currency currency to apply
|
|
1476
|
-
* @returns {string} formatted currency
|
|
1477
|
-
*/
|
|
1478
|
-
function localeCurrency(number, locale, currency) {
|
|
1479
|
-
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
|
|
1480
|
-
}
|
|
1481
|
-
/**
|
|
1482
|
-
* Format number to locale
|
|
1483
|
-
*
|
|
1484
|
-
* @param {number} number number to format
|
|
1485
|
-
* @param {string} locale locale to apply
|
|
1486
|
-
* @returns {string} formatted number
|
|
1487
|
-
*/
|
|
1488
|
-
function localeNumber(number, locale) {
|
|
1489
|
-
return new Intl.NumberFormat(locale).format(number);
|
|
1490
|
-
}
|
|
1491
|
-
/**
|
|
1492
|
-
* Date RegExp
|
|
1493
|
-
*/
|
|
1494
|
-
const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
1495
|
-
/**
|
|
1496
|
-
* Locale date format
|
|
1497
|
-
*
|
|
1498
|
-
* @param {string} date date to format
|
|
1499
|
-
* @param {string} locale locale to apply
|
|
1500
|
-
* @returns {string} formatted date
|
|
1501
|
-
*/
|
|
1502
|
-
function localeDate(date, locale) {
|
|
1503
|
-
if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
|
|
1504
|
-
return '';
|
|
1505
|
-
}
|
|
1506
|
-
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
const mgInputDateCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}";
|
|
1512
|
+
const mgInputDateCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}";
|
|
1510
1513
|
|
|
1511
1514
|
const MgInputDate = class {
|
|
1512
1515
|
constructor(hostRef) {
|
|
@@ -1515,31 +1518,6 @@ const MgInputDate = class {
|
|
|
1515
1518
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
1516
1519
|
// hasDisplayedError (triggered by blur event)
|
|
1517
1520
|
this.hasDisplayedError = false;
|
|
1518
|
-
/**
|
|
1519
|
-
* Input name
|
|
1520
|
-
* If not set the value equals the identifier
|
|
1521
|
-
*/
|
|
1522
|
-
this.name = this.identifier;
|
|
1523
|
-
/**
|
|
1524
|
-
* Define if label is visible
|
|
1525
|
-
*/
|
|
1526
|
-
this.labelHide = false;
|
|
1527
|
-
/**
|
|
1528
|
-
* Define if input is required
|
|
1529
|
-
*/
|
|
1530
|
-
this.required = false;
|
|
1531
|
-
/**
|
|
1532
|
-
* Define if input is readonly
|
|
1533
|
-
*/
|
|
1534
|
-
this.readonly = false;
|
|
1535
|
-
/**
|
|
1536
|
-
* Define if input is disabled
|
|
1537
|
-
*/
|
|
1538
|
-
this.disabled = false;
|
|
1539
|
-
/**
|
|
1540
|
-
* Component classes
|
|
1541
|
-
*/
|
|
1542
|
-
this.classList = new ClassList(['mg-input--date']);
|
|
1543
1521
|
/**
|
|
1544
1522
|
* Handle input event
|
|
1545
1523
|
*/
|
|
@@ -1618,13 +1596,33 @@ const MgInputDate = class {
|
|
|
1618
1596
|
}
|
|
1619
1597
|
}
|
|
1620
1598
|
};
|
|
1599
|
+
this.value = undefined;
|
|
1600
|
+
this.identifier = undefined;
|
|
1601
|
+
this.name = this.identifier;
|
|
1602
|
+
this.label = undefined;
|
|
1603
|
+
this.labelOnTop = undefined;
|
|
1604
|
+
this.labelHide = false;
|
|
1605
|
+
this.required = false;
|
|
1606
|
+
this.readonly = false;
|
|
1607
|
+
this.disabled = false;
|
|
1608
|
+
this.tooltip = undefined;
|
|
1609
|
+
this.helpText = undefined;
|
|
1610
|
+
this.valid = undefined;
|
|
1611
|
+
this.invalid = undefined;
|
|
1612
|
+
this.min = undefined;
|
|
1613
|
+
this.max = undefined;
|
|
1614
|
+
this.classList = new ClassList(['mg-input--date']);
|
|
1615
|
+
this.errorMessage = undefined;
|
|
1621
1616
|
}
|
|
1622
1617
|
validateValue(newValue) {
|
|
1618
|
+
// When the input is not fully completed or has been cleared, the value becomes an empty string.
|
|
1619
|
+
if (newValue === '')
|
|
1620
|
+
newValue = null;
|
|
1623
1621
|
if (newValue !== undefined && newValue !== null && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
|
|
1624
1622
|
throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
|
|
1625
1623
|
}
|
|
1626
1624
|
else {
|
|
1627
|
-
this.valueChange.emit(
|
|
1625
|
+
this.valueChange.emit(newValue);
|
|
1628
1626
|
}
|
|
1629
1627
|
}
|
|
1630
1628
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -1711,7 +1709,7 @@ var InputError;
|
|
|
1711
1709
|
InputError["REQUIRED"] = "required";
|
|
1712
1710
|
})(InputError || (InputError = {}));
|
|
1713
1711
|
|
|
1714
|
-
const mgInputNumericCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem
|
|
1712
|
+
const mgInputNumericCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input .mg-input__box{text-align:var(--mg-inputs-text-align, right)}";
|
|
1715
1713
|
|
|
1716
1714
|
const MgInputNumeric = class {
|
|
1717
1715
|
constructor(hostRef) {
|
|
@@ -1721,65 +1719,18 @@ const MgInputNumeric = class {
|
|
|
1721
1719
|
// hasDisplayedError (triggered by blur event)
|
|
1722
1720
|
this.hasDisplayedError = false;
|
|
1723
1721
|
/**
|
|
1724
|
-
*
|
|
1725
|
-
*
|
|
1722
|
+
* Handle input event
|
|
1723
|
+
*
|
|
1724
|
+
* @returns {void}
|
|
1726
1725
|
*/
|
|
1727
|
-
this.
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
this.required = false;
|
|
1736
|
-
/**
|
|
1737
|
-
* Define if input is readonly
|
|
1738
|
-
*/
|
|
1739
|
-
this.readonly = false;
|
|
1740
|
-
/**
|
|
1741
|
-
* Define if input is disabled
|
|
1742
|
-
*/
|
|
1743
|
-
this.disabled = false;
|
|
1744
|
-
/**
|
|
1745
|
-
* Define numeric type
|
|
1746
|
-
*/
|
|
1747
|
-
this.type = types[0];
|
|
1748
|
-
/**
|
|
1749
|
-
* Define currency
|
|
1750
|
-
*/
|
|
1751
|
-
this.currency = 'USD';
|
|
1752
|
-
/**
|
|
1753
|
-
* Override integer length
|
|
1754
|
-
* integer is the number before the decimal point
|
|
1755
|
-
*/
|
|
1756
|
-
this.integerLength = 13;
|
|
1757
|
-
/**
|
|
1758
|
-
* Override decimal length
|
|
1759
|
-
* decimal is the number after the decimal point
|
|
1760
|
-
*/
|
|
1761
|
-
this.decimalLength = 2;
|
|
1762
|
-
/**
|
|
1763
|
-
* Component classes
|
|
1764
|
-
*/
|
|
1765
|
-
this.classList = new ClassList(['mg-input--numeric']);
|
|
1766
|
-
/**
|
|
1767
|
-
* Define if input has focus
|
|
1768
|
-
*/
|
|
1769
|
-
this.hasFocus = false;
|
|
1770
|
-
/**
|
|
1771
|
-
* Handle input event
|
|
1772
|
-
*
|
|
1773
|
-
* @returns {void}
|
|
1774
|
-
*/
|
|
1775
|
-
this.handleInput = () => {
|
|
1776
|
-
// Check validity
|
|
1777
|
-
this.checkValidity();
|
|
1778
|
-
if (this.hasDisplayedError) {
|
|
1779
|
-
this.setErrorMessage();
|
|
1780
|
-
}
|
|
1781
|
-
this.value = this.input.value;
|
|
1782
|
-
};
|
|
1726
|
+
this.handleInput = () => {
|
|
1727
|
+
// Check validity
|
|
1728
|
+
this.checkValidity();
|
|
1729
|
+
if (this.hasDisplayedError) {
|
|
1730
|
+
this.setErrorMessage();
|
|
1731
|
+
}
|
|
1732
|
+
this.value = this.input.value;
|
|
1733
|
+
};
|
|
1783
1734
|
/**
|
|
1784
1735
|
* Handle focus event
|
|
1785
1736
|
*
|
|
@@ -1873,6 +1824,30 @@ const MgInputNumeric = class {
|
|
|
1873
1824
|
this.classList.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
1874
1825
|
}
|
|
1875
1826
|
};
|
|
1827
|
+
this.value = undefined;
|
|
1828
|
+
this.identifier = undefined;
|
|
1829
|
+
this.name = this.identifier;
|
|
1830
|
+
this.label = undefined;
|
|
1831
|
+
this.labelOnTop = undefined;
|
|
1832
|
+
this.labelHide = false;
|
|
1833
|
+
this.placeholder = undefined;
|
|
1834
|
+
this.required = false;
|
|
1835
|
+
this.readonly = false;
|
|
1836
|
+
this.disabled = false;
|
|
1837
|
+
this.mgWidth = undefined;
|
|
1838
|
+
this.tooltip = undefined;
|
|
1839
|
+
this.helpText = undefined;
|
|
1840
|
+
this.type = types[0];
|
|
1841
|
+
this.currency = 'USD';
|
|
1842
|
+
this.max = undefined;
|
|
1843
|
+
this.min = undefined;
|
|
1844
|
+
this.integerLength = 13;
|
|
1845
|
+
this.decimalLength = 2;
|
|
1846
|
+
this.valid = undefined;
|
|
1847
|
+
this.invalid = undefined;
|
|
1848
|
+
this.classList = new ClassList(['mg-input--numeric']);
|
|
1849
|
+
this.errorMessage = undefined;
|
|
1850
|
+
this.hasFocus = false;
|
|
1876
1851
|
}
|
|
1877
1852
|
validateValue(newValue) {
|
|
1878
1853
|
if (newValue !== undefined && newValue !== null) {
|
|
@@ -1995,7 +1970,7 @@ const MgInputNumeric = class {
|
|
|
1995
1970
|
};
|
|
1996
1971
|
MgInputNumeric.style = mgInputNumericCss;
|
|
1997
1972
|
|
|
1998
|
-
const mgInputPasswordCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem
|
|
1973
|
+
const mgInputPasswordCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}";
|
|
1999
1974
|
|
|
2000
1975
|
const MgInputPassword = class {
|
|
2001
1976
|
constructor(hostRef) {
|
|
@@ -2004,35 +1979,6 @@ const MgInputPassword = class {
|
|
|
2004
1979
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
2005
1980
|
// hasDisplayedError (triggered by blur event)
|
|
2006
1981
|
this.hasDisplayedError = false;
|
|
2007
|
-
/**
|
|
2008
|
-
* Input name
|
|
2009
|
-
* If not set the value equals the identifier
|
|
2010
|
-
*/
|
|
2011
|
-
this.name = this.identifier;
|
|
2012
|
-
/**
|
|
2013
|
-
* Define if label is visible
|
|
2014
|
-
*/
|
|
2015
|
-
this.labelHide = false;
|
|
2016
|
-
/**
|
|
2017
|
-
* Define if input is required
|
|
2018
|
-
*/
|
|
2019
|
-
this.required = false;
|
|
2020
|
-
/**
|
|
2021
|
-
* Define if input is readonly
|
|
2022
|
-
*/
|
|
2023
|
-
this.readonly = false;
|
|
2024
|
-
/**
|
|
2025
|
-
* Define if input is disabled
|
|
2026
|
-
*/
|
|
2027
|
-
this.disabled = false;
|
|
2028
|
-
/**
|
|
2029
|
-
* Define input width
|
|
2030
|
-
*/
|
|
2031
|
-
this.mgWidth = 'full';
|
|
2032
|
-
/**
|
|
2033
|
-
* Component classes
|
|
2034
|
-
*/
|
|
2035
|
-
this.classList = new ClassList(['mg-input--password']);
|
|
2036
1982
|
/**
|
|
2037
1983
|
* Handle input event
|
|
2038
1984
|
*/
|
|
@@ -2070,6 +2016,23 @@ const MgInputPassword = class {
|
|
|
2070
2016
|
this.errorMessage = this.messages.errors.required;
|
|
2071
2017
|
}
|
|
2072
2018
|
};
|
|
2019
|
+
this.value = undefined;
|
|
2020
|
+
this.identifier = undefined;
|
|
2021
|
+
this.name = this.identifier;
|
|
2022
|
+
this.label = undefined;
|
|
2023
|
+
this.labelOnTop = undefined;
|
|
2024
|
+
this.labelHide = false;
|
|
2025
|
+
this.placeholder = undefined;
|
|
2026
|
+
this.required = false;
|
|
2027
|
+
this.readonly = false;
|
|
2028
|
+
this.disabled = false;
|
|
2029
|
+
this.mgWidth = 'full';
|
|
2030
|
+
this.tooltip = undefined;
|
|
2031
|
+
this.helpText = undefined;
|
|
2032
|
+
this.valid = undefined;
|
|
2033
|
+
this.invalid = undefined;
|
|
2034
|
+
this.classList = new ClassList(['mg-input--password']);
|
|
2035
|
+
this.errorMessage = undefined;
|
|
2073
2036
|
}
|
|
2074
2037
|
handleValue(newValue) {
|
|
2075
2038
|
this.valueChange.emit(newValue);
|
|
@@ -2154,39 +2117,6 @@ const MgInputRadio = class {
|
|
|
2154
2117
|
this.inputs = [];
|
|
2155
2118
|
// hasDisplayedError (triggered by blur event)
|
|
2156
2119
|
this.hasDisplayedError = false;
|
|
2157
|
-
/**
|
|
2158
|
-
* Input name
|
|
2159
|
-
* If not set the value equals the identifier
|
|
2160
|
-
*/
|
|
2161
|
-
this.name = this.identifier;
|
|
2162
|
-
/**
|
|
2163
|
-
* Define if label is displayed on top
|
|
2164
|
-
*/
|
|
2165
|
-
this.labelOnTop = false;
|
|
2166
|
-
/**
|
|
2167
|
-
* Define if label is visible
|
|
2168
|
-
*/
|
|
2169
|
-
this.labelHide = false;
|
|
2170
|
-
/**
|
|
2171
|
-
* Define if inputs are display verticaly
|
|
2172
|
-
*/
|
|
2173
|
-
this.inputVerticalList = false;
|
|
2174
|
-
/**
|
|
2175
|
-
* Define if input is required
|
|
2176
|
-
*/
|
|
2177
|
-
this.required = false;
|
|
2178
|
-
/**
|
|
2179
|
-
* Define if input is readonly
|
|
2180
|
-
*/
|
|
2181
|
-
this.readonly = false;
|
|
2182
|
-
/**
|
|
2183
|
-
* Define if input is disabled
|
|
2184
|
-
*/
|
|
2185
|
-
this.disabled = false;
|
|
2186
|
-
/**
|
|
2187
|
-
* Component classes
|
|
2188
|
-
*/
|
|
2189
|
-
this.classList = new ClassList(['mg-input--radio']);
|
|
2190
2120
|
/**
|
|
2191
2121
|
* Handle input event
|
|
2192
2122
|
*
|
|
@@ -2236,6 +2166,24 @@ const MgInputRadio = class {
|
|
|
2236
2166
|
* @returns {HTMLInputElement} element
|
|
2237
2167
|
*/
|
|
2238
2168
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
2169
|
+
this.value = undefined;
|
|
2170
|
+
this.items = undefined;
|
|
2171
|
+
this.identifier = undefined;
|
|
2172
|
+
this.name = this.identifier;
|
|
2173
|
+
this.label = undefined;
|
|
2174
|
+
this.labelOnTop = false;
|
|
2175
|
+
this.labelHide = false;
|
|
2176
|
+
this.inputVerticalList = false;
|
|
2177
|
+
this.required = false;
|
|
2178
|
+
this.readonly = false;
|
|
2179
|
+
this.disabled = false;
|
|
2180
|
+
this.tooltip = undefined;
|
|
2181
|
+
this.helpText = undefined;
|
|
2182
|
+
this.valid = undefined;
|
|
2183
|
+
this.invalid = undefined;
|
|
2184
|
+
this.classList = new ClassList(['mg-input--radio']);
|
|
2185
|
+
this.errorMessage = undefined;
|
|
2186
|
+
this.options = undefined;
|
|
2239
2187
|
}
|
|
2240
2188
|
handleValue(newValue) {
|
|
2241
2189
|
this.valueChange.emit(newValue);
|
|
@@ -2319,7 +2267,7 @@ const MgInputRadio = class {
|
|
|
2319
2267
|
};
|
|
2320
2268
|
MgInputRadio.style = mgInputRadioCss;
|
|
2321
2269
|
|
|
2322
|
-
const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem
|
|
2270
|
+
const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input__box{width:100%;padding-top:0;padding-bottom:0;padding-right:1rem}.mg-input.mg-input--select:not(.mg-input--label-on-top) .mg-input__box{max-width:unset}";
|
|
2323
2271
|
|
|
2324
2272
|
/**
|
|
2325
2273
|
* Check if item is a well configured option
|
|
@@ -2364,39 +2312,6 @@ const MgInputSelect = class {
|
|
|
2364
2312
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
2365
2313
|
// hasDisplayedError (triggered by blur event)
|
|
2366
2314
|
this.hasDisplayedError = false;
|
|
2367
|
-
/**
|
|
2368
|
-
* Input name
|
|
2369
|
-
* If not set the value equals the identifier
|
|
2370
|
-
*/
|
|
2371
|
-
this.name = this.identifier;
|
|
2372
|
-
/**
|
|
2373
|
-
* Define if label is visible
|
|
2374
|
-
*/
|
|
2375
|
-
this.labelHide = false;
|
|
2376
|
-
/**
|
|
2377
|
-
* Option to remove placeholder
|
|
2378
|
-
*/
|
|
2379
|
-
this.placeholderHide = false;
|
|
2380
|
-
/**
|
|
2381
|
-
* Option to disable placeholder
|
|
2382
|
-
*/
|
|
2383
|
-
this.placeholderDisabled = false;
|
|
2384
|
-
/**
|
|
2385
|
-
* Define if input is required
|
|
2386
|
-
*/
|
|
2387
|
-
this.required = false;
|
|
2388
|
-
/**
|
|
2389
|
-
* Define if input is readonly
|
|
2390
|
-
*/
|
|
2391
|
-
this.readonly = false;
|
|
2392
|
-
/**
|
|
2393
|
-
* Define if input is disabled
|
|
2394
|
-
*/
|
|
2395
|
-
this.disabled = false;
|
|
2396
|
-
/**
|
|
2397
|
-
* Component classes
|
|
2398
|
-
*/
|
|
2399
|
-
this.classList = new ClassList(['mg-input--select']);
|
|
2400
2315
|
/**
|
|
2401
2316
|
* Handle input event
|
|
2402
2317
|
*/
|
|
@@ -2438,6 +2353,29 @@ const MgInputSelect = class {
|
|
|
2438
2353
|
this.errorMessage = this.messages.errors.required;
|
|
2439
2354
|
}
|
|
2440
2355
|
};
|
|
2356
|
+
this.value = undefined;
|
|
2357
|
+
this.items = undefined;
|
|
2358
|
+
this.identifier = undefined;
|
|
2359
|
+
this.name = this.identifier;
|
|
2360
|
+
this.label = undefined;
|
|
2361
|
+
this.labelOnTop = undefined;
|
|
2362
|
+
this.labelHide = false;
|
|
2363
|
+
this.placeholder = undefined;
|
|
2364
|
+
this.placeholderHide = false;
|
|
2365
|
+
this.placeholderDisabled = false;
|
|
2366
|
+
this.required = false;
|
|
2367
|
+
this.readonly = false;
|
|
2368
|
+
this.disabled = false;
|
|
2369
|
+
this.mgWidth = undefined;
|
|
2370
|
+
this.tooltip = undefined;
|
|
2371
|
+
this.helpText = undefined;
|
|
2372
|
+
this.valid = undefined;
|
|
2373
|
+
this.invalid = undefined;
|
|
2374
|
+
this.classList = new ClassList(['mg-input--select']);
|
|
2375
|
+
this.errorMessage = undefined;
|
|
2376
|
+
this.options = undefined;
|
|
2377
|
+
this.valueExist = undefined;
|
|
2378
|
+
this.readonlyValue = undefined;
|
|
2441
2379
|
}
|
|
2442
2380
|
handleValue(newValue) {
|
|
2443
2381
|
if (newValue !== null) {
|
|
@@ -2449,13 +2387,17 @@ const MgInputSelect = class {
|
|
|
2449
2387
|
this.valueChange.emit(newValue);
|
|
2450
2388
|
}
|
|
2451
2389
|
validateItems(newValue) {
|
|
2390
|
+
// Empty options
|
|
2391
|
+
if (newValue.length === 0) {
|
|
2392
|
+
this.options = [];
|
|
2393
|
+
}
|
|
2452
2394
|
// String array
|
|
2453
|
-
if (allItemsAreString(newValue)) {
|
|
2395
|
+
else if (allItemsAreString(newValue)) {
|
|
2454
2396
|
this.valueExist = newValue.includes(this.value);
|
|
2455
2397
|
this.options = newValue.map((item) => ({ title: item, value: item }));
|
|
2456
2398
|
}
|
|
2457
2399
|
// Object array
|
|
2458
|
-
else if (newValue
|
|
2400
|
+
else if (newValue.every(item => isOption$1(item))) {
|
|
2459
2401
|
this.valueExist = newValue.map(item => item.value).includes(this.value);
|
|
2460
2402
|
// Grouped object options
|
|
2461
2403
|
if (newValue.some(item => item.group !== undefined)) {
|
|
@@ -2467,7 +2409,7 @@ const MgInputSelect = class {
|
|
|
2467
2409
|
}
|
|
2468
2410
|
}
|
|
2469
2411
|
else {
|
|
2470
|
-
throw new Error('<mg-input-select> prop "items" is required
|
|
2412
|
+
throw new Error('<mg-input-select> prop "items" is required, can be an empty Array or all items must be the same type: string or Option.');
|
|
2471
2413
|
}
|
|
2472
2414
|
}
|
|
2473
2415
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -2537,7 +2479,7 @@ const MgInputSelect = class {
|
|
|
2537
2479
|
};
|
|
2538
2480
|
MgInputSelect.style = mgInputSelectCss;
|
|
2539
2481
|
|
|
2540
|
-
const mgInputTextCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem
|
|
2482
|
+
const mgInputTextCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input.mg-input--has-icon .mg-input__with-character-left>mg-icon{position:absolute;top:50%;left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__with-character-left .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}.mg-input__with-character-left{position:relative;display:inline-flex}.mg-input--width-full .mg-input__with-character-left{width:100%}.mg-input.is-focused .mg-input__with-character-left .mg-input__box{padding-right:calc(var(--mg-character-left-message-length) * 1ch + 0.8rem)}.mg-input__with-character-left mg-character-left{position:absolute;display:none;top:50%;right:1rem;opacity:0.6;transform:translateY(-50%);font-size:1.1rem}.mg-input.is-focused .mg-input__with-character-left mg-character-left{display:block}";
|
|
2541
2483
|
|
|
2542
2484
|
const MgInputText = class {
|
|
2543
2485
|
constructor(hostRef) {
|
|
@@ -2553,47 +2495,6 @@ const MgInputText = class {
|
|
|
2553
2495
|
this.classHasIcon = 'mg-input--has-icon';
|
|
2554
2496
|
// hasDisplayedError (triggered by blur event)
|
|
2555
2497
|
this.hasDisplayedError = false;
|
|
2556
|
-
/**
|
|
2557
|
-
* Input name
|
|
2558
|
-
* If not set the value equals the identifier
|
|
2559
|
-
*/
|
|
2560
|
-
this.name = this.identifier;
|
|
2561
|
-
/**
|
|
2562
|
-
* Input type
|
|
2563
|
-
*/
|
|
2564
|
-
this.type = 'text';
|
|
2565
|
-
/**
|
|
2566
|
-
* Define if label is visible
|
|
2567
|
-
*/
|
|
2568
|
-
this.labelHide = false;
|
|
2569
|
-
/**
|
|
2570
|
-
* Input max length
|
|
2571
|
-
*/
|
|
2572
|
-
this.maxlength = 400;
|
|
2573
|
-
/**
|
|
2574
|
-
* Define if input is required
|
|
2575
|
-
*/
|
|
2576
|
-
this.required = false;
|
|
2577
|
-
/**
|
|
2578
|
-
* Define if input is readonly
|
|
2579
|
-
*/
|
|
2580
|
-
this.readonly = false;
|
|
2581
|
-
/**
|
|
2582
|
-
* Define if input is disabled
|
|
2583
|
-
*/
|
|
2584
|
-
this.disabled = false;
|
|
2585
|
-
/**
|
|
2586
|
-
* Define input width
|
|
2587
|
-
*/
|
|
2588
|
-
this.mgWidth = 'full';
|
|
2589
|
-
/**
|
|
2590
|
-
* Define if component should display character left
|
|
2591
|
-
*/
|
|
2592
|
-
this.displayCharacterLeft = true;
|
|
2593
|
-
/**
|
|
2594
|
-
* Component classes
|
|
2595
|
-
*/
|
|
2596
|
-
this.classList = new ClassList(['mg-input--text']);
|
|
2597
2498
|
/**
|
|
2598
2499
|
* Handle input event
|
|
2599
2500
|
*
|
|
@@ -2684,6 +2585,29 @@ const MgInputText = class {
|
|
|
2684
2585
|
this.classList.add('mg-input--has-buttons-group-append');
|
|
2685
2586
|
}
|
|
2686
2587
|
};
|
|
2588
|
+
this.value = undefined;
|
|
2589
|
+
this.identifier = undefined;
|
|
2590
|
+
this.name = this.identifier;
|
|
2591
|
+
this.label = undefined;
|
|
2592
|
+
this.type = 'text';
|
|
2593
|
+
this.icon = undefined;
|
|
2594
|
+
this.labelOnTop = undefined;
|
|
2595
|
+
this.labelHide = false;
|
|
2596
|
+
this.placeholder = undefined;
|
|
2597
|
+
this.maxlength = 400;
|
|
2598
|
+
this.required = false;
|
|
2599
|
+
this.readonly = false;
|
|
2600
|
+
this.disabled = false;
|
|
2601
|
+
this.mgWidth = 'full';
|
|
2602
|
+
this.pattern = undefined;
|
|
2603
|
+
this.patternErrorMessage = undefined;
|
|
2604
|
+
this.tooltip = undefined;
|
|
2605
|
+
this.displayCharacterLeft = true;
|
|
2606
|
+
this.helpText = undefined;
|
|
2607
|
+
this.valid = undefined;
|
|
2608
|
+
this.invalid = undefined;
|
|
2609
|
+
this.classList = new ClassList(['mg-input--text']);
|
|
2610
|
+
this.errorMessage = undefined;
|
|
2687
2611
|
}
|
|
2688
2612
|
handleValue(newValue) {
|
|
2689
2613
|
this.valueChange.emit(newValue);
|
|
@@ -2773,7 +2697,7 @@ const MgInputText = class {
|
|
|
2773
2697
|
};
|
|
2774
2698
|
MgInputText.style = mgInputTextCss;
|
|
2775
2699
|
|
|
2776
|
-
const mgInputTextareaCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem
|
|
2700
|
+
const mgInputTextareaCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input .mg-input__box{display:block;height:auto;resize:none}.mg-input .mg-input__box.mg-input__box--resizable{resize:both}.mg-input .mg-input__box.mg-input__box--resizable-horizontal{resize:horizontal}.mg-input .mg-input__box.mg-input__box--resizable-vertical{resize:vertical}.mg-input__with-character-left{width:100%}.mg-input__with-character-left mg-character-left{display:block;visibility:hidden;margin-top:0.2rem;text-align:end}.mg-input.is-focused .mg-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
|
|
2777
2701
|
|
|
2778
2702
|
const MgInputTextarea = class {
|
|
2779
2703
|
constructor(hostRef) {
|
|
@@ -2788,51 +2712,6 @@ const MgInputTextarea = class {
|
|
|
2788
2712
|
this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
|
|
2789
2713
|
// hasDisplayedError (triggered by blur event)
|
|
2790
2714
|
this.hasDisplayedError = false;
|
|
2791
|
-
/**
|
|
2792
|
-
* Input name
|
|
2793
|
-
* If not set the value equals the identifier
|
|
2794
|
-
*/
|
|
2795
|
-
this.name = this.identifier;
|
|
2796
|
-
/**
|
|
2797
|
-
* Define if label is visible
|
|
2798
|
-
*/
|
|
2799
|
-
this.labelHide = false;
|
|
2800
|
-
/**
|
|
2801
|
-
* Input max length
|
|
2802
|
-
*/
|
|
2803
|
-
this.maxlength = 4000;
|
|
2804
|
-
/**
|
|
2805
|
-
* Define if input is required
|
|
2806
|
-
*/
|
|
2807
|
-
this.required = false;
|
|
2808
|
-
/**
|
|
2809
|
-
* Define if input is readonly
|
|
2810
|
-
*/
|
|
2811
|
-
this.readonly = false;
|
|
2812
|
-
/**
|
|
2813
|
-
* Define if input is disabled
|
|
2814
|
-
*/
|
|
2815
|
-
this.disabled = false;
|
|
2816
|
-
/**
|
|
2817
|
-
* Define input width
|
|
2818
|
-
*/
|
|
2819
|
-
this.mgWidth = 'full';
|
|
2820
|
-
/**
|
|
2821
|
-
* Define the number of visible text lines for the control
|
|
2822
|
-
*/
|
|
2823
|
-
this.rows = 3;
|
|
2824
|
-
/**
|
|
2825
|
-
* Define if component should display character left
|
|
2826
|
-
*/
|
|
2827
|
-
this.displayCharacterLeft = true;
|
|
2828
|
-
/**
|
|
2829
|
-
* Define if input is resizable
|
|
2830
|
-
*/
|
|
2831
|
-
this.resizable = 'none';
|
|
2832
|
-
/**
|
|
2833
|
-
* Component classes
|
|
2834
|
-
*/
|
|
2835
|
-
this.classList = new ClassList(['mg-input--textarea']);
|
|
2836
2715
|
/**
|
|
2837
2716
|
* Handle input event
|
|
2838
2717
|
*/
|
|
@@ -2903,6 +2782,29 @@ const MgInputTextarea = class {
|
|
|
2903
2782
|
throw new Error('<mg-input-textarea> prop "pattern" must be paired with the prop "patternErrorMessage"');
|
|
2904
2783
|
}
|
|
2905
2784
|
};
|
|
2785
|
+
this.value = undefined;
|
|
2786
|
+
this.identifier = undefined;
|
|
2787
|
+
this.name = this.identifier;
|
|
2788
|
+
this.label = undefined;
|
|
2789
|
+
this.labelOnTop = undefined;
|
|
2790
|
+
this.labelHide = false;
|
|
2791
|
+
this.placeholder = undefined;
|
|
2792
|
+
this.maxlength = 4000;
|
|
2793
|
+
this.required = false;
|
|
2794
|
+
this.readonly = false;
|
|
2795
|
+
this.disabled = false;
|
|
2796
|
+
this.mgWidth = 'full';
|
|
2797
|
+
this.pattern = undefined;
|
|
2798
|
+
this.patternErrorMessage = undefined;
|
|
2799
|
+
this.rows = 3;
|
|
2800
|
+
this.tooltip = undefined;
|
|
2801
|
+
this.displayCharacterLeft = true;
|
|
2802
|
+
this.helpText = undefined;
|
|
2803
|
+
this.valid = undefined;
|
|
2804
|
+
this.invalid = undefined;
|
|
2805
|
+
this.resizable = 'none';
|
|
2806
|
+
this.classList = new ClassList(['mg-input--textarea']);
|
|
2807
|
+
this.errorMessage = undefined;
|
|
2906
2808
|
}
|
|
2907
2809
|
handleValue(newValue) {
|
|
2908
2810
|
this.checkValidity();
|
|
@@ -2990,17 +2892,13 @@ const mgInputTitleCss = ".is-asterisk.sc-mg-input-title{color:hsl(var(--color-da
|
|
|
2990
2892
|
const MgInputTitle = class {
|
|
2991
2893
|
constructor(hostRef) {
|
|
2992
2894
|
index.registerInstance(this, hostRef);
|
|
2993
|
-
/**
|
|
2994
|
-
* Switch from label to fieldset sementic
|
|
2995
|
-
*/
|
|
2996
|
-
this.isLegend = false;
|
|
2997
|
-
/**
|
|
2998
|
-
* Component parent tagname
|
|
2999
|
-
*/
|
|
3000
|
-
this.tagName = 'label';
|
|
3001
2895
|
this.getTagName = () => {
|
|
3002
2896
|
this.tagName = this.isLegend ? 'legend' : 'label';
|
|
3003
2897
|
};
|
|
2898
|
+
this.identifier = undefined;
|
|
2899
|
+
this.required = undefined;
|
|
2900
|
+
this.isLegend = false;
|
|
2901
|
+
this.tagName = 'label';
|
|
3004
2902
|
}
|
|
3005
2903
|
validateIdentifier(newValue) {
|
|
3006
2904
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -3058,39 +2956,6 @@ const MgInputToggle = class {
|
|
|
3058
2956
|
this.classIsActive = 'mg-input--toggle-is-active';
|
|
3059
2957
|
this.classOnOff = 'mg-input--toggle-on-off';
|
|
3060
2958
|
this.classIcon = 'mg-input--toggle-icon';
|
|
3061
|
-
/**
|
|
3062
|
-
* Input name
|
|
3063
|
-
* If not set the value equals the identifier
|
|
3064
|
-
*/
|
|
3065
|
-
this.name = this.identifier;
|
|
3066
|
-
/**
|
|
3067
|
-
* Define if label is visible
|
|
3068
|
-
*/
|
|
3069
|
-
this.labelHide = false;
|
|
3070
|
-
/**
|
|
3071
|
-
* Define if toggle have on/off style
|
|
3072
|
-
*/
|
|
3073
|
-
this.isOnOff = false;
|
|
3074
|
-
/**
|
|
3075
|
-
* Define if toggle display icon
|
|
3076
|
-
*/
|
|
3077
|
-
this.isIcon = false;
|
|
3078
|
-
/**
|
|
3079
|
-
* Define if input is readonly
|
|
3080
|
-
*/
|
|
3081
|
-
this.readonly = false;
|
|
3082
|
-
/**
|
|
3083
|
-
* Define if input is disabled
|
|
3084
|
-
*/
|
|
3085
|
-
this.disabled = false;
|
|
3086
|
-
/**
|
|
3087
|
-
* Component classes
|
|
3088
|
-
*/
|
|
3089
|
-
this.classList = new ClassList(['mg-input--toggle']);
|
|
3090
|
-
/**
|
|
3091
|
-
* Checked internal value
|
|
3092
|
-
*/
|
|
3093
|
-
this.checked = false;
|
|
3094
2959
|
/**
|
|
3095
2960
|
* Change checked value
|
|
3096
2961
|
*
|
|
@@ -3115,6 +2980,22 @@ const MgInputToggle = class {
|
|
|
3115
2980
|
slots.forEach(slot => slot.setAttribute('title', slot.textContent));
|
|
3116
2981
|
}
|
|
3117
2982
|
};
|
|
2983
|
+
this.value = undefined;
|
|
2984
|
+
this.items = undefined;
|
|
2985
|
+
this.identifier = undefined;
|
|
2986
|
+
this.name = this.identifier;
|
|
2987
|
+
this.label = undefined;
|
|
2988
|
+
this.labelOnTop = undefined;
|
|
2989
|
+
this.labelHide = false;
|
|
2990
|
+
this.isOnOff = false;
|
|
2991
|
+
this.isIcon = false;
|
|
2992
|
+
this.readonly = false;
|
|
2993
|
+
this.disabled = false;
|
|
2994
|
+
this.tooltip = undefined;
|
|
2995
|
+
this.helpText = undefined;
|
|
2996
|
+
this.classList = new ClassList(['mg-input--toggle']);
|
|
2997
|
+
this.options = undefined;
|
|
2998
|
+
this.checked = false;
|
|
3118
2999
|
}
|
|
3119
3000
|
handleValue(newValue) {
|
|
3120
3001
|
// Swich to the right option
|
|
@@ -3235,6 +3116,194 @@ const MgInputToggle = class {
|
|
|
3235
3116
|
};
|
|
3236
3117
|
MgInputToggle.style = mgInputToggleCss;
|
|
3237
3118
|
|
|
3119
|
+
/**
|
|
3120
|
+
* Available menu-item positions
|
|
3121
|
+
*/
|
|
3122
|
+
var ElementPosition;
|
|
3123
|
+
(function (ElementPosition) {
|
|
3124
|
+
ElementPosition["FIRST"] = "first";
|
|
3125
|
+
ElementPosition["LAST"] = "last";
|
|
3126
|
+
})(ElementPosition || (ElementPosition = {}));
|
|
3127
|
+
/**
|
|
3128
|
+
* Available menu item status
|
|
3129
|
+
*/
|
|
3130
|
+
var Status$1;
|
|
3131
|
+
(function (Status) {
|
|
3132
|
+
Status["VISIBLE"] = "visible";
|
|
3133
|
+
Status["HIDDEN"] = "hidden";
|
|
3134
|
+
Status["DISABLED"] = "disabled";
|
|
3135
|
+
Status["ACTIVE"] = "active";
|
|
3136
|
+
})(Status$1 || (Status$1 = {}));
|
|
3137
|
+
|
|
3138
|
+
/**
|
|
3139
|
+
* MgMenuItem type guard
|
|
3140
|
+
*
|
|
3141
|
+
* @param {HTMLElement} element element to control type
|
|
3142
|
+
* @returns {boolean} truthy if element is mg-menu-item
|
|
3143
|
+
*/
|
|
3144
|
+
const isMgMenuItem = (element) => element.nodeName === 'MG-MENU-ITEM';
|
|
3145
|
+
var OverflowBehaviorElements;
|
|
3146
|
+
(function (OverflowBehaviorElements) {
|
|
3147
|
+
OverflowBehaviorElements["MORE"] = "data-overflow-more";
|
|
3148
|
+
OverflowBehaviorElements["BASE_INDEX"] = "data-overflow-base-index";
|
|
3149
|
+
OverflowBehaviorElements["PROXY_INDEX"] = "data-overflow-proxy-index";
|
|
3150
|
+
})(OverflowBehaviorElements || (OverflowBehaviorElements = {}));
|
|
3151
|
+
class OverflowBehavior {
|
|
3152
|
+
constructor(element, render) {
|
|
3153
|
+
this.element = element;
|
|
3154
|
+
this.render = render;
|
|
3155
|
+
/**********
|
|
3156
|
+
* Public *
|
|
3157
|
+
**********/
|
|
3158
|
+
/**
|
|
3159
|
+
* Disconnect ResizeObserver
|
|
3160
|
+
*
|
|
3161
|
+
* @returns {void}
|
|
3162
|
+
*/
|
|
3163
|
+
this.disconnect = () => {
|
|
3164
|
+
this.resizeObserver.disconnect();
|
|
3165
|
+
};
|
|
3166
|
+
/**
|
|
3167
|
+
* Update more element status if active child
|
|
3168
|
+
*
|
|
3169
|
+
* @returns {void}
|
|
3170
|
+
*/
|
|
3171
|
+
this.updateActiveStatus = () => {
|
|
3172
|
+
const hasActiveChild = Array.from(this.moreELement.querySelector('mg-menu').children).some(element => element.nodeName === 'MG-MENU-ITEM' && element.getAttribute('status') === Status$1.ACTIVE && element.getAttribute('hidden') === null);
|
|
3173
|
+
this.moreELement.setAttribute('status', hasActiveChild ? Status$1.ACTIVE : Status$1.VISIBLE);
|
|
3174
|
+
};
|
|
3175
|
+
/************
|
|
3176
|
+
* Internal *
|
|
3177
|
+
************/
|
|
3178
|
+
/**
|
|
3179
|
+
* run overflow behavior
|
|
3180
|
+
*
|
|
3181
|
+
* @param {number} width width of the container
|
|
3182
|
+
* @returns {void}
|
|
3183
|
+
*/
|
|
3184
|
+
this.run = (width) => {
|
|
3185
|
+
if (this.moreELement === undefined) {
|
|
3186
|
+
// set moreElement
|
|
3187
|
+
this.moreELement = this.render();
|
|
3188
|
+
this.moreELement.setAttribute(OverflowBehaviorElements.MORE, '');
|
|
3189
|
+
// set children
|
|
3190
|
+
this.children = Array.from(this.element.children);
|
|
3191
|
+
let moreELementChildren;
|
|
3192
|
+
const allowedElements = ['MG-MENU-ITEM', 'MG-BUTTON'];
|
|
3193
|
+
if (isMgMenuItem(this.moreELement)) {
|
|
3194
|
+
moreELementChildren = Array.from(this.moreELement.querySelector('mg-menu').children).filter(element => allowedElements.includes(element.nodeName));
|
|
3195
|
+
}
|
|
3196
|
+
this.children.forEach((child, index) => {
|
|
3197
|
+
child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);
|
|
3198
|
+
if (child.getAttribute(OverflowBehaviorElements.MORE) === null) {
|
|
3199
|
+
// set moreElement children
|
|
3200
|
+
moreELementChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);
|
|
3201
|
+
}
|
|
3202
|
+
});
|
|
3203
|
+
}
|
|
3204
|
+
this.updateDisplayedItems(width);
|
|
3205
|
+
if (isMgMenuItem(this.moreELement))
|
|
3206
|
+
this.updateActiveStatus();
|
|
3207
|
+
};
|
|
3208
|
+
/**
|
|
3209
|
+
* Update displayed items in container from a given available space
|
|
3210
|
+
*
|
|
3211
|
+
* @param {number} availableWidth available width in container to display child items
|
|
3212
|
+
* @returns {void}
|
|
3213
|
+
*/
|
|
3214
|
+
this.updateDisplayedItems = (availableWidth) => {
|
|
3215
|
+
this.restoreItems();
|
|
3216
|
+
this.children.reduce((acc, curr) => {
|
|
3217
|
+
acc.accWidth += curr.offsetWidth;
|
|
3218
|
+
const isPreviousItemHidden = acc.previousItem !== null && acc.previousItem.getAttribute('hidden') !== null;
|
|
3219
|
+
// if previous item is hidden AND is NOT more element we hidde current
|
|
3220
|
+
// OR if item has an overflow we hidde current
|
|
3221
|
+
// OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item
|
|
3222
|
+
// ELSE current is a display item
|
|
3223
|
+
if ((isPreviousItemHidden && !this.isMoreElement(curr)) ||
|
|
3224
|
+
this.isOverflowElement(acc.accWidth, curr, availableWidth) ||
|
|
3225
|
+
(this.isMoreElement(curr) && !isPreviousItemHidden)) {
|
|
3226
|
+
this.toggleItem(curr, true);
|
|
3227
|
+
}
|
|
3228
|
+
else
|
|
3229
|
+
this.toggleItem(curr, false);
|
|
3230
|
+
// update previous item with current item
|
|
3231
|
+
acc.previousItem = curr;
|
|
3232
|
+
return acc;
|
|
3233
|
+
}, { accWidth: 0, previousItem: null });
|
|
3234
|
+
};
|
|
3235
|
+
/**
|
|
3236
|
+
* Utility method to know if item overflow partialy or totaly in the container
|
|
3237
|
+
*
|
|
3238
|
+
* @param {number} cumulateWidth previous sibling elements cumulate width + item width
|
|
3239
|
+
* @param {HTMLElement} item item HTML element
|
|
3240
|
+
* @param {number} availableWidth container available width
|
|
3241
|
+
* @returns {boolean} truthy if element is overflow
|
|
3242
|
+
*/
|
|
3243
|
+
this.isOverflowElement = (cumulateWidth, item, availableWidth) => {
|
|
3244
|
+
if (item.previousElementSibling === null || this.isMoreElement(item))
|
|
3245
|
+
return false;
|
|
3246
|
+
else if (!this.isMoreElement(item.nextElementSibling))
|
|
3247
|
+
return cumulateWidth + this.moreELement.offsetWidth > availableWidth;
|
|
3248
|
+
else
|
|
3249
|
+
return cumulateWidth > availableWidth;
|
|
3250
|
+
};
|
|
3251
|
+
/**
|
|
3252
|
+
* Utility method to know if a given element is the 'MORE' element
|
|
3253
|
+
*
|
|
3254
|
+
* @param {Element} element element to match with 'MORE' element
|
|
3255
|
+
* @returns {boolean} truthy if element is the 'MORE' element
|
|
3256
|
+
*/
|
|
3257
|
+
this.isMoreElement = (element) => element.getAttribute(OverflowBehaviorElements.MORE) !== null;
|
|
3258
|
+
/**
|
|
3259
|
+
* Toggle display item element
|
|
3260
|
+
*
|
|
3261
|
+
* @param {HTMLElement} item item to control
|
|
3262
|
+
* @param {boolean} isHidden is item hidden
|
|
3263
|
+
* @returns {void}
|
|
3264
|
+
*/
|
|
3265
|
+
this.toggleItem = (item, isHidden) => {
|
|
3266
|
+
const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));
|
|
3267
|
+
if (this.isMoreElement(item))
|
|
3268
|
+
this.toggleElement(this.moreELement, isHidden);
|
|
3269
|
+
else if (mgActionMenuindex >= 0) {
|
|
3270
|
+
this.toggleElement(item, isHidden);
|
|
3271
|
+
this.toggleElement(this.moreELement.querySelector(`[${OverflowBehaviorElements.PROXY_INDEX}="${mgActionMenuindex}"]`), !isHidden);
|
|
3272
|
+
}
|
|
3273
|
+
};
|
|
3274
|
+
/**
|
|
3275
|
+
* Toggle element's hidde attribute
|
|
3276
|
+
*
|
|
3277
|
+
* @param {Element} element element to toggle
|
|
3278
|
+
* @param {boolean} isHidden element is hidden
|
|
3279
|
+
* @returns {void}
|
|
3280
|
+
*/
|
|
3281
|
+
this.toggleElement = (element, isHidden) => {
|
|
3282
|
+
if (isHidden)
|
|
3283
|
+
element.setAttribute('hidden', '');
|
|
3284
|
+
else
|
|
3285
|
+
element.removeAttribute('hidden');
|
|
3286
|
+
};
|
|
3287
|
+
/**
|
|
3288
|
+
* Remove hidden attributes on all items
|
|
3289
|
+
*
|
|
3290
|
+
* @returns {void}
|
|
3291
|
+
*/
|
|
3292
|
+
this.restoreItems = () => {
|
|
3293
|
+
this.children.forEach(item => item.removeAttribute('hidden'));
|
|
3294
|
+
};
|
|
3295
|
+
if (this.resizeObserver === undefined) {
|
|
3296
|
+
// add resize observer
|
|
3297
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
3298
|
+
entries.forEach(entry => {
|
|
3299
|
+
this.run(entry.contentRect.width);
|
|
3300
|
+
});
|
|
3301
|
+
});
|
|
3302
|
+
this.resizeObserver.observe(this.element);
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
|
|
3238
3307
|
/**
|
|
3239
3308
|
* Menu direction type
|
|
3240
3309
|
*/
|
|
@@ -3243,8 +3312,25 @@ var Direction;
|
|
|
3243
3312
|
Direction["VERTICAL"] = "vertical";
|
|
3244
3313
|
Direction["HORIZONTAL"] = "horizontal";
|
|
3245
3314
|
})(Direction || (Direction = {}));
|
|
3315
|
+
/**
|
|
3316
|
+
* More item type guard
|
|
3317
|
+
*
|
|
3318
|
+
* @param {unknown} element element to control
|
|
3319
|
+
* @returns {boolean} truthy if element is more-item
|
|
3320
|
+
*/
|
|
3321
|
+
const isMoreItem = (element) => {
|
|
3322
|
+
var _a, _b, _c;
|
|
3323
|
+
const item = element;
|
|
3324
|
+
return (item === undefined ||
|
|
3325
|
+
(typeof item === 'object' &&
|
|
3326
|
+
(typeof item.size === 'string' || typeof ((_a = item.mgIcon) === null || _a === void 0 ? void 0 : _a.icon) === 'string' || typeof ((_b = item.slotLabel) === null || _b === void 0 ? void 0 : _b.label) === 'string' || typeof ((_c = item.slotLabel) === null || _c === void 0 ? void 0 : _c.display) === 'boolean')));
|
|
3327
|
+
};
|
|
3328
|
+
/**
|
|
3329
|
+
* List of all possibles sizes
|
|
3330
|
+
*/
|
|
3331
|
+
const sizes$1 = ['regular', 'medium', 'large'];
|
|
3246
3332
|
|
|
3247
|
-
const mgMenuCss = ":host{display:flex;background-color:hsl(var(--mg-menu-background-color-hsl, var(--color-light)))}:host([direction=vertical]){flex-direction:column;height:100%;overflow-y:auto}";
|
|
3333
|
+
const mgMenuCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}:host{display:flex;background-color:hsl(var(--mg-menu-background-color-hsl, var(--color-light)))}:host([direction=vertical]){flex-direction:column;height:100%;overflow-y:auto}";
|
|
3248
3334
|
|
|
3249
3335
|
const MgMenu = class {
|
|
3250
3336
|
constructor(hostRef) {
|
|
@@ -3253,15 +3339,12 @@ const MgMenu = class {
|
|
|
3253
3339
|
* Internal *
|
|
3254
3340
|
************/
|
|
3255
3341
|
this.name = 'mg-menu';
|
|
3342
|
+
this.menuItems = [];
|
|
3256
3343
|
this.focusedMenuItem = 0;
|
|
3257
|
-
/**
|
|
3258
|
-
* Component display direction. Default: "horizontal"
|
|
3259
|
-
*/
|
|
3260
|
-
this.direction = Direction.HORIZONTAL;
|
|
3261
3344
|
/**
|
|
3262
3345
|
* Close matching menu-item
|
|
3263
3346
|
*
|
|
3264
|
-
* @param {
|
|
3347
|
+
* @param {HTMLElement} item menu-item to close
|
|
3265
3348
|
* @param {boolean} condition addionnal condition
|
|
3266
3349
|
* @returns {void}
|
|
3267
3350
|
*/
|
|
@@ -3270,18 +3353,19 @@ const MgMenu = class {
|
|
|
3270
3353
|
item.expanded = false;
|
|
3271
3354
|
}
|
|
3272
3355
|
};
|
|
3356
|
+
/*************
|
|
3357
|
+
* Methods *
|
|
3358
|
+
*************/
|
|
3273
3359
|
/**
|
|
3274
3360
|
* Store menu-items on component init and add listeners
|
|
3361
|
+
*
|
|
3362
|
+
* @returns {void}
|
|
3275
3363
|
*/
|
|
3276
|
-
this.
|
|
3277
|
-
// store all menu-items
|
|
3278
|
-
this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM');
|
|
3364
|
+
this.initMenuItemsListeners = () => {
|
|
3279
3365
|
// add listeners on menu item and edit index
|
|
3280
3366
|
this.menuItems.forEach((item, menuItemIndex) => {
|
|
3281
3367
|
['click', 'focus'].forEach(trigger => {
|
|
3282
|
-
(item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, (
|
|
3283
|
-
event.preventDefault();
|
|
3284
|
-
event.stopPropagation();
|
|
3368
|
+
(item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, () => {
|
|
3285
3369
|
this.focusedMenuItem = menuItemIndex;
|
|
3286
3370
|
// reset expanded on previous active menu item
|
|
3287
3371
|
this.menuItems.forEach((item, index) => {
|
|
@@ -3291,6 +3375,47 @@ const MgMenu = class {
|
|
|
3291
3375
|
});
|
|
3292
3376
|
});
|
|
3293
3377
|
};
|
|
3378
|
+
/**
|
|
3379
|
+
* render mg-menu-more
|
|
3380
|
+
*
|
|
3381
|
+
* @returns {HTMLElement} formated mg-menu-item element
|
|
3382
|
+
*/
|
|
3383
|
+
this.renderMgMenuMore = () => {
|
|
3384
|
+
const moreElement = this.element.shadowRoot.querySelector(`[${OverflowBehaviorElements.MORE}]`);
|
|
3385
|
+
this.menuItems.forEach((child) => {
|
|
3386
|
+
const proxy = child.cloneNode(true);
|
|
3387
|
+
moreElement.querySelector('mg-menu').appendChild(proxy);
|
|
3388
|
+
});
|
|
3389
|
+
const allMenuItem = Array.from(this.element.querySelectorAll('mg-menu-item:not([data-overflow-more])'));
|
|
3390
|
+
Array.from(moreElement.querySelectorAll('mg-menu-item:not([data-overflow-more])')).forEach((proxy, index) => {
|
|
3391
|
+
// manage click on proxy to mirror it on initial element
|
|
3392
|
+
proxy.addEventListener('click', () => {
|
|
3393
|
+
(allMenuItem[index].shadowRoot.querySelector('a') || allMenuItem[index].shadowRoot.querySelector('button')).dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
3394
|
+
});
|
|
3395
|
+
// manage status change miror in proxy
|
|
3396
|
+
allMenuItem[index].addEventListener('status-change', (event) => {
|
|
3397
|
+
proxy.setAttribute('status', event.detail);
|
|
3398
|
+
this.overflowBehavior.updateActiveStatus();
|
|
3399
|
+
});
|
|
3400
|
+
});
|
|
3401
|
+
this.element.appendChild(moreElement);
|
|
3402
|
+
return this.element.querySelector(`[${OverflowBehaviorElements.MORE}]`);
|
|
3403
|
+
};
|
|
3404
|
+
/**
|
|
3405
|
+
* Render mg-menu-item more element for overflow behavior
|
|
3406
|
+
*
|
|
3407
|
+
* @returns {HTMLElement} rendered mg-menu-item more element
|
|
3408
|
+
*/
|
|
3409
|
+
this.renderMgMenuItemMore = () => {
|
|
3410
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3411
|
+
return (index.h("mg-menu-item", { "data-overflow-more": true }, index.h("mg-icon", { icon: ((_b = (_a = this.moreitem) === null || _a === void 0 ? void 0 : _a.mgIcon) === null || _b === void 0 ? void 0 : _b.icon) || 'ellipsis-vertical', slot: "image" }), index.h("span", { class: { 'sr-only': !((_d = (_c = this.moreitem) === null || _c === void 0 ? void 0 : _c.slotLabel) === null || _d === void 0 ? void 0 : _d.display) }, slot: "label" }, ((_f = (_e = this.moreitem) === null || _e === void 0 ? void 0 : _e.slotLabel) === null || _f === void 0 ? void 0 : _f.label) || this.messages.moreLabel), index.h("mg-menu", { direction: Direction.VERTICAL, label: this.messages.moreLabel, size: (_g = this.moreitem) === null || _g === void 0 ? void 0 : _g.size })));
|
|
3412
|
+
};
|
|
3413
|
+
this.label = undefined;
|
|
3414
|
+
this.direction = Direction.HORIZONTAL;
|
|
3415
|
+
this.moreitem = undefined;
|
|
3416
|
+
this.size = 'regular';
|
|
3417
|
+
this.isChildMenu = undefined;
|
|
3418
|
+
this.hasOverflow = false;
|
|
3294
3419
|
}
|
|
3295
3420
|
validateLabel(newValue) {
|
|
3296
3421
|
if (newValue === undefined) {
|
|
@@ -3302,6 +3427,19 @@ const MgMenu = class {
|
|
|
3302
3427
|
throw new Error(`<${this.name}> prop "direction" must be one of : ${Direction.HORIZONTAL}, ${Direction.VERTICAL}.`);
|
|
3303
3428
|
}
|
|
3304
3429
|
}
|
|
3430
|
+
validateMoreItem(newValue) {
|
|
3431
|
+
if (newValue !== undefined && this.direction !== Direction.HORIZONTAL) {
|
|
3432
|
+
throw new Error(`<${this.name}> prop "moreitem" must be paired with direction ${Direction.HORIZONTAL}.`);
|
|
3433
|
+
}
|
|
3434
|
+
else if (newValue !== undefined && !isMoreItem(newValue)) {
|
|
3435
|
+
throw new Error(`<${this.name}> prop "moreitem" must match MoreItemType.`);
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
validateSize(newValue) {
|
|
3439
|
+
if (!sizes$1.includes(newValue)) {
|
|
3440
|
+
throw new Error(`<${this.name}> prop "size" must be one of : ${sizes$1.join(', ')}.`);
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3305
3443
|
/*************
|
|
3306
3444
|
* Lifecycle *
|
|
3307
3445
|
*************/
|
|
@@ -3311,8 +3449,12 @@ const MgMenu = class {
|
|
|
3311
3449
|
* @returns {void}
|
|
3312
3450
|
*/
|
|
3313
3451
|
componentWillLoad() {
|
|
3452
|
+
this.messages = initLocales(this.element).messages.plusMenu;
|
|
3453
|
+
// validation
|
|
3314
3454
|
this.validateDirection(this.direction);
|
|
3315
3455
|
this.validateLabel(this.label);
|
|
3456
|
+
this.validateMoreItem(this.moreitem);
|
|
3457
|
+
this.validateSize(this.size);
|
|
3316
3458
|
}
|
|
3317
3459
|
/**
|
|
3318
3460
|
* Check if component slots configuration
|
|
@@ -3324,95 +3466,64 @@ const MgMenu = class {
|
|
|
3324
3466
|
// return a promise to process action only in the FIRST render().
|
|
3325
3467
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
3326
3468
|
return setTimeout(() => {
|
|
3327
|
-
|
|
3469
|
+
// store all menu-items
|
|
3470
|
+
this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM');
|
|
3328
3471
|
this.isChildMenu = this.element.closest('mg-menu-item') !== null;
|
|
3329
|
-
|
|
3330
|
-
if (
|
|
3331
|
-
|
|
3332
|
-
if (event.target.closest('mg-menu') === null) {
|
|
3333
|
-
this.menuItems.forEach(item => {
|
|
3334
|
-
this.closeMenuItem(item, this.direction === Direction.HORIZONTAL);
|
|
3335
|
-
});
|
|
3336
|
-
}
|
|
3337
|
-
});
|
|
3338
|
-
}
|
|
3472
|
+
this.hasOverflow = this.direction === Direction.HORIZONTAL && !this.isChildMenu;
|
|
3473
|
+
if (this.hasOverflow && isMoreItem(this.moreitem))
|
|
3474
|
+
this.overflowBehavior = new OverflowBehavior(this.element, this.renderMgMenuMore);
|
|
3339
3475
|
}, 0);
|
|
3340
3476
|
}
|
|
3477
|
+
/**
|
|
3478
|
+
* Check add listeners to childs
|
|
3479
|
+
*
|
|
3480
|
+
* @returns {void}
|
|
3481
|
+
*/
|
|
3482
|
+
componentDidRender() {
|
|
3483
|
+
// add menu items listeners
|
|
3484
|
+
this.initMenuItemsListeners();
|
|
3485
|
+
}
|
|
3486
|
+
/**
|
|
3487
|
+
* Disconnect overflow ResizeObserver
|
|
3488
|
+
*
|
|
3489
|
+
* @returns {void} run overflow resize obeserver disconnexion
|
|
3490
|
+
*/
|
|
3491
|
+
disconnectedCallback() {
|
|
3492
|
+
if (this.hasOverflow)
|
|
3493
|
+
this.overflowBehavior.disconnect();
|
|
3494
|
+
}
|
|
3341
3495
|
/**
|
|
3342
3496
|
* Render
|
|
3343
3497
|
*
|
|
3344
3498
|
* @returns {HTMLElement} HTML Element
|
|
3345
3499
|
*/
|
|
3346
3500
|
render() {
|
|
3347
|
-
return (index.h(index.Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, index.h("slot", null)));
|
|
3501
|
+
return (index.h(index.Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, index.h("slot", null), this.hasOverflow && isMoreItem(this.moreitem) && this.renderMgMenuItemMore()));
|
|
3348
3502
|
}
|
|
3349
3503
|
get element() { return index.getElement(this); }
|
|
3350
3504
|
static get watchers() { return {
|
|
3351
3505
|
"label": ["validateLabel"],
|
|
3352
|
-
"direction": ["validateDirection"]
|
|
3506
|
+
"direction": ["validateDirection"],
|
|
3507
|
+
"moreitem": ["validateMoreItem"],
|
|
3508
|
+
"size": ["validateSize"]
|
|
3353
3509
|
}; }
|
|
3354
3510
|
};
|
|
3355
3511
|
MgMenu.style = mgMenuCss;
|
|
3356
3512
|
|
|
3357
|
-
/**
|
|
3358
|
-
* Available menu-item positions
|
|
3359
|
-
*/
|
|
3360
|
-
var ElementPosition;
|
|
3361
|
-
(function (ElementPosition) {
|
|
3362
|
-
ElementPosition["FIRST"] = "first";
|
|
3363
|
-
ElementPosition["LAST"] = "last";
|
|
3364
|
-
})(ElementPosition || (ElementPosition = {}));
|
|
3365
|
-
/**
|
|
3366
|
-
* Available menu item status
|
|
3367
|
-
*/
|
|
3368
|
-
var Status$1;
|
|
3369
|
-
(function (Status) {
|
|
3370
|
-
Status["VISIBLE"] = "visible";
|
|
3371
|
-
Status["HIDDEN"] = "hidden";
|
|
3372
|
-
Status["DISABLED"] = "disabled";
|
|
3373
|
-
Status["ACTIVE"] = "active";
|
|
3374
|
-
})(Status$1 || (Status$1 = {}));
|
|
3375
|
-
/**
|
|
3376
|
-
* List of all possibles sizes
|
|
3377
|
-
*/
|
|
3378
|
-
const sizes$1 = ['regular', 'medium', 'large'];
|
|
3379
|
-
|
|
3380
|
-
const mgMenuItemCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding:1rem 2rem}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button,.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button ::slotted([slot=label]),.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button ::slotted([slot=metadata]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular ::slotted([slot=label]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular ::slotted([slot=metadata]){font-size:1.3rem}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular.mg-menu-item__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular.mg-menu-item__navigation-button--vertical{padding-left:calc(2rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding:1.5rem 3rem}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button,.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button ::slotted([slot=label]),.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button ::slotted([slot=metadata]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium ::slotted([slot=label]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium ::slotted([slot=metadata]){font-size:1.5rem}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium.mg-menu-item__navigation-button--horizontal{padding-bottom:calc(1.5rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium.mg-menu-item__navigation-button--vertical{padding-left:calc(3rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding:2.5rem 4rem}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button,.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button ::slotted([slot=label]),.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button ::slotted([slot=metadata]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large ::slotted([slot=label]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large ::slotted([slot=metadata]){font-size:1.5rem}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large.mg-menu-item__navigation-button--horizontal{padding-bottom:calc(2.5rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large.mg-menu-item__navigation-button--vertical{padding-left:calc(4rem - 0.3rem)}.mg-menu-item__navigation-button{display:flex;align-items:center;column-gap:1rem;background-color:unset;border:none;font-family:var(--font-family);color:hsl(var(--mg-menu-item-color-hsl, var(--color-dark)));line-height:var(--line-height);text-decoration:none;cursor:pointer}.mg-menu-item__navigation-button:disabled,.mg-menu-item__navigation-button--disabled{cursor:default;opacity:30%}.mg-menu-item__navigation-button:focus-visible{z-index:10}.mg-menu-item__navigation-button:hover:not(.mg-menu-item__navigation-button--disabled),.mg-menu-item__navigation-button:focus:not(.mg-menu-item__navigation-button--disabled){background-color:hsla(var(--mg-menu-item-focused-background-color-hsl), 10%)}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--active{color:hsl(var(--mg-menu-item-color-active-hsl));font-weight:700}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--active.mg-menu-item__navigation-button--horizontal{border-bottom-color:hsl(var(--mg-menu-item-border-color-active-hsl))}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--active.mg-menu-item__navigation-button--vertical{border-left-color:hsl(var(--mg-menu-item-border-color-active-hsl))}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--hidden{display:none}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal{border-bottom:0.3rem solid transparent}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical{border-left:0.3rem solid transparent}:host([data-style-direction-vertical][data-level=\"1\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(1 * 2rem - 0.3rem)}:host([data-level=\"1\"]) .mg-menu-item__collapse-container{z-index:calc(1 * 10)}:host([data-style-direction-vertical][data-level=\"2\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(2 * 2rem - 0.3rem)}:host([data-level=\"2\"]) .mg-menu-item__collapse-container{z-index:calc(2 * 10)}:host([data-style-direction-vertical][data-level=\"3\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(3 * 2rem - 0.3rem)}:host([data-level=\"3\"]) .mg-menu-item__collapse-container{z-index:calc(3 * 10)}:host([data-style-direction-vertical][data-level=\"4\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(4 * 2rem - 0.3rem)}:host([data-level=\"4\"]) .mg-menu-item__collapse-container{z-index:calc(4 * 10)}:host([data-style-direction-vertical][data-level=\"5\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(5 * 2rem - 0.3rem)}:host([data-level=\"5\"]) .mg-menu-item__collapse-container{z-index:calc(5 * 10)}:host([data-style-direction-vertical][data-level=\"6\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(6 * 2rem - 0.3rem)}:host([data-level=\"6\"]) .mg-menu-item__collapse-container{z-index:calc(6 * 10)}:host([data-style-direction-vertical][data-level=\"1\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(1 * 3rem - 0.3rem)}:host([data-level=\"1\"]) .mg-menu-item__collapse-container{z-index:calc(1 * 10)}:host([data-style-direction-vertical][data-level=\"2\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(2 * 3rem - 0.3rem)}:host([data-level=\"2\"]) .mg-menu-item__collapse-container{z-index:calc(2 * 10)}:host([data-style-direction-vertical][data-level=\"3\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(3 * 3rem - 0.3rem)}:host([data-level=\"3\"]) .mg-menu-item__collapse-container{z-index:calc(3 * 10)}:host([data-style-direction-vertical][data-level=\"4\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(4 * 3rem - 0.3rem)}:host([data-level=\"4\"]) .mg-menu-item__collapse-container{z-index:calc(4 * 10)}:host([data-style-direction-vertical][data-level=\"5\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(5 * 3rem - 0.3rem)}:host([data-level=\"5\"]) .mg-menu-item__collapse-container{z-index:calc(5 * 10)}:host([data-style-direction-vertical][data-level=\"6\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(6 * 3rem - 0.3rem)}:host([data-level=\"6\"]) .mg-menu-item__collapse-container{z-index:calc(6 * 10)}:host([data-style-direction-vertical][data-level=\"1\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(1 * 4rem - 0.3rem)}:host([data-level=\"1\"]) .mg-menu-item__collapse-container{z-index:calc(1 * 10)}:host([data-style-direction-vertical][data-level=\"2\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(2 * 4rem - 0.3rem)}:host([data-level=\"2\"]) .mg-menu-item__collapse-container{z-index:calc(2 * 10)}:host([data-style-direction-vertical][data-level=\"3\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(3 * 4rem - 0.3rem)}:host([data-level=\"3\"]) .mg-menu-item__collapse-container{z-index:calc(3 * 10)}:host([data-style-direction-vertical][data-level=\"4\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(4 * 4rem - 0.3rem)}:host([data-level=\"4\"]) .mg-menu-item__collapse-container{z-index:calc(4 * 10)}:host([data-style-direction-vertical][data-level=\"5\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(5 * 4rem - 0.3rem)}:host([data-level=\"5\"]) .mg-menu-item__collapse-container{z-index:calc(5 * 10)}:host([data-style-direction-vertical][data-level=\"6\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(6 * 4rem - 0.3rem)}:host([data-level=\"6\"]) .mg-menu-item__collapse-container{z-index:calc(6 * 10)}:host{position:relative;display:flex}:host([data-style-position-last]) .mg-menu-item__collapse-container{left:unset;right:0}:host([data-style-direction-vertical]){flex-direction:column}:host([data-style-direction-vertical]) .mg-menu-item__collapse-container{left:unset;top:unset;position:unset;width:unset}:host([data-style-direction-vertical]) .mg-menu-item-chevron{margin-left:auto}:host([data-style-direction-horizontal]) .mg-menu-item__collapse-container.mg-menu-item__collapse-container--first-level{box-shadow:var(--box-shadow);background-color:hsl(var(--color-light))}:host([data-style-direction-horizontal]) .mg-menu-item__collapse-container.mg-menu-item__collapse-container--first-level ::slotted(mg-menu){padding:1rem 0}.mg-menu-item{max-width:var(--mg-menu-item-navigation-button-max-width)}.mg-menu-item__collapse-container{position:absolute;top:100%;left:0;width:max-content;z-index:10}.mg-menu-item__navigation-button-center{min-width:0}.mg-menu-item__navigation-button-text-content{width:100%;display:flex}.mg-menu-item__navigation-button-text-content ::slotted([slot=information]){margin-left:1rem}.mg-menu-item__navigation-button-chevron{margin-left:auto;transition:200ms}.mg-menu-item__navigation-button-chevron--rotate.mg-menu-item__navigation-button-chevron{transform:rotate(180deg)}::slotted([slot=label]),::slotted([slot=metadata]){display:block;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";
|
|
3513
|
+
const mgMenuItemCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding:1rem 2rem;height:calc(3.8rem)}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button,.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button ::slotted([slot=label]),.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button ::slotted([slot=metadata]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular ::slotted([slot=label]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular ::slotted([slot=metadata]){font-size:var(--font-size)}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular.mg-menu-item__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular.mg-menu-item__navigation-button--vertical{padding-left:calc(2rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding:1rem 3rem;height:calc(5.1rem)}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button,.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button ::slotted([slot=label]),.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button ::slotted([slot=metadata]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium ::slotted([slot=label]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium ::slotted([slot=metadata]){font-size:calc(var(--font-size) + 0.2rem)}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium.mg-menu-item__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium.mg-menu-item__navigation-button--vertical{padding-left:calc(3rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding:1rem 4rem;height:calc(7.1rem)}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button,.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button ::slotted([slot=label]),.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button ::slotted([slot=metadata]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large ::slotted([slot=label]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large ::slotted([slot=metadata]){font-size:calc(var(--font-size) + 0.2rem)}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large.mg-menu-item__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large.mg-menu-item__navigation-button--vertical{padding-left:calc(4rem - 0.3rem)}.mg-menu-item__navigation-button{display:flex;align-items:center;column-gap:var(--mg-menu-item-navigation-button-column-gap, 1rem);background-color:unset;border:none;font-family:var(--font-family);color:hsl(var(--mg-menu-item-color-hsl, var(--color-dark)));line-height:var(--line-height);text-decoration:none;white-space:nowrap;box-sizing:border-box;cursor:pointer}.mg-menu-item__navigation-button:disabled,.mg-menu-item__navigation-button--disabled{cursor:default;opacity:0.3}.mg-menu-item__navigation-button:focus-visible{z-index:10}.mg-menu-item__navigation-button:hover:not(.mg-menu-item__navigation-button--disabled),.mg-menu-item__navigation-button:focus-visible:not(.mg-menu-item__navigation-button--disabled){background-color:hsl(var(--mg-menu-item-focused-background-color-hsl), 0.1)}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--active{color:hsl(var(--mg-menu-item-color-active-hsl));font-weight:600}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--active.mg-menu-item__navigation-button--horizontal{border-bottom-color:hsl(var(--mg-menu-item-border-color-active-hsl))}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--active.mg-menu-item__navigation-button--vertical{border-left-color:hsl(var(--mg-menu-item-border-color-active-hsl))}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--hidden{display:none}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal{border-bottom:0.3rem solid transparent}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical{border-left:0.3rem solid transparent}:host([data-style-direction-vertical][data-level=\"1\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(1 * 2rem - 0.3rem)}:host([data-level=\"1\"]) .mg-menu-item__collapse-container{z-index:calc(1 * 10)}:host([data-style-direction-vertical][data-level=\"2\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(2 * 2rem - 0.3rem)}:host([data-level=\"2\"]) .mg-menu-item__collapse-container{z-index:calc(2 * 10)}:host([data-style-direction-vertical][data-level=\"3\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(3 * 2rem - 0.3rem)}:host([data-level=\"3\"]) .mg-menu-item__collapse-container{z-index:calc(3 * 10)}:host([data-style-direction-vertical][data-level=\"4\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(4 * 2rem - 0.3rem)}:host([data-level=\"4\"]) .mg-menu-item__collapse-container{z-index:calc(4 * 10)}:host([data-style-direction-vertical][data-level=\"5\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(5 * 2rem - 0.3rem)}:host([data-level=\"5\"]) .mg-menu-item__collapse-container{z-index:calc(5 * 10)}:host([data-style-direction-vertical][data-level=\"6\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(6 * 2rem - 0.3rem)}:host([data-level=\"6\"]) .mg-menu-item__collapse-container{z-index:calc(6 * 10)}:host([data-style-direction-vertical][data-level=\"1\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(1 * 3rem - 0.3rem)}:host([data-level=\"1\"]) .mg-menu-item__collapse-container{z-index:calc(1 * 10)}:host([data-style-direction-vertical][data-level=\"2\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(2 * 3rem - 0.3rem)}:host([data-level=\"2\"]) .mg-menu-item__collapse-container{z-index:calc(2 * 10)}:host([data-style-direction-vertical][data-level=\"3\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(3 * 3rem - 0.3rem)}:host([data-level=\"3\"]) .mg-menu-item__collapse-container{z-index:calc(3 * 10)}:host([data-style-direction-vertical][data-level=\"4\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(4 * 3rem - 0.3rem)}:host([data-level=\"4\"]) .mg-menu-item__collapse-container{z-index:calc(4 * 10)}:host([data-style-direction-vertical][data-level=\"5\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(5 * 3rem - 0.3rem)}:host([data-level=\"5\"]) .mg-menu-item__collapse-container{z-index:calc(5 * 10)}:host([data-style-direction-vertical][data-level=\"6\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(6 * 3rem - 0.3rem)}:host([data-level=\"6\"]) .mg-menu-item__collapse-container{z-index:calc(6 * 10)}:host([data-style-direction-vertical][data-level=\"1\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(1 * 4rem - 0.3rem)}:host([data-level=\"1\"]) .mg-menu-item__collapse-container{z-index:calc(1 * 10)}:host([data-style-direction-vertical][data-level=\"2\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(2 * 4rem - 0.3rem)}:host([data-level=\"2\"]) .mg-menu-item__collapse-container{z-index:calc(2 * 10)}:host([data-style-direction-vertical][data-level=\"3\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(3 * 4rem - 0.3rem)}:host([data-level=\"3\"]) .mg-menu-item__collapse-container{z-index:calc(3 * 10)}:host([data-style-direction-vertical][data-level=\"4\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(4 * 4rem - 0.3rem)}:host([data-level=\"4\"]) .mg-menu-item__collapse-container{z-index:calc(4 * 10)}:host([data-style-direction-vertical][data-level=\"5\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(5 * 4rem - 0.3rem)}:host([data-level=\"5\"]) .mg-menu-item__collapse-container{z-index:calc(5 * 10)}:host([data-style-direction-vertical][data-level=\"6\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(6 * 4rem - 0.3rem)}:host([data-level=\"6\"]) .mg-menu-item__collapse-container{z-index:calc(6 * 10)}:host{position:relative;display:flex;--mg-popover-padding-vertical:0;--mg-popover-padding-horizontal:0}:host([data-style-direction-vertical]){flex-direction:column}:host([data-style-direction-vertical]) .mg-menu-item__navigation-button{width:100%}:host([data-style-direction-vertical]) .mg-menu-item__collapse-container{left:unset;top:unset;position:unset;width:unset}:host([data-style-direction-vertical]) .mg-menu-item-chevron{margin-left:auto}:host([data-style-direction-horizontal]) .mg-menu-item__collapse-container.mg-menu-item__collapse-container--first-level{background-color:hsl(var(--color-light))}:host([data-style-direction-horizontal]) .mg-menu-item__collapse-container.mg-menu-item__collapse-container--first-level ::slotted(mg-menu){padding:1rem 0}:host([data-overflow-more]){--mg-menu-item-navigation-button-column-gap:0}:host([data-overflow-more]) .mg-menu-item__navigation-button-chevron{display:none}:host([data-overflow-more]) .mg-menu-item__navigation-button-text-content ::slotted([slot=information]){margin-left:0}:host([data-overflow-more]) ::slotted(mg-menu){--mg-menu-item-navigation-button-column-gap:1rem}.mg-menu-item{max-width:var(--mg-menu-item-navigation-button-max-width)}.mg-menu-item__collapse-container{width:max-content;z-index:10}.mg-menu-item__navigation-button-center{min-width:0}.mg-menu-item__navigation-button-text-content{width:100%;display:flex;align-items:center}.mg-menu-item__navigation-button-text-content-notification,.mg-menu-item__navigation-button-text-content ::slotted([slot=information]){margin-left:1rem;font-size:var(--font-size)}.mg-menu-item__navigation-button-chevron{margin-left:auto;transition:200ms}.mg-menu-item__navigation-button-chevron--rotate.mg-menu-item__navigation-button-chevron{transform:rotate(180deg)}::slotted([slot=label]),::slotted([slot=metadata]){display:block;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}::slotted(*){display:flex;flex-direction:column}:host([status=disabled]){pointer-events:none}:host([hidden]){display:none}";
|
|
3381
3514
|
|
|
3382
3515
|
const MgMenuItem = class {
|
|
3383
3516
|
constructor(hostRef) {
|
|
3384
3517
|
index.registerInstance(this, hostRef);
|
|
3518
|
+
this.statusChange = index.createEvent(this, "status-change", 7);
|
|
3385
3519
|
/************
|
|
3386
3520
|
* Internal *
|
|
3387
3521
|
************/
|
|
3388
3522
|
this.name = 'mg-menu-item';
|
|
3389
3523
|
this.navigationButton = `${this.name}__navigation-button`;
|
|
3390
|
-
|
|
3391
|
-
* Define menu-item status. Default: "visible"
|
|
3392
|
-
*/
|
|
3393
|
-
this.status = Status$1.VISIBLE;
|
|
3394
|
-
/**
|
|
3395
|
-
* Define menu-item size. Default: "large".
|
|
3396
|
-
*/
|
|
3397
|
-
this.size = 'large';
|
|
3398
|
-
/**
|
|
3399
|
-
* Define menu-item content expanded. Default: false.
|
|
3400
|
-
*/
|
|
3401
|
-
this.expanded = false;
|
|
3402
|
-
/************
|
|
3403
|
-
* States *
|
|
3404
|
-
************/
|
|
3405
|
-
/**
|
|
3406
|
-
* Component button classes
|
|
3407
|
-
*/
|
|
3408
|
-
this.navigationButtonClassList = new ClassList([this.navigationButton]);
|
|
3409
|
-
/**
|
|
3410
|
-
* Does component have children. Default: false.
|
|
3411
|
-
*/
|
|
3412
|
-
this.hasChildren = false;
|
|
3413
|
-
/************
|
|
3524
|
+
/***********
|
|
3414
3525
|
* Methods *
|
|
3415
|
-
|
|
3526
|
+
**********/
|
|
3416
3527
|
/**
|
|
3417
3528
|
* Toggle expanded prop value
|
|
3418
3529
|
*
|
|
@@ -3422,20 +3533,20 @@ const MgMenuItem = class {
|
|
|
3422
3533
|
this.expanded = !this.expanded;
|
|
3423
3534
|
};
|
|
3424
3535
|
/**
|
|
3425
|
-
* Does an
|
|
3536
|
+
* Does an Element have given Status
|
|
3426
3537
|
*
|
|
3427
|
-
* @param {
|
|
3538
|
+
* @param {Element} element to parse
|
|
3428
3539
|
* @param {MgMenuItem['status']} status to check
|
|
3429
3540
|
* @returns {boolean} true if element with status is found
|
|
3430
3541
|
*/
|
|
3431
|
-
this.
|
|
3542
|
+
this.hasStatus = (element, status) => element.querySelector(`${this.name}[status="${status}"]`) !== null;
|
|
3432
3543
|
/**
|
|
3433
3544
|
* Is component contextual direction match the given direction
|
|
3434
3545
|
*
|
|
3435
3546
|
* @param {MgMenuItem['direction']} direction in parent menu
|
|
3436
3547
|
* @returns {boolean} true is direction match the direction propertie
|
|
3437
3548
|
*/
|
|
3438
|
-
this.
|
|
3549
|
+
this.isDirection = (direction) => this.direction === direction;
|
|
3439
3550
|
/************
|
|
3440
3551
|
* Handlers *
|
|
3441
3552
|
************/
|
|
@@ -3446,23 +3557,57 @@ const MgMenuItem = class {
|
|
|
3446
3557
|
* @returns {void}
|
|
3447
3558
|
*/
|
|
3448
3559
|
this.handleElementCLick = (event) => {
|
|
3449
|
-
|
|
3560
|
+
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status$1.DISABLED) {
|
|
3561
|
+
event.preventDefault();
|
|
3562
|
+
event.stopPropagation();
|
|
3563
|
+
}
|
|
3564
|
+
// toggle expanded when mg-menu-item has child items
|
|
3450
3565
|
if (this.hasChildren)
|
|
3451
3566
|
this.toggleExpanded();
|
|
3452
3567
|
};
|
|
3568
|
+
/**
|
|
3569
|
+
* Handle popover element display-change event
|
|
3570
|
+
*
|
|
3571
|
+
* @param {CustomEvent} event popover display event
|
|
3572
|
+
* @returns {void}
|
|
3573
|
+
*/
|
|
3574
|
+
this.handlePopoverDisplay = (event) => {
|
|
3575
|
+
this.expanded = event.detail;
|
|
3576
|
+
};
|
|
3577
|
+
/**
|
|
3578
|
+
* Update displayNotificationBadge
|
|
3579
|
+
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
3580
|
+
*
|
|
3581
|
+
* @returns {void} update displayNotificationBadge value
|
|
3582
|
+
*/
|
|
3583
|
+
this.updateDisplayNotificationBadge = () => {
|
|
3584
|
+
const childMenu = this.element.querySelector('mg-menu');
|
|
3585
|
+
this.displayNotificationBadge =
|
|
3586
|
+
childMenu !== null &&
|
|
3587
|
+
Array.from(childMenu.children).some((subItem) => subItem.querySelector('mg-badge') !== null && subItem.getAttribute('hidden') === null);
|
|
3588
|
+
};
|
|
3589
|
+
/**
|
|
3590
|
+
* Render slot
|
|
3591
|
+
*
|
|
3592
|
+
* @returns {HTMLElement} HTML Element
|
|
3593
|
+
*/
|
|
3594
|
+
this.renderSlot = () => index.h("slot", null);
|
|
3595
|
+
this.href = undefined;
|
|
3596
|
+
this.status = Status$1.VISIBLE;
|
|
3597
|
+
this.expanded = false;
|
|
3598
|
+
this.size = 'regular';
|
|
3599
|
+
this.navigationButtonClassList = new ClassList([this.navigationButton]);
|
|
3600
|
+
this.direction = undefined;
|
|
3601
|
+
this.isInMainMenu = undefined;
|
|
3602
|
+
this.hasChildren = false;
|
|
3603
|
+
this.displayNotificationBadge = undefined;
|
|
3453
3604
|
}
|
|
3454
3605
|
validateStatus(newValue, oldValue) {
|
|
3455
3606
|
if (oldValue !== undefined) {
|
|
3456
3607
|
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
3457
3608
|
}
|
|
3458
3609
|
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
3459
|
-
|
|
3460
|
-
validateSize(newValue, oldValue) {
|
|
3461
|
-
if (!sizes$1.includes(newValue)) {
|
|
3462
|
-
throw new Error(`<${this.name}> prop "size" must be one of : ${sizes$1.join(', ')}.`);
|
|
3463
|
-
}
|
|
3464
|
-
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
3465
|
-
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
3610
|
+
this.statusChange.emit(newValue);
|
|
3466
3611
|
}
|
|
3467
3612
|
validateExpanded(newValue) {
|
|
3468
3613
|
if (typeof newValue !== 'boolean')
|
|
@@ -3476,16 +3621,20 @@ const MgMenuItem = class {
|
|
|
3476
3621
|
item.expanded = false;
|
|
3477
3622
|
});
|
|
3478
3623
|
}
|
|
3479
|
-
else if (
|
|
3624
|
+
else if (this.hasStatus(this.element, Status$1.ACTIVE)) {
|
|
3480
3625
|
// - when expanded and contain an active item parents are expended too
|
|
3481
3626
|
subItems.forEach(item => {
|
|
3482
|
-
if (this.
|
|
3627
|
+
if (this.hasStatus(item, Status$1.ACTIVE)) {
|
|
3483
3628
|
item.expanded = true;
|
|
3484
3629
|
}
|
|
3485
3630
|
});
|
|
3486
3631
|
}
|
|
3487
3632
|
}
|
|
3488
3633
|
}
|
|
3634
|
+
validateSize(newValue, oldValue) {
|
|
3635
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
3636
|
+
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
3637
|
+
}
|
|
3489
3638
|
validateHasChildren(newValue) {
|
|
3490
3639
|
if (newValue && this.element.href !== undefined) {
|
|
3491
3640
|
throw new Error(`<${this.name}> prop "href" is unauthorizied when element is a parent.`);
|
|
@@ -3500,13 +3649,14 @@ const MgMenuItem = class {
|
|
|
3500
3649
|
* @returns {void}
|
|
3501
3650
|
*/
|
|
3502
3651
|
componentWillLoad() {
|
|
3503
|
-
// has children items that is NOT [slot=
|
|
3652
|
+
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
3504
3653
|
// we store only matching elements
|
|
3505
|
-
this.hasChildren = Array.from(this.element.children).
|
|
3654
|
+
this.hasChildren = Array.from(this.element.children).some(child => !['image', 'information', 'label', 'metadata'].includes(child.getAttribute('slot')));
|
|
3506
3655
|
// Validate props
|
|
3507
3656
|
this.validateSize(this.size);
|
|
3508
3657
|
this.validateStatus(this.status);
|
|
3509
3658
|
this.validateExpanded(this.expanded);
|
|
3659
|
+
this.badgeLabel = initLocales(this.element).messages.plusMenu.badgeLabel;
|
|
3510
3660
|
}
|
|
3511
3661
|
/**
|
|
3512
3662
|
* Check if component slots configuration
|
|
@@ -3530,55 +3680,73 @@ const MgMenuItem = class {
|
|
|
3530
3680
|
// return a promise to process action only in the FIRST render().
|
|
3531
3681
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
3532
3682
|
return setTimeout(() => {
|
|
3533
|
-
var _a
|
|
3683
|
+
var _a;
|
|
3534
3684
|
// define menu-item context states
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
this.isInMainMenu = this.element.parentElement.
|
|
3539
|
-
const hasNextMenuItem = ((_a = this.element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.nodeName) === 'MG-MENU-ITEM';
|
|
3540
|
-
const hasPreviousMenuItem = ((_b = this.element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.nodeName) === 'MG-MENU-ITEM';
|
|
3541
|
-
// manage last menu item
|
|
3542
|
-
if (!hasNextMenuItem && hasPreviousMenuItem && this.isdirection(Direction.HORIZONTAL)) {
|
|
3543
|
-
this.element.setAttribute('data-style-position-last', '');
|
|
3544
|
-
}
|
|
3685
|
+
const menu = this.element.closest('mg-menu');
|
|
3686
|
+
this.direction = this.element.getAttribute(OverflowBehaviorElements.MORE) !== null || menu === null ? Direction.HORIZONTAL : menu.direction;
|
|
3687
|
+
this.size = menu === null || menu === void 0 ? void 0 : menu.size;
|
|
3688
|
+
this.isInMainMenu = this.element.parentElement.closest('mg-menu-item') === null;
|
|
3545
3689
|
// when main menu item contain an active item it will get the active style
|
|
3546
3690
|
// AND if item is in vertical menu it will be expanded
|
|
3547
|
-
|
|
3691
|
+
const hasActiveChild = Array.from(this.element.children).some(element => this.hasStatus(element, Status$1.ACTIVE) && element.getAttribute('hidden') === null);
|
|
3692
|
+
if (this.isInMainMenu && hasActiveChild) {
|
|
3548
3693
|
this.status = Status$1.ACTIVE;
|
|
3549
|
-
this.expanded = this.
|
|
3694
|
+
this.expanded = this.isDirection(Direction.VERTICAL);
|
|
3550
3695
|
}
|
|
3551
3696
|
// manage menu items style depending to parent menu horientation
|
|
3552
3697
|
this.element.setAttribute(`data-style-direction-${this.direction}`, '');
|
|
3553
3698
|
this.navigationButtonClassList.add(`${this.navigationButton}--${this.direction}`);
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3699
|
+
this.updateDisplayNotificationBadge();
|
|
3700
|
+
// manage all sub levels child menu-items level with data-level attribut
|
|
3701
|
+
if (this.isDirection(Direction.VERTICAL)) {
|
|
3702
|
+
Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
|
|
3558
3703
|
const itemLevel = Number(item.getAttribute('data-level')) || 1;
|
|
3559
3704
|
item.setAttribute('data-level', `${itemLevel + 1}`);
|
|
3560
|
-
}
|
|
3705
|
+
});
|
|
3706
|
+
}
|
|
3707
|
+
// manage first sub-level menu-items
|
|
3708
|
+
const childItems = Array.from(((_a = this.element.querySelector('mg-menu')) === null || _a === void 0 ? void 0 : _a.children) || []).filter(item => item.nodeName === 'MG-MENU-ITEM');
|
|
3709
|
+
childItems.forEach(item => {
|
|
3710
|
+
// manage child menu listener
|
|
3711
|
+
new MutationObserver(() => {
|
|
3712
|
+
this.updateDisplayNotificationBadge();
|
|
3713
|
+
}).observe(item, { attributes: true });
|
|
3561
3714
|
});
|
|
3562
3715
|
}, 0);
|
|
3563
3716
|
}
|
|
3717
|
+
/**
|
|
3718
|
+
* Render ineractive element
|
|
3719
|
+
*
|
|
3720
|
+
* @returns {HTMLElement} HTML Element
|
|
3721
|
+
*/
|
|
3722
|
+
renderInteractiveElement() {
|
|
3723
|
+
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
3724
|
+
return (index.h(TagName, { href: this.href, class: this.navigationButtonClassList.join(), tabindex: [Status$1.DISABLED, Status$1.HIDDEN].includes(this.status) ? -1 : 0, disabled: this.status === Status$1.DISABLED, hidden: this.status === Status$1.HIDDEN, "aria-expanded": this.hasChildren && this.expanded.toString(), "aria-current": this.status === Status$1.ACTIVE && 'page', onClick: this.handleElementCLick }, index.h("slot", { name: "image" }), index.h("div", { class: `${this.navigationButton}-center` }, index.h("div", { class: `${this.navigationButton}-text-content` }, index.h("slot", { name: "label" }), !this.displayNotificationBadge && index.h("slot", { name: "information" }), this.displayNotificationBadge && (index.h("span", { class: "mg-menu-item__navigation-button-text-content-notification" }, index.h("mg-badge", { label: this.badgeLabel, value: "!", variant: "info", slot: "information" })))), this.size !== 'regular' && index.h("slot", { name: "metadata" })), this.hasChildren && this.href === undefined && (index.h("span", { class: {
|
|
3725
|
+
[`${this.navigationButton}-chevron`]: true,
|
|
3726
|
+
[`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
|
|
3727
|
+
'mg-a11y-animation': true,
|
|
3728
|
+
} }, index.h("mg-icon", { icon: "chevron-down" })))));
|
|
3729
|
+
}
|
|
3564
3730
|
/**
|
|
3565
3731
|
* Render
|
|
3566
3732
|
*
|
|
3567
3733
|
* @returns {HTMLElement} HTML Element
|
|
3568
3734
|
*/
|
|
3569
3735
|
render() {
|
|
3570
|
-
const
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3736
|
+
const getContainerClasses = () => ({
|
|
3737
|
+
[`${this.name}__collapse-container`]: true,
|
|
3738
|
+
[`${this.name}__collapse-container--first-level`]: this.isInMainMenu && this.isDirection(Direction.HORIZONTAL),
|
|
3739
|
+
});
|
|
3740
|
+
return (index.h(index.Host, { role: "menuitem", "aria-haspopup": this.hasChildren.toString() }, this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined ? (index.h("mg-popover", { display: this.expanded, placement: "bottom-start", arrowHide: true, "onDisplay-change": this.handlePopoverDisplay }, this.renderInteractiveElement(), index.h("div", { class: getContainerClasses(), slot: "content" }, this.renderSlot()))) : ([
|
|
3741
|
+
this.renderInteractiveElement(),
|
|
3742
|
+
index.h("div", { class: getContainerClasses(), hidden: !this.expanded }, this.renderSlot()),
|
|
3743
|
+
])));
|
|
3576
3744
|
}
|
|
3577
3745
|
get element() { return index.getElement(this); }
|
|
3578
3746
|
static get watchers() { return {
|
|
3579
3747
|
"status": ["validateStatus"],
|
|
3580
|
-
"size": ["validateSize"],
|
|
3581
3748
|
"expanded": ["validateExpanded"],
|
|
3749
|
+
"size": ["validateSize"],
|
|
3582
3750
|
"hasChildren": ["validateHasChildren"]
|
|
3583
3751
|
}; }
|
|
3584
3752
|
};
|
|
@@ -3589,7 +3757,7 @@ MgMenuItem.style = mgMenuItemCss;
|
|
|
3589
3757
|
*/
|
|
3590
3758
|
const variants$1 = ['info', 'warning', 'success', 'danger'];
|
|
3591
3759
|
|
|
3592
|
-
const mgMessageCss = "
|
|
3760
|
+
const mgMessageCss = ":host{--mg-card-padding:0;--mg-card-border-radius:var(--mg-message-border-radius);--mg-card-border:none;--mg-card-overflow:hidden}.mg-message{display:inline-block;min-height:var(--default-size)}.mg-message__bar{position:absolute;top:0;left:0;width:0.3rem;height:100%}.mg-message.mg-message--info .mg-message__bar{background-color:hsl(var(--color-info))}.mg-message.mg-message--info .mg-message__icon{color:hsl(var(--color-info))}.mg-message.mg-message--warning .mg-message__bar{background-color:hsl(var(--color-warning))}.mg-message.mg-message--warning .mg-message__icon{color:hsl(var(--color-warning))}.mg-message.mg-message--success .mg-message__bar{background-color:hsl(var(--color-success))}.mg-message.mg-message--success .mg-message__icon{color:hsl(var(--color-success))}.mg-message.mg-message--danger .mg-message__bar{background-color:hsl(var(--color-danger))}.mg-message.mg-message--danger .mg-message__icon{color:hsl(var(--color-danger))}.mg-message.mg-message--close-button{--mg-card-padding:0 3.4rem 0 0}.mg-message.mg-message--hide{display:none}.mg-message ::slotted(*){margin:0;padding:0}.mg-message__icon{position:absolute;top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);left:1.3rem;line-height:1}.mg-message__content{display:flex;flex-wrap:wrap;justify-content:flex-end;align-content:stretch;padding:0 1rem 0 3.8rem}.mg-message__content-slot{flex-grow:1;margin:0.84rem 0}.mg-message__content-separator{display:inline-block;width:4.5rem;height:0}.mg-message__content-actions-slot{padding:1rem 0;text-align:right}.mg-message__close-button{position:absolute;top:0;right:0}.mg-message ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default)}.mg-message,mg-message{max-width:100%}";
|
|
3593
3761
|
|
|
3594
3762
|
const MgMessage = class {
|
|
3595
3763
|
constructor(hostRef) {
|
|
@@ -3605,49 +3773,50 @@ const MgMessage = class {
|
|
|
3605
3773
|
this.closeButtonId = '';
|
|
3606
3774
|
// Stored timer setted when hide action is run from setTimeOut
|
|
3607
3775
|
this.storedTimer = null;
|
|
3776
|
+
// Manage hover
|
|
3777
|
+
this.isFocused = false;
|
|
3778
|
+
this.isHovered = false;
|
|
3608
3779
|
/**
|
|
3609
|
-
*
|
|
3610
|
-
*
|
|
3611
|
-
|
|
3612
|
-
this.identifier = createID('mg-message');
|
|
3613
|
-
/**
|
|
3614
|
-
* Message variant
|
|
3615
|
-
*/
|
|
3616
|
-
this.variant = variants$1[0]; // info
|
|
3617
|
-
/**
|
|
3618
|
-
* Define if message has a cross button
|
|
3619
|
-
* RG 01: https://jira.mgdis.fr/browse/PDA9-140
|
|
3620
|
-
*/
|
|
3621
|
-
this.closeButton = false;
|
|
3622
|
-
/**
|
|
3623
|
-
* Define if message is hidden
|
|
3780
|
+
* Set timer
|
|
3781
|
+
*
|
|
3782
|
+
* @returns {void}
|
|
3624
3783
|
*/
|
|
3625
|
-
this.
|
|
3784
|
+
this.setTimer = () => {
|
|
3785
|
+
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
3786
|
+
};
|
|
3626
3787
|
/**
|
|
3627
|
-
*
|
|
3788
|
+
* Clear timer
|
|
3789
|
+
*
|
|
3790
|
+
* @returns {void}
|
|
3628
3791
|
*/
|
|
3629
|
-
this.
|
|
3792
|
+
this.clearTimer = () => {
|
|
3793
|
+
clearTimeout(this.storedTimer);
|
|
3794
|
+
};
|
|
3630
3795
|
/**
|
|
3631
|
-
*
|
|
3796
|
+
* Event to add on element
|
|
3797
|
+
*
|
|
3798
|
+
* @param {MouseEvent | FocusEvent} event event
|
|
3799
|
+
* @returns {void}
|
|
3632
3800
|
*/
|
|
3633
|
-
this.
|
|
3801
|
+
this.timerEvents = (event) => {
|
|
3802
|
+
this.clearTimer();
|
|
3803
|
+
const isMouseEvent = event.type === 'mouseenter';
|
|
3804
|
+
// Needed to ensure we don't start the timer
|
|
3805
|
+
this[isMouseEvent ? 'isHovered' : 'isFocused'] = true;
|
|
3806
|
+
// Restart timer when loose focus AND mouse leave
|
|
3807
|
+
this.element.addEventListener(isMouseEvent ? 'mouseleave' : 'focusout', eventOut => {
|
|
3808
|
+
this[eventOut.type === 'mouseleave' ? 'isHovered' : 'isFocused'] = false;
|
|
3809
|
+
// Start timer if needed
|
|
3810
|
+
if (!this.isFocused && !this.isHovered)
|
|
3811
|
+
this.setTimer();
|
|
3812
|
+
}, { once: true });
|
|
3813
|
+
};
|
|
3634
3814
|
/**
|
|
3635
3815
|
* Handle close button
|
|
3636
3816
|
*/
|
|
3637
3817
|
this.handleClose = () => {
|
|
3638
3818
|
this.hide = true;
|
|
3639
3819
|
};
|
|
3640
|
-
/**
|
|
3641
|
-
* Hide component whith delay
|
|
3642
|
-
*/
|
|
3643
|
-
this.hideWithDelay = () => {
|
|
3644
|
-
if (this.delay > 0 && this.hide !== true) {
|
|
3645
|
-
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
3646
|
-
}
|
|
3647
|
-
else if (this.storedTimer !== null) {
|
|
3648
|
-
clearTimeout(this.storedTimer);
|
|
3649
|
-
}
|
|
3650
|
-
};
|
|
3651
3820
|
/**
|
|
3652
3821
|
* Get icon corresponding to variant
|
|
3653
3822
|
*
|
|
@@ -3665,6 +3834,13 @@ const MgMessage = class {
|
|
|
3665
3834
|
return 'exclamation-circle';
|
|
3666
3835
|
}
|
|
3667
3836
|
};
|
|
3837
|
+
this.identifier = createID('mg-message');
|
|
3838
|
+
this.delay = undefined;
|
|
3839
|
+
this.variant = variants$1[0];
|
|
3840
|
+
this.closeButton = false;
|
|
3841
|
+
this.hide = false;
|
|
3842
|
+
this.classList = new ClassList(['mg-message']);
|
|
3843
|
+
this.hasActions = false;
|
|
3668
3844
|
}
|
|
3669
3845
|
validateDelay(newValue) {
|
|
3670
3846
|
if (newValue && newValue < 2) {
|
|
@@ -3692,12 +3868,26 @@ const MgMessage = class {
|
|
|
3692
3868
|
if (newValue) {
|
|
3693
3869
|
this.componentHide.emit();
|
|
3694
3870
|
this.classList.add(this.classHide);
|
|
3871
|
+
// Remove event Listener
|
|
3872
|
+
['focusin', 'mouseenter'].forEach(event => {
|
|
3873
|
+
this.element.removeEventListener(event, this.timerEvents);
|
|
3874
|
+
});
|
|
3875
|
+
// Clear Timer
|
|
3876
|
+
this.clearTimer();
|
|
3695
3877
|
}
|
|
3696
3878
|
else {
|
|
3697
3879
|
this.componentShow.emit();
|
|
3698
3880
|
this.classList.delete(this.classHide);
|
|
3881
|
+
// If delay is set
|
|
3882
|
+
if (this.delay > 1) {
|
|
3883
|
+
// Start timer
|
|
3884
|
+
this.setTimer();
|
|
3885
|
+
// Stop timer when get focus or mouse enter
|
|
3886
|
+
['focusin', 'mouseenter'].forEach(event => {
|
|
3887
|
+
this.element.addEventListener(event, this.timerEvents);
|
|
3888
|
+
});
|
|
3889
|
+
}
|
|
3699
3890
|
}
|
|
3700
|
-
this.hideWithDelay();
|
|
3701
3891
|
}
|
|
3702
3892
|
/*************
|
|
3703
3893
|
* Lifecycle *
|
|
@@ -3726,7 +3916,7 @@ const MgMessage = class {
|
|
|
3726
3916
|
* @returns {HTMLElement} HTML Element
|
|
3727
3917
|
*/
|
|
3728
3918
|
render() {
|
|
3729
|
-
return (index.h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, index.h("span", { class: "mg-message__icon" }, index.h("mg-icon", { icon: this.getIcon() })), index.h("div", { class: "mg-message__content" }, index.h("span", { class: "mg-message__content-slot" }, index.h("slot", null)), this.hasActions && index.h("span", { class: "mg-message__content-separator" }), this.hasActions && (index.h("span", { class: "mg-message__content-actions-slot" }, index.h("slot", { name: "actions" })))), this.closeButton && (index.h("span", { class: "mg-message__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" }))))));
|
|
3919
|
+
return (index.h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, index.h("mg-card", null, index.h("span", { class: "mg-message__bar" }), index.h("span", { class: "mg-message__icon" }, index.h("mg-icon", { icon: this.getIcon() })), index.h("div", { class: "mg-message__content" }, index.h("span", { class: "mg-message__content-slot" }, index.h("slot", null)), this.hasActions && index.h("span", { class: "mg-message__content-separator" }), this.hasActions && (index.h("span", { class: "mg-message__content-actions-slot" }, index.h("slot", { name: "actions" })))), this.closeButton && (index.h("span", { class: "mg-message__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" })))))));
|
|
3730
3920
|
}
|
|
3731
3921
|
get element() { return index.getElement(this); }
|
|
3732
3922
|
static get watchers() { return {
|
|
@@ -3738,7 +3928,7 @@ const MgMessage = class {
|
|
|
3738
3928
|
};
|
|
3739
3929
|
MgMessage.style = mgMessageCss;
|
|
3740
3930
|
|
|
3741
|
-
const mgModalCss = ".mg-modal{display:flex;justify-content:center;align-items:center;position:fixed;top:0;right:0;bottom:0;left:0;z-index:2000;padding:2rem 0;background-color:
|
|
3931
|
+
const mgModalCss = ":host{--mg-card-border-radius:var(--mg-modal-border-radius);--mg-card-padding:1.5rem 2.5rem;--mg-card-border:none}.mg-modal{display:flex;justify-content:center;align-items:center;position:fixed;top:0;right:0;bottom:0;left:0;z-index:2000;padding:2rem 0;background-color:hsl(var(--color-light), 0.85)}.mg-modal mg-card{display:flex;width:60rem;max-width:100%;max-height:100%}.mg-modal__dialog{display:flex;position:relative;flex-direction:column;align-self:center;row-gap:3rem;height:fit-content;max-height:100%}.mg-modal__header{margin-bottom:0.5rem}.mg-modal__title{margin:0;font-family:var(--font-family-heading);font-size:var(--mg-modal-title-font-size);font-weight:600}.mg-modal__close-button{float:right;height:var(--mg-modal-title-font-size);margin-top:calc((var(--default-size) - var(--mg-modal-title-font-size) * var(--line-height)) / 2 * -1);margin-right:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2 * -1)}.mg-modal__content{overflow-y:auto}.mg-modal__content::slotted(*){font-size:var(--mg-modal-content-font-size)}.mg-modal.mg-modal--hide{display:none}.mg-modal ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default)}";
|
|
3742
3932
|
|
|
3743
3933
|
const MgModal = class {
|
|
3744
3934
|
constructor(hostRef) {
|
|
@@ -3750,31 +3940,6 @@ const MgModal = class {
|
|
|
3750
3940
|
// IDs
|
|
3751
3941
|
this.closeButtonId = '';
|
|
3752
3942
|
this.titleId = '';
|
|
3753
|
-
/**
|
|
3754
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
3755
|
-
* If not set, it will be created.
|
|
3756
|
-
*/
|
|
3757
|
-
this.identifier = createID('mg-modal');
|
|
3758
|
-
/**
|
|
3759
|
-
* Define if modal has a cross button
|
|
3760
|
-
*/
|
|
3761
|
-
this.closeButton = false;
|
|
3762
|
-
/**
|
|
3763
|
-
* Define if modal is hidden
|
|
3764
|
-
*/
|
|
3765
|
-
this.hide = false;
|
|
3766
|
-
/**
|
|
3767
|
-
* Define if component is using actions slot
|
|
3768
|
-
*/
|
|
3769
|
-
this.hasActions = false;
|
|
3770
|
-
/**
|
|
3771
|
-
* Define if component is using content slot
|
|
3772
|
-
*/
|
|
3773
|
-
this.hasContent = false;
|
|
3774
|
-
/**
|
|
3775
|
-
* Component classes
|
|
3776
|
-
*/
|
|
3777
|
-
this.classList = new ClassList(['mg-modal']);
|
|
3778
3943
|
this.setFocus = () => {
|
|
3779
3944
|
// Get all focusable elements
|
|
3780
3945
|
this.modalFocusableElements = Array.from(this.element.querySelectorAll(focusableElements)).reduce((acc, focusableElement) => {
|
|
@@ -3817,6 +3982,13 @@ const MgModal = class {
|
|
|
3817
3982
|
this.handleClose = () => {
|
|
3818
3983
|
this.hide = true;
|
|
3819
3984
|
};
|
|
3985
|
+
this.identifier = createID('mg-modal');
|
|
3986
|
+
this.modalTitle = undefined;
|
|
3987
|
+
this.closeButton = false;
|
|
3988
|
+
this.hide = false;
|
|
3989
|
+
this.hasActions = false;
|
|
3990
|
+
this.hasContent = false;
|
|
3991
|
+
this.classList = new ClassList(['mg-modal']);
|
|
3820
3992
|
}
|
|
3821
3993
|
validateModalTitle(newValue) {
|
|
3822
3994
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -3892,7 +4064,7 @@ const MgModal = class {
|
|
|
3892
4064
|
* @returns {HTMLElement} HTML Element
|
|
3893
4065
|
*/
|
|
3894
4066
|
render() {
|
|
3895
|
-
return (index.h("
|
|
4067
|
+
return (index.h("div", { role: "alertdialog", id: this.identifier, class: this.classList.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, index.h("mg-card", null, index.h("div", { class: "mg-modal__dialog" }, index.h("header", { class: "mg-modal__header" }, this.closeButton && (index.h("span", { class: "mg-modal__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" })))), index.h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (index.h("article", { class: "mg-modal__content" }, index.h("slot", { name: "content" }))), this.hasActions && (index.h("footer", { class: "mg-modal__footer" }, index.h("slot", { name: "actions" })))))));
|
|
3896
4068
|
}
|
|
3897
4069
|
get element() { return index.getElement(this); }
|
|
3898
4070
|
static get watchers() { return {
|
|
@@ -3935,19 +4107,6 @@ const MgPagination = class {
|
|
|
3935
4107
|
constructor(hostRef) {
|
|
3936
4108
|
index.registerInstance(this, hostRef);
|
|
3937
4109
|
this.currentPageChange = index.createEvent(this, "current-page-change", 7);
|
|
3938
|
-
/**
|
|
3939
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
3940
|
-
* If not set, it will be created.
|
|
3941
|
-
*/
|
|
3942
|
-
this.identifier = createID('mg-pagination');
|
|
3943
|
-
/**
|
|
3944
|
-
* Component total pages
|
|
3945
|
-
*/
|
|
3946
|
-
this.totalPages = 1;
|
|
3947
|
-
/**
|
|
3948
|
-
* Component current page
|
|
3949
|
-
*/
|
|
3950
|
-
this.currentPage = 1;
|
|
3951
4110
|
/**
|
|
3952
4111
|
* Change current page from target
|
|
3953
4112
|
*
|
|
@@ -3980,6 +4139,10 @@ const MgPagination = class {
|
|
|
3980
4139
|
this.handleGoToPage = (action, disabled) => {
|
|
3981
4140
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
3982
4141
|
};
|
|
4142
|
+
this.identifier = createID('mg-pagination');
|
|
4143
|
+
this.label = undefined;
|
|
4144
|
+
this.totalPages = 1;
|
|
4145
|
+
this.currentPage = 1;
|
|
3983
4146
|
}
|
|
3984
4147
|
validateTotalPages(newValue) {
|
|
3985
4148
|
if (newValue < 1) {
|
|
@@ -4033,34 +4196,13 @@ const MgPagination = class {
|
|
|
4033
4196
|
};
|
|
4034
4197
|
MgPagination.style = mgPaginationCss;
|
|
4035
4198
|
|
|
4036
|
-
const mgPanelCss = "
|
|
4199
|
+
const mgPanelCss = ":host{--mg-card-border:none;--mg-card-padding:0;--mg-card-border-radius:var(--mg-panel-border-radius);--mg-card-background:hsl(var(--mg-panel-background));--mg-card-box-shadow:var(--mg-panel-box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-right{padding-left:0.3rem;flex:1 auto;min-height:var(--default-size);align-items:center}.mg-panel__header-left mg-input-text{flex-grow:1;margin-left:0.3rem}.mg-panel__header-left mg-button+mg-button:not([slot=append-input]){margin-left:0.3rem}.mg-panel__header-left.mg-panel__header-left--full{flex:1 1 auto}.mg-panel__collapse-button-content{--font-size:1.4rem;--mg-button-font-weight:600}.mg-panel__content{padding:var(--mg-panel-content-padding)}.mg-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;gap:1rem;margin-left:auto}.mg-panel ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default)}";
|
|
4037
4200
|
|
|
4038
4201
|
const MgPanel = class {
|
|
4039
4202
|
constructor(hostRef) {
|
|
4040
4203
|
index.registerInstance(this, hostRef);
|
|
4041
4204
|
this.titleChange = index.createEvent(this, "title-change", 7);
|
|
4042
4205
|
this.expandedChange = index.createEvent(this, "expanded-change", 7);
|
|
4043
|
-
/**
|
|
4044
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
4045
|
-
* If not set, it will be created.
|
|
4046
|
-
*/
|
|
4047
|
-
this.identifier = createID('mg-panel');
|
|
4048
|
-
/**
|
|
4049
|
-
* Panel is opened
|
|
4050
|
-
*/
|
|
4051
|
-
this.expanded = false;
|
|
4052
|
-
/**
|
|
4053
|
-
* Panel title is editabled
|
|
4054
|
-
*/
|
|
4055
|
-
this.titleEditable = false;
|
|
4056
|
-
/**
|
|
4057
|
-
* Component classes
|
|
4058
|
-
*/
|
|
4059
|
-
this.classList = new ClassList(['mg-panel']);
|
|
4060
|
-
/**
|
|
4061
|
-
* Title is in edition mode
|
|
4062
|
-
*/
|
|
4063
|
-
this.isEditing = false;
|
|
4064
4206
|
/************
|
|
4065
4207
|
* Methods *
|
|
4066
4208
|
************/
|
|
@@ -4145,6 +4287,16 @@ const MgPanel = class {
|
|
|
4145
4287
|
}
|
|
4146
4288
|
return collapseButton();
|
|
4147
4289
|
};
|
|
4290
|
+
this.identifier = createID('mg-panel');
|
|
4291
|
+
this.panelTitle = undefined;
|
|
4292
|
+
this.titlePattern = undefined;
|
|
4293
|
+
this.titlePatternErrorMessage = undefined;
|
|
4294
|
+
this.expanded = false;
|
|
4295
|
+
this.expandToggleDisabled = undefined;
|
|
4296
|
+
this.titleEditable = false;
|
|
4297
|
+
this.classList = new ClassList(['mg-panel']);
|
|
4298
|
+
this.isEditing = false;
|
|
4299
|
+
this.updatedPanelTitle = undefined;
|
|
4148
4300
|
}
|
|
4149
4301
|
validatePanelTitle(newValue) {
|
|
4150
4302
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -4195,7 +4347,7 @@ const MgPanel = class {
|
|
|
4195
4347
|
* @returns {HTMLElement} html element
|
|
4196
4348
|
*/
|
|
4197
4349
|
render() {
|
|
4198
|
-
return (index.h("section", { class: this.classList.join(), id: this.identifier }, index.h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, index.h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), index.h("div", { class: "mg-panel__header-right" }, index.h("slot", { name: "header-right" }))), index.h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, index.h("slot", null))));
|
|
4350
|
+
return (index.h("section", { class: this.classList.join(), id: this.identifier }, index.h("mg-card", null, index.h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, index.h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), index.h("div", { class: "mg-panel__header-right" }, index.h("slot", { name: "header-right" }))), index.h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, index.h("slot", null)))));
|
|
4199
4351
|
}
|
|
4200
4352
|
get element() { return index.getElement(this); }
|
|
4201
4353
|
static get watchers() { return {
|
|
@@ -6004,34 +6156,15 @@ var createPopper = /*#__PURE__*/popperGenerator({
|
|
|
6004
6156
|
defaultModifiers: defaultModifiers
|
|
6005
6157
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
6006
6158
|
|
|
6007
|
-
const mgPopoverCss = "mg-
|
|
6159
|
+
const mgPopoverCss = ":host{--mg-card-padding:var(--mg-popover-padding-vertical, 1.5rem) var(--mg-popover-padding-horizontal, var(--mg-popover-padding-vertical, 1.5rem));--mg-card-border:none;--mg-card-border-radius:0.5rem;--mg-card-background:hsl(var(--mg-popover-background-color));position:relative;display:contents}:host::slotted(*){display:inline-block}.mg-popover{display:none;padding:1rem;z-index:2000;color:hsl(var(--mg-popover-font-color))}.mg-popover mg-card{position:relative;z-index:-1}.mg-popover[data-show]{display:block}.mg-popover mg-button{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover__arrow{position:absolute;visibility:hidden;width:calc(3rem + 2 * var(--mg-card-border-radius) + 2rem);height:calc(3rem + 2 * var(--mg-card-border-radius) + 2rem)}.mg-popover__arrow:before{visibility:visible;content:\"\";position:absolute}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow,.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{height:1rem}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow:before{left:calc(var(--mg-card-border-radius) + 1rem);border-right:calc(3rem / 2) solid transparent;border-left:calc(3rem / 2) solid transparent}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow{bottom:0.1rem;filter:drop-shadow(0 0.5rem 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow:before{border-top:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{top:0.1rem;filter:drop-shadow(0 -0.5rem 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow:before{border-bottom:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{width:1rem}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right]>.mg-popover__arrow:before{top:calc(var(--mg-card-border-radius) + 1rem);border-top:calc(3rem / 2) solid transparent;border-bottom:calc(3rem / 2) solid transparent}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow{right:0.1rem;filter:drop-shadow(0.5rem 0 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow:before{border-left:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{left:0.1rem;filter:drop-shadow(-0.5rem 0 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow:before{border-right:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=left-start],.mg-popover[data-popper-placement^=left-end],.mg-popover[data-popper-placement^=right-start],.mg-popover[data-popper-placement^=right-end]{padding:0 1rem}.mg-popover[data-popper-placement^=left-start]>.mg-popover__arrow,.mg-popover[data-popper-placement^=left-end]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right-start]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right-end]>.mg-popover__arrow{height:calc(3rem + 2 * var(--mg-card-border-radius))}.mg-popover[data-popper-placement^=left-start]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=left-end]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right-start]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right-end]>.mg-popover__arrow:before{top:var(--mg-card-border-radius)}.mg-popover__title ::slotted([slot=title]){margin:0 0 1rem !important;font-size:var(--mg-popover-title-font-size) !important;font-weight:600}.mg-popover--arrow-hide.mg-popover[data-popper-placement^=top]{padding-bottom:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement^=bottom]{padding-top:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement$=end],.mg-popover--arrow-hide.mg-popover[data-popper-placement^=left]{padding-right:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement$=start],.mg-popover--arrow-hide.mg-popover[data-popper-placement^=right]{padding-left:0}.mg-popover ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default)}";
|
|
6008
6160
|
|
|
6009
6161
|
const MgPopover = class {
|
|
6010
6162
|
constructor(hostRef) {
|
|
6011
6163
|
index.registerInstance(this, hostRef);
|
|
6012
6164
|
this.displayChange = index.createEvent(this, "display-change", 7);
|
|
6013
6165
|
this.closeButtonId = '';
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
* Needed by the input for accessibility `aria-decribedby`.
|
|
6017
|
-
*/
|
|
6018
|
-
this.identifier = createID('mg-popover');
|
|
6019
|
-
/**
|
|
6020
|
-
* Popover placement
|
|
6021
|
-
*/
|
|
6022
|
-
this.placement = 'bottom';
|
|
6023
|
-
/**
|
|
6024
|
-
* Define if popover has a cross button
|
|
6025
|
-
*/
|
|
6026
|
-
this.closeButton = false;
|
|
6027
|
-
/**
|
|
6028
|
-
* Display popover
|
|
6029
|
-
*/
|
|
6030
|
-
this.display = false;
|
|
6031
|
-
/**
|
|
6032
|
-
* Disable popover
|
|
6033
|
-
*/
|
|
6034
|
-
this.disabled = false;
|
|
6166
|
+
// Classes
|
|
6167
|
+
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
6035
6168
|
/**
|
|
6036
6169
|
* Check if clicked outside of component
|
|
6037
6170
|
*
|
|
@@ -6058,7 +6191,9 @@ const MgPopover = class {
|
|
|
6058
6191
|
// hide when click outside
|
|
6059
6192
|
// setTimeout is used to prevent event to trigger after creation
|
|
6060
6193
|
setTimeout(() => {
|
|
6061
|
-
|
|
6194
|
+
this.windows.forEach((localWindow) => {
|
|
6195
|
+
localWindow.addEventListener('click', this.clickOutside, false);
|
|
6196
|
+
});
|
|
6062
6197
|
}, 0);
|
|
6063
6198
|
};
|
|
6064
6199
|
/**
|
|
@@ -6072,7 +6207,9 @@ const MgPopover = class {
|
|
|
6072
6207
|
// Disable the event listeners
|
|
6073
6208
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
6074
6209
|
// Remove event listener
|
|
6075
|
-
|
|
6210
|
+
this.windows.forEach((localWindow) => {
|
|
6211
|
+
localWindow.removeEventListener('click', this.clickOutside, false);
|
|
6212
|
+
});
|
|
6076
6213
|
};
|
|
6077
6214
|
/**
|
|
6078
6215
|
* Handle action for close button
|
|
@@ -6082,6 +6219,19 @@ const MgPopover = class {
|
|
|
6082
6219
|
this.handleCloseButton = () => {
|
|
6083
6220
|
this.display = false;
|
|
6084
6221
|
};
|
|
6222
|
+
this.identifier = createID('mg-popover');
|
|
6223
|
+
this.placement = 'bottom';
|
|
6224
|
+
this.arrowHide = false;
|
|
6225
|
+
this.closeButton = false;
|
|
6226
|
+
this.display = false;
|
|
6227
|
+
this.disabled = false;
|
|
6228
|
+
this.classList = new ClassList(['mg-popover']);
|
|
6229
|
+
}
|
|
6230
|
+
validateArrowHide(newValue) {
|
|
6231
|
+
if (newValue)
|
|
6232
|
+
this.classList.add(this.classArrowHide);
|
|
6233
|
+
else
|
|
6234
|
+
this.classList.delete(this.classArrowHide);
|
|
6085
6235
|
}
|
|
6086
6236
|
handleDisplay(newValue) {
|
|
6087
6237
|
if (newValue) {
|
|
@@ -6101,8 +6251,11 @@ const MgPopover = class {
|
|
|
6101
6251
|
* @returns {void} timeout
|
|
6102
6252
|
*/
|
|
6103
6253
|
componentWillLoad() {
|
|
6254
|
+
// Get windows to attach events
|
|
6255
|
+
this.windows = getWindows(window);
|
|
6104
6256
|
// Get locales
|
|
6105
6257
|
this.messages = initLocales(this.element).messages;
|
|
6258
|
+
this.validateArrowHide(this.arrowHide);
|
|
6106
6259
|
}
|
|
6107
6260
|
/**
|
|
6108
6261
|
* Check if component props are well configured on init
|
|
@@ -6120,7 +6273,7 @@ const MgPopover = class {
|
|
|
6120
6273
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
6121
6274
|
}
|
|
6122
6275
|
// Get popover content
|
|
6123
|
-
this.popover = this.element.shadowRoot.
|
|
6276
|
+
this.popover = this.element.shadowRoot.getElementById(this.identifier);
|
|
6124
6277
|
//Get interactive element (first element without slot attribute)
|
|
6125
6278
|
const interactiveElement = this.element.querySelector(':not([slot])');
|
|
6126
6279
|
// Add aria attributes
|
|
@@ -6134,7 +6287,7 @@ const MgPopover = class {
|
|
|
6134
6287
|
{
|
|
6135
6288
|
name: 'offset',
|
|
6136
6289
|
options: {
|
|
6137
|
-
offset: [0,
|
|
6290
|
+
offset: [0, 0],
|
|
6138
6291
|
},
|
|
6139
6292
|
},
|
|
6140
6293
|
],
|
|
@@ -6157,15 +6310,71 @@ const MgPopover = class {
|
|
|
6157
6310
|
* @returns {HTMLElement} HTML Element
|
|
6158
6311
|
*/
|
|
6159
6312
|
render() {
|
|
6160
|
-
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: "mg-
|
|
6313
|
+
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: this.classList.join() }, index.h("mg-card", null, this.closeButton && (index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, index.h("mg-icon", { icon: "cross" }))), index.h("div", { class: "mg-popover__title" }, index.h("slot", { name: "title" })), index.h("slot", { name: "content" })), !this.arrowHide && index.h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
6161
6314
|
}
|
|
6162
6315
|
get element() { return index.getElement(this); }
|
|
6163
6316
|
static get watchers() { return {
|
|
6317
|
+
"arrowHide": ["validateArrowHide"],
|
|
6164
6318
|
"display": ["handleDisplay"]
|
|
6165
6319
|
}; }
|
|
6166
6320
|
};
|
|
6167
6321
|
MgPopover.style = mgPopoverCss;
|
|
6168
6322
|
|
|
6323
|
+
const mgSkipLinksCss = ".mg-skip-links{position:absolute;transform:translateY(-100%);opacity:0;background:hsl(var(--color-light))}.mg-skip-links:focus-within{position:relative;transform:translateY(0);opacity:1}.mg-skip-links__list{display:flex;flex-wrap:wrap;align-items:center;gap:0.6rem;margin:0;padding:0.64rem 1.8rem;list-style:none}.mg-skip-links__link{display:inline-block;padding:1.2rem;color:hsl(var(--color-dark))}.mg-skip-links__link:hover{background:hsl(var(--color-dark), 0.1)}";
|
|
6324
|
+
|
|
6325
|
+
const MgSkipLinks = class {
|
|
6326
|
+
constructor(hostRef) {
|
|
6327
|
+
index.registerInstance(this, hostRef);
|
|
6328
|
+
this.goToAnchor = index.createEvent(this, "go-to-anchor", 7);
|
|
6329
|
+
/***********
|
|
6330
|
+
* Methods *
|
|
6331
|
+
**********/
|
|
6332
|
+
/**
|
|
6333
|
+
* Handle link click and emit go-to-anchor event
|
|
6334
|
+
*
|
|
6335
|
+
* @param {MouseEvent} event mouse event
|
|
6336
|
+
* @returns {void}
|
|
6337
|
+
*/
|
|
6338
|
+
this.handleLinkCLick = (event) => {
|
|
6339
|
+
event.currentTarget.blur();
|
|
6340
|
+
this.goToAnchor.emit(event.currentTarget.getAttribute('href'));
|
|
6341
|
+
};
|
|
6342
|
+
this.links = undefined;
|
|
6343
|
+
}
|
|
6344
|
+
validateLinks(links) {
|
|
6345
|
+
if (links === undefined ||
|
|
6346
|
+
links.length === 0 ||
|
|
6347
|
+
links.some(link => link.href === undefined || !link.href.startsWith('#') || link.label === undefined || link.label.trim() === '')) {
|
|
6348
|
+
throw new Error(`<mg-skip-links> prop "links": Cannot be empty and each link must contains an href starting with a "#" and a non empty label attributes.`);
|
|
6349
|
+
}
|
|
6350
|
+
}
|
|
6351
|
+
/*************
|
|
6352
|
+
* Lifecycle *
|
|
6353
|
+
*************/
|
|
6354
|
+
/**
|
|
6355
|
+
* Check if props are well configured on init
|
|
6356
|
+
*
|
|
6357
|
+
* @returns {void}
|
|
6358
|
+
*/
|
|
6359
|
+
componentWillLoad() {
|
|
6360
|
+
this.validateLinks(this.links);
|
|
6361
|
+
this.messages = initLocales(this.element).messages;
|
|
6362
|
+
}
|
|
6363
|
+
/**
|
|
6364
|
+
* Render
|
|
6365
|
+
*
|
|
6366
|
+
* @returns {HTMLElement} HTML Element
|
|
6367
|
+
*/
|
|
6368
|
+
render() {
|
|
6369
|
+
return (index.h("nav", { class: "mg-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, index.h("ul", { class: "mg-skip-links__list" }, this.links.map(link => (index.h("li", null, index.h("a", { class: "mg-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
6370
|
+
}
|
|
6371
|
+
get element() { return index.getElement(this); }
|
|
6372
|
+
static get watchers() { return {
|
|
6373
|
+
"links": ["validateLinks"]
|
|
6374
|
+
}; }
|
|
6375
|
+
};
|
|
6376
|
+
MgSkipLinks.style = mgSkipLinksCss;
|
|
6377
|
+
|
|
6169
6378
|
/**
|
|
6170
6379
|
* Available tabs items status
|
|
6171
6380
|
*/
|
|
@@ -6181,7 +6390,7 @@ var Status;
|
|
|
6181
6390
|
*/
|
|
6182
6391
|
const sizes = ['regular', 'large'];
|
|
6183
6392
|
|
|
6184
|
-
const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular{padding:1rem 2rem}.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button ::slotted([slot=label]),.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button ::slotted([slot=metadata]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular ::slotted([slot=label]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular ::slotted([slot=metadata]){font-size:
|
|
6393
|
+
const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular{padding:1rem 2rem;height:calc()}.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button ::slotted([slot=label]),.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button ::slotted([slot=metadata]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular ::slotted([slot=label]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular ::slotted([slot=metadata]){font-size:var(--font-size)}.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button.mg-tabs__navigation-button--horizontal,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular.mg-tabs__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button.mg-tabs__navigation-button--vertical,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular.mg-tabs__navigation-button--vertical{padding-left:calc(2rem - 0.3rem)}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large{padding:1.5rem 3rem;height:calc()}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button,.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button ::slotted([slot=label]),.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button ::slotted([slot=metadata]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large ::slotted([slot=label]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large ::slotted([slot=metadata]){font-size:calc(var(--font-size) + 0.2rem)}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button.mg-tabs__navigation-button--horizontal,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large.mg-tabs__navigation-button--horizontal{padding-bottom:calc(1.5rem - 0.3rem)}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button.mg-tabs__navigation-button--vertical,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large.mg-tabs__navigation-button--vertical{padding-left:calc(3rem - 0.3rem)}.mg-tabs__navigation-button{display:flex;align-items:center;column-gap:var(--mg-tabs-navigation-button-column-gap, 1rem);background-color:unset;border:none;font-family:var(--font-family);color:hsl(var(--mg-tabs-color-hsl, var(--color-dark)));line-height:var(--line-height);text-decoration:none;white-space:nowrap;box-sizing:border-box;cursor:pointer}.mg-tabs__navigation-button:disabled,.mg-tabs__navigation-button--disabled{cursor:default;opacity:0.3}.mg-tabs__navigation-button:focus-visible{z-index:10}.mg-tabs__navigation-button:hover:not(.mg-tabs__navigation-button--disabled),.mg-tabs__navigation-button:focus-visible:not(.mg-tabs__navigation-button--disabled){background-color:hsl(var(--mg-tabs-focused-background-color-hsl), 0.1)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active{color:hsl(var(--mg-tabs-color-active-hsl));font-weight:600}.mg-tabs__navigation-button.mg-tabs__navigation-button--active.mg-tabs__navigation-button--horizontal{border-bottom-color:hsl(var(--mg-tabs-border-color-active-hsl))}.mg-tabs__navigation-button.mg-tabs__navigation-button--active.mg-tabs__navigation-button--vertical{border-left-color:hsl(var(--mg-tabs-border-color-active-hsl))}.mg-tabs__navigation-button.mg-tabs__navigation-button--hidden{display:none}.mg-tabs__navigation-button.mg-tabs__navigation-button--horizontal{border-bottom:0.3rem solid transparent}.mg-tabs__navigation-button.mg-tabs__navigation-button--vertical{border-left:0.3rem solid transparent}.mg-tabs__header{display:flex;flex-direction:row;flex-wrap:wrap}.mg-tabs__content-container:focus-visible{outline:none}.mg-tabs__navigation-button-text{flex:0 0 content}";
|
|
6185
6394
|
|
|
6186
6395
|
/**
|
|
6187
6396
|
* type TabItem validation function
|
|
@@ -6197,48 +6406,10 @@ const MgTabs = class {
|
|
|
6197
6406
|
/************
|
|
6198
6407
|
* Internal *
|
|
6199
6408
|
************/
|
|
6409
|
+
// classes
|
|
6200
6410
|
this.tabPanel = 'panel';
|
|
6201
|
-
this.startIndex = 1;
|
|
6202
6411
|
this.buttonTabBaseClass = 'mg-tabs__navigation-button';
|
|
6203
|
-
|
|
6204
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
6205
|
-
* If not set, it will be created.
|
|
6206
|
-
*/
|
|
6207
|
-
this.identifier = createID('mg-tabs');
|
|
6208
|
-
/**
|
|
6209
|
-
* Define tabs size
|
|
6210
|
-
*/
|
|
6211
|
-
this.size = 'regular';
|
|
6212
|
-
/**
|
|
6213
|
-
* Active tab number
|
|
6214
|
-
* default: first is 1
|
|
6215
|
-
*/
|
|
6216
|
-
this.activeTab = 1;
|
|
6217
|
-
/**
|
|
6218
|
-
* Component tabs
|
|
6219
|
-
*/
|
|
6220
|
-
this.tabs = [];
|
|
6221
|
-
/**
|
|
6222
|
-
* Component classes
|
|
6223
|
-
*/
|
|
6224
|
-
this.classList = new ClassList(['mg-tabs']);
|
|
6225
|
-
/**
|
|
6226
|
-
* Method to set active tab
|
|
6227
|
-
*
|
|
6228
|
-
* @param {number} tabKey item tab key to set to ACTIVE status
|
|
6229
|
-
* @returns {void}
|
|
6230
|
-
*/
|
|
6231
|
-
this.setActiveTab = (tabKey) => {
|
|
6232
|
-
// reset active tabs
|
|
6233
|
-
this.tabs.forEach(tab => {
|
|
6234
|
-
if (this.tabHasGivenStatus(tab, Status.ACTIVE))
|
|
6235
|
-
tab.status = Status.VISIBLE;
|
|
6236
|
-
});
|
|
6237
|
-
// set active tab from given tab key
|
|
6238
|
-
this.tabs[tabKey - this.startIndex].status = Status.ACTIVE;
|
|
6239
|
-
// emit change active tab key event
|
|
6240
|
-
this.activeTabChange.emit(tabKey);
|
|
6241
|
-
};
|
|
6412
|
+
this.startIndex = 1;
|
|
6242
6413
|
/**
|
|
6243
6414
|
* Method to know if given tab has the given status
|
|
6244
6415
|
*
|
|
@@ -6246,7 +6417,7 @@ const MgTabs = class {
|
|
|
6246
6417
|
* @param {Status} status status to valide
|
|
6247
6418
|
* @returns {boolean} status comparaison
|
|
6248
6419
|
*/
|
|
6249
|
-
this.
|
|
6420
|
+
this.tabHasStatus = (tab, status) => tab.status === status;
|
|
6250
6421
|
/**
|
|
6251
6422
|
* Method to get element id from index
|
|
6252
6423
|
*
|
|
@@ -6254,14 +6425,20 @@ const MgTabs = class {
|
|
|
6254
6425
|
* @param {number} index to generate id
|
|
6255
6426
|
* @returns {string} generated element id
|
|
6256
6427
|
*/
|
|
6257
|
-
this.getElementId = (element, index) => `${element}-${this.
|
|
6428
|
+
this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
|
|
6258
6429
|
/**
|
|
6259
|
-
* Method to get tab index
|
|
6430
|
+
* Method to get tab item index
|
|
6260
6431
|
*
|
|
6261
6432
|
* @param {number} index to get
|
|
6262
6433
|
* @returns {number} index
|
|
6263
6434
|
*/
|
|
6264
|
-
this.
|
|
6435
|
+
this.getTabItemIndex = (index) => index + this.startIndex;
|
|
6436
|
+
/**
|
|
6437
|
+
* Method to get the active-tab value
|
|
6438
|
+
*
|
|
6439
|
+
* @returns {number} of the active-tab
|
|
6440
|
+
*/
|
|
6441
|
+
this.getActiveTab = () => this.activeTab || this.getTabItemIndex(this.tabs.map((tab, index) => (Object.assign(Object.assign({}, tab), { index }))).find(tab => this.tabHasStatus(tab, Status.ACTIVE)).index);
|
|
6265
6442
|
/**
|
|
6266
6443
|
* Handle click events on tabs
|
|
6267
6444
|
*
|
|
@@ -6269,16 +6446,22 @@ const MgTabs = class {
|
|
|
6269
6446
|
*/
|
|
6270
6447
|
this.handleClick = (event) => {
|
|
6271
6448
|
const tabId = event.currentTarget.getAttribute('data-index');
|
|
6272
|
-
|
|
6449
|
+
const tab = this.tabs[Number(tabId) - this.startIndex];
|
|
6450
|
+
if (this.tabHasStatus(tab, Status.HIDDEN) || this.tabHasStatus(tab, Status.DISABLED)) {
|
|
6451
|
+
event.preventDefault();
|
|
6452
|
+
}
|
|
6453
|
+
else {
|
|
6454
|
+
this.activeTab = Number(tabId);
|
|
6455
|
+
this.tabFocus = undefined;
|
|
6456
|
+
}
|
|
6273
6457
|
};
|
|
6274
6458
|
/**
|
|
6275
6459
|
* get navigation button class from given status
|
|
6276
6460
|
*
|
|
6277
6461
|
* @param {Status} status button tab status
|
|
6278
|
-
* @param {boolean} isSelector set if we need a CSS selector with the dot '.' at the begin. default value = false.
|
|
6279
6462
|
* @returns {string} button class/selector variant
|
|
6280
6463
|
*/
|
|
6281
|
-
this.getNavigationButtonClass = (status
|
|
6464
|
+
this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
|
|
6282
6465
|
/**
|
|
6283
6466
|
* Handle keyboard event on tabs
|
|
6284
6467
|
*
|
|
@@ -6286,32 +6469,67 @@ const MgTabs = class {
|
|
|
6286
6469
|
* @returns {void}
|
|
6287
6470
|
*/
|
|
6288
6471
|
this.handleKeydown = (event) => {
|
|
6289
|
-
let tabId = Number(event.target.getAttribute('data-index'));
|
|
6290
6472
|
const parent = event.target.parentElement;
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6473
|
+
if (['ArrowRight', 'ArrowLeft'].includes(event.key)) {
|
|
6474
|
+
this.tabFocus = Number(event.target.getAttribute('data-index'));
|
|
6475
|
+
parent.querySelector(`[data-index="${this.tabFocus}"]`).setAttribute('tabindex', '-1');
|
|
6476
|
+
// Move right
|
|
6477
|
+
if (event.key === 'ArrowRight') {
|
|
6478
|
+
this.tabFocus++;
|
|
6479
|
+
// If we're at the end, go to the start
|
|
6480
|
+
if (this.tabFocus > this.tabs.length)
|
|
6481
|
+
this.tabFocus = this.startIndex;
|
|
6482
|
+
// Move left
|
|
6483
|
+
}
|
|
6484
|
+
else if (event.key === 'ArrowLeft') {
|
|
6485
|
+
this.tabFocus--;
|
|
6486
|
+
// If we're at the start, move to the end
|
|
6487
|
+
if (this.tabFocus < this.startIndex)
|
|
6488
|
+
this.tabFocus = this.tabs.length;
|
|
6489
|
+
}
|
|
6490
|
+
// if focus item is ['hidden'] we recursively repeat action
|
|
6491
|
+
if (this.tabHasStatus(this.tabs[this.tabFocus - 1], Status.HIDDEN)) {
|
|
6492
|
+
parent.querySelector(`[data-index="${this.tabFocus}"]`).dispatchEvent(new KeyboardEvent('keydown', { key: event.key, bubbles: true }));
|
|
6493
|
+
// else run focus methods on tabFocus element
|
|
6494
|
+
}
|
|
6495
|
+
else {
|
|
6496
|
+
parent.querySelector(`[data-index="${this.tabFocus}"]`).setAttribute('tabindex', '0');
|
|
6497
|
+
parent.querySelector(`[data-index="${this.tabFocus}"]`).focus();
|
|
6498
|
+
}
|
|
6297
6499
|
}
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
// apply selected tab if exist
|
|
6301
|
-
if (selectedTab !== null) {
|
|
6302
|
-
selectedTab.focus();
|
|
6303
|
-
this.activeTab = tabId;
|
|
6500
|
+
else if (event.key === 'Tab') {
|
|
6501
|
+
this.resetFocus();
|
|
6304
6502
|
}
|
|
6305
6503
|
};
|
|
6504
|
+
/**
|
|
6505
|
+
* Method to reset focus behavior
|
|
6506
|
+
*
|
|
6507
|
+
* @returns {void}
|
|
6508
|
+
*/
|
|
6509
|
+
this.resetFocus = () => {
|
|
6510
|
+
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
6511
|
+
setTimeout(() => {
|
|
6512
|
+
this.tabFocus = undefined;
|
|
6513
|
+
Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {
|
|
6514
|
+
tab.setAttribute('tabindex', this.getActiveTab() - this.startIndex !== index ? '-1' : '0');
|
|
6515
|
+
});
|
|
6516
|
+
}, 0);
|
|
6517
|
+
};
|
|
6306
6518
|
/**
|
|
6307
6519
|
* Validate slots setting
|
|
6308
6520
|
*/
|
|
6309
6521
|
this.validateSlots = () => {
|
|
6310
6522
|
const slots = Array.from(this.element.children).filter(slot => { var _a; return (_a = slot.getAttribute('slot')) === null || _a === void 0 ? void 0 : _a.includes('tab_content-'); });
|
|
6311
|
-
if (slots.length !== this.tabs.length)
|
|
6523
|
+
if (slots.length !== this.tabs.length)
|
|
6312
6524
|
throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
|
|
6313
|
-
}
|
|
6314
6525
|
};
|
|
6526
|
+
this.identifier = createID('mg-tabs');
|
|
6527
|
+
this.label = undefined;
|
|
6528
|
+
this.size = 'regular';
|
|
6529
|
+
this.items = undefined;
|
|
6530
|
+
this.activeTab = undefined;
|
|
6531
|
+
this.tabs = [];
|
|
6532
|
+
this.classList = new ClassList(['mg-tabs']);
|
|
6315
6533
|
}
|
|
6316
6534
|
validateLabel(newValue) {
|
|
6317
6535
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -6327,22 +6545,37 @@ const MgTabs = class {
|
|
|
6327
6545
|
validateItems(newValue) {
|
|
6328
6546
|
// String array
|
|
6329
6547
|
if (allItemsAreString(newValue)) {
|
|
6330
|
-
this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
|
|
6548
|
+
this.tabs = newValue.map((item, index) => ({ label: item, status: index === 0 ? Status.ACTIVE : Status.VISIBLE }));
|
|
6331
6549
|
}
|
|
6332
6550
|
// Object array
|
|
6333
|
-
else if (newValue && newValue.every(item => isTabItem(item))) {
|
|
6551
|
+
else if (newValue && newValue.length > 0 && newValue.every(item => isTabItem(item))) {
|
|
6334
6552
|
this.tabs = newValue;
|
|
6553
|
+
// init active tabs if not set. Default: index 0.
|
|
6554
|
+
if (this.tabs.find(tab => this.tabHasStatus(tab, Status.ACTIVE)) === undefined)
|
|
6555
|
+
this.tabs[0].status = Status.ACTIVE;
|
|
6335
6556
|
}
|
|
6336
6557
|
else {
|
|
6337
6558
|
throw new Error('<mg-tabs> prop "items" is required and all items must be the same type: TabItem.');
|
|
6338
6559
|
}
|
|
6339
6560
|
}
|
|
6340
6561
|
validateActiveTab(newValue) {
|
|
6341
|
-
if (newValue
|
|
6342
|
-
|
|
6562
|
+
if (typeof newValue === 'number' && newValue >= 1 && newValue <= this.tabs.length) {
|
|
6563
|
+
this.tabs.forEach((tab, index) => {
|
|
6564
|
+
const isNewActiveTab = index === newValue - this.startIndex;
|
|
6565
|
+
// reset active tabs
|
|
6566
|
+
if (this.tabHasStatus(tab, Status.ACTIVE) && !isNewActiveTab)
|
|
6567
|
+
tab.status = Status.VISIBLE;
|
|
6568
|
+
// set active tab from given tab key
|
|
6569
|
+
else if ((tab.status === undefined || this.tabHasStatus(tab, Status.VISIBLE)) && isNewActiveTab)
|
|
6570
|
+
tab.status = Status.ACTIVE;
|
|
6571
|
+
});
|
|
6572
|
+
// emit change active tab key event
|
|
6573
|
+
if (this.tabs.find(tab => this.tabHasStatus(tab, Status.ACTIVE)) !== undefined) {
|
|
6574
|
+
this.activeTabChange.emit(newValue);
|
|
6575
|
+
}
|
|
6343
6576
|
}
|
|
6344
|
-
else {
|
|
6345
|
-
|
|
6577
|
+
else if (newValue !== undefined) {
|
|
6578
|
+
throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
|
|
6346
6579
|
}
|
|
6347
6580
|
}
|
|
6348
6581
|
/*************
|
|
@@ -6361,6 +6594,17 @@ const MgTabs = class {
|
|
|
6361
6594
|
this.validateSize(this.size);
|
|
6362
6595
|
this.validateSlots();
|
|
6363
6596
|
}
|
|
6597
|
+
/**
|
|
6598
|
+
* add listners
|
|
6599
|
+
*
|
|
6600
|
+
* @returns {void}
|
|
6601
|
+
*/
|
|
6602
|
+
componentDidLoad() {
|
|
6603
|
+
document.addEventListener('click', (event) => {
|
|
6604
|
+
if (event.target.closest('mg-tabs') !== this.element)
|
|
6605
|
+
this.resetFocus();
|
|
6606
|
+
}, false);
|
|
6607
|
+
}
|
|
6364
6608
|
/**
|
|
6365
6609
|
* Render
|
|
6366
6610
|
*
|
|
@@ -6370,10 +6614,10 @@ const MgTabs = class {
|
|
|
6370
6614
|
return (index.h("div", { class: this.classList.join() }, index.h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index$1) => (index.h("button", { role: "tab", id: this.getElementId(this.identifier, index$1), class: {
|
|
6371
6615
|
[`${this.buttonTabBaseClass}`]: true,
|
|
6372
6616
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
6373
|
-
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.
|
|
6374
|
-
[`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.
|
|
6375
|
-
[`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.
|
|
6376
|
-
}, tabindex: this.
|
|
6617
|
+
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
6618
|
+
[`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasStatus(tab, Status.DISABLED),
|
|
6619
|
+
[`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasStatus(tab, Status.HIDDEN),
|
|
6620
|
+
}, tabindex: this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1, "aria-selected": this.tabHasStatus(tab, Status.ACTIVE).toString(), "aria-controls": this.getElementId(this.tabPanel, index$1), "aria-disabled": this.tabHasStatus(tab, Status.DISABLED), onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": this.getTabItemIndex(index$1) }, tab.icon !== undefined && index.h("mg-icon", { icon: tab.icon }), tab.label, tab.badge !== undefined && index.h("mg-badge", { variant: "text-color", value: tab.badge.value, label: tab.badge.label, outline: tab.badge.role === 'information' }))))), this.tabs.map((tab, index$1) => (index.h("article", { role: "tabpanel", id: this.getElementId(this.tabPanel, index$1), hidden: !this.tabHasStatus(tab, Status.ACTIVE), "aria-labelledby": this.getElementId(this.identifier, index$1), tabindex: this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1, class: "mg-tabs__content-container" }, index.h("slot", { name: this.getElementId('tab_content', index$1) }))))));
|
|
6377
6621
|
}
|
|
6378
6622
|
get element() { return index.getElement(this); }
|
|
6379
6623
|
static get watchers() { return {
|
|
@@ -6390,7 +6634,7 @@ MgTabs.style = mgTabsCss;
|
|
|
6390
6634
|
*/
|
|
6391
6635
|
const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
|
|
6392
6636
|
|
|
6393
|
-
const mgTagCss = ".mg-tag{padding:calc((var(--mg-tag-height) - 0.2rem - var(--mg-tag-font-size) * var(--line-height)) / 2) 0.6rem;min-height:var(--mg-tag-height);box-sizing:border-box;border-radius:var(--mg-tag-border-radius);border:0.1rem solid;font-size:var(--mg-tag-font-size);font-weight:600;text-align:center}.mg-tag.mg-tag--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-tag.mg-tag--primary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-tag.mg-tag--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-tag.mg-tag--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-tag.mg-tag--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-tag.mg-tag--danger.mg-tag--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-tag.mg-tag--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-tag.mg-tag--info.mg-tag--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-tag,mg-tag{display:inline-block;vertical-align:middle}";
|
|
6637
|
+
const mgTagCss = ".mg-tag{padding:calc((var(--mg-tag-height) - 0.2rem - var(--mg-tag-font-size) * var(--line-height)) / 2) 0.6rem;min-height:var(--mg-tag-height);box-sizing:border-box;border-radius:var(--mg-tag-border-radius);border:0.1rem solid;font-size:var(--mg-tag-font-size);font-weight:600;text-align:center}.mg-tag.mg-tag--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-tag.mg-tag--primary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-tag.mg-tag--primary.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-dark-h), var(--color-dark-s), 90%);border-color:hsl(var(--color-dark-h), var(--color-dark-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--primary.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-tag.mg-tag--secondary.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-light-h), var(--color-light-s), 90%);border-color:hsl(var(--color-light-h), var(--color-light-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-dark))}.mg-tag.mg-tag--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-tag.mg-tag--success.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-success-h), var(--color-success-s), 90%);border-color:hsl(var(--color-success-h), var(--color-success-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-success))}.mg-tag.mg-tag--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-tag.mg-tag--warning.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-warning-h), var(--color-warning-s), 90%);border-color:hsl(var(--color-warning-h), var(--color-warning-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-warning))}.mg-tag.mg-tag--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-tag.mg-tag--danger.mg-tag--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-tag.mg-tag--danger.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-danger-h), var(--color-danger-s), 90%);border-color:hsl(var(--color-danger-h), var(--color-danger-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--danger.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-danger))}.mg-tag.mg-tag--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-tag.mg-tag--info.mg-tag--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-tag.mg-tag--info.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-info-h), var(--color-info-s), 90%);border-color:hsl(var(--color-info-h), var(--color-info-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--info.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-info))}.mg-tag,mg-tag{display:inline-block;vertical-align:middle}::slotted(mg-icon){margin-right:0.4rem}";
|
|
6394
6638
|
|
|
6395
6639
|
const MgTag = class {
|
|
6396
6640
|
constructor(hostRef) {
|
|
@@ -6399,17 +6643,11 @@ const MgTag = class {
|
|
|
6399
6643
|
* Internal *
|
|
6400
6644
|
************/
|
|
6401
6645
|
// Classes
|
|
6402
|
-
this.classOutline =
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
* Define button variant
|
|
6408
|
-
*/
|
|
6409
|
-
this.variant = variants[0]; // primary
|
|
6410
|
-
/**
|
|
6411
|
-
* Component classes
|
|
6412
|
-
*/
|
|
6646
|
+
this.classOutline = 'mg-tag--outline';
|
|
6647
|
+
this.classSoft = 'mg-tag--soft';
|
|
6648
|
+
this.variant = variants[0];
|
|
6649
|
+
this.outline = undefined;
|
|
6650
|
+
this.soft = undefined;
|
|
6413
6651
|
this.classList = new ClassList(['mg-tag']);
|
|
6414
6652
|
}
|
|
6415
6653
|
validateVariant(newValue, oldValue) {
|
|
@@ -6429,6 +6667,29 @@ const MgTag = class {
|
|
|
6429
6667
|
else
|
|
6430
6668
|
this.classList.delete(this.classOutline);
|
|
6431
6669
|
}
|
|
6670
|
+
validateSoft(newValue) {
|
|
6671
|
+
// usage validation
|
|
6672
|
+
if (newValue && this.outline)
|
|
6673
|
+
throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
|
|
6674
|
+
// apply class
|
|
6675
|
+
if (newValue)
|
|
6676
|
+
this.classList.add(this.classSoft);
|
|
6677
|
+
else
|
|
6678
|
+
this.classList.delete(this.classSoft);
|
|
6679
|
+
}
|
|
6680
|
+
/*************
|
|
6681
|
+
* Methods *
|
|
6682
|
+
*************/
|
|
6683
|
+
/**
|
|
6684
|
+
* Validate the given textContent
|
|
6685
|
+
*
|
|
6686
|
+
* @param {string} textContent html element textContent property
|
|
6687
|
+
* @returns {void}
|
|
6688
|
+
*/
|
|
6689
|
+
validateTextContent(textContent) {
|
|
6690
|
+
if (typeof textContent !== 'string' || textContent.trim() === '')
|
|
6691
|
+
throw new Error('<mg-tag> slot must contain a text content.');
|
|
6692
|
+
}
|
|
6432
6693
|
/*************
|
|
6433
6694
|
* Lifecycle *
|
|
6434
6695
|
*************/
|
|
@@ -6440,6 +6701,8 @@ const MgTag = class {
|
|
|
6440
6701
|
componentWillLoad() {
|
|
6441
6702
|
this.validateVariant(this.variant);
|
|
6442
6703
|
this.validateOutline(this.outline);
|
|
6704
|
+
this.validateSoft(this.soft);
|
|
6705
|
+
this.validateTextContent(this.element.textContent);
|
|
6443
6706
|
}
|
|
6444
6707
|
/**
|
|
6445
6708
|
* Render
|
|
@@ -6449,9 +6712,11 @@ const MgTag = class {
|
|
|
6449
6712
|
render() {
|
|
6450
6713
|
return (index.h("span", { class: this.classList.join() }, index.h("slot", null)));
|
|
6451
6714
|
}
|
|
6715
|
+
get element() { return index.getElement(this); }
|
|
6452
6716
|
static get watchers() { return {
|
|
6453
6717
|
"variant": ["validateVariant"],
|
|
6454
|
-
"outline": ["validateOutline"]
|
|
6718
|
+
"outline": ["validateOutline"],
|
|
6719
|
+
"soft": ["validateSoft"]
|
|
6455
6720
|
}; }
|
|
6456
6721
|
};
|
|
6457
6722
|
MgTag.style = mgTagCss;
|
|
@@ -6463,28 +6728,11 @@ var Guard;
|
|
|
6463
6728
|
Guard["HOVER_TOOLTIPED_ELEMENT"] = "hoverTooltipedGuard";
|
|
6464
6729
|
})(Guard || (Guard = {}));
|
|
6465
6730
|
|
|
6466
|
-
const mgTooltipCss = ":host{display:inline-block}.mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:1000;border-radius:var(--mg-tooltip-border-radius);background-color:hsl(var(--mg-tooltip-background-color));color:hsl(var(--mg-tooltip-font-color));text-align:start}.mg-tooltip[data-show]{display:block}.mg-tooltip .mg-tooltip__arrow,.mg-tooltip .mg-tooltip__arrow::before{position:absolute;width:0.8rem;height:0.8rem;z-index:9999;background:inherit}.mg-tooltip .mg-tooltip__arrow{visibility:hidden}.mg-tooltip .mg-tooltip__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-tooltip[data-popper-placement^=top]>.mg-tooltip__arrow{bottom:-4px}.mg-tooltip[data-popper-placement^=bottom]>.mg-tooltip__arrow{top:-4px}.mg-tooltip[data-popper-placement^=left]>.mg-tooltip__arrow{right:-4px}.mg-tooltip[data-popper-placement^=right]>.mg-tooltip__arrow{left:-4px}";
|
|
6731
|
+
const mgTooltipCss = ":host{display:inline-block}.mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:1000;border-radius:var(--mg-tooltip-border-radius);background-color:hsl(var(--mg-tooltip-background-color));color:hsl(var(--mg-tooltip-font-color));text-align:start;max-width:40rem;box-sizing:border-box}.mg-tooltip[data-show]{display:block}.mg-tooltip .mg-tooltip__arrow,.mg-tooltip .mg-tooltip__arrow::before{position:absolute;width:0.8rem;height:0.8rem;z-index:9999;background:inherit}.mg-tooltip .mg-tooltip__arrow{visibility:hidden}.mg-tooltip .mg-tooltip__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-tooltip[data-popper-placement^=top]>.mg-tooltip__arrow{bottom:-4px}.mg-tooltip[data-popper-placement^=bottom]>.mg-tooltip__arrow{top:-4px}.mg-tooltip[data-popper-placement^=left]>.mg-tooltip__arrow{right:-4px}.mg-tooltip[data-popper-placement^=right]>.mg-tooltip__arrow{left:-4px}";
|
|
6467
6732
|
|
|
6468
6733
|
const MgTooltip = class {
|
|
6469
6734
|
constructor(hostRef) {
|
|
6470
6735
|
index.registerInstance(this, hostRef);
|
|
6471
|
-
/**
|
|
6472
|
-
* Sets an `id` attribute.
|
|
6473
|
-
* Needed by the input for accessibility `aria-decribedby`.
|
|
6474
|
-
*/
|
|
6475
|
-
this.identifier = createID('mg-tooltip');
|
|
6476
|
-
/**
|
|
6477
|
-
* Tooltip placement
|
|
6478
|
-
*/
|
|
6479
|
-
this.placement = 'bottom';
|
|
6480
|
-
/**
|
|
6481
|
-
* Display tooltip
|
|
6482
|
-
*/
|
|
6483
|
-
this.display = false;
|
|
6484
|
-
/**
|
|
6485
|
-
* Disable tooltip
|
|
6486
|
-
*/
|
|
6487
|
-
this.disabled = false;
|
|
6488
6736
|
/**
|
|
6489
6737
|
* Show tooltip
|
|
6490
6738
|
*
|
|
@@ -6538,7 +6786,7 @@ const MgTooltip = class {
|
|
|
6538
6786
|
this.resetGuard();
|
|
6539
6787
|
}, 100);
|
|
6540
6788
|
}
|
|
6541
|
-
else if (
|
|
6789
|
+
else if (this.guard === Guard.HOVER_TOOLTIPED_ELEMENT) {
|
|
6542
6790
|
this.setDisplay(isMouseenter);
|
|
6543
6791
|
}
|
|
6544
6792
|
}
|
|
@@ -6608,7 +6856,7 @@ const MgTooltip = class {
|
|
|
6608
6856
|
this.setDisplay(true);
|
|
6609
6857
|
});
|
|
6610
6858
|
['blur', 'keydown'].forEach(event => {
|
|
6611
|
-
|
|
6859
|
+
document.addEventListener(event, (e) => {
|
|
6612
6860
|
// we continue to process ONLY for KeyboardEvents 'Escape'
|
|
6613
6861
|
if (e.type === 'keydown' && e.code !== 'Escape') {
|
|
6614
6862
|
return;
|
|
@@ -6630,6 +6878,11 @@ const MgTooltip = class {
|
|
|
6630
6878
|
});
|
|
6631
6879
|
});
|
|
6632
6880
|
};
|
|
6881
|
+
this.identifier = createID('mg-tooltip');
|
|
6882
|
+
this.message = undefined;
|
|
6883
|
+
this.placement = 'bottom';
|
|
6884
|
+
this.display = false;
|
|
6885
|
+
this.disabled = false;
|
|
6633
6886
|
}
|
|
6634
6887
|
validateMessage(newValue) {
|
|
6635
6888
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -6662,8 +6915,7 @@ const MgTooltip = class {
|
|
|
6662
6915
|
const slotElement = this.element.firstElementChild;
|
|
6663
6916
|
// Get interactive element
|
|
6664
6917
|
const interactiveElements = ['a', 'button', 'input', 'textarea', 'select']; //! Might needs updates
|
|
6665
|
-
const interactiveElement = this.element.shadowRoot.querySelector(interactiveElements.join(',')) ||
|
|
6666
|
-
((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
|
|
6918
|
+
const interactiveElement = this.element.shadowRoot.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
|
|
6667
6919
|
// define selected element to become tooltip selector
|
|
6668
6920
|
this.tooltipedElement = interactiveElement || slotElement;
|
|
6669
6921
|
// Check if slotted element is a disabled mg-button
|
|
@@ -6688,7 +6940,7 @@ const MgTooltip = class {
|
|
|
6688
6940
|
* @returns {HTMLElement} HTML Element
|
|
6689
6941
|
*/
|
|
6690
6942
|
render() {
|
|
6691
|
-
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip", innerHTML: this.message }, index.h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|
|
6943
|
+
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip" }, index.h("span", { innerHTML: this.message }), index.h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|
|
6692
6944
|
}
|
|
6693
6945
|
get element() { return index.getElement(this); }
|
|
6694
6946
|
static get watchers() { return {
|
|
@@ -6724,6 +6976,7 @@ exports.mg_modal = MgModal;
|
|
|
6724
6976
|
exports.mg_pagination = MgPagination;
|
|
6725
6977
|
exports.mg_panel = MgPanel;
|
|
6726
6978
|
exports.mg_popover = MgPopover;
|
|
6979
|
+
exports.mg_skip_links = MgSkipLinks;
|
|
6727
6980
|
exports.mg_tabs = MgTabs;
|
|
6728
6981
|
exports.mg_tag = MgTag;
|
|
6729
6982
|
exports.mg_tooltip = MgTooltip;
|