@mgdis/mg-components 6.15.0 → 6.16.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.
Files changed (88) hide show
  1. package/dist/cjs/events.utils-D5SAtkpQ.js +25 -0
  2. package/dist/cjs/{index-BGxkpQwi.js → index-T3-qWqFE.js} +2 -2
  3. package/dist/cjs/{index-iUZvsp-F.js → index-YM1EJx9X.js} +8 -20
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/mg-action-more_37.cjs.entry.js +68 -305
  6. package/dist/cjs/mg-alert.cjs.entry.js +2 -2
  7. package/dist/cjs/mg-components.cjs.js +3 -3
  8. package/dist/cjs/mg-input-combobox.cjs.entry.js +78 -140
  9. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +3 -3
  10. package/dist/cjs/{mg-input.conf-CwjEAih3.js → mg-input.conf-WTsvDfpC.js} +0 -7
  11. package/dist/cjs/mg-loader.cjs.entry.js +2 -2
  12. package/dist/cjs/mg-progress.cjs.entry.js +1 -1
  13. package/dist/collection/collection-manifest.json +1 -1
  14. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +0 -6
  15. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +22 -93
  16. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +1 -2
  17. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +13 -69
  18. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +54 -136
  19. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -63
  20. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +6 -54
  21. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +9 -142
  22. package/dist/collection/locales/en/messages.json +3 -8
  23. package/dist/collection/locales/fr/messages.json +3 -8
  24. package/dist/components/index2.js +1 -1
  25. package/dist/components/index3.js +8 -20
  26. package/dist/components/mg-details.js +97 -1
  27. package/dist/components/mg-input-checkbox-paginated2.js +1 -2
  28. package/dist/components/mg-input-checkbox.js +19 -63
  29. package/dist/components/mg-input-combobox.js +60 -130
  30. package/dist/components/mg-input-date.js +1 -7
  31. package/dist/components/mg-input-numeric.js +1 -7
  32. package/dist/components/mg-input-password.js +2 -8
  33. package/dist/components/mg-input-radio.js +12 -53
  34. package/dist/components/mg-input-rich-text-editor.js +1 -7
  35. package/dist/components/mg-input-select2.js +8 -44
  36. package/dist/components/mg-input-text2.js +2 -8
  37. package/dist/components/mg-input-textarea.js +2 -8
  38. package/dist/components/mg-input-toggle.js +11 -96
  39. package/dist/components/mg-input2.js +22 -99
  40. package/dist/components/mg-pagination.js +2 -8
  41. package/dist/components/mg-panel.js +7 -13
  42. package/dist/esm/events.utils-yMGqY8YG.js +23 -0
  43. package/dist/esm/{index-CKB-AnCZ.js → index-Bab8_u8S.js} +8 -20
  44. package/dist/esm/{index-DhAOnZJn.js → index-JHj_9FSs.js} +2 -2
  45. package/dist/esm/loader.js +3 -3
  46. package/dist/esm/mg-action-more_37.entry.js +64 -301
  47. package/dist/esm/mg-alert.entry.js +2 -2
  48. package/dist/esm/mg-components.js +4 -4
  49. package/dist/esm/mg-input-combobox.entry.js +59 -121
  50. package/dist/esm/mg-input-rich-text-editor.entry.js +3 -3
  51. package/dist/esm/{mg-input.conf-BAUTlb6r.js → mg-input.conf-CNgv8hc5.js} +1 -7
  52. package/dist/esm/mg-loader.entry.js +2 -2
  53. package/dist/esm/mg-progress.entry.js +1 -1
  54. package/dist/mg-components/locales/en/messages.json +3 -8
  55. package/dist/mg-components/locales/fr/messages.json +3 -8
  56. package/dist/mg-components/mg-components.esm.js +1 -1
  57. package/dist/mg-components/{p-420daa1e.entry.js → p-42a90251.entry.js} +1 -1
  58. package/dist/mg-components/p-54156253.entry.js +1 -0
  59. package/dist/mg-components/{p-47e19783.entry.js → p-658f828c.entry.js} +1 -1
  60. package/dist/mg-components/{p-67af6274.entry.js → p-82455ac7.entry.js} +1 -1
  61. package/dist/mg-components/p-Bab8_u8S.js +1 -0
  62. package/dist/mg-components/p-CNgv8hc5.js +1 -0
  63. package/dist/mg-components/{p-DhAOnZJn.js → p-JHj_9FSs.js} +1 -1
  64. package/dist/mg-components/p-abbd151c.entry.js +1 -0
  65. package/dist/mg-components/{p-a0fa44cf.entry.js → p-c85b5d10.entry.js} +1 -1
  66. package/dist/mg-components/p-yMGqY8YG.js +1 -0
  67. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +0 -13
  68. package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +4 -15
  69. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +3 -21
  70. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +2 -16
  71. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +0 -18
  72. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +0 -18
  73. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -40
  74. package/dist/types/components.d.ts +7 -63
  75. package/ide/intellij/web-types.json +10 -136
  76. package/ide/vscode/html-custom-data.json +6 -104
  77. package/package.json +20 -20
  78. package/dist/cjs/mg-input.utils-D-ASK4ua.js +0 -49
  79. package/dist/collection/components/molecules/inputs/mg-input/mg-input.utils.js +0 -21
  80. package/dist/components/mg-details2.js +0 -99
  81. package/dist/components/mg-input.utils.js +0 -24
  82. package/dist/esm/mg-input.utils-BYI03zSi.js +0 -46
  83. package/dist/mg-components/p-31856cff.entry.js +0 -1
  84. package/dist/mg-components/p-698dfc6c.entry.js +0 -1
  85. package/dist/mg-components/p-BAUTlb6r.js +0 -1
  86. package/dist/mg-components/p-CKB-AnCZ.js +0 -1
  87. package/dist/mg-components/p-PuX-pdL4.js +0 -1
  88. package/dist/types/components/molecules/inputs/mg-input/mg-input.utils.d.ts +0 -8
@@ -1,9 +1,8 @@
1
1
  import { h } from "@stencil/core";
2
2
  import { allItemsAreString, ClassList, getObjectValueFromKey, isValidString, nextTick, Page, Paginate, Cursor, toString, isObject, formatID, } from "@mgdis/core-ui-helpers/dist/utils";
3
- import { widths, classReadonly, classDisabled, CustomError } from "../mg-input/mg-input.conf";
3
+ import { widths, classReadonly, classDisabled } from "../mg-input/mg-input.conf";
4
4
  import { initLocales } from "../../../../locales";
5
5
  import { Keys } from "../../../../utils/events.utils";
6
- import { defineErrorMessage } from "../mg-input/mg-input.utils";
7
6
  /**
8
7
  * Check if object is an item
9
8
  * @param item - object to check
@@ -127,12 +126,10 @@ export class MgInputCombobox {
127
126
  */
128
127
  this.handleFilterInput = () => {
129
128
  this.checkValidity();
130
- if (this.hasDisplayedError) {
129
+ if (this.hasDisplayedError)
131
130
  this.setErrorMessage();
132
- }
133
- if (!this.popoverDisplay) {
131
+ if (!this.popoverDisplay)
134
132
  this.popoverDisplay = true;
135
- }
136
133
  // update filter with debounce to prevent filter update overload
137
134
  if (!this.debounce) {
138
135
  this.debounce = true;
@@ -178,6 +175,7 @@ export class MgInputCombobox {
178
175
  * @param event - keyboard event
179
176
  */
180
177
  this.handleFilterKeydown = (event) => {
178
+ var _a;
181
179
  if (this.disabled || event.ctrlKey || event.shiftKey)
182
180
  return;
183
181
  let guard = false;
@@ -186,10 +184,11 @@ export class MgInputCombobox {
186
184
  case Keys.TAB:
187
185
  case Keys.ENTER:
188
186
  guard = event.key === Keys.ENTER;
189
- const option = this.option || this.options.items.find(this.isCurrentOption);
187
+ const option = (_a = this.option) !== null && _a !== void 0 ? _a : this.options.items.find(this.isCurrentOption);
190
188
  // Sets the value to the content of the focused option in the listbox.
191
- if (this.popoverDisplay)
189
+ if (this.popoverDisplay) {
192
190
  this.setValue(option);
191
+ }
193
192
  // Closes the popover.
194
193
  this.popoverDisplay = false;
195
194
  break;
@@ -310,46 +309,27 @@ export class MgInputCombobox {
310
309
  else
311
310
  return '';
312
311
  };
313
- /**
314
- * Test if component has no value error message displayed
315
- * @returns truthy if compent display no value error message
316
- */
317
- this.hasNoValueError = () => this.customError === CustomError.NoValue;
318
312
  /**
319
313
  * Check if input is valid
320
314
  */
321
315
  this.checkValidity = () => {
322
- // force validity with readonly|disabled states
323
- this.setValidity(this.readonly || this.disabled);
316
+ this.setValidity(this.readonly || this.disabled || this.input.checkValidity());
324
317
  };
325
318
  /**
326
319
  * Set input error message
320
+ * @param errorMessage - errorMessage override
327
321
  */
328
- this.setErrorMessage = () => {
322
+ this.setErrorMessage = (errorMessage) => {
329
323
  // Set error message
330
324
  this.errorMessage = undefined;
331
- if (!this.valid) {
332
- // Does have a custom error message
333
- if (this.customError !== undefined && !Object.values(CustomError).includes(this.customError)) {
334
- this.errorMessage = this.customError;
335
- }
336
- // no items
337
- else if (this.hasNoValueError()) {
338
- this.errorMessage = this.messages.errors.noValue;
339
- }
340
- // required
341
- else if (this.input.validity.valueMissing) {
342
- this.errorMessage = this.messages.errors.required;
343
- }
325
+ // Does have a custom error message
326
+ if (!this.valid && errorMessage !== undefined) {
327
+ this.errorMessage = errorMessage;
328
+ }
329
+ // required
330
+ else if (!this.valid && this.input.validity.valueMissing) {
331
+ this.errorMessage = this.messages.errors.required;
344
332
  }
345
- };
346
- /**
347
- * Reset error message
348
- */
349
- this.resetErrorMessage = () => {
350
- this.checkValidity();
351
- this.errorMessage = undefined;
352
- this.hasDisplayedError = false;
353
333
  };
354
334
  /**
355
335
  * Get filtered options from `filter` input value
@@ -423,14 +403,14 @@ export class MgInputCombobox {
423
403
  */
424
404
  this.goToNextPage = () => {
425
405
  this.showMore.emit();
426
- if (this.fetchurl !== undefined) {
406
+ if (Boolean(this.fetchurl)) {
427
407
  return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then(nextPage => {
428
- if (isObject(nextPage)) {
429
- // merge items from current page and next page
430
- const items = [...this.page.items, ...nextPage.items];
431
- // create new options pagination withe merged items
432
- this.options = new Paginate(items, { total: nextPage.total, next: nextPage.next, top: items.length });
433
- }
408
+ if (!Boolean(nextPage))
409
+ return;
410
+ // merge items from current page and next page
411
+ const items = [...this.page.items, ...nextPage.items];
412
+ // create new options pagination withe merged items
413
+ this.options = new Paginate(items, { total: nextPage.total, next: nextPage.next, top: items.length });
434
414
  });
435
415
  }
436
416
  else {
@@ -447,20 +427,12 @@ export class MgInputCombobox {
447
427
  * @returns promise
448
428
  */
449
429
  this.updatePage = async () => {
450
- if (this.fetchurl !== undefined) {
430
+ if (Boolean(this.fetchurl)) {
451
431
  return this.getOptions().then(page => {
452
- if (isObject(page)) {
453
- // reset current options pagination from API response
454
- this.options = new Paginate(page.items, { total: page.total, next: page.next, top: page.top });
455
- // has items aren't updated with fetch mode we run the noValueError control here
456
- if (this.filter.length === 0 && page.total === 0) {
457
- this.displayError();
458
- }
459
- // force to reset error when noValueError is displaied
460
- else if (this.invalid && this.hasNoValueError()) {
461
- this.resetErrorMessage();
462
- }
463
- }
432
+ if (!Boolean(page))
433
+ return;
434
+ // reset current options pagination from API response
435
+ this.options = new Paginate(page.items, { total: page.total, next: page.next, top: page.top });
464
436
  });
465
437
  }
466
438
  else {
@@ -479,16 +451,14 @@ export class MgInputCombobox {
479
451
  const response = await fetch(updateUrl, this.fetchoptions);
480
452
  if (!response.ok) {
481
453
  this.fetchError.emit(new Error(`${response.status} - ${response.statusText}`));
482
- this.displayError();
483
454
  return;
484
455
  }
485
456
  const json = await response.json();
486
- const defaultItems = [];
487
- const items = getObjectValueFromKey(json, this.fetchmappings.response.items, defaultItems).map((item) => ({
488
- title: getObjectValueFromKey(item, this.fetchmappings.response.itemTitle, typeof item === 'string' ? item : JSON.stringify(item)),
489
- value: getObjectValueFromKey(item, this.fetchmappings.response.itemValue, item),
457
+ const items = getObjectValueFromKey(json, this.fetchmappings.response.items).map((item) => ({
458
+ title: getObjectValueFromKey(item, this.fetchmappings.response.itemTitle),
459
+ value: this.fetchmappings.response.itemValue !== undefined ? getObjectValueFromKey(item, this.fetchmappings.response.itemValue) : item,
490
460
  }));
491
- const total = Number(getObjectValueFromKey(json, this.fetchmappings.response.total, defaultItems.length));
461
+ const total = Number(getObjectValueFromKey(json, this.fetchmappings.response.total, 0));
492
462
  let next = getObjectValueFromKey(json, this.fetchmappings.response.next);
493
463
  if (URL.canParse(updateUrl) && Boolean(next) && !URL.canParse(next)) {
494
464
  const previousUrl = new URL(updateUrl);
@@ -500,7 +470,6 @@ export class MgInputCombobox {
500
470
  }
501
471
  catch (error) {
502
472
  this.fetchError.emit(error);
503
- this.displayError();
504
473
  }
505
474
  };
506
475
  }
@@ -509,35 +478,24 @@ export class MgInputCombobox {
509
478
  this.valueChange.emit(newValue);
510
479
  }
511
480
  watchItems(newValue) {
512
- // fetch items
513
- if (![undefined, null].includes(this.fetchurl) && [undefined, null].includes(newValue)) {
481
+ if (Boolean(this.fetchurl) && !Boolean(newValue)) {
514
482
  // skip newValue check
515
483
  return;
516
484
  }
517
- // invalid items
518
- else if (![undefined, null].includes(this.fetchurl) && Array.isArray(newValue)) {
485
+ else if (Boolean(this.fetchurl) && Boolean(newValue)) {
519
486
  throw new Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${toString(newValue)}.`);
520
487
  }
521
- // Empty items
522
- else if ([undefined, null].includes(newValue) || (Array.isArray(newValue) && newValue.length === 0)) {
488
+ // Empty options
489
+ else if (Array.isArray(newValue) && newValue.length === 0) {
523
490
  this.options = new Paginate([]);
524
- this.displayError();
525
491
  }
526
492
  // String array
527
493
  else if (allItemsAreString(newValue)) {
528
494
  this.options = new Paginate(newValue.map(item => ({ title: item, value: item })), { total: newValue.length });
529
- // force to reset error when noValueError is displayed
530
- if (this.invalid && this.hasNoValueError()) {
531
- this.resetErrorMessage();
532
- }
533
495
  }
534
496
  // Object array
535
497
  else if (isItems(newValue)) {
536
498
  this.options = new Paginate(newValue, { total: newValue.length });
537
- // force to reset error when noValueError is displayed
538
- if (this.invalid && this.hasNoValueError()) {
539
- this.resetErrorMessage();
540
- }
541
499
  }
542
500
  else {
543
501
  throw new Error(`<mg-input-combobox> prop "items" values must be the same type, string or Option. Passed value: ${toString(newValue)}.`);
@@ -605,7 +563,7 @@ export class MgInputCombobox {
605
563
  }
606
564
  }
607
565
  watchOptions(newValue) {
608
- this.page = newValue.getPage(0, this.filter.length > 0 ? this.optionsFilter : undefined);
566
+ this.page = newValue.getPage(0, Boolean(this.filter) ? this.optionsFilter : undefined);
609
567
  }
610
568
  watchFilter(newValue) {
611
569
  this.loadingWrapper({ name: 'load-data' });
@@ -671,8 +629,8 @@ export class MgInputCombobox {
671
629
  throw new Error('<mg-input-combobox> method "setError()" param "errorMessage" must be a string.');
672
630
  }
673
631
  else {
674
- this.setValidity(valid, errorMessage);
675
- this.setErrorMessage();
632
+ this.setValidity(valid);
633
+ this.setErrorMessage(valid ? undefined : errorMessage);
676
634
  this.hasDisplayedError = this.invalid;
677
635
  }
678
636
  }
@@ -692,7 +650,9 @@ export class MgInputCombobox {
692
650
  // - Keep everything in sync both inside and outside the component
693
651
  return new Promise(resolve => {
694
652
  requestAnimationFrame(() => {
695
- this.resetErrorMessage();
653
+ this.checkValidity();
654
+ this.errorMessage = undefined;
655
+ this.hasDisplayedError = false;
696
656
  resolve();
697
657
  });
698
658
  });
@@ -715,34 +675,15 @@ export class MgInputCombobox {
715
675
  }
716
676
  /**
717
677
  * Method to set validity values
718
- * @param newValidValue - new valid value. `true` will bypass input check.
719
- * @param customErrorMessage - custom error message
678
+ * @param newValue - valid new value
720
679
  */
721
- setValidity(newValidValue, customErrorMessage) {
722
- var _a;
680
+ setValidity(newValue) {
723
681
  const oldValidValue = this.valid;
724
- let valid = newValidValue;
725
- // Set custom validity
726
- if (!valid && this.input !== undefined) {
727
- // custom errror, start by reset it
728
- this.customError = undefined;
729
- if (isValidString(customErrorMessage)) {
730
- this.customError = customErrorMessage;
731
- }
732
- // no value
733
- else if ((this.fetchurl === undefined ? ((_a = this.items) !== null && _a !== void 0 ? _a : []).length : this.page.total) === 0) {
734
- this.customError = CustomError.NoValue;
735
- }
736
- // get new input validity from validity state
737
- valid = this.input.checkValidity() && this.customError === undefined;
738
- }
739
- // set valid/invalid props
740
- this.valid = valid;
682
+ this.valid = newValue;
741
683
  this.invalid = !this.valid;
742
684
  // We need to send valid event even if it is the same value
743
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue)) {
685
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
744
686
  this.inputValid.emit(this.valid);
745
- }
746
687
  }
747
688
  /*************
748
689
  * Lifecycle *
@@ -783,19 +724,15 @@ export class MgInputCombobox {
783
724
  const listId = `${this.identifier}-list`;
784
725
  const readonlyValue = this.getValueTitle();
785
726
  const withResetButton = this.value && !this.disabled;
786
- const disabled = this.disabled || this.hasNoValueError();
787
727
  let popoverContent;
788
- if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0) {
728
+ if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0)
789
729
  popoverContent = 'list';
790
- }
791
- else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && this.filter.length > 0) {
730
+ else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && Boolean(this.filter))
792
731
  popoverContent = 'notfound';
793
- }
794
- else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0) {
732
+ else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0)
795
733
  popoverContent = 'notavailable';
796
- }
797
734
  let activeDescendant;
798
- if (![null, undefined].includes((_d = this.option) === null || _d === void 0 ? void 0 : _d.value)) {
735
+ if (Boolean((_d = this.option) === null || _d === void 0 ? void 0 : _d.value)) {
799
736
  activeDescendant = this.option.value;
800
737
  }
801
738
  else if (typeof this.value === 'string') {
@@ -804,12 +741,12 @@ export class MgInputCombobox {
804
741
  else {
805
742
  activeDescendant = (_e = this.value) === null || _e === void 0 ? void 0 : _e.value;
806
743
  }
807
- return (h("mg-input", { key: 'fa0977713a1150c39b4f989bbb139e0e345b4c5f', 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: defineErrorMessage(this.errorMessage, this.noValueErrorDetail) }, 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: {
744
+ return (h("mg-input", { key: '79e5263cd3b1c0fa0b3f386a547f2bdd48a33b28', 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: {
808
745
  '--mg-c-input-list-width': Boolean((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) ? `${this.input.offsetWidth}px` : undefined,
809
- }, "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: 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) => {
746
+ }, "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) => {
810
747
  if (el !== null)
811
748
  this.input = el;
812
- } }), withResetButton ? (h("mg-button", { class: "mg-c-input__box-append mg-c-input__reset", variant: "flat", "is-icon": true, label: this.messages.general.reset, "aria-controls": this.identifier, tabindex: "-1", onClick: this.handleResetButton, disabled: disabled }, h("mg-icon", { icon: "cross" }))) : (h("mg-button", { class: "mg-c-input__box-append", variant: "flat", "is-icon": true, label: this.itemsLabel, tabindex: "-1", disabled: disabled }, h("mg-icon", { icon: `chevron-${this.popoverDisplay ? 'up' : 'down'}` })))), h("div", { slot: "content", class: "mg-c-input__popover-container" }, popoverContent === 'list' && [
749
+ } }), withResetButton ? (h("mg-button", { class: "mg-c-input__box-append mg-c-input__reset", variant: "flat", "is-icon": true, label: this.messages.general.reset, "aria-controls": this.identifier, tabindex: "-1", onClick: this.handleResetButton }, h("mg-icon", { icon: "cross" }))) : (h("mg-button", { class: "mg-c-input__box-append", variant: "flat", "is-icon": true, label: this.itemsLabel, tabindex: "-1", disabled: this.disabled }, h("mg-icon", { icon: `chevron-${this.popoverDisplay ? 'up' : 'down'}` })))), h("div", { slot: "content", class: "mg-c-input__popover-container" }, popoverContent === 'list' && [
813
750
  // eslint-disable-next-line jsx-a11y/role-supports-aria-props
814
751
  h("ul", { key: "list", class: "mg-c-input__input-list", role: "listbox", id: listId, "aria-label": this.itemsLabel, "aria-setsize": this.page.total }, this.page.items.map(option => {
815
752
  var _a;
@@ -1268,25 +1205,6 @@ export class MgInputCombobox {
1268
1205
  "getter": false,
1269
1206
  "setter": false
1270
1207
  },
1271
- "noValueErrorDetail": {
1272
- "type": "string",
1273
- "attribute": "no-value-error-detail",
1274
- "mutable": false,
1275
- "complexType": {
1276
- "original": "string",
1277
- "resolved": "string",
1278
- "references": {}
1279
- },
1280
- "required": false,
1281
- "optional": true,
1282
- "docs": {
1283
- "tags": [],
1284
- "text": "Define no value error detail"
1285
- },
1286
- "getter": false,
1287
- "setter": false,
1288
- "reflect": false
1289
- },
1290
1208
  "valid": {
1291
1209
  "type": "boolean",
1292
1210
  "attribute": "valid",
@@ -2,7 +2,6 @@ import { h } from "@stencil/core";
2
2
  import { ClassList, allItemsAreString, isValidString, toString } from "@mgdis/core-ui-helpers/dist/utils";
3
3
  import { classReadonly, classDisabled, classFieldset } from "../mg-input/mg-input.conf";
4
4
  import { initLocales } from "../../../../locales";
5
- import { defineErrorMessage } from "../mg-input/mg-input.utils";
6
5
  /**
7
6
  * type Option validation function
8
7
  * @param option - radio option
@@ -75,21 +74,11 @@ export class MgInputRadio {
75
74
  // reset guard
76
75
  this.handlerInProgress = undefined;
77
76
  };
78
- /**
79
- * Test if component has items
80
- * @returns truthy if component has items
81
- */
82
- this.hasInputValue = () => { var _a; return ((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) > 0; };
83
- /**
84
- * Test if component has no value error message displayed
85
- * @returns truthy if compent display no value error message
86
- */
87
- this.hasNoValueErrorMessageDisplay = () => this.errorMessage === this.messages.errors.noValue;
88
77
  /**
89
78
  * Check if input is valid
90
79
  */
91
80
  this.checkValidity = () => {
92
- this.setValidity(this.readonly || this.disabled || (this.hasInputValue() && this.getInvalidElement() === undefined));
81
+ this.setValidity(this.readonly || this.disabled || this.getInvalidElement() === undefined);
93
82
  };
94
83
  /**
95
84
  * Set input error message
@@ -103,22 +92,11 @@ export class MgInputRadio {
103
92
  if (errorMessage !== undefined) {
104
93
  this.errorMessage = errorMessage;
105
94
  }
106
- else if (!this.hasInputValue()) {
107
- this.errorMessage = this.messages.errors.noValue;
108
- }
109
95
  else if (invalidElement.validity.valueMissing) {
110
96
  this.errorMessage = this.messages.errors.required;
111
97
  }
112
98
  }
113
99
  };
114
- /**
115
- * Reset error message
116
- */
117
- this.resetErrorMessage = () => {
118
- this.checkValidity();
119
- this.errorMessage = undefined;
120
- this.hasDisplayedError = false;
121
- };
122
100
  /**
123
101
  * get invalid element
124
102
  * @returns element
@@ -140,29 +118,17 @@ export class MgInputRadio {
140
118
  this.valueChange.emit(newValue);
141
119
  }
142
120
  validateItems(newValue) {
143
- if ([undefined, null].includes(newValue) || (Array.isArray(newValue) && newValue.length === 0)) {
144
- this.options = [];
145
- this.displayError();
146
- }
147
121
  // Validate if items have required min length
148
- else if (Array.isArray(newValue) && newValue.length < 2) {
122
+ if (typeof newValue === 'object' && newValue.length < 2) {
149
123
  throw new Error(`<mg-input-radio> prop "items" require at least 2 items. Passed value: ${toString(newValue)}.`);
150
124
  }
151
125
  // String array
152
126
  else if (allItemsAreString(newValue)) {
153
127
  this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
154
- // force to reset error when noValueError is displaied
155
- if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
156
- this.resetErrorMessage();
157
- }
158
128
  }
159
129
  // Object array
160
- else if (Array.isArray(newValue) && newValue.every(isOption)) {
130
+ else if (newValue && newValue.every(item => isOption(item))) {
161
131
  this.options = newValue;
162
- // force to reset error when noValueError is displaied
163
- if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
164
- this.resetErrorMessage();
165
- }
166
132
  }
167
133
  else {
168
134
  throw new Error(`<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption. Passed value: ${toString(newValue)}.`);
@@ -258,7 +224,9 @@ export class MgInputRadio {
258
224
  // - Keep everything in sync both inside and outside the component
259
225
  return new Promise(resolve => {
260
226
  requestAnimationFrame(() => {
261
- this.resetErrorMessage();
227
+ this.checkValidity();
228
+ this.errorMessage = undefined;
229
+ this.hasDisplayedError = false;
262
230
  resolve();
263
231
  });
264
232
  });
@@ -304,12 +272,10 @@ export class MgInputRadio {
304
272
  * @returns HTML Element
305
273
  */
306
274
  render() {
307
- return (h("mg-input", { key: 'ecb4efa3a4ccfae5ff56c4a304158c7a03c73153', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && !this.value ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: defineErrorMessage(this.errorMessage, this.noValueErrorDetail) }, this.readonly
308
- ? this.readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)
309
- : this.options.length > 0 && (h("ul", { class: "mg-c-input__input-group-container", role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: (el) => {
310
- if (el !== null)
311
- this.inputs[index] = el;
312
- } }), h("label", { htmlFor: this.identifier + '_' + index }, input.title))))))));
275
+ return (h("mg-input", { key: '048aa732e7f8593701c9397e571b97584bc5e37b', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && !this.value ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)) : (h("ul", { class: "mg-c-input__input-group-container", role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: (el) => {
276
+ if (el !== null)
277
+ this.inputs[index] = el;
278
+ } }), h("label", { htmlFor: this.identifier + '_' + index }, input.title))))))));
313
279
  }
314
280
  static get is() { return "mg-input-radio"; }
315
281
  static get encapsulation() { return "shadow"; }
@@ -610,25 +576,6 @@ export class MgInputRadio {
610
576
  "setter": false,
611
577
  "reflect": false
612
578
  },
613
- "noValueErrorDetail": {
614
- "type": "string",
615
- "attribute": "no-value-error-detail",
616
- "mutable": false,
617
- "complexType": {
618
- "original": "string",
619
- "resolved": "string",
620
- "references": {}
621
- },
622
- "required": false,
623
- "optional": true,
624
- "docs": {
625
- "tags": [],
626
- "text": "Define no value error detail"
627
- },
628
- "getter": false,
629
- "setter": false,
630
- "reflect": false
631
- },
632
579
  "valid": {
633
580
  "type": "boolean",
634
581
  "attribute": "valid",
@@ -2,7 +2,6 @@ import { h } from "@stencil/core";
2
2
  import { ClassList, allItemsAreString, isValidString, toString } from "@mgdis/core-ui-helpers/dist/utils";
3
3
  import { classReadonly, classDisabled, widths } from "../mg-input/mg-input.conf";
4
4
  import { initLocales } from "../../../../locales";
5
- import { defineErrorMessage } from "../mg-input/mg-input.utils";
6
5
  /**
7
6
  * Check if item is a well configured option
8
7
  * @param option - select option
@@ -134,16 +133,6 @@ export class MgInputSelect {
134
133
  * @returns truthy if input.value is an item
135
134
  */
136
135
  this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
137
- /**
138
- * Test if component has items
139
- * @returns truthy if component has items
140
- */
141
- this.hasInputValue = () => { var _a; return ((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) > 0; };
142
- /**
143
- * Test if component has no value error message displayed
144
- * @returns truthy if compent display no value error message
145
- */
146
- this.hasNoValueErrorMessageDisplay = () => this.errorMessage === this.messages.errors.noValue;
147
136
  /**
148
137
  * Handle blur event
149
138
  */
@@ -163,7 +152,7 @@ export class MgInputSelect {
163
152
  * Check if input is valid
164
153
  */
165
154
  this.checkValidity = () => {
166
- this.setValidity(!this.isDisabledValue() && (this.readonly || this.disabled || (this.hasInputValue() && this.input.checkValidity())));
155
+ this.setValidity(!this.isDisabledValue() && (this.readonly || this.disabled || this.input.checkValidity()));
167
156
  };
168
157
  /**
169
158
  * Set input error message
@@ -176,22 +165,11 @@ export class MgInputSelect {
176
165
  if (errorMessage !== undefined) {
177
166
  this.errorMessage = errorMessage;
178
167
  }
179
- else if (!this.hasInputValue()) {
180
- this.errorMessage = this.messages.errors.noValue;
181
- }
182
168
  else if (this.input.validity.valueMissing) {
183
169
  this.errorMessage = this.messages.errors.required;
184
170
  }
185
171
  }
186
172
  };
187
- /**
188
- * Reset error message
189
- */
190
- this.resetErrorMessage = () => {
191
- this.checkValidity();
192
- this.errorMessage = undefined;
193
- this.hasDisplayedError = false;
194
- };
195
173
  /**
196
174
  * Render option
197
175
  * @param option - to render
@@ -209,11 +187,9 @@ export class MgInputSelect {
209
187
  this.valueChange.emit(newValue);
210
188
  }
211
189
  validateItems(newValue) {
212
- let resetMessage = false;
213
190
  // Empty options
214
- if ([undefined, null].includes(newValue) || (Array.isArray(newValue) && newValue.length === 0)) {
191
+ if (newValue.length === 0) {
215
192
  this.options = [];
216
- this.displayError();
217
193
  }
218
194
  // String array
219
195
  else if (allItemsAreString(newValue)) {
@@ -221,8 +197,6 @@ export class MgInputSelect {
221
197
  this.valueExist = newValue.includes(this.value);
222
198
  }
223
199
  this.options = newValue.map(item => ({ title: item, value: item }));
224
- // force to reset error when noValueError is displaied
225
- resetMessage = this.invalid && this.hasNoValueErrorMessageDisplay();
226
200
  }
227
201
  // Object array
228
202
  else if (allItemsAreOptions(newValue)) {
@@ -235,15 +209,10 @@ export class MgInputSelect {
235
209
  else {
236
210
  this.options = newValue;
237
211
  }
238
- // force to reset error when noValueError is displaied
239
- resetMessage = this.invalid && this.hasNoValueErrorMessageDisplay();
240
212
  }
241
213
  else {
242
214
  throw new Error(`<mg-input-select> prop "items" is required, can be an empty Array or all items must be the same type: string or Option. Passed value: ${toString(newValue)}.`);
243
215
  }
244
- if (resetMessage) {
245
- this.resetErrorMessage();
246
- }
247
216
  }
248
217
  watchReadonly(newValue) {
249
218
  if (newValue)
@@ -337,7 +306,9 @@ export class MgInputSelect {
337
306
  // - Keep everything in sync both inside and outside the component
338
307
  return new Promise(resolve => {
339
308
  requestAnimationFrame(() => {
340
- this.resetErrorMessage();
309
+ this.checkValidity();
310
+ this.errorMessage = undefined;
311
+ this.hasDisplayedError = false;
341
312
  resolve();
342
313
  });
343
314
  });
@@ -389,7 +360,7 @@ export class MgInputSelect {
389
360
  */
390
361
  render() {
391
362
  const readonlyValue = this.getReadonlyValue();
392
- return (h("mg-input", { key: 'b980e7e5bd2e1eac6e0075e61f3a6d8ab993216a', 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 && readonlyValue === null ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: defineErrorMessage(this.errorMessage, this.noValueErrorDetail) }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("select", { class: "mg-c-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled || !this.hasInputValue(), required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
363
+ return (h("mg-input", { key: '1394827503d3f2dd71efc6efa389ac707573d2ec', 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 && readonlyValue === null ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("select", { class: "mg-c-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
393
364
  if (el !== null)
394
365
  this.input = el;
395
366
  } }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
@@ -758,25 +729,6 @@ export class MgInputSelect {
758
729
  "setter": false,
759
730
  "reflect": false
760
731
  },
761
- "noValueErrorDetail": {
762
- "type": "string",
763
- "attribute": "no-value-error-detail",
764
- "mutable": false,
765
- "complexType": {
766
- "original": "string",
767
- "resolved": "string",
768
- "references": {}
769
- },
770
- "required": false,
771
- "optional": true,
772
- "docs": {
773
- "tags": [],
774
- "text": "Define no value error detail"
775
- },
776
- "getter": false,
777
- "setter": false,
778
- "reflect": false
779
- },
780
732
  "valid": {
781
733
  "type": "boolean",
782
734
  "attribute": "valid",