@mgdis/mg-components 6.17.0 → 6.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-DCZEYvlH.js → index-Bp6wZzau.js} +5 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_37.cjs.entry.js +438 -212
- package/dist/cjs/mg-alert.cjs.entry.js +2 -2
- package/dist/cjs/mg-components.cjs.js +2 -2
- package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
- package/dist/cjs/mg-input-combobox.cjs.entry.js +93 -80
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +35 -26
- package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-D7jmj_lh.js} +7 -0
- package/dist/cjs/mg-loader.cjs.entry.js +2 -2
- package/dist/cjs/mg-progress.cjs.entry.js +2 -2
- package/dist/collection/assets/icons/index.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +5 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +178 -18
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +36 -16
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +98 -78
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +41 -22
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +32 -12
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +30 -12
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +31 -12
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +41 -25
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +31 -12
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +60 -40
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +35 -33
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +36 -11
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +1 -1
- package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +5 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -2
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
- package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +404 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +13 -4
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +40 -9
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/components/mg-action-more.js +1 -1
- package/dist/components/mg-alert.js +1 -1
- package/dist/components/mg-details.js +1 -1
- package/dist/components/mg-fieldset.d.ts +11 -0
- package/dist/components/mg-fieldset.js +209 -0
- package/dist/components/mg-form.js +4 -3
- package/dist/components/mg-icon2.js +1 -1
- package/dist/components/mg-illustrated-message.js +2 -2
- package/dist/components/mg-input-checkbox-paginated2.js +1 -1
- package/dist/components/mg-input-checkbox.js +29 -16
- package/dist/components/mg-input-combobox.js +92 -79
- package/dist/components/mg-input-date.js +34 -22
- package/dist/components/mg-input-numeric.js +25 -12
- package/dist/components/mg-input-password.js +23 -12
- package/dist/components/mg-input-radio.js +23 -11
- package/dist/components/mg-input-rich-text-editor.js +33 -24
- package/dist/components/mg-input-select2.js +24 -12
- package/dist/components/mg-input-text2.js +51 -39
- package/dist/components/mg-input-textarea.js +28 -33
- package/dist/components/mg-input-toggle.js +35 -10
- package/dist/components/mg-input2.js +119 -19
- package/dist/components/mg-item-more2.js +5 -1
- package/dist/components/mg-loader2.js +1 -1
- package/dist/components/mg-message2.js +2 -2
- package/dist/components/mg-modal.js +3 -3
- package/dist/components/mg-panel.js +37 -8
- package/dist/components/mg-popover-content2.js +2 -2
- package/dist/components/mg-popover2.js +2 -2
- package/dist/components/mg-progress.js +1 -1
- package/dist/components/mg-skip-links.js +1 -1
- package/dist/components/mg-tabs2.js +1 -1
- package/dist/esm/{index-T6kOJXP1.js → index-BluNKQ3L.js} +5 -1
- package/dist/esm/{index-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_37.entry.js +439 -213
- package/dist/esm/mg-alert.entry.js +3 -3
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-fieldset.entry.js +139 -0
- package/dist/esm/mg-input-combobox.entry.js +94 -81
- package/dist/esm/mg-input-rich-text-editor.entry.js +36 -27
- package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-DDnrE1hD.js} +6 -1
- package/dist/esm/mg-loader.entry.js +3 -3
- package/dist/esm/mg-progress.entry.js +3 -3
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-016bd291.entry.js +1 -0
- package/dist/mg-components/{p-397bf67b.entry.js → p-186a6139.entry.js} +1 -1
- package/dist/mg-components/p-66a1cb83.entry.js +1 -0
- package/dist/mg-components/p-6efd819f.entry.js +1 -0
- package/dist/mg-components/{p-c5da335e.entry.js → p-916dfb6d.entry.js} +1 -1
- package/dist/mg-components/p-BluNKQ3L.js +2 -0
- package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
- package/dist/mg-components/p-DDnrE1hD.js +1 -0
- package/dist/mg-components/{p-0e6b40d6.entry.js → p-d2c72f09.entry.js} +1 -1
- package/dist/mg-components/{p-5dc3a1fb.entry.js → p-d5a276eb.entry.js} +1 -1
- package/dist/types/assets/icons/index.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +32 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +8 -7
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -7
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -8
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -2
- package/dist/types/components/molecules/mg-fieldset/mg-fieldset.d.ts +105 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +8 -1
- package/dist/types/components.d.ts +168 -18
- package/ide/intellij/web-types.json +289 -22
- package/ide/vscode/css-custom-data.json +7 -3
- package/ide/vscode/html-custom-data.json +300 -8
- package/package.json +18 -18
- package/dist/mg-components/p-8a69175b.entry.js +0 -1
- package/dist/mg-components/p-CNgv8hc5.js +0 -1
- package/dist/mg-components/p-T6kOJXP1.js +0 -2
- package/dist/mg-components/p-d84d87ea.entry.js +0 -1
|
@@ -9,7 +9,7 @@ import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
|
|
|
9
9
|
|
|
10
10
|
const DEFAULT_MAX_DATE = '9999-12-31';
|
|
11
11
|
|
|
12
|
-
const mgInputDateCss = ".mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-
|
|
12
|
+
const mgInputDateCss = ".mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}";
|
|
13
13
|
|
|
14
14
|
const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends HTMLElement {
|
|
15
15
|
constructor(registerHost) {
|
|
@@ -22,6 +22,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
|
|
|
22
22
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
23
23
|
// hasDisplayedError (triggered by blur event)
|
|
24
24
|
this.hasDisplayedError = false;
|
|
25
|
+
this.customErrorMessage = { lock: false };
|
|
25
26
|
/**
|
|
26
27
|
* Input name
|
|
27
28
|
* If not set the value equals the identifier
|
|
@@ -134,39 +135,41 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
|
|
|
134
135
|
*/
|
|
135
136
|
this.getInputError = () => {
|
|
136
137
|
var _a;
|
|
138
|
+
let error;
|
|
137
139
|
// bad input or pattern
|
|
138
140
|
if (this.input.validity.badInput || (this.value && !this.isValidPattern(this.value))) {
|
|
139
|
-
|
|
141
|
+
error = 'badInput';
|
|
140
142
|
}
|
|
141
143
|
// required
|
|
142
|
-
if (this.input.validity.valueMissing) {
|
|
143
|
-
|
|
144
|
+
else if (this.input.validity.valueMissing) {
|
|
145
|
+
error = 'required';
|
|
144
146
|
}
|
|
145
147
|
// min & max
|
|
146
|
-
if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
|
|
147
|
-
|
|
148
|
+
else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
|
|
149
|
+
error = 'minMax';
|
|
148
150
|
}
|
|
149
151
|
// min
|
|
150
|
-
if (this.input.validity.rangeUnderflow) {
|
|
151
|
-
|
|
152
|
+
else if (this.input.validity.rangeUnderflow) {
|
|
153
|
+
error = 'min';
|
|
152
154
|
}
|
|
153
155
|
// max
|
|
154
|
-
if (this.input.validity.rangeOverflow) {
|
|
155
|
-
|
|
156
|
+
else if (this.input.validity.rangeOverflow) {
|
|
157
|
+
error = 'max';
|
|
156
158
|
}
|
|
157
|
-
return
|
|
159
|
+
return error;
|
|
158
160
|
};
|
|
159
161
|
/**
|
|
160
162
|
* Check input errors
|
|
161
|
-
* @param
|
|
163
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
162
164
|
*/
|
|
163
|
-
this.setErrorMessage = (
|
|
165
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
164
166
|
// Set error message
|
|
165
167
|
this.errorMessage = undefined;
|
|
166
168
|
if (!this.valid) {
|
|
167
169
|
const inputError = this.getInputError();
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
171
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
172
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
170
173
|
}
|
|
171
174
|
// required
|
|
172
175
|
else if (inputError === 'required') {
|
|
@@ -278,17 +281,22 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
|
|
|
278
281
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
279
282
|
* @param valid - value indicating the validity
|
|
280
283
|
* @param errorMessage - the error message to display
|
|
284
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
281
285
|
*/
|
|
282
|
-
async setError(valid, errorMessage) {
|
|
286
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
283
287
|
if (typeof valid !== 'boolean') {
|
|
284
288
|
throw new Error('<mg-input-date> method "setError()" param "valid" must be a boolean.');
|
|
285
289
|
}
|
|
286
|
-
else if (!isValidString(errorMessage)) {
|
|
290
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
287
291
|
throw new Error('<mg-input-date> method "setError()" param "errorMessage" must be a string.');
|
|
288
292
|
}
|
|
289
293
|
else {
|
|
294
|
+
this.customErrorMessage = {
|
|
295
|
+
lock: valid ? false : errorMessageLock,
|
|
296
|
+
message: valid ? undefined : errorMessage,
|
|
297
|
+
};
|
|
290
298
|
this.setValidity(valid);
|
|
291
|
-
this.setErrorMessage(
|
|
299
|
+
this.setErrorMessage(true);
|
|
292
300
|
this.hasDisplayedError = this.invalid;
|
|
293
301
|
}
|
|
294
302
|
}
|
|
@@ -306,6 +314,8 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
|
|
|
306
314
|
// - Keep everything in sync both inside and outside the component
|
|
307
315
|
return new Promise(resolve => {
|
|
308
316
|
requestAnimationFrame(() => {
|
|
317
|
+
// unlock validity check by reseting customErrorMessage
|
|
318
|
+
this.customErrorMessage = { lock: false };
|
|
309
319
|
this.checkValidity();
|
|
310
320
|
this.errorMessage = undefined;
|
|
311
321
|
this.hasDisplayedError = false;
|
|
@@ -319,11 +329,13 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
|
|
|
319
329
|
* @param newValue - valid new value
|
|
320
330
|
*/
|
|
321
331
|
setValidity(newValue) {
|
|
322
|
-
const
|
|
323
|
-
this.
|
|
332
|
+
const oldValue = this.valid;
|
|
333
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
334
|
+
this.valid = newValue;
|
|
335
|
+
}
|
|
324
336
|
this.invalid = !this.valid;
|
|
325
337
|
// We need to send valid event even if it is the same value
|
|
326
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
338
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
327
339
|
this.inputValid.emit(this.valid);
|
|
328
340
|
}
|
|
329
341
|
/*************
|
|
@@ -359,7 +371,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
|
|
|
359
371
|
* @returns HTML Element
|
|
360
372
|
*/
|
|
361
373
|
render() {
|
|
362
|
-
return (h("mg-input", { key: '
|
|
374
|
+
return (h("mg-input", { key: '1428f0f9f11d829ec8d3ed507c8690d63839ff17', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === null ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly ? (this.value && h("b", { class: "mg-c-input__readonly-value" }, localeDate(this.value, this.locale))) : (h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
|
|
363
375
|
if (el !== null)
|
|
364
376
|
this.input = el;
|
|
365
377
|
} }))));
|
|
@@ -13,7 +13,7 @@ import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
|
|
|
13
13
|
const types = ['decimal', 'integer'];
|
|
14
14
|
const formats = ['none', 'number', 'currency', 'percent', 'unit'];
|
|
15
15
|
|
|
16
|
-
const mgInputNumericCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-
|
|
16
|
+
const mgInputNumericCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-full .mg-c-input__input-group-container{width:100%;flex-grow:1}.mg-c-input.mg-c-input--width-2.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-4.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-16.mg-c-input--display-character-left .mg-c-input__input-group-container{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input .mg-c-input__box{width:auto;text-align:var(--mg-c-input-text-align, right)}";
|
|
17
17
|
|
|
18
18
|
const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class MgInputNumeric extends HTMLElement {
|
|
19
19
|
constructor(registerHost) {
|
|
@@ -26,6 +26,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class MgInputNumeric e
|
|
|
26
26
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
27
27
|
// hasDisplayedError (triggered by blur event)
|
|
28
28
|
this.hasDisplayedError = false;
|
|
29
|
+
this.customErrorMessage = { lock: false };
|
|
29
30
|
/**
|
|
30
31
|
* Input name
|
|
31
32
|
* If not set the value equals the identifier
|
|
@@ -131,19 +132,22 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class MgInputNumeric e
|
|
|
131
132
|
this.formatErrorValue = (value) => localeNumber(value, this.locale, !Number.isInteger(value) && this.type === 'decimal' ? this.decimalLength : 0);
|
|
132
133
|
/**
|
|
133
134
|
* Set input error message
|
|
134
|
-
* @param
|
|
135
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
135
136
|
*/
|
|
136
|
-
this.setErrorMessage = (
|
|
137
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
137
138
|
// Set error message
|
|
138
139
|
this.errorMessage = undefined;
|
|
139
140
|
if (!this.valid) {
|
|
140
141
|
const inputError = this.getInputError();
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
143
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
144
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
143
145
|
}
|
|
146
|
+
// required
|
|
144
147
|
else if (inputError === 'required') {
|
|
145
148
|
this.errorMessage = this.messages.errors[inputError];
|
|
146
149
|
}
|
|
150
|
+
// min/max
|
|
147
151
|
else {
|
|
148
152
|
const formattedMin = this.formatErrorValue(this.min);
|
|
149
153
|
const formattedMax = this.formatErrorValue(this.max);
|
|
@@ -345,17 +349,22 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class MgInputNumeric e
|
|
|
345
349
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
346
350
|
* @param valid - value indicating the validity
|
|
347
351
|
* @param errorMessage - the error message to display
|
|
352
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
348
353
|
*/
|
|
349
|
-
async setError(valid, errorMessage) {
|
|
354
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
350
355
|
if (typeof valid !== 'boolean') {
|
|
351
356
|
throw new Error('<mg-input-numeric> method "setError()" param "valid" must be a boolean.');
|
|
352
357
|
}
|
|
353
|
-
else if (!isValidString(errorMessage)) {
|
|
358
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
354
359
|
throw new Error('<mg-input-numeric> method "setError()" param "errorMessage" must be a string.');
|
|
355
360
|
}
|
|
356
361
|
else {
|
|
362
|
+
this.customErrorMessage = {
|
|
363
|
+
lock: valid ? false : errorMessageLock,
|
|
364
|
+
message: valid ? undefined : errorMessage,
|
|
365
|
+
};
|
|
357
366
|
this.setValidity(valid);
|
|
358
|
-
this.setErrorMessage(
|
|
367
|
+
this.setErrorMessage(true);
|
|
359
368
|
this.hasDisplayedError = this.invalid;
|
|
360
369
|
}
|
|
361
370
|
}
|
|
@@ -373,6 +382,8 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class MgInputNumeric e
|
|
|
373
382
|
// - Keep everything in sync both inside and outside the component
|
|
374
383
|
return new Promise(resolve => {
|
|
375
384
|
requestAnimationFrame(() => {
|
|
385
|
+
// unlock validity check by reseting customErrorMessage
|
|
386
|
+
this.customErrorMessage = { lock: false };
|
|
376
387
|
this.checkValidity();
|
|
377
388
|
this.errorMessage = undefined;
|
|
378
389
|
this.hasDisplayedError = false;
|
|
@@ -386,11 +397,13 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class MgInputNumeric e
|
|
|
386
397
|
* @param newValue - valid new value
|
|
387
398
|
*/
|
|
388
399
|
setValidity(newValue) {
|
|
389
|
-
const
|
|
390
|
-
this.
|
|
400
|
+
const oldValue = this.valid;
|
|
401
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
402
|
+
this.valid = newValue;
|
|
403
|
+
}
|
|
391
404
|
this.invalid = !this.valid;
|
|
392
405
|
// We need to send valid event even if it is the same value
|
|
393
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
406
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
394
407
|
this.inputValid.emit(this.valid);
|
|
395
408
|
}
|
|
396
409
|
/**
|
|
@@ -462,7 +475,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class MgInputNumeric e
|
|
|
462
475
|
* @returns HTML Element
|
|
463
476
|
*/
|
|
464
477
|
render() {
|
|
465
|
-
return (h("mg-input", { key: '
|
|
478
|
+
return (h("mg-input", { key: 'c47f7c310587fc3bb4e7d5ffd07854a2297958df', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly
|
|
466
479
|
? this.readonlyValue && this.renderReadonly()
|
|
467
480
|
: [
|
|
468
481
|
h("input", { key: "input", type: "text", class: "mg-c-input__box mg-c-input__box--width", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
@@ -8,7 +8,7 @@ import { d as defineCustomElement$4 } from './mg-input-title2.js';
|
|
|
8
8
|
import { d as defineCustomElement$3 } from './mg-tooltip2.js';
|
|
9
9
|
import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
|
|
10
10
|
|
|
11
|
-
const mgInputPasswordCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-
|
|
11
|
+
const mgInputPasswordCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-full .mg-c-input__input-group-container{width:100%;flex-grow:1}.mg-c-input.mg-c-input--width-2.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-4.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-16.mg-c-input--display-character-left .mg-c-input__input-group-container{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input.mg-c-input--password .mg-c-input__input-icon{color:var(--mg-b-color-dark)}.mg-c-input.mg-c-input--password .mg-c-input__input-group{position:relative;flex-grow:1}.mg-c-input.mg-c-input--password .mg-c-input__append-button{position:absolute;right:0}.mg-c-input.mg-c-input--password .mg-c-input__box{padding-right:calc(var(--mg-b-size-min-height) + var(--mg-b-size-8))}.mg-c-input.mg-c-input--password .mg-c-input__box::-ms-reveal{display:none}";
|
|
12
12
|
|
|
13
13
|
const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class MgInputPassword extends HTMLElement {
|
|
14
14
|
constructor(registerHost) {
|
|
@@ -21,6 +21,7 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class MgInputPassword
|
|
|
21
21
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
22
22
|
// hasDisplayedError (triggered by blur event)
|
|
23
23
|
this.hasDisplayedError = false;
|
|
24
|
+
this.customErrorMessage = { lock: false };
|
|
24
25
|
/**
|
|
25
26
|
* Input name
|
|
26
27
|
* If not set the value equals the identifier
|
|
@@ -96,14 +97,15 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class MgInputPassword
|
|
|
96
97
|
};
|
|
97
98
|
/**
|
|
98
99
|
* Set input error message
|
|
99
|
-
* @param
|
|
100
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
100
101
|
*/
|
|
101
|
-
this.setErrorMessage = (
|
|
102
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
102
103
|
// Set error message
|
|
103
104
|
this.errorMessage = undefined;
|
|
104
105
|
if (!this.valid) {
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
107
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
108
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
107
109
|
}
|
|
108
110
|
// required
|
|
109
111
|
else if (this.input.validity.valueMissing) {
|
|
@@ -179,17 +181,22 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class MgInputPassword
|
|
|
179
181
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
180
182
|
* @param valid - value indicating the validity
|
|
181
183
|
* @param errorMessage - the error message to display
|
|
184
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
182
185
|
*/
|
|
183
|
-
async setError(valid, errorMessage) {
|
|
186
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
184
187
|
if (typeof valid !== 'boolean') {
|
|
185
188
|
throw new Error('<mg-input-password> method "setError()" param "valid" must be a boolean.');
|
|
186
189
|
}
|
|
187
|
-
else if (!isValidString(errorMessage)) {
|
|
190
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
188
191
|
throw new Error('<mg-input-password> method "setError()" param "errorMessage" must be a string.');
|
|
189
192
|
}
|
|
190
193
|
else {
|
|
194
|
+
this.customErrorMessage = {
|
|
195
|
+
lock: valid ? false : errorMessageLock,
|
|
196
|
+
message: valid ? undefined : errorMessage,
|
|
197
|
+
};
|
|
191
198
|
this.setValidity(valid);
|
|
192
|
-
this.setErrorMessage(
|
|
199
|
+
this.setErrorMessage(true);
|
|
193
200
|
this.hasDisplayedError = this.invalid;
|
|
194
201
|
}
|
|
195
202
|
}
|
|
@@ -207,6 +214,8 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class MgInputPassword
|
|
|
207
214
|
// - Keep everything in sync both inside and outside the component
|
|
208
215
|
return new Promise(resolve => {
|
|
209
216
|
requestAnimationFrame(() => {
|
|
217
|
+
// unlock validity check by reseting customErrorMessage
|
|
218
|
+
this.customErrorMessage = { lock: false };
|
|
210
219
|
this.checkValidity();
|
|
211
220
|
this.errorMessage = undefined;
|
|
212
221
|
this.hasDisplayedError = false;
|
|
@@ -220,11 +229,13 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class MgInputPassword
|
|
|
220
229
|
* @param newValue - valid new value
|
|
221
230
|
*/
|
|
222
231
|
setValidity(newValue) {
|
|
223
|
-
const
|
|
224
|
-
this.
|
|
232
|
+
const oldValue = this.valid;
|
|
233
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
234
|
+
this.valid = newValue;
|
|
235
|
+
}
|
|
225
236
|
this.invalid = !this.valid;
|
|
226
237
|
// We need to send valid event even if it is the same value
|
|
227
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
238
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
228
239
|
this.inputValid.emit(this.valid);
|
|
229
240
|
}
|
|
230
241
|
/*************
|
|
@@ -252,7 +263,7 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class MgInputPassword
|
|
|
252
263
|
* @returns HTML Element
|
|
253
264
|
*/
|
|
254
265
|
render() {
|
|
255
|
-
return (h("mg-input", { key: '
|
|
266
|
+
return (h("mg-input", { key: '845c075a44c50043776b7577642254d772629eef', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.value !== undefined && h("b", { class: "mg-c-input__readonly-value" }, '•'.repeat(this.value.length))) : (h("span", { class: "mg-c-input__input-group" }, h("input", { type: this.displayPassword ? 'text' : 'password', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, maxlength: this.maxlength, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
256
267
|
if (el !== null)
|
|
257
268
|
this.input = el;
|
|
258
269
|
} }), h("mg-button", { label: this.messages.input.password[this.displayPassword ? 'hide' : 'display'], disabled: this.disabled, variant: "flat", class: "mg-c-input__append-button", "is-icon": true, onClick: this.toggleDisplayPassword, "aria-controls": this.identifier }, h("mg-icon", { class: "mg-c-input__input-icon", icon: this.displayPassword ? 'eye-slash' : 'eye' }))))));
|
|
@@ -33,6 +33,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
|
|
|
33
33
|
this.classVerticalList = 'mg-c-input--vertical-list';
|
|
34
34
|
// hasDisplayedError (triggered by blur event)
|
|
35
35
|
this.hasDisplayedError = false;
|
|
36
|
+
this.customErrorMessage = { lock: false };
|
|
36
37
|
/**
|
|
37
38
|
* Input name
|
|
38
39
|
* If not set the value equals the identifier
|
|
@@ -96,16 +97,18 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
|
|
|
96
97
|
};
|
|
97
98
|
/**
|
|
98
99
|
* Set input error message
|
|
99
|
-
* @param
|
|
100
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
100
101
|
*/
|
|
101
|
-
this.setErrorMessage = (
|
|
102
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
102
103
|
const invalidElement = this.getInvalidElement();
|
|
103
104
|
// Set error message
|
|
104
105
|
this.errorMessage = undefined;
|
|
105
106
|
if (!this.valid) {
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
108
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
109
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
108
110
|
}
|
|
111
|
+
// required
|
|
109
112
|
else if (invalidElement.validity.valueMissing) {
|
|
110
113
|
this.errorMessage = this.messages.errors.required;
|
|
111
114
|
}
|
|
@@ -210,17 +213,22 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
|
|
|
210
213
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
211
214
|
* @param valid - value indicating the validity
|
|
212
215
|
* @param errorMessage - the error message to display
|
|
216
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
213
217
|
*/
|
|
214
|
-
async setError(valid, errorMessage) {
|
|
218
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
215
219
|
if (typeof valid !== 'boolean') {
|
|
216
220
|
throw new Error('<mg-input-radio> method "setError()" param "valid" must be a boolean.');
|
|
217
221
|
}
|
|
218
|
-
else if (!isValidString(errorMessage)) {
|
|
222
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
219
223
|
throw new Error('<mg-input-radio> method "setError()" param "errorMessage" must be a string.');
|
|
220
224
|
}
|
|
221
225
|
else {
|
|
226
|
+
this.customErrorMessage = {
|
|
227
|
+
lock: valid ? false : errorMessageLock,
|
|
228
|
+
message: valid ? undefined : errorMessage,
|
|
229
|
+
};
|
|
222
230
|
this.setValidity(valid);
|
|
223
|
-
this.setErrorMessage(
|
|
231
|
+
this.setErrorMessage(true);
|
|
224
232
|
this.hasDisplayedError = this.invalid;
|
|
225
233
|
}
|
|
226
234
|
}
|
|
@@ -238,6 +246,8 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
|
|
|
238
246
|
// - Keep everything in sync both inside and outside the component
|
|
239
247
|
return new Promise(resolve => {
|
|
240
248
|
requestAnimationFrame(() => {
|
|
249
|
+
// unlock validity check by reseting customErrorMessage
|
|
250
|
+
this.customErrorMessage = { lock: false };
|
|
241
251
|
this.checkValidity();
|
|
242
252
|
this.errorMessage = undefined;
|
|
243
253
|
this.hasDisplayedError = false;
|
|
@@ -251,11 +261,13 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
|
|
|
251
261
|
* @param newValue - valid new value
|
|
252
262
|
*/
|
|
253
263
|
setValidity(newValue) {
|
|
254
|
-
const
|
|
255
|
-
this.
|
|
264
|
+
const oldValue = this.valid;
|
|
265
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
266
|
+
this.valid = newValue;
|
|
267
|
+
}
|
|
256
268
|
this.invalid = !this.valid;
|
|
257
269
|
// We need to send valid event even if it is the same value
|
|
258
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
270
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
259
271
|
this.inputValid.emit(this.valid);
|
|
260
272
|
}
|
|
261
273
|
/*************
|
|
@@ -286,7 +298,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
|
|
|
286
298
|
* @returns HTML Element
|
|
287
299
|
*/
|
|
288
300
|
render() {
|
|
289
|
-
return (h("mg-input", { key: '
|
|
301
|
+
return (h("mg-input", { key: '9290ab8e5048dd6806985ab55d13bd8b0dd93bd1', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && !this.value ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)) : (h("ul", { class: "mg-c-input__input-group-container", role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-c-input__input-group': true, 'mg-c-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) => {
|
|
290
302
|
if (el !== null)
|
|
291
303
|
this.inputs[index] = el;
|
|
292
304
|
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title))))))));
|
|
@@ -16395,8 +16395,7 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
|
|
|
16395
16395
|
this.valueChange = createEvent(this, "value-change", 7);
|
|
16396
16396
|
// hasDisplayedError (triggered by blur event)
|
|
16397
16397
|
this.hasDisplayedError = false;
|
|
16398
|
-
|
|
16399
|
-
this.classFocus = 'mg-u-is-focused';
|
|
16398
|
+
this.customErrorMessage = { lock: false };
|
|
16400
16399
|
/**
|
|
16401
16400
|
* Define the value of the editor
|
|
16402
16401
|
* Can be either HTML string or plain text
|
|
@@ -16460,27 +16459,29 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
|
|
|
16460
16459
|
};
|
|
16461
16460
|
/**
|
|
16462
16461
|
* Set input error message
|
|
16463
|
-
* @param
|
|
16462
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
16464
16463
|
*/
|
|
16465
|
-
this.setErrorMessage = (
|
|
16464
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
16465
|
+
// Set error message
|
|
16466
16466
|
this.errorMessage = undefined;
|
|
16467
|
-
|
|
16468
|
-
|
|
16469
|
-
|
|
16470
|
-
this.
|
|
16471
|
-
|
|
16472
|
-
|
|
16473
|
-
this.
|
|
16474
|
-
|
|
16475
|
-
|
|
16476
|
-
|
|
16467
|
+
// Does have a new custom error message
|
|
16468
|
+
if (!this.valid) {
|
|
16469
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
16470
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
16471
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
16472
|
+
}
|
|
16473
|
+
else if (this.required && this.isEmpty()) {
|
|
16474
|
+
this.errorMessage = this.messages.errors.required;
|
|
16475
|
+
}
|
|
16476
|
+
else if (!this.getPatternValidity()) {
|
|
16477
|
+
this.errorMessage = this.patternErrorMessage;
|
|
16478
|
+
}
|
|
16477
16479
|
}
|
|
16478
16480
|
};
|
|
16479
16481
|
/**
|
|
16480
16482
|
* Handle focus event
|
|
16481
16483
|
*/
|
|
16482
16484
|
this.handleFocus = () => {
|
|
16483
|
-
this.classCollection.add(this.classFocus);
|
|
16484
16485
|
this.classCollection = new ClassList(this.classCollection.classes);
|
|
16485
16486
|
};
|
|
16486
16487
|
/**
|
|
@@ -16489,7 +16490,6 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
|
|
|
16489
16490
|
*/
|
|
16490
16491
|
this.handleBlur = () => {
|
|
16491
16492
|
// Manage focus
|
|
16492
|
-
this.classCollection.delete(this.classFocus);
|
|
16493
16493
|
this.classCollection = new ClassList(this.classCollection.classes);
|
|
16494
16494
|
if (!this.readonly) {
|
|
16495
16495
|
this.checkValidity();
|
|
@@ -16557,7 +16557,7 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
|
|
|
16557
16557
|
* Get editor content as HTML
|
|
16558
16558
|
* @returns HTML content of the editor
|
|
16559
16559
|
*/
|
|
16560
|
-
|
|
16560
|
+
getHTML() {
|
|
16561
16561
|
return new Promise(resolve => {
|
|
16562
16562
|
requestAnimationFrame(() => {
|
|
16563
16563
|
resolve(this.editor.getSemanticHTML());
|
|
@@ -16601,17 +16601,22 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
|
|
|
16601
16601
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
16602
16602
|
* @param valid - value indicating the validity
|
|
16603
16603
|
* @param errorMessage - the error message to display
|
|
16604
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
16604
16605
|
*/
|
|
16605
|
-
async setError(valid, errorMessage) {
|
|
16606
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
16606
16607
|
if (typeof valid !== 'boolean') {
|
|
16607
16608
|
throw new Error('<mg-input-rich-text-editor> method "setError()" param "valid" must be a boolean.');
|
|
16608
16609
|
}
|
|
16609
|
-
else if (!isValidString(errorMessage)) {
|
|
16610
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
16610
16611
|
throw new Error('<mg-input-rich-text-editor> method "setError()" param "errorMessage" must be a string.');
|
|
16611
16612
|
}
|
|
16612
16613
|
else {
|
|
16614
|
+
this.customErrorMessage = {
|
|
16615
|
+
lock: valid ? false : errorMessageLock,
|
|
16616
|
+
message: valid ? undefined : errorMessage,
|
|
16617
|
+
};
|
|
16613
16618
|
this.setValidity(valid);
|
|
16614
|
-
this.setErrorMessage(
|
|
16619
|
+
this.setErrorMessage(true);
|
|
16615
16620
|
this.hasDisplayedError = this.invalid;
|
|
16616
16621
|
}
|
|
16617
16622
|
}
|
|
@@ -16630,6 +16635,8 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
|
|
|
16630
16635
|
// - Keep everything in sync both inside and outside the component
|
|
16631
16636
|
return new Promise(resolve => {
|
|
16632
16637
|
requestAnimationFrame(() => {
|
|
16638
|
+
// unlock validity check by reseting customErrorMessage
|
|
16639
|
+
this.customErrorMessage = { lock: false };
|
|
16633
16640
|
this.checkValidity();
|
|
16634
16641
|
this.errorMessage = undefined;
|
|
16635
16642
|
this.hasDisplayedError = false;
|
|
@@ -16643,10 +16650,12 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
|
|
|
16643
16650
|
* @param newValue - valid new value
|
|
16644
16651
|
*/
|
|
16645
16652
|
setValidity(newValue) {
|
|
16646
|
-
const
|
|
16647
|
-
this.
|
|
16653
|
+
const oldValue = this.valid;
|
|
16654
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
16655
|
+
this.valid = newValue;
|
|
16656
|
+
}
|
|
16648
16657
|
this.invalid = !this.valid;
|
|
16649
|
-
if (this.valid !==
|
|
16658
|
+
if (this.valid !== oldValue) {
|
|
16650
16659
|
this.inputValid.emit(this.valid);
|
|
16651
16660
|
}
|
|
16652
16661
|
}
|
|
@@ -16695,7 +16704,7 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
|
|
|
16695
16704
|
* @returns HTML mg-input Element
|
|
16696
16705
|
*/
|
|
16697
16706
|
render() {
|
|
16698
|
-
return (h("mg-input", { key: '
|
|
16707
|
+
return (h("mg-input", { key: '5e807e1059704a6624a1fda63ab56a6f9a51230f', identifier: this.identifier, class: this.classCollection.join(), label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, helpText: this.helpText, errorMessage: this.hasDisplayedError ? this.errorMessage : undefined }, this.readonly ? (h("div", { class: "mg-c-input__readonly-value", innerHTML: this.value })) : (h("div", { ref: el => {
|
|
16699
16708
|
this.wrapperElement = el;
|
|
16700
16709
|
}, id: this.identifier, class: "mg-c-input__wrapper" }, h("div", null)))));
|
|
16701
16710
|
}
|