@mgdis/mg-components 5.0.0 → 5.2.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} +892 -295
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -1
- 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 +41 -3
- 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-tag/mg-tag.js +1 -1
- 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/inputs/MgInput.js +3 -11
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +41 -20
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +50 -39
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +42 -33
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +36 -17
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +35 -14
- package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +2 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -6
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +36 -17
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +38 -19
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +37 -18
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -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-form/mg-form.js +73 -27
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +6 -6
- package/dist/collection/components/molecules/mg-message/mg-message.js +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +2 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +48 -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/utils/unit.test.utils.js +51 -0
- package/dist/collection/variables.css +23 -8
- package/dist/components/MgInput.js +4 -12
- 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-badge2.js +1 -1
- package/dist/components/mg-button2.js +23 -4
- 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-form.js +67 -26
- package/dist/components/mg-input-checkbox.js +36 -21
- package/dist/components/mg-input-date.js +44 -39
- package/dist/components/mg-input-numeric.js +37 -34
- package/dist/components/mg-input-password.js +32 -19
- package/dist/components/mg-input-radio.js +30 -15
- package/dist/components/mg-input-select2.js +32 -19
- package/dist/components/mg-input-text2.js +34 -21
- package/dist/components/mg-input-textarea.js +32 -19
- package/dist/components/mg-input-toggle.js +1 -1
- package/dist/components/mg-message.js +1 -1
- package/dist/components/mg-modal.js +49 -5
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover.js +3 -2
- package/dist/components/mg-tag.js +1 -1
- 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} +839 -245
- 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-b2b07c3f.entry.js +1 -0
- package/dist/mg-components/variables.css +23 -8
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +8 -2
- 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/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +10 -8
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +3 -8
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +3 -8
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -4
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -3
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +21 -1
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +3 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +11 -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 +9 -9
- 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/collection/utils/test.utils.js +0 -38
- 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
- package/dist/types/utils/test.utils.d.ts +0 -17
|
@@ -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 {
|
|
@@ -14,7 +102,7 @@ const MgBadge = class {
|
|
|
14
102
|
/************
|
|
15
103
|
* Internal *
|
|
16
104
|
************/
|
|
17
|
-
//
|
|
105
|
+
// Classes
|
|
18
106
|
this.classOutline = `mg-badge--outline`;
|
|
19
107
|
/**
|
|
20
108
|
* Define button variant
|
|
@@ -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.
|
|
@@ -136,7 +229,7 @@ const MgButton = class {
|
|
|
136
229
|
}
|
|
137
230
|
};
|
|
138
231
|
/**
|
|
139
|
-
* Handle
|
|
232
|
+
* Handle onKeydown event
|
|
140
233
|
*
|
|
141
234
|
* @param {KeyboardEvent} event keyboard event
|
|
142
235
|
* @returns {void}
|
|
@@ -151,7 +244,7 @@ const MgButton = class {
|
|
|
151
244
|
}
|
|
152
245
|
};
|
|
153
246
|
/**
|
|
154
|
-
* Handle
|
|
247
|
+
* Handle onKeyup event
|
|
155
248
|
*
|
|
156
249
|
* @param {KeyboardEvent} event keyboard event
|
|
157
250
|
* @returns {void}
|
|
@@ -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,
|
|
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 {
|
|
@@ -337,6 +646,8 @@ const MgForm = class {
|
|
|
337
646
|
registerInstance(this, hostRef);
|
|
338
647
|
this.formValid = createEvent(this, "form-valid", 7);
|
|
339
648
|
this.formSubmit = createEvent(this, "form-submit", 7);
|
|
649
|
+
// Classes
|
|
650
|
+
this.classAllRequired = 'mg-form--all-required';
|
|
340
651
|
/**
|
|
341
652
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
342
653
|
* If not set, it will be created.
|
|
@@ -366,17 +677,24 @@ const MgForm = class {
|
|
|
366
677
|
* @returns {void}
|
|
367
678
|
*/
|
|
368
679
|
this.setRequiredMessage = () => {
|
|
369
|
-
//
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
//
|
|
373
|
-
if
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
680
|
+
// init required message
|
|
681
|
+
this.requiredMessage = null;
|
|
682
|
+
this.classList.delete(this.classAllRequired);
|
|
683
|
+
// If the form is disabled or readonly none of them are required
|
|
684
|
+
// Check if all fields are not editable (readonly or disabled)
|
|
685
|
+
if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
|
|
686
|
+
// Get required fields
|
|
687
|
+
const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !input.readonly);
|
|
688
|
+
// All fields are required
|
|
689
|
+
// mg-input-toggle can not be required
|
|
690
|
+
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
691
|
+
this.requiredMessage = this.messages.form.allRequired;
|
|
692
|
+
this.classList.add(this.classAllRequired);
|
|
693
|
+
}
|
|
694
|
+
// Some fields are required
|
|
695
|
+
else if (requiredInputs.length > 0) {
|
|
696
|
+
this.requiredMessage = this.messages.form.required;
|
|
697
|
+
}
|
|
380
698
|
}
|
|
381
699
|
};
|
|
382
700
|
/**
|
|
@@ -385,15 +703,46 @@ const MgForm = class {
|
|
|
385
703
|
* @returns {void}
|
|
386
704
|
*/
|
|
387
705
|
this.checkValidity = () => {
|
|
388
|
-
|
|
389
|
-
this.
|
|
390
|
-
this.
|
|
391
|
-
this.
|
|
706
|
+
// Update required on input event
|
|
707
|
+
this.setRequiredMessage();
|
|
708
|
+
this.valid = !this.mgInputs.some(input => input.invalid);
|
|
709
|
+
this.invalid = !this.valid;
|
|
710
|
+
// We need to send valid event if it is the same value
|
|
711
|
+
this.formValid.emit(this.valid);
|
|
392
712
|
};
|
|
713
|
+
/**
|
|
714
|
+
* Handle Form Submit
|
|
715
|
+
*
|
|
716
|
+
* @param {SubmitEvent} event submit event
|
|
717
|
+
* @returns {void}
|
|
718
|
+
*/
|
|
393
719
|
this.handleFormSubmit = (event) => {
|
|
394
720
|
event.preventDefault();
|
|
395
721
|
this.formSubmit.emit();
|
|
396
722
|
};
|
|
723
|
+
/**
|
|
724
|
+
* Set mgInputs
|
|
725
|
+
*
|
|
726
|
+
* @returns {void}
|
|
727
|
+
*/
|
|
728
|
+
this.setMgInputs = () => {
|
|
729
|
+
// Get slotted mgInputs
|
|
730
|
+
this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
|
|
731
|
+
// Set inputs readonly or disabled based on form configuration
|
|
732
|
+
// Othewise listen to events
|
|
733
|
+
this.mgInputs.map(input => {
|
|
734
|
+
if (this.readonly)
|
|
735
|
+
input.readonly = true;
|
|
736
|
+
else if (this.disabled)
|
|
737
|
+
input.disabled = true;
|
|
738
|
+
else
|
|
739
|
+
input.addEventListener('input-valid', this.checkValidity);
|
|
740
|
+
});
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
handleAttributeChange() {
|
|
744
|
+
this.setMgInputs();
|
|
745
|
+
this.setRequiredMessage();
|
|
397
746
|
}
|
|
398
747
|
/**
|
|
399
748
|
* Public method to display errors
|
|
@@ -419,26 +768,18 @@ const MgForm = class {
|
|
|
419
768
|
componentWillLoad() {
|
|
420
769
|
// Get locales
|
|
421
770
|
this.messages = initLocales(this.element).messages;
|
|
422
|
-
// Get slotted mgInputs
|
|
423
|
-
this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
|
|
424
771
|
// Get slotted mgButtons
|
|
425
|
-
this.mgButtons = Array.from(this.element.querySelectorAll('
|
|
772
|
+
this.mgButtons = Array.from(this.element.querySelectorAll('mg-button'));
|
|
426
773
|
// Set button form identifier
|
|
427
774
|
this.mgButtons.forEach(mgButton => {
|
|
428
775
|
mgButton.setAttribute('form', this.identifier);
|
|
429
776
|
});
|
|
777
|
+
// Set mgInputs
|
|
778
|
+
this.setMgInputs();
|
|
430
779
|
// Define required message
|
|
431
780
|
this.setRequiredMessage();
|
|
432
781
|
// Check validity when slotted mgInputs are ready
|
|
433
782
|
Promise.all(this.mgInputs.map(async (input) => {
|
|
434
|
-
// Set inputs readonly or disabled based on form configuration
|
|
435
|
-
// Othewise listen to events
|
|
436
|
-
if (this.readonly)
|
|
437
|
-
input.readonly = true;
|
|
438
|
-
else if (this.disabled)
|
|
439
|
-
input.disabled = true;
|
|
440
|
-
else
|
|
441
|
-
input.addEventListener('input-valid', this.checkValidity);
|
|
442
783
|
try {
|
|
443
784
|
await input.componentOnReady();
|
|
444
785
|
}
|
|
@@ -461,6 +802,10 @@ const MgForm = class {
|
|
|
461
802
|
});
|
|
462
803
|
}
|
|
463
804
|
});
|
|
805
|
+
// Update mgInputs when mgForm content change
|
|
806
|
+
new MutationObserver(() => {
|
|
807
|
+
this.setMgInputs();
|
|
808
|
+
}).observe(this.element, { childList: true });
|
|
464
809
|
}
|
|
465
810
|
/**
|
|
466
811
|
* Render
|
|
@@ -471,6 +816,10 @@ const MgForm = class {
|
|
|
471
816
|
return (h("form", { class: this.classList.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && h("p", { innerHTML: this.requiredMessage }), h("slot", null), !this.readonly && !this.disabled && h("slot", { name: "actions" })));
|
|
472
817
|
}
|
|
473
818
|
get element() { return getElement(this); }
|
|
819
|
+
static get watchers() { return {
|
|
820
|
+
"readonly": ["handleAttributeChange"],
|
|
821
|
+
"disabled": ["handleAttributeChange"]
|
|
822
|
+
}; }
|
|
474
823
|
};
|
|
475
824
|
MgForm.style = mgFormCss;
|
|
476
825
|
|
|
@@ -859,15 +1208,6 @@ const MgInput = (props, children, utils) => {
|
|
|
859
1208
|
if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
|
|
860
1209
|
ariaDescribedbyIDs.add(helpTextErrorId);
|
|
861
1210
|
}
|
|
862
|
-
/**
|
|
863
|
-
* Update input(s) in children
|
|
864
|
-
*/
|
|
865
|
-
if (props.readonly) {
|
|
866
|
-
children = children.filter(child => child.$name$ === 'append-input');
|
|
867
|
-
}
|
|
868
|
-
else {
|
|
869
|
-
children = applyAriadescribedBy(children, ariaDescribedbyIDs, utils);
|
|
870
|
-
}
|
|
871
1211
|
/**
|
|
872
1212
|
* Return template
|
|
873
1213
|
*
|
|
@@ -893,19 +1233,20 @@ const MgInput = (props, children, utils) => {
|
|
|
893
1233
|
h("mg-icon", { icon: "info-circle" })));
|
|
894
1234
|
/**
|
|
895
1235
|
* Get input title (label) node
|
|
1236
|
+
* Display asterisk only if not disabled and not readonly
|
|
896
1237
|
*
|
|
897
1238
|
* @returns {VNode[]} mg-input-title
|
|
898
1239
|
*/
|
|
899
|
-
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled, "is-legend": props.isFieldset }, props.label));
|
|
1240
|
+
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
|
|
900
1241
|
return (h(TagName, { class: props.classList.join() },
|
|
901
1242
|
props.labelOnTop ? (h("div", { class: "mg-input__title" },
|
|
902
1243
|
getInputTitle(),
|
|
903
1244
|
!props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
|
|
904
1245
|
props.readonly ? (h("div", { class: "mg-input__input-container" },
|
|
905
1246
|
h("strong", null, props.readonlyValue || props.value),
|
|
906
|
-
children)) : (h("div", { class: "mg-input__input-container" },
|
|
1247
|
+
children.filter(child => child.$name$ === 'append-input'))) : (h("div", { class: "mg-input__input-container" },
|
|
907
1248
|
h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } },
|
|
908
|
-
children,
|
|
1249
|
+
applyAriadescribedBy(children, ariaDescribedbyIDs, utils),
|
|
909
1250
|
!props.labelOnTop && props.tooltip && getTooltip()),
|
|
910
1251
|
props.helpText && h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }),
|
|
911
1252
|
props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
|
|
@@ -930,6 +1271,8 @@ const MgInputCheckbox = class {
|
|
|
930
1271
|
************/
|
|
931
1272
|
// HTML selector
|
|
932
1273
|
this.inputs = [];
|
|
1274
|
+
// hasDisplayedError (triggered by blur event)
|
|
1275
|
+
this.hasDisplayedError = false;
|
|
933
1276
|
/**
|
|
934
1277
|
* Input name
|
|
935
1278
|
* If not set the value equals the identifier
|
|
@@ -984,25 +1327,27 @@ const MgInputCheckbox = class {
|
|
|
984
1327
|
this.handleBlur = () => {
|
|
985
1328
|
// Check validity
|
|
986
1329
|
this.checkValidity();
|
|
987
|
-
this.
|
|
1330
|
+
this.setErrorMessage();
|
|
988
1331
|
};
|
|
1332
|
+
/**
|
|
1333
|
+
* get invalid element
|
|
1334
|
+
*
|
|
1335
|
+
* @returns {HTMLInputElement} element
|
|
1336
|
+
*/
|
|
1337
|
+
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
989
1338
|
/**
|
|
990
1339
|
* Check if input is valid
|
|
991
1340
|
*/
|
|
992
1341
|
this.checkValidity = () => {
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
this.invalid = !validity;
|
|
998
|
-
//Send event
|
|
999
|
-
this.inputValid.emit(validity);
|
|
1000
|
-
}
|
|
1342
|
+
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
1343
|
+
this.invalid = !this.valid;
|
|
1344
|
+
// We need to send valid event even if it is the same value
|
|
1345
|
+
this.inputValid.emit(this.valid);
|
|
1001
1346
|
};
|
|
1002
1347
|
/**
|
|
1003
|
-
*
|
|
1348
|
+
* Set input error message
|
|
1004
1349
|
*/
|
|
1005
|
-
this.
|
|
1350
|
+
this.setErrorMessage = () => {
|
|
1006
1351
|
const invalidElement = this.getInvalidElement();
|
|
1007
1352
|
// Set error message
|
|
1008
1353
|
this.errorMessage = undefined;
|
|
@@ -1010,12 +1355,6 @@ const MgInputCheckbox = class {
|
|
|
1010
1355
|
this.errorMessage = this.messages.errors.required;
|
|
1011
1356
|
}
|
|
1012
1357
|
};
|
|
1013
|
-
/**
|
|
1014
|
-
* get invalid element
|
|
1015
|
-
*
|
|
1016
|
-
* @returns {HTMLInputElement} element
|
|
1017
|
-
*/
|
|
1018
|
-
this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
|
|
1019
1358
|
}
|
|
1020
1359
|
validateValue(newValue) {
|
|
1021
1360
|
if (newValue && newValue.every(item => isCheckboxItem(item))) {
|
|
@@ -1031,6 +1370,16 @@ const MgInputCheckbox = class {
|
|
|
1031
1370
|
throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
|
|
1032
1371
|
}
|
|
1033
1372
|
}
|
|
1373
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
1374
|
+
this.inputs.forEach(input => {
|
|
1375
|
+
input[prop] = newValue;
|
|
1376
|
+
});
|
|
1377
|
+
this.checkValidity();
|
|
1378
|
+
if (this.hasDisplayedError) {
|
|
1379
|
+
this.setErrorMessage();
|
|
1380
|
+
this.hasDisplayedError = false;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1034
1383
|
/**
|
|
1035
1384
|
* Public method to display errors
|
|
1036
1385
|
*
|
|
@@ -1038,7 +1387,8 @@ const MgInputCheckbox = class {
|
|
|
1038
1387
|
*/
|
|
1039
1388
|
async displayError() {
|
|
1040
1389
|
this.checkValidity();
|
|
1041
|
-
this.
|
|
1390
|
+
this.setErrorMessage();
|
|
1391
|
+
this.hasDisplayedError = this.invalid;
|
|
1042
1392
|
}
|
|
1043
1393
|
/*************
|
|
1044
1394
|
* Lifecycle *
|
|
@@ -1066,15 +1416,21 @@ const MgInputCheckbox = class {
|
|
|
1066
1416
|
* @returns {HTMLElement} HTML Element
|
|
1067
1417
|
*/
|
|
1068
1418
|
render() {
|
|
1069
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly
|
|
1419
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
|
|
1070
1420
|
.filter(item => {
|
|
1071
1421
|
return !this.readonly || item.value;
|
|
1072
1422
|
})
|
|
1073
|
-
.map(input => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el =>
|
|
1423
|
+
.map((input, index) => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
1424
|
+
if (el !== null)
|
|
1425
|
+
this.inputs[index] = el;
|
|
1426
|
+
} }), h("label", { htmlFor: input.id }, input.title)))))));
|
|
1074
1427
|
}
|
|
1075
1428
|
get element() { return getElement(this); }
|
|
1076
1429
|
static get watchers() { return {
|
|
1077
|
-
"value": ["validateValue"]
|
|
1430
|
+
"value": ["validateValue"],
|
|
1431
|
+
"required": ["handleValidityChange"],
|
|
1432
|
+
"readonly": ["handleValidityChange"],
|
|
1433
|
+
"disabled": ["handleValidityChange"]
|
|
1078
1434
|
}; }
|
|
1079
1435
|
};
|
|
1080
1436
|
MgInputCheckbox.style = mgInputCheckboxCss;
|
|
@@ -1133,8 +1489,8 @@ const MgInputDate = class {
|
|
|
1133
1489
|
registerInstance(this, hostRef);
|
|
1134
1490
|
this.valueChange = createEvent(this, "value-change", 7);
|
|
1135
1491
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
1136
|
-
//
|
|
1137
|
-
this.
|
|
1492
|
+
// hasDisplayedError (triggered by blur event)
|
|
1493
|
+
this.hasDisplayedError = false;
|
|
1138
1494
|
/**
|
|
1139
1495
|
* Input name
|
|
1140
1496
|
* If not set the value equals the identifier
|
|
@@ -1165,8 +1521,8 @@ const MgInputDate = class {
|
|
|
1165
1521
|
*/
|
|
1166
1522
|
this.handleInput = () => {
|
|
1167
1523
|
this.checkValidity();
|
|
1168
|
-
if (this.
|
|
1169
|
-
this.
|
|
1524
|
+
if (this.hasDisplayedError) {
|
|
1525
|
+
this.setErrorMessage();
|
|
1170
1526
|
}
|
|
1171
1527
|
this.value = this.input.value;
|
|
1172
1528
|
};
|
|
@@ -1180,14 +1536,11 @@ const MgInputDate = class {
|
|
|
1180
1536
|
* Check if input is valid
|
|
1181
1537
|
*/
|
|
1182
1538
|
this.checkValidity = () => {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
//Send event
|
|
1189
|
-
this.inputValid.emit(validity);
|
|
1190
|
-
}
|
|
1539
|
+
var _a;
|
|
1540
|
+
this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
|
|
1541
|
+
this.invalid = !this.valid;
|
|
1542
|
+
// We need to send valid event even if it is the same value
|
|
1543
|
+
this.inputValid.emit(this.valid);
|
|
1191
1544
|
};
|
|
1192
1545
|
/**
|
|
1193
1546
|
* get input error code
|
|
@@ -1216,48 +1569,50 @@ const MgInputDate = class {
|
|
|
1216
1569
|
return inputError;
|
|
1217
1570
|
};
|
|
1218
1571
|
/**
|
|
1219
|
-
*
|
|
1572
|
+
* Check input errors
|
|
1220
1573
|
*
|
|
1221
1574
|
* @returns {void}
|
|
1222
1575
|
*/
|
|
1223
1576
|
this.setErrorMessage = () => {
|
|
1224
1577
|
var _a;
|
|
1225
|
-
const inputError = this.getInputError();
|
|
1226
|
-
// required
|
|
1227
|
-
if (inputError === InputError$1.REQUIRED) {
|
|
1228
|
-
this.errorMessage = this.messages.errors[inputError];
|
|
1229
|
-
}
|
|
1230
|
-
// min, max & minMax
|
|
1231
|
-
else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
|
|
1232
|
-
this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
|
|
1233
|
-
}
|
|
1234
|
-
// wrong date format
|
|
1235
|
-
// element.validity.badInput is default error message
|
|
1236
|
-
else {
|
|
1237
|
-
this.errorMessage = this.messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min, this.locale) : localeDate('1900-01-01', this.locale));
|
|
1238
|
-
}
|
|
1239
|
-
};
|
|
1240
|
-
/**
|
|
1241
|
-
* Check input errors
|
|
1242
|
-
*
|
|
1243
|
-
* @returns {void}
|
|
1244
|
-
*/
|
|
1245
|
-
this.checkError = () => {
|
|
1246
1578
|
// Set error message
|
|
1247
1579
|
this.errorMessage = undefined;
|
|
1248
1580
|
if (!this.valid) {
|
|
1249
|
-
this.
|
|
1581
|
+
const inputError = this.getInputError();
|
|
1582
|
+
// required
|
|
1583
|
+
if (inputError === InputError$1.REQUIRED) {
|
|
1584
|
+
this.errorMessage = this.messages.errors[inputError];
|
|
1585
|
+
}
|
|
1586
|
+
// min, max & minMax
|
|
1587
|
+
else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
|
|
1588
|
+
this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
|
|
1589
|
+
}
|
|
1590
|
+
// wrong date format
|
|
1591
|
+
// element.validity.badInput is default error message
|
|
1592
|
+
else {
|
|
1593
|
+
this.errorMessage = this.messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min, this.locale) : localeDate('1900-01-01', this.locale));
|
|
1594
|
+
}
|
|
1250
1595
|
}
|
|
1251
1596
|
};
|
|
1252
1597
|
}
|
|
1253
1598
|
validateValue(newValue) {
|
|
1254
|
-
if (newValue !== undefined && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
|
|
1599
|
+
if (newValue !== undefined && newValue !== null && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
|
|
1255
1600
|
throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
|
|
1256
1601
|
}
|
|
1257
1602
|
else {
|
|
1258
1603
|
this.valueChange.emit(this.value);
|
|
1259
1604
|
}
|
|
1260
1605
|
}
|
|
1606
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
1607
|
+
if (this.input !== undefined) {
|
|
1608
|
+
this.input[prop] = newValue;
|
|
1609
|
+
this.checkValidity();
|
|
1610
|
+
if (this.hasDisplayedError) {
|
|
1611
|
+
this.setErrorMessage();
|
|
1612
|
+
this.hasDisplayedError = false;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1261
1616
|
validateMinMax(newValue) {
|
|
1262
1617
|
if ((newValue === null || newValue === void 0 ? void 0 : newValue.length) === 0 || ((newValue === null || newValue === void 0 ? void 0 : newValue.length) > 0 && !(typeof newValue === 'string' && dateRegExp.test(newValue)))) {
|
|
1263
1618
|
throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
|
|
@@ -1270,8 +1625,8 @@ const MgInputDate = class {
|
|
|
1270
1625
|
*/
|
|
1271
1626
|
async displayError() {
|
|
1272
1627
|
this.checkValidity();
|
|
1273
|
-
this.
|
|
1274
|
-
this.
|
|
1628
|
+
this.setErrorMessage();
|
|
1629
|
+
this.hasDisplayedError = this.invalid;
|
|
1275
1630
|
}
|
|
1276
1631
|
/*************
|
|
1277
1632
|
* Lifecycle *
|
|
@@ -1303,11 +1658,17 @@ const MgInputDate = class {
|
|
|
1303
1658
|
* @returns {HTMLElement} HTML Element
|
|
1304
1659
|
*/
|
|
1305
1660
|
render() {
|
|
1306
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el =>
|
|
1661
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => {
|
|
1662
|
+
if (el !== null)
|
|
1663
|
+
this.input = el;
|
|
1664
|
+
} })));
|
|
1307
1665
|
}
|
|
1308
1666
|
get element() { return getElement(this); }
|
|
1309
1667
|
static get watchers() { return {
|
|
1310
1668
|
"value": ["validateValue"],
|
|
1669
|
+
"required": ["handleValidityChange"],
|
|
1670
|
+
"readonly": ["handleValidityChange"],
|
|
1671
|
+
"disabled": ["handleValidityChange"],
|
|
1311
1672
|
"min": ["validateMinMax"],
|
|
1312
1673
|
"max": ["validateMinMax"]
|
|
1313
1674
|
}; }
|
|
@@ -1326,15 +1687,15 @@ var InputError;
|
|
|
1326
1687
|
InputError["REQUIRED"] = "required";
|
|
1327
1688
|
})(InputError || (InputError = {}));
|
|
1328
1689
|
|
|
1329
|
-
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 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)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.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{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{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}.mg-input .mg-input__box{text-align:var(--mg-inputs-text-align, right)}";
|
|
1690
|
+
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 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)}.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}.mg-input .mg-input__box{text-align:var(--mg-inputs-text-align, right)}";
|
|
1330
1691
|
|
|
1331
1692
|
const MgInputNumeric = class {
|
|
1332
1693
|
constructor(hostRef) {
|
|
1333
1694
|
registerInstance(this, hostRef);
|
|
1334
1695
|
this.valueChange = createEvent(this, "value-change", 7);
|
|
1335
1696
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
1336
|
-
//
|
|
1337
|
-
this.
|
|
1697
|
+
// hasDisplayedError (triggered by blur event)
|
|
1698
|
+
this.hasDisplayedError = false;
|
|
1338
1699
|
/**
|
|
1339
1700
|
* Input name
|
|
1340
1701
|
* If not set the value equals the identifier
|
|
@@ -1390,8 +1751,8 @@ const MgInputNumeric = class {
|
|
|
1390
1751
|
this.handleInput = () => {
|
|
1391
1752
|
// Check validity
|
|
1392
1753
|
this.checkValidity();
|
|
1393
|
-
if (this.
|
|
1394
|
-
this.
|
|
1754
|
+
if (this.hasDisplayedError) {
|
|
1755
|
+
this.setErrorMessage();
|
|
1395
1756
|
}
|
|
1396
1757
|
this.value = this.input.value;
|
|
1397
1758
|
};
|
|
@@ -1419,40 +1780,27 @@ const MgInputNumeric = class {
|
|
|
1419
1780
|
* @returns {void}
|
|
1420
1781
|
*/
|
|
1421
1782
|
this.checkValidity = () => {
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
this.invalid = !validity;
|
|
1427
|
-
//Send event
|
|
1428
|
-
this.inputValid.emit(validity);
|
|
1429
|
-
}
|
|
1783
|
+
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
1784
|
+
this.invalid = !this.valid;
|
|
1785
|
+
// We need to send valid event even if it is the same value
|
|
1786
|
+
this.inputValid.emit(this.valid);
|
|
1430
1787
|
};
|
|
1431
1788
|
/**
|
|
1432
|
-
* Set error message
|
|
1789
|
+
* Set input error message
|
|
1433
1790
|
*
|
|
1434
1791
|
* @returns {void}
|
|
1435
1792
|
*/
|
|
1436
1793
|
this.setErrorMessage = () => {
|
|
1437
|
-
const inputError = this.getInputError();
|
|
1438
|
-
if (inputError === InputError.REQUIRED) {
|
|
1439
|
-
this.errorMessage = this.messages.errors[inputError];
|
|
1440
|
-
}
|
|
1441
|
-
else {
|
|
1442
|
-
this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
|
|
1443
|
-
}
|
|
1444
|
-
};
|
|
1445
|
-
/**
|
|
1446
|
-
* Check input errors
|
|
1447
|
-
*
|
|
1448
|
-
* @returns {void}
|
|
1449
|
-
*/
|
|
1450
|
-
this.checkError = () => {
|
|
1451
1794
|
// Set error message
|
|
1452
1795
|
this.errorMessage = undefined;
|
|
1453
|
-
// Update class
|
|
1454
1796
|
if (!this.valid) {
|
|
1455
|
-
this.
|
|
1797
|
+
const inputError = this.getInputError();
|
|
1798
|
+
if (inputError === InputError.REQUIRED) {
|
|
1799
|
+
this.errorMessage = this.messages.errors[inputError];
|
|
1800
|
+
}
|
|
1801
|
+
else {
|
|
1802
|
+
this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
|
|
1803
|
+
}
|
|
1456
1804
|
}
|
|
1457
1805
|
};
|
|
1458
1806
|
/**
|
|
@@ -1462,7 +1810,7 @@ const MgInputNumeric = class {
|
|
|
1462
1810
|
*/
|
|
1463
1811
|
this.getInputError = () => {
|
|
1464
1812
|
let inputError = null;
|
|
1465
|
-
if (this.input === undefined)
|
|
1813
|
+
if (this.input === undefined || this.input === null)
|
|
1466
1814
|
return inputError;
|
|
1467
1815
|
// required
|
|
1468
1816
|
if (!this.input.checkValidity() && this.input.validity.valueMissing) {
|
|
@@ -1529,6 +1877,16 @@ const MgInputNumeric = class {
|
|
|
1529
1877
|
this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
|
|
1530
1878
|
}
|
|
1531
1879
|
}
|
|
1880
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
1881
|
+
if (this.input !== undefined) {
|
|
1882
|
+
this.input[prop] = newValue;
|
|
1883
|
+
this.checkValidity();
|
|
1884
|
+
if (this.hasDisplayedError) {
|
|
1885
|
+
this.setErrorMessage();
|
|
1886
|
+
this.hasDisplayedError = false;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1532
1890
|
validateType(newValue) {
|
|
1533
1891
|
if (!types.includes(newValue)) {
|
|
1534
1892
|
throw new Error(`<mg-input-numeric> prop "type" must be one of : ${types.join(', ')}`);
|
|
@@ -1551,8 +1909,8 @@ const MgInputNumeric = class {
|
|
|
1551
1909
|
*/
|
|
1552
1910
|
async displayError() {
|
|
1553
1911
|
this.checkValidity();
|
|
1554
|
-
this.
|
|
1555
|
-
this.
|
|
1912
|
+
this.setErrorMessage();
|
|
1913
|
+
this.hasDisplayedError = this.invalid;
|
|
1556
1914
|
}
|
|
1557
1915
|
/**
|
|
1558
1916
|
* Displayed value in input
|
|
@@ -1595,11 +1953,17 @@ const MgInputNumeric = class {
|
|
|
1595
1953
|
* @returns {HTMLElement} HTML Element
|
|
1596
1954
|
*/
|
|
1597
1955
|
render() {
|
|
1598
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el =>
|
|
1956
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
|
|
1957
|
+
if (el !== null)
|
|
1958
|
+
this.input = el;
|
|
1959
|
+
} }), h("slot", { name: "append-input" })));
|
|
1599
1960
|
}
|
|
1600
1961
|
get element() { return getElement(this); }
|
|
1601
1962
|
static get watchers() { return {
|
|
1602
1963
|
"value": ["validateValue"],
|
|
1964
|
+
"required": ["handleValidityChange"],
|
|
1965
|
+
"readonly": ["handleValidityChange"],
|
|
1966
|
+
"disabled": ["handleValidityChange"],
|
|
1603
1967
|
"type": ["validateType"],
|
|
1604
1968
|
"integerLength": ["validateIntegerLength"],
|
|
1605
1969
|
"decimalLength": ["validateDecimalLength"]
|
|
@@ -1607,15 +1971,15 @@ const MgInputNumeric = class {
|
|
|
1607
1971
|
};
|
|
1608
1972
|
MgInputNumeric.style = mgInputNumericCss;
|
|
1609
1973
|
|
|
1610
|
-
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 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)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.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{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{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}";
|
|
1974
|
+
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 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)}.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}";
|
|
1611
1975
|
|
|
1612
1976
|
const MgInputPassword = class {
|
|
1613
1977
|
constructor(hostRef) {
|
|
1614
1978
|
registerInstance(this, hostRef);
|
|
1615
1979
|
this.valueChange = createEvent(this, "value-change", 7);
|
|
1616
1980
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
1617
|
-
//
|
|
1618
|
-
this.
|
|
1981
|
+
// hasDisplayedError (triggered by blur event)
|
|
1982
|
+
this.hasDisplayedError = false;
|
|
1619
1983
|
/**
|
|
1620
1984
|
* Input name
|
|
1621
1985
|
* If not set the value equals the identifier
|
|
@@ -1650,8 +2014,8 @@ const MgInputPassword = class {
|
|
|
1650
2014
|
*/
|
|
1651
2015
|
this.handleInput = () => {
|
|
1652
2016
|
this.checkValidity();
|
|
1653
|
-
if (this.
|
|
1654
|
-
this.
|
|
2017
|
+
if (this.hasDisplayedError) {
|
|
2018
|
+
this.setErrorMessage();
|
|
1655
2019
|
}
|
|
1656
2020
|
this.value = this.input.value;
|
|
1657
2021
|
};
|
|
@@ -1665,19 +2029,16 @@ const MgInputPassword = class {
|
|
|
1665
2029
|
* Check if input is valid
|
|
1666
2030
|
*/
|
|
1667
2031
|
this.checkValidity = () => {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
//Send event
|
|
1674
|
-
this.inputValid.emit(validity);
|
|
1675
|
-
}
|
|
2032
|
+
var _a;
|
|
2033
|
+
this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
|
|
2034
|
+
this.invalid = !this.valid;
|
|
2035
|
+
// We need to send valid event even if it is the same value
|
|
2036
|
+
this.inputValid.emit(this.valid);
|
|
1676
2037
|
};
|
|
1677
2038
|
/**
|
|
1678
|
-
*
|
|
2039
|
+
* Set input error message
|
|
1679
2040
|
*/
|
|
1680
|
-
this.
|
|
2041
|
+
this.setErrorMessage = () => {
|
|
1681
2042
|
// Set error message
|
|
1682
2043
|
this.errorMessage = undefined;
|
|
1683
2044
|
// required
|
|
@@ -1689,6 +2050,16 @@ const MgInputPassword = class {
|
|
|
1689
2050
|
handleValue(newValue) {
|
|
1690
2051
|
this.valueChange.emit(newValue);
|
|
1691
2052
|
}
|
|
2053
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
2054
|
+
if (this.input !== undefined) {
|
|
2055
|
+
this.input[prop] = newValue;
|
|
2056
|
+
this.checkValidity();
|
|
2057
|
+
if (this.hasDisplayedError) {
|
|
2058
|
+
this.setErrorMessage();
|
|
2059
|
+
this.hasDisplayedError = false;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
1692
2063
|
/**
|
|
1693
2064
|
* Public method to display errors
|
|
1694
2065
|
*
|
|
@@ -1696,8 +2067,8 @@ const MgInputPassword = class {
|
|
|
1696
2067
|
*/
|
|
1697
2068
|
async displayError() {
|
|
1698
2069
|
this.checkValidity();
|
|
1699
|
-
this.
|
|
1700
|
-
this.
|
|
2070
|
+
this.setErrorMessage();
|
|
2071
|
+
this.hasDisplayedError = this.invalid;
|
|
1701
2072
|
}
|
|
1702
2073
|
/*************
|
|
1703
2074
|
* Lifecycle *
|
|
@@ -1723,11 +2094,17 @@ const MgInputPassword = class {
|
|
|
1723
2094
|
* @returns {HTMLElement} HTML Element
|
|
1724
2095
|
*/
|
|
1725
2096
|
render() {
|
|
1726
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el =>
|
|
2097
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2098
|
+
if (el !== null)
|
|
2099
|
+
this.input = el;
|
|
2100
|
+
} })));
|
|
1727
2101
|
}
|
|
1728
2102
|
get element() { return getElement(this); }
|
|
1729
2103
|
static get watchers() { return {
|
|
1730
|
-
"value": ["handleValue"]
|
|
2104
|
+
"value": ["handleValue"],
|
|
2105
|
+
"required": ["handleValidityChange"],
|
|
2106
|
+
"readonly": ["handleValidityChange"],
|
|
2107
|
+
"disabled": ["handleValidityChange"]
|
|
1731
2108
|
}; }
|
|
1732
2109
|
};
|
|
1733
2110
|
MgInputPassword.style = mgInputPasswordCss;
|
|
@@ -1751,6 +2128,8 @@ const MgInputRadio = class {
|
|
|
1751
2128
|
************/
|
|
1752
2129
|
// HTML selector
|
|
1753
2130
|
this.inputs = [];
|
|
2131
|
+
// hasDisplayedError (triggered by blur event)
|
|
2132
|
+
this.hasDisplayedError = false;
|
|
1754
2133
|
/**
|
|
1755
2134
|
* Input name
|
|
1756
2135
|
* If not set the value equals the identifier
|
|
@@ -1801,7 +2180,7 @@ const MgInputRadio = class {
|
|
|
1801
2180
|
*/
|
|
1802
2181
|
this.handleBlur = () => {
|
|
1803
2182
|
this.checkValidity();
|
|
1804
|
-
this.
|
|
2183
|
+
this.setErrorMessage();
|
|
1805
2184
|
};
|
|
1806
2185
|
/**
|
|
1807
2186
|
* Check if input is valid
|
|
@@ -1809,21 +2188,17 @@ const MgInputRadio = class {
|
|
|
1809
2188
|
* @returns {void}
|
|
1810
2189
|
*/
|
|
1811
2190
|
this.checkValidity = () => {
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
this.invalid = !validity;
|
|
1817
|
-
//Send event
|
|
1818
|
-
this.inputValid.emit(validity);
|
|
1819
|
-
}
|
|
2191
|
+
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
2192
|
+
this.invalid = !this.valid;
|
|
2193
|
+
// We need to send valid event even if it is the same value
|
|
2194
|
+
this.inputValid.emit(this.valid);
|
|
1820
2195
|
};
|
|
1821
2196
|
/**
|
|
1822
|
-
*
|
|
2197
|
+
* Set input error message
|
|
1823
2198
|
*
|
|
1824
2199
|
* @returns {void}
|
|
1825
2200
|
*/
|
|
1826
|
-
this.
|
|
2201
|
+
this.setErrorMessage = () => {
|
|
1827
2202
|
const invalidElement = this.getInvalidElement();
|
|
1828
2203
|
// Set error message
|
|
1829
2204
|
this.errorMessage = undefined;
|
|
@@ -1836,7 +2211,7 @@ const MgInputRadio = class {
|
|
|
1836
2211
|
*
|
|
1837
2212
|
* @returns {HTMLInputElement} element
|
|
1838
2213
|
*/
|
|
1839
|
-
this.getInvalidElement = () => this.inputs.find((
|
|
2214
|
+
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
1840
2215
|
}
|
|
1841
2216
|
handleValue(newValue) {
|
|
1842
2217
|
this.valueChange.emit(newValue);
|
|
@@ -1858,6 +2233,16 @@ const MgInputRadio = class {
|
|
|
1858
2233
|
throw new Error('<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption.');
|
|
1859
2234
|
}
|
|
1860
2235
|
}
|
|
2236
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
2237
|
+
this.inputs.forEach(input => {
|
|
2238
|
+
input[prop] = newValue;
|
|
2239
|
+
});
|
|
2240
|
+
this.checkValidity();
|
|
2241
|
+
if (this.hasDisplayedError) {
|
|
2242
|
+
this.setErrorMessage();
|
|
2243
|
+
this.hasDisplayedError = false;
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
1861
2246
|
/**
|
|
1862
2247
|
* Public method to display errors
|
|
1863
2248
|
*
|
|
@@ -1865,7 +2250,8 @@ const MgInputRadio = class {
|
|
|
1865
2250
|
*/
|
|
1866
2251
|
async displayError() {
|
|
1867
2252
|
this.checkValidity();
|
|
1868
|
-
this.
|
|
2253
|
+
this.setErrorMessage();
|
|
2254
|
+
this.hasDisplayedError = this.invalid;
|
|
1869
2255
|
}
|
|
1870
2256
|
/*************
|
|
1871
2257
|
* Lifecycle *
|
|
@@ -1893,17 +2279,23 @@ const MgInputRadio = class {
|
|
|
1893
2279
|
* @returns {HTMLElement} HTML Element
|
|
1894
2280
|
*/
|
|
1895
2281
|
render() {
|
|
1896
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index) => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el =>
|
|
2282
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index) => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
|
|
2283
|
+
if (el !== null)
|
|
2284
|
+
this.inputs[index] = el;
|
|
2285
|
+
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
|
|
1897
2286
|
}
|
|
1898
2287
|
get element() { return getElement(this); }
|
|
1899
2288
|
static get watchers() { return {
|
|
1900
2289
|
"value": ["handleValue"],
|
|
1901
|
-
"items": ["validateItems"]
|
|
2290
|
+
"items": ["validateItems"],
|
|
2291
|
+
"required": ["handleValidityChange"],
|
|
2292
|
+
"readonly": ["handleValidityChange"],
|
|
2293
|
+
"disabled": ["handleValidityChange"]
|
|
1902
2294
|
}; }
|
|
1903
2295
|
};
|
|
1904
2296
|
MgInputRadio.style = mgInputRadioCss;
|
|
1905
2297
|
|
|
1906
|
-
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 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)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.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{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{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}.mg-input__box{width:100%;padding-top:0;padding-bottom:0;padding-right:1rem}";
|
|
2298
|
+
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 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)}.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}.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}";
|
|
1907
2299
|
|
|
1908
2300
|
/**
|
|
1909
2301
|
* Check if item is a well configured option
|
|
@@ -1946,8 +2338,8 @@ const MgInputSelect = class {
|
|
|
1946
2338
|
registerInstance(this, hostRef);
|
|
1947
2339
|
this.valueChange = createEvent(this, "value-change", 7);
|
|
1948
2340
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
1949
|
-
//
|
|
1950
|
-
this.
|
|
2341
|
+
// hasDisplayedError (triggered by blur event)
|
|
2342
|
+
this.hasDisplayedError = false;
|
|
1951
2343
|
/**
|
|
1952
2344
|
* Input name
|
|
1953
2345
|
* If not set the value equals the identifier
|
|
@@ -1986,8 +2378,8 @@ const MgInputSelect = class {
|
|
|
1986
2378
|
*/
|
|
1987
2379
|
this.handleInput = () => {
|
|
1988
2380
|
this.checkValidity();
|
|
1989
|
-
if (this.
|
|
1990
|
-
this.
|
|
2381
|
+
if (this.hasDisplayedError) {
|
|
2382
|
+
this.setErrorMessage();
|
|
1991
2383
|
}
|
|
1992
2384
|
if (this.input.value !== '') {
|
|
1993
2385
|
this.value = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
|
|
@@ -2006,19 +2398,16 @@ const MgInputSelect = class {
|
|
|
2006
2398
|
* Check if input is valid
|
|
2007
2399
|
*/
|
|
2008
2400
|
this.checkValidity = () => {
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
//Send event
|
|
2015
|
-
this.inputValid.emit(validity);
|
|
2016
|
-
}
|
|
2401
|
+
var _a;
|
|
2402
|
+
this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
|
|
2403
|
+
this.invalid = !this.valid;
|
|
2404
|
+
// We need to send valid event even if it is the same value
|
|
2405
|
+
this.inputValid.emit(this.valid);
|
|
2017
2406
|
};
|
|
2018
2407
|
/**
|
|
2019
|
-
*
|
|
2408
|
+
* Set input error message
|
|
2020
2409
|
*/
|
|
2021
|
-
this.
|
|
2410
|
+
this.setErrorMessage = () => {
|
|
2022
2411
|
// Set error message
|
|
2023
2412
|
this.errorMessage = undefined;
|
|
2024
2413
|
if (!this.valid && this.input.validity.valueMissing) {
|
|
@@ -2057,6 +2446,16 @@ const MgInputSelect = class {
|
|
|
2057
2446
|
throw new Error('<mg-input-select> prop "items" is required and all items must be the same type, string or Option.');
|
|
2058
2447
|
}
|
|
2059
2448
|
}
|
|
2449
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
2450
|
+
if (this.input !== undefined) {
|
|
2451
|
+
this.input[prop] = newValue;
|
|
2452
|
+
this.checkValidity();
|
|
2453
|
+
if (this.hasDisplayedError) {
|
|
2454
|
+
this.setErrorMessage();
|
|
2455
|
+
this.hasDisplayedError = false;
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2060
2459
|
/**
|
|
2061
2460
|
* Public method to display errors
|
|
2062
2461
|
*
|
|
@@ -2064,8 +2463,8 @@ const MgInputSelect = class {
|
|
|
2064
2463
|
*/
|
|
2065
2464
|
async displayError() {
|
|
2066
2465
|
this.checkValidity();
|
|
2067
|
-
this.
|
|
2068
|
-
this.
|
|
2466
|
+
this.setErrorMessage();
|
|
2467
|
+
this.hasDisplayedError = this.invalid;
|
|
2069
2468
|
}
|
|
2070
2469
|
/*************
|
|
2071
2470
|
* Lifecycle *
|
|
@@ -2097,18 +2496,24 @@ const MgInputSelect = class {
|
|
|
2097
2496
|
* @returns {HTMLElement} HTML Element
|
|
2098
2497
|
*/
|
|
2099
2498
|
render() {
|
|
2100
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el =>
|
|
2499
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2500
|
+
if (el !== null)
|
|
2501
|
+
this.input = el;
|
|
2502
|
+
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
2101
2503
|
h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(option => option.group !== undefined ? (h("optgroup", { label: option.group }, option.options.map(optgroup => (h("option", { value: optgroup.title, selected: JSON.stringify(this.value) === JSON.stringify(optgroup.value), disabled: optgroup.disabled }, optgroup.title))))) : (h("option", { value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title))))));
|
|
2102
2504
|
}
|
|
2103
2505
|
get element() { return getElement(this); }
|
|
2104
2506
|
static get watchers() { return {
|
|
2105
2507
|
"value": ["handleValue"],
|
|
2106
|
-
"items": ["validateItems"]
|
|
2508
|
+
"items": ["validateItems"],
|
|
2509
|
+
"required": ["handleValidityChange"],
|
|
2510
|
+
"readonly": ["handleValidityChange"],
|
|
2511
|
+
"disabled": ["handleValidityChange"]
|
|
2107
2512
|
}; }
|
|
2108
2513
|
};
|
|
2109
2514
|
MgInputSelect.style = mgInputSelectCss;
|
|
2110
2515
|
|
|
2111
|
-
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 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)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.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{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{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}.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}";
|
|
2516
|
+
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 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)}.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}.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}";
|
|
2112
2517
|
|
|
2113
2518
|
const MgInputText = class {
|
|
2114
2519
|
constructor(hostRef) {
|
|
@@ -2118,12 +2523,12 @@ const MgInputText = class {
|
|
|
2118
2523
|
/************
|
|
2119
2524
|
* Internal *
|
|
2120
2525
|
************/
|
|
2121
|
-
//
|
|
2526
|
+
// Classes
|
|
2122
2527
|
this.classFocus = 'is-focused';
|
|
2123
2528
|
this.classIsInputGroupAppend = 'mg-input--is-input-group-append';
|
|
2124
2529
|
this.classHasIcon = 'mg-input--has-icon';
|
|
2125
|
-
//
|
|
2126
|
-
this.
|
|
2530
|
+
// hasDisplayedError (triggered by blur event)
|
|
2531
|
+
this.hasDisplayedError = false;
|
|
2127
2532
|
/**
|
|
2128
2533
|
* Input name
|
|
2129
2534
|
* If not set the value equals the identifier
|
|
@@ -2172,8 +2577,8 @@ const MgInputText = class {
|
|
|
2172
2577
|
*/
|
|
2173
2578
|
this.handleInput = () => {
|
|
2174
2579
|
this.checkValidity();
|
|
2175
|
-
if (this.
|
|
2176
|
-
this.
|
|
2580
|
+
if (this.hasDisplayedError) {
|
|
2581
|
+
this.setErrorMessage();
|
|
2177
2582
|
}
|
|
2178
2583
|
this.value = this.input.value;
|
|
2179
2584
|
};
|
|
@@ -2204,21 +2609,18 @@ const MgInputText = class {
|
|
|
2204
2609
|
* @returns {void}
|
|
2205
2610
|
*/
|
|
2206
2611
|
this.checkValidity = () => {
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
//Send event
|
|
2213
|
-
this.inputValid.emit(validity);
|
|
2214
|
-
}
|
|
2612
|
+
var _a;
|
|
2613
|
+
this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
|
|
2614
|
+
this.invalid = !this.valid;
|
|
2615
|
+
// We need to send valid event even if it is the same value
|
|
2616
|
+
this.inputValid.emit(this.valid);
|
|
2215
2617
|
};
|
|
2216
2618
|
/**
|
|
2217
|
-
*
|
|
2619
|
+
* Set input error message
|
|
2218
2620
|
*
|
|
2219
2621
|
* @returns {void}
|
|
2220
2622
|
*/
|
|
2221
|
-
this.
|
|
2623
|
+
this.setErrorMessage = () => {
|
|
2222
2624
|
// Set error message
|
|
2223
2625
|
this.errorMessage = undefined;
|
|
2224
2626
|
// Does not match pattern
|
|
@@ -2231,7 +2633,7 @@ const MgInputText = class {
|
|
|
2231
2633
|
}
|
|
2232
2634
|
};
|
|
2233
2635
|
/**
|
|
2234
|
-
* Validate
|
|
2636
|
+
* Validate pattern configuration
|
|
2235
2637
|
*
|
|
2236
2638
|
* @returns {void}
|
|
2237
2639
|
*/
|
|
@@ -2270,6 +2672,16 @@ const MgInputText = class {
|
|
|
2270
2672
|
this.classList.delete(this.classHasIcon);
|
|
2271
2673
|
}
|
|
2272
2674
|
}
|
|
2675
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
2676
|
+
if (this.input !== undefined) {
|
|
2677
|
+
this.input[prop] = newValue;
|
|
2678
|
+
this.checkValidity();
|
|
2679
|
+
if (this.hasDisplayedError) {
|
|
2680
|
+
this.setErrorMessage();
|
|
2681
|
+
this.hasDisplayedError = false;
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2273
2685
|
/**
|
|
2274
2686
|
* Public method to play input focus
|
|
2275
2687
|
*
|
|
@@ -2285,8 +2697,8 @@ const MgInputText = class {
|
|
|
2285
2697
|
*/
|
|
2286
2698
|
async displayError() {
|
|
2287
2699
|
this.checkValidity();
|
|
2288
|
-
this.
|
|
2289
|
-
this.
|
|
2700
|
+
this.setErrorMessage();
|
|
2701
|
+
this.hasDisplayedError = this.invalid;
|
|
2290
2702
|
}
|
|
2291
2703
|
/*************
|
|
2292
2704
|
* Lifecycle *
|
|
@@ -2321,17 +2733,23 @@ const MgInputText = class {
|
|
|
2321
2733
|
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
2322
2734
|
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
2323
2735
|
: 0).toString(),
|
|
2324
|
-
} }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type, class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el =>
|
|
2736
|
+
} }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type, class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
|
|
2737
|
+
if (el !== null)
|
|
2738
|
+
this.input = el;
|
|
2739
|
+
} }), this.displayCharacterLeft && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), h("slot", { name: "append-input" })));
|
|
2325
2740
|
}
|
|
2326
2741
|
get element() { return getElement(this); }
|
|
2327
2742
|
static get watchers() { return {
|
|
2328
2743
|
"value": ["handleValue"],
|
|
2329
|
-
"icon": ["validateIcon"]
|
|
2744
|
+
"icon": ["validateIcon"],
|
|
2745
|
+
"required": ["handleValidityChange"],
|
|
2746
|
+
"readonly": ["handleValidityChange"],
|
|
2747
|
+
"disabled": ["handleValidityChange"]
|
|
2330
2748
|
}; }
|
|
2331
2749
|
};
|
|
2332
2750
|
MgInputText.style = mgInputTextCss;
|
|
2333
2751
|
|
|
2334
|
-
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 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)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.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{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{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}.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}}";
|
|
2752
|
+
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 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)}.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}.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}}";
|
|
2335
2753
|
|
|
2336
2754
|
const MgInputTextarea = class {
|
|
2337
2755
|
constructor(hostRef) {
|
|
@@ -2341,11 +2759,11 @@ const MgInputTextarea = class {
|
|
|
2341
2759
|
/************
|
|
2342
2760
|
* Internal *
|
|
2343
2761
|
************/
|
|
2344
|
-
//
|
|
2762
|
+
// Classes
|
|
2345
2763
|
this.classFocus = 'is-focused';
|
|
2346
2764
|
this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
|
|
2347
|
-
//
|
|
2348
|
-
this.
|
|
2765
|
+
// hasDisplayedError (triggered by blur event)
|
|
2766
|
+
this.hasDisplayedError = false;
|
|
2349
2767
|
/**
|
|
2350
2768
|
* Input name
|
|
2351
2769
|
* If not set the value equals the identifier
|
|
@@ -2395,9 +2813,9 @@ const MgInputTextarea = class {
|
|
|
2395
2813
|
* Handle input event
|
|
2396
2814
|
*/
|
|
2397
2815
|
this.handleInput = () => {
|
|
2398
|
-
if (this.
|
|
2816
|
+
if (this.hasDisplayedError) {
|
|
2399
2817
|
this.checkValidity();
|
|
2400
|
-
this.
|
|
2818
|
+
this.setErrorMessage();
|
|
2401
2819
|
}
|
|
2402
2820
|
this.value = this.input.value;
|
|
2403
2821
|
};
|
|
@@ -2429,19 +2847,16 @@ const MgInputTextarea = class {
|
|
|
2429
2847
|
* Check if input is valid
|
|
2430
2848
|
*/
|
|
2431
2849
|
this.checkValidity = () => {
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
//Send event
|
|
2438
|
-
this.inputValid.emit(validity);
|
|
2439
|
-
}
|
|
2850
|
+
var _a;
|
|
2851
|
+
this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined && this.input.checkValidity() && this.getPatternValidity());
|
|
2852
|
+
this.invalid = !this.valid;
|
|
2853
|
+
// We need to send valid event even if it is the same value
|
|
2854
|
+
this.inputValid.emit(this.valid);
|
|
2440
2855
|
};
|
|
2441
2856
|
/**
|
|
2442
|
-
*
|
|
2857
|
+
* Set input error message
|
|
2443
2858
|
*/
|
|
2444
|
-
this.
|
|
2859
|
+
this.setErrorMessage = () => {
|
|
2445
2860
|
// Set error message
|
|
2446
2861
|
this.errorMessage = undefined;
|
|
2447
2862
|
// Does not match pattern
|
|
@@ -2469,6 +2884,16 @@ const MgInputTextarea = class {
|
|
|
2469
2884
|
this.checkValidity();
|
|
2470
2885
|
this.valueChange.emit(newValue);
|
|
2471
2886
|
}
|
|
2887
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
2888
|
+
if (this.input !== undefined) {
|
|
2889
|
+
this.input[prop] = newValue;
|
|
2890
|
+
this.checkValidity();
|
|
2891
|
+
if (this.hasDisplayedError) {
|
|
2892
|
+
this.setErrorMessage();
|
|
2893
|
+
this.hasDisplayedError = false;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2472
2897
|
validateDisplayCharacterLeft(newValue) {
|
|
2473
2898
|
if (newValue) {
|
|
2474
2899
|
this.classList.add(this.classHasDisplayCharacterLeft);
|
|
@@ -2484,8 +2909,8 @@ const MgInputTextarea = class {
|
|
|
2484
2909
|
*/
|
|
2485
2910
|
async displayError() {
|
|
2486
2911
|
this.checkValidity();
|
|
2487
|
-
this.
|
|
2488
|
-
this.
|
|
2912
|
+
this.setErrorMessage();
|
|
2913
|
+
this.hasDisplayedError = this.invalid;
|
|
2489
2914
|
}
|
|
2490
2915
|
/*************
|
|
2491
2916
|
* Lifecycle *
|
|
@@ -2520,11 +2945,17 @@ const MgInputTextarea = class {
|
|
|
2520
2945
|
'mg-input__box--resizable': this.resizable === 'both',
|
|
2521
2946
|
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
2522
2947
|
'mg-input__box--resizable-vertical': this.resizable === 'vertical',
|
|
2523
|
-
}, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el =>
|
|
2948
|
+
}, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
|
|
2949
|
+
if (el !== null)
|
|
2950
|
+
this.input = el;
|
|
2951
|
+
} }), this.displayCharacterLeft && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
|
|
2524
2952
|
}
|
|
2525
2953
|
get element() { return getElement(this); }
|
|
2526
2954
|
static get watchers() { return {
|
|
2527
2955
|
"value": ["handleValue"],
|
|
2956
|
+
"required": ["handleValidityChange"],
|
|
2957
|
+
"readonly": ["handleValidityChange"],
|
|
2958
|
+
"disabled": ["handleValidityChange"],
|
|
2528
2959
|
"displayCharacterLeft": ["validateDisplayCharacterLeft"]
|
|
2529
2960
|
}; }
|
|
2530
2961
|
};
|
|
@@ -2597,7 +3028,7 @@ const MgInputToggle = class {
|
|
|
2597
3028
|
/************
|
|
2598
3029
|
* Internal *
|
|
2599
3030
|
************/
|
|
2600
|
-
//
|
|
3031
|
+
// Classes
|
|
2601
3032
|
this.classReadonly = 'mg-input--toggle-readonly';
|
|
2602
3033
|
this.classDisabled = 'mg-input--toggle-disabled';
|
|
2603
3034
|
this.classIsActive = 'mg-input--toggle-is-active';
|
|
@@ -2795,7 +3226,7 @@ const MgMessage = class {
|
|
|
2795
3226
|
/************
|
|
2796
3227
|
* Internal *
|
|
2797
3228
|
************/
|
|
2798
|
-
//
|
|
3229
|
+
// Classes
|
|
2799
3230
|
this.classHide = 'mg-message--hide';
|
|
2800
3231
|
// IDs
|
|
2801
3232
|
this.closeButtonId = '';
|
|
@@ -2934,6 +3365,170 @@ const MgMessage = class {
|
|
|
2934
3365
|
};
|
|
2935
3366
|
MgMessage.style = mgMessageCss;
|
|
2936
3367
|
|
|
3368
|
+
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}";
|
|
3369
|
+
|
|
3370
|
+
const MgModal = class {
|
|
3371
|
+
constructor(hostRef) {
|
|
3372
|
+
registerInstance(this, hostRef);
|
|
3373
|
+
this.componentShow = createEvent(this, "component-show", 7);
|
|
3374
|
+
this.componentHide = createEvent(this, "component-hide", 7);
|
|
3375
|
+
// Classes
|
|
3376
|
+
this.classHide = 'mg-modal--hide';
|
|
3377
|
+
// IDs
|
|
3378
|
+
this.closeButtonId = '';
|
|
3379
|
+
this.titleId = '';
|
|
3380
|
+
/**
|
|
3381
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
3382
|
+
* If not set, it will be created.
|
|
3383
|
+
*/
|
|
3384
|
+
this.identifier = createID('mg-modal');
|
|
3385
|
+
/**
|
|
3386
|
+
* Define if modal has a cross button
|
|
3387
|
+
*/
|
|
3388
|
+
this.closeButton = false;
|
|
3389
|
+
/**
|
|
3390
|
+
* Define if modal is hidden
|
|
3391
|
+
*/
|
|
3392
|
+
this.hide = false;
|
|
3393
|
+
/**
|
|
3394
|
+
* Define if component is using actions slot
|
|
3395
|
+
*/
|
|
3396
|
+
this.hasActions = false;
|
|
3397
|
+
/**
|
|
3398
|
+
* Define if component is using content slot
|
|
3399
|
+
*/
|
|
3400
|
+
this.hasContent = false;
|
|
3401
|
+
/**
|
|
3402
|
+
* Component classes
|
|
3403
|
+
*/
|
|
3404
|
+
this.classList = new ClassList(['mg-modal']);
|
|
3405
|
+
this.setFocus = () => {
|
|
3406
|
+
// Get all focusable elements
|
|
3407
|
+
this.modalFocusableElements = Array.from(this.element.querySelectorAll(focusableElements)).reduce((acc, focusableElement) => {
|
|
3408
|
+
acc.push(focusableElement.shadowRoot !== null ? focusableElement.shadowRoot.querySelector(focusableElements) || focusableElement : focusableElement);
|
|
3409
|
+
return acc;
|
|
3410
|
+
}, []);
|
|
3411
|
+
// When close button is enabled it's the first focusable element.
|
|
3412
|
+
if (this.closeButton) {
|
|
3413
|
+
this.modalFocusableElements.unshift(this.element.shadowRoot.querySelector(`.mg-modal__close-button mg-button`));
|
|
3414
|
+
}
|
|
3415
|
+
// It at least one
|
|
3416
|
+
if (this.modalFocusableElements.length >= 1) {
|
|
3417
|
+
// Set focus on first element
|
|
3418
|
+
this.modalFocusableElements[0].focus();
|
|
3419
|
+
// Add event listener on last element
|
|
3420
|
+
const lastFocusableElement = this.modalFocusableElements[this.modalFocusableElements.length - 1];
|
|
3421
|
+
lastFocusableElement.addEventListener('keydown', event => {
|
|
3422
|
+
if (event.key === 'Tab' && !event.shiftKey) {
|
|
3423
|
+
event.preventDefault();
|
|
3424
|
+
this.modalFocusableElements[0].focus();
|
|
3425
|
+
}
|
|
3426
|
+
});
|
|
3427
|
+
// Add event listener on first element (case shift + tab)
|
|
3428
|
+
this.modalFocusableElements[0].addEventListener('keydown', event => {
|
|
3429
|
+
if (event.key === 'Tab' && event.shiftKey) {
|
|
3430
|
+
event.preventDefault();
|
|
3431
|
+
lastFocusableElement.focus();
|
|
3432
|
+
}
|
|
3433
|
+
});
|
|
3434
|
+
}
|
|
3435
|
+
};
|
|
3436
|
+
/*************
|
|
3437
|
+
* Handlers *
|
|
3438
|
+
*************/
|
|
3439
|
+
/**
|
|
3440
|
+
* Handle close button
|
|
3441
|
+
*
|
|
3442
|
+
* @returns {void}
|
|
3443
|
+
*/
|
|
3444
|
+
this.handleClose = () => {
|
|
3445
|
+
this.hide = true;
|
|
3446
|
+
};
|
|
3447
|
+
}
|
|
3448
|
+
validateModalTitle(newValue) {
|
|
3449
|
+
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
3450
|
+
throw new Error('<mg-modal> prop "modalTitle" is required.');
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
validateHide(newValue) {
|
|
3454
|
+
if (newValue) {
|
|
3455
|
+
this.componentHide.emit();
|
|
3456
|
+
this.classList.add(this.classHide);
|
|
3457
|
+
document.body.style.overflow = this.bodyOverflow;
|
|
3458
|
+
}
|
|
3459
|
+
else {
|
|
3460
|
+
this.componentShow.emit();
|
|
3461
|
+
this.classList.delete(this.classHide);
|
|
3462
|
+
document.body.style.overflow = 'hidden';
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
/**
|
|
3466
|
+
* Handle 'escape' key down
|
|
3467
|
+
*
|
|
3468
|
+
* @param {KeyboardEvent} event keydown event
|
|
3469
|
+
* @returns {void}
|
|
3470
|
+
*/
|
|
3471
|
+
handleKeyDown(event) {
|
|
3472
|
+
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
3473
|
+
if (this.closeButton && event.key === 'Escape') {
|
|
3474
|
+
this.hide = true;
|
|
3475
|
+
}
|
|
3476
|
+
}
|
|
3477
|
+
/*************
|
|
3478
|
+
* Lifecycle *
|
|
3479
|
+
*************/
|
|
3480
|
+
/**
|
|
3481
|
+
* Check if component props are well configured on init
|
|
3482
|
+
*
|
|
3483
|
+
* @returns {void}
|
|
3484
|
+
*/
|
|
3485
|
+
componentWillLoad() {
|
|
3486
|
+
// Store body overflow
|
|
3487
|
+
this.bodyOverflow = document.body.style.overflow;
|
|
3488
|
+
// Get locales
|
|
3489
|
+
this.messages = initLocales(this.element).messages;
|
|
3490
|
+
// Validate
|
|
3491
|
+
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
3492
|
+
this.hasContent = this.element.querySelector('[slot="content"]') !== null;
|
|
3493
|
+
if (this.closeButton) {
|
|
3494
|
+
this.closeButtonId = `${this.identifier}-close-button`;
|
|
3495
|
+
}
|
|
3496
|
+
this.titleId = `${this.identifier}-title`;
|
|
3497
|
+
this.validateModalTitle(this.modalTitle);
|
|
3498
|
+
this.validateHide(this.hide);
|
|
3499
|
+
}
|
|
3500
|
+
/**
|
|
3501
|
+
* Add observer on component to set focus when displayed
|
|
3502
|
+
*
|
|
3503
|
+
* @returns {void}
|
|
3504
|
+
*/
|
|
3505
|
+
componentDidLoad() {
|
|
3506
|
+
new MutationObserver(mutationList => {
|
|
3507
|
+
if (mutationList.some(mutation => mutation.attributeName === 'aria-hidden' && mutation.target.ariaHidden === null)) {
|
|
3508
|
+
this.setFocus();
|
|
3509
|
+
}
|
|
3510
|
+
}).observe(this.element.shadowRoot.getElementById(this.identifier), { attributes: true });
|
|
3511
|
+
// Set focus if display on load
|
|
3512
|
+
if (!this.hide) {
|
|
3513
|
+
this.setFocus();
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
/**
|
|
3517
|
+
* Render
|
|
3518
|
+
*
|
|
3519
|
+
* @returns {HTMLElement} HTML Element
|
|
3520
|
+
*/
|
|
3521
|
+
render() {
|
|
3522
|
+
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" }))))));
|
|
3523
|
+
}
|
|
3524
|
+
get element() { return getElement(this); }
|
|
3525
|
+
static get watchers() { return {
|
|
3526
|
+
"modalTitle": ["validateModalTitle"],
|
|
3527
|
+
"hide": ["validateHide"]
|
|
3528
|
+
}; }
|
|
3529
|
+
};
|
|
3530
|
+
MgModal.style = mgModalCss;
|
|
3531
|
+
|
|
2937
3532
|
var NavigationAction;
|
|
2938
3533
|
(function (NavigationAction) {
|
|
2939
3534
|
NavigationAction["NEXT"] = "next";
|
|
@@ -3065,7 +3660,7 @@ const MgPagination = class {
|
|
|
3065
3660
|
};
|
|
3066
3661
|
MgPagination.style = mgPaginationCss;
|
|
3067
3662
|
|
|
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-
|
|
3663
|
+
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
3664
|
|
|
3070
3665
|
const MgPanel = class {
|
|
3071
3666
|
constructor(hostRef) {
|
|
@@ -5036,7 +5631,7 @@ var createPopper = /*#__PURE__*/popperGenerator({
|
|
|
5036
5631
|
defaultModifiers: defaultModifiers
|
|
5037
5632
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
5038
5633
|
|
|
5039
|
-
const mgPopoverCss = "mg-popover{display:contents}mg-popover::slotted(*){display:inline-block}.mg-popover{display:none;padding:1.5rem;z-index:
|
|
5634
|
+
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
5635
|
|
|
5041
5636
|
const MgPopover = class {
|
|
5042
5637
|
constructor(hostRef) {
|
|
@@ -5161,6 +5756,7 @@ const MgPopover = class {
|
|
|
5161
5756
|
// Create popperjs popover
|
|
5162
5757
|
this.popper = createPopper(interactiveElement, this.popover, {
|
|
5163
5758
|
placement: this.placement,
|
|
5759
|
+
strategy: 'fixed',
|
|
5164
5760
|
modifiers: [
|
|
5165
5761
|
{
|
|
5166
5762
|
name: 'offset',
|
|
@@ -5188,7 +5784,7 @@ const MgPopover = class {
|
|
|
5188
5784
|
* @returns {HTMLElement} HTML Element
|
|
5189
5785
|
*/
|
|
5190
5786
|
render() {
|
|
5191
|
-
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: "mg-popover" },
|
|
5787
|
+
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
5788
|
}
|
|
5193
5789
|
get element() { return getElement(this); }
|
|
5194
5790
|
static get watchers() { return {
|
|
@@ -5425,7 +6021,7 @@ const MgTag = class {
|
|
|
5425
6021
|
/************
|
|
5426
6022
|
* Internal *
|
|
5427
6023
|
************/
|
|
5428
|
-
//
|
|
6024
|
+
// Classes
|
|
5429
6025
|
this.classOutline = `mg-tag--outline`;
|
|
5430
6026
|
/**************
|
|
5431
6027
|
* Decorators *
|
|
@@ -5483,9 +6079,6 @@ const MgTag = class {
|
|
|
5483
6079
|
};
|
|
5484
6080
|
MgTag.style = mgTagCss;
|
|
5485
6081
|
|
|
5486
|
-
/**
|
|
5487
|
-
* List of all possibles placements
|
|
5488
|
-
*/
|
|
5489
6082
|
var Guard;
|
|
5490
6083
|
(function (Guard) {
|
|
5491
6084
|
Guard["FOCUS"] = "focus";
|
|
@@ -5493,7 +6086,7 @@ var Guard;
|
|
|
5493
6086
|
Guard["HOVER_TOOLTIPED_ELEMENT"] = "hoverTooltipedGuard";
|
|
5494
6087
|
})(Guard || (Guard = {}));
|
|
5495
6088
|
|
|
5496
|
-
const mgTooltipCss = ":host{display:inline-block}.mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:
|
|
6089
|
+
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
6090
|
|
|
5498
6091
|
const MgTooltip = class {
|
|
5499
6092
|
constructor(hostRef) {
|
|
@@ -5630,6 +6223,7 @@ const MgTooltip = class {
|
|
|
5630
6223
|
// Create popperjs tooltip
|
|
5631
6224
|
this.popper = createPopper(tooltipedElement, this.tooltip, {
|
|
5632
6225
|
placement: this.placement,
|
|
6226
|
+
strategy: 'fixed',
|
|
5633
6227
|
modifiers: [
|
|
5634
6228
|
{
|
|
5635
6229
|
name: 'offset',
|
|
@@ -5685,4 +6279,4 @@ const MgTooltip = class {
|
|
|
5685
6279
|
};
|
|
5686
6280
|
MgTooltip.style = mgTooltipCss;
|
|
5687
6281
|
|
|
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 };
|
|
6282
|
+
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 };
|