@mgdis/mg-components 6.17.0 → 6.18.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 +4 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_37.cjs.entry.js +411 -168
- package/dist/cjs/mg-alert.cjs.entry.js +1 -1
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
- package/dist/cjs/mg-input-combobox.cjs.entry.js +71 -55
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +33 -20
- package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-HYIzRsy7.js} +5 -0
- package/dist/cjs/mg-loader.cjs.entry.js +1 -1
- package/dist/cjs/mg-progress.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +4 -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 +78 -55
- 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 +40 -20
- 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 +44 -25
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +31 -13
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +36 -11
- 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 +1 -1
- 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-illustrated-message.js +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +1 -1
- package/dist/components/mg-input-checkbox.js +28 -15
- package/dist/components/mg-input-combobox.js +71 -55
- package/dist/components/mg-input-date.js +33 -21
- package/dist/components/mg-input-numeric.js +24 -11
- package/dist/components/mg-input-password.js +22 -11
- package/dist/components/mg-input-radio.js +23 -11
- package/dist/components/mg-input-rich-text-editor.js +32 -19
- package/dist/components/mg-input-select2.js +24 -12
- package/dist/components/mg-input-text2.js +36 -24
- package/dist/components/mg-input-textarea.js +23 -12
- package/dist/components/mg-input-toggle.js +35 -10
- package/dist/components/mg-input2.js +117 -18
- 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 +2 -2
- package/dist/components/mg-panel.js +36 -7
- package/dist/components/mg-popover-content2.js +1 -1
- package/dist/components/mg-popover2.js +1 -1
- 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-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
- package/dist/esm/index-T6kOJXP1.js +4 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_37.entry.js +412 -169
- package/dist/esm/mg-alert.entry.js +2 -2
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-fieldset.entry.js +139 -0
- package/dist/esm/mg-input-combobox.entry.js +72 -56
- package/dist/esm/mg-input-rich-text-editor.entry.js +34 -21
- package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-D9V2v4n2.js} +5 -1
- package/dist/esm/mg-loader.entry.js +2 -2
- package/dist/esm/mg-progress.entry.js +2 -2
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-2bab89c2.entry.js +1 -0
- package/dist/mg-components/{p-0e6b40d6.entry.js → p-5abc77cd.entry.js} +1 -1
- package/dist/mg-components/p-7d2e43b2.entry.js +1 -0
- package/dist/mg-components/{p-5dc3a1fb.entry.js → p-92e5e5a6.entry.js} +1 -1
- package/dist/mg-components/{p-c5da335e.entry.js → p-952288bd.entry.js} +1 -1
- package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
- package/dist/mg-components/p-D9V2v4n2.js +1 -0
- package/dist/mg-components/p-f2cddd52.entry.js +1 -0
- package/dist/mg-components/{p-397bf67b.entry.js → p-f6afaeb8.entry.js} +1 -1
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +5 -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.d.ts +4 -2
- 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 -2
- 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 +4 -2
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -2
- 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 +272 -9
- package/ide/vscode/html-custom-data.json +243 -5
- package/package.json +15 -15
- package/dist/mg-components/p-8a69175b.entry.js +0 -1
- package/dist/mg-components/p-CNgv8hc5.js +0 -1
- package/dist/mg-components/p-d84d87ea.entry.js +0 -1
|
@@ -48,6 +48,7 @@ export class MgInputCombobox {
|
|
|
48
48
|
this.classFocus = 'mg-u-is-focused';
|
|
49
49
|
// hasDisplayedError (triggered by blur event)
|
|
50
50
|
this.hasDisplayedError = false;
|
|
51
|
+
this.customErrorMessage = { lock: false };
|
|
51
52
|
/**
|
|
52
53
|
* Input name
|
|
53
54
|
* If not set the value equals the identifier
|
|
@@ -182,7 +183,7 @@ export class MgInputCombobox {
|
|
|
182
183
|
// override keys actions
|
|
183
184
|
switch (event.key) {
|
|
184
185
|
case Keys.TAB:
|
|
185
|
-
case Keys.ENTER:
|
|
186
|
+
case Keys.ENTER: {
|
|
186
187
|
guard = event.key === Keys.ENTER;
|
|
187
188
|
const option = (_a = this.option) !== null && _a !== void 0 ? _a : this.options.items.find(this.isCurrentOption);
|
|
188
189
|
// Sets the value to the content of the focused option in the listbox.
|
|
@@ -192,12 +193,13 @@ export class MgInputCombobox {
|
|
|
192
193
|
// Closes the popover.
|
|
193
194
|
this.popoverDisplay = false;
|
|
194
195
|
break;
|
|
196
|
+
}
|
|
195
197
|
case Keys.DOWN:
|
|
196
198
|
case Keys.ARROWDOWN:
|
|
197
199
|
case Keys.UP:
|
|
198
|
-
case Keys.ARROWUP:
|
|
200
|
+
case Keys.ARROWUP: {
|
|
199
201
|
guard = true;
|
|
200
|
-
if (this.isLoading ||
|
|
202
|
+
if (this.isLoading || this.page.total === 0) {
|
|
201
203
|
this.popoverDisplay = true;
|
|
202
204
|
break;
|
|
203
205
|
}
|
|
@@ -228,12 +230,13 @@ export class MgInputCombobox {
|
|
|
228
230
|
// open popover
|
|
229
231
|
this.popoverDisplay = true;
|
|
230
232
|
break;
|
|
233
|
+
}
|
|
231
234
|
case Keys.LEFT:
|
|
232
235
|
case Keys.ARROWLEFT:
|
|
233
236
|
case Keys.HOME:
|
|
234
237
|
case Keys.RIGHT:
|
|
235
238
|
case Keys.ARROWRIGHT:
|
|
236
|
-
case Keys.END:
|
|
239
|
+
case Keys.END: {
|
|
237
240
|
// skip process if visual focus is not in popover
|
|
238
241
|
if (!isItem(this.option))
|
|
239
242
|
break;
|
|
@@ -253,8 +256,9 @@ export class MgInputCombobox {
|
|
|
253
256
|
this.input.setSelectionRange(index, index);
|
|
254
257
|
}
|
|
255
258
|
break;
|
|
259
|
+
}
|
|
256
260
|
case Keys.ESC:
|
|
257
|
-
case Keys.ESCAPE:
|
|
261
|
+
case Keys.ESCAPE: {
|
|
258
262
|
guard = true;
|
|
259
263
|
if (this.popoverDisplay) {
|
|
260
264
|
// If the popover is displayed, closes it.
|
|
@@ -268,10 +272,12 @@ export class MgInputCombobox {
|
|
|
268
272
|
this.option = null;
|
|
269
273
|
}
|
|
270
274
|
break;
|
|
271
|
-
|
|
275
|
+
}
|
|
276
|
+
default: {
|
|
272
277
|
// Remove visual focus from popover options
|
|
273
278
|
this.option = null;
|
|
274
279
|
break;
|
|
280
|
+
}
|
|
275
281
|
}
|
|
276
282
|
if (guard) {
|
|
277
283
|
event.stopPropagation();
|
|
@@ -317,18 +323,20 @@ export class MgInputCombobox {
|
|
|
317
323
|
};
|
|
318
324
|
/**
|
|
319
325
|
* Set input error message
|
|
320
|
-
* @param
|
|
326
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
321
327
|
*/
|
|
322
|
-
this.setErrorMessage = (
|
|
328
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
323
329
|
// Set error message
|
|
324
330
|
this.errorMessage = undefined;
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
this.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
331
|
+
if (!this.valid) {
|
|
332
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
333
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
334
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
335
|
+
}
|
|
336
|
+
// required
|
|
337
|
+
else if (this.input.validity.valueMissing) {
|
|
338
|
+
this.errorMessage = this.messages.errors.required;
|
|
339
|
+
}
|
|
332
340
|
}
|
|
333
341
|
};
|
|
334
342
|
/**
|
|
@@ -342,15 +350,14 @@ export class MgInputCombobox {
|
|
|
342
350
|
* @returns promisified action
|
|
343
351
|
*/
|
|
344
352
|
this.loadingWrapper = (action) => {
|
|
353
|
+
var _a;
|
|
345
354
|
let promise;
|
|
346
355
|
let index;
|
|
347
356
|
// cache initial loading action if not defined
|
|
348
|
-
|
|
349
|
-
this.loadingAction = action.name;
|
|
350
|
-
}
|
|
357
|
+
(_a = this.loadingAction) !== null && _a !== void 0 ? _a : (this.loadingAction = action.name);
|
|
351
358
|
// update index
|
|
352
359
|
if (Boolean(this.option) && this.loadingAction !== 'load-more') {
|
|
353
|
-
index = this.page.items.findIndex(option => option.value
|
|
360
|
+
index = this.page.items.findIndex(option => toString(option.value) === toString(this.option.value));
|
|
354
361
|
}
|
|
355
362
|
else if (this.loadingAction === 'load-more') {
|
|
356
363
|
index = this.page.items.length - this.page.baseIndex;
|
|
@@ -403,14 +410,14 @@ export class MgInputCombobox {
|
|
|
403
410
|
*/
|
|
404
411
|
this.goToNextPage = () => {
|
|
405
412
|
this.showMore.emit();
|
|
406
|
-
if (
|
|
413
|
+
if (this.fetchurl !== undefined) {
|
|
407
414
|
return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then(nextPage => {
|
|
408
|
-
if (
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
415
|
+
if (nextPage !== undefined) {
|
|
416
|
+
// merge items from current page and next page
|
|
417
|
+
const items = [...this.page.items, ...nextPage.items];
|
|
418
|
+
// create new options pagination withe merged items
|
|
419
|
+
this.options = new Paginate(items, { total: nextPage.total, next: nextPage.next, top: items.length });
|
|
420
|
+
}
|
|
414
421
|
});
|
|
415
422
|
}
|
|
416
423
|
else {
|
|
@@ -427,12 +434,12 @@ export class MgInputCombobox {
|
|
|
427
434
|
* @returns promise
|
|
428
435
|
*/
|
|
429
436
|
this.updatePage = async () => {
|
|
430
|
-
if (
|
|
437
|
+
if (this.fetchurl !== undefined) {
|
|
431
438
|
return this.getOptions().then(page => {
|
|
432
|
-
if (
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
439
|
+
if (page !== undefined) {
|
|
440
|
+
// reset current options pagination from API response
|
|
441
|
+
this.options = new Paginate(page.items, { total: page.total, next: page.next, top: page.top });
|
|
442
|
+
}
|
|
436
443
|
});
|
|
437
444
|
}
|
|
438
445
|
else {
|
|
@@ -478,11 +485,11 @@ export class MgInputCombobox {
|
|
|
478
485
|
this.valueChange.emit(newValue);
|
|
479
486
|
}
|
|
480
487
|
watchItems(newValue) {
|
|
481
|
-
if (
|
|
488
|
+
if (this.fetchurl !== undefined && newValue === undefined) {
|
|
482
489
|
// skip newValue check
|
|
483
490
|
return;
|
|
484
491
|
}
|
|
485
|
-
else if (
|
|
492
|
+
else if (this.fetchurl !== undefined && newValue !== undefined) {
|
|
486
493
|
throw new Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${toString(newValue)}.`);
|
|
487
494
|
}
|
|
488
495
|
// Empty options
|
|
@@ -502,7 +509,7 @@ export class MgInputCombobox {
|
|
|
502
509
|
}
|
|
503
510
|
}
|
|
504
511
|
watchIdentifier(newValue) {
|
|
505
|
-
if (
|
|
512
|
+
if (isValidString(newValue)) {
|
|
506
513
|
this.popoverId = `${newValue}-popover`;
|
|
507
514
|
this.element.dataset.mgPopoverGuard = this.popoverId;
|
|
508
515
|
}
|
|
@@ -542,7 +549,7 @@ export class MgInputCombobox {
|
|
|
542
549
|
this.classCollection = new ClassList(this.classCollection.classes);
|
|
543
550
|
}
|
|
544
551
|
watchFetchUrl(newValue) {
|
|
545
|
-
if (
|
|
552
|
+
if (newValue !== undefined) {
|
|
546
553
|
this.loadingWrapper({ name: 'load-data' });
|
|
547
554
|
}
|
|
548
555
|
}
|
|
@@ -550,20 +557,17 @@ export class MgInputCombobox {
|
|
|
550
557
|
if (this.fetchurl && newValue && !isObject(newValue)) {
|
|
551
558
|
throw new Error(`<mg-input-combobox> prop "fetchoptions" value must be a valid RequestInit. Passed value: ${toString(newValue)}.`);
|
|
552
559
|
}
|
|
553
|
-
else {
|
|
554
|
-
new Request(this.fetchurl, newValue);
|
|
555
|
-
}
|
|
556
560
|
}
|
|
557
561
|
watchFetchMappings(newValue) {
|
|
558
|
-
if (
|
|
562
|
+
if (this.fetchurl !== undefined && !isObject(newValue)) {
|
|
559
563
|
throw new Error(`<mg-input-combobox> prop "fetchmappings" is required with "fetchurl" prop.`);
|
|
560
564
|
}
|
|
561
|
-
else if (
|
|
565
|
+
else if (newValue !== undefined && !isFetchmappings(newValue)) {
|
|
562
566
|
throw new Error(`<mg-input-combobox> prop "fetchmappings" value must be { request: RequestMappingType, response: ResponseMappingType }. Passed value: ${toString(newValue)}.`);
|
|
563
567
|
}
|
|
564
568
|
}
|
|
565
569
|
watchOptions(newValue) {
|
|
566
|
-
this.page = newValue.getPage(0,
|
|
570
|
+
this.page = newValue.getPage(0, this.filter.length > 0 ? this.optionsFilter : undefined);
|
|
567
571
|
}
|
|
568
572
|
watchFilter(newValue) {
|
|
569
573
|
this.loadingWrapper({ name: 'load-data' });
|
|
@@ -620,17 +624,22 @@ export class MgInputCombobox {
|
|
|
620
624
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
621
625
|
* @param valid - value indicating the validity
|
|
622
626
|
* @param errorMessage - the error message to display
|
|
627
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
623
628
|
*/
|
|
624
|
-
async setError(valid, errorMessage) {
|
|
629
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
625
630
|
if (typeof valid !== 'boolean') {
|
|
626
631
|
throw new Error('<mg-input-combobox> method "setError()" param "valid" must be a boolean.');
|
|
627
632
|
}
|
|
628
|
-
else if (!isValidString(errorMessage)) {
|
|
633
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
629
634
|
throw new Error('<mg-input-combobox> method "setError()" param "errorMessage" must be a string.');
|
|
630
635
|
}
|
|
631
636
|
else {
|
|
637
|
+
this.customErrorMessage = {
|
|
638
|
+
lock: valid ? false : errorMessageLock,
|
|
639
|
+
message: valid ? undefined : errorMessage,
|
|
640
|
+
};
|
|
632
641
|
this.setValidity(valid);
|
|
633
|
-
this.setErrorMessage(
|
|
642
|
+
this.setErrorMessage(true);
|
|
634
643
|
this.hasDisplayedError = this.invalid;
|
|
635
644
|
}
|
|
636
645
|
}
|
|
@@ -650,6 +659,8 @@ export class MgInputCombobox {
|
|
|
650
659
|
// - Keep everything in sync both inside and outside the component
|
|
651
660
|
return new Promise(resolve => {
|
|
652
661
|
requestAnimationFrame(() => {
|
|
662
|
+
// unlock validity check by reseting customErrorMessage
|
|
663
|
+
this.customErrorMessage = { lock: false };
|
|
653
664
|
this.checkValidity();
|
|
654
665
|
this.errorMessage = undefined;
|
|
655
666
|
this.hasDisplayedError = false;
|
|
@@ -678,11 +689,13 @@ export class MgInputCombobox {
|
|
|
678
689
|
* @param newValue - valid new value
|
|
679
690
|
*/
|
|
680
691
|
setValidity(newValue) {
|
|
681
|
-
const
|
|
682
|
-
this.
|
|
692
|
+
const oldValue = this.valid;
|
|
693
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
694
|
+
this.valid = newValue;
|
|
695
|
+
}
|
|
683
696
|
this.invalid = !this.valid;
|
|
684
697
|
// We need to send valid event even if it is the same value
|
|
685
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
698
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
686
699
|
this.inputValid.emit(this.valid);
|
|
687
700
|
}
|
|
688
701
|
/*************
|
|
@@ -698,7 +711,7 @@ export class MgInputCombobox {
|
|
|
698
711
|
// Validate
|
|
699
712
|
this.watchIdentifier(this.identifier);
|
|
700
713
|
this.watchItems(this.items);
|
|
701
|
-
if (
|
|
714
|
+
if (this.fetchurl !== undefined) {
|
|
702
715
|
this.watchFetchOptions(this.fetchoptions);
|
|
703
716
|
this.watchFetchMappings(this.fetchmappings);
|
|
704
717
|
this.loadingWrapper({ name: 'load-data' });
|
|
@@ -725,14 +738,17 @@ export class MgInputCombobox {
|
|
|
725
738
|
const readonlyValue = this.getValueTitle();
|
|
726
739
|
const withResetButton = this.value && !this.disabled;
|
|
727
740
|
let popoverContent;
|
|
728
|
-
if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0)
|
|
741
|
+
if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0) {
|
|
729
742
|
popoverContent = 'list';
|
|
730
|
-
|
|
743
|
+
}
|
|
744
|
+
else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && this.filter.length > 0) {
|
|
731
745
|
popoverContent = 'notfound';
|
|
732
|
-
|
|
746
|
+
}
|
|
747
|
+
else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0) {
|
|
733
748
|
popoverContent = 'notavailable';
|
|
749
|
+
}
|
|
734
750
|
let activeDescendant;
|
|
735
|
-
if (
|
|
751
|
+
if (((_d = this.option) === null || _d === void 0 ? void 0 : _d.value) !== undefined) {
|
|
736
752
|
activeDescendant = this.option.value;
|
|
737
753
|
}
|
|
738
754
|
else if (typeof this.value === 'string') {
|
|
@@ -741,8 +757,8 @@ export class MgInputCombobox {
|
|
|
741
757
|
else {
|
|
742
758
|
activeDescendant = (_e = this.value) === null || _e === void 0 ? void 0 : _e.value;
|
|
743
759
|
}
|
|
744
|
-
return (h("mg-input", { key: '
|
|
745
|
-
'--mg-c-input-list-width':
|
|
760
|
+
return (h("mg-input", { key: 'bebf380dbdea1a9f9e0257a9425dcb6cd94a7a52', label: this.label, identifier: this.identifier, class: this.classCollection.classes.join(' '), ariaDescribedbyIDs: popoverContent && popoverContent !== 'list' ? popoverContent : undefined, 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 ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
|
|
761
|
+
'--mg-c-input-list-width': ((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) > 0 ? `${this.input.offsetWidth}px` : undefined,
|
|
746
762
|
}, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, h("div", { class: "mg-c-input__input-group-container" }, h("mg-icon", { icon: "magnifying-glass" }), h("input", { type: "text", role: "combobox", class: "mg-c-input__box mg-c-input__box--width", value: this.filter, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-autocomplete": "list", "aria-expanded": this.popoverDisplay.toString(), "aria-controls": listId, "aria-invalid": (this.invalid === true).toString(), "aria-activedescendant": formatID(activeDescendant), onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
|
|
747
763
|
if (el !== null)
|
|
748
764
|
this.input = el;
|
|
@@ -1384,7 +1400,7 @@ export class MgInputCombobox {
|
|
|
1384
1400
|
},
|
|
1385
1401
|
"setError": {
|
|
1386
1402
|
"complexType": {
|
|
1387
|
-
"signature": "(valid: MgInputCombobox[\"valid\"], errorMessage
|
|
1403
|
+
"signature": "(valid: MgInputCombobox[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
|
|
1388
1404
|
"parameters": [{
|
|
1389
1405
|
"name": "valid",
|
|
1390
1406
|
"type": "boolean",
|
|
@@ -1393,6 +1409,10 @@ export class MgInputCombobox {
|
|
|
1393
1409
|
"name": "errorMessage",
|
|
1394
1410
|
"type": "string",
|
|
1395
1411
|
"docs": "- the error message to display"
|
|
1412
|
+
}, {
|
|
1413
|
+
"name": "errorMessageLock",
|
|
1414
|
+
"type": "boolean",
|
|
1415
|
+
"docs": "- lock the error message and validity state"
|
|
1396
1416
|
}],
|
|
1397
1417
|
"references": {
|
|
1398
1418
|
"Promise": {
|
|
@@ -1414,6 +1434,9 @@ export class MgInputCombobox {
|
|
|
1414
1434
|
}, {
|
|
1415
1435
|
"name": "param",
|
|
1416
1436
|
"text": "errorMessage - the error message to display"
|
|
1437
|
+
}, {
|
|
1438
|
+
"name": "param",
|
|
1439
|
+
"text": "errorMessageLock - lock the error message and validity state"
|
|
1417
1440
|
}]
|
|
1418
1441
|
}
|
|
1419
1442
|
},
|
|
@@ -8,6 +8,7 @@ export class MgInputDate {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
// hasDisplayedError (triggered by blur event)
|
|
10
10
|
this.hasDisplayedError = false;
|
|
11
|
+
this.customErrorMessage = { lock: false };
|
|
11
12
|
/**
|
|
12
13
|
* Input name
|
|
13
14
|
* If not set the value equals the identifier
|
|
@@ -120,39 +121,41 @@ export class MgInputDate {
|
|
|
120
121
|
*/
|
|
121
122
|
this.getInputError = () => {
|
|
122
123
|
var _a;
|
|
124
|
+
let error;
|
|
123
125
|
// bad input or pattern
|
|
124
126
|
if (this.input.validity.badInput || (this.value && !this.isValidPattern(this.value))) {
|
|
125
|
-
|
|
127
|
+
error = 'badInput';
|
|
126
128
|
}
|
|
127
129
|
// required
|
|
128
|
-
if (this.input.validity.valueMissing) {
|
|
129
|
-
|
|
130
|
+
else if (this.input.validity.valueMissing) {
|
|
131
|
+
error = 'required';
|
|
130
132
|
}
|
|
131
133
|
// min & max
|
|
132
|
-
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) {
|
|
133
|
-
|
|
134
|
+
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) {
|
|
135
|
+
error = 'minMax';
|
|
134
136
|
}
|
|
135
137
|
// min
|
|
136
|
-
if (this.input.validity.rangeUnderflow) {
|
|
137
|
-
|
|
138
|
+
else if (this.input.validity.rangeUnderflow) {
|
|
139
|
+
error = 'min';
|
|
138
140
|
}
|
|
139
141
|
// max
|
|
140
|
-
if (this.input.validity.rangeOverflow) {
|
|
141
|
-
|
|
142
|
+
else if (this.input.validity.rangeOverflow) {
|
|
143
|
+
error = 'max';
|
|
142
144
|
}
|
|
143
|
-
return
|
|
145
|
+
return error;
|
|
144
146
|
};
|
|
145
147
|
/**
|
|
146
148
|
* Check input errors
|
|
147
|
-
* @param
|
|
149
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
148
150
|
*/
|
|
149
|
-
this.setErrorMessage = (
|
|
151
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
150
152
|
// Set error message
|
|
151
153
|
this.errorMessage = undefined;
|
|
152
154
|
if (!this.valid) {
|
|
153
155
|
const inputError = this.getInputError();
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
157
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
158
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
156
159
|
}
|
|
157
160
|
// required
|
|
158
161
|
else if (inputError === 'required') {
|
|
@@ -264,17 +267,22 @@ export class MgInputDate {
|
|
|
264
267
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
265
268
|
* @param valid - value indicating the validity
|
|
266
269
|
* @param errorMessage - the error message to display
|
|
270
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
267
271
|
*/
|
|
268
|
-
async setError(valid, errorMessage) {
|
|
272
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
269
273
|
if (typeof valid !== 'boolean') {
|
|
270
274
|
throw new Error('<mg-input-date> method "setError()" param "valid" must be a boolean.');
|
|
271
275
|
}
|
|
272
|
-
else if (!isValidString(errorMessage)) {
|
|
276
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
273
277
|
throw new Error('<mg-input-date> method "setError()" param "errorMessage" must be a string.');
|
|
274
278
|
}
|
|
275
279
|
else {
|
|
280
|
+
this.customErrorMessage = {
|
|
281
|
+
lock: valid ? false : errorMessageLock,
|
|
282
|
+
message: valid ? undefined : errorMessage,
|
|
283
|
+
};
|
|
276
284
|
this.setValidity(valid);
|
|
277
|
-
this.setErrorMessage(
|
|
285
|
+
this.setErrorMessage(true);
|
|
278
286
|
this.hasDisplayedError = this.invalid;
|
|
279
287
|
}
|
|
280
288
|
}
|
|
@@ -292,6 +300,8 @@ export class MgInputDate {
|
|
|
292
300
|
// - Keep everything in sync both inside and outside the component
|
|
293
301
|
return new Promise(resolve => {
|
|
294
302
|
requestAnimationFrame(() => {
|
|
303
|
+
// unlock validity check by reseting customErrorMessage
|
|
304
|
+
this.customErrorMessage = { lock: false };
|
|
295
305
|
this.checkValidity();
|
|
296
306
|
this.errorMessage = undefined;
|
|
297
307
|
this.hasDisplayedError = false;
|
|
@@ -305,11 +315,13 @@ export class MgInputDate {
|
|
|
305
315
|
* @param newValue - valid new value
|
|
306
316
|
*/
|
|
307
317
|
setValidity(newValue) {
|
|
308
|
-
const
|
|
309
|
-
this.
|
|
318
|
+
const oldValue = this.valid;
|
|
319
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
320
|
+
this.valid = newValue;
|
|
321
|
+
}
|
|
310
322
|
this.invalid = !this.valid;
|
|
311
323
|
// We need to send valid event even if it is the same value
|
|
312
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
324
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
313
325
|
this.inputValid.emit(this.valid);
|
|
314
326
|
}
|
|
315
327
|
/*************
|
|
@@ -345,7 +357,7 @@ export class MgInputDate {
|
|
|
345
357
|
* @returns HTML Element
|
|
346
358
|
*/
|
|
347
359
|
render() {
|
|
348
|
-
return (h("mg-input", { key: '
|
|
360
|
+
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) => {
|
|
349
361
|
if (el !== null)
|
|
350
362
|
this.input = el;
|
|
351
363
|
} }))));
|
|
@@ -771,7 +783,7 @@ export class MgInputDate {
|
|
|
771
783
|
},
|
|
772
784
|
"setError": {
|
|
773
785
|
"complexType": {
|
|
774
|
-
"signature": "(valid: MgInputDate[\"valid\"], errorMessage
|
|
786
|
+
"signature": "(valid: MgInputDate[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
|
|
775
787
|
"parameters": [{
|
|
776
788
|
"name": "valid",
|
|
777
789
|
"type": "boolean",
|
|
@@ -780,6 +792,10 @@ export class MgInputDate {
|
|
|
780
792
|
"name": "errorMessage",
|
|
781
793
|
"type": "string",
|
|
782
794
|
"docs": "- the error message to display"
|
|
795
|
+
}, {
|
|
796
|
+
"name": "errorMessageLock",
|
|
797
|
+
"type": "boolean",
|
|
798
|
+
"docs": "- lock the error message and validity state"
|
|
783
799
|
}],
|
|
784
800
|
"references": {
|
|
785
801
|
"Promise": {
|
|
@@ -801,6 +817,9 @@ export class MgInputDate {
|
|
|
801
817
|
}, {
|
|
802
818
|
"name": "param",
|
|
803
819
|
"text": "errorMessage - the error message to display"
|
|
820
|
+
}, {
|
|
821
|
+
"name": "param",
|
|
822
|
+
"text": "errorMessageLock - lock the error message and validity state"
|
|
804
823
|
}]
|
|
805
824
|
}
|
|
806
825
|
},
|
|
@@ -11,6 +11,7 @@ export class MgInputNumeric {
|
|
|
11
11
|
constructor() {
|
|
12
12
|
// hasDisplayedError (triggered by blur event)
|
|
13
13
|
this.hasDisplayedError = false;
|
|
14
|
+
this.customErrorMessage = { lock: false };
|
|
14
15
|
/**
|
|
15
16
|
* Input name
|
|
16
17
|
* If not set the value equals the identifier
|
|
@@ -116,19 +117,22 @@ export class MgInputNumeric {
|
|
|
116
117
|
this.formatErrorValue = (value) => localeNumber(value, this.locale, !Number.isInteger(value) && this.type === 'decimal' ? this.decimalLength : 0);
|
|
117
118
|
/**
|
|
118
119
|
* Set input error message
|
|
119
|
-
* @param
|
|
120
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
120
121
|
*/
|
|
121
|
-
this.setErrorMessage = (
|
|
122
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
122
123
|
// Set error message
|
|
123
124
|
this.errorMessage = undefined;
|
|
124
125
|
if (!this.valid) {
|
|
125
126
|
const inputError = this.getInputError();
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
128
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
129
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
128
130
|
}
|
|
131
|
+
// required
|
|
129
132
|
else if (inputError === 'required') {
|
|
130
133
|
this.errorMessage = this.messages.errors[inputError];
|
|
131
134
|
}
|
|
135
|
+
// min/max
|
|
132
136
|
else {
|
|
133
137
|
const formattedMin = this.formatErrorValue(this.min);
|
|
134
138
|
const formattedMax = this.formatErrorValue(this.max);
|
|
@@ -330,17 +334,22 @@ export class MgInputNumeric {
|
|
|
330
334
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
331
335
|
* @param valid - value indicating the validity
|
|
332
336
|
* @param errorMessage - the error message to display
|
|
337
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
333
338
|
*/
|
|
334
|
-
async setError(valid, errorMessage) {
|
|
339
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
335
340
|
if (typeof valid !== 'boolean') {
|
|
336
341
|
throw new Error('<mg-input-numeric> method "setError()" param "valid" must be a boolean.');
|
|
337
342
|
}
|
|
338
|
-
else if (!isValidString(errorMessage)) {
|
|
343
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
339
344
|
throw new Error('<mg-input-numeric> method "setError()" param "errorMessage" must be a string.');
|
|
340
345
|
}
|
|
341
346
|
else {
|
|
347
|
+
this.customErrorMessage = {
|
|
348
|
+
lock: valid ? false : errorMessageLock,
|
|
349
|
+
message: valid ? undefined : errorMessage,
|
|
350
|
+
};
|
|
342
351
|
this.setValidity(valid);
|
|
343
|
-
this.setErrorMessage(
|
|
352
|
+
this.setErrorMessage(true);
|
|
344
353
|
this.hasDisplayedError = this.invalid;
|
|
345
354
|
}
|
|
346
355
|
}
|
|
@@ -358,6 +367,8 @@ export class MgInputNumeric {
|
|
|
358
367
|
// - Keep everything in sync both inside and outside the component
|
|
359
368
|
return new Promise(resolve => {
|
|
360
369
|
requestAnimationFrame(() => {
|
|
370
|
+
// unlock validity check by reseting customErrorMessage
|
|
371
|
+
this.customErrorMessage = { lock: false };
|
|
361
372
|
this.checkValidity();
|
|
362
373
|
this.errorMessage = undefined;
|
|
363
374
|
this.hasDisplayedError = false;
|
|
@@ -371,11 +382,13 @@ export class MgInputNumeric {
|
|
|
371
382
|
* @param newValue - valid new value
|
|
372
383
|
*/
|
|
373
384
|
setValidity(newValue) {
|
|
374
|
-
const
|
|
375
|
-
this.
|
|
385
|
+
const oldValue = this.valid;
|
|
386
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
387
|
+
this.valid = newValue;
|
|
388
|
+
}
|
|
376
389
|
this.invalid = !this.valid;
|
|
377
390
|
// We need to send valid event even if it is the same value
|
|
378
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
391
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
379
392
|
this.inputValid.emit(this.valid);
|
|
380
393
|
}
|
|
381
394
|
/**
|
|
@@ -447,7 +460,7 @@ export class MgInputNumeric {
|
|
|
447
460
|
* @returns HTML Element
|
|
448
461
|
*/
|
|
449
462
|
render() {
|
|
450
|
-
return (h("mg-input", { key: '
|
|
463
|
+
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
|
|
451
464
|
? this.readonlyValue && this.renderReadonly()
|
|
452
465
|
: [
|
|
453
466
|
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) => {
|
|
@@ -1078,7 +1091,7 @@ export class MgInputNumeric {
|
|
|
1078
1091
|
},
|
|
1079
1092
|
"setError": {
|
|
1080
1093
|
"complexType": {
|
|
1081
|
-
"signature": "(valid: MgInputNumeric[\"valid\"], errorMessage
|
|
1094
|
+
"signature": "(valid: MgInputNumeric[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
|
|
1082
1095
|
"parameters": [{
|
|
1083
1096
|
"name": "valid",
|
|
1084
1097
|
"type": "boolean",
|
|
@@ -1087,6 +1100,10 @@ export class MgInputNumeric {
|
|
|
1087
1100
|
"name": "errorMessage",
|
|
1088
1101
|
"type": "string",
|
|
1089
1102
|
"docs": "- the error message to display"
|
|
1103
|
+
}, {
|
|
1104
|
+
"name": "errorMessageLock",
|
|
1105
|
+
"type": "boolean",
|
|
1106
|
+
"docs": "- lock the error message and validity state"
|
|
1090
1107
|
}],
|
|
1091
1108
|
"references": {
|
|
1092
1109
|
"Promise": {
|
|
@@ -1108,6 +1125,9 @@ export class MgInputNumeric {
|
|
|
1108
1125
|
}, {
|
|
1109
1126
|
"name": "param",
|
|
1110
1127
|
"text": "errorMessage - the error message to display"
|
|
1128
|
+
}, {
|
|
1129
|
+
"name": "param",
|
|
1130
|
+
"text": "errorMessageLock - lock the error message and validity state"
|
|
1111
1131
|
}]
|
|
1112
1132
|
}
|
|
1113
1133
|
},
|