@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
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-
|
|
1
|
+
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-dc9a2348.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* List of all possibles variants
|
|
5
5
|
*/
|
|
6
|
-
const variants$4 = ['info', 'primary', 'secondary', 'success', 'warning', 'danger'];
|
|
6
|
+
const variants$4 = ['info', 'primary', 'secondary', 'success', 'warning', 'danger', 'text-color'];
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Create random ID
|
|
@@ -93,8 +93,58 @@ const isTagName = (element, tagNames) => {
|
|
|
93
93
|
* Focusable elements query selector
|
|
94
94
|
*/
|
|
95
95
|
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @param {Window} localWindow the window we are lookink for other windows
|
|
99
|
+
* @returns {Window[]} The list of windows found
|
|
100
|
+
*/
|
|
101
|
+
const getWindows = (localWindow) => {
|
|
102
|
+
const parentWindows = getParentWindows(localWindow);
|
|
103
|
+
const childWindows = getChildWindows(localWindow);
|
|
104
|
+
return [localWindow, ...parentWindows, ...childWindows];
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Get parent windows
|
|
108
|
+
*
|
|
109
|
+
* @param {Window} localWindow the window we are lookink for parents
|
|
110
|
+
* @param {Window[]} windows The list of allready found windows
|
|
111
|
+
* @returns {Window[]} The list of windows found
|
|
112
|
+
*/
|
|
113
|
+
const getParentWindows = (localWindow, windows = []) => {
|
|
114
|
+
// Check if is in iframe
|
|
115
|
+
if (localWindow.self !== localWindow.top) {
|
|
116
|
+
// Check if we have permission to access parent
|
|
117
|
+
try {
|
|
118
|
+
const parentWindow = localWindow.parent;
|
|
119
|
+
windows.push(parentWindow);
|
|
120
|
+
return getParentWindows(parentWindow, windows);
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
console.error('Different hosts between iframes:', err);
|
|
124
|
+
return windows;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return windows;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Get child windows
|
|
131
|
+
*
|
|
132
|
+
* @param {Window} localWindow the window we are lookink for children
|
|
133
|
+
* @param {Window[]} windows The list of allready found windows
|
|
134
|
+
* @returns {Window[]} The list of windows found
|
|
135
|
+
*/
|
|
136
|
+
const getChildWindows = (localWindow, windows = []) => {
|
|
137
|
+
if (localWindow.frames.length > 0) {
|
|
138
|
+
for (let i = 0; i < localWindow.frames.length; i++) {
|
|
139
|
+
const childWindow = localWindow.frames[i];
|
|
140
|
+
windows.push(childWindow);
|
|
141
|
+
windows.concat(getChildWindows(childWindow, windows));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return windows;
|
|
145
|
+
};
|
|
96
146
|
|
|
97
|
-
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}";
|
|
147
|
+
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}";
|
|
98
148
|
|
|
99
149
|
const MgBadge = class {
|
|
100
150
|
constructor(hostRef) {
|
|
@@ -104,18 +154,15 @@ const MgBadge = class {
|
|
|
104
154
|
************/
|
|
105
155
|
// Classes
|
|
106
156
|
this.classOutline = `mg-badge--outline`;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.
|
|
111
|
-
/**
|
|
112
|
-
* Component classes
|
|
113
|
-
*/
|
|
157
|
+
this.value = undefined;
|
|
158
|
+
this.label = undefined;
|
|
159
|
+
this.variant = variants$4[0];
|
|
160
|
+
this.outline = undefined;
|
|
114
161
|
this.classList = new ClassList(['mg-badge']);
|
|
115
162
|
}
|
|
116
163
|
validateValue(newValue) {
|
|
117
164
|
if (`${newValue}`.match(/^(\d+\+*|[?*!a-z])$/i) === null) {
|
|
118
|
-
throw new Error('<mg-badge> prop "value" must be
|
|
165
|
+
throw new Error('<mg-badge> prop "value" must be integer or ponctuation character.');
|
|
119
166
|
}
|
|
120
167
|
}
|
|
121
168
|
validateLabel(newValue) {
|
|
@@ -157,7 +204,7 @@ const MgBadge = class {
|
|
|
157
204
|
* @returns {HTMLElement} HTML Element
|
|
158
205
|
*/
|
|
159
206
|
render() {
|
|
160
|
-
return (h("span", { class: this.classList.join() }, this.value, h("span", { class: "sr-only" }, this.label)));
|
|
207
|
+
return (h("span", { class: this.classList.join() }, h("span", { class: "mg-badge__value" }, this.value), h("span", { class: "sr-only" }, this.label)));
|
|
161
208
|
}
|
|
162
209
|
static get watchers() { return {
|
|
163
210
|
"value": ["validateValue"],
|
|
@@ -171,9 +218,9 @@ MgBadge.style = mgBadgeCss;
|
|
|
171
218
|
/**
|
|
172
219
|
* List of all possibles variants
|
|
173
220
|
*/
|
|
174
|
-
const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success'];
|
|
221
|
+
const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success', 'link'];
|
|
175
222
|
|
|
176
|
-
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:
|
|
223
|
+
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}";
|
|
177
224
|
|
|
178
225
|
const MgButton = class {
|
|
179
226
|
constructor(hostRef) {
|
|
@@ -185,34 +232,6 @@ const MgButton = class {
|
|
|
185
232
|
this.classDisabled = 'mg-button--disabled';
|
|
186
233
|
this.classLoading = 'mg-button--loading';
|
|
187
234
|
this.classFullWidth = 'mg-button--full-width';
|
|
188
|
-
/**
|
|
189
|
-
* Define button variant
|
|
190
|
-
*/
|
|
191
|
-
this.variant = variants$3[0]; // Primary
|
|
192
|
-
/**
|
|
193
|
-
* Set button to full-width
|
|
194
|
-
*/
|
|
195
|
-
this.fullWidth = false;
|
|
196
|
-
/**
|
|
197
|
-
* Define if button is round.
|
|
198
|
-
* Used for icon button.
|
|
199
|
-
*/
|
|
200
|
-
this.isIcon = false;
|
|
201
|
-
/**
|
|
202
|
-
* Option to set input disable on click, in order to prevent multi-click.
|
|
203
|
-
* Parent component have to remove the attribute 'disabled' when the process ends.
|
|
204
|
-
*/
|
|
205
|
-
this.disableOnClick = false;
|
|
206
|
-
/**
|
|
207
|
-
* Define if button is loading, default to false.
|
|
208
|
-
* Trigger when button is clicked or key-up ['enter', 'space], then value change to true.
|
|
209
|
-
* It's required to reset to false when action/promise in parent is done to stop the loading state
|
|
210
|
-
*/
|
|
211
|
-
this.loading = false;
|
|
212
|
-
/**
|
|
213
|
-
* Component classes
|
|
214
|
-
*/
|
|
215
|
-
this.classList = new ClassList(['mg-button']);
|
|
216
235
|
/**
|
|
217
236
|
* Trigger actions onClick event
|
|
218
237
|
*
|
|
@@ -255,6 +274,17 @@ const MgButton = class {
|
|
|
255
274
|
this.element.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
256
275
|
}
|
|
257
276
|
};
|
|
277
|
+
this.variant = variants$3[0];
|
|
278
|
+
this.identifier = undefined;
|
|
279
|
+
this.label = undefined;
|
|
280
|
+
this.type = undefined;
|
|
281
|
+
this.fullWidth = false;
|
|
282
|
+
this.form = undefined;
|
|
283
|
+
this.disabled = undefined;
|
|
284
|
+
this.isIcon = false;
|
|
285
|
+
this.disableOnClick = false;
|
|
286
|
+
this.loading = false;
|
|
287
|
+
this.classList = new ClassList(['mg-button']);
|
|
258
288
|
}
|
|
259
289
|
validateVariant(newValue, oldValue) {
|
|
260
290
|
if (!variants$3.includes(newValue)) {
|
|
@@ -339,7 +369,7 @@ const MgButton = class {
|
|
|
339
369
|
};
|
|
340
370
|
MgButton.style = mgButtonCss;
|
|
341
371
|
|
|
342
|
-
const mgCardCss = ".mg-card{padding:var(--mg-card-padding);border-radius:var(--mg-card-border-radius);
|
|
372
|
+
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)}";
|
|
343
373
|
|
|
344
374
|
const MgCard = class {
|
|
345
375
|
constructor(hostRef) {
|
|
@@ -400,6 +430,9 @@ const pagination$1 = {
|
|
|
400
430
|
const panel$1 = {
|
|
401
431
|
editLabel: "Edit section title."
|
|
402
432
|
};
|
|
433
|
+
const skipLinks$1 = {
|
|
434
|
+
navLabel: "Quick access"
|
|
435
|
+
};
|
|
403
436
|
const general$1 = {
|
|
404
437
|
confirm: "Confirm",
|
|
405
438
|
cancel: "Cancel",
|
|
@@ -407,6 +440,10 @@ const general$1 = {
|
|
|
407
440
|
next: "next",
|
|
408
441
|
previous: "previous"
|
|
409
442
|
};
|
|
443
|
+
const plusMenu$1 = {
|
|
444
|
+
moreLabel: "Additional menu",
|
|
445
|
+
badgeLabel: "Include notification(s)"
|
|
446
|
+
};
|
|
410
447
|
const en = {
|
|
411
448
|
errors: errors$1,
|
|
412
449
|
nbCharLeft: nbCharLeft$1,
|
|
@@ -416,7 +453,9 @@ const en = {
|
|
|
416
453
|
modal: modal$1,
|
|
417
454
|
pagination: pagination$1,
|
|
418
455
|
panel: panel$1,
|
|
419
|
-
|
|
456
|
+
skipLinks: skipLinks$1,
|
|
457
|
+
general: general$1,
|
|
458
|
+
plusMenu: plusMenu$1
|
|
420
459
|
};
|
|
421
460
|
|
|
422
461
|
const errors = {
|
|
@@ -460,6 +499,9 @@ const pagination = {
|
|
|
460
499
|
const panel = {
|
|
461
500
|
editLabel: "Modifier le titre de la section."
|
|
462
501
|
};
|
|
502
|
+
const skipLinks = {
|
|
503
|
+
navLabel: "Accès rapide"
|
|
504
|
+
};
|
|
463
505
|
const general = {
|
|
464
506
|
confirm: "Valider",
|
|
465
507
|
cancel: "Annuler",
|
|
@@ -467,6 +509,10 @@ const general = {
|
|
|
467
509
|
next: "suivant",
|
|
468
510
|
previous: "précédent"
|
|
469
511
|
};
|
|
512
|
+
const plusMenu = {
|
|
513
|
+
moreLabel: "Menu complémentaire",
|
|
514
|
+
badgeLabel: "Notification(s) incluse(s)"
|
|
515
|
+
};
|
|
470
516
|
const fr = {
|
|
471
517
|
errors: errors,
|
|
472
518
|
nbCharLeft: nbCharLeft,
|
|
@@ -476,34 +522,63 @@ const fr = {
|
|
|
476
522
|
modal: modal,
|
|
477
523
|
pagination: pagination,
|
|
478
524
|
panel: panel,
|
|
479
|
-
|
|
525
|
+
skipLinks: skipLinks,
|
|
526
|
+
general: general,
|
|
527
|
+
plusMenu: plusMenu
|
|
480
528
|
};
|
|
481
529
|
|
|
482
|
-
const defaultLocale = 'en';
|
|
483
|
-
const messages = { en, fr };
|
|
484
530
|
/**
|
|
485
|
-
*
|
|
531
|
+
* Format number to the locale currency
|
|
486
532
|
*
|
|
487
|
-
* @param {
|
|
488
|
-
* @
|
|
533
|
+
* @param {number} number number to format
|
|
534
|
+
* @param {string} locale locale to apply
|
|
535
|
+
* @param {string} currency currency to apply
|
|
536
|
+
* @returns {string} formatted currency
|
|
489
537
|
*/
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
const closestLang = Intl.NumberFormat.supportedLocalesOf((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang);
|
|
494
|
-
return closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;
|
|
495
|
-
};
|
|
538
|
+
function localeCurrency(number, locale, currency) {
|
|
539
|
+
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
|
|
540
|
+
}
|
|
496
541
|
/**
|
|
497
|
-
*
|
|
542
|
+
* Format number to locale
|
|
543
|
+
*
|
|
544
|
+
* @param {number} number number to format
|
|
545
|
+
* @param {string} locale locale to apply
|
|
546
|
+
* @returns {string} formatted number
|
|
547
|
+
*/
|
|
548
|
+
function localeNumber(number, locale) {
|
|
549
|
+
return new Intl.NumberFormat(locale).format(number);
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Date RegExp
|
|
553
|
+
*/
|
|
554
|
+
const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
555
|
+
/**
|
|
556
|
+
* Locale date format
|
|
557
|
+
*
|
|
558
|
+
* @param {string} date date to format
|
|
559
|
+
* @param {string} locale locale to apply
|
|
560
|
+
* @returns {string} formatted date
|
|
561
|
+
*/
|
|
562
|
+
function localeDate(date, locale) {
|
|
563
|
+
if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
|
|
564
|
+
return '';
|
|
565
|
+
}
|
|
566
|
+
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Get locale and messages
|
|
498
570
|
* We load the defined locale but for now we only support the first subtag for messages
|
|
499
571
|
*
|
|
500
572
|
* @param {HTMLElement} element element we need to get the language
|
|
573
|
+
* @param {unknown} messages messages to use
|
|
574
|
+
* @param {string} defaultLocale default messages locale
|
|
501
575
|
* @returns {{ locale: string; messages: unknown }} messages object
|
|
502
576
|
*/
|
|
503
|
-
|
|
504
|
-
|
|
577
|
+
const getLocaleMessages = (element, messages, defaultLocale) => {
|
|
578
|
+
var _a;
|
|
505
579
|
// Get local
|
|
506
|
-
const
|
|
580
|
+
const closestLang = Intl.NumberFormat.supportedLocalesOf((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang);
|
|
581
|
+
const locale = closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;
|
|
507
582
|
// Only keep first subtag
|
|
508
583
|
const localeSubtag = locale.split('-').shift();
|
|
509
584
|
// Return
|
|
@@ -513,15 +588,24 @@ const initLocales = (element) => {
|
|
|
513
588
|
};
|
|
514
589
|
};
|
|
515
590
|
|
|
591
|
+
const defaultLocale = 'en';
|
|
592
|
+
const messages = { en, fr };
|
|
593
|
+
/**
|
|
594
|
+
* Get Intl object
|
|
595
|
+
*
|
|
596
|
+
* @param {HTMLElement} element element we need to get the language
|
|
597
|
+
* @returns {{ locale: string; messages: unknown }} messages object
|
|
598
|
+
*/
|
|
599
|
+
const initLocales = (element) => getLocaleMessages(element, messages, defaultLocale);
|
|
600
|
+
|
|
516
601
|
const mgCharacterLeftCss = "mg-character-left.sc-mg-character-left{display:block}";
|
|
517
602
|
|
|
518
603
|
const MgCharacterLeft = class {
|
|
519
604
|
constructor(hostRef) {
|
|
520
605
|
registerInstance(this, hostRef);
|
|
521
|
-
|
|
522
|
-
* Sets the characters to count
|
|
523
|
-
*/
|
|
606
|
+
this.identifier = undefined;
|
|
524
607
|
this.characters = '';
|
|
608
|
+
this.maxlength = undefined;
|
|
525
609
|
}
|
|
526
610
|
validateMaxlength(newValue) {
|
|
527
611
|
if (typeof newValue !== 'number') {
|
|
@@ -561,14 +645,6 @@ const MgDetails = class {
|
|
|
561
645
|
constructor(hostRef) {
|
|
562
646
|
registerInstance(this, hostRef);
|
|
563
647
|
this.expandedChange = createEvent(this, "expanded-change", 7);
|
|
564
|
-
/**
|
|
565
|
-
* Hide summary element
|
|
566
|
-
*/
|
|
567
|
-
this.hideSummary = false;
|
|
568
|
-
/**
|
|
569
|
-
* Define if details are diplayed
|
|
570
|
-
*/
|
|
571
|
-
this.expanded = false;
|
|
572
648
|
/**
|
|
573
649
|
* Handle details toggle
|
|
574
650
|
*
|
|
@@ -577,6 +653,10 @@ const MgDetails = class {
|
|
|
577
653
|
this.handleToggle = () => {
|
|
578
654
|
this.expanded = this.details.open;
|
|
579
655
|
};
|
|
656
|
+
this.toggleClosed = undefined;
|
|
657
|
+
this.toggleOpened = undefined;
|
|
658
|
+
this.hideSummary = false;
|
|
659
|
+
this.expanded = false;
|
|
580
660
|
}
|
|
581
661
|
validateTitles(newValue) {
|
|
582
662
|
if (newValue === undefined || newValue.trim() === '') {
|
|
@@ -619,12 +699,6 @@ const mgDividerCss = ".mg-divider{margin:var(--mg-divider-vertical-spacing) auto
|
|
|
619
699
|
const MgDivider = class {
|
|
620
700
|
constructor(hostRef) {
|
|
621
701
|
registerInstance(this, hostRef);
|
|
622
|
-
/**************
|
|
623
|
-
* Decorators *
|
|
624
|
-
**************/
|
|
625
|
-
/**
|
|
626
|
-
* Define component size
|
|
627
|
-
*/
|
|
628
702
|
this.size = 'regular';
|
|
629
703
|
}
|
|
630
704
|
/**
|
|
@@ -650,28 +724,6 @@ const MgForm = class {
|
|
|
650
724
|
this.formSubmit = createEvent(this, "form-submit", 7);
|
|
651
725
|
// Classes
|
|
652
726
|
this.classAllRequired = 'mg-form--all-required';
|
|
653
|
-
/**
|
|
654
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
655
|
-
* If not set, it will be created.
|
|
656
|
-
*/
|
|
657
|
-
this.identifier = createID('mg-form');
|
|
658
|
-
/**
|
|
659
|
-
* Input name
|
|
660
|
-
* If not set the value equals the identifier
|
|
661
|
-
*/
|
|
662
|
-
this.name = this.identifier;
|
|
663
|
-
/**
|
|
664
|
-
* Define if form is readonly
|
|
665
|
-
*/
|
|
666
|
-
this.readonly = false;
|
|
667
|
-
/**
|
|
668
|
-
* Define if form is disabled
|
|
669
|
-
*/
|
|
670
|
-
this.disabled = false;
|
|
671
|
-
/**
|
|
672
|
-
* Component classes
|
|
673
|
-
*/
|
|
674
|
-
this.classList = new ClassList(['mg-form']);
|
|
675
727
|
/**
|
|
676
728
|
* Define required message based on mg-inputs required elements
|
|
677
729
|
* Also
|
|
@@ -741,6 +793,14 @@ const MgForm = class {
|
|
|
741
793
|
input.addEventListener('input-valid', this.checkValidity);
|
|
742
794
|
});
|
|
743
795
|
};
|
|
796
|
+
this.identifier = createID('mg-form');
|
|
797
|
+
this.name = this.identifier;
|
|
798
|
+
this.readonly = false;
|
|
799
|
+
this.disabled = false;
|
|
800
|
+
this.valid = undefined;
|
|
801
|
+
this.invalid = undefined;
|
|
802
|
+
this.classList = new ClassList(['mg-form']);
|
|
803
|
+
this.requiredMessage = undefined;
|
|
744
804
|
}
|
|
745
805
|
handleAttributeChange() {
|
|
746
806
|
this.setMgInputs();
|
|
@@ -838,6 +898,7 @@ const icons = {
|
|
|
838
898
|
'archive': () => (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" })),
|
|
839
899
|
'archive-outline': () => (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" })),
|
|
840
900
|
'arrow-down': () => (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" })),
|
|
901
|
+
'arrow-down-a-z': () => (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" })),
|
|
841
902
|
'arrow-down-right': () => (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" })),
|
|
842
903
|
'arrow-left': () => (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" })),
|
|
843
904
|
'arrow-right': () => (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" })),
|
|
@@ -846,6 +907,7 @@ const icons = {
|
|
|
846
907
|
'arrow-up': () => (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" })),
|
|
847
908
|
'arrow-up-right': () => (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" })),
|
|
848
909
|
'arrow-up-right-square': () => (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" })),
|
|
910
|
+
'arrow-up-z-a': () => (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" })),
|
|
849
911
|
'arrows-compare': () => 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" }),
|
|
850
912
|
'arrows-right-down': () => (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" })),
|
|
851
913
|
'arrows-right-left': () => (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" })),
|
|
@@ -856,8 +918,13 @@ const icons = {
|
|
|
856
918
|
'briefcase': () => (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" })),
|
|
857
919
|
'briefcase-outline': () => (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" })),
|
|
858
920
|
'calculator': () => (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" })),
|
|
859
|
-
'calendar': () => (h("path", { fill: "currentColor", d: "M14
|
|
860
|
-
'calendar-
|
|
921
|
+
'calendar': () => (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" })),
|
|
922
|
+
'calendar-outline': () => (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" })),
|
|
923
|
+
'calendar-euro': () => [
|
|
924
|
+
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" }),
|
|
925
|
+
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" }),
|
|
926
|
+
],
|
|
927
|
+
'calendar-euro-outline': () => (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" })),
|
|
861
928
|
'check': () => (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" })),
|
|
862
929
|
'check-circle': () => (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" })),
|
|
863
930
|
'chevron-down': () => (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" })),
|
|
@@ -869,6 +936,8 @@ const icons = {
|
|
|
869
936
|
'chevron-up': () => (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" })),
|
|
870
937
|
'chevron-up-circle': () => (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" })),
|
|
871
938
|
'clock': () => (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" })),
|
|
939
|
+
'clock-outline': () => (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" })),
|
|
940
|
+
'code-square-outline': () => (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" })),
|
|
872
941
|
'conversation': () => (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" })),
|
|
873
942
|
'conversation-outline': () => [
|
|
874
943
|
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" }),
|
|
@@ -886,9 +955,10 @@ const icons = {
|
|
|
886
955
|
'download': () => (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" })),
|
|
887
956
|
'ellipsis': () => (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" })),
|
|
888
957
|
'ellipsis-vertical': () => (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" })),
|
|
889
|
-
'euro': () => (h("path", { fill: "currentColor", d: "
|
|
958
|
+
'euro': () => (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" })),
|
|
890
959
|
'euro-circle': () => (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" })),
|
|
891
960
|
'exclamation-circle': () => (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" })),
|
|
961
|
+
'exclamation-stamp': () => (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" })),
|
|
892
962
|
'exclamation-triangle': () => (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" })),
|
|
893
963
|
'eye': () => [
|
|
894
964
|
h("circle", { fill: "currentColor", cx: "8.01", cy: "7.96", r: "2.44" }),
|
|
@@ -1011,24 +1081,17 @@ const mgIconCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !i
|
|
|
1011
1081
|
const MgIcon = class {
|
|
1012
1082
|
constructor(hostRef) {
|
|
1013
1083
|
registerInstance(this, hostRef);
|
|
1014
|
-
/**
|
|
1015
|
-
* Define icon size
|
|
1016
|
-
*/
|
|
1017
|
-
this.size = 'regular';
|
|
1018
|
-
/**
|
|
1019
|
-
* Make the icon spin
|
|
1020
|
-
*/
|
|
1021
|
-
this.spin = false;
|
|
1022
|
-
/**
|
|
1023
|
-
* Component classes
|
|
1024
|
-
*/
|
|
1025
|
-
this.classList = new ClassList(['mg-icon']);
|
|
1026
1084
|
/**
|
|
1027
1085
|
* getIcon
|
|
1028
1086
|
*
|
|
1029
1087
|
* @returns {HTMLElement} icon html
|
|
1030
1088
|
*/
|
|
1031
1089
|
this.getIcon = () => icons[this.icon]();
|
|
1090
|
+
this.icon = undefined;
|
|
1091
|
+
this.size = 'regular';
|
|
1092
|
+
this.variant = undefined;
|
|
1093
|
+
this.spin = false;
|
|
1094
|
+
this.classList = new ClassList(['mg-icon']);
|
|
1032
1095
|
}
|
|
1033
1096
|
validateIcon(newValue, oldValue) {
|
|
1034
1097
|
if (!Object.keys(icons).includes(newValue)) {
|
|
@@ -1101,18 +1164,12 @@ const MgIcon = class {
|
|
|
1101
1164
|
};
|
|
1102
1165
|
MgIcon.style = mgIconCss;
|
|
1103
1166
|
|
|
1104
|
-
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:
|
|
1167
|
+
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}";
|
|
1105
1168
|
|
|
1106
1169
|
const MgIllustratedMessage = class {
|
|
1107
1170
|
constructor(hostRef) {
|
|
1108
1171
|
registerInstance(this, hostRef);
|
|
1109
|
-
/**
|
|
1110
|
-
* Define illustration size
|
|
1111
|
-
*/
|
|
1112
1172
|
this.size = 'regular';
|
|
1113
|
-
/**
|
|
1114
|
-
* Define component orientation
|
|
1115
|
-
*/
|
|
1116
1173
|
this.direction = 'vertical';
|
|
1117
1174
|
}
|
|
1118
1175
|
/*************
|
|
@@ -1125,13 +1182,14 @@ const MgIllustratedMessage = class {
|
|
|
1125
1182
|
*/
|
|
1126
1183
|
componentDidLoad() {
|
|
1127
1184
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
1128
|
-
const
|
|
1185
|
+
const slottedIllustrations = this.element.querySelectorAll('[slot="illustration"]');
|
|
1129
1186
|
if (!isTagName(this.element.querySelector('[slot="title"]'), headingTags)) {
|
|
1130
1187
|
throw new Error(`<mg-illustrated-message> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
1131
1188
|
}
|
|
1132
|
-
else if (
|
|
1133
|
-
throw new Error(
|
|
1189
|
+
else if (slottedIllustrations.length !== 1) {
|
|
1190
|
+
throw new Error('<mg-illustrated-message> Slotted illustration must be present and unique.');
|
|
1134
1191
|
}
|
|
1192
|
+
slottedIllustrations[0].setAttribute('aria-hidden', 'true');
|
|
1135
1193
|
}
|
|
1136
1194
|
/**
|
|
1137
1195
|
* Render
|
|
@@ -1293,39 +1351,6 @@ const MgInputCheckbox = class {
|
|
|
1293
1351
|
this.inputs = [];
|
|
1294
1352
|
// hasDisplayedError (triggered by blur event)
|
|
1295
1353
|
this.hasDisplayedError = false;
|
|
1296
|
-
/**
|
|
1297
|
-
* Input name
|
|
1298
|
-
* If not set the value equals the identifier
|
|
1299
|
-
*/
|
|
1300
|
-
this.name = this.identifier;
|
|
1301
|
-
/**
|
|
1302
|
-
* Define if label is visible
|
|
1303
|
-
*/
|
|
1304
|
-
this.labelHide = false;
|
|
1305
|
-
/**
|
|
1306
|
-
* Define if inputs are display verticaly
|
|
1307
|
-
*/
|
|
1308
|
-
this.inputVerticalList = false;
|
|
1309
|
-
/**
|
|
1310
|
-
* Define if input is required
|
|
1311
|
-
*/
|
|
1312
|
-
this.required = false;
|
|
1313
|
-
/**
|
|
1314
|
-
* Define if input is readonly
|
|
1315
|
-
*/
|
|
1316
|
-
this.readonly = false;
|
|
1317
|
-
/**
|
|
1318
|
-
* Define if input is disabled
|
|
1319
|
-
*/
|
|
1320
|
-
this.disabled = false;
|
|
1321
|
-
/**
|
|
1322
|
-
* Component classes
|
|
1323
|
-
*/
|
|
1324
|
-
this.classList = new ClassList(['mg-input--checkbox']);
|
|
1325
|
-
/**
|
|
1326
|
-
* Formated value for display
|
|
1327
|
-
*/
|
|
1328
|
-
this.checkboxItems = [];
|
|
1329
1354
|
/**
|
|
1330
1355
|
* Handle input event
|
|
1331
1356
|
*
|
|
@@ -1375,6 +1400,23 @@ const MgInputCheckbox = class {
|
|
|
1375
1400
|
this.errorMessage = this.messages.errors.required;
|
|
1376
1401
|
}
|
|
1377
1402
|
};
|
|
1403
|
+
this.value = undefined;
|
|
1404
|
+
this.identifier = undefined;
|
|
1405
|
+
this.name = this.identifier;
|
|
1406
|
+
this.label = undefined;
|
|
1407
|
+
this.labelOnTop = undefined;
|
|
1408
|
+
this.labelHide = false;
|
|
1409
|
+
this.inputVerticalList = false;
|
|
1410
|
+
this.required = false;
|
|
1411
|
+
this.readonly = false;
|
|
1412
|
+
this.disabled = false;
|
|
1413
|
+
this.tooltip = undefined;
|
|
1414
|
+
this.helpText = undefined;
|
|
1415
|
+
this.valid = undefined;
|
|
1416
|
+
this.invalid = undefined;
|
|
1417
|
+
this.classList = new ClassList(['mg-input--checkbox']);
|
|
1418
|
+
this.errorMessage = undefined;
|
|
1419
|
+
this.checkboxItems = [];
|
|
1378
1420
|
}
|
|
1379
1421
|
validateValue(newValue) {
|
|
1380
1422
|
if (newValue && newValue.every(item => isCheckboxItem(item))) {
|
|
@@ -1463,46 +1505,7 @@ var InputError$1;
|
|
|
1463
1505
|
InputError["REQUIRED"] = "required";
|
|
1464
1506
|
})(InputError$1 || (InputError$1 = {}));
|
|
1465
1507
|
|
|
1466
|
-
|
|
1467
|
-
* Format number to the locale currency
|
|
1468
|
-
*
|
|
1469
|
-
* @param {number} number number to format
|
|
1470
|
-
* @param {string} locale locale to apply
|
|
1471
|
-
* @param {string} currency currency to apply
|
|
1472
|
-
* @returns {string} formatted currency
|
|
1473
|
-
*/
|
|
1474
|
-
function localeCurrency(number, locale, currency) {
|
|
1475
|
-
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
|
|
1476
|
-
}
|
|
1477
|
-
/**
|
|
1478
|
-
* Format number to locale
|
|
1479
|
-
*
|
|
1480
|
-
* @param {number} number number to format
|
|
1481
|
-
* @param {string} locale locale to apply
|
|
1482
|
-
* @returns {string} formatted number
|
|
1483
|
-
*/
|
|
1484
|
-
function localeNumber(number, locale) {
|
|
1485
|
-
return new Intl.NumberFormat(locale).format(number);
|
|
1486
|
-
}
|
|
1487
|
-
/**
|
|
1488
|
-
* Date RegExp
|
|
1489
|
-
*/
|
|
1490
|
-
const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
1491
|
-
/**
|
|
1492
|
-
* Locale date format
|
|
1493
|
-
*
|
|
1494
|
-
* @param {string} date date to format
|
|
1495
|
-
* @param {string} locale locale to apply
|
|
1496
|
-
* @returns {string} formatted date
|
|
1497
|
-
*/
|
|
1498
|
-
function localeDate(date, locale) {
|
|
1499
|
-
if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
|
|
1500
|
-
return '';
|
|
1501
|
-
}
|
|
1502
|
-
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
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}}";
|
|
1508
|
+
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}}";
|
|
1506
1509
|
|
|
1507
1510
|
const MgInputDate = class {
|
|
1508
1511
|
constructor(hostRef) {
|
|
@@ -1511,31 +1514,6 @@ const MgInputDate = class {
|
|
|
1511
1514
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
1512
1515
|
// hasDisplayedError (triggered by blur event)
|
|
1513
1516
|
this.hasDisplayedError = false;
|
|
1514
|
-
/**
|
|
1515
|
-
* Input name
|
|
1516
|
-
* If not set the value equals the identifier
|
|
1517
|
-
*/
|
|
1518
|
-
this.name = this.identifier;
|
|
1519
|
-
/**
|
|
1520
|
-
* Define if label is visible
|
|
1521
|
-
*/
|
|
1522
|
-
this.labelHide = false;
|
|
1523
|
-
/**
|
|
1524
|
-
* Define if input is required
|
|
1525
|
-
*/
|
|
1526
|
-
this.required = false;
|
|
1527
|
-
/**
|
|
1528
|
-
* Define if input is readonly
|
|
1529
|
-
*/
|
|
1530
|
-
this.readonly = false;
|
|
1531
|
-
/**
|
|
1532
|
-
* Define if input is disabled
|
|
1533
|
-
*/
|
|
1534
|
-
this.disabled = false;
|
|
1535
|
-
/**
|
|
1536
|
-
* Component classes
|
|
1537
|
-
*/
|
|
1538
|
-
this.classList = new ClassList(['mg-input--date']);
|
|
1539
1517
|
/**
|
|
1540
1518
|
* Handle input event
|
|
1541
1519
|
*/
|
|
@@ -1614,13 +1592,33 @@ const MgInputDate = class {
|
|
|
1614
1592
|
}
|
|
1615
1593
|
}
|
|
1616
1594
|
};
|
|
1595
|
+
this.value = undefined;
|
|
1596
|
+
this.identifier = undefined;
|
|
1597
|
+
this.name = this.identifier;
|
|
1598
|
+
this.label = undefined;
|
|
1599
|
+
this.labelOnTop = undefined;
|
|
1600
|
+
this.labelHide = false;
|
|
1601
|
+
this.required = false;
|
|
1602
|
+
this.readonly = false;
|
|
1603
|
+
this.disabled = false;
|
|
1604
|
+
this.tooltip = undefined;
|
|
1605
|
+
this.helpText = undefined;
|
|
1606
|
+
this.valid = undefined;
|
|
1607
|
+
this.invalid = undefined;
|
|
1608
|
+
this.min = undefined;
|
|
1609
|
+
this.max = undefined;
|
|
1610
|
+
this.classList = new ClassList(['mg-input--date']);
|
|
1611
|
+
this.errorMessage = undefined;
|
|
1617
1612
|
}
|
|
1618
1613
|
validateValue(newValue) {
|
|
1614
|
+
// When the input is not fully completed or has been cleared, the value becomes an empty string.
|
|
1615
|
+
if (newValue === '')
|
|
1616
|
+
newValue = null;
|
|
1619
1617
|
if (newValue !== undefined && newValue !== null && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
|
|
1620
1618
|
throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
|
|
1621
1619
|
}
|
|
1622
1620
|
else {
|
|
1623
|
-
this.valueChange.emit(
|
|
1621
|
+
this.valueChange.emit(newValue);
|
|
1624
1622
|
}
|
|
1625
1623
|
}
|
|
1626
1624
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -1707,7 +1705,7 @@ var InputError;
|
|
|
1707
1705
|
InputError["REQUIRED"] = "required";
|
|
1708
1706
|
})(InputError || (InputError = {}));
|
|
1709
1707
|
|
|
1710
|
-
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
|
|
1708
|
+
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)}";
|
|
1711
1709
|
|
|
1712
1710
|
const MgInputNumeric = class {
|
|
1713
1711
|
constructor(hostRef) {
|
|
@@ -1717,65 +1715,18 @@ const MgInputNumeric = class {
|
|
|
1717
1715
|
// hasDisplayedError (triggered by blur event)
|
|
1718
1716
|
this.hasDisplayedError = false;
|
|
1719
1717
|
/**
|
|
1720
|
-
*
|
|
1721
|
-
*
|
|
1718
|
+
* Handle input event
|
|
1719
|
+
*
|
|
1720
|
+
* @returns {void}
|
|
1722
1721
|
*/
|
|
1723
|
-
this.
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
this.required = false;
|
|
1732
|
-
/**
|
|
1733
|
-
* Define if input is readonly
|
|
1734
|
-
*/
|
|
1735
|
-
this.readonly = false;
|
|
1736
|
-
/**
|
|
1737
|
-
* Define if input is disabled
|
|
1738
|
-
*/
|
|
1739
|
-
this.disabled = false;
|
|
1740
|
-
/**
|
|
1741
|
-
* Define numeric type
|
|
1742
|
-
*/
|
|
1743
|
-
this.type = types[0];
|
|
1744
|
-
/**
|
|
1745
|
-
* Define currency
|
|
1746
|
-
*/
|
|
1747
|
-
this.currency = 'USD';
|
|
1748
|
-
/**
|
|
1749
|
-
* Override integer length
|
|
1750
|
-
* integer is the number before the decimal point
|
|
1751
|
-
*/
|
|
1752
|
-
this.integerLength = 13;
|
|
1753
|
-
/**
|
|
1754
|
-
* Override decimal length
|
|
1755
|
-
* decimal is the number after the decimal point
|
|
1756
|
-
*/
|
|
1757
|
-
this.decimalLength = 2;
|
|
1758
|
-
/**
|
|
1759
|
-
* Component classes
|
|
1760
|
-
*/
|
|
1761
|
-
this.classList = new ClassList(['mg-input--numeric']);
|
|
1762
|
-
/**
|
|
1763
|
-
* Define if input has focus
|
|
1764
|
-
*/
|
|
1765
|
-
this.hasFocus = false;
|
|
1766
|
-
/**
|
|
1767
|
-
* Handle input event
|
|
1768
|
-
*
|
|
1769
|
-
* @returns {void}
|
|
1770
|
-
*/
|
|
1771
|
-
this.handleInput = () => {
|
|
1772
|
-
// Check validity
|
|
1773
|
-
this.checkValidity();
|
|
1774
|
-
if (this.hasDisplayedError) {
|
|
1775
|
-
this.setErrorMessage();
|
|
1776
|
-
}
|
|
1777
|
-
this.value = this.input.value;
|
|
1778
|
-
};
|
|
1722
|
+
this.handleInput = () => {
|
|
1723
|
+
// Check validity
|
|
1724
|
+
this.checkValidity();
|
|
1725
|
+
if (this.hasDisplayedError) {
|
|
1726
|
+
this.setErrorMessage();
|
|
1727
|
+
}
|
|
1728
|
+
this.value = this.input.value;
|
|
1729
|
+
};
|
|
1779
1730
|
/**
|
|
1780
1731
|
* Handle focus event
|
|
1781
1732
|
*
|
|
@@ -1869,6 +1820,30 @@ const MgInputNumeric = class {
|
|
|
1869
1820
|
this.classList.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
1870
1821
|
}
|
|
1871
1822
|
};
|
|
1823
|
+
this.value = undefined;
|
|
1824
|
+
this.identifier = undefined;
|
|
1825
|
+
this.name = this.identifier;
|
|
1826
|
+
this.label = undefined;
|
|
1827
|
+
this.labelOnTop = undefined;
|
|
1828
|
+
this.labelHide = false;
|
|
1829
|
+
this.placeholder = undefined;
|
|
1830
|
+
this.required = false;
|
|
1831
|
+
this.readonly = false;
|
|
1832
|
+
this.disabled = false;
|
|
1833
|
+
this.mgWidth = undefined;
|
|
1834
|
+
this.tooltip = undefined;
|
|
1835
|
+
this.helpText = undefined;
|
|
1836
|
+
this.type = types[0];
|
|
1837
|
+
this.currency = 'USD';
|
|
1838
|
+
this.max = undefined;
|
|
1839
|
+
this.min = undefined;
|
|
1840
|
+
this.integerLength = 13;
|
|
1841
|
+
this.decimalLength = 2;
|
|
1842
|
+
this.valid = undefined;
|
|
1843
|
+
this.invalid = undefined;
|
|
1844
|
+
this.classList = new ClassList(['mg-input--numeric']);
|
|
1845
|
+
this.errorMessage = undefined;
|
|
1846
|
+
this.hasFocus = false;
|
|
1872
1847
|
}
|
|
1873
1848
|
validateValue(newValue) {
|
|
1874
1849
|
if (newValue !== undefined && newValue !== null) {
|
|
@@ -1991,7 +1966,7 @@ const MgInputNumeric = class {
|
|
|
1991
1966
|
};
|
|
1992
1967
|
MgInputNumeric.style = mgInputNumericCss;
|
|
1993
1968
|
|
|
1994
|
-
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
|
|
1969
|
+
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}}";
|
|
1995
1970
|
|
|
1996
1971
|
const MgInputPassword = class {
|
|
1997
1972
|
constructor(hostRef) {
|
|
@@ -2000,35 +1975,6 @@ const MgInputPassword = class {
|
|
|
2000
1975
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
2001
1976
|
// hasDisplayedError (triggered by blur event)
|
|
2002
1977
|
this.hasDisplayedError = false;
|
|
2003
|
-
/**
|
|
2004
|
-
* Input name
|
|
2005
|
-
* If not set the value equals the identifier
|
|
2006
|
-
*/
|
|
2007
|
-
this.name = this.identifier;
|
|
2008
|
-
/**
|
|
2009
|
-
* Define if label is visible
|
|
2010
|
-
*/
|
|
2011
|
-
this.labelHide = false;
|
|
2012
|
-
/**
|
|
2013
|
-
* Define if input is required
|
|
2014
|
-
*/
|
|
2015
|
-
this.required = false;
|
|
2016
|
-
/**
|
|
2017
|
-
* Define if input is readonly
|
|
2018
|
-
*/
|
|
2019
|
-
this.readonly = false;
|
|
2020
|
-
/**
|
|
2021
|
-
* Define if input is disabled
|
|
2022
|
-
*/
|
|
2023
|
-
this.disabled = false;
|
|
2024
|
-
/**
|
|
2025
|
-
* Define input width
|
|
2026
|
-
*/
|
|
2027
|
-
this.mgWidth = 'full';
|
|
2028
|
-
/**
|
|
2029
|
-
* Component classes
|
|
2030
|
-
*/
|
|
2031
|
-
this.classList = new ClassList(['mg-input--password']);
|
|
2032
1978
|
/**
|
|
2033
1979
|
* Handle input event
|
|
2034
1980
|
*/
|
|
@@ -2066,6 +2012,23 @@ const MgInputPassword = class {
|
|
|
2066
2012
|
this.errorMessage = this.messages.errors.required;
|
|
2067
2013
|
}
|
|
2068
2014
|
};
|
|
2015
|
+
this.value = undefined;
|
|
2016
|
+
this.identifier = undefined;
|
|
2017
|
+
this.name = this.identifier;
|
|
2018
|
+
this.label = undefined;
|
|
2019
|
+
this.labelOnTop = undefined;
|
|
2020
|
+
this.labelHide = false;
|
|
2021
|
+
this.placeholder = undefined;
|
|
2022
|
+
this.required = false;
|
|
2023
|
+
this.readonly = false;
|
|
2024
|
+
this.disabled = false;
|
|
2025
|
+
this.mgWidth = 'full';
|
|
2026
|
+
this.tooltip = undefined;
|
|
2027
|
+
this.helpText = undefined;
|
|
2028
|
+
this.valid = undefined;
|
|
2029
|
+
this.invalid = undefined;
|
|
2030
|
+
this.classList = new ClassList(['mg-input--password']);
|
|
2031
|
+
this.errorMessage = undefined;
|
|
2069
2032
|
}
|
|
2070
2033
|
handleValue(newValue) {
|
|
2071
2034
|
this.valueChange.emit(newValue);
|
|
@@ -2150,39 +2113,6 @@ const MgInputRadio = class {
|
|
|
2150
2113
|
this.inputs = [];
|
|
2151
2114
|
// hasDisplayedError (triggered by blur event)
|
|
2152
2115
|
this.hasDisplayedError = false;
|
|
2153
|
-
/**
|
|
2154
|
-
* Input name
|
|
2155
|
-
* If not set the value equals the identifier
|
|
2156
|
-
*/
|
|
2157
|
-
this.name = this.identifier;
|
|
2158
|
-
/**
|
|
2159
|
-
* Define if label is displayed on top
|
|
2160
|
-
*/
|
|
2161
|
-
this.labelOnTop = false;
|
|
2162
|
-
/**
|
|
2163
|
-
* Define if label is visible
|
|
2164
|
-
*/
|
|
2165
|
-
this.labelHide = false;
|
|
2166
|
-
/**
|
|
2167
|
-
* Define if inputs are display verticaly
|
|
2168
|
-
*/
|
|
2169
|
-
this.inputVerticalList = false;
|
|
2170
|
-
/**
|
|
2171
|
-
* Define if input is required
|
|
2172
|
-
*/
|
|
2173
|
-
this.required = false;
|
|
2174
|
-
/**
|
|
2175
|
-
* Define if input is readonly
|
|
2176
|
-
*/
|
|
2177
|
-
this.readonly = false;
|
|
2178
|
-
/**
|
|
2179
|
-
* Define if input is disabled
|
|
2180
|
-
*/
|
|
2181
|
-
this.disabled = false;
|
|
2182
|
-
/**
|
|
2183
|
-
* Component classes
|
|
2184
|
-
*/
|
|
2185
|
-
this.classList = new ClassList(['mg-input--radio']);
|
|
2186
2116
|
/**
|
|
2187
2117
|
* Handle input event
|
|
2188
2118
|
*
|
|
@@ -2232,6 +2162,24 @@ const MgInputRadio = class {
|
|
|
2232
2162
|
* @returns {HTMLInputElement} element
|
|
2233
2163
|
*/
|
|
2234
2164
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
2165
|
+
this.value = undefined;
|
|
2166
|
+
this.items = undefined;
|
|
2167
|
+
this.identifier = undefined;
|
|
2168
|
+
this.name = this.identifier;
|
|
2169
|
+
this.label = undefined;
|
|
2170
|
+
this.labelOnTop = false;
|
|
2171
|
+
this.labelHide = false;
|
|
2172
|
+
this.inputVerticalList = false;
|
|
2173
|
+
this.required = false;
|
|
2174
|
+
this.readonly = false;
|
|
2175
|
+
this.disabled = false;
|
|
2176
|
+
this.tooltip = undefined;
|
|
2177
|
+
this.helpText = undefined;
|
|
2178
|
+
this.valid = undefined;
|
|
2179
|
+
this.invalid = undefined;
|
|
2180
|
+
this.classList = new ClassList(['mg-input--radio']);
|
|
2181
|
+
this.errorMessage = undefined;
|
|
2182
|
+
this.options = undefined;
|
|
2235
2183
|
}
|
|
2236
2184
|
handleValue(newValue) {
|
|
2237
2185
|
this.valueChange.emit(newValue);
|
|
@@ -2315,7 +2263,7 @@ const MgInputRadio = class {
|
|
|
2315
2263
|
};
|
|
2316
2264
|
MgInputRadio.style = mgInputRadioCss;
|
|
2317
2265
|
|
|
2318
|
-
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
|
|
2266
|
+
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}";
|
|
2319
2267
|
|
|
2320
2268
|
/**
|
|
2321
2269
|
* Check if item is a well configured option
|
|
@@ -2360,39 +2308,6 @@ const MgInputSelect = class {
|
|
|
2360
2308
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
2361
2309
|
// hasDisplayedError (triggered by blur event)
|
|
2362
2310
|
this.hasDisplayedError = false;
|
|
2363
|
-
/**
|
|
2364
|
-
* Input name
|
|
2365
|
-
* If not set the value equals the identifier
|
|
2366
|
-
*/
|
|
2367
|
-
this.name = this.identifier;
|
|
2368
|
-
/**
|
|
2369
|
-
* Define if label is visible
|
|
2370
|
-
*/
|
|
2371
|
-
this.labelHide = false;
|
|
2372
|
-
/**
|
|
2373
|
-
* Option to remove placeholder
|
|
2374
|
-
*/
|
|
2375
|
-
this.placeholderHide = false;
|
|
2376
|
-
/**
|
|
2377
|
-
* Option to disable placeholder
|
|
2378
|
-
*/
|
|
2379
|
-
this.placeholderDisabled = false;
|
|
2380
|
-
/**
|
|
2381
|
-
* Define if input is required
|
|
2382
|
-
*/
|
|
2383
|
-
this.required = false;
|
|
2384
|
-
/**
|
|
2385
|
-
* Define if input is readonly
|
|
2386
|
-
*/
|
|
2387
|
-
this.readonly = false;
|
|
2388
|
-
/**
|
|
2389
|
-
* Define if input is disabled
|
|
2390
|
-
*/
|
|
2391
|
-
this.disabled = false;
|
|
2392
|
-
/**
|
|
2393
|
-
* Component classes
|
|
2394
|
-
*/
|
|
2395
|
-
this.classList = new ClassList(['mg-input--select']);
|
|
2396
2311
|
/**
|
|
2397
2312
|
* Handle input event
|
|
2398
2313
|
*/
|
|
@@ -2434,6 +2349,29 @@ const MgInputSelect = class {
|
|
|
2434
2349
|
this.errorMessage = this.messages.errors.required;
|
|
2435
2350
|
}
|
|
2436
2351
|
};
|
|
2352
|
+
this.value = undefined;
|
|
2353
|
+
this.items = undefined;
|
|
2354
|
+
this.identifier = undefined;
|
|
2355
|
+
this.name = this.identifier;
|
|
2356
|
+
this.label = undefined;
|
|
2357
|
+
this.labelOnTop = undefined;
|
|
2358
|
+
this.labelHide = false;
|
|
2359
|
+
this.placeholder = undefined;
|
|
2360
|
+
this.placeholderHide = false;
|
|
2361
|
+
this.placeholderDisabled = false;
|
|
2362
|
+
this.required = false;
|
|
2363
|
+
this.readonly = false;
|
|
2364
|
+
this.disabled = false;
|
|
2365
|
+
this.mgWidth = undefined;
|
|
2366
|
+
this.tooltip = undefined;
|
|
2367
|
+
this.helpText = undefined;
|
|
2368
|
+
this.valid = undefined;
|
|
2369
|
+
this.invalid = undefined;
|
|
2370
|
+
this.classList = new ClassList(['mg-input--select']);
|
|
2371
|
+
this.errorMessage = undefined;
|
|
2372
|
+
this.options = undefined;
|
|
2373
|
+
this.valueExist = undefined;
|
|
2374
|
+
this.readonlyValue = undefined;
|
|
2437
2375
|
}
|
|
2438
2376
|
handleValue(newValue) {
|
|
2439
2377
|
if (newValue !== null) {
|
|
@@ -2445,13 +2383,17 @@ const MgInputSelect = class {
|
|
|
2445
2383
|
this.valueChange.emit(newValue);
|
|
2446
2384
|
}
|
|
2447
2385
|
validateItems(newValue) {
|
|
2386
|
+
// Empty options
|
|
2387
|
+
if (newValue.length === 0) {
|
|
2388
|
+
this.options = [];
|
|
2389
|
+
}
|
|
2448
2390
|
// String array
|
|
2449
|
-
if (allItemsAreString(newValue)) {
|
|
2391
|
+
else if (allItemsAreString(newValue)) {
|
|
2450
2392
|
this.valueExist = newValue.includes(this.value);
|
|
2451
2393
|
this.options = newValue.map((item) => ({ title: item, value: item }));
|
|
2452
2394
|
}
|
|
2453
2395
|
// Object array
|
|
2454
|
-
else if (newValue
|
|
2396
|
+
else if (newValue.every(item => isOption$1(item))) {
|
|
2455
2397
|
this.valueExist = newValue.map(item => item.value).includes(this.value);
|
|
2456
2398
|
// Grouped object options
|
|
2457
2399
|
if (newValue.some(item => item.group !== undefined)) {
|
|
@@ -2463,7 +2405,7 @@ const MgInputSelect = class {
|
|
|
2463
2405
|
}
|
|
2464
2406
|
}
|
|
2465
2407
|
else {
|
|
2466
|
-
throw new Error('<mg-input-select> prop "items" is required
|
|
2408
|
+
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.');
|
|
2467
2409
|
}
|
|
2468
2410
|
}
|
|
2469
2411
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -2533,7 +2475,7 @@ const MgInputSelect = class {
|
|
|
2533
2475
|
};
|
|
2534
2476
|
MgInputSelect.style = mgInputSelectCss;
|
|
2535
2477
|
|
|
2536
|
-
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
|
|
2478
|
+
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}";
|
|
2537
2479
|
|
|
2538
2480
|
const MgInputText = class {
|
|
2539
2481
|
constructor(hostRef) {
|
|
@@ -2549,47 +2491,6 @@ const MgInputText = class {
|
|
|
2549
2491
|
this.classHasIcon = 'mg-input--has-icon';
|
|
2550
2492
|
// hasDisplayedError (triggered by blur event)
|
|
2551
2493
|
this.hasDisplayedError = false;
|
|
2552
|
-
/**
|
|
2553
|
-
* Input name
|
|
2554
|
-
* If not set the value equals the identifier
|
|
2555
|
-
*/
|
|
2556
|
-
this.name = this.identifier;
|
|
2557
|
-
/**
|
|
2558
|
-
* Input type
|
|
2559
|
-
*/
|
|
2560
|
-
this.type = 'text';
|
|
2561
|
-
/**
|
|
2562
|
-
* Define if label is visible
|
|
2563
|
-
*/
|
|
2564
|
-
this.labelHide = false;
|
|
2565
|
-
/**
|
|
2566
|
-
* Input max length
|
|
2567
|
-
*/
|
|
2568
|
-
this.maxlength = 400;
|
|
2569
|
-
/**
|
|
2570
|
-
* Define if input is required
|
|
2571
|
-
*/
|
|
2572
|
-
this.required = false;
|
|
2573
|
-
/**
|
|
2574
|
-
* Define if input is readonly
|
|
2575
|
-
*/
|
|
2576
|
-
this.readonly = false;
|
|
2577
|
-
/**
|
|
2578
|
-
* Define if input is disabled
|
|
2579
|
-
*/
|
|
2580
|
-
this.disabled = false;
|
|
2581
|
-
/**
|
|
2582
|
-
* Define input width
|
|
2583
|
-
*/
|
|
2584
|
-
this.mgWidth = 'full';
|
|
2585
|
-
/**
|
|
2586
|
-
* Define if component should display character left
|
|
2587
|
-
*/
|
|
2588
|
-
this.displayCharacterLeft = true;
|
|
2589
|
-
/**
|
|
2590
|
-
* Component classes
|
|
2591
|
-
*/
|
|
2592
|
-
this.classList = new ClassList(['mg-input--text']);
|
|
2593
2494
|
/**
|
|
2594
2495
|
* Handle input event
|
|
2595
2496
|
*
|
|
@@ -2680,6 +2581,29 @@ const MgInputText = class {
|
|
|
2680
2581
|
this.classList.add('mg-input--has-buttons-group-append');
|
|
2681
2582
|
}
|
|
2682
2583
|
};
|
|
2584
|
+
this.value = undefined;
|
|
2585
|
+
this.identifier = undefined;
|
|
2586
|
+
this.name = this.identifier;
|
|
2587
|
+
this.label = undefined;
|
|
2588
|
+
this.type = 'text';
|
|
2589
|
+
this.icon = undefined;
|
|
2590
|
+
this.labelOnTop = undefined;
|
|
2591
|
+
this.labelHide = false;
|
|
2592
|
+
this.placeholder = undefined;
|
|
2593
|
+
this.maxlength = 400;
|
|
2594
|
+
this.required = false;
|
|
2595
|
+
this.readonly = false;
|
|
2596
|
+
this.disabled = false;
|
|
2597
|
+
this.mgWidth = 'full';
|
|
2598
|
+
this.pattern = undefined;
|
|
2599
|
+
this.patternErrorMessage = undefined;
|
|
2600
|
+
this.tooltip = undefined;
|
|
2601
|
+
this.displayCharacterLeft = true;
|
|
2602
|
+
this.helpText = undefined;
|
|
2603
|
+
this.valid = undefined;
|
|
2604
|
+
this.invalid = undefined;
|
|
2605
|
+
this.classList = new ClassList(['mg-input--text']);
|
|
2606
|
+
this.errorMessage = undefined;
|
|
2683
2607
|
}
|
|
2684
2608
|
handleValue(newValue) {
|
|
2685
2609
|
this.valueChange.emit(newValue);
|
|
@@ -2769,7 +2693,7 @@ const MgInputText = class {
|
|
|
2769
2693
|
};
|
|
2770
2694
|
MgInputText.style = mgInputTextCss;
|
|
2771
2695
|
|
|
2772
|
-
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
|
|
2696
|
+
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}}";
|
|
2773
2697
|
|
|
2774
2698
|
const MgInputTextarea = class {
|
|
2775
2699
|
constructor(hostRef) {
|
|
@@ -2784,51 +2708,6 @@ const MgInputTextarea = class {
|
|
|
2784
2708
|
this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
|
|
2785
2709
|
// hasDisplayedError (triggered by blur event)
|
|
2786
2710
|
this.hasDisplayedError = false;
|
|
2787
|
-
/**
|
|
2788
|
-
* Input name
|
|
2789
|
-
* If not set the value equals the identifier
|
|
2790
|
-
*/
|
|
2791
|
-
this.name = this.identifier;
|
|
2792
|
-
/**
|
|
2793
|
-
* Define if label is visible
|
|
2794
|
-
*/
|
|
2795
|
-
this.labelHide = false;
|
|
2796
|
-
/**
|
|
2797
|
-
* Input max length
|
|
2798
|
-
*/
|
|
2799
|
-
this.maxlength = 4000;
|
|
2800
|
-
/**
|
|
2801
|
-
* Define if input is required
|
|
2802
|
-
*/
|
|
2803
|
-
this.required = false;
|
|
2804
|
-
/**
|
|
2805
|
-
* Define if input is readonly
|
|
2806
|
-
*/
|
|
2807
|
-
this.readonly = false;
|
|
2808
|
-
/**
|
|
2809
|
-
* Define if input is disabled
|
|
2810
|
-
*/
|
|
2811
|
-
this.disabled = false;
|
|
2812
|
-
/**
|
|
2813
|
-
* Define input width
|
|
2814
|
-
*/
|
|
2815
|
-
this.mgWidth = 'full';
|
|
2816
|
-
/**
|
|
2817
|
-
* Define the number of visible text lines for the control
|
|
2818
|
-
*/
|
|
2819
|
-
this.rows = 3;
|
|
2820
|
-
/**
|
|
2821
|
-
* Define if component should display character left
|
|
2822
|
-
*/
|
|
2823
|
-
this.displayCharacterLeft = true;
|
|
2824
|
-
/**
|
|
2825
|
-
* Define if input is resizable
|
|
2826
|
-
*/
|
|
2827
|
-
this.resizable = 'none';
|
|
2828
|
-
/**
|
|
2829
|
-
* Component classes
|
|
2830
|
-
*/
|
|
2831
|
-
this.classList = new ClassList(['mg-input--textarea']);
|
|
2832
2711
|
/**
|
|
2833
2712
|
* Handle input event
|
|
2834
2713
|
*/
|
|
@@ -2899,6 +2778,29 @@ const MgInputTextarea = class {
|
|
|
2899
2778
|
throw new Error('<mg-input-textarea> prop "pattern" must be paired with the prop "patternErrorMessage"');
|
|
2900
2779
|
}
|
|
2901
2780
|
};
|
|
2781
|
+
this.value = undefined;
|
|
2782
|
+
this.identifier = undefined;
|
|
2783
|
+
this.name = this.identifier;
|
|
2784
|
+
this.label = undefined;
|
|
2785
|
+
this.labelOnTop = undefined;
|
|
2786
|
+
this.labelHide = false;
|
|
2787
|
+
this.placeholder = undefined;
|
|
2788
|
+
this.maxlength = 4000;
|
|
2789
|
+
this.required = false;
|
|
2790
|
+
this.readonly = false;
|
|
2791
|
+
this.disabled = false;
|
|
2792
|
+
this.mgWidth = 'full';
|
|
2793
|
+
this.pattern = undefined;
|
|
2794
|
+
this.patternErrorMessage = undefined;
|
|
2795
|
+
this.rows = 3;
|
|
2796
|
+
this.tooltip = undefined;
|
|
2797
|
+
this.displayCharacterLeft = true;
|
|
2798
|
+
this.helpText = undefined;
|
|
2799
|
+
this.valid = undefined;
|
|
2800
|
+
this.invalid = undefined;
|
|
2801
|
+
this.resizable = 'none';
|
|
2802
|
+
this.classList = new ClassList(['mg-input--textarea']);
|
|
2803
|
+
this.errorMessage = undefined;
|
|
2902
2804
|
}
|
|
2903
2805
|
handleValue(newValue) {
|
|
2904
2806
|
this.checkValidity();
|
|
@@ -2986,17 +2888,13 @@ const mgInputTitleCss = ".is-asterisk.sc-mg-input-title{color:hsl(var(--color-da
|
|
|
2986
2888
|
const MgInputTitle = class {
|
|
2987
2889
|
constructor(hostRef) {
|
|
2988
2890
|
registerInstance(this, hostRef);
|
|
2989
|
-
/**
|
|
2990
|
-
* Switch from label to fieldset sementic
|
|
2991
|
-
*/
|
|
2992
|
-
this.isLegend = false;
|
|
2993
|
-
/**
|
|
2994
|
-
* Component parent tagname
|
|
2995
|
-
*/
|
|
2996
|
-
this.tagName = 'label';
|
|
2997
2891
|
this.getTagName = () => {
|
|
2998
2892
|
this.tagName = this.isLegend ? 'legend' : 'label';
|
|
2999
2893
|
};
|
|
2894
|
+
this.identifier = undefined;
|
|
2895
|
+
this.required = undefined;
|
|
2896
|
+
this.isLegend = false;
|
|
2897
|
+
this.tagName = 'label';
|
|
3000
2898
|
}
|
|
3001
2899
|
validateIdentifier(newValue) {
|
|
3002
2900
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -3054,39 +2952,6 @@ const MgInputToggle = class {
|
|
|
3054
2952
|
this.classIsActive = 'mg-input--toggle-is-active';
|
|
3055
2953
|
this.classOnOff = 'mg-input--toggle-on-off';
|
|
3056
2954
|
this.classIcon = 'mg-input--toggle-icon';
|
|
3057
|
-
/**
|
|
3058
|
-
* Input name
|
|
3059
|
-
* If not set the value equals the identifier
|
|
3060
|
-
*/
|
|
3061
|
-
this.name = this.identifier;
|
|
3062
|
-
/**
|
|
3063
|
-
* Define if label is visible
|
|
3064
|
-
*/
|
|
3065
|
-
this.labelHide = false;
|
|
3066
|
-
/**
|
|
3067
|
-
* Define if toggle have on/off style
|
|
3068
|
-
*/
|
|
3069
|
-
this.isOnOff = false;
|
|
3070
|
-
/**
|
|
3071
|
-
* Define if toggle display icon
|
|
3072
|
-
*/
|
|
3073
|
-
this.isIcon = false;
|
|
3074
|
-
/**
|
|
3075
|
-
* Define if input is readonly
|
|
3076
|
-
*/
|
|
3077
|
-
this.readonly = false;
|
|
3078
|
-
/**
|
|
3079
|
-
* Define if input is disabled
|
|
3080
|
-
*/
|
|
3081
|
-
this.disabled = false;
|
|
3082
|
-
/**
|
|
3083
|
-
* Component classes
|
|
3084
|
-
*/
|
|
3085
|
-
this.classList = new ClassList(['mg-input--toggle']);
|
|
3086
|
-
/**
|
|
3087
|
-
* Checked internal value
|
|
3088
|
-
*/
|
|
3089
|
-
this.checked = false;
|
|
3090
2955
|
/**
|
|
3091
2956
|
* Change checked value
|
|
3092
2957
|
*
|
|
@@ -3111,6 +2976,22 @@ const MgInputToggle = class {
|
|
|
3111
2976
|
slots.forEach(slot => slot.setAttribute('title', slot.textContent));
|
|
3112
2977
|
}
|
|
3113
2978
|
};
|
|
2979
|
+
this.value = undefined;
|
|
2980
|
+
this.items = undefined;
|
|
2981
|
+
this.identifier = undefined;
|
|
2982
|
+
this.name = this.identifier;
|
|
2983
|
+
this.label = undefined;
|
|
2984
|
+
this.labelOnTop = undefined;
|
|
2985
|
+
this.labelHide = false;
|
|
2986
|
+
this.isOnOff = false;
|
|
2987
|
+
this.isIcon = false;
|
|
2988
|
+
this.readonly = false;
|
|
2989
|
+
this.disabled = false;
|
|
2990
|
+
this.tooltip = undefined;
|
|
2991
|
+
this.helpText = undefined;
|
|
2992
|
+
this.classList = new ClassList(['mg-input--toggle']);
|
|
2993
|
+
this.options = undefined;
|
|
2994
|
+
this.checked = false;
|
|
3114
2995
|
}
|
|
3115
2996
|
handleValue(newValue) {
|
|
3116
2997
|
// Swich to the right option
|
|
@@ -3231,6 +3112,194 @@ const MgInputToggle = class {
|
|
|
3231
3112
|
};
|
|
3232
3113
|
MgInputToggle.style = mgInputToggleCss;
|
|
3233
3114
|
|
|
3115
|
+
/**
|
|
3116
|
+
* Available menu-item positions
|
|
3117
|
+
*/
|
|
3118
|
+
var ElementPosition;
|
|
3119
|
+
(function (ElementPosition) {
|
|
3120
|
+
ElementPosition["FIRST"] = "first";
|
|
3121
|
+
ElementPosition["LAST"] = "last";
|
|
3122
|
+
})(ElementPosition || (ElementPosition = {}));
|
|
3123
|
+
/**
|
|
3124
|
+
* Available menu item status
|
|
3125
|
+
*/
|
|
3126
|
+
var Status$1;
|
|
3127
|
+
(function (Status) {
|
|
3128
|
+
Status["VISIBLE"] = "visible";
|
|
3129
|
+
Status["HIDDEN"] = "hidden";
|
|
3130
|
+
Status["DISABLED"] = "disabled";
|
|
3131
|
+
Status["ACTIVE"] = "active";
|
|
3132
|
+
})(Status$1 || (Status$1 = {}));
|
|
3133
|
+
|
|
3134
|
+
/**
|
|
3135
|
+
* MgMenuItem type guard
|
|
3136
|
+
*
|
|
3137
|
+
* @param {HTMLElement} element element to control type
|
|
3138
|
+
* @returns {boolean} truthy if element is mg-menu-item
|
|
3139
|
+
*/
|
|
3140
|
+
const isMgMenuItem = (element) => element.nodeName === 'MG-MENU-ITEM';
|
|
3141
|
+
var OverflowBehaviorElements;
|
|
3142
|
+
(function (OverflowBehaviorElements) {
|
|
3143
|
+
OverflowBehaviorElements["MORE"] = "data-overflow-more";
|
|
3144
|
+
OverflowBehaviorElements["BASE_INDEX"] = "data-overflow-base-index";
|
|
3145
|
+
OverflowBehaviorElements["PROXY_INDEX"] = "data-overflow-proxy-index";
|
|
3146
|
+
})(OverflowBehaviorElements || (OverflowBehaviorElements = {}));
|
|
3147
|
+
class OverflowBehavior {
|
|
3148
|
+
constructor(element, render) {
|
|
3149
|
+
this.element = element;
|
|
3150
|
+
this.render = render;
|
|
3151
|
+
/**********
|
|
3152
|
+
* Public *
|
|
3153
|
+
**********/
|
|
3154
|
+
/**
|
|
3155
|
+
* Disconnect ResizeObserver
|
|
3156
|
+
*
|
|
3157
|
+
* @returns {void}
|
|
3158
|
+
*/
|
|
3159
|
+
this.disconnect = () => {
|
|
3160
|
+
this.resizeObserver.disconnect();
|
|
3161
|
+
};
|
|
3162
|
+
/**
|
|
3163
|
+
* Update more element status if active child
|
|
3164
|
+
*
|
|
3165
|
+
* @returns {void}
|
|
3166
|
+
*/
|
|
3167
|
+
this.updateActiveStatus = () => {
|
|
3168
|
+
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);
|
|
3169
|
+
this.moreELement.setAttribute('status', hasActiveChild ? Status$1.ACTIVE : Status$1.VISIBLE);
|
|
3170
|
+
};
|
|
3171
|
+
/************
|
|
3172
|
+
* Internal *
|
|
3173
|
+
************/
|
|
3174
|
+
/**
|
|
3175
|
+
* run overflow behavior
|
|
3176
|
+
*
|
|
3177
|
+
* @param {number} width width of the container
|
|
3178
|
+
* @returns {void}
|
|
3179
|
+
*/
|
|
3180
|
+
this.run = (width) => {
|
|
3181
|
+
if (this.moreELement === undefined) {
|
|
3182
|
+
// set moreElement
|
|
3183
|
+
this.moreELement = this.render();
|
|
3184
|
+
this.moreELement.setAttribute(OverflowBehaviorElements.MORE, '');
|
|
3185
|
+
// set children
|
|
3186
|
+
this.children = Array.from(this.element.children);
|
|
3187
|
+
let moreELementChildren;
|
|
3188
|
+
const allowedElements = ['MG-MENU-ITEM', 'MG-BUTTON'];
|
|
3189
|
+
if (isMgMenuItem(this.moreELement)) {
|
|
3190
|
+
moreELementChildren = Array.from(this.moreELement.querySelector('mg-menu').children).filter(element => allowedElements.includes(element.nodeName));
|
|
3191
|
+
}
|
|
3192
|
+
this.children.forEach((child, index) => {
|
|
3193
|
+
child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);
|
|
3194
|
+
if (child.getAttribute(OverflowBehaviorElements.MORE) === null) {
|
|
3195
|
+
// set moreElement children
|
|
3196
|
+
moreELementChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);
|
|
3197
|
+
}
|
|
3198
|
+
});
|
|
3199
|
+
}
|
|
3200
|
+
this.updateDisplayedItems(width);
|
|
3201
|
+
if (isMgMenuItem(this.moreELement))
|
|
3202
|
+
this.updateActiveStatus();
|
|
3203
|
+
};
|
|
3204
|
+
/**
|
|
3205
|
+
* Update displayed items in container from a given available space
|
|
3206
|
+
*
|
|
3207
|
+
* @param {number} availableWidth available width in container to display child items
|
|
3208
|
+
* @returns {void}
|
|
3209
|
+
*/
|
|
3210
|
+
this.updateDisplayedItems = (availableWidth) => {
|
|
3211
|
+
this.restoreItems();
|
|
3212
|
+
this.children.reduce((acc, curr) => {
|
|
3213
|
+
acc.accWidth += curr.offsetWidth;
|
|
3214
|
+
const isPreviousItemHidden = acc.previousItem !== null && acc.previousItem.getAttribute('hidden') !== null;
|
|
3215
|
+
// if previous item is hidden AND is NOT more element we hidde current
|
|
3216
|
+
// OR if item has an overflow we hidde current
|
|
3217
|
+
// OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item
|
|
3218
|
+
// ELSE current is a display item
|
|
3219
|
+
if ((isPreviousItemHidden && !this.isMoreElement(curr)) ||
|
|
3220
|
+
this.isOverflowElement(acc.accWidth, curr, availableWidth) ||
|
|
3221
|
+
(this.isMoreElement(curr) && !isPreviousItemHidden)) {
|
|
3222
|
+
this.toggleItem(curr, true);
|
|
3223
|
+
}
|
|
3224
|
+
else
|
|
3225
|
+
this.toggleItem(curr, false);
|
|
3226
|
+
// update previous item with current item
|
|
3227
|
+
acc.previousItem = curr;
|
|
3228
|
+
return acc;
|
|
3229
|
+
}, { accWidth: 0, previousItem: null });
|
|
3230
|
+
};
|
|
3231
|
+
/**
|
|
3232
|
+
* Utility method to know if item overflow partialy or totaly in the container
|
|
3233
|
+
*
|
|
3234
|
+
* @param {number} cumulateWidth previous sibling elements cumulate width + item width
|
|
3235
|
+
* @param {HTMLElement} item item HTML element
|
|
3236
|
+
* @param {number} availableWidth container available width
|
|
3237
|
+
* @returns {boolean} truthy if element is overflow
|
|
3238
|
+
*/
|
|
3239
|
+
this.isOverflowElement = (cumulateWidth, item, availableWidth) => {
|
|
3240
|
+
if (item.previousElementSibling === null || this.isMoreElement(item))
|
|
3241
|
+
return false;
|
|
3242
|
+
else if (!this.isMoreElement(item.nextElementSibling))
|
|
3243
|
+
return cumulateWidth + this.moreELement.offsetWidth > availableWidth;
|
|
3244
|
+
else
|
|
3245
|
+
return cumulateWidth > availableWidth;
|
|
3246
|
+
};
|
|
3247
|
+
/**
|
|
3248
|
+
* Utility method to know if a given element is the 'MORE' element
|
|
3249
|
+
*
|
|
3250
|
+
* @param {Element} element element to match with 'MORE' element
|
|
3251
|
+
* @returns {boolean} truthy if element is the 'MORE' element
|
|
3252
|
+
*/
|
|
3253
|
+
this.isMoreElement = (element) => element.getAttribute(OverflowBehaviorElements.MORE) !== null;
|
|
3254
|
+
/**
|
|
3255
|
+
* Toggle display item element
|
|
3256
|
+
*
|
|
3257
|
+
* @param {HTMLElement} item item to control
|
|
3258
|
+
* @param {boolean} isHidden is item hidden
|
|
3259
|
+
* @returns {void}
|
|
3260
|
+
*/
|
|
3261
|
+
this.toggleItem = (item, isHidden) => {
|
|
3262
|
+
const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));
|
|
3263
|
+
if (this.isMoreElement(item))
|
|
3264
|
+
this.toggleElement(this.moreELement, isHidden);
|
|
3265
|
+
else if (mgActionMenuindex >= 0) {
|
|
3266
|
+
this.toggleElement(item, isHidden);
|
|
3267
|
+
this.toggleElement(this.moreELement.querySelector(`[${OverflowBehaviorElements.PROXY_INDEX}="${mgActionMenuindex}"]`), !isHidden);
|
|
3268
|
+
}
|
|
3269
|
+
};
|
|
3270
|
+
/**
|
|
3271
|
+
* Toggle element's hidde attribute
|
|
3272
|
+
*
|
|
3273
|
+
* @param {Element} element element to toggle
|
|
3274
|
+
* @param {boolean} isHidden element is hidden
|
|
3275
|
+
* @returns {void}
|
|
3276
|
+
*/
|
|
3277
|
+
this.toggleElement = (element, isHidden) => {
|
|
3278
|
+
if (isHidden)
|
|
3279
|
+
element.setAttribute('hidden', '');
|
|
3280
|
+
else
|
|
3281
|
+
element.removeAttribute('hidden');
|
|
3282
|
+
};
|
|
3283
|
+
/**
|
|
3284
|
+
* Remove hidden attributes on all items
|
|
3285
|
+
*
|
|
3286
|
+
* @returns {void}
|
|
3287
|
+
*/
|
|
3288
|
+
this.restoreItems = () => {
|
|
3289
|
+
this.children.forEach(item => item.removeAttribute('hidden'));
|
|
3290
|
+
};
|
|
3291
|
+
if (this.resizeObserver === undefined) {
|
|
3292
|
+
// add resize observer
|
|
3293
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
3294
|
+
entries.forEach(entry => {
|
|
3295
|
+
this.run(entry.contentRect.width);
|
|
3296
|
+
});
|
|
3297
|
+
});
|
|
3298
|
+
this.resizeObserver.observe(this.element);
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
|
|
3234
3303
|
/**
|
|
3235
3304
|
* Menu direction type
|
|
3236
3305
|
*/
|
|
@@ -3239,8 +3308,25 @@ var Direction;
|
|
|
3239
3308
|
Direction["VERTICAL"] = "vertical";
|
|
3240
3309
|
Direction["HORIZONTAL"] = "horizontal";
|
|
3241
3310
|
})(Direction || (Direction = {}));
|
|
3311
|
+
/**
|
|
3312
|
+
* More item type guard
|
|
3313
|
+
*
|
|
3314
|
+
* @param {unknown} element element to control
|
|
3315
|
+
* @returns {boolean} truthy if element is more-item
|
|
3316
|
+
*/
|
|
3317
|
+
const isMoreItem = (element) => {
|
|
3318
|
+
var _a, _b, _c;
|
|
3319
|
+
const item = element;
|
|
3320
|
+
return (item === undefined ||
|
|
3321
|
+
(typeof item === 'object' &&
|
|
3322
|
+
(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')));
|
|
3323
|
+
};
|
|
3324
|
+
/**
|
|
3325
|
+
* List of all possibles sizes
|
|
3326
|
+
*/
|
|
3327
|
+
const sizes$1 = ['regular', 'medium', 'large'];
|
|
3242
3328
|
|
|
3243
|
-
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}";
|
|
3329
|
+
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}";
|
|
3244
3330
|
|
|
3245
3331
|
const MgMenu = class {
|
|
3246
3332
|
constructor(hostRef) {
|
|
@@ -3249,15 +3335,12 @@ const MgMenu = class {
|
|
|
3249
3335
|
* Internal *
|
|
3250
3336
|
************/
|
|
3251
3337
|
this.name = 'mg-menu';
|
|
3338
|
+
this.menuItems = [];
|
|
3252
3339
|
this.focusedMenuItem = 0;
|
|
3253
|
-
/**
|
|
3254
|
-
* Component display direction. Default: "horizontal"
|
|
3255
|
-
*/
|
|
3256
|
-
this.direction = Direction.HORIZONTAL;
|
|
3257
3340
|
/**
|
|
3258
3341
|
* Close matching menu-item
|
|
3259
3342
|
*
|
|
3260
|
-
* @param {
|
|
3343
|
+
* @param {HTMLElement} item menu-item to close
|
|
3261
3344
|
* @param {boolean} condition addionnal condition
|
|
3262
3345
|
* @returns {void}
|
|
3263
3346
|
*/
|
|
@@ -3266,18 +3349,19 @@ const MgMenu = class {
|
|
|
3266
3349
|
item.expanded = false;
|
|
3267
3350
|
}
|
|
3268
3351
|
};
|
|
3352
|
+
/*************
|
|
3353
|
+
* Methods *
|
|
3354
|
+
*************/
|
|
3269
3355
|
/**
|
|
3270
3356
|
* Store menu-items on component init and add listeners
|
|
3357
|
+
*
|
|
3358
|
+
* @returns {void}
|
|
3271
3359
|
*/
|
|
3272
|
-
this.
|
|
3273
|
-
// store all menu-items
|
|
3274
|
-
this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM');
|
|
3360
|
+
this.initMenuItemsListeners = () => {
|
|
3275
3361
|
// add listeners on menu item and edit index
|
|
3276
3362
|
this.menuItems.forEach((item, menuItemIndex) => {
|
|
3277
3363
|
['click', 'focus'].forEach(trigger => {
|
|
3278
|
-
(item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, (
|
|
3279
|
-
event.preventDefault();
|
|
3280
|
-
event.stopPropagation();
|
|
3364
|
+
(item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, () => {
|
|
3281
3365
|
this.focusedMenuItem = menuItemIndex;
|
|
3282
3366
|
// reset expanded on previous active menu item
|
|
3283
3367
|
this.menuItems.forEach((item, index) => {
|
|
@@ -3287,6 +3371,47 @@ const MgMenu = class {
|
|
|
3287
3371
|
});
|
|
3288
3372
|
});
|
|
3289
3373
|
};
|
|
3374
|
+
/**
|
|
3375
|
+
* render mg-menu-more
|
|
3376
|
+
*
|
|
3377
|
+
* @returns {HTMLElement} formated mg-menu-item element
|
|
3378
|
+
*/
|
|
3379
|
+
this.renderMgMenuMore = () => {
|
|
3380
|
+
const moreElement = this.element.shadowRoot.querySelector(`[${OverflowBehaviorElements.MORE}]`);
|
|
3381
|
+
this.menuItems.forEach((child) => {
|
|
3382
|
+
const proxy = child.cloneNode(true);
|
|
3383
|
+
moreElement.querySelector('mg-menu').appendChild(proxy);
|
|
3384
|
+
});
|
|
3385
|
+
const allMenuItem = Array.from(this.element.querySelectorAll('mg-menu-item:not([data-overflow-more])'));
|
|
3386
|
+
Array.from(moreElement.querySelectorAll('mg-menu-item:not([data-overflow-more])')).forEach((proxy, index) => {
|
|
3387
|
+
// manage click on proxy to mirror it on initial element
|
|
3388
|
+
proxy.addEventListener('click', () => {
|
|
3389
|
+
(allMenuItem[index].shadowRoot.querySelector('a') || allMenuItem[index].shadowRoot.querySelector('button')).dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
3390
|
+
});
|
|
3391
|
+
// manage status change miror in proxy
|
|
3392
|
+
allMenuItem[index].addEventListener('status-change', (event) => {
|
|
3393
|
+
proxy.setAttribute('status', event.detail);
|
|
3394
|
+
this.overflowBehavior.updateActiveStatus();
|
|
3395
|
+
});
|
|
3396
|
+
});
|
|
3397
|
+
this.element.appendChild(moreElement);
|
|
3398
|
+
return this.element.querySelector(`[${OverflowBehaviorElements.MORE}]`);
|
|
3399
|
+
};
|
|
3400
|
+
/**
|
|
3401
|
+
* Render mg-menu-item more element for overflow behavior
|
|
3402
|
+
*
|
|
3403
|
+
* @returns {HTMLElement} rendered mg-menu-item more element
|
|
3404
|
+
*/
|
|
3405
|
+
this.renderMgMenuItemMore = () => {
|
|
3406
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3407
|
+
return (h("mg-menu-item", { "data-overflow-more": true }, 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" }), 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), h("mg-menu", { direction: Direction.VERTICAL, label: this.messages.moreLabel, size: (_g = this.moreitem) === null || _g === void 0 ? void 0 : _g.size })));
|
|
3408
|
+
};
|
|
3409
|
+
this.label = undefined;
|
|
3410
|
+
this.direction = Direction.HORIZONTAL;
|
|
3411
|
+
this.moreitem = undefined;
|
|
3412
|
+
this.size = 'regular';
|
|
3413
|
+
this.isChildMenu = undefined;
|
|
3414
|
+
this.hasOverflow = false;
|
|
3290
3415
|
}
|
|
3291
3416
|
validateLabel(newValue) {
|
|
3292
3417
|
if (newValue === undefined) {
|
|
@@ -3298,6 +3423,19 @@ const MgMenu = class {
|
|
|
3298
3423
|
throw new Error(`<${this.name}> prop "direction" must be one of : ${Direction.HORIZONTAL}, ${Direction.VERTICAL}.`);
|
|
3299
3424
|
}
|
|
3300
3425
|
}
|
|
3426
|
+
validateMoreItem(newValue) {
|
|
3427
|
+
if (newValue !== undefined && this.direction !== Direction.HORIZONTAL) {
|
|
3428
|
+
throw new Error(`<${this.name}> prop "moreitem" must be paired with direction ${Direction.HORIZONTAL}.`);
|
|
3429
|
+
}
|
|
3430
|
+
else if (newValue !== undefined && !isMoreItem(newValue)) {
|
|
3431
|
+
throw new Error(`<${this.name}> prop "moreitem" must match MoreItemType.`);
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
validateSize(newValue) {
|
|
3435
|
+
if (!sizes$1.includes(newValue)) {
|
|
3436
|
+
throw new Error(`<${this.name}> prop "size" must be one of : ${sizes$1.join(', ')}.`);
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3301
3439
|
/*************
|
|
3302
3440
|
* Lifecycle *
|
|
3303
3441
|
*************/
|
|
@@ -3307,8 +3445,12 @@ const MgMenu = class {
|
|
|
3307
3445
|
* @returns {void}
|
|
3308
3446
|
*/
|
|
3309
3447
|
componentWillLoad() {
|
|
3448
|
+
this.messages = initLocales(this.element).messages.plusMenu;
|
|
3449
|
+
// validation
|
|
3310
3450
|
this.validateDirection(this.direction);
|
|
3311
3451
|
this.validateLabel(this.label);
|
|
3452
|
+
this.validateMoreItem(this.moreitem);
|
|
3453
|
+
this.validateSize(this.size);
|
|
3312
3454
|
}
|
|
3313
3455
|
/**
|
|
3314
3456
|
* Check if component slots configuration
|
|
@@ -3320,95 +3462,64 @@ const MgMenu = class {
|
|
|
3320
3462
|
// return a promise to process action only in the FIRST render().
|
|
3321
3463
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
3322
3464
|
return setTimeout(() => {
|
|
3323
|
-
|
|
3465
|
+
// store all menu-items
|
|
3466
|
+
this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM');
|
|
3324
3467
|
this.isChildMenu = this.element.closest('mg-menu-item') !== null;
|
|
3325
|
-
|
|
3326
|
-
if (
|
|
3327
|
-
|
|
3328
|
-
if (event.target.closest('mg-menu') === null) {
|
|
3329
|
-
this.menuItems.forEach(item => {
|
|
3330
|
-
this.closeMenuItem(item, this.direction === Direction.HORIZONTAL);
|
|
3331
|
-
});
|
|
3332
|
-
}
|
|
3333
|
-
});
|
|
3334
|
-
}
|
|
3468
|
+
this.hasOverflow = this.direction === Direction.HORIZONTAL && !this.isChildMenu;
|
|
3469
|
+
if (this.hasOverflow && isMoreItem(this.moreitem))
|
|
3470
|
+
this.overflowBehavior = new OverflowBehavior(this.element, this.renderMgMenuMore);
|
|
3335
3471
|
}, 0);
|
|
3336
3472
|
}
|
|
3473
|
+
/**
|
|
3474
|
+
* Check add listeners to childs
|
|
3475
|
+
*
|
|
3476
|
+
* @returns {void}
|
|
3477
|
+
*/
|
|
3478
|
+
componentDidRender() {
|
|
3479
|
+
// add menu items listeners
|
|
3480
|
+
this.initMenuItemsListeners();
|
|
3481
|
+
}
|
|
3482
|
+
/**
|
|
3483
|
+
* Disconnect overflow ResizeObserver
|
|
3484
|
+
*
|
|
3485
|
+
* @returns {void} run overflow resize obeserver disconnexion
|
|
3486
|
+
*/
|
|
3487
|
+
disconnectedCallback() {
|
|
3488
|
+
if (this.hasOverflow)
|
|
3489
|
+
this.overflowBehavior.disconnect();
|
|
3490
|
+
}
|
|
3337
3491
|
/**
|
|
3338
3492
|
* Render
|
|
3339
3493
|
*
|
|
3340
3494
|
* @returns {HTMLElement} HTML Element
|
|
3341
3495
|
*/
|
|
3342
3496
|
render() {
|
|
3343
|
-
return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, h("slot", null)));
|
|
3497
|
+
return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, h("slot", null), this.hasOverflow && isMoreItem(this.moreitem) && this.renderMgMenuItemMore()));
|
|
3344
3498
|
}
|
|
3345
3499
|
get element() { return getElement(this); }
|
|
3346
3500
|
static get watchers() { return {
|
|
3347
3501
|
"label": ["validateLabel"],
|
|
3348
|
-
"direction": ["validateDirection"]
|
|
3502
|
+
"direction": ["validateDirection"],
|
|
3503
|
+
"moreitem": ["validateMoreItem"],
|
|
3504
|
+
"size": ["validateSize"]
|
|
3349
3505
|
}; }
|
|
3350
3506
|
};
|
|
3351
3507
|
MgMenu.style = mgMenuCss;
|
|
3352
3508
|
|
|
3353
|
-
/**
|
|
3354
|
-
* Available menu-item positions
|
|
3355
|
-
*/
|
|
3356
|
-
var ElementPosition;
|
|
3357
|
-
(function (ElementPosition) {
|
|
3358
|
-
ElementPosition["FIRST"] = "first";
|
|
3359
|
-
ElementPosition["LAST"] = "last";
|
|
3360
|
-
})(ElementPosition || (ElementPosition = {}));
|
|
3361
|
-
/**
|
|
3362
|
-
* Available menu item status
|
|
3363
|
-
*/
|
|
3364
|
-
var Status$1;
|
|
3365
|
-
(function (Status) {
|
|
3366
|
-
Status["VISIBLE"] = "visible";
|
|
3367
|
-
Status["HIDDEN"] = "hidden";
|
|
3368
|
-
Status["DISABLED"] = "disabled";
|
|
3369
|
-
Status["ACTIVE"] = "active";
|
|
3370
|
-
})(Status$1 || (Status$1 = {}));
|
|
3371
|
-
/**
|
|
3372
|
-
* List of all possibles sizes
|
|
3373
|
-
*/
|
|
3374
|
-
const sizes$1 = ['regular', 'medium', 'large'];
|
|
3375
|
-
|
|
3376
|
-
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}";
|
|
3509
|
+
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}";
|
|
3377
3510
|
|
|
3378
3511
|
const MgMenuItem = class {
|
|
3379
3512
|
constructor(hostRef) {
|
|
3380
3513
|
registerInstance(this, hostRef);
|
|
3514
|
+
this.statusChange = createEvent(this, "status-change", 7);
|
|
3381
3515
|
/************
|
|
3382
3516
|
* Internal *
|
|
3383
3517
|
************/
|
|
3384
3518
|
this.name = 'mg-menu-item';
|
|
3385
3519
|
this.navigationButton = `${this.name}__navigation-button`;
|
|
3386
|
-
|
|
3387
|
-
* Define menu-item status. Default: "visible"
|
|
3388
|
-
*/
|
|
3389
|
-
this.status = Status$1.VISIBLE;
|
|
3390
|
-
/**
|
|
3391
|
-
* Define menu-item size. Default: "large".
|
|
3392
|
-
*/
|
|
3393
|
-
this.size = 'large';
|
|
3394
|
-
/**
|
|
3395
|
-
* Define menu-item content expanded. Default: false.
|
|
3396
|
-
*/
|
|
3397
|
-
this.expanded = false;
|
|
3398
|
-
/************
|
|
3399
|
-
* States *
|
|
3400
|
-
************/
|
|
3401
|
-
/**
|
|
3402
|
-
* Component button classes
|
|
3403
|
-
*/
|
|
3404
|
-
this.navigationButtonClassList = new ClassList([this.navigationButton]);
|
|
3405
|
-
/**
|
|
3406
|
-
* Does component have children. Default: false.
|
|
3407
|
-
*/
|
|
3408
|
-
this.hasChildren = false;
|
|
3409
|
-
/************
|
|
3520
|
+
/***********
|
|
3410
3521
|
* Methods *
|
|
3411
|
-
|
|
3522
|
+
**********/
|
|
3412
3523
|
/**
|
|
3413
3524
|
* Toggle expanded prop value
|
|
3414
3525
|
*
|
|
@@ -3418,20 +3529,20 @@ const MgMenuItem = class {
|
|
|
3418
3529
|
this.expanded = !this.expanded;
|
|
3419
3530
|
};
|
|
3420
3531
|
/**
|
|
3421
|
-
* Does an
|
|
3532
|
+
* Does an Element have given Status
|
|
3422
3533
|
*
|
|
3423
|
-
* @param {
|
|
3534
|
+
* @param {Element} element to parse
|
|
3424
3535
|
* @param {MgMenuItem['status']} status to check
|
|
3425
3536
|
* @returns {boolean} true if element with status is found
|
|
3426
3537
|
*/
|
|
3427
|
-
this.
|
|
3538
|
+
this.hasStatus = (element, status) => element.querySelector(`${this.name}[status="${status}"]`) !== null;
|
|
3428
3539
|
/**
|
|
3429
3540
|
* Is component contextual direction match the given direction
|
|
3430
3541
|
*
|
|
3431
3542
|
* @param {MgMenuItem['direction']} direction in parent menu
|
|
3432
3543
|
* @returns {boolean} true is direction match the direction propertie
|
|
3433
3544
|
*/
|
|
3434
|
-
this.
|
|
3545
|
+
this.isDirection = (direction) => this.direction === direction;
|
|
3435
3546
|
/************
|
|
3436
3547
|
* Handlers *
|
|
3437
3548
|
************/
|
|
@@ -3442,23 +3553,57 @@ const MgMenuItem = class {
|
|
|
3442
3553
|
* @returns {void}
|
|
3443
3554
|
*/
|
|
3444
3555
|
this.handleElementCLick = (event) => {
|
|
3445
|
-
|
|
3556
|
+
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status$1.DISABLED) {
|
|
3557
|
+
event.preventDefault();
|
|
3558
|
+
event.stopPropagation();
|
|
3559
|
+
}
|
|
3560
|
+
// toggle expanded when mg-menu-item has child items
|
|
3446
3561
|
if (this.hasChildren)
|
|
3447
3562
|
this.toggleExpanded();
|
|
3448
3563
|
};
|
|
3564
|
+
/**
|
|
3565
|
+
* Handle popover element display-change event
|
|
3566
|
+
*
|
|
3567
|
+
* @param {CustomEvent} event popover display event
|
|
3568
|
+
* @returns {void}
|
|
3569
|
+
*/
|
|
3570
|
+
this.handlePopoverDisplay = (event) => {
|
|
3571
|
+
this.expanded = event.detail;
|
|
3572
|
+
};
|
|
3573
|
+
/**
|
|
3574
|
+
* Update displayNotificationBadge
|
|
3575
|
+
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
3576
|
+
*
|
|
3577
|
+
* @returns {void} update displayNotificationBadge value
|
|
3578
|
+
*/
|
|
3579
|
+
this.updateDisplayNotificationBadge = () => {
|
|
3580
|
+
const childMenu = this.element.querySelector('mg-menu');
|
|
3581
|
+
this.displayNotificationBadge =
|
|
3582
|
+
childMenu !== null &&
|
|
3583
|
+
Array.from(childMenu.children).some((subItem) => subItem.querySelector('mg-badge') !== null && subItem.getAttribute('hidden') === null);
|
|
3584
|
+
};
|
|
3585
|
+
/**
|
|
3586
|
+
* Render slot
|
|
3587
|
+
*
|
|
3588
|
+
* @returns {HTMLElement} HTML Element
|
|
3589
|
+
*/
|
|
3590
|
+
this.renderSlot = () => h("slot", null);
|
|
3591
|
+
this.href = undefined;
|
|
3592
|
+
this.status = Status$1.VISIBLE;
|
|
3593
|
+
this.expanded = false;
|
|
3594
|
+
this.size = 'regular';
|
|
3595
|
+
this.navigationButtonClassList = new ClassList([this.navigationButton]);
|
|
3596
|
+
this.direction = undefined;
|
|
3597
|
+
this.isInMainMenu = undefined;
|
|
3598
|
+
this.hasChildren = false;
|
|
3599
|
+
this.displayNotificationBadge = undefined;
|
|
3449
3600
|
}
|
|
3450
3601
|
validateStatus(newValue, oldValue) {
|
|
3451
3602
|
if (oldValue !== undefined) {
|
|
3452
3603
|
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
3453
3604
|
}
|
|
3454
3605
|
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
3455
|
-
|
|
3456
|
-
validateSize(newValue, oldValue) {
|
|
3457
|
-
if (!sizes$1.includes(newValue)) {
|
|
3458
|
-
throw new Error(`<${this.name}> prop "size" must be one of : ${sizes$1.join(', ')}.`);
|
|
3459
|
-
}
|
|
3460
|
-
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
3461
|
-
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
3606
|
+
this.statusChange.emit(newValue);
|
|
3462
3607
|
}
|
|
3463
3608
|
validateExpanded(newValue) {
|
|
3464
3609
|
if (typeof newValue !== 'boolean')
|
|
@@ -3472,16 +3617,20 @@ const MgMenuItem = class {
|
|
|
3472
3617
|
item.expanded = false;
|
|
3473
3618
|
});
|
|
3474
3619
|
}
|
|
3475
|
-
else if (
|
|
3620
|
+
else if (this.hasStatus(this.element, Status$1.ACTIVE)) {
|
|
3476
3621
|
// - when expanded and contain an active item parents are expended too
|
|
3477
3622
|
subItems.forEach(item => {
|
|
3478
|
-
if (this.
|
|
3623
|
+
if (this.hasStatus(item, Status$1.ACTIVE)) {
|
|
3479
3624
|
item.expanded = true;
|
|
3480
3625
|
}
|
|
3481
3626
|
});
|
|
3482
3627
|
}
|
|
3483
3628
|
}
|
|
3484
3629
|
}
|
|
3630
|
+
validateSize(newValue, oldValue) {
|
|
3631
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
3632
|
+
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
3633
|
+
}
|
|
3485
3634
|
validateHasChildren(newValue) {
|
|
3486
3635
|
if (newValue && this.element.href !== undefined) {
|
|
3487
3636
|
throw new Error(`<${this.name}> prop "href" is unauthorizied when element is a parent.`);
|
|
@@ -3496,13 +3645,14 @@ const MgMenuItem = class {
|
|
|
3496
3645
|
* @returns {void}
|
|
3497
3646
|
*/
|
|
3498
3647
|
componentWillLoad() {
|
|
3499
|
-
// has children items that is NOT [slot=
|
|
3648
|
+
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
3500
3649
|
// we store only matching elements
|
|
3501
|
-
this.hasChildren = Array.from(this.element.children).
|
|
3650
|
+
this.hasChildren = Array.from(this.element.children).some(child => !['image', 'information', 'label', 'metadata'].includes(child.getAttribute('slot')));
|
|
3502
3651
|
// Validate props
|
|
3503
3652
|
this.validateSize(this.size);
|
|
3504
3653
|
this.validateStatus(this.status);
|
|
3505
3654
|
this.validateExpanded(this.expanded);
|
|
3655
|
+
this.badgeLabel = initLocales(this.element).messages.plusMenu.badgeLabel;
|
|
3506
3656
|
}
|
|
3507
3657
|
/**
|
|
3508
3658
|
* Check if component slots configuration
|
|
@@ -3526,55 +3676,73 @@ const MgMenuItem = class {
|
|
|
3526
3676
|
// return a promise to process action only in the FIRST render().
|
|
3527
3677
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
3528
3678
|
return setTimeout(() => {
|
|
3529
|
-
var _a
|
|
3679
|
+
var _a;
|
|
3530
3680
|
// define menu-item context states
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
this.isInMainMenu = this.element.parentElement.
|
|
3535
|
-
const hasNextMenuItem = ((_a = this.element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.nodeName) === 'MG-MENU-ITEM';
|
|
3536
|
-
const hasPreviousMenuItem = ((_b = this.element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.nodeName) === 'MG-MENU-ITEM';
|
|
3537
|
-
// manage last menu item
|
|
3538
|
-
if (!hasNextMenuItem && hasPreviousMenuItem && this.isdirection(Direction.HORIZONTAL)) {
|
|
3539
|
-
this.element.setAttribute('data-style-position-last', '');
|
|
3540
|
-
}
|
|
3681
|
+
const menu = this.element.closest('mg-menu');
|
|
3682
|
+
this.direction = this.element.getAttribute(OverflowBehaviorElements.MORE) !== null || menu === null ? Direction.HORIZONTAL : menu.direction;
|
|
3683
|
+
this.size = menu === null || menu === void 0 ? void 0 : menu.size;
|
|
3684
|
+
this.isInMainMenu = this.element.parentElement.closest('mg-menu-item') === null;
|
|
3541
3685
|
// when main menu item contain an active item it will get the active style
|
|
3542
3686
|
// AND if item is in vertical menu it will be expanded
|
|
3543
|
-
|
|
3687
|
+
const hasActiveChild = Array.from(this.element.children).some(element => this.hasStatus(element, Status$1.ACTIVE) && element.getAttribute('hidden') === null);
|
|
3688
|
+
if (this.isInMainMenu && hasActiveChild) {
|
|
3544
3689
|
this.status = Status$1.ACTIVE;
|
|
3545
|
-
this.expanded = this.
|
|
3690
|
+
this.expanded = this.isDirection(Direction.VERTICAL);
|
|
3546
3691
|
}
|
|
3547
3692
|
// manage menu items style depending to parent menu horientation
|
|
3548
3693
|
this.element.setAttribute(`data-style-direction-${this.direction}`, '');
|
|
3549
3694
|
this.navigationButtonClassList.add(`${this.navigationButton}--${this.direction}`);
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3695
|
+
this.updateDisplayNotificationBadge();
|
|
3696
|
+
// manage all sub levels child menu-items level with data-level attribut
|
|
3697
|
+
if (this.isDirection(Direction.VERTICAL)) {
|
|
3698
|
+
Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
|
|
3554
3699
|
const itemLevel = Number(item.getAttribute('data-level')) || 1;
|
|
3555
3700
|
item.setAttribute('data-level', `${itemLevel + 1}`);
|
|
3556
|
-
}
|
|
3701
|
+
});
|
|
3702
|
+
}
|
|
3703
|
+
// manage first sub-level menu-items
|
|
3704
|
+
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');
|
|
3705
|
+
childItems.forEach(item => {
|
|
3706
|
+
// manage child menu listener
|
|
3707
|
+
new MutationObserver(() => {
|
|
3708
|
+
this.updateDisplayNotificationBadge();
|
|
3709
|
+
}).observe(item, { attributes: true });
|
|
3557
3710
|
});
|
|
3558
3711
|
}, 0);
|
|
3559
3712
|
}
|
|
3713
|
+
/**
|
|
3714
|
+
* Render ineractive element
|
|
3715
|
+
*
|
|
3716
|
+
* @returns {HTMLElement} HTML Element
|
|
3717
|
+
*/
|
|
3718
|
+
renderInteractiveElement() {
|
|
3719
|
+
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
3720
|
+
return (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 }, h("slot", { name: "image" }), h("div", { class: `${this.navigationButton}-center` }, h("div", { class: `${this.navigationButton}-text-content` }, h("slot", { name: "label" }), !this.displayNotificationBadge && h("slot", { name: "information" }), this.displayNotificationBadge && (h("span", { class: "mg-menu-item__navigation-button-text-content-notification" }, h("mg-badge", { label: this.badgeLabel, value: "!", variant: "info", slot: "information" })))), this.size !== 'regular' && h("slot", { name: "metadata" })), this.hasChildren && this.href === undefined && (h("span", { class: {
|
|
3721
|
+
[`${this.navigationButton}-chevron`]: true,
|
|
3722
|
+
[`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
|
|
3723
|
+
'mg-a11y-animation': true,
|
|
3724
|
+
} }, h("mg-icon", { icon: "chevron-down" })))));
|
|
3725
|
+
}
|
|
3560
3726
|
/**
|
|
3561
3727
|
* Render
|
|
3562
3728
|
*
|
|
3563
3729
|
* @returns {HTMLElement} HTML Element
|
|
3564
3730
|
*/
|
|
3565
3731
|
render() {
|
|
3566
|
-
const
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3732
|
+
const getContainerClasses = () => ({
|
|
3733
|
+
[`${this.name}__collapse-container`]: true,
|
|
3734
|
+
[`${this.name}__collapse-container--first-level`]: this.isInMainMenu && this.isDirection(Direction.HORIZONTAL),
|
|
3735
|
+
});
|
|
3736
|
+
return (h(Host, { role: "menuitem", "aria-haspopup": this.hasChildren.toString() }, this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined ? (h("mg-popover", { display: this.expanded, placement: "bottom-start", arrowHide: true, "onDisplay-change": this.handlePopoverDisplay }, this.renderInteractiveElement(), h("div", { class: getContainerClasses(), slot: "content" }, this.renderSlot()))) : ([
|
|
3737
|
+
this.renderInteractiveElement(),
|
|
3738
|
+
h("div", { class: getContainerClasses(), hidden: !this.expanded }, this.renderSlot()),
|
|
3739
|
+
])));
|
|
3572
3740
|
}
|
|
3573
3741
|
get element() { return getElement(this); }
|
|
3574
3742
|
static get watchers() { return {
|
|
3575
3743
|
"status": ["validateStatus"],
|
|
3576
|
-
"size": ["validateSize"],
|
|
3577
3744
|
"expanded": ["validateExpanded"],
|
|
3745
|
+
"size": ["validateSize"],
|
|
3578
3746
|
"hasChildren": ["validateHasChildren"]
|
|
3579
3747
|
}; }
|
|
3580
3748
|
};
|
|
@@ -3585,7 +3753,7 @@ MgMenuItem.style = mgMenuItemCss;
|
|
|
3585
3753
|
*/
|
|
3586
3754
|
const variants$1 = ['info', 'warning', 'success', 'danger'];
|
|
3587
3755
|
|
|
3588
|
-
const mgMessageCss = "
|
|
3756
|
+
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%}";
|
|
3589
3757
|
|
|
3590
3758
|
const MgMessage = class {
|
|
3591
3759
|
constructor(hostRef) {
|
|
@@ -3601,49 +3769,50 @@ const MgMessage = class {
|
|
|
3601
3769
|
this.closeButtonId = '';
|
|
3602
3770
|
// Stored timer setted when hide action is run from setTimeOut
|
|
3603
3771
|
this.storedTimer = null;
|
|
3772
|
+
// Manage hover
|
|
3773
|
+
this.isFocused = false;
|
|
3774
|
+
this.isHovered = false;
|
|
3604
3775
|
/**
|
|
3605
|
-
*
|
|
3606
|
-
*
|
|
3607
|
-
|
|
3608
|
-
this.identifier = createID('mg-message');
|
|
3609
|
-
/**
|
|
3610
|
-
* Message variant
|
|
3611
|
-
*/
|
|
3612
|
-
this.variant = variants$1[0]; // info
|
|
3613
|
-
/**
|
|
3614
|
-
* Define if message has a cross button
|
|
3615
|
-
* RG 01: https://jira.mgdis.fr/browse/PDA9-140
|
|
3616
|
-
*/
|
|
3617
|
-
this.closeButton = false;
|
|
3618
|
-
/**
|
|
3619
|
-
* Define if message is hidden
|
|
3776
|
+
* Set timer
|
|
3777
|
+
*
|
|
3778
|
+
* @returns {void}
|
|
3620
3779
|
*/
|
|
3621
|
-
this.
|
|
3780
|
+
this.setTimer = () => {
|
|
3781
|
+
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
3782
|
+
};
|
|
3622
3783
|
/**
|
|
3623
|
-
*
|
|
3784
|
+
* Clear timer
|
|
3785
|
+
*
|
|
3786
|
+
* @returns {void}
|
|
3624
3787
|
*/
|
|
3625
|
-
this.
|
|
3788
|
+
this.clearTimer = () => {
|
|
3789
|
+
clearTimeout(this.storedTimer);
|
|
3790
|
+
};
|
|
3626
3791
|
/**
|
|
3627
|
-
*
|
|
3792
|
+
* Event to add on element
|
|
3793
|
+
*
|
|
3794
|
+
* @param {MouseEvent | FocusEvent} event event
|
|
3795
|
+
* @returns {void}
|
|
3628
3796
|
*/
|
|
3629
|
-
this.
|
|
3797
|
+
this.timerEvents = (event) => {
|
|
3798
|
+
this.clearTimer();
|
|
3799
|
+
const isMouseEvent = event.type === 'mouseenter';
|
|
3800
|
+
// Needed to ensure we don't start the timer
|
|
3801
|
+
this[isMouseEvent ? 'isHovered' : 'isFocused'] = true;
|
|
3802
|
+
// Restart timer when loose focus AND mouse leave
|
|
3803
|
+
this.element.addEventListener(isMouseEvent ? 'mouseleave' : 'focusout', eventOut => {
|
|
3804
|
+
this[eventOut.type === 'mouseleave' ? 'isHovered' : 'isFocused'] = false;
|
|
3805
|
+
// Start timer if needed
|
|
3806
|
+
if (!this.isFocused && !this.isHovered)
|
|
3807
|
+
this.setTimer();
|
|
3808
|
+
}, { once: true });
|
|
3809
|
+
};
|
|
3630
3810
|
/**
|
|
3631
3811
|
* Handle close button
|
|
3632
3812
|
*/
|
|
3633
3813
|
this.handleClose = () => {
|
|
3634
3814
|
this.hide = true;
|
|
3635
3815
|
};
|
|
3636
|
-
/**
|
|
3637
|
-
* Hide component whith delay
|
|
3638
|
-
*/
|
|
3639
|
-
this.hideWithDelay = () => {
|
|
3640
|
-
if (this.delay > 0 && this.hide !== true) {
|
|
3641
|
-
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
3642
|
-
}
|
|
3643
|
-
else if (this.storedTimer !== null) {
|
|
3644
|
-
clearTimeout(this.storedTimer);
|
|
3645
|
-
}
|
|
3646
|
-
};
|
|
3647
3816
|
/**
|
|
3648
3817
|
* Get icon corresponding to variant
|
|
3649
3818
|
*
|
|
@@ -3661,6 +3830,13 @@ const MgMessage = class {
|
|
|
3661
3830
|
return 'exclamation-circle';
|
|
3662
3831
|
}
|
|
3663
3832
|
};
|
|
3833
|
+
this.identifier = createID('mg-message');
|
|
3834
|
+
this.delay = undefined;
|
|
3835
|
+
this.variant = variants$1[0];
|
|
3836
|
+
this.closeButton = false;
|
|
3837
|
+
this.hide = false;
|
|
3838
|
+
this.classList = new ClassList(['mg-message']);
|
|
3839
|
+
this.hasActions = false;
|
|
3664
3840
|
}
|
|
3665
3841
|
validateDelay(newValue) {
|
|
3666
3842
|
if (newValue && newValue < 2) {
|
|
@@ -3688,12 +3864,26 @@ const MgMessage = class {
|
|
|
3688
3864
|
if (newValue) {
|
|
3689
3865
|
this.componentHide.emit();
|
|
3690
3866
|
this.classList.add(this.classHide);
|
|
3867
|
+
// Remove event Listener
|
|
3868
|
+
['focusin', 'mouseenter'].forEach(event => {
|
|
3869
|
+
this.element.removeEventListener(event, this.timerEvents);
|
|
3870
|
+
});
|
|
3871
|
+
// Clear Timer
|
|
3872
|
+
this.clearTimer();
|
|
3691
3873
|
}
|
|
3692
3874
|
else {
|
|
3693
3875
|
this.componentShow.emit();
|
|
3694
3876
|
this.classList.delete(this.classHide);
|
|
3877
|
+
// If delay is set
|
|
3878
|
+
if (this.delay > 1) {
|
|
3879
|
+
// Start timer
|
|
3880
|
+
this.setTimer();
|
|
3881
|
+
// Stop timer when get focus or mouse enter
|
|
3882
|
+
['focusin', 'mouseenter'].forEach(event => {
|
|
3883
|
+
this.element.addEventListener(event, this.timerEvents);
|
|
3884
|
+
});
|
|
3885
|
+
}
|
|
3695
3886
|
}
|
|
3696
|
-
this.hideWithDelay();
|
|
3697
3887
|
}
|
|
3698
3888
|
/*************
|
|
3699
3889
|
* Lifecycle *
|
|
@@ -3722,7 +3912,7 @@ const MgMessage = class {
|
|
|
3722
3912
|
* @returns {HTMLElement} HTML Element
|
|
3723
3913
|
*/
|
|
3724
3914
|
render() {
|
|
3725
|
-
return (h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" }))))));
|
|
3915
|
+
return (h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("mg-card", null, h("span", { class: "mg-message__bar" }), h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))))));
|
|
3726
3916
|
}
|
|
3727
3917
|
get element() { return getElement(this); }
|
|
3728
3918
|
static get watchers() { return {
|
|
@@ -3734,7 +3924,7 @@ const MgMessage = class {
|
|
|
3734
3924
|
};
|
|
3735
3925
|
MgMessage.style = mgMessageCss;
|
|
3736
3926
|
|
|
3737
|
-
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:
|
|
3927
|
+
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)}";
|
|
3738
3928
|
|
|
3739
3929
|
const MgModal = class {
|
|
3740
3930
|
constructor(hostRef) {
|
|
@@ -3746,31 +3936,6 @@ const MgModal = class {
|
|
|
3746
3936
|
// IDs
|
|
3747
3937
|
this.closeButtonId = '';
|
|
3748
3938
|
this.titleId = '';
|
|
3749
|
-
/**
|
|
3750
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
3751
|
-
* If not set, it will be created.
|
|
3752
|
-
*/
|
|
3753
|
-
this.identifier = createID('mg-modal');
|
|
3754
|
-
/**
|
|
3755
|
-
* Define if modal has a cross button
|
|
3756
|
-
*/
|
|
3757
|
-
this.closeButton = false;
|
|
3758
|
-
/**
|
|
3759
|
-
* Define if modal is hidden
|
|
3760
|
-
*/
|
|
3761
|
-
this.hide = false;
|
|
3762
|
-
/**
|
|
3763
|
-
* Define if component is using actions slot
|
|
3764
|
-
*/
|
|
3765
|
-
this.hasActions = false;
|
|
3766
|
-
/**
|
|
3767
|
-
* Define if component is using content slot
|
|
3768
|
-
*/
|
|
3769
|
-
this.hasContent = false;
|
|
3770
|
-
/**
|
|
3771
|
-
* Component classes
|
|
3772
|
-
*/
|
|
3773
|
-
this.classList = new ClassList(['mg-modal']);
|
|
3774
3939
|
this.setFocus = () => {
|
|
3775
3940
|
// Get all focusable elements
|
|
3776
3941
|
this.modalFocusableElements = Array.from(this.element.querySelectorAll(focusableElements)).reduce((acc, focusableElement) => {
|
|
@@ -3813,6 +3978,13 @@ const MgModal = class {
|
|
|
3813
3978
|
this.handleClose = () => {
|
|
3814
3979
|
this.hide = true;
|
|
3815
3980
|
};
|
|
3981
|
+
this.identifier = createID('mg-modal');
|
|
3982
|
+
this.modalTitle = undefined;
|
|
3983
|
+
this.closeButton = false;
|
|
3984
|
+
this.hide = false;
|
|
3985
|
+
this.hasActions = false;
|
|
3986
|
+
this.hasContent = false;
|
|
3987
|
+
this.classList = new ClassList(['mg-modal']);
|
|
3816
3988
|
}
|
|
3817
3989
|
validateModalTitle(newValue) {
|
|
3818
3990
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -3888,7 +4060,7 @@ const MgModal = class {
|
|
|
3888
4060
|
* @returns {HTMLElement} HTML Element
|
|
3889
4061
|
*/
|
|
3890
4062
|
render() {
|
|
3891
|
-
return (h("
|
|
4063
|
+
return (h("div", { role: "alertdialog", id: this.identifier, class: this.classList.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, h("mg-card", null, h("div", { class: "mg-modal__dialog" }, h("header", { class: "mg-modal__header" }, this.closeButton && (h("span", { class: "mg-modal__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))), h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (h("article", { class: "mg-modal__content" }, h("slot", { name: "content" }))), this.hasActions && (h("footer", { class: "mg-modal__footer" }, h("slot", { name: "actions" })))))));
|
|
3892
4064
|
}
|
|
3893
4065
|
get element() { return getElement(this); }
|
|
3894
4066
|
static get watchers() { return {
|
|
@@ -3931,19 +4103,6 @@ const MgPagination = class {
|
|
|
3931
4103
|
constructor(hostRef) {
|
|
3932
4104
|
registerInstance(this, hostRef);
|
|
3933
4105
|
this.currentPageChange = createEvent(this, "current-page-change", 7);
|
|
3934
|
-
/**
|
|
3935
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
3936
|
-
* If not set, it will be created.
|
|
3937
|
-
*/
|
|
3938
|
-
this.identifier = createID('mg-pagination');
|
|
3939
|
-
/**
|
|
3940
|
-
* Component total pages
|
|
3941
|
-
*/
|
|
3942
|
-
this.totalPages = 1;
|
|
3943
|
-
/**
|
|
3944
|
-
* Component current page
|
|
3945
|
-
*/
|
|
3946
|
-
this.currentPage = 1;
|
|
3947
4106
|
/**
|
|
3948
4107
|
* Change current page from target
|
|
3949
4108
|
*
|
|
@@ -3976,6 +4135,10 @@ const MgPagination = class {
|
|
|
3976
4135
|
this.handleGoToPage = (action, disabled) => {
|
|
3977
4136
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
3978
4137
|
};
|
|
4138
|
+
this.identifier = createID('mg-pagination');
|
|
4139
|
+
this.label = undefined;
|
|
4140
|
+
this.totalPages = 1;
|
|
4141
|
+
this.currentPage = 1;
|
|
3979
4142
|
}
|
|
3980
4143
|
validateTotalPages(newValue) {
|
|
3981
4144
|
if (newValue < 1) {
|
|
@@ -4029,34 +4192,13 @@ const MgPagination = class {
|
|
|
4029
4192
|
};
|
|
4030
4193
|
MgPagination.style = mgPaginationCss;
|
|
4031
4194
|
|
|
4032
|
-
const mgPanelCss = "
|
|
4195
|
+
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)}";
|
|
4033
4196
|
|
|
4034
4197
|
const MgPanel = class {
|
|
4035
4198
|
constructor(hostRef) {
|
|
4036
4199
|
registerInstance(this, hostRef);
|
|
4037
4200
|
this.titleChange = createEvent(this, "title-change", 7);
|
|
4038
4201
|
this.expandedChange = createEvent(this, "expanded-change", 7);
|
|
4039
|
-
/**
|
|
4040
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
4041
|
-
* If not set, it will be created.
|
|
4042
|
-
*/
|
|
4043
|
-
this.identifier = createID('mg-panel');
|
|
4044
|
-
/**
|
|
4045
|
-
* Panel is opened
|
|
4046
|
-
*/
|
|
4047
|
-
this.expanded = false;
|
|
4048
|
-
/**
|
|
4049
|
-
* Panel title is editabled
|
|
4050
|
-
*/
|
|
4051
|
-
this.titleEditable = false;
|
|
4052
|
-
/**
|
|
4053
|
-
* Component classes
|
|
4054
|
-
*/
|
|
4055
|
-
this.classList = new ClassList(['mg-panel']);
|
|
4056
|
-
/**
|
|
4057
|
-
* Title is in edition mode
|
|
4058
|
-
*/
|
|
4059
|
-
this.isEditing = false;
|
|
4060
4202
|
/************
|
|
4061
4203
|
* Methods *
|
|
4062
4204
|
************/
|
|
@@ -4141,6 +4283,16 @@ const MgPanel = class {
|
|
|
4141
4283
|
}
|
|
4142
4284
|
return collapseButton();
|
|
4143
4285
|
};
|
|
4286
|
+
this.identifier = createID('mg-panel');
|
|
4287
|
+
this.panelTitle = undefined;
|
|
4288
|
+
this.titlePattern = undefined;
|
|
4289
|
+
this.titlePatternErrorMessage = undefined;
|
|
4290
|
+
this.expanded = false;
|
|
4291
|
+
this.expandToggleDisabled = undefined;
|
|
4292
|
+
this.titleEditable = false;
|
|
4293
|
+
this.classList = new ClassList(['mg-panel']);
|
|
4294
|
+
this.isEditing = false;
|
|
4295
|
+
this.updatedPanelTitle = undefined;
|
|
4144
4296
|
}
|
|
4145
4297
|
validatePanelTitle(newValue) {
|
|
4146
4298
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -4191,7 +4343,7 @@ const MgPanel = class {
|
|
|
4191
4343
|
* @returns {HTMLElement} html element
|
|
4192
4344
|
*/
|
|
4193
4345
|
render() {
|
|
4194
|
-
return (h("section", { class: this.classList.join(), id: this.identifier }, h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), h("div", { class: "mg-panel__header-right" }, h("slot", { name: "header-right" }))), h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, h("slot", null))));
|
|
4346
|
+
return (h("section", { class: this.classList.join(), id: this.identifier }, h("mg-card", null, h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), h("div", { class: "mg-panel__header-right" }, h("slot", { name: "header-right" }))), h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, h("slot", null)))));
|
|
4195
4347
|
}
|
|
4196
4348
|
get element() { return getElement(this); }
|
|
4197
4349
|
static get watchers() { return {
|
|
@@ -6000,34 +6152,15 @@ var createPopper = /*#__PURE__*/popperGenerator({
|
|
|
6000
6152
|
defaultModifiers: defaultModifiers
|
|
6001
6153
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
6002
6154
|
|
|
6003
|
-
const mgPopoverCss = "mg-
|
|
6155
|
+
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)}";
|
|
6004
6156
|
|
|
6005
6157
|
const MgPopover = class {
|
|
6006
6158
|
constructor(hostRef) {
|
|
6007
6159
|
registerInstance(this, hostRef);
|
|
6008
6160
|
this.displayChange = createEvent(this, "display-change", 7);
|
|
6009
6161
|
this.closeButtonId = '';
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
* Needed by the input for accessibility `aria-decribedby`.
|
|
6013
|
-
*/
|
|
6014
|
-
this.identifier = createID('mg-popover');
|
|
6015
|
-
/**
|
|
6016
|
-
* Popover placement
|
|
6017
|
-
*/
|
|
6018
|
-
this.placement = 'bottom';
|
|
6019
|
-
/**
|
|
6020
|
-
* Define if popover has a cross button
|
|
6021
|
-
*/
|
|
6022
|
-
this.closeButton = false;
|
|
6023
|
-
/**
|
|
6024
|
-
* Display popover
|
|
6025
|
-
*/
|
|
6026
|
-
this.display = false;
|
|
6027
|
-
/**
|
|
6028
|
-
* Disable popover
|
|
6029
|
-
*/
|
|
6030
|
-
this.disabled = false;
|
|
6162
|
+
// Classes
|
|
6163
|
+
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
6031
6164
|
/**
|
|
6032
6165
|
* Check if clicked outside of component
|
|
6033
6166
|
*
|
|
@@ -6054,7 +6187,9 @@ const MgPopover = class {
|
|
|
6054
6187
|
// hide when click outside
|
|
6055
6188
|
// setTimeout is used to prevent event to trigger after creation
|
|
6056
6189
|
setTimeout(() => {
|
|
6057
|
-
|
|
6190
|
+
this.windows.forEach((localWindow) => {
|
|
6191
|
+
localWindow.addEventListener('click', this.clickOutside, false);
|
|
6192
|
+
});
|
|
6058
6193
|
}, 0);
|
|
6059
6194
|
};
|
|
6060
6195
|
/**
|
|
@@ -6068,7 +6203,9 @@ const MgPopover = class {
|
|
|
6068
6203
|
// Disable the event listeners
|
|
6069
6204
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
6070
6205
|
// Remove event listener
|
|
6071
|
-
|
|
6206
|
+
this.windows.forEach((localWindow) => {
|
|
6207
|
+
localWindow.removeEventListener('click', this.clickOutside, false);
|
|
6208
|
+
});
|
|
6072
6209
|
};
|
|
6073
6210
|
/**
|
|
6074
6211
|
* Handle action for close button
|
|
@@ -6078,6 +6215,19 @@ const MgPopover = class {
|
|
|
6078
6215
|
this.handleCloseButton = () => {
|
|
6079
6216
|
this.display = false;
|
|
6080
6217
|
};
|
|
6218
|
+
this.identifier = createID('mg-popover');
|
|
6219
|
+
this.placement = 'bottom';
|
|
6220
|
+
this.arrowHide = false;
|
|
6221
|
+
this.closeButton = false;
|
|
6222
|
+
this.display = false;
|
|
6223
|
+
this.disabled = false;
|
|
6224
|
+
this.classList = new ClassList(['mg-popover']);
|
|
6225
|
+
}
|
|
6226
|
+
validateArrowHide(newValue) {
|
|
6227
|
+
if (newValue)
|
|
6228
|
+
this.classList.add(this.classArrowHide);
|
|
6229
|
+
else
|
|
6230
|
+
this.classList.delete(this.classArrowHide);
|
|
6081
6231
|
}
|
|
6082
6232
|
handleDisplay(newValue) {
|
|
6083
6233
|
if (newValue) {
|
|
@@ -6097,8 +6247,11 @@ const MgPopover = class {
|
|
|
6097
6247
|
* @returns {void} timeout
|
|
6098
6248
|
*/
|
|
6099
6249
|
componentWillLoad() {
|
|
6250
|
+
// Get windows to attach events
|
|
6251
|
+
this.windows = getWindows(window);
|
|
6100
6252
|
// Get locales
|
|
6101
6253
|
this.messages = initLocales(this.element).messages;
|
|
6254
|
+
this.validateArrowHide(this.arrowHide);
|
|
6102
6255
|
}
|
|
6103
6256
|
/**
|
|
6104
6257
|
* Check if component props are well configured on init
|
|
@@ -6116,7 +6269,7 @@ const MgPopover = class {
|
|
|
6116
6269
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
6117
6270
|
}
|
|
6118
6271
|
// Get popover content
|
|
6119
|
-
this.popover = this.element.shadowRoot.
|
|
6272
|
+
this.popover = this.element.shadowRoot.getElementById(this.identifier);
|
|
6120
6273
|
//Get interactive element (first element without slot attribute)
|
|
6121
6274
|
const interactiveElement = this.element.querySelector(':not([slot])');
|
|
6122
6275
|
// Add aria attributes
|
|
@@ -6130,7 +6283,7 @@ const MgPopover = class {
|
|
|
6130
6283
|
{
|
|
6131
6284
|
name: 'offset',
|
|
6132
6285
|
options: {
|
|
6133
|
-
offset: [0,
|
|
6286
|
+
offset: [0, 0],
|
|
6134
6287
|
},
|
|
6135
6288
|
},
|
|
6136
6289
|
],
|
|
@@ -6153,15 +6306,71 @@ const MgPopover = class {
|
|
|
6153
6306
|
* @returns {HTMLElement} HTML Element
|
|
6154
6307
|
*/
|
|
6155
6308
|
render() {
|
|
6156
|
-
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: "mg-
|
|
6309
|
+
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: this.classList.join() }, h("mg-card", null, this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { icon: "cross" }))), h("div", { class: "mg-popover__title" }, h("slot", { name: "title" })), h("slot", { name: "content" })), !this.arrowHide && h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
6157
6310
|
}
|
|
6158
6311
|
get element() { return getElement(this); }
|
|
6159
6312
|
static get watchers() { return {
|
|
6313
|
+
"arrowHide": ["validateArrowHide"],
|
|
6160
6314
|
"display": ["handleDisplay"]
|
|
6161
6315
|
}; }
|
|
6162
6316
|
};
|
|
6163
6317
|
MgPopover.style = mgPopoverCss;
|
|
6164
6318
|
|
|
6319
|
+
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)}";
|
|
6320
|
+
|
|
6321
|
+
const MgSkipLinks = class {
|
|
6322
|
+
constructor(hostRef) {
|
|
6323
|
+
registerInstance(this, hostRef);
|
|
6324
|
+
this.goToAnchor = createEvent(this, "go-to-anchor", 7);
|
|
6325
|
+
/***********
|
|
6326
|
+
* Methods *
|
|
6327
|
+
**********/
|
|
6328
|
+
/**
|
|
6329
|
+
* Handle link click and emit go-to-anchor event
|
|
6330
|
+
*
|
|
6331
|
+
* @param {MouseEvent} event mouse event
|
|
6332
|
+
* @returns {void}
|
|
6333
|
+
*/
|
|
6334
|
+
this.handleLinkCLick = (event) => {
|
|
6335
|
+
event.currentTarget.blur();
|
|
6336
|
+
this.goToAnchor.emit(event.currentTarget.getAttribute('href'));
|
|
6337
|
+
};
|
|
6338
|
+
this.links = undefined;
|
|
6339
|
+
}
|
|
6340
|
+
validateLinks(links) {
|
|
6341
|
+
if (links === undefined ||
|
|
6342
|
+
links.length === 0 ||
|
|
6343
|
+
links.some(link => link.href === undefined || !link.href.startsWith('#') || link.label === undefined || link.label.trim() === '')) {
|
|
6344
|
+
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.`);
|
|
6345
|
+
}
|
|
6346
|
+
}
|
|
6347
|
+
/*************
|
|
6348
|
+
* Lifecycle *
|
|
6349
|
+
*************/
|
|
6350
|
+
/**
|
|
6351
|
+
* Check if props are well configured on init
|
|
6352
|
+
*
|
|
6353
|
+
* @returns {void}
|
|
6354
|
+
*/
|
|
6355
|
+
componentWillLoad() {
|
|
6356
|
+
this.validateLinks(this.links);
|
|
6357
|
+
this.messages = initLocales(this.element).messages;
|
|
6358
|
+
}
|
|
6359
|
+
/**
|
|
6360
|
+
* Render
|
|
6361
|
+
*
|
|
6362
|
+
* @returns {HTMLElement} HTML Element
|
|
6363
|
+
*/
|
|
6364
|
+
render() {
|
|
6365
|
+
return (h("nav", { class: "mg-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, h("ul", { class: "mg-skip-links__list" }, this.links.map(link => (h("li", null, h("a", { class: "mg-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
6366
|
+
}
|
|
6367
|
+
get element() { return getElement(this); }
|
|
6368
|
+
static get watchers() { return {
|
|
6369
|
+
"links": ["validateLinks"]
|
|
6370
|
+
}; }
|
|
6371
|
+
};
|
|
6372
|
+
MgSkipLinks.style = mgSkipLinksCss;
|
|
6373
|
+
|
|
6165
6374
|
/**
|
|
6166
6375
|
* Available tabs items status
|
|
6167
6376
|
*/
|
|
@@ -6177,7 +6386,7 @@ var Status;
|
|
|
6177
6386
|
*/
|
|
6178
6387
|
const sizes = ['regular', 'large'];
|
|
6179
6388
|
|
|
6180
|
-
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:
|
|
6389
|
+
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}";
|
|
6181
6390
|
|
|
6182
6391
|
/**
|
|
6183
6392
|
* type TabItem validation function
|
|
@@ -6193,48 +6402,10 @@ const MgTabs = class {
|
|
|
6193
6402
|
/************
|
|
6194
6403
|
* Internal *
|
|
6195
6404
|
************/
|
|
6405
|
+
// classes
|
|
6196
6406
|
this.tabPanel = 'panel';
|
|
6197
|
-
this.startIndex = 1;
|
|
6198
6407
|
this.buttonTabBaseClass = 'mg-tabs__navigation-button';
|
|
6199
|
-
|
|
6200
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
6201
|
-
* If not set, it will be created.
|
|
6202
|
-
*/
|
|
6203
|
-
this.identifier = createID('mg-tabs');
|
|
6204
|
-
/**
|
|
6205
|
-
* Define tabs size
|
|
6206
|
-
*/
|
|
6207
|
-
this.size = 'regular';
|
|
6208
|
-
/**
|
|
6209
|
-
* Active tab number
|
|
6210
|
-
* default: first is 1
|
|
6211
|
-
*/
|
|
6212
|
-
this.activeTab = 1;
|
|
6213
|
-
/**
|
|
6214
|
-
* Component tabs
|
|
6215
|
-
*/
|
|
6216
|
-
this.tabs = [];
|
|
6217
|
-
/**
|
|
6218
|
-
* Component classes
|
|
6219
|
-
*/
|
|
6220
|
-
this.classList = new ClassList(['mg-tabs']);
|
|
6221
|
-
/**
|
|
6222
|
-
* Method to set active tab
|
|
6223
|
-
*
|
|
6224
|
-
* @param {number} tabKey item tab key to set to ACTIVE status
|
|
6225
|
-
* @returns {void}
|
|
6226
|
-
*/
|
|
6227
|
-
this.setActiveTab = (tabKey) => {
|
|
6228
|
-
// reset active tabs
|
|
6229
|
-
this.tabs.forEach(tab => {
|
|
6230
|
-
if (this.tabHasGivenStatus(tab, Status.ACTIVE))
|
|
6231
|
-
tab.status = Status.VISIBLE;
|
|
6232
|
-
});
|
|
6233
|
-
// set active tab from given tab key
|
|
6234
|
-
this.tabs[tabKey - this.startIndex].status = Status.ACTIVE;
|
|
6235
|
-
// emit change active tab key event
|
|
6236
|
-
this.activeTabChange.emit(tabKey);
|
|
6237
|
-
};
|
|
6408
|
+
this.startIndex = 1;
|
|
6238
6409
|
/**
|
|
6239
6410
|
* Method to know if given tab has the given status
|
|
6240
6411
|
*
|
|
@@ -6242,7 +6413,7 @@ const MgTabs = class {
|
|
|
6242
6413
|
* @param {Status} status status to valide
|
|
6243
6414
|
* @returns {boolean} status comparaison
|
|
6244
6415
|
*/
|
|
6245
|
-
this.
|
|
6416
|
+
this.tabHasStatus = (tab, status) => tab.status === status;
|
|
6246
6417
|
/**
|
|
6247
6418
|
* Method to get element id from index
|
|
6248
6419
|
*
|
|
@@ -6250,14 +6421,20 @@ const MgTabs = class {
|
|
|
6250
6421
|
* @param {number} index to generate id
|
|
6251
6422
|
* @returns {string} generated element id
|
|
6252
6423
|
*/
|
|
6253
|
-
this.getElementId = (element, index) => `${element}-${this.
|
|
6424
|
+
this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
|
|
6254
6425
|
/**
|
|
6255
|
-
* Method to get tab index
|
|
6426
|
+
* Method to get tab item index
|
|
6256
6427
|
*
|
|
6257
6428
|
* @param {number} index to get
|
|
6258
6429
|
* @returns {number} index
|
|
6259
6430
|
*/
|
|
6260
|
-
this.
|
|
6431
|
+
this.getTabItemIndex = (index) => index + this.startIndex;
|
|
6432
|
+
/**
|
|
6433
|
+
* Method to get the active-tab value
|
|
6434
|
+
*
|
|
6435
|
+
* @returns {number} of the active-tab
|
|
6436
|
+
*/
|
|
6437
|
+
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);
|
|
6261
6438
|
/**
|
|
6262
6439
|
* Handle click events on tabs
|
|
6263
6440
|
*
|
|
@@ -6265,16 +6442,22 @@ const MgTabs = class {
|
|
|
6265
6442
|
*/
|
|
6266
6443
|
this.handleClick = (event) => {
|
|
6267
6444
|
const tabId = event.currentTarget.getAttribute('data-index');
|
|
6268
|
-
|
|
6445
|
+
const tab = this.tabs[Number(tabId) - this.startIndex];
|
|
6446
|
+
if (this.tabHasStatus(tab, Status.HIDDEN) || this.tabHasStatus(tab, Status.DISABLED)) {
|
|
6447
|
+
event.preventDefault();
|
|
6448
|
+
}
|
|
6449
|
+
else {
|
|
6450
|
+
this.activeTab = Number(tabId);
|
|
6451
|
+
this.tabFocus = undefined;
|
|
6452
|
+
}
|
|
6269
6453
|
};
|
|
6270
6454
|
/**
|
|
6271
6455
|
* get navigation button class from given status
|
|
6272
6456
|
*
|
|
6273
6457
|
* @param {Status} status button tab status
|
|
6274
|
-
* @param {boolean} isSelector set if we need a CSS selector with the dot '.' at the begin. default value = false.
|
|
6275
6458
|
* @returns {string} button class/selector variant
|
|
6276
6459
|
*/
|
|
6277
|
-
this.getNavigationButtonClass = (status
|
|
6460
|
+
this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
|
|
6278
6461
|
/**
|
|
6279
6462
|
* Handle keyboard event on tabs
|
|
6280
6463
|
*
|
|
@@ -6282,32 +6465,67 @@ const MgTabs = class {
|
|
|
6282
6465
|
* @returns {void}
|
|
6283
6466
|
*/
|
|
6284
6467
|
this.handleKeydown = (event) => {
|
|
6285
|
-
let tabId = Number(event.target.getAttribute('data-index'));
|
|
6286
6468
|
const parent = event.target.parentElement;
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6469
|
+
if (['ArrowRight', 'ArrowLeft'].includes(event.key)) {
|
|
6470
|
+
this.tabFocus = Number(event.target.getAttribute('data-index'));
|
|
6471
|
+
parent.querySelector(`[data-index="${this.tabFocus}"]`).setAttribute('tabindex', '-1');
|
|
6472
|
+
// Move right
|
|
6473
|
+
if (event.key === 'ArrowRight') {
|
|
6474
|
+
this.tabFocus++;
|
|
6475
|
+
// If we're at the end, go to the start
|
|
6476
|
+
if (this.tabFocus > this.tabs.length)
|
|
6477
|
+
this.tabFocus = this.startIndex;
|
|
6478
|
+
// Move left
|
|
6479
|
+
}
|
|
6480
|
+
else if (event.key === 'ArrowLeft') {
|
|
6481
|
+
this.tabFocus--;
|
|
6482
|
+
// If we're at the start, move to the end
|
|
6483
|
+
if (this.tabFocus < this.startIndex)
|
|
6484
|
+
this.tabFocus = this.tabs.length;
|
|
6485
|
+
}
|
|
6486
|
+
// if focus item is ['hidden'] we recursively repeat action
|
|
6487
|
+
if (this.tabHasStatus(this.tabs[this.tabFocus - 1], Status.HIDDEN)) {
|
|
6488
|
+
parent.querySelector(`[data-index="${this.tabFocus}"]`).dispatchEvent(new KeyboardEvent('keydown', { key: event.key, bubbles: true }));
|
|
6489
|
+
// else run focus methods on tabFocus element
|
|
6490
|
+
}
|
|
6491
|
+
else {
|
|
6492
|
+
parent.querySelector(`[data-index="${this.tabFocus}"]`).setAttribute('tabindex', '0');
|
|
6493
|
+
parent.querySelector(`[data-index="${this.tabFocus}"]`).focus();
|
|
6494
|
+
}
|
|
6293
6495
|
}
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
// apply selected tab if exist
|
|
6297
|
-
if (selectedTab !== null) {
|
|
6298
|
-
selectedTab.focus();
|
|
6299
|
-
this.activeTab = tabId;
|
|
6496
|
+
else if (event.key === 'Tab') {
|
|
6497
|
+
this.resetFocus();
|
|
6300
6498
|
}
|
|
6301
6499
|
};
|
|
6500
|
+
/**
|
|
6501
|
+
* Method to reset focus behavior
|
|
6502
|
+
*
|
|
6503
|
+
* @returns {void}
|
|
6504
|
+
*/
|
|
6505
|
+
this.resetFocus = () => {
|
|
6506
|
+
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
6507
|
+
setTimeout(() => {
|
|
6508
|
+
this.tabFocus = undefined;
|
|
6509
|
+
Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {
|
|
6510
|
+
tab.setAttribute('tabindex', this.getActiveTab() - this.startIndex !== index ? '-1' : '0');
|
|
6511
|
+
});
|
|
6512
|
+
}, 0);
|
|
6513
|
+
};
|
|
6302
6514
|
/**
|
|
6303
6515
|
* Validate slots setting
|
|
6304
6516
|
*/
|
|
6305
6517
|
this.validateSlots = () => {
|
|
6306
6518
|
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-'); });
|
|
6307
|
-
if (slots.length !== this.tabs.length)
|
|
6519
|
+
if (slots.length !== this.tabs.length)
|
|
6308
6520
|
throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
|
|
6309
|
-
}
|
|
6310
6521
|
};
|
|
6522
|
+
this.identifier = createID('mg-tabs');
|
|
6523
|
+
this.label = undefined;
|
|
6524
|
+
this.size = 'regular';
|
|
6525
|
+
this.items = undefined;
|
|
6526
|
+
this.activeTab = undefined;
|
|
6527
|
+
this.tabs = [];
|
|
6528
|
+
this.classList = new ClassList(['mg-tabs']);
|
|
6311
6529
|
}
|
|
6312
6530
|
validateLabel(newValue) {
|
|
6313
6531
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -6323,22 +6541,37 @@ const MgTabs = class {
|
|
|
6323
6541
|
validateItems(newValue) {
|
|
6324
6542
|
// String array
|
|
6325
6543
|
if (allItemsAreString(newValue)) {
|
|
6326
|
-
this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
|
|
6544
|
+
this.tabs = newValue.map((item, index) => ({ label: item, status: index === 0 ? Status.ACTIVE : Status.VISIBLE }));
|
|
6327
6545
|
}
|
|
6328
6546
|
// Object array
|
|
6329
|
-
else if (newValue && newValue.every(item => isTabItem(item))) {
|
|
6547
|
+
else if (newValue && newValue.length > 0 && newValue.every(item => isTabItem(item))) {
|
|
6330
6548
|
this.tabs = newValue;
|
|
6549
|
+
// init active tabs if not set. Default: index 0.
|
|
6550
|
+
if (this.tabs.find(tab => this.tabHasStatus(tab, Status.ACTIVE)) === undefined)
|
|
6551
|
+
this.tabs[0].status = Status.ACTIVE;
|
|
6331
6552
|
}
|
|
6332
6553
|
else {
|
|
6333
6554
|
throw new Error('<mg-tabs> prop "items" is required and all items must be the same type: TabItem.');
|
|
6334
6555
|
}
|
|
6335
6556
|
}
|
|
6336
6557
|
validateActiveTab(newValue) {
|
|
6337
|
-
if (newValue
|
|
6338
|
-
|
|
6558
|
+
if (typeof newValue === 'number' && newValue >= 1 && newValue <= this.tabs.length) {
|
|
6559
|
+
this.tabs.forEach((tab, index) => {
|
|
6560
|
+
const isNewActiveTab = index === newValue - this.startIndex;
|
|
6561
|
+
// reset active tabs
|
|
6562
|
+
if (this.tabHasStatus(tab, Status.ACTIVE) && !isNewActiveTab)
|
|
6563
|
+
tab.status = Status.VISIBLE;
|
|
6564
|
+
// set active tab from given tab key
|
|
6565
|
+
else if ((tab.status === undefined || this.tabHasStatus(tab, Status.VISIBLE)) && isNewActiveTab)
|
|
6566
|
+
tab.status = Status.ACTIVE;
|
|
6567
|
+
});
|
|
6568
|
+
// emit change active tab key event
|
|
6569
|
+
if (this.tabs.find(tab => this.tabHasStatus(tab, Status.ACTIVE)) !== undefined) {
|
|
6570
|
+
this.activeTabChange.emit(newValue);
|
|
6571
|
+
}
|
|
6339
6572
|
}
|
|
6340
|
-
else {
|
|
6341
|
-
|
|
6573
|
+
else if (newValue !== undefined) {
|
|
6574
|
+
throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
|
|
6342
6575
|
}
|
|
6343
6576
|
}
|
|
6344
6577
|
/*************
|
|
@@ -6357,6 +6590,17 @@ const MgTabs = class {
|
|
|
6357
6590
|
this.validateSize(this.size);
|
|
6358
6591
|
this.validateSlots();
|
|
6359
6592
|
}
|
|
6593
|
+
/**
|
|
6594
|
+
* add listners
|
|
6595
|
+
*
|
|
6596
|
+
* @returns {void}
|
|
6597
|
+
*/
|
|
6598
|
+
componentDidLoad() {
|
|
6599
|
+
document.addEventListener('click', (event) => {
|
|
6600
|
+
if (event.target.closest('mg-tabs') !== this.element)
|
|
6601
|
+
this.resetFocus();
|
|
6602
|
+
}, false);
|
|
6603
|
+
}
|
|
6360
6604
|
/**
|
|
6361
6605
|
* Render
|
|
6362
6606
|
*
|
|
@@ -6366,10 +6610,10 @@ const MgTabs = class {
|
|
|
6366
6610
|
return (h("div", { class: this.classList.join() }, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { role: "tab", id: this.getElementId(this.identifier, index), class: {
|
|
6367
6611
|
[`${this.buttonTabBaseClass}`]: true,
|
|
6368
6612
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
6369
|
-
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.
|
|
6370
|
-
[`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.
|
|
6371
|
-
[`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.
|
|
6372
|
-
}, tabindex: this.
|
|
6613
|
+
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
6614
|
+
[`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasStatus(tab, Status.DISABLED),
|
|
6615
|
+
[`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasStatus(tab, Status.HIDDEN),
|
|
6616
|
+
}, tabindex: this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1, "aria-selected": this.tabHasStatus(tab, Status.ACTIVE).toString(), "aria-controls": this.getElementId(this.tabPanel, index), "aria-disabled": this.tabHasStatus(tab, Status.DISABLED), onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": this.getTabItemIndex(index) }, tab.icon !== undefined && h("mg-icon", { icon: tab.icon }), tab.label, tab.badge !== undefined && h("mg-badge", { variant: "text-color", value: tab.badge.value, label: tab.badge.label, outline: tab.badge.role === 'information' }))))), this.tabs.map((tab, index) => (h("article", { role: "tabpanel", id: this.getElementId(this.tabPanel, index), hidden: !this.tabHasStatus(tab, Status.ACTIVE), "aria-labelledby": this.getElementId(this.identifier, index), tabindex: this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1, class: "mg-tabs__content-container" }, h("slot", { name: this.getElementId('tab_content', index) }))))));
|
|
6373
6617
|
}
|
|
6374
6618
|
get element() { return getElement(this); }
|
|
6375
6619
|
static get watchers() { return {
|
|
@@ -6386,7 +6630,7 @@ MgTabs.style = mgTabsCss;
|
|
|
6386
6630
|
*/
|
|
6387
6631
|
const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
|
|
6388
6632
|
|
|
6389
|
-
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}";
|
|
6633
|
+
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}";
|
|
6390
6634
|
|
|
6391
6635
|
const MgTag = class {
|
|
6392
6636
|
constructor(hostRef) {
|
|
@@ -6395,17 +6639,11 @@ const MgTag = class {
|
|
|
6395
6639
|
* Internal *
|
|
6396
6640
|
************/
|
|
6397
6641
|
// Classes
|
|
6398
|
-
this.classOutline =
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
* Define button variant
|
|
6404
|
-
*/
|
|
6405
|
-
this.variant = variants[0]; // primary
|
|
6406
|
-
/**
|
|
6407
|
-
* Component classes
|
|
6408
|
-
*/
|
|
6642
|
+
this.classOutline = 'mg-tag--outline';
|
|
6643
|
+
this.classSoft = 'mg-tag--soft';
|
|
6644
|
+
this.variant = variants[0];
|
|
6645
|
+
this.outline = undefined;
|
|
6646
|
+
this.soft = undefined;
|
|
6409
6647
|
this.classList = new ClassList(['mg-tag']);
|
|
6410
6648
|
}
|
|
6411
6649
|
validateVariant(newValue, oldValue) {
|
|
@@ -6425,6 +6663,29 @@ const MgTag = class {
|
|
|
6425
6663
|
else
|
|
6426
6664
|
this.classList.delete(this.classOutline);
|
|
6427
6665
|
}
|
|
6666
|
+
validateSoft(newValue) {
|
|
6667
|
+
// usage validation
|
|
6668
|
+
if (newValue && this.outline)
|
|
6669
|
+
throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
|
|
6670
|
+
// apply class
|
|
6671
|
+
if (newValue)
|
|
6672
|
+
this.classList.add(this.classSoft);
|
|
6673
|
+
else
|
|
6674
|
+
this.classList.delete(this.classSoft);
|
|
6675
|
+
}
|
|
6676
|
+
/*************
|
|
6677
|
+
* Methods *
|
|
6678
|
+
*************/
|
|
6679
|
+
/**
|
|
6680
|
+
* Validate the given textContent
|
|
6681
|
+
*
|
|
6682
|
+
* @param {string} textContent html element textContent property
|
|
6683
|
+
* @returns {void}
|
|
6684
|
+
*/
|
|
6685
|
+
validateTextContent(textContent) {
|
|
6686
|
+
if (typeof textContent !== 'string' || textContent.trim() === '')
|
|
6687
|
+
throw new Error('<mg-tag> slot must contain a text content.');
|
|
6688
|
+
}
|
|
6428
6689
|
/*************
|
|
6429
6690
|
* Lifecycle *
|
|
6430
6691
|
*************/
|
|
@@ -6436,6 +6697,8 @@ const MgTag = class {
|
|
|
6436
6697
|
componentWillLoad() {
|
|
6437
6698
|
this.validateVariant(this.variant);
|
|
6438
6699
|
this.validateOutline(this.outline);
|
|
6700
|
+
this.validateSoft(this.soft);
|
|
6701
|
+
this.validateTextContent(this.element.textContent);
|
|
6439
6702
|
}
|
|
6440
6703
|
/**
|
|
6441
6704
|
* Render
|
|
@@ -6445,9 +6708,11 @@ const MgTag = class {
|
|
|
6445
6708
|
render() {
|
|
6446
6709
|
return (h("span", { class: this.classList.join() }, h("slot", null)));
|
|
6447
6710
|
}
|
|
6711
|
+
get element() { return getElement(this); }
|
|
6448
6712
|
static get watchers() { return {
|
|
6449
6713
|
"variant": ["validateVariant"],
|
|
6450
|
-
"outline": ["validateOutline"]
|
|
6714
|
+
"outline": ["validateOutline"],
|
|
6715
|
+
"soft": ["validateSoft"]
|
|
6451
6716
|
}; }
|
|
6452
6717
|
};
|
|
6453
6718
|
MgTag.style = mgTagCss;
|
|
@@ -6459,28 +6724,11 @@ var Guard;
|
|
|
6459
6724
|
Guard["HOVER_TOOLTIPED_ELEMENT"] = "hoverTooltipedGuard";
|
|
6460
6725
|
})(Guard || (Guard = {}));
|
|
6461
6726
|
|
|
6462
|
-
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}";
|
|
6727
|
+
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}";
|
|
6463
6728
|
|
|
6464
6729
|
const MgTooltip = class {
|
|
6465
6730
|
constructor(hostRef) {
|
|
6466
6731
|
registerInstance(this, hostRef);
|
|
6467
|
-
/**
|
|
6468
|
-
* Sets an `id` attribute.
|
|
6469
|
-
* Needed by the input for accessibility `aria-decribedby`.
|
|
6470
|
-
*/
|
|
6471
|
-
this.identifier = createID('mg-tooltip');
|
|
6472
|
-
/**
|
|
6473
|
-
* Tooltip placement
|
|
6474
|
-
*/
|
|
6475
|
-
this.placement = 'bottom';
|
|
6476
|
-
/**
|
|
6477
|
-
* Display tooltip
|
|
6478
|
-
*/
|
|
6479
|
-
this.display = false;
|
|
6480
|
-
/**
|
|
6481
|
-
* Disable tooltip
|
|
6482
|
-
*/
|
|
6483
|
-
this.disabled = false;
|
|
6484
6732
|
/**
|
|
6485
6733
|
* Show tooltip
|
|
6486
6734
|
*
|
|
@@ -6534,7 +6782,7 @@ const MgTooltip = class {
|
|
|
6534
6782
|
this.resetGuard();
|
|
6535
6783
|
}, 100);
|
|
6536
6784
|
}
|
|
6537
|
-
else if (
|
|
6785
|
+
else if (this.guard === Guard.HOVER_TOOLTIPED_ELEMENT) {
|
|
6538
6786
|
this.setDisplay(isMouseenter);
|
|
6539
6787
|
}
|
|
6540
6788
|
}
|
|
@@ -6604,7 +6852,7 @@ const MgTooltip = class {
|
|
|
6604
6852
|
this.setDisplay(true);
|
|
6605
6853
|
});
|
|
6606
6854
|
['blur', 'keydown'].forEach(event => {
|
|
6607
|
-
|
|
6855
|
+
document.addEventListener(event, (e) => {
|
|
6608
6856
|
// we continue to process ONLY for KeyboardEvents 'Escape'
|
|
6609
6857
|
if (e.type === 'keydown' && e.code !== 'Escape') {
|
|
6610
6858
|
return;
|
|
@@ -6626,6 +6874,11 @@ const MgTooltip = class {
|
|
|
6626
6874
|
});
|
|
6627
6875
|
});
|
|
6628
6876
|
};
|
|
6877
|
+
this.identifier = createID('mg-tooltip');
|
|
6878
|
+
this.message = undefined;
|
|
6879
|
+
this.placement = 'bottom';
|
|
6880
|
+
this.display = false;
|
|
6881
|
+
this.disabled = false;
|
|
6629
6882
|
}
|
|
6630
6883
|
validateMessage(newValue) {
|
|
6631
6884
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -6658,8 +6911,7 @@ const MgTooltip = class {
|
|
|
6658
6911
|
const slotElement = this.element.firstElementChild;
|
|
6659
6912
|
// Get interactive element
|
|
6660
6913
|
const interactiveElements = ['a', 'button', 'input', 'textarea', 'select']; //! Might needs updates
|
|
6661
|
-
const interactiveElement = this.element.shadowRoot.querySelector(interactiveElements.join(',')) ||
|
|
6662
|
-
((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
|
|
6914
|
+
const interactiveElement = this.element.shadowRoot.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
|
|
6663
6915
|
// define selected element to become tooltip selector
|
|
6664
6916
|
this.tooltipedElement = interactiveElement || slotElement;
|
|
6665
6917
|
// Check if slotted element is a disabled mg-button
|
|
@@ -6684,7 +6936,7 @@ const MgTooltip = class {
|
|
|
6684
6936
|
* @returns {HTMLElement} HTML Element
|
|
6685
6937
|
*/
|
|
6686
6938
|
render() {
|
|
6687
|
-
return (h(Host, null, h("slot", null), h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip", innerHTML: this.message }, h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|
|
6939
|
+
return (h(Host, null, h("slot", null), h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip" }, h("span", { innerHTML: this.message }), h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|
|
6688
6940
|
}
|
|
6689
6941
|
get element() { return getElement(this); }
|
|
6690
6942
|
static get watchers() { return {
|
|
@@ -6694,4 +6946,4 @@ const MgTooltip = class {
|
|
|
6694
6946
|
};
|
|
6695
6947
|
MgTooltip.style = mgTooltipCss;
|
|
6696
6948
|
|
|
6697
|
-
export { MgBadge as mg_badge, MgButton as mg_button, MgCard as mg_card, MgCharacterLeft as mg_character_left, MgDetails as mg_details, MgDivider as mg_divider, MgForm as mg_form, MgIcon as mg_icon, MgIllustratedMessage as mg_illustrated_message, MgInputCheckbox as mg_input_checkbox, MgInputDate as mg_input_date, MgInputNumeric as mg_input_numeric, MgInputPassword as mg_input_password, MgInputRadio as mg_input_radio, MgInputSelect as mg_input_select, MgInputText as mg_input_text, MgInputTextarea as mg_input_textarea, MgInputTitle as mg_input_title, MgInputToggle as mg_input_toggle, MgMenu as mg_menu, MgMenuItem as mg_menu_item, MgMessage as mg_message, MgModal as mg_modal, MgPagination as mg_pagination, MgPanel as mg_panel, MgPopover as mg_popover, MgTabs as mg_tabs, MgTag as mg_tag, MgTooltip as mg_tooltip };
|
|
6949
|
+
export { MgBadge as mg_badge, MgButton as mg_button, MgCard as mg_card, MgCharacterLeft as mg_character_left, MgDetails as mg_details, MgDivider as mg_divider, MgForm as mg_form, MgIcon as mg_icon, MgIllustratedMessage as mg_illustrated_message, MgInputCheckbox as mg_input_checkbox, MgInputDate as mg_input_date, MgInputNumeric as mg_input_numeric, MgInputPassword as mg_input_password, MgInputRadio as mg_input_radio, MgInputSelect as mg_input_select, MgInputText as mg_input_text, MgInputTextarea as mg_input_textarea, MgInputTitle as mg_input_title, MgInputToggle as mg_input_toggle, MgMenu as mg_menu, MgMenuItem as mg_menu_item, MgMessage as mg_message, MgModal as mg_modal, MgPagination as mg_pagination, MgPanel as mg_panel, MgPopover as mg_popover, MgSkipLinks as mg_skip_links, MgTabs as mg_tabs, MgTag as mg_tag, MgTooltip as mg_tooltip };
|