@mgdis/mg-components 5.0.0 → 5.1.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/loader.cjs.js +1 -1
- package/dist/cjs/{mg-badge_24.cjs.entry.js → mg-badge_27.cjs.entry.js} +543 -64
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +8 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +39 -1
- package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +18 -0
- package/dist/collection/components/atoms/mg-card/mg-card.css +7 -0
- package/dist/collection/components/atoms/mg-card/mg-card.js +26 -0
- package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +18 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.css +9 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +57 -0
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -5
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +0 -20
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +2 -1
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +1 -0
- package/dist/collection/components/molecules/mg-details/mg-details.css +29 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +26 -4
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +2 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +52 -4
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +5 -14
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -5
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +3 -2
- package/dist/collection/utils/components.utils.js +10 -6
- package/dist/collection/variables.css +17 -2
- package/dist/components/components.utils.js +11 -7
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/mg-button2.js +21 -2
- package/dist/components/mg-card.d.ts +11 -0
- package/dist/components/mg-card.js +42 -0
- package/dist/components/mg-details.js +8 -3
- package/dist/components/mg-divider.d.ts +11 -0
- package/dist/components/mg-divider.js +51 -0
- package/dist/components/mg-modal.js +53 -5
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover.js +3 -2
- package/dist/components/mg-tooltip2.js +2 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mg-badge_24.entry.js → mg-badge_27.entry.js} +490 -14
- package/dist/esm/mg-components.js +1 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-e131701a.entry.js +1 -0
- package/dist/mg-components/variables.css +17 -2
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +6 -0
- package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -0
- package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +15 -0
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +0 -8
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +1 -1
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +8 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +1 -1
- package/dist/types/components.d.ts +55 -6
- package/dist/types/utils/components.utils.d.ts +7 -3
- package/package.json +4 -3
- package/dist/cjs/index-179621c8.js +0 -244
- package/dist/cjs/mg-modal.cjs.entry.js +0 -128
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -20
- package/dist/esm/index-7efedd97.js +0 -238
- package/dist/esm/mg-modal.entry.js +0 -124
- package/dist/mg-components/p-5f89600c.js +0 -1
- package/dist/mg-components/p-b60a4c53.entry.js +0 -1
- package/dist/mg-components/p-df947fa5.entry.js +0 -1
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -8
|
@@ -1,11 +1,99 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-aad0184c.js';
|
|
2
|
-
import { C as ClassList, i as initLocales, c as createID, a as isTagName, b as allItemsAreString } from './index-7efedd97.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* List of all possibles variants
|
|
6
5
|
*/
|
|
7
6
|
const variants$4 = ['info', 'primary', 'secondary', 'success', 'warning', 'danger'];
|
|
8
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Create random ID
|
|
10
|
+
*
|
|
11
|
+
* @param {string} prefix add prefix to created ID
|
|
12
|
+
* @param {number} length ID length
|
|
13
|
+
* @returns {string} ID
|
|
14
|
+
*/
|
|
15
|
+
const createID = (prefix = '', length = 10) => {
|
|
16
|
+
let ID = '';
|
|
17
|
+
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
18
|
+
const charsLength = chars.length;
|
|
19
|
+
for (let i = 0; i < length; i++) {
|
|
20
|
+
ID += chars.charAt(Math.floor(Math.random() * charsLength));
|
|
21
|
+
}
|
|
22
|
+
return (prefix !== '' ? `${prefix}-` : '') + ID;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Class to manage component classlist
|
|
26
|
+
* Set() are not working when imported in project
|
|
27
|
+
*/
|
|
28
|
+
class ClassList {
|
|
29
|
+
constructor(classlist = []) {
|
|
30
|
+
/**
|
|
31
|
+
* Add class
|
|
32
|
+
*
|
|
33
|
+
* @param {string} className class name to add
|
|
34
|
+
* @returns {void}
|
|
35
|
+
*/
|
|
36
|
+
this.add = (className) => {
|
|
37
|
+
if (!this.has(className)) {
|
|
38
|
+
this.classes.push(className);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Delete class
|
|
43
|
+
*
|
|
44
|
+
* @param {string} className class name to delete
|
|
45
|
+
* @returns {void}
|
|
46
|
+
*/
|
|
47
|
+
this.delete = (className) => {
|
|
48
|
+
const index = this.classes.indexOf(className);
|
|
49
|
+
if (index > -1) {
|
|
50
|
+
this.classes.splice(index, 1);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Check if class exist in list
|
|
55
|
+
*
|
|
56
|
+
* @param {string} className class name to check
|
|
57
|
+
* @returns {boolean} class name is in the list
|
|
58
|
+
*/
|
|
59
|
+
this.has = (className) => {
|
|
60
|
+
return this.classes.includes(className);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Join classes seperated by spaces
|
|
64
|
+
*
|
|
65
|
+
* @returns {string} joined values
|
|
66
|
+
*/
|
|
67
|
+
this.join = () => {
|
|
68
|
+
return this.classes.join(' ');
|
|
69
|
+
};
|
|
70
|
+
this.classes = classlist;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if all items are string
|
|
75
|
+
*
|
|
76
|
+
* @param {string[]} items items to check
|
|
77
|
+
* @returns {boolean} all items are string
|
|
78
|
+
*/
|
|
79
|
+
const allItemsAreString = (items) => {
|
|
80
|
+
return items && items.every(item => typeof item === 'string');
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Check if element is a heading
|
|
84
|
+
*
|
|
85
|
+
* @param {Element} element slotted element
|
|
86
|
+
* @param {string[]} tagNames allowed tag names list
|
|
87
|
+
* @returns {boolean} element is a heading
|
|
88
|
+
*/
|
|
89
|
+
const isTagName = (element, tagNames) => {
|
|
90
|
+
return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Focusable elements query selector
|
|
94
|
+
*/
|
|
95
|
+
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
96
|
+
|
|
9
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}.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}";
|
|
10
98
|
|
|
11
99
|
const MgBadge = class {
|
|
@@ -85,7 +173,7 @@ MgBadge.style = mgBadgeCss;
|
|
|
85
173
|
*/
|
|
86
174
|
const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success'];
|
|
87
175
|
|
|
88
|
-
const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button:not(.mg-button--disabled){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:hsla(var(--color-dark), 0.1)}.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--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}";
|
|
176
|
+
const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button:not(.mg-button--disabled){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:hsla(var(--color-dark), 0.1)}:host([full-width]){display:block}.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--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}";
|
|
89
177
|
|
|
90
178
|
const MgButton = class {
|
|
91
179
|
constructor(hostRef) {
|
|
@@ -96,10 +184,15 @@ const MgButton = class {
|
|
|
96
184
|
this.onClickElementFn = null;
|
|
97
185
|
this.classDisabled = 'mg-button--disabled';
|
|
98
186
|
this.classLoading = 'mg-button--loading';
|
|
187
|
+
this.classFullWidth = 'mg-button--full-width';
|
|
99
188
|
/**
|
|
100
189
|
* Define button variant
|
|
101
190
|
*/
|
|
102
191
|
this.variant = variants$3[0]; // Primary
|
|
192
|
+
/**
|
|
193
|
+
* Set button to full-width
|
|
194
|
+
*/
|
|
195
|
+
this.fullWidth = false;
|
|
103
196
|
/**
|
|
104
197
|
* Define if button is round.
|
|
105
198
|
* Used for icon button.
|
|
@@ -174,6 +267,17 @@ const MgButton = class {
|
|
|
174
267
|
this.classList.add(`mg-button--${newValue}`);
|
|
175
268
|
}
|
|
176
269
|
}
|
|
270
|
+
validateFullWidth(newValue) {
|
|
271
|
+
if (newValue && this.isIcon) {
|
|
272
|
+
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
273
|
+
}
|
|
274
|
+
else if (newValue) {
|
|
275
|
+
this.classList.add(this.classFullWidth);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
this.classList.delete(this.classFullWidth);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
177
281
|
disabledHandler(isDisabled) {
|
|
178
282
|
// Remove loading when enable
|
|
179
283
|
// Will be set back onclick
|
|
@@ -206,6 +310,7 @@ const MgButton = class {
|
|
|
206
310
|
*/
|
|
207
311
|
componentWillLoad() {
|
|
208
312
|
this.validateVariant(this.variant);
|
|
313
|
+
this.validateFullWidth(this.fullWidth);
|
|
209
314
|
if (this.isIcon) {
|
|
210
315
|
this.classList.add(`mg-button--icon`);
|
|
211
316
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
@@ -222,17 +327,190 @@ const MgButton = class {
|
|
|
222
327
|
* @returns {HTMLElement} html element
|
|
223
328
|
*/
|
|
224
329
|
render() {
|
|
225
|
-
return (h(Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyUp: this.handleKeyup, onKeyDown: this.handleKeydown }, h("div", { class: this.classList.join(), id: this.identifier }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-button__content" }, h("slot", null)))));
|
|
330
|
+
return (h(Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyUp: this.handleKeyup, onKeyDown: this.handleKeydown }, h("div", { class: this.classList.join(), id: this.identifier }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-button__content" }, h("slot", null)))));
|
|
226
331
|
}
|
|
227
332
|
get element() { return getElement(this); }
|
|
228
333
|
static get watchers() { return {
|
|
229
334
|
"variant": ["validateVariant"],
|
|
335
|
+
"fullWidth": ["validateFullWidth"],
|
|
230
336
|
"disabled": ["disabledHandler"],
|
|
231
337
|
"loading": ["loadingHandler"]
|
|
232
338
|
}; }
|
|
233
339
|
};
|
|
234
340
|
MgButton.style = mgButtonCss;
|
|
235
341
|
|
|
342
|
+
const mgCardCss = ".mg-card{padding:var(--mg-card-padding);border-radius:var(--mg-card-border-radius);background:var(--mg-card-background);border:var(--mg-card-border);box-shadow:var(--mg-card-box-shadow)}";
|
|
343
|
+
|
|
344
|
+
const MgCard = class {
|
|
345
|
+
constructor(hostRef) {
|
|
346
|
+
registerInstance(this, hostRef);
|
|
347
|
+
}
|
|
348
|
+
/*************
|
|
349
|
+
* Lifecycle *
|
|
350
|
+
*************/
|
|
351
|
+
/**
|
|
352
|
+
* Render
|
|
353
|
+
*
|
|
354
|
+
* @returns {HTMLElement} HTML Element
|
|
355
|
+
*/
|
|
356
|
+
render() {
|
|
357
|
+
return (h("div", { class: "mg-card" }, h("slot", null)));
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
MgCard.style = mgCardCss;
|
|
361
|
+
|
|
362
|
+
const errors$1 = {
|
|
363
|
+
required: "This field is required.",
|
|
364
|
+
date: {
|
|
365
|
+
badInput: "The date format must be <span aria-hidden=\"true\">mm/dd/yyyy</span><span class=\"sr-only\">m m / d d / y y y y</span> and the date must be greater than {min}",
|
|
366
|
+
min: "The date cannot be earlier than {min}",
|
|
367
|
+
max: "The date cannot be later than {max}",
|
|
368
|
+
minMax: "The date must be between {min} and {max}"
|
|
369
|
+
},
|
|
370
|
+
numeric: {
|
|
371
|
+
min: "The value cannot be less than {min}",
|
|
372
|
+
max: "The value cannot be greater than {max}",
|
|
373
|
+
minMax: "The value must be between {min} et {max}"
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
const nbCharLeft$1 = "{counter} characters left.";
|
|
377
|
+
const input$1 = {
|
|
378
|
+
select: {
|
|
379
|
+
placeholder: "Select a value"
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
const form$1 = {
|
|
383
|
+
required: "Fields with a <strong class=\"is-asterisk\">*</strong> are required",
|
|
384
|
+
allRequired: "All fields are required"
|
|
385
|
+
};
|
|
386
|
+
const message$1 = {
|
|
387
|
+
closeButton: "Close message"
|
|
388
|
+
};
|
|
389
|
+
const modal$1 = {
|
|
390
|
+
closeButton: "Close modal"
|
|
391
|
+
};
|
|
392
|
+
const pagination$1 = {
|
|
393
|
+
label: "Pagination",
|
|
394
|
+
page: "page",
|
|
395
|
+
pages: "pages",
|
|
396
|
+
nextPage: "Next page",
|
|
397
|
+
previousPage: "Previous page",
|
|
398
|
+
selectPage: "Select the page to display."
|
|
399
|
+
};
|
|
400
|
+
const panel$1 = {
|
|
401
|
+
editLabel: "Edit section title."
|
|
402
|
+
};
|
|
403
|
+
const general$1 = {
|
|
404
|
+
confirm: "Confirm",
|
|
405
|
+
cancel: "Cancel",
|
|
406
|
+
close: "Close",
|
|
407
|
+
next: "next",
|
|
408
|
+
previous: "previous"
|
|
409
|
+
};
|
|
410
|
+
const en = {
|
|
411
|
+
errors: errors$1,
|
|
412
|
+
nbCharLeft: nbCharLeft$1,
|
|
413
|
+
input: input$1,
|
|
414
|
+
form: form$1,
|
|
415
|
+
message: message$1,
|
|
416
|
+
modal: modal$1,
|
|
417
|
+
pagination: pagination$1,
|
|
418
|
+
panel: panel$1,
|
|
419
|
+
general: general$1
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const errors = {
|
|
423
|
+
required: "Ce champ est obligatoire.",
|
|
424
|
+
date: {
|
|
425
|
+
badInput: "Le format de la date doit être du type <span aria-hidden=\"true\">jj/mm/aaaa</span><span class=\"sr-only\">j j / m m / a a a a</span> et la date supérieure au {min}",
|
|
426
|
+
min: "La date ne peut pas être antérieure au {min}",
|
|
427
|
+
max: "La date ne peut pas être postérieure au {max}",
|
|
428
|
+
minMax: "La date doit être comprise entre le {min} et le {max}"
|
|
429
|
+
},
|
|
430
|
+
numeric: {
|
|
431
|
+
min: "La valeur ne peut pas être inférieure à {min}",
|
|
432
|
+
max: "La valeur ne peut pas être supérieure à {max}",
|
|
433
|
+
minMax: "La valeur doit être comprise entre {min} et {max}"
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
const nbCharLeft = "{counter} caractères disponibles.";
|
|
437
|
+
const input = {
|
|
438
|
+
select: {
|
|
439
|
+
placeholder: "Sélectionnez une valeur"
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
const form = {
|
|
443
|
+
required: "Les champs marqués d'un <strong class=\"is-asterisk\">*</strong> sont obligatoires",
|
|
444
|
+
allRequired: "Tous les champs sont obligatoires"
|
|
445
|
+
};
|
|
446
|
+
const message = {
|
|
447
|
+
closeButton: "Fermer le message"
|
|
448
|
+
};
|
|
449
|
+
const modal = {
|
|
450
|
+
closeButton: "Fermer la modale"
|
|
451
|
+
};
|
|
452
|
+
const pagination = {
|
|
453
|
+
label: "Pagination",
|
|
454
|
+
page: "page",
|
|
455
|
+
pages: "pages",
|
|
456
|
+
nextPage: "Page suivante",
|
|
457
|
+
previousPage: "Page précédente",
|
|
458
|
+
selectPage: "Sélectionner la page à afficher."
|
|
459
|
+
};
|
|
460
|
+
const panel = {
|
|
461
|
+
editLabel: "Modifier le titre de la section."
|
|
462
|
+
};
|
|
463
|
+
const general = {
|
|
464
|
+
confirm: "Valider",
|
|
465
|
+
cancel: "Annuler",
|
|
466
|
+
close: "Fermer",
|
|
467
|
+
next: "suivant",
|
|
468
|
+
previous: "précédent"
|
|
469
|
+
};
|
|
470
|
+
const fr = {
|
|
471
|
+
errors: errors,
|
|
472
|
+
nbCharLeft: nbCharLeft,
|
|
473
|
+
input: input,
|
|
474
|
+
form: form,
|
|
475
|
+
message: message,
|
|
476
|
+
modal: modal,
|
|
477
|
+
pagination: pagination,
|
|
478
|
+
panel: panel,
|
|
479
|
+
general: general
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
const defaultLocale = 'en';
|
|
483
|
+
const messages = { en, fr };
|
|
484
|
+
/**
|
|
485
|
+
* Get locale
|
|
486
|
+
*
|
|
487
|
+
* @param {HTMLElement} element element that needs to know the locale to use
|
|
488
|
+
* @returns {string} locale
|
|
489
|
+
*/
|
|
490
|
+
const getLocale = (element) => {
|
|
491
|
+
var _a;
|
|
492
|
+
return ((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang) || navigator.language || defaultLocale;
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Get Intl object
|
|
496
|
+
* We load the defined locale but for now we only support the first subtag for messages
|
|
497
|
+
*
|
|
498
|
+
* @param {HTMLElement} element element we need to get the language
|
|
499
|
+
* @returns {{ locale: string; messages: unknown }} messages object
|
|
500
|
+
*/
|
|
501
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
502
|
+
const initLocales = (element) => {
|
|
503
|
+
// Get local
|
|
504
|
+
const locale = getLocale(element);
|
|
505
|
+
// Only keep first subtag
|
|
506
|
+
const localeSubtag = locale.split('-').shift();
|
|
507
|
+
// Return
|
|
508
|
+
return {
|
|
509
|
+
locale,
|
|
510
|
+
messages: messages[localeSubtag] || messages[defaultLocale],
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
|
|
236
514
|
const mgCharacterLeftCss = "mg-character-left.sc-mg-character-left{display:block}";
|
|
237
515
|
|
|
238
516
|
const MgCharacterLeft = class {
|
|
@@ -275,12 +553,16 @@ const MgCharacterLeft = class {
|
|
|
275
553
|
};
|
|
276
554
|
MgCharacterLeft.style = mgCharacterLeftCss;
|
|
277
555
|
|
|
278
|
-
const mgDetailsCss = ".mg-details summary{display:flex;align-items:baseline;cursor:pointer}.mg-details__toggle{margin-left:1.5rem;flex-shrink:0}.mg-details__details{margin-top:1.5rem}";
|
|
556
|
+
const mgDetailsCss = ".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}.mg-details summary{display:flex;align-items:baseline;cursor:pointer}.mg-details__toggle{margin-left:1.5rem;flex-shrink:0;display:flex;align-items:center;align-self:flex-start;gap:0.6rem;min-height:calc(var(--font-size) * var(--line-height))}.mg-details__toggle mg-icon{align-self:self-end}.mg-details__details{margin-top:1.5rem}";
|
|
279
557
|
|
|
280
558
|
const MgDetails = class {
|
|
281
559
|
constructor(hostRef) {
|
|
282
560
|
registerInstance(this, hostRef);
|
|
283
561
|
this.expandedChange = createEvent(this, "expanded-change", 7);
|
|
562
|
+
/**
|
|
563
|
+
* Hide summary element
|
|
564
|
+
*/
|
|
565
|
+
this.hideSummary = false;
|
|
284
566
|
/**
|
|
285
567
|
* Define if details are diplayed
|
|
286
568
|
*/
|
|
@@ -295,7 +577,7 @@ const MgDetails = class {
|
|
|
295
577
|
};
|
|
296
578
|
}
|
|
297
579
|
validateTitles(newValue) {
|
|
298
|
-
if (newValue === undefined || newValue === '') {
|
|
580
|
+
if (newValue === undefined || newValue.trim() === '') {
|
|
299
581
|
throw new Error('<mg-details> prop "toggleClosed" and "toggleOpened" must be defined.');
|
|
300
582
|
}
|
|
301
583
|
}
|
|
@@ -320,7 +602,7 @@ const MgDetails = class {
|
|
|
320
602
|
* @returns {HTMLElement} HTML Element
|
|
321
603
|
*/
|
|
322
604
|
render() {
|
|
323
|
-
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), "
|
|
605
|
+
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { class: "mg-details__details" }, h("slot", { name: "details" }))));
|
|
324
606
|
}
|
|
325
607
|
static get watchers() { return {
|
|
326
608
|
"toggleClosed": ["validateTitles"],
|
|
@@ -330,6 +612,33 @@ const MgDetails = class {
|
|
|
330
612
|
};
|
|
331
613
|
MgDetails.style = mgDetailsCss;
|
|
332
614
|
|
|
615
|
+
const mgDividerCss = ".mg-divider{margin:var(--mg-divider-vertical-spacing) auto;width:12rem;height:var(--mg-divider-thickness);background-color:var(--mg-divider-background-color)}.mg-divider.mg-divider--full{width:100%}";
|
|
616
|
+
|
|
617
|
+
const MgDivider = class {
|
|
618
|
+
constructor(hostRef) {
|
|
619
|
+
registerInstance(this, hostRef);
|
|
620
|
+
/**************
|
|
621
|
+
* Decorators *
|
|
622
|
+
**************/
|
|
623
|
+
/**
|
|
624
|
+
* Define component size
|
|
625
|
+
*/
|
|
626
|
+
this.size = 'regular';
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Render
|
|
630
|
+
*
|
|
631
|
+
* @returns {HTMLElement} HTML Element
|
|
632
|
+
*/
|
|
633
|
+
render() {
|
|
634
|
+
return (h("div", { class: {
|
|
635
|
+
'mg-divider': true,
|
|
636
|
+
'mg-divider--full': this.size === 'full',
|
|
637
|
+
} }));
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
MgDivider.style = mgDividerCss;
|
|
641
|
+
|
|
333
642
|
const mgFormCss = ".is-asterisk{color:hsl(var(--color-danger))}.mg-form,.mg-form-group{--mg-inputs-title-width:var(--mg-form-inputs-title-width, 15rem);--mg-inputs-margin-bottom:1.5rem;--mg-inputs-title-horizontal-space:3rem;--mg-inputs-shrink:0}.mg-form.mg-form--all-required,.mg-form-group.mg-form--all-required{--mg-input-title-display:none}.mg-form>p,.mg-form-group>p{font-size:1.2rem}";
|
|
334
643
|
|
|
335
644
|
const MgForm = class {
|
|
@@ -2934,6 +3243,174 @@ const MgMessage = class {
|
|
|
2934
3243
|
};
|
|
2935
3244
|
MgMessage.style = mgMessageCss;
|
|
2936
3245
|
|
|
3246
|
+
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:hsla(var(--color-light), 85%)}.mg-modal__dialog{display:flex;position:relative;flex-direction:column;align-self:center;row-gap:3rem;padding:1.5rem 2.5rem;width:60rem;height:fit-content;max-width:100%;max-height:100%;box-sizing:border-box;background-color:hsl(var(--color-light));box-shadow:var(--box-shadow);border-radius:var(--mg-modal-border-radius)}.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}";
|
|
3247
|
+
|
|
3248
|
+
const MgModal = class {
|
|
3249
|
+
constructor(hostRef) {
|
|
3250
|
+
registerInstance(this, hostRef);
|
|
3251
|
+
this.componentShow = createEvent(this, "component-show", 7);
|
|
3252
|
+
this.componentHide = createEvent(this, "component-hide", 7);
|
|
3253
|
+
// Classes
|
|
3254
|
+
this.classHide = 'mg-modal--hide';
|
|
3255
|
+
// IDs
|
|
3256
|
+
this.closeButtonId = '';
|
|
3257
|
+
this.titleId = '';
|
|
3258
|
+
/**
|
|
3259
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
3260
|
+
* If not set, it will be created.
|
|
3261
|
+
*/
|
|
3262
|
+
this.identifier = createID('mg-modal');
|
|
3263
|
+
/**
|
|
3264
|
+
* Define if modal has a cross button
|
|
3265
|
+
*/
|
|
3266
|
+
this.closeButton = false;
|
|
3267
|
+
/**
|
|
3268
|
+
* Define if modal is hidden
|
|
3269
|
+
*/
|
|
3270
|
+
this.hide = false;
|
|
3271
|
+
/**
|
|
3272
|
+
* Define if component is using actions slot
|
|
3273
|
+
*/
|
|
3274
|
+
this.hasActions = false;
|
|
3275
|
+
/**
|
|
3276
|
+
* Define if component is using content slot
|
|
3277
|
+
*/
|
|
3278
|
+
this.hasContent = false;
|
|
3279
|
+
/**
|
|
3280
|
+
* Component classes
|
|
3281
|
+
*/
|
|
3282
|
+
this.classList = new ClassList(['mg-modal']);
|
|
3283
|
+
this.setFocus = () => {
|
|
3284
|
+
// Get all focusable elements
|
|
3285
|
+
this.modalFocusableElements = Array.from(this.element.querySelectorAll(focusableElements)).reduce((acc, focusableElement) => {
|
|
3286
|
+
acc.push(focusableElement.shadowRoot !== null ? focusableElement.shadowRoot.querySelector(focusableElements) || focusableElement : focusableElement);
|
|
3287
|
+
return acc;
|
|
3288
|
+
}, []);
|
|
3289
|
+
// When close button is enabled it's the first focusable element.
|
|
3290
|
+
if (this.closeButton) {
|
|
3291
|
+
this.modalFocusableElements.unshift(this.element.shadowRoot.querySelector(`.mg-modal__close-button mg-button`));
|
|
3292
|
+
}
|
|
3293
|
+
// It at least one
|
|
3294
|
+
if (this.modalFocusableElements.length >= 1) {
|
|
3295
|
+
// Set focus on first element
|
|
3296
|
+
this.modalFocusableElements[0].focus();
|
|
3297
|
+
// Add event listener on last element
|
|
3298
|
+
const lastFocusableElement = this.modalFocusableElements[this.modalFocusableElements.length - 1];
|
|
3299
|
+
lastFocusableElement.addEventListener('keydown', event => {
|
|
3300
|
+
if (event.key === 'Tab' && !event.shiftKey) {
|
|
3301
|
+
event.preventDefault();
|
|
3302
|
+
this.modalFocusableElements[0].focus();
|
|
3303
|
+
}
|
|
3304
|
+
});
|
|
3305
|
+
// Add event listener on first element (case shift + tab)
|
|
3306
|
+
this.modalFocusableElements[0].addEventListener('keydown', event => {
|
|
3307
|
+
if (event.key === 'Tab' && event.shiftKey) {
|
|
3308
|
+
event.preventDefault();
|
|
3309
|
+
lastFocusableElement.focus();
|
|
3310
|
+
}
|
|
3311
|
+
});
|
|
3312
|
+
}
|
|
3313
|
+
};
|
|
3314
|
+
/*************
|
|
3315
|
+
* Handlers *
|
|
3316
|
+
*************/
|
|
3317
|
+
/**
|
|
3318
|
+
* Handle close button
|
|
3319
|
+
*
|
|
3320
|
+
* @returns {void}
|
|
3321
|
+
*/
|
|
3322
|
+
this.handleClose = () => {
|
|
3323
|
+
this.hide = true;
|
|
3324
|
+
};
|
|
3325
|
+
}
|
|
3326
|
+
validateModalTitle(newValue) {
|
|
3327
|
+
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
3328
|
+
throw new Error('<mg-modal> prop "modalTitle" is required.');
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
validateHide(newValue) {
|
|
3332
|
+
if (newValue) {
|
|
3333
|
+
this.componentHide.emit();
|
|
3334
|
+
this.classList.add(this.classHide);
|
|
3335
|
+
document.body.style.overflow = this.bodyOverflow;
|
|
3336
|
+
}
|
|
3337
|
+
else {
|
|
3338
|
+
this.componentShow.emit();
|
|
3339
|
+
this.classList.delete(this.classHide);
|
|
3340
|
+
document.body.style.overflow = 'hidden';
|
|
3341
|
+
}
|
|
3342
|
+
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Handle 'escape' key down
|
|
3345
|
+
*
|
|
3346
|
+
* @param {KeyboardEvent} event keydown event
|
|
3347
|
+
* @returns {void}
|
|
3348
|
+
*/
|
|
3349
|
+
handleKeyDown(event) {
|
|
3350
|
+
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
3351
|
+
if (this.closeButton && event.key === 'Escape') {
|
|
3352
|
+
this.hide = true;
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
/*************
|
|
3356
|
+
* Lifecycle *
|
|
3357
|
+
*************/
|
|
3358
|
+
/**
|
|
3359
|
+
* Check if component props are well configured on init
|
|
3360
|
+
*
|
|
3361
|
+
* @returns {void}
|
|
3362
|
+
*/
|
|
3363
|
+
componentWillLoad() {
|
|
3364
|
+
// Store body overflow
|
|
3365
|
+
this.bodyOverflow = document.body.style.overflow;
|
|
3366
|
+
// Get locales
|
|
3367
|
+
this.messages = initLocales(this.element).messages;
|
|
3368
|
+
// Validate
|
|
3369
|
+
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
3370
|
+
this.hasContent = this.element.querySelector('[slot="content"]') !== null;
|
|
3371
|
+
if (this.closeButton) {
|
|
3372
|
+
this.closeButtonId = `${this.identifier}-close-button`;
|
|
3373
|
+
}
|
|
3374
|
+
this.titleId = `${this.identifier}-title`;
|
|
3375
|
+
this.validateModalTitle(this.modalTitle);
|
|
3376
|
+
this.validateHide(this.hide);
|
|
3377
|
+
}
|
|
3378
|
+
/**
|
|
3379
|
+
* Add observer on component to set focus when displayed
|
|
3380
|
+
*
|
|
3381
|
+
* @returns {void}
|
|
3382
|
+
*/
|
|
3383
|
+
componentDidLoad() {
|
|
3384
|
+
new MutationObserver(mutationList => {
|
|
3385
|
+
/*
|
|
3386
|
+
TODO find a way to cover this callback
|
|
3387
|
+
*/
|
|
3388
|
+
/* istanbul ignore next */
|
|
3389
|
+
if (mutationList.some(mutation => mutation.attributeName === 'aria-hidden' && mutation.target.ariaHidden === null)) {
|
|
3390
|
+
this.setFocus();
|
|
3391
|
+
}
|
|
3392
|
+
}).observe(this.element.shadowRoot.getElementById(this.identifier), { attributes: true });
|
|
3393
|
+
// Set focus if display on load
|
|
3394
|
+
if (!this.hide) {
|
|
3395
|
+
this.setFocus();
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
/**
|
|
3399
|
+
* Render
|
|
3400
|
+
*
|
|
3401
|
+
* @returns {HTMLElement} HTML Element
|
|
3402
|
+
*/
|
|
3403
|
+
render() {
|
|
3404
|
+
return (h("section", { role: "dialog", id: this.identifier, class: this.classList.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, h("article", { 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" }))))));
|
|
3405
|
+
}
|
|
3406
|
+
get element() { return getElement(this); }
|
|
3407
|
+
static get watchers() { return {
|
|
3408
|
+
"modalTitle": ["validateModalTitle"],
|
|
3409
|
+
"hide": ["validateHide"]
|
|
3410
|
+
}; }
|
|
3411
|
+
};
|
|
3412
|
+
MgModal.style = mgModalCss;
|
|
3413
|
+
|
|
2937
3414
|
var NavigationAction;
|
|
2938
3415
|
(function (NavigationAction) {
|
|
2939
3416
|
NavigationAction["NEXT"] = "next";
|
|
@@ -3065,7 +3542,7 @@ const MgPagination = class {
|
|
|
3065
3542
|
};
|
|
3066
3543
|
MgPagination.style = mgPaginationCss;
|
|
3067
3544
|
|
|
3068
|
-
const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);box-shadow:var(--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-
|
|
3545
|
+
const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);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}.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}";
|
|
3069
3546
|
|
|
3070
3547
|
const MgPanel = class {
|
|
3071
3548
|
constructor(hostRef) {
|
|
@@ -5036,7 +5513,7 @@ var createPopper = /*#__PURE__*/popperGenerator({
|
|
|
5036
5513
|
defaultModifiers: defaultModifiers
|
|
5037
5514
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
5038
5515
|
|
|
5039
|
-
const mgPopoverCss = "mg-popover{display:contents}mg-popover::slotted(*){display:inline-block}.mg-popover{display:none;padding:1.5rem;z-index:
|
|
5516
|
+
const mgPopoverCss = "mg-popover{display:contents}mg-popover::slotted(*){display:inline-block}.mg-popover{display:none;padding:1.5rem;z-index:1000;border-radius:0.5rem;background-color:hsl(var(--mg-popover-background-color));box-shadow:var(--box-shadow);color:hsl(var(--mg-popover-font-color))}.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,.mg-popover__arrow::before{position:absolute;width:2rem;height:2rem;z-index:-1;background:inherit}.mg-popover__arrow{visibility:hidden}.mg-popover__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow{bottom:-6px}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{top:-6px}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow{right:-6px}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{left:-6px}.mg-popover__title ::slotted([slot=title]){margin:0 0 1rem !important;font-size:var(--mg-popover-title-font-size) !important;font-weight:600}";
|
|
5040
5517
|
|
|
5041
5518
|
const MgPopover = class {
|
|
5042
5519
|
constructor(hostRef) {
|
|
@@ -5161,6 +5638,7 @@ const MgPopover = class {
|
|
|
5161
5638
|
// Create popperjs popover
|
|
5162
5639
|
this.popper = createPopper(interactiveElement, this.popover, {
|
|
5163
5640
|
placement: this.placement,
|
|
5641
|
+
strategy: 'fixed',
|
|
5164
5642
|
modifiers: [
|
|
5165
5643
|
{
|
|
5166
5644
|
name: 'offset',
|
|
@@ -5188,7 +5666,7 @@ const MgPopover = class {
|
|
|
5188
5666
|
* @returns {HTMLElement} HTML Element
|
|
5189
5667
|
*/
|
|
5190
5668
|
render() {
|
|
5191
|
-
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: "mg-popover" },
|
|
5669
|
+
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: "mg-popover" }, 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" }), h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
5192
5670
|
}
|
|
5193
5671
|
get element() { return getElement(this); }
|
|
5194
5672
|
static get watchers() { return {
|
|
@@ -5483,9 +5961,6 @@ const MgTag = class {
|
|
|
5483
5961
|
};
|
|
5484
5962
|
MgTag.style = mgTagCss;
|
|
5485
5963
|
|
|
5486
|
-
/**
|
|
5487
|
-
* List of all possibles placements
|
|
5488
|
-
*/
|
|
5489
5964
|
var Guard;
|
|
5490
5965
|
(function (Guard) {
|
|
5491
5966
|
Guard["FOCUS"] = "focus";
|
|
@@ -5493,7 +5968,7 @@ var Guard;
|
|
|
5493
5968
|
Guard["HOVER_TOOLTIPED_ELEMENT"] = "hoverTooltipedGuard";
|
|
5494
5969
|
})(Guard || (Guard = {}));
|
|
5495
5970
|
|
|
5496
|
-
const mgTooltipCss = ":host{display:inline-block}.mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:
|
|
5971
|
+
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}";
|
|
5497
5972
|
|
|
5498
5973
|
const MgTooltip = class {
|
|
5499
5974
|
constructor(hostRef) {
|
|
@@ -5630,6 +6105,7 @@ const MgTooltip = class {
|
|
|
5630
6105
|
// Create popperjs tooltip
|
|
5631
6106
|
this.popper = createPopper(tooltipedElement, this.tooltip, {
|
|
5632
6107
|
placement: this.placement,
|
|
6108
|
+
strategy: 'fixed',
|
|
5633
6109
|
modifiers: [
|
|
5634
6110
|
{
|
|
5635
6111
|
name: 'offset',
|
|
@@ -5685,4 +6161,4 @@ const MgTooltip = class {
|
|
|
5685
6161
|
};
|
|
5686
6162
|
MgTooltip.style = mgTooltipCss;
|
|
5687
6163
|
|
|
5688
|
-
export { MgBadge as mg_badge, MgButton as mg_button, MgCharacterLeft as mg_character_left, MgDetails as mg_details, 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, MgMessage as mg_message, MgPagination as mg_pagination, MgPanel as mg_panel, MgPopover as mg_popover, MgTabs as mg_tabs, MgTag as mg_tag, MgTooltip as mg_tooltip };
|
|
6164
|
+
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, 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 };
|