@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { allItemsAreString, ClassList, isValidString, toString } from "@mgdis/core-ui-helpers/dist/utils";
|
|
3
3
|
import { helpTextTypes, textTypes } from "./mg-input-text.conf";
|
|
4
|
-
import { widths, classReadonly, classDisabled } from "../mg-input/mg-input.conf";
|
|
4
|
+
import { widths, classReadonly, classDisabled, classDisplayCharacterLeft } from "../mg-input/mg-input.conf";
|
|
5
5
|
import { initLocales } from "../../../../locales";
|
|
6
6
|
/**
|
|
7
7
|
* Check if object is an option
|
|
@@ -24,13 +24,13 @@ export class MgInputText {
|
|
|
24
24
|
* Internal *
|
|
25
25
|
************/
|
|
26
26
|
// Classes
|
|
27
|
-
this.classFocus = 'mg-u-is-focused';
|
|
28
27
|
this.classIsInputGroupAppend = 'mg-c-input--is-input-group-append';
|
|
29
28
|
this.classHasIcon = 'mg-c-input--has-icon';
|
|
30
29
|
this.classHasButtonsGroupAppend = 'mg-c-input--has-buttons-group-append';
|
|
31
30
|
this.classIsAppendInputSlotContent = 'mg-c-input--is-append-input-slot-content';
|
|
32
31
|
// hasDisplayedError (triggered by blur event)
|
|
33
32
|
this.hasDisplayedError = false;
|
|
33
|
+
this.customErrorMessage = { lock: false };
|
|
34
34
|
/**
|
|
35
35
|
* Input name
|
|
36
36
|
* If not set the value equals the identifier
|
|
@@ -100,20 +100,10 @@ export class MgInputText {
|
|
|
100
100
|
}
|
|
101
101
|
this.value = this.input.value;
|
|
102
102
|
};
|
|
103
|
-
/**
|
|
104
|
-
* Handle focus event
|
|
105
|
-
*/
|
|
106
|
-
this.handleFocus = () => {
|
|
107
|
-
this.classCollection.add(this.classFocus);
|
|
108
|
-
this.classCollection = new ClassList(this.classCollection.classes);
|
|
109
|
-
};
|
|
110
103
|
/**
|
|
111
104
|
* Handle blur event
|
|
112
105
|
*/
|
|
113
106
|
this.handleBlur = () => {
|
|
114
|
-
// Manage focus
|
|
115
|
-
this.classCollection.delete(this.classFocus);
|
|
116
|
-
this.classCollection = new ClassList(this.classCollection.classes);
|
|
117
107
|
// Display Error
|
|
118
108
|
this.handlerInProgress = 'blur';
|
|
119
109
|
this.displayError().finally(() => {
|
|
@@ -129,27 +119,29 @@ export class MgInputText {
|
|
|
129
119
|
};
|
|
130
120
|
/**
|
|
131
121
|
* Set input error message
|
|
132
|
-
* @param
|
|
122
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
133
123
|
*/
|
|
134
|
-
this.setErrorMessage = (
|
|
124
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
135
125
|
var _a;
|
|
136
126
|
// Set error message
|
|
137
127
|
this.errorMessage = undefined;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
128
|
+
if (!this.valid) {
|
|
129
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
130
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
131
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
132
|
+
}
|
|
133
|
+
// Does not match type (email, emails, tel, url, etc.)
|
|
134
|
+
else if (this.input.validity.typeMismatch) {
|
|
135
|
+
this.errorMessage = this.messages.input.text.errors.typeMismatch[this.type];
|
|
136
|
+
}
|
|
137
|
+
// Does not match pattern
|
|
138
|
+
else if (this.input.validity.patternMismatch) {
|
|
139
|
+
this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : this.messages.input.text.errors.typeMismatch[this.type];
|
|
140
|
+
}
|
|
141
|
+
// required
|
|
142
|
+
else if (this.input.validity.valueMissing) {
|
|
143
|
+
this.errorMessage = this.messages.errors.required;
|
|
144
|
+
}
|
|
153
145
|
}
|
|
154
146
|
};
|
|
155
147
|
/**
|
|
@@ -245,6 +237,14 @@ export class MgInputText {
|
|
|
245
237
|
watchPattern() {
|
|
246
238
|
this.validatePattern();
|
|
247
239
|
}
|
|
240
|
+
validateCharacterLeftHide(newValue) {
|
|
241
|
+
if (newValue) {
|
|
242
|
+
this.classCollection.delete(classDisplayCharacterLeft);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
this.classCollection.add(classDisplayCharacterLeft);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
248
|
watchHelpText(newValue) {
|
|
249
249
|
if (!isValidString(newValue) && helpTextTypes.includes(this.type)) {
|
|
250
250
|
this.helpText = this.messages.input.text.helpText[this.type];
|
|
@@ -283,17 +283,22 @@ export class MgInputText {
|
|
|
283
283
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
284
284
|
* @param valid - value indicating the validity
|
|
285
285
|
* @param errorMessage - the error message to display
|
|
286
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
286
287
|
*/
|
|
287
|
-
async setError(valid, errorMessage) {
|
|
288
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
288
289
|
if (typeof valid !== 'boolean') {
|
|
289
290
|
throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean.');
|
|
290
291
|
}
|
|
291
|
-
else if (!isValidString(errorMessage)) {
|
|
292
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
292
293
|
throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string.');
|
|
293
294
|
}
|
|
294
295
|
else {
|
|
296
|
+
this.customErrorMessage = {
|
|
297
|
+
lock: valid ? false : errorMessageLock,
|
|
298
|
+
message: valid ? undefined : errorMessage,
|
|
299
|
+
};
|
|
295
300
|
this.setValidity(valid);
|
|
296
|
-
this.setErrorMessage(
|
|
301
|
+
this.setErrorMessage(true);
|
|
297
302
|
this.hasDisplayedError = this.invalid;
|
|
298
303
|
}
|
|
299
304
|
}
|
|
@@ -311,6 +316,8 @@ export class MgInputText {
|
|
|
311
316
|
// - Keep everything in sync both inside and outside the component
|
|
312
317
|
return new Promise(resolve => {
|
|
313
318
|
requestAnimationFrame(() => {
|
|
319
|
+
// unlock validity check by reseting customErrorMessage
|
|
320
|
+
this.customErrorMessage = { lock: false };
|
|
314
321
|
this.checkValidity();
|
|
315
322
|
this.errorMessage = undefined;
|
|
316
323
|
this.hasDisplayedError = false;
|
|
@@ -324,11 +331,13 @@ export class MgInputText {
|
|
|
324
331
|
* @param newValue - valid new value
|
|
325
332
|
*/
|
|
326
333
|
setValidity(newValue) {
|
|
327
|
-
const
|
|
328
|
-
this.
|
|
334
|
+
const oldValue = this.valid;
|
|
335
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
336
|
+
this.valid = newValue;
|
|
337
|
+
}
|
|
329
338
|
this.invalid = !this.valid;
|
|
330
339
|
// We need to send valid event even if it is the same value
|
|
331
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
340
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
332
341
|
this.inputValid.emit(this.valid);
|
|
333
342
|
}
|
|
334
343
|
/*************
|
|
@@ -351,6 +360,7 @@ export class MgInputText {
|
|
|
351
360
|
this.watchMgWidth(this.mgWidth);
|
|
352
361
|
this.watchReadonly(this.readonly);
|
|
353
362
|
this.watchDisabled(this.disabled);
|
|
363
|
+
this.validateCharacterLeftHide(this.characterLeftHide);
|
|
354
364
|
this.validateType(this.type);
|
|
355
365
|
this.watchHelpText(this.helpText);
|
|
356
366
|
// Check validity when component is ready
|
|
@@ -365,12 +375,12 @@ export class MgInputText {
|
|
|
365
375
|
* @returns HTML Element
|
|
366
376
|
*/
|
|
367
377
|
render() {
|
|
368
|
-
return (h("mg-input", { key: '
|
|
378
|
+
return (h("mg-input", { key: 'b6360c95530daf744ae5c3eb5cc41d6c81c3e35c', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: this.characterLeftId, 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
|
|
369
379
|
? this.value && this.renderReadonly()
|
|
370
380
|
: [
|
|
371
|
-
h("div", { key: "input", class: "mg-c-
|
|
381
|
+
h("div", { key: "input", class: "mg-c-input__input-group-container", style: {
|
|
372
382
|
'--mg-c-character-left-message-length': (!this.characterLeftHide ? this.maxlength.toString().length * 2 + 1 : 0).toString(),
|
|
373
|
-
} }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type === 'emails' ? 'email' : this.type, multiple: this.type === 'emails', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, list: this.hasDatalist() ? this.datalistId : undefined, autocomplete: this.hasDatalist() ? 'off' : undefined, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), pattern: this.pattern, onInput: this.handleInput,
|
|
383
|
+
} }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type === 'emails' ? 'email' : this.type, multiple: this.type === 'emails', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, list: this.hasDatalist() ? this.datalistId : undefined, autocomplete: this.hasDatalist() ? 'off' : undefined, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), pattern: this.pattern, onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
374
384
|
if (el !== null)
|
|
375
385
|
this.input = el;
|
|
376
386
|
} }), this.hasDatalist() && (h("datalist", { id: this.datalistId }, this.datalistoptions.map(option => (h("option", { value: isOption(option) ? option.title : option, key: option }))))), !this.characterLeftHide && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))),
|
|
@@ -539,7 +549,7 @@ export class MgInputText {
|
|
|
539
549
|
"mutable": false,
|
|
540
550
|
"complexType": {
|
|
541
551
|
"original": "IconType",
|
|
542
|
-
"resolved": "\"filter\" | \"link\" | \"picture\" | \"table\" | \"circle\" | \"download\" | \"key\" | \"list\" | \"copy\" | \"history\" | \"location\" | \"loader\" | \"address-card\" | \"address-card-outline\" | \"align-center\" | \"align-justify\" | \"align-left\" | \"align-right\" | \"api\" | \"archive\" | \"archive-outline\" | \"arrow-clock\" | \"arrow-down\" | \"arrow-down-a-z\" | \"arrow-down-right\" | \"arrow-left\" | \"arrow-right\" | \"arrow-rotate\" | \"arrow-rotate-backward\" | \"arrow-up\" | \"arrow-up-right\" | \"arrow-up-right-square\" | \"arrow-up-z-a\" | \"arrows-compare\" | \"arrows-right-down\" | \"arrows-right-left\" | \"arrows-rotate\" | \"arrows-rotate-backward\" | \"arrows-up-down\" | \"ban\" | \"bell\" | \"bell-outline\" | \"book\" | \"book-outline\" | \"briefcase\" | \"briefcase-outline\" | \"building-outline\" | \"calculator\" | \"calculator-outline\" | \"calendar\" | \"calendar-euro\" | \"calendar-euro-outline\" | \"calendar-outline\" | \"check\" | \"check-circle\" | \"check-circle-outline\" | \"chevron-down\" | \"chevron-down-circle\" | \"chevron-left\" | \"chevron-left-circle\" | \"chevron-right\" | \"chevron-right-circle\" | \"chevron-up\" | \"chevron-up-circle\" | \"clock\" | \"clock-outline\" | \"code-square-outline\" | \"cog\" | \"cog-outline\" | \"comment\" | \"comment-exclamation\" | \"comment-exclamation-outline\" | \"comment-outline\" | \"comment-question\" | \"comment-question-outline\" | \"comment-sms\" | \"conversation\" | \"conversation-outline\" | \"copy-file\" | \"copy-file-outline\" | \"copy-outline\" | \"credit-card\" | \"cross\" | \"cross-circle\" | \"cross-circle-outline\" | \"dashboard\" | \"dashboard-outline\" | \"earth\" | \"earth-outline\" | \"ellipsis\" | \"ellipsis-vertical\" | \"euro\" | \"euro-circle\" | \"exclamation-circle\" | \"exclamation-circle-outline\" | \"exclamation-stamp\" | \"exclamation-triangle\" | \"exclamation-triangle-outline\" | \"eye\" | \"eye-outline\" | \"eye-slash\" | \"eye-slash-outline\" | \"fax\" | \"fax-outline\" | \"file\" | \"file-cog\" | \"file-download\" | \"file-excel\" | \"file-excel-outline\" | \"file-outline\" | \"file-pdf\" | \"file-pdf-outline\" | \"file-text\" | \"file-text-outline\" | \"file-upload\" | \"file-word\" | \"file-word-outline\" | \"filter-outline\" | \"floppy-disk\" | \"floppy-disk-checked\" | \"floppy-disk-checked-outline\" | \"floppy-disk-outline\" | \"folder\" | \"folder-check\" | \"folder-check-outline\" | \"folder-lines\" | \"folder-lines-outline\" | \"folder-link\" | \"folder-link-outline\" | \"folder-outline\" | \"folder-star\" | \"folders\" | \"folders-outline\" | \"gavel\" | \"gavel-outline\" | \"graduation-cap\" | \"graduation-cap-outline\" | \"hand-euro\" | \"hand-euro-outline\" | \"hand-up\" | \"home\" | \"home-outline\" | \"info-circle\" | \"info-circle-outline\" | \"interrogation-circle\" | \"interrogation-circle-outline\" | \"laptop\" | \"layers\" | \"life-ring\" | \"lines-rectangle\" | \"lines-rectangle-outline\" | \"location-outline\" | \"lock\" | \"lock-outline\" | \"log-in\" | \"log-out\" | \"magnifying-glass\" | \"mail\" | \"mail-open\" | \"mail-open-outline\" | \"mail-outline\" | \"messages-square\" | \"messages-square-outline\" | \"mobile\" | \"mobile-outline\" | \"notes\" | \"notes-outline\" | \"paper-plane\" | \"paper-plane-outline\" | \"paper-plane-slash\" | \"paper-plane-slash-outline\" | \"paperclip\" | \"pen\" | \"pen-circle\" | \"pen-fancy\" | \"pen-fancy-files-outline\" | \"pen-fancy-outline\" | \"pen-outline\" | \"phone\" | \"phone-outline\" | \"picture-outline\" | \"play-circle\" | \"plus\" | \"plus-circle\" | \"share\" | \"share-outline\" | \"shuffle\" | \"sitemap\" | \"sliders\" | \"sliders-outline\" | \"squares\" | \"star\" | \"star-outline\" | \"tag\" | \"tag-outline\" | \"tags\" | \"tags-outline\" | \"thumb-down\" | \"thumb-down-outline\" | \"thumb-up\" | \"thumb-up-outline\" | \"thumbtack\" | \"thumbtack-outline\" | \"trash\" | \"trash-outline\" | \"universal-access\" | \"universal-access-outline\" | \"unlink\" | \"unlock\" | \"unlock-outline\" | \"upload\" | \"user\" | \"user-circle\" | \"user-group\" | \"user-group-outline\" | \"user-lock\" | \"user-outline\" | \"user-pen-fancy-outline\" | \"user-plus\" | \"user-question-outline\" | \"user-shield\" | \"user-shield-outline\" | \"users\" | \"users-outline\" | \"wallet\" | \"wallet-outline\"",
|
|
552
|
+
"resolved": "\"filter\" | \"link\" | \"picture\" | \"table\" | \"circle\" | \"download\" | \"key\" | \"list\" | \"copy\" | \"history\" | \"location\" | \"loader\" | \"address-card\" | \"address-card-outline\" | \"align-center\" | \"align-justify\" | \"align-left\" | \"align-right\" | \"api\" | \"archive\" | \"archive-outline\" | \"arrow-clock\" | \"arrow-down\" | \"arrow-down-a-z\" | \"arrow-down-right\" | \"arrow-left\" | \"arrow-right\" | \"arrow-rotate\" | \"arrow-rotate-backward\" | \"arrow-up\" | \"arrow-up-right\" | \"arrow-up-right-square\" | \"arrow-up-z-a\" | \"arrows-compare\" | \"arrows-right-down\" | \"arrows-right-left\" | \"arrows-rotate\" | \"arrows-rotate-backward\" | \"arrows-up-down\" | \"ban\" | \"bell\" | \"bell-outline\" | \"book\" | \"book-outline\" | \"briefcase\" | \"briefcase-outline\" | \"building\" | \"building-outline\" | \"calculator\" | \"calculator-outline\" | \"calendar\" | \"calendar-euro\" | \"calendar-euro-outline\" | \"calendar-outline\" | \"check\" | \"check-circle\" | \"check-circle-outline\" | \"chevron-down\" | \"chevron-down-circle\" | \"chevron-left\" | \"chevron-left-circle\" | \"chevron-right\" | \"chevron-right-circle\" | \"chevron-up\" | \"chevron-up-circle\" | \"clock\" | \"clock-outline\" | \"code-square-outline\" | \"cog\" | \"cog-outline\" | \"comment\" | \"comment-exclamation\" | \"comment-exclamation-outline\" | \"comment-outline\" | \"comment-question\" | \"comment-question-outline\" | \"comment-sms\" | \"comment-sms-outline\" | \"conversation\" | \"conversation-outline\" | \"copy-file\" | \"copy-file-outline\" | \"copy-outline\" | \"credit-card\" | \"cross\" | \"cross-circle\" | \"cross-circle-outline\" | \"dashboard\" | \"dashboard-outline\" | \"earth\" | \"earth-outline\" | \"ellipsis\" | \"ellipsis-vertical\" | \"euro\" | \"euro-circle\" | \"exclamation-circle\" | \"exclamation-circle-outline\" | \"exclamation-stamp\" | \"exclamation-triangle\" | \"exclamation-triangle-outline\" | \"eye\" | \"eye-outline\" | \"eye-slash\" | \"eye-slash-outline\" | \"fax\" | \"fax-outline\" | \"file\" | \"file-cog\" | \"file-cog-outline\" | \"file-download\" | \"file-download-outline\" | \"file-excel\" | \"file-excel-outline\" | \"file-outline\" | \"file-pdf\" | \"file-pdf-outline\" | \"file-text\" | \"file-text-outline\" | \"file-upload\" | \"file-upload-outline\" | \"file-word\" | \"file-word-outline\" | \"filter-outline\" | \"floppy-disk\" | \"floppy-disk-checked\" | \"floppy-disk-checked-outline\" | \"floppy-disk-outline\" | \"folder\" | \"folder-check\" | \"folder-check-outline\" | \"folder-lines\" | \"folder-lines-outline\" | \"folder-link\" | \"folder-link-outline\" | \"folder-outline\" | \"folder-star\" | \"folder-star-outline\" | \"folders\" | \"folders-outline\" | \"gavel\" | \"gavel-outline\" | \"graduation-cap\" | \"graduation-cap-outline\" | \"hand-euro\" | \"hand-euro-outline\" | \"hand-up\" | \"home\" | \"home-outline\" | \"info-circle\" | \"info-circle-outline\" | \"interrogation-circle\" | \"interrogation-circle-outline\" | \"laptop\" | \"layers\" | \"life-ring\" | \"lines-rectangle\" | \"lines-rectangle-outline\" | \"location-outline\" | \"lock\" | \"lock-outline\" | \"log-in\" | \"log-out\" | \"magnifying-glass\" | \"mail\" | \"mail-open\" | \"mail-open-outline\" | \"mail-outline\" | \"messages-square\" | \"messages-square-outline\" | \"mobile\" | \"mobile-outline\" | \"notes\" | \"notes-outline\" | \"paper-plane\" | \"paper-plane-outline\" | \"paper-plane-slash\" | \"paper-plane-slash-outline\" | \"paperclip\" | \"pen\" | \"pen-circle\" | \"pen-fancy\" | \"pen-fancy-files-outline\" | \"pen-fancy-outline\" | \"pen-outline\" | \"phone\" | \"phone-outline\" | \"picture-outline\" | \"play-circle\" | \"plus\" | \"plus-circle\" | \"plus-circle-outline\" | \"share\" | \"share-outline\" | \"shuffle\" | \"sidebar-arrow-left\" | \"sidebar-arrow-right\" | \"sitemap\" | \"sliders\" | \"sliders-outline\" | \"squares\" | \"star\" | \"star-outline\" | \"tag\" | \"tag-outline\" | \"tags\" | \"tags-outline\" | \"thumb-down\" | \"thumb-down-outline\" | \"thumb-up\" | \"thumb-up-outline\" | \"thumbtack\" | \"thumbtack-outline\" | \"trash\" | \"trash-outline\" | \"universal-access\" | \"universal-access-outline\" | \"unlink\" | \"unlock\" | \"unlock-outline\" | \"upload\" | \"user\" | \"user-circle\" | \"user-group\" | \"user-group-outline\" | \"user-lock\" | \"user-outline\" | \"user-pen-fancy-outline\" | \"user-plus\" | \"user-question-outline\" | \"user-shield\" | \"user-shield-outline\" | \"users\" | \"users-outline\" | \"wallet\" | \"wallet-outline\"",
|
|
543
553
|
"references": {
|
|
544
554
|
"IconType": {
|
|
545
555
|
"location": "import",
|
|
@@ -956,7 +966,7 @@ export class MgInputText {
|
|
|
956
966
|
},
|
|
957
967
|
"setError": {
|
|
958
968
|
"complexType": {
|
|
959
|
-
"signature": "(valid: MgInputText[\"valid\"], errorMessage
|
|
969
|
+
"signature": "(valid: MgInputText[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
|
|
960
970
|
"parameters": [{
|
|
961
971
|
"name": "valid",
|
|
962
972
|
"type": "boolean",
|
|
@@ -965,6 +975,10 @@ export class MgInputText {
|
|
|
965
975
|
"name": "errorMessage",
|
|
966
976
|
"type": "string",
|
|
967
977
|
"docs": "- the error message to display"
|
|
978
|
+
}, {
|
|
979
|
+
"name": "errorMessageLock",
|
|
980
|
+
"type": "boolean",
|
|
981
|
+
"docs": "- lock the error message and validity state"
|
|
968
982
|
}],
|
|
969
983
|
"references": {
|
|
970
984
|
"Promise": {
|
|
@@ -986,6 +1000,9 @@ export class MgInputText {
|
|
|
986
1000
|
}, {
|
|
987
1001
|
"name": "param",
|
|
988
1002
|
"text": "errorMessage - the error message to display"
|
|
1003
|
+
}, {
|
|
1004
|
+
"name": "param",
|
|
1005
|
+
"text": "errorMessageLock - lock the error message and validity state"
|
|
989
1006
|
}]
|
|
990
1007
|
}
|
|
991
1008
|
},
|
|
@@ -1046,6 +1063,9 @@ export class MgInputText {
|
|
|
1046
1063
|
}, {
|
|
1047
1064
|
"propName": "patternErrorMessage",
|
|
1048
1065
|
"methodName": "watchPattern"
|
|
1066
|
+
}, {
|
|
1067
|
+
"propName": "characterLeftHide",
|
|
1068
|
+
"methodName": "validateCharacterLeftHide"
|
|
1049
1069
|
}, {
|
|
1050
1070
|
"propName": "helpText",
|
|
1051
1071
|
"methodName": "watchHelpText"
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { ClassList, isValidString, toString } from "@mgdis/core-ui-helpers/dist/utils";
|
|
3
|
-
import { widths, classReadonly, classDisabled } from "../mg-input/mg-input.conf";
|
|
3
|
+
import { widths, classReadonly, classDisabled, classDisplayCharacterLeft } from "../mg-input/mg-input.conf";
|
|
4
4
|
import { initLocales } from "../../../../locales";
|
|
5
5
|
export class MgInputTextarea {
|
|
6
6
|
constructor() {
|
|
7
|
-
/************
|
|
8
|
-
* Internal *
|
|
9
|
-
************/
|
|
10
|
-
// Classes
|
|
11
|
-
this.classFocus = 'mg-u-is-focused';
|
|
12
|
-
this.classDisplayCharacterLeft = 'mg-c-input--display-character-left';
|
|
13
7
|
// hasDisplayedError (triggered by blur event)
|
|
14
8
|
this.hasDisplayedError = false;
|
|
9
|
+
this.customErrorMessage = { lock: false };
|
|
15
10
|
/**
|
|
16
11
|
* Input name
|
|
17
12
|
* If not set the value equals the identifier
|
|
@@ -75,20 +70,10 @@ export class MgInputTextarea {
|
|
|
75
70
|
}
|
|
76
71
|
this.value = this.input.value;
|
|
77
72
|
};
|
|
78
|
-
/**
|
|
79
|
-
* Handle focus event
|
|
80
|
-
*/
|
|
81
|
-
this.handleFocus = () => {
|
|
82
|
-
this.classCollection.add(this.classFocus);
|
|
83
|
-
this.classCollection = new ClassList(this.classCollection.classes);
|
|
84
|
-
};
|
|
85
73
|
/**
|
|
86
74
|
* Handle blur event
|
|
87
75
|
*/
|
|
88
76
|
this.handleBlur = () => {
|
|
89
|
-
// Manage focus
|
|
90
|
-
this.classCollection.delete(this.classFocus);
|
|
91
|
-
this.classCollection = new ClassList(this.classCollection.classes);
|
|
92
77
|
// Display Error
|
|
93
78
|
this.handlerInProgress = 'blur';
|
|
94
79
|
this.displayError().finally(() => {
|
|
@@ -110,15 +95,16 @@ export class MgInputTextarea {
|
|
|
110
95
|
};
|
|
111
96
|
/**
|
|
112
97
|
* Set input error message
|
|
113
|
-
* @param
|
|
98
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
114
99
|
*/
|
|
115
|
-
this.setErrorMessage = (
|
|
100
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
116
101
|
// Set error message
|
|
117
102
|
this.errorMessage = undefined;
|
|
118
|
-
// Does
|
|
103
|
+
// Does have a new custom error message
|
|
119
104
|
if (!this.valid) {
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
106
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
107
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
122
108
|
}
|
|
123
109
|
else if (!this.getPatternValidity()) {
|
|
124
110
|
this.errorMessage = this.patternErrorMessage;
|
|
@@ -172,10 +158,10 @@ export class MgInputTextarea {
|
|
|
172
158
|
}
|
|
173
159
|
validatecharacterLeftHide(newValue) {
|
|
174
160
|
if (newValue) {
|
|
175
|
-
this.classCollection.delete(
|
|
161
|
+
this.classCollection.delete(classDisplayCharacterLeft);
|
|
176
162
|
}
|
|
177
163
|
else {
|
|
178
|
-
this.classCollection.add(
|
|
164
|
+
this.classCollection.add(classDisplayCharacterLeft);
|
|
179
165
|
}
|
|
180
166
|
}
|
|
181
167
|
/**
|
|
@@ -211,17 +197,22 @@ export class MgInputTextarea {
|
|
|
211
197
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
212
198
|
* @param valid - value indicating the validity
|
|
213
199
|
* @param errorMessage - the error message to display
|
|
200
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
214
201
|
*/
|
|
215
|
-
async setError(valid, errorMessage) {
|
|
202
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
216
203
|
if (typeof valid !== 'boolean') {
|
|
217
204
|
throw new Error('<mg-input-textarea> method "setError()" param "valid" must be a boolean.');
|
|
218
205
|
}
|
|
219
|
-
else if (!isValidString(errorMessage)) {
|
|
206
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
220
207
|
throw new Error('<mg-input-textarea> method "setError()" param "errorMessage" must be a string.');
|
|
221
208
|
}
|
|
222
209
|
else {
|
|
210
|
+
this.customErrorMessage = {
|
|
211
|
+
lock: valid ? false : errorMessageLock,
|
|
212
|
+
message: valid ? undefined : errorMessage,
|
|
213
|
+
};
|
|
223
214
|
this.setValidity(valid);
|
|
224
|
-
this.setErrorMessage(
|
|
215
|
+
this.setErrorMessage(true);
|
|
225
216
|
this.hasDisplayedError = this.invalid;
|
|
226
217
|
}
|
|
227
218
|
}
|
|
@@ -239,6 +230,8 @@ export class MgInputTextarea {
|
|
|
239
230
|
// - Keep everything in sync both inside and outside the component
|
|
240
231
|
return new Promise(resolve => {
|
|
241
232
|
requestAnimationFrame(() => {
|
|
233
|
+
// unlock validity check by reseting customErrorMessage
|
|
234
|
+
this.customErrorMessage = { lock: false };
|
|
242
235
|
this.checkValidity();
|
|
243
236
|
this.errorMessage = undefined;
|
|
244
237
|
this.hasDisplayedError = false;
|
|
@@ -252,11 +245,13 @@ export class MgInputTextarea {
|
|
|
252
245
|
* @param newValue - valid new value
|
|
253
246
|
*/
|
|
254
247
|
setValidity(newValue) {
|
|
255
|
-
const
|
|
256
|
-
this.
|
|
248
|
+
const oldValue = this.valid;
|
|
249
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
250
|
+
this.valid = newValue;
|
|
251
|
+
}
|
|
257
252
|
this.invalid = !this.valid;
|
|
258
253
|
// We need to send valid event even if it is the same value
|
|
259
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
254
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
260
255
|
this.inputValid.emit(this.valid);
|
|
261
256
|
}
|
|
262
257
|
/*************
|
|
@@ -289,13 +284,13 @@ export class MgInputTextarea {
|
|
|
289
284
|
* @returns HTML Element
|
|
290
285
|
*/
|
|
291
286
|
render() {
|
|
292
|
-
return (h("mg-input", { key: '
|
|
287
|
+
return (h("mg-input", { key: 'a43b8b1572249e31fb6ea5bd9244639698629218', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: this.characterLeftId, 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 && h("b", { class: "mg-c-input__readonly-value" }, this.value)) : (h("div", { class: "mg-c-input__input-group-container" }, h("textarea", { class: {
|
|
293
288
|
'mg-c-input__box': true,
|
|
294
289
|
'mg-c-input__box--width': true,
|
|
295
290
|
'mg-c-input__box--resizable': this.resizable === 'both',
|
|
296
291
|
'mg-c-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
297
292
|
'mg-c-input__box--resizable-vertical': this.resizable === 'vertical',
|
|
298
|
-
}, 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, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput,
|
|
293
|
+
}, 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, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
299
294
|
if (el !== null)
|
|
300
295
|
this.input = el;
|
|
301
296
|
} }), !this.characterLeftHide && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))))));
|
|
@@ -845,7 +840,7 @@ export class MgInputTextarea {
|
|
|
845
840
|
},
|
|
846
841
|
"setError": {
|
|
847
842
|
"complexType": {
|
|
848
|
-
"signature": "(valid: MgInputTextarea[\"valid\"], errorMessage
|
|
843
|
+
"signature": "(valid: MgInputTextarea[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
|
|
849
844
|
"parameters": [{
|
|
850
845
|
"name": "valid",
|
|
851
846
|
"type": "boolean",
|
|
@@ -854,6 +849,10 @@ export class MgInputTextarea {
|
|
|
854
849
|
"name": "errorMessage",
|
|
855
850
|
"type": "string",
|
|
856
851
|
"docs": "- the error message to display"
|
|
852
|
+
}, {
|
|
853
|
+
"name": "errorMessageLock",
|
|
854
|
+
"type": "boolean",
|
|
855
|
+
"docs": "- lock the error message and validity state"
|
|
857
856
|
}],
|
|
858
857
|
"references": {
|
|
859
858
|
"Promise": {
|
|
@@ -875,6 +874,9 @@ export class MgInputTextarea {
|
|
|
875
874
|
}, {
|
|
876
875
|
"name": "param",
|
|
877
876
|
"text": "errorMessage - the error message to display"
|
|
877
|
+
}, {
|
|
878
|
+
"name": "param",
|
|
879
|
+
"text": "errorMessageLock - lock the error message and validity state"
|
|
878
880
|
}]
|
|
879
881
|
}
|
|
880
882
|
},
|
|
@@ -31,7 +31,9 @@ export class MgInputToggle {
|
|
|
31
31
|
*/
|
|
32
32
|
this.labelHide = false;
|
|
33
33
|
/**
|
|
34
|
-
* Define if toggle have on/off style
|
|
34
|
+
* Define if toggle have on/off style,
|
|
35
|
+
* the left icon is hidden.
|
|
36
|
+
* Only available in combination with the "isIcon" prop.
|
|
35
37
|
*/
|
|
36
38
|
this.isOnOff = false;
|
|
37
39
|
/**
|
|
@@ -66,7 +68,7 @@ export class MgInputToggle {
|
|
|
66
68
|
// Set error message
|
|
67
69
|
this.errorMessage = undefined;
|
|
68
70
|
// Does have a custom error message
|
|
69
|
-
if (!this.valid && errorMessage
|
|
71
|
+
if (!this.valid && typeof errorMessage === 'string') {
|
|
70
72
|
this.errorMessage = errorMessage;
|
|
71
73
|
}
|
|
72
74
|
};
|
|
@@ -81,14 +83,31 @@ export class MgInputToggle {
|
|
|
81
83
|
*/
|
|
82
84
|
this.validateSlots = () => {
|
|
83
85
|
const slots = Array.from(this.element.children);
|
|
86
|
+
// validate slots
|
|
84
87
|
if (slots.length !== 2) {
|
|
85
|
-
|
|
88
|
+
if (this.isOnOff && this.isIcon) {
|
|
89
|
+
// ONLY slot="item-2" is required in with isOnOff && isIcon
|
|
90
|
+
if (this.element.querySelector('[slot="item-2"]') === null) {
|
|
91
|
+
throw new Error('<mg-input-toggle> an element with attribute slot="item-2" is required.');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw new Error('<mg-input-toggle> 2 slots are required.');
|
|
96
|
+
}
|
|
86
97
|
}
|
|
87
|
-
|
|
98
|
+
// update slots
|
|
99
|
+
if (!this.isIcon) {
|
|
88
100
|
// Due to text-overflow set to ellipsis
|
|
89
101
|
// we need to ensure that slot element have title to display value on mouse over
|
|
90
102
|
slots.forEach(slot => slot.setAttribute('title', slot.textContent));
|
|
91
103
|
}
|
|
104
|
+
else {
|
|
105
|
+
slots.forEach(slot => {
|
|
106
|
+
if (slot.nodeName === 'MG-ICON') {
|
|
107
|
+
slot.size = 'small';
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
92
111
|
};
|
|
93
112
|
/**
|
|
94
113
|
* Get checked item
|
|
@@ -129,10 +148,16 @@ export class MgInputToggle {
|
|
|
129
148
|
}
|
|
130
149
|
}
|
|
131
150
|
watchIsOnOff(newValue) {
|
|
132
|
-
if (newValue)
|
|
151
|
+
if (newValue) {
|
|
133
152
|
this.classCollection.add(this.classOnOff);
|
|
134
|
-
|
|
153
|
+
if (!this.isIcon) {
|
|
154
|
+
this.isOnOff = false;
|
|
155
|
+
console.warn('<mg-input-toggle> prop "isOnOff" must be used with "isIcon". Setting isOnOff to false.');
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
135
159
|
this.classCollection.delete(this.classOnOff);
|
|
160
|
+
}
|
|
136
161
|
}
|
|
137
162
|
watchIsIcon(newValue) {
|
|
138
163
|
if (newValue)
|
|
@@ -180,7 +205,7 @@ export class MgInputToggle {
|
|
|
180
205
|
if (typeof valid !== 'boolean') {
|
|
181
206
|
throw new Error('<mg-input-toggle> method "setError()" param "valid" must be a boolean.');
|
|
182
207
|
}
|
|
183
|
-
else if (!isValidString(errorMessage)) {
|
|
208
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
184
209
|
throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string.');
|
|
185
210
|
}
|
|
186
211
|
else {
|
|
@@ -257,7 +282,7 @@ export class MgInputToggle {
|
|
|
257
282
|
*/
|
|
258
283
|
render() {
|
|
259
284
|
const checkedItem = this.getCheckedItem(this.checked);
|
|
260
|
-
return (h("mg-input", { key: '
|
|
285
|
+
return (h("mg-input", { key: '4d87ed13bbd3d3a54303c21001247e1251417326', label: this.label, helpText: this.helpText, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, errorMessage: this.errorMessage }, this.readonly ? (checkedItem && h("b", { class: "mg-c-input__readonly-value" }, checkedItem.title)) : (h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-c-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked, ref: el => {
|
|
261
286
|
if (el !== null)
|
|
262
287
|
this.button = el;
|
|
263
288
|
} }, h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-2" }))))));
|
|
@@ -418,7 +443,7 @@ export class MgInputToggle {
|
|
|
418
443
|
},
|
|
419
444
|
"isOnOff": {
|
|
420
445
|
"type": "boolean",
|
|
421
|
-
"mutable":
|
|
446
|
+
"mutable": true,
|
|
422
447
|
"complexType": {
|
|
423
448
|
"original": "boolean",
|
|
424
449
|
"resolved": "boolean",
|
|
@@ -428,7 +453,7 @@ export class MgInputToggle {
|
|
|
428
453
|
"optional": false,
|
|
429
454
|
"docs": {
|
|
430
455
|
"tags": [],
|
|
431
|
-
"text": "Define if toggle have on/off style"
|
|
456
|
+
"text": "Define if toggle have on/off style,\nthe left icon is hidden.\nOnly available in combination with the \"isIcon\" prop."
|
|
432
457
|
},
|
|
433
458
|
"getter": false,
|
|
434
459
|
"setter": false,
|
|
@@ -630,7 +655,7 @@ export class MgInputToggle {
|
|
|
630
655
|
},
|
|
631
656
|
"setError": {
|
|
632
657
|
"complexType": {
|
|
633
|
-
"signature": "(valid: boolean, errorMessage
|
|
658
|
+
"signature": "(valid: boolean, errorMessage?: string) => Promise<void>",
|
|
634
659
|
"parameters": [{
|
|
635
660
|
"name": "valid",
|
|
636
661
|
"type": "boolean",
|
|
@@ -104,7 +104,7 @@ export class MgItemMore {
|
|
|
104
104
|
"mutable": false,
|
|
105
105
|
"complexType": {
|
|
106
106
|
"original": "IconType",
|
|
107
|
-
"resolved": "{ icon: \"filter\" | \"link\" | \"picture\" | \"table\" | \"circle\" | \"download\" | \"key\" | \"list\" | \"copy\" | \"history\" | \"location\" | \"loader\" | \"address-card\" | \"address-card-outline\" | \"align-center\" | \"align-justify\" | \"align-left\" | \"align-right\" | \"api\" | \"archive\" | \"archive-outline\" | \"arrow-clock\" | \"arrow-down\" | \"arrow-down-a-z\" | \"arrow-down-right\" | \"arrow-left\" | \"arrow-right\" | \"arrow-rotate\" | \"arrow-rotate-backward\" | \"arrow-up\" | \"arrow-up-right\" | \"arrow-up-right-square\" | \"arrow-up-z-a\" | \"arrows-compare\" | \"arrows-right-down\" | \"arrows-right-left\" | \"arrows-rotate\" | \"arrows-rotate-backward\" | \"arrows-up-down\" | \"ban\" | \"bell\" | \"bell-outline\" | \"book\" | \"book-outline\" | \"briefcase\" | \"briefcase-outline\" | \"building-outline\" | \"calculator\" | \"calculator-outline\" | \"calendar\" | \"calendar-euro\" | \"calendar-euro-outline\" | \"calendar-outline\" | \"check\" | \"check-circle\" | \"check-circle-outline\" | \"chevron-down\" | \"chevron-down-circle\" | \"chevron-left\" | \"chevron-left-circle\" | \"chevron-right\" | \"chevron-right-circle\" | \"chevron-up\" | \"chevron-up-circle\" | \"clock\" | \"clock-outline\" | \"code-square-outline\" | \"cog\" | \"cog-outline\" | \"comment\" | \"comment-exclamation\" | \"comment-exclamation-outline\" | \"comment-outline\" | \"comment-question\" | \"comment-question-outline\" | \"comment-sms\" | \"conversation\" | \"conversation-outline\" | \"copy-file\" | \"copy-file-outline\" | \"copy-outline\" | \"credit-card\" | \"cross\" | \"cross-circle\" | \"cross-circle-outline\" | \"dashboard\" | \"dashboard-outline\" | \"earth\" | \"earth-outline\" | \"ellipsis\" | \"ellipsis-vertical\" | \"euro\" | \"euro-circle\" | \"exclamation-circle\" | \"exclamation-circle-outline\" | \"exclamation-stamp\" | \"exclamation-triangle\" | \"exclamation-triangle-outline\" | \"eye\" | \"eye-outline\" | \"eye-slash\" | \"eye-slash-outline\" | \"fax\" | \"fax-outline\" | \"file\" | \"file-cog\" | \"file-download\" | \"file-excel\" | \"file-excel-outline\" | \"file-outline\" | \"file-pdf\" | \"file-pdf-outline\" | \"file-text\" | \"file-text-outline\" | \"file-upload\" | \"file-word\" | \"file-word-outline\" | \"filter-outline\" | \"floppy-disk\" | \"floppy-disk-checked\" | \"floppy-disk-checked-outline\" | \"floppy-disk-outline\" | \"folder\" | \"folder-check\" | \"folder-check-outline\" | \"folder-lines\" | \"folder-lines-outline\" | \"folder-link\" | \"folder-link-outline\" | \"folder-outline\" | \"folder-star\" | \"folders\" | \"folders-outline\" | \"gavel\" | \"gavel-outline\" | \"graduation-cap\" | \"graduation-cap-outline\" | \"hand-euro\" | \"hand-euro-outline\" | \"hand-up\" | \"home\" | \"home-outline\" | \"info-circle\" | \"info-circle-outline\" | \"interrogation-circle\" | \"interrogation-circle-outline\" | \"laptop\" | \"layers\" | \"life-ring\" | \"lines-rectangle\" | \"lines-rectangle-outline\" | \"location-outline\" | \"lock\" | \"lock-outline\" | \"log-in\" | \"log-out\" | \"magnifying-glass\" | \"mail\" | \"mail-open\" | \"mail-open-outline\" | \"mail-outline\" | \"messages-square\" | \"messages-square-outline\" | \"mobile\" | \"mobile-outline\" | \"notes\" | \"notes-outline\" | \"paper-plane\" | \"paper-plane-outline\" | \"paper-plane-slash\" | \"paper-plane-slash-outline\" | \"paperclip\" | \"pen\" | \"pen-circle\" | \"pen-fancy\" | \"pen-fancy-files-outline\" | \"pen-fancy-outline\" | \"pen-outline\" | \"phone\" | \"phone-outline\" | \"picture-outline\" | \"play-circle\" | \"plus\" | \"plus-circle\" | \"share\" | \"share-outline\" | \"shuffle\" | \"sitemap\" | \"sliders\" | \"sliders-outline\" | \"squares\" | \"star\" | \"star-outline\" | \"tag\" | \"tag-outline\" | \"tags\" | \"tags-outline\" | \"thumb-down\" | \"thumb-down-outline\" | \"thumb-up\" | \"thumb-up-outline\" | \"thumbtack\" | \"thumbtack-outline\" | \"trash\" | \"trash-outline\" | \"universal-access\" | \"universal-access-outline\" | \"unlink\" | \"unlock\" | \"unlock-outline\" | \"upload\" | \"user\" | \"user-circle\" | \"user-group\" | \"user-group-outline\" | \"user-lock\" | \"user-outline\" | \"user-pen-fancy-outline\" | \"user-plus\" | \"user-question-outline\" | \"user-shield\" | \"user-shield-outline\" | \"users\" | \"users-outline\" | \"wallet\" | \"wallet-outline\"; }",
|
|
107
|
+
"resolved": "{ icon: \"filter\" | \"link\" | \"picture\" | \"table\" | \"circle\" | \"download\" | \"key\" | \"list\" | \"copy\" | \"history\" | \"location\" | \"loader\" | \"address-card\" | \"address-card-outline\" | \"align-center\" | \"align-justify\" | \"align-left\" | \"align-right\" | \"api\" | \"archive\" | \"archive-outline\" | \"arrow-clock\" | \"arrow-down\" | \"arrow-down-a-z\" | \"arrow-down-right\" | \"arrow-left\" | \"arrow-right\" | \"arrow-rotate\" | \"arrow-rotate-backward\" | \"arrow-up\" | \"arrow-up-right\" | \"arrow-up-right-square\" | \"arrow-up-z-a\" | \"arrows-compare\" | \"arrows-right-down\" | \"arrows-right-left\" | \"arrows-rotate\" | \"arrows-rotate-backward\" | \"arrows-up-down\" | \"ban\" | \"bell\" | \"bell-outline\" | \"book\" | \"book-outline\" | \"briefcase\" | \"briefcase-outline\" | \"building\" | \"building-outline\" | \"calculator\" | \"calculator-outline\" | \"calendar\" | \"calendar-euro\" | \"calendar-euro-outline\" | \"calendar-outline\" | \"check\" | \"check-circle\" | \"check-circle-outline\" | \"chevron-down\" | \"chevron-down-circle\" | \"chevron-left\" | \"chevron-left-circle\" | \"chevron-right\" | \"chevron-right-circle\" | \"chevron-up\" | \"chevron-up-circle\" | \"clock\" | \"clock-outline\" | \"code-square-outline\" | \"cog\" | \"cog-outline\" | \"comment\" | \"comment-exclamation\" | \"comment-exclamation-outline\" | \"comment-outline\" | \"comment-question\" | \"comment-question-outline\" | \"comment-sms\" | \"comment-sms-outline\" | \"conversation\" | \"conversation-outline\" | \"copy-file\" | \"copy-file-outline\" | \"copy-outline\" | \"credit-card\" | \"cross\" | \"cross-circle\" | \"cross-circle-outline\" | \"dashboard\" | \"dashboard-outline\" | \"earth\" | \"earth-outline\" | \"ellipsis\" | \"ellipsis-vertical\" | \"euro\" | \"euro-circle\" | \"exclamation-circle\" | \"exclamation-circle-outline\" | \"exclamation-stamp\" | \"exclamation-triangle\" | \"exclamation-triangle-outline\" | \"eye\" | \"eye-outline\" | \"eye-slash\" | \"eye-slash-outline\" | \"fax\" | \"fax-outline\" | \"file\" | \"file-cog\" | \"file-cog-outline\" | \"file-download\" | \"file-download-outline\" | \"file-excel\" | \"file-excel-outline\" | \"file-outline\" | \"file-pdf\" | \"file-pdf-outline\" | \"file-text\" | \"file-text-outline\" | \"file-upload\" | \"file-upload-outline\" | \"file-word\" | \"file-word-outline\" | \"filter-outline\" | \"floppy-disk\" | \"floppy-disk-checked\" | \"floppy-disk-checked-outline\" | \"floppy-disk-outline\" | \"folder\" | \"folder-check\" | \"folder-check-outline\" | \"folder-lines\" | \"folder-lines-outline\" | \"folder-link\" | \"folder-link-outline\" | \"folder-outline\" | \"folder-star\" | \"folder-star-outline\" | \"folders\" | \"folders-outline\" | \"gavel\" | \"gavel-outline\" | \"graduation-cap\" | \"graduation-cap-outline\" | \"hand-euro\" | \"hand-euro-outline\" | \"hand-up\" | \"home\" | \"home-outline\" | \"info-circle\" | \"info-circle-outline\" | \"interrogation-circle\" | \"interrogation-circle-outline\" | \"laptop\" | \"layers\" | \"life-ring\" | \"lines-rectangle\" | \"lines-rectangle-outline\" | \"location-outline\" | \"lock\" | \"lock-outline\" | \"log-in\" | \"log-out\" | \"magnifying-glass\" | \"mail\" | \"mail-open\" | \"mail-open-outline\" | \"mail-outline\" | \"messages-square\" | \"messages-square-outline\" | \"mobile\" | \"mobile-outline\" | \"notes\" | \"notes-outline\" | \"paper-plane\" | \"paper-plane-outline\" | \"paper-plane-slash\" | \"paper-plane-slash-outline\" | \"paperclip\" | \"pen\" | \"pen-circle\" | \"pen-fancy\" | \"pen-fancy-files-outline\" | \"pen-fancy-outline\" | \"pen-outline\" | \"phone\" | \"phone-outline\" | \"picture-outline\" | \"play-circle\" | \"plus\" | \"plus-circle\" | \"plus-circle-outline\" | \"share\" | \"share-outline\" | \"shuffle\" | \"sidebar-arrow-left\" | \"sidebar-arrow-right\" | \"sitemap\" | \"sliders\" | \"sliders-outline\" | \"squares\" | \"star\" | \"star-outline\" | \"tag\" | \"tag-outline\" | \"tags\" | \"tags-outline\" | \"thumb-down\" | \"thumb-down-outline\" | \"thumb-up\" | \"thumb-up-outline\" | \"thumbtack\" | \"thumbtack-outline\" | \"trash\" | \"trash-outline\" | \"universal-access\" | \"universal-access-outline\" | \"unlink\" | \"unlock\" | \"unlock-outline\" | \"upload\" | \"user\" | \"user-circle\" | \"user-group\" | \"user-group-outline\" | \"user-lock\" | \"user-outline\" | \"user-pen-fancy-outline\" | \"user-plus\" | \"user-question-outline\" | \"user-shield\" | \"user-shield-outline\" | \"users\" | \"users-outline\" | \"wallet\" | \"wallet-outline\"; }",
|
|
108
108
|
"references": {
|
|
109
109
|
"IconType": {
|
|
110
110
|
"location": "import",
|
|
@@ -102,6 +102,10 @@ export class MgMenu {
|
|
|
102
102
|
* @param event - mg-item-loaded "item-loaded" custom event
|
|
103
103
|
*/
|
|
104
104
|
updateItemListener(event) {
|
|
105
|
+
// `<mg-action-more>` element doesn't need `data-has-focus` attribute
|
|
106
|
+
if (event.target.nodeName === 'MG-ACTION-MORE') {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
105
109
|
const itemToWatch = event.target.nodeName === 'MG-ITEM-MORE' ? event.target.shadowRoot.querySelector('mg-menu-item') : event.target;
|
|
106
110
|
['click', 'focus'].forEach(trigger => {
|
|
107
111
|
itemToWatch.addEventListener(trigger, () => {
|
|
@@ -162,7 +166,7 @@ export class MgMenu {
|
|
|
162
166
|
* @returns HTML Element
|
|
163
167
|
*/
|
|
164
168
|
render() {
|
|
165
|
-
return (h(Host, { key: '
|
|
169
|
+
return (h(Host, { key: '753833b01b86d6983f5d063f5598e2187b147a6e', role: "list", "aria-label": this.label }, h("slot", { key: '56702e49f5a97feddeb66e6271bd898061aa0d48' })));
|
|
166
170
|
}
|
|
167
171
|
static get is() { return "mg-menu"; }
|
|
168
172
|
static get encapsulation() { return "shadow"; }
|