@mgdis/mg-components 6.1.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/cjs/{index-e4a8bf81.js → index-52d5f3d4.js} +16 -6
  2. package/dist/cjs/index-52d5f3d4.js.map +1 -0
  3. package/dist/{esm/index-d8f69946.js → cjs/index-cc11af95.js} +6 -116
  4. package/dist/cjs/index-cc11af95.js.map +1 -0
  5. package/dist/cjs/index.es-ac7c22e3.js +152 -0
  6. package/dist/cjs/index.es-ac7c22e3.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/cjs/mg-action-more_36.cjs.entry.js +324 -216
  9. package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
  10. package/dist/cjs/mg-alert.cjs.entry.js +7 -6
  11. package/dist/cjs/mg-alert.cjs.entry.js.map +1 -1
  12. package/dist/cjs/mg-components.cjs.js +3 -3
  13. package/dist/cjs/mg-components.cjs.js.map +1 -1
  14. package/dist/cjs/mg-loader.cjs.entry.js +5 -4
  15. package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
  16. package/dist/cjs/mg-progress.cjs.entry.js +82 -0
  17. package/dist/cjs/mg-progress.cjs.entry.js.map +1 -0
  18. package/dist/collection/collection-manifest.json +2 -1
  19. package/dist/collection/components/atoms/mg-button/mg-button.js +8 -2
  20. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  21. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js.map +1 -1
  22. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +1 -1
  23. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js.map +1 -1
  24. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js.map +1 -1
  25. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +33 -26
  26. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
  27. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +30 -1
  28. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
  29. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +1 -1
  30. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js.map +1 -1
  31. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +85 -4
  32. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
  33. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +29 -1
  34. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
  35. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +30 -3
  36. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
  37. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +29 -3
  38. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
  39. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +29 -2
  40. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
  41. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +29 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
  43. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +30 -3
  44. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
  45. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +3 -4
  46. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js.map +1 -1
  47. package/dist/collection/components/molecules/mg-form/mg-form.conf.js.map +1 -1
  48. package/dist/collection/components/molecules/mg-form/mg-form.js +32 -2
  49. package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
  50. package/dist/collection/components/molecules/mg-progress/mg-progress.conf.js +5 -0
  51. package/dist/collection/components/molecules/mg-progress/mg-progress.conf.js.map +1 -0
  52. package/dist/collection/components/molecules/mg-progress/mg-progress.js +187 -0
  53. package/dist/collection/components/molecules/mg-progress/mg-progress.js.map +1 -0
  54. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  55. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
  56. package/dist/collection/types/index.js.map +1 -1
  57. package/dist/components/index.es.js +26 -13
  58. package/dist/components/index.es.js.map +1 -1
  59. package/dist/components/index2.js +2 -2
  60. package/dist/components/mg-action-more.js +2 -2
  61. package/dist/components/mg-button2.js +10 -4
  62. package/dist/components/mg-button2.js.map +1 -1
  63. package/dist/components/mg-form.js +19 -5
  64. package/dist/components/mg-form.js.map +1 -1
  65. package/dist/components/mg-input-checkbox-paginated2.js +1 -1
  66. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  67. package/dist/components/mg-input-checkbox.js +20 -29
  68. package/dist/components/mg-input-checkbox.js.map +1 -1
  69. package/dist/components/mg-input-date.js +18 -5
  70. package/dist/components/mg-input-date.js.map +1 -1
  71. package/dist/components/mg-input-numeric.js +29 -7
  72. package/dist/components/mg-input-numeric.js.map +1 -1
  73. package/dist/components/mg-input-password.js +14 -2
  74. package/dist/components/mg-input-password.js.map +1 -1
  75. package/dist/components/mg-input-radio.js +15 -2
  76. package/dist/components/mg-input-radio.js.map +1 -1
  77. package/dist/components/mg-input-select2.js +14 -2
  78. package/dist/components/mg-input-select2.js.map +1 -1
  79. package/dist/components/mg-input-text2.js +14 -2
  80. package/dist/components/mg-input-text2.js.map +1 -1
  81. package/dist/components/mg-input-textarea.js +14 -2
  82. package/dist/components/mg-input-textarea.js.map +1 -1
  83. package/dist/components/mg-input-toggle.js +15 -2
  84. package/dist/components/mg-input-toggle.js.map +1 -1
  85. package/dist/components/mg-input2.js.map +1 -1
  86. package/dist/components/mg-item-more2.js +5 -6
  87. package/dist/components/mg-item-more2.js.map +1 -1
  88. package/dist/components/mg-menu-item2.js +3 -3
  89. package/dist/components/mg-modal.js +2 -2
  90. package/dist/components/mg-pagination2.js +2 -2
  91. package/dist/components/mg-panel.js +2 -2
  92. package/dist/components/mg-popover2.js +2 -2
  93. package/dist/components/mg-progress.d.ts +11 -0
  94. package/dist/components/mg-progress.js +109 -0
  95. package/dist/components/mg-progress.js.map +1 -0
  96. package/dist/components/mg-skip-links.js +1 -1
  97. package/dist/components/mg-tabs.js +4 -4
  98. package/dist/components/mg-tooltip2.js +3 -3
  99. package/dist/esm/{index-e26aede5.js → index-81752ffe.js} +16 -6
  100. package/dist/esm/index-81752ffe.js.map +1 -0
  101. package/dist/{cjs/index-0fe2670c.js → esm/index-f3d3fb70.js} +4 -135
  102. package/dist/esm/index-f3d3fb70.js.map +1 -0
  103. package/dist/esm/index.es-940821a9.js +130 -0
  104. package/dist/esm/index.es-940821a9.js.map +1 -0
  105. package/dist/esm/loader.js +3 -3
  106. package/dist/esm/mg-action-more_36.entry.js +175 -67
  107. package/dist/esm/mg-action-more_36.entry.js.map +1 -1
  108. package/dist/esm/mg-alert.entry.js +3 -2
  109. package/dist/esm/mg-alert.entry.js.map +1 -1
  110. package/dist/esm/mg-components.js +4 -4
  111. package/dist/esm/mg-components.js.map +1 -1
  112. package/dist/esm/mg-loader.entry.js +3 -2
  113. package/dist/esm/mg-loader.entry.js.map +1 -1
  114. package/dist/esm/mg-progress.entry.js +78 -0
  115. package/dist/esm/mg-progress.entry.js.map +1 -0
  116. package/dist/mg-components/mg-components.css +1 -1
  117. package/dist/mg-components/mg-components.esm.js +1 -1
  118. package/dist/mg-components/mg-components.esm.js.map +1 -1
  119. package/dist/mg-components/p-2298352f.js +3 -0
  120. package/dist/mg-components/p-2298352f.js.map +1 -0
  121. package/dist/mg-components/p-31e6c1a7.entry.js +2 -0
  122. package/dist/mg-components/{p-9beb09e5.entry.js.map → p-31e6c1a7.entry.js.map} +1 -1
  123. package/dist/mg-components/p-67c9be27.entry.js +2 -0
  124. package/dist/mg-components/p-67c9be27.entry.js.map +1 -0
  125. package/dist/mg-components/p-95895169.entry.js +2 -0
  126. package/dist/mg-components/{p-5c77f5dd.entry.js.map → p-95895169.entry.js.map} +1 -1
  127. package/dist/mg-components/p-a49e2b74.js +2 -0
  128. package/dist/mg-components/p-a49e2b74.js.map +1 -0
  129. package/dist/mg-components/p-abddacc2.entry.js +2 -0
  130. package/dist/mg-components/p-abddacc2.entry.js.map +1 -0
  131. package/dist/mg-components/p-ee51ec5e.js +2 -0
  132. package/dist/mg-components/p-ee51ec5e.js.map +1 -0
  133. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +13 -11
  134. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +0 -2
  135. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -9
  136. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -0
  137. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +1 -1
  138. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +12 -0
  139. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -0
  140. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -0
  141. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -0
  142. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +4 -0
  143. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -0
  144. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -0
  145. package/dist/types/components/molecules/mg-form/mg-form.conf.d.ts +2 -1
  146. package/dist/types/components/molecules/mg-form/mg-form.d.ts +4 -0
  147. package/dist/types/components/molecules/mg-progress/mg-progress.conf.d.ts +9 -0
  148. package/dist/types/components/molecules/mg-progress/mg-progress.d.ts +47 -0
  149. package/dist/types/components.d.ts +111 -0
  150. package/dist/types/stencil-public-runtime.d.ts +2 -0
  151. package/dist/types/types/index.d.ts +4 -0
  152. package/ide/intellij/web-types.json +183 -15
  153. package/ide/vscode/css-custom-data.json +16 -0
  154. package/ide/vscode/html-custom-data.json +150 -11
  155. package/package.json +25 -25
  156. package/dist/cjs/index-0fe2670c.js.map +0 -1
  157. package/dist/cjs/index-e4a8bf81.js.map +0 -1
  158. package/dist/esm/index-d8f69946.js.map +0 -1
  159. package/dist/esm/index-e26aede5.js.map +0 -1
  160. package/dist/mg-components/p-1fbb6ee7.js +0 -3
  161. package/dist/mg-components/p-1fbb6ee7.js.map +0 -1
  162. package/dist/mg-components/p-5c77f5dd.entry.js +0 -2
  163. package/dist/mg-components/p-9beb09e5.entry.js +0 -2
  164. package/dist/mg-components/p-c9934e81.js +0 -2
  165. package/dist/mg-components/p-c9934e81.js.map +0 -1
  166. package/dist/mg-components/p-d7dde2ac.entry.js +0 -2
  167. package/dist/mg-components/p-d7dde2ac.entry.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { h } from "@stencil/core";
2
- import { ClassList, isValidString, localeCurrency, localeNumber, toString } from "@mgdis/stencil-helpers";
2
+ import { ClassList, isValidString, localeCurrency, localeNumber, localePercent, localeUnit, toString } from "@mgdis/stencil-helpers";
3
3
  import { types, formats } from "./mg-input-numeric.conf";
4
4
  import { classReadonly, classDisabled, widths } from "../mg-input/mg-input.conf";
5
5
  import { initLocales } from "../../../../locales/";
@@ -63,7 +63,9 @@ export class MgInputNumeric {
63
63
  this.errorMessage = this.messages.errors[inputError];
64
64
  }
65
65
  else {
66
- this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
66
+ const formattedMin = this.formatValue(this.min);
67
+ const formattedMax = this.formatValue(this.max);
68
+ this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', formattedMin).replace('{max}', formattedMax);
67
69
  }
68
70
  }
69
71
  };
@@ -104,6 +106,10 @@ export class MgInputNumeric {
104
106
  return localeNumber(value, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);
105
107
  case 'currency':
106
108
  return localeCurrency(value, this.locale, this.currency);
109
+ case 'percent':
110
+ return localePercent(value / 100, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);
111
+ case 'unit':
112
+ return localeUnit(value, this.locale, this.unit, this.unitDisplay, this.type === 'decimal' ? this.decimalLength : undefined);
107
113
  case 'none':
108
114
  return value.toString();
109
115
  }
@@ -149,6 +155,8 @@ export class MgInputNumeric {
149
155
  this.type = 'decimal';
150
156
  this.format = 'number';
151
157
  this.currency = 'EUR';
158
+ this.unit = undefined;
159
+ this.unitDisplay = 'short';
152
160
  this.integerLength = 13;
153
161
  this.decimalLength = 2;
154
162
  this.valid = undefined;
@@ -255,6 +263,17 @@ export class MgInputNumeric {
255
263
  this.hasDisplayedError = this.invalid;
256
264
  }
257
265
  }
266
+ /**
267
+ * Reset value, validity and error state
268
+ */
269
+ async reset() {
270
+ if (!this.readonly) {
271
+ this.value = '';
272
+ this.checkValidity();
273
+ this.errorMessage = undefined;
274
+ this.hasDisplayedError = false;
275
+ }
276
+ }
258
277
  /**
259
278
  * Method to set validity values
260
279
  * @param newValue - valid new value
@@ -341,7 +360,7 @@ export class MgInputNumeric {
341
360
  * @returns HTML Element
342
361
  */
343
362
  render() {
344
- return (h("mg-input", { key: '9b48fe7bf2a16f084ebddc050d90938c5d4e4b23', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], 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
363
+ return (h("mg-input", { key: '6d34c2b7e9762cdefc5de3814ff4afd95fa4a6a6', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], 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
345
364
  ? this.readonlyValue && this.renderReadonly()
346
365
  : [
347
366
  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, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
@@ -684,7 +703,7 @@ export class MgInputNumeric {
684
703
  "mutable": false,
685
704
  "complexType": {
686
705
  "original": "Format",
687
- "resolved": "\"currency\" | \"none\" | \"number\"",
706
+ "resolved": "\"currency\" | \"none\" | \"number\" | \"percent\" | \"unit\"",
688
707
  "references": {
689
708
  "Format": {
690
709
  "location": "import",
@@ -721,6 +740,51 @@ export class MgInputNumeric {
721
740
  "reflect": false,
722
741
  "defaultValue": "'EUR'"
723
742
  },
743
+ "unit": {
744
+ "type": "string",
745
+ "mutable": false,
746
+ "complexType": {
747
+ "original": "Intl.NumberFormatOptions['unit']",
748
+ "resolved": "string",
749
+ "references": {
750
+ "Intl": {
751
+ "location": "global",
752
+ "id": "global::Intl"
753
+ }
754
+ }
755
+ },
756
+ "required": false,
757
+ "optional": true,
758
+ "docs": {
759
+ "tags": [],
760
+ "text": "Define unit symbol (km, L, etc.)"
761
+ },
762
+ "attribute": "unit",
763
+ "reflect": false
764
+ },
765
+ "unitDisplay": {
766
+ "type": "string",
767
+ "mutable": false,
768
+ "complexType": {
769
+ "original": "Intl.NumberFormatOptions['unitDisplay']",
770
+ "resolved": "\"long\" | \"narrow\" | \"short\"",
771
+ "references": {
772
+ "Intl": {
773
+ "location": "global",
774
+ "id": "global::Intl"
775
+ }
776
+ }
777
+ },
778
+ "required": false,
779
+ "optional": false,
780
+ "docs": {
781
+ "tags": [],
782
+ "text": "Define unit display format ('short', 'long', 'narrow')"
783
+ },
784
+ "attribute": "unit-display",
785
+ "reflect": false,
786
+ "defaultValue": "'short'"
787
+ },
724
788
  "integerLength": {
725
789
  "type": "number",
726
790
  "mutable": false,
@@ -891,6 +955,23 @@ export class MgInputNumeric {
891
955
  "text": "errorMessage - the error message to display"
892
956
  }]
893
957
  }
958
+ },
959
+ "reset": {
960
+ "complexType": {
961
+ "signature": "() => Promise<void>",
962
+ "parameters": [],
963
+ "references": {
964
+ "Promise": {
965
+ "location": "global",
966
+ "id": "global::Promise"
967
+ }
968
+ },
969
+ "return": "Promise<void>"
970
+ },
971
+ "docs": {
972
+ "text": "Reset value, validity and error state",
973
+ "tags": []
974
+ }
894
975
  }
895
976
  };
896
977
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mg-input-numeric.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-numeric/mg-input-numeric.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC1G,OAAO,EAAE,KAAK,EAAyD,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAChH,OAAO,EAAoD,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnI,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;GAEG;AAMH,MAAM,OAAO,cAAc;;QAkBzB,8CAA8C;QACtC,sBAAiB,GAAG,KAAK,CAAC;QAmUlC;;WAEG;QACK,gBAAW,GAAG,GAAS,EAAE;YAC/B,iBAAiB;YACjB,IAAI,CAAC,aAAa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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, h, Prop, EventEmitter, State, Watch, Method } from '@stencil/core';\nimport { ClassList, isValidString, localeCurrency, localeNumber, toString } from '@mgdis/stencil-helpers';\nimport { types, type InputNumericError, type NumericType, type Format, formats } from './mg-input-numeric.conf';\nimport { type TooltipPosition, type Width, type EventType, classReadonly, classDisabled, widths } from '../mg-input/mg-input.conf';\nimport { initLocales } from '../../../../locales/';\n\n/**\n * @slot append-input - Content to display next to the input\n */\n@Component({\n tag: 'mg-input-numeric',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-numeric.css',\n shadow: true,\n})\nexport class MgInputNumeric {\n /************\n * Internal *\n ************/\n\n // Manage different values\n private storedValue: string;\n private numericValue: number;\n private readonlyValue: string;\n private slotContent: string;\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private locale: string;\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: EventType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputNumericElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n validateValue(newValue: MgInputNumeric['value']): void {\n // has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type\n if (typeof newValue === 'string') {\n // Split number and decimal\n const [integer, decimal = ''] = newValue.replace('-', '').split(/[.,]/);\n // Regex\n const regex = this.type === 'integer' ? /^-?\\d+$/ : /^-?\\d+(?:[.,]\\d*)?$/;\n // Filter input\n if (this.isValidValue(newValue, regex, integer, decimal)) {\n this.storedValue = newValue;\n } else {\n newValue = this.handleInvalidValue();\n }\n // Set value and input value\n this.updateValues(newValue);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop?: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop() placeholder?: string;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n @Watch('readonly')\n watchReadonly(newValue: MgInputNumeric['readonly']): void {\n if (newValue) this.classCollection.add(classReadonly);\n else this.classCollection.delete(classReadonly);\n }\n\n /**\n * Maximum value\n */\n @Prop() max?: number;\n\n /**\n * Minimum value\n */\n @Prop() min?: number;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n @Watch('min')\n @Watch('max')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n @Watch('disabled')\n watchDisabled(newValue: MgInputNumeric['disabled']): void {\n if (newValue) this.classCollection.add(classDisabled);\n else this.classCollection.delete(classDisabled);\n }\n\n /**\n * Define input width\n */\n @Prop() mgWidth?: Width;\n @Watch('mgWidth')\n watchMgWidth(newValue: MgInputNumeric['mgWidth']): void {\n // reset width class\n widths.forEach(width => {\n this.classCollection.delete(`mg-c-input--width-${width}`);\n });\n\n // apply new width\n if (newValue !== undefined) this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip?: string;\n\n /**\n * Define tooltip position\n */\n @Prop() tooltipPosition: TooltipPosition = 'input';\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText?: string;\n\n /**\n * Define numeric type\n */\n @Prop() type: NumericType = 'decimal';\n @Watch('type')\n validateType(newValue: MgInputNumeric['type']): void {\n if (!types.includes(newValue)) {\n throw new Error(`<mg-input-numeric> prop \"type\" must be one of: ${types.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Set local formatting.\n * Numbers are formatted based on the locale.\n */\n @Prop() format: Format = 'number';\n @Watch('format')\n watchFormat(newValue: MgInputNumeric['format']): void {\n if (!formats.includes(newValue)) {\n throw new Error(`<mg-input-numeric> prop \"format\" must be one of: ${formats.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define currency\n */\n @Prop() currency = 'EUR';\n\n /**\n * Override integer length\n * integer is the number before the decimal point\n */\n @Prop() integerLength = 13;\n @Watch('integerLength')\n validateIntegerLength(newValue: MgInputNumeric['integerLength']): void {\n if (newValue < 1) {\n throw new Error(`<mg-input-numeric> prop \"integer-length\" must be a positive number. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Override decimal length\n * decimal is the number after the decimal point\n */\n @Prop() decimalLength = 2;\n @Watch('decimalLength')\n validateDecimalLength(newValue: MgInputNumeric['decimalLength']): void {\n if (newValue < 1) {\n throw new Error(`<mg-input-numeric> prop \"decimal-length\" must be a positive number, consider using prop \"type\" to \"integer\" instead. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define input pattern to validate\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input pattern error message\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--numeric']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Define if input has focus\n */\n @State() hasFocus: boolean;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<number>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputNumericElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputNumeric['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-numeric> method \"setError()\" param \"valid\" must be a boolean.');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-numeric> method \"setError()\" param \"errorMessage\" must be a string.');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputNumeric['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Checks if the given value is valid according to the defined rules.\n * @param value - The input value to validate.\n * @param regex - The regular expression for validation.\n * @param integer - The integer part of the value.\n * @param decimal - The decimal part of the value.\n * @returns Returns true if the value is valid, otherwise false.\n */\n private isValidValue(value: string, regex: RegExp, integer: string, decimal: string): boolean {\n return (\n ['', '-'].includes(value) || (regex.exec(value) !== null && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))\n );\n }\n\n /**\n * Handles invalid input values and returns a corrected value.\n * @returns The corrected value.\n */\n private handleInvalidValue(): string | null {\n return this.storedValue ?? null;\n }\n\n /**\n * Updates the component values based on the validated input value.\n * @param newValue - The validated input value.\n */\n private updateValues(newValue: string | null): void {\n this.value = newValue;\n if (this.input !== undefined) this.input.value = this.value;\n\n this.numericValue = !['', null].includes(this.value) ? parseFloat(this.value.replace(',', '.')) : null;\n this.valueChange.emit(this.numericValue);\n\n this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';\n }\n\n /**\n * Displayed value in input\n * Change on focus/blur\n * @returns display value\n */\n private displayValue(): MgInputNumeric['value'] | MgInputNumeric['readonlyValue'] {\n return this.hasFocus ? this.value : this.readonlyValue;\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n // Check validity\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle focus event\n */\n private handleFocus = (): void => {\n this.hasFocus = true;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n if (this.value === '-') this.value = '';\n // Display Error\n this.handlerInProgress = 'blur';\n this.displayError().finally(() => {\n // reset guard\n this.handlerInProgress = undefined;\n this.hasFocus = false;\n });\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || this.getInputError() === null);\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n const inputError = this.getInputError();\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n } else if (inputError === 'required') {\n this.errorMessage = this.messages.errors[inputError];\n } else {\n this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);\n }\n }\n };\n\n /**\n * Get input error code\n * @returns error code\n */\n private getInputError = (): null | InputNumericError => {\n let inputError: InputNumericError = null;\n const hasNotEmptyValues = (toControl: number[]) => !toControl.some(value => [null, undefined].includes(value));\n\n // required\n if (!this.input.checkValidity() && this.input.validity.valueMissing) {\n inputError = 'required';\n }\n // Min & Max\n else if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {\n // Only a min value is set\n inputError = 'min';\n } else if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {\n // Only a max value is set\n inputError = 'max';\n } else if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {\n // both min and max values are set\n inputError = 'minMax';\n }\n return inputError;\n };\n\n /**\n * Format value based on type\n * @param value - value to format\n * @returns formated local value\n */\n private formatValue = (value: number): string => {\n switch (this.format) {\n case 'number':\n return localeNumber(value, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);\n case 'currency':\n return localeCurrency(value, this.locale, this.currency);\n case 'none':\n return value.toString();\n }\n };\n\n /**\n * Validate append slot\n */\n private validateAppendSlot = (): void => {\n const slotAppendInput: HTMLSlotElement = this.element.querySelector('[slot=\"append-input\"]');\n if (slotAppendInput !== null) {\n if (slotAppendInput.nodeName === 'MG-BUTTON') {\n this.classCollection.add('mg-c-input--is-input-group-append');\n } else {\n this.classCollection.add('mg-c-input--is-append-input-slot-content');\n this.slotContent = slotAppendInput.textContent;\n }\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n const locales = initLocales(this.element);\n this.locale = locales.locale;\n this.messages = locales.messages;\n // Validate component config\n this.watchFormat(this.format);\n this.validateType(this.type);\n this.validateIntegerLength(this.integerLength);\n this.validateDecimalLength(this.decimalLength);\n // validate value\n this.validateValue(this.value);\n this.validateAppendSlot();\n this.watchReadonly(this.readonly);\n this.watchDisabled(this.disabled);\n this.watchMgWidth(this.mgWidth);\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Renders the readonly content of the input component.\n * @returns The readonly content element.\n */\n private renderReadonly = (): HTMLElement => {\n return this.slotContent !== undefined ? (\n <span class=\"mg-c-input__readonly-value\">\n <b>{this.readonlyValue}</b>\n {this.slotContent}\n </span>\n ) : (\n <b class=\"mg-c-input__readonly-value\">{this.readonlyValue}</b>\n );\n };\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <mg-input\n label={this.label}\n identifier={this.identifier}\n class={this.classCollection.join()}\n ariaDescribedbyIDs={[]}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n tooltip={this.tooltip}\n tooltipPosition={this.readonly && this.value === undefined ? 'label' : this.tooltipPosition}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n >\n {this.readonly\n ? this.readonlyValue && this.renderReadonly()\n : [\n <input\n key=\"input\"\n type=\"text\"\n class=\"mg-c-input__box mg-c-input__box--width\"\n value={this.displayValue()}\n id={this.identifier}\n name={this.name}\n placeholder={this.placeholder}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n aria-invalid={(this.invalid === true).toString()}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />,\n <slot key=\"slot\" name=\"append-input\"></slot>,\n ]}\n </mg-input>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mg-input-numeric.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-numeric/mg-input-numeric.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, h, Prop, EventEmitter, State, Watch, Method } from '@stencil/core';\nimport { ClassList, isValidString, localeCurrency, localeNumber, localePercent, localeUnit, toString } from '@mgdis/stencil-helpers';\nimport { types, type InputNumericError, type NumericType, type Format, formats } from './mg-input-numeric.conf';\nimport { type TooltipPosition, type Width, type EventType, classReadonly, classDisabled, widths } from '../mg-input/mg-input.conf';\nimport { initLocales } from '../../../../locales/';\n\n/**\n * @slot append-input - Content to display next to the input\n */\n@Component({\n tag: 'mg-input-numeric',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-numeric.css',\n shadow: true,\n})\nexport class MgInputNumeric {\n /************\n * Internal *\n ************/\n\n // Manage different values\n private storedValue: string;\n private numericValue: number;\n private readonlyValue: string;\n private slotContent: string;\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private locale: string;\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: EventType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputNumericElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n validateValue(newValue: MgInputNumeric['value']): void {\n // has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type\n if (typeof newValue === 'string') {\n // Split number and decimal\n const [integer, decimal = ''] = newValue.replace('-', '').split(/[.,]/);\n // Regex\n const regex = this.type === 'integer' ? /^-?\\d+$/ : /^-?\\d+(?:[.,]\\d*)?$/;\n // Filter input\n if (this.isValidValue(newValue, regex, integer, decimal)) {\n this.storedValue = newValue;\n } else {\n newValue = this.handleInvalidValue();\n }\n // Set value and input value\n this.updateValues(newValue);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop?: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop() placeholder?: string;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n @Watch('readonly')\n watchReadonly(newValue: MgInputNumeric['readonly']): void {\n if (newValue) this.classCollection.add(classReadonly);\n else this.classCollection.delete(classReadonly);\n }\n\n /**\n * Maximum value\n */\n @Prop() max?: number;\n\n /**\n * Minimum value\n */\n @Prop() min?: number;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n @Watch('min')\n @Watch('max')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n @Watch('disabled')\n watchDisabled(newValue: MgInputNumeric['disabled']): void {\n if (newValue) this.classCollection.add(classDisabled);\n else this.classCollection.delete(classDisabled);\n }\n\n /**\n * Define input width\n */\n @Prop() mgWidth?: Width;\n @Watch('mgWidth')\n watchMgWidth(newValue: MgInputNumeric['mgWidth']): void {\n // reset width class\n widths.forEach(width => {\n this.classCollection.delete(`mg-c-input--width-${width}`);\n });\n\n // apply new width\n if (newValue !== undefined) this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip?: string;\n\n /**\n * Define tooltip position\n */\n @Prop() tooltipPosition: TooltipPosition = 'input';\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText?: string;\n\n /**\n * Define numeric type\n */\n @Prop() type: NumericType = 'decimal';\n @Watch('type')\n validateType(newValue: MgInputNumeric['type']): void {\n if (!types.includes(newValue)) {\n throw new Error(`<mg-input-numeric> prop \"type\" must be one of: ${types.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Set local formatting.\n * Numbers are formatted based on the locale.\n */\n @Prop() format: Format = 'number';\n @Watch('format')\n watchFormat(newValue: MgInputNumeric['format']): void {\n if (!formats.includes(newValue)) {\n throw new Error(`<mg-input-numeric> prop \"format\" must be one of: ${formats.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define currency\n */\n @Prop() currency = 'EUR';\n\n /**\n * Define unit symbol (km, L, etc.)\n */\n @Prop() unit?: Intl.NumberFormatOptions['unit'];\n\n /**\n * Define unit display format ('short', 'long', 'narrow')\n */\n @Prop() unitDisplay: Intl.NumberFormatOptions['unitDisplay'] = 'short';\n\n /**\n * Override integer length\n * integer is the number before the decimal point\n */\n @Prop() integerLength = 13;\n @Watch('integerLength')\n validateIntegerLength(newValue: MgInputNumeric['integerLength']): void {\n if (newValue < 1) {\n throw new Error(`<mg-input-numeric> prop \"integer-length\" must be a positive number. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Override decimal length\n * decimal is the number after the decimal point\n */\n @Prop() decimalLength = 2;\n @Watch('decimalLength')\n validateDecimalLength(newValue: MgInputNumeric['decimalLength']): void {\n if (newValue < 1) {\n throw new Error(`<mg-input-numeric> prop \"decimal-length\" must be a positive number, consider using prop \"type\" to \"integer\" instead. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define input pattern to validate\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input pattern error message\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--numeric']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Define if input has focus\n */\n @State() hasFocus: boolean;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<number>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputNumericElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputNumeric['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-numeric> method \"setError()\" param \"valid\" must be a boolean.');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-numeric> method \"setError()\" param \"errorMessage\" must be a string.');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Reset value, validity and error state\n */\n @Method()\n async reset(): Promise<void> {\n if (!this.readonly) {\n this.value = '';\n this.checkValidity();\n this.errorMessage = undefined;\n this.hasDisplayedError = false;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputNumeric['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Checks if the given value is valid according to the defined rules.\n * @param value - The input value to validate.\n * @param regex - The regular expression for validation.\n * @param integer - The integer part of the value.\n * @param decimal - The decimal part of the value.\n * @returns Returns true if the value is valid, otherwise false.\n */\n private isValidValue(value: string, regex: RegExp, integer: string, decimal: string): boolean {\n return (\n ['', '-'].includes(value) || (regex.exec(value) !== null && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))\n );\n }\n\n /**\n * Handles invalid input values and returns a corrected value.\n * @returns The corrected value.\n */\n private handleInvalidValue(): string | null {\n return this.storedValue ?? null;\n }\n\n /**\n * Updates the component values based on the validated input value.\n * @param newValue - The validated input value.\n */\n private updateValues(newValue: string | null): void {\n this.value = newValue;\n if (this.input !== undefined) this.input.value = this.value;\n\n this.numericValue = !['', null].includes(this.value) ? parseFloat(this.value.replace(',', '.')) : null;\n this.valueChange.emit(this.numericValue);\n\n this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';\n }\n\n /**\n * Displayed value in input\n * Change on focus/blur\n * @returns display value\n */\n private displayValue(): MgInputNumeric['value'] | MgInputNumeric['readonlyValue'] {\n return this.hasFocus ? this.value : this.readonlyValue;\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n // Check validity\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle focus event\n */\n private handleFocus = (): void => {\n this.hasFocus = true;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n if (this.value === '-') this.value = '';\n // Display Error\n this.handlerInProgress = 'blur';\n this.displayError().finally(() => {\n // reset guard\n this.handlerInProgress = undefined;\n this.hasFocus = false;\n });\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || this.getInputError() === null);\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n const inputError = this.getInputError();\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n } else if (inputError === 'required') {\n this.errorMessage = this.messages.errors[inputError];\n } else {\n const formattedMin = this.formatValue(this.min);\n const formattedMax = this.formatValue(this.max);\n this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', formattedMin).replace('{max}', formattedMax);\n }\n }\n };\n\n /**\n * Get input error code\n * @returns error code\n */\n private getInputError = (): null | InputNumericError => {\n let inputError: InputNumericError = null;\n const hasNotEmptyValues = (toControl: number[]) => !toControl.some(value => [null, undefined].includes(value));\n\n // required\n if (!this.input.checkValidity() && this.input.validity.valueMissing) {\n inputError = 'required';\n }\n // Min & Max\n else if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {\n // Only a min value is set\n inputError = 'min';\n } else if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {\n // Only a max value is set\n inputError = 'max';\n } else if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {\n // both min and max values are set\n inputError = 'minMax';\n }\n return inputError;\n };\n\n /**\n * Format value based on type\n * @param value - value to format\n * @returns formated local value\n */\n private formatValue = (value: number): string => {\n switch (this.format) {\n case 'number':\n return localeNumber(value, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);\n case 'currency':\n return localeCurrency(value, this.locale, this.currency);\n case 'percent':\n return localePercent(value / 100, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);\n case 'unit':\n return localeUnit(value, this.locale, this.unit, this.unitDisplay, this.type === 'decimal' ? this.decimalLength : undefined);\n case 'none':\n return value.toString();\n }\n };\n\n /**\n * Validate append slot\n */\n private validateAppendSlot = (): void => {\n const slotAppendInput: HTMLSlotElement = this.element.querySelector('[slot=\"append-input\"]');\n if (slotAppendInput !== null) {\n if (slotAppendInput.nodeName === 'MG-BUTTON') {\n this.classCollection.add('mg-c-input--is-input-group-append');\n } else {\n this.classCollection.add('mg-c-input--is-append-input-slot-content');\n this.slotContent = slotAppendInput.textContent;\n }\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n const locales = initLocales(this.element);\n this.locale = locales.locale;\n this.messages = locales.messages;\n // Validate component config\n this.watchFormat(this.format);\n this.validateType(this.type);\n this.validateIntegerLength(this.integerLength);\n this.validateDecimalLength(this.decimalLength);\n // validate value\n this.validateValue(this.value);\n this.validateAppendSlot();\n this.watchReadonly(this.readonly);\n this.watchDisabled(this.disabled);\n this.watchMgWidth(this.mgWidth);\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Renders the readonly content of the input component.\n * @returns The readonly content element.\n */\n private renderReadonly = (): HTMLElement => {\n return this.slotContent !== undefined ? (\n <span class=\"mg-c-input__readonly-value\">\n <b>{this.readonlyValue}</b>\n {this.slotContent}\n </span>\n ) : (\n <b class=\"mg-c-input__readonly-value\">{this.readonlyValue}</b>\n );\n };\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <mg-input\n label={this.label}\n identifier={this.identifier}\n class={this.classCollection.join()}\n ariaDescribedbyIDs={[]}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n tooltip={this.tooltip}\n tooltipPosition={this.readonly && this.value === undefined ? 'label' : this.tooltipPosition}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n >\n {this.readonly\n ? this.readonlyValue && this.renderReadonly()\n : [\n <input\n key=\"input\"\n type=\"text\"\n class=\"mg-c-input__box mg-c-input__box--width\"\n value={this.displayValue()}\n id={this.identifier}\n name={this.name}\n placeholder={this.placeholder}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n aria-invalid={(this.invalid === true).toString()}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />,\n <slot key=\"slot\" name=\"append-input\"></slot>,\n ]}\n </mg-input>\n );\n }\n}\n"]}
@@ -139,6 +139,17 @@ export class MgInputPassword {
139
139
  this.hasDisplayedError = this.invalid;
140
140
  }
141
141
  }
142
+ /**
143
+ * Reset value, validity and error state
144
+ */
145
+ async reset() {
146
+ if (!this.readonly) {
147
+ this.value = '';
148
+ this.checkValidity();
149
+ this.errorMessage = undefined;
150
+ this.hasDisplayedError = false;
151
+ }
152
+ }
142
153
  /**
143
154
  * Method to set validity values
144
155
  * @param newValue - valid new value
@@ -176,7 +187,7 @@ export class MgInputPassword {
176
187
  * @returns HTML Element
177
188
  */
178
189
  render() {
179
- return (h("mg-input", { key: '6459a70869ba217a29ad57b79aac2e5bf2aaddfb', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.value !== undefined && h("b", { class: "mg-c-input__readonly-value" }, '•'.repeat(this.value.length))) : (h("span", { class: "mg-c-input__input-group" }, h("input", { type: this.displayPassword ? 'text' : 'password', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, maxlength: this.maxlength, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
190
+ return (h("mg-input", { key: 'af313cb20a94a9c8dcf2b944c31b7ea36b2d3feb', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.value !== undefined && h("b", { class: "mg-c-input__readonly-value" }, '•'.repeat(this.value.length))) : (h("span", { class: "mg-c-input__input-group" }, h("input", { type: this.displayPassword ? 'text' : 'password', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, maxlength: this.maxlength, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
180
191
  if (el !== null)
181
192
  this.input = el;
182
193
  } }), h("mg-button", { label: this.messages.input.password[this.displayPassword ? 'hide' : 'display'], disabled: this.disabled, variant: "flat", class: "mg-c-input__append-button", "is-icon": true, onClick: this.toggleDisplayPassword, "aria-controls": this.identifier }, h("mg-icon", { class: "mg-c-input__input-icon", icon: this.displayPassword ? 'eye-slash' : 'eye' }))))));
@@ -608,6 +619,23 @@ export class MgInputPassword {
608
619
  "text": "errorMessage - the error message to display"
609
620
  }]
610
621
  }
622
+ },
623
+ "reset": {
624
+ "complexType": {
625
+ "signature": "() => Promise<void>",
626
+ "parameters": [],
627
+ "references": {
628
+ "Promise": {
629
+ "location": "global",
630
+ "id": "global::Promise"
631
+ }
632
+ },
633
+ "return": "Promise<void>"
634
+ },
635
+ "docs": {
636
+ "text": "Reset value, validity and error state",
637
+ "tags": []
638
+ }
611
639
  }
612
640
  };
613
641
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mg-input-password.js","sourceRoot":"","sources":["../../../../../src/components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EAAE,CAAC;gBACnC,CAAC,GACD;YACF,iBACE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,EAC9E,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAC,MAAM,EACd,KAAK,EAAC,2BAA2B,mBAEjC,OAAO,EAAE,IAAI,CAAC,qBAAqB,mBACpB,IAAI,CAAC,UAAU;gBAE9B,eAAS,KAAK,EAAC,wBAAwB,EAAC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,GAAY,CAC1F,CACP,CACR,CACQ,CACZ,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, h, Prop, EventEmitter, State, Method, Watch } from '@stencil/core';\nimport { ClassList, isValidString } from '@mgdis/stencil-helpers';\nimport { type TooltipPosition, type Width, type EventType, classReadonly, classDisabled, widths } from '../mg-input/mg-input.conf';\nimport { initLocales } from '../../../../locales';\n\n@Component({\n tag: 'mg-input-password',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-password.css',\n shadow: true,\n})\nexport class MgInputPassword {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: EventType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputPasswordElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n handleValue(newValue: string): void {\n this.valueChange.emit(newValue);\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop?: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop() placeholder?: string;\n\n /**\n * Input max length\n */\n @Prop() maxlength;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n @Watch('readonly')\n watchReadonly(newValue: MgInputPassword['readonly']): void {\n if (newValue) this.classCollection.add(classReadonly);\n else this.classCollection.delete(classReadonly);\n }\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n @Watch('disabled')\n watchDisabled(newValue: MgInputPassword['disabled']): void {\n if (newValue) this.classCollection.add(classDisabled);\n else this.classCollection.delete(classDisabled);\n }\n\n /**\n * Define input width\n */\n @Prop() mgWidth: Width = 'full';\n @Watch('mgWidth')\n watchMgWidth(newValue: MgInputPassword['mgWidth']): void {\n // reset width class\n widths.forEach(width => {\n this.classCollection.delete(`mg-c-input--width-${width}`);\n });\n\n // apply new width\n if (newValue !== undefined) this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip?: string;\n\n /**\n * Define tooltip position\n */\n @Prop() tooltipPosition: TooltipPosition = 'input';\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText?: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--password']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Indicates if password is displayed or not\n */\n @State() displayPassword = false;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputPasswordElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputPasswordElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputPassword['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-password> method \"setError()\" param \"valid\" must be a boolean.');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-password> method \"setError()\" param \"errorMessage\" must be a string.');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputPassword['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.handlerInProgress = 'blur';\n this.displayError().finally(() => {\n // reset guard\n this.handlerInProgress = undefined;\n });\n };\n\n /**\n * Toggle display-pasword value\n */\n private toggleDisplayPassword = (): void => {\n this.displayPassword = !this.displayPassword;\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || this.input.checkValidity());\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n }\n // required\n else if (this.input.validity.valueMissing) {\n this.errorMessage = this.messages.errors.required;\n }\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n this.watchReadonly(this.readonly);\n this.watchDisabled(this.disabled);\n this.watchMgWidth(this.mgWidth);\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <mg-input\n label={this.label}\n identifier={this.identifier}\n class={this.classCollection.join()}\n ariaDescribedbyIDs={[]}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n tooltip={this.tooltip}\n tooltipPosition={this.readonly && this.value === undefined ? 'label' : this.tooltipPosition}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n >\n {this.readonly ? (\n this.value !== undefined && <b class=\"mg-c-input__readonly-value\">{'•'.repeat(this.value.length)}</b>\n ) : (\n <span class=\"mg-c-input__input-group\">\n <input\n type={this.displayPassword ? 'text' : 'password'}\n class=\"mg-c-input__box mg-c-input__box--width\"\n value={this.value}\n id={this.identifier}\n name={this.name}\n placeholder={this.placeholder}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n maxlength={this.maxlength}\n aria-invalid={(this.invalid === true).toString()}\n onInput={this.handleInput}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />\n <mg-button\n label={this.messages.input.password[this.displayPassword ? 'hide' : 'display']}\n disabled={this.disabled}\n variant=\"flat\"\n class=\"mg-c-input__append-button\"\n is-icon\n onClick={this.toggleDisplayPassword}\n aria-controls={this.identifier}\n >\n <mg-icon class=\"mg-c-input__input-icon\" icon={this.displayPassword ? 'eye-slash' : 'eye'}></mg-icon>\n </mg-button>\n </span>\n )}\n </mg-input>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mg-input-password.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-password/mg-input-password.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,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CAAC,KAAK,GAAG,EAAE,CAAC;gBACnC,CAAC,GACD;YACF,iBACE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,EAC9E,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAC,MAAM,EACd,KAAK,EAAC,2BAA2B,mBAEjC,OAAO,EAAE,IAAI,CAAC,qBAAqB,mBACpB,IAAI,CAAC,UAAU;gBAE9B,eAAS,KAAK,EAAC,wBAAwB,EAAC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,GAAY,CAC1F,CACP,CACR,CACQ,CACZ,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, h, Prop, EventEmitter, State, Method, Watch } from '@stencil/core';\nimport { ClassList, isValidString } from '@mgdis/stencil-helpers';\nimport { type TooltipPosition, type Width, type EventType, classReadonly, classDisabled, widths } from '../mg-input/mg-input.conf';\nimport { initLocales } from '../../../../locales';\n\n@Component({\n tag: 'mg-input-password',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-password.css',\n shadow: true,\n})\nexport class MgInputPassword {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: EventType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputPasswordElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n handleValue(newValue: string): void {\n this.valueChange.emit(newValue);\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop?: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop() placeholder?: string;\n\n /**\n * Input max length\n */\n @Prop() maxlength;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n @Watch('readonly')\n watchReadonly(newValue: MgInputPassword['readonly']): void {\n if (newValue) this.classCollection.add(classReadonly);\n else this.classCollection.delete(classReadonly);\n }\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n @Watch('disabled')\n watchDisabled(newValue: MgInputPassword['disabled']): void {\n if (newValue) this.classCollection.add(classDisabled);\n else this.classCollection.delete(classDisabled);\n }\n\n /**\n * Define input width\n */\n @Prop() mgWidth: Width = 'full';\n @Watch('mgWidth')\n watchMgWidth(newValue: MgInputPassword['mgWidth']): void {\n // reset width class\n widths.forEach(width => {\n this.classCollection.delete(`mg-c-input--width-${width}`);\n });\n\n // apply new width\n if (newValue !== undefined) this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip?: string;\n\n /**\n * Define tooltip position\n */\n @Prop() tooltipPosition: TooltipPosition = 'input';\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText?: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--password']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Indicates if password is displayed or not\n */\n @State() displayPassword = false;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputPasswordElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputPasswordElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputPassword['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-password> method \"setError()\" param \"valid\" must be a boolean.');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-password> method \"setError()\" param \"errorMessage\" must be a string.');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Reset value, validity and error state\n */\n @Method()\n async reset(): Promise<void> {\n if (!this.readonly) {\n this.value = '';\n this.checkValidity();\n this.errorMessage = undefined;\n this.hasDisplayedError = false;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputPassword['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.handlerInProgress = 'blur';\n this.displayError().finally(() => {\n // reset guard\n this.handlerInProgress = undefined;\n });\n };\n\n /**\n * Toggle display-pasword value\n */\n private toggleDisplayPassword = (): void => {\n this.displayPassword = !this.displayPassword;\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || this.input.checkValidity());\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n }\n // required\n else if (this.input.validity.valueMissing) {\n this.errorMessage = this.messages.errors.required;\n }\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n this.watchReadonly(this.readonly);\n this.watchDisabled(this.disabled);\n this.watchMgWidth(this.mgWidth);\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <mg-input\n label={this.label}\n identifier={this.identifier}\n class={this.classCollection.join()}\n ariaDescribedbyIDs={[]}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n tooltip={this.tooltip}\n tooltipPosition={this.readonly && this.value === undefined ? 'label' : this.tooltipPosition}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n >\n {this.readonly ? (\n this.value !== undefined && <b class=\"mg-c-input__readonly-value\">{'•'.repeat(this.value.length)}</b>\n ) : (\n <span class=\"mg-c-input__input-group\">\n <input\n type={this.displayPassword ? 'text' : 'password'}\n class=\"mg-c-input__box mg-c-input__box--width\"\n value={this.value}\n id={this.identifier}\n name={this.name}\n placeholder={this.placeholder}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n maxlength={this.maxlength}\n aria-invalid={(this.invalid === true).toString()}\n onInput={this.handleInput}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />\n <mg-button\n label={this.messages.input.password[this.displayPassword ? 'hide' : 'display']}\n disabled={this.disabled}\n variant=\"flat\"\n class=\"mg-c-input__append-button\"\n is-icon\n onClick={this.toggleDisplayPassword}\n aria-controls={this.identifier}\n >\n <mg-icon class=\"mg-c-input__input-icon\" icon={this.displayPassword ? 'eye-slash' : 'eye'}></mg-icon>\n </mg-button>\n </span>\n )}\n </mg-input>\n );\n }\n}\n"]}
@@ -1,5 +1,3 @@
1
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
1
  import { h } from "@stencil/core";
4
2
  import { ClassList, allItemsAreString, isValidString, toString } from "@mgdis/stencil-helpers";
5
3
  import { classReadonly, classDisabled, classFieldset } from "../mg-input/mg-input.conf";
@@ -88,6 +86,7 @@ export class MgInputRadio {
88
86
  this.options = undefined;
89
87
  this.readonlyValue = undefined;
90
88
  }
89
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
91
90
  watchValue(newValue) {
92
91
  var _a;
93
92
  if (allItemsAreString(this.items) && typeof newValue === 'string') {
@@ -175,6 +174,17 @@ export class MgInputRadio {
175
174
  this.hasDisplayedError = this.invalid;
176
175
  }
177
176
  }
177
+ /**
178
+ * Reset value, validity and error state
179
+ */
180
+ async reset() {
181
+ if (!this.readonly) {
182
+ this.value = undefined;
183
+ this.checkValidity();
184
+ this.errorMessage = undefined;
185
+ this.hasDisplayedError = false;
186
+ }
187
+ }
178
188
  /**
179
189
  * Method to set validity values
180
190
  * @param newValue - valid new value
@@ -215,7 +225,7 @@ export class MgInputRadio {
215
225
  * @returns HTML Element
216
226
  */
217
227
  render() {
218
- return (h("mg-input", { key: '228bdfa7215bf39bbdd5ca97b46ca761a3f42779', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], 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) => {
228
+ return (h("mg-input", { key: '1f27ea2672375c28b2b7afca66ebd09f8dfc2354', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], 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) => {
219
229
  if (el !== null)
220
230
  this.inputs[index] = el;
221
231
  } }), h("label", { htmlFor: this.identifier + '_' + index }, input.title))))))));
@@ -630,6 +640,23 @@ export class MgInputRadio {
630
640
  "text": "errorMessage - the error message to display"
631
641
  }]
632
642
  }
643
+ },
644
+ "reset": {
645
+ "complexType": {
646
+ "signature": "() => Promise<void>",
647
+ "parameters": [],
648
+ "references": {
649
+ "Promise": {
650
+ "location": "global",
651
+ "id": "global::Promise"
652
+ }
653
+ },
654
+ "return": "Promise<void>"
655
+ },
656
+ "docs": {
657
+ "text": "Reset value, validity and error state",
658
+ "tags": []
659
+ }
633
660
  }
634
661
  };
635
662
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mg-input-radio.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-radio/mg-input-radio.tsx"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,SAAS,E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any */\nimport { Component, Element, Event, h, Prop, EventEmitter, State, Watch, Method } from '@stencil/core';\nimport { ClassList, allItemsAreString, isValidString, toString } from '@mgdis/stencil-helpers';\nimport { RadioOption } from './mg-input-radio.conf';\nimport { type EventType, classReadonly, type TooltipPosition, classDisabled, classFieldset } from '../mg-input/mg-input.conf';\nimport { initLocales } from '../../../../locales';\n\n/**\n * type Option validation function\n * @param option - radio option\n * @returns radio option type is valid\n */\nconst isOption = (option: unknown): option is RadioOption =>\n typeof option === 'object' && typeof (option as RadioOption).title === 'string' && (option as RadioOption).value !== undefined;\n\n@Component({\n tag: 'mg-input-radio',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-radio.css',\n shadow: true,\n})\nexport class MgInputRadio {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private inputs: HTMLInputElement[] = [];\n\n // classes\n private readonly classVerticalList = 'mg-c-input--vertical-list';\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: EventType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputRadioElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true }) value: any;\n @Watch('value')\n watchValue(newValue: any): void {\n if (allItemsAreString(this.items) && typeof newValue === 'string') {\n this.readonlyValue = newValue;\n } else if (Array.isArray(this.items) && this.items.every(isOption)) {\n this.readonlyValue = this.items.find(item => item.value === newValue)?.title;\n } else {\n this.readonlyValue = null;\n }\n this.valueChange.emit(newValue);\n }\n\n /**\n * Items are the possible options to select\n */\n @Prop() items!: string[] | RadioOption[];\n @Watch('items')\n validateItems(newValue: string[] | RadioOption[]): void {\n // Validate if items have required min length\n if (typeof newValue === 'object' && newValue.length < 2) {\n throw new Error(`<mg-input-radio> prop \"items\" require at least 2 items. Passed value: ${toString(newValue)}.`);\n }\n // String array\n else if (allItemsAreString(newValue as string[])) {\n this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));\n }\n // Object array\n else if (newValue && (newValue as RadioOption[]).every(item => isOption(item))) {\n this.options = newValue as RadioOption[];\n } else {\n 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)}.`);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop = false;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Define if inputs are display verticaly\n */\n @Prop() inputVerticalList = false;\n @Watch('inputVerticalList')\n watchInputVerticalList(newValue: MgInputRadio['inputVerticalList']): void {\n if (newValue) this.classCollection.add(this.classVerticalList);\n else this.classCollection.delete(this.classVerticalList);\n }\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n @Watch('readonly')\n watchReadonly(newValue: MgInputRadio['readonly']): void {\n if (newValue) this.classCollection.add(classReadonly);\n else this.classCollection.delete(classReadonly);\n }\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n this.inputs.forEach(input => {\n input[prop] = newValue;\n });\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n\n @Watch('disabled')\n watchDisabled(newValue: MgInputRadio['disabled']): void {\n if (newValue) this.classCollection.add(classDisabled);\n else this.classCollection.delete(classDisabled);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip?: string;\n\n /**\n * Define tooltip position\n */\n @Prop() tooltipPosition: TooltipPosition = 'input';\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText?: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--radio', classFieldset]);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Formated items for display\n */\n @State() options: RadioOption[];\n\n /**\n * Value to display in readonly mode\n */\n @State() readonlyValue: string;\n\n /**\n * Emitted event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputRadioElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputRadioElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputRadio['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-radio> method \"setError()\" param \"valid\" must be a boolean.');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-radio> method \"setError()\" param \"errorMessage\" must be a string.');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputRadio['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n * @param event - input event\n */\n private handleInput = (event: InputEvent & { target: HTMLInputElement }) => {\n this.checkValidity();\n this.value = this.options[event.target.value].value;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.handlerInProgress = 'blur';\n this.checkValidity();\n this.setErrorMessage();\n // reset guard\n this.handlerInProgress = undefined;\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || this.getInvalidElement() === undefined);\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n const invalidElement = this.getInvalidElement();\n\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n } else if (invalidElement.validity.valueMissing) {\n this.errorMessage = this.messages.errors.required;\n }\n }\n };\n\n /**\n * get invalid element\n * @returns element\n */\n private getInvalidElement = (): HTMLInputElement => this.inputs.find((input: HTMLInputElement) => !input.disabled && !input.readOnly && !input.checkValidity());\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n // Validate\n this.validateItems(this.items);\n this.watchInputVerticalList(this.inputVerticalList);\n this.watchReadonly(this.readonly);\n this.watchDisabled(this.disabled);\n this.watchValue(this.value);\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <mg-input\n label={this.label}\n identifier={this.identifier}\n class={this.classCollection.join()}\n ariaDescribedbyIDs={[]}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n tooltip={this.tooltip}\n tooltipPosition={this.readonly && !this.value ? 'label' : this.tooltipPosition}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n >\n {this.readonly ? (\n this.readonlyValue && <b class=\"mg-c-input__readonly-value\">{this.readonlyValue}</b>\n ) : (\n <ul class=\"mg-c-input__input-group-container\" role=\"list\">\n {this.options.map((input, index) => (\n <li key={input.title} class={{ 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled }}>\n <input\n type=\"radio\"\n id={this.identifier + '_' + index}\n name={this.identifier}\n value={index}\n checked={JSON.stringify(this.value) === JSON.stringify(this.options[index].value)}\n disabled={this.disabled || input.disabled}\n required={this.required}\n onBlur={this.handleBlur}\n onInput={this.handleInput}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.inputs[index] = el;\n }}\n />\n <label htmlFor={this.identifier + '_' + index}>{input.title}</label>\n </li>\n ))}\n </ul>\n )}\n </mg-input>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mg-input-radio.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-radio/mg-input-radio.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAkB,aAAa,EAAwB,aAAa,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC9H,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,MAAe,EAAyB,EAAE,CAC1D,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAQ,MAAsB,CAAC,KAAK,KAAK,QAAQ,IAAK,MAAsB,CAAC,KAAK,KAAK,SAAS,CAAC;AAOjI,MAAM,OAAO,YAAY;;QACvB;;sBAEc;QAEd,gBAAgB;QACR,W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AC,EACjF,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,EACzC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,GAAG,EAAE,CAAC,EAAoB,EAAE,EAAE;oBAC5B,IAAI,EAAE,KAAK,IAAI;wBAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;gBAC3C,CAAC,GACD;YACF,aAAO,OAAO,EAAE,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,KAAK,IAAG,KAAK,CAAC,KAAK,CAAS,CACjE,CACN,CAAC,CACC,CACN,CACQ,CACZ,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, h, Prop, EventEmitter, State, Watch, Method } from '@stencil/core';\nimport { ClassList, allItemsAreString, isValidString, toString } from '@mgdis/stencil-helpers';\nimport { RadioOption } from './mg-input-radio.conf';\nimport { type EventType, classReadonly, type TooltipPosition, classDisabled, classFieldset } from '../mg-input/mg-input.conf';\nimport { initLocales } from '../../../../locales';\n\n/**\n * type Option validation function\n * @param option - radio option\n * @returns radio option type is valid\n */\nconst isOption = (option: unknown): option is RadioOption =>\n typeof option === 'object' && typeof (option as RadioOption).title === 'string' && (option as RadioOption).value !== undefined;\n\n@Component({\n tag: 'mg-input-radio',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-radio.css',\n shadow: true,\n})\nexport class MgInputRadio {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private inputs: HTMLInputElement[] = [];\n\n // classes\n private readonly classVerticalList = 'mg-c-input--vertical-list';\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: EventType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputRadioElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true }) value: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n @Watch('value')\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n watchValue(newValue: any): void {\n if (allItemsAreString(this.items) && typeof newValue === 'string') {\n this.readonlyValue = newValue;\n } else if (Array.isArray(this.items) && this.items.every(isOption)) {\n this.readonlyValue = this.items.find(item => item.value === newValue)?.title;\n } else {\n this.readonlyValue = null;\n }\n this.valueChange.emit(newValue);\n }\n\n /**\n * Items are the possible options to select\n */\n @Prop() items!: string[] | RadioOption[];\n @Watch('items')\n validateItems(newValue: string[] | RadioOption[]): void {\n // Validate if items have required min length\n if (typeof newValue === 'object' && newValue.length < 2) {\n throw new Error(`<mg-input-radio> prop \"items\" require at least 2 items. Passed value: ${toString(newValue)}.`);\n }\n // String array\n else if (allItemsAreString(newValue as string[])) {\n this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));\n }\n // Object array\n else if (newValue && (newValue as RadioOption[]).every(item => isOption(item))) {\n this.options = newValue as RadioOption[];\n } else {\n 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)}.`);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop = false;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Define if inputs are display verticaly\n */\n @Prop() inputVerticalList = false;\n @Watch('inputVerticalList')\n watchInputVerticalList(newValue: MgInputRadio['inputVerticalList']): void {\n if (newValue) this.classCollection.add(this.classVerticalList);\n else this.classCollection.delete(this.classVerticalList);\n }\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n @Watch('readonly')\n watchReadonly(newValue: MgInputRadio['readonly']): void {\n if (newValue) this.classCollection.add(classReadonly);\n else this.classCollection.delete(classReadonly);\n }\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n this.inputs.forEach(input => {\n input[prop] = newValue;\n });\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n\n @Watch('disabled')\n watchDisabled(newValue: MgInputRadio['disabled']): void {\n if (newValue) this.classCollection.add(classDisabled);\n else this.classCollection.delete(classDisabled);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip?: string;\n\n /**\n * Define tooltip position\n */\n @Prop() tooltipPosition: TooltipPosition = 'input';\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText?: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--radio', classFieldset]);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Formated items for display\n */\n @State() options: RadioOption[];\n\n /**\n * Value to display in readonly mode\n */\n @State() readonlyValue: string;\n\n /**\n * Emitted event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputRadioElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputRadioElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputRadio['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-radio> method \"setError()\" param \"valid\" must be a boolean.');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-radio> method \"setError()\" param \"errorMessage\" must be a string.');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Reset value, validity and error state\n */\n @Method()\n async reset(): Promise<void> {\n if (!this.readonly) {\n this.value = undefined;\n this.checkValidity();\n this.errorMessage = undefined;\n this.hasDisplayedError = false;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputRadio['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n * @param event - input event\n */\n private handleInput = (event: InputEvent & { target: HTMLInputElement }) => {\n this.checkValidity();\n this.value = this.options[event.target.value].value;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.handlerInProgress = 'blur';\n this.checkValidity();\n this.setErrorMessage();\n // reset guard\n this.handlerInProgress = undefined;\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || this.getInvalidElement() === undefined);\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n const invalidElement = this.getInvalidElement();\n\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n } else if (invalidElement.validity.valueMissing) {\n this.errorMessage = this.messages.errors.required;\n }\n }\n };\n\n /**\n * get invalid element\n * @returns element\n */\n private getInvalidElement = (): HTMLInputElement => this.inputs.find((input: HTMLInputElement) => !input.disabled && !input.readOnly && !input.checkValidity());\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n // Validate\n this.validateItems(this.items);\n this.watchInputVerticalList(this.inputVerticalList);\n this.watchReadonly(this.readonly);\n this.watchDisabled(this.disabled);\n this.watchValue(this.value);\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <mg-input\n label={this.label}\n identifier={this.identifier}\n class={this.classCollection.join()}\n ariaDescribedbyIDs={[]}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n tooltip={this.tooltip}\n tooltipPosition={this.readonly && !this.value ? 'label' : this.tooltipPosition}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n >\n {this.readonly ? (\n this.readonlyValue && <b class=\"mg-c-input__readonly-value\">{this.readonlyValue}</b>\n ) : (\n <ul class=\"mg-c-input__input-group-container\" role=\"list\">\n {this.options.map((input, index) => (\n <li key={input.title} class={{ 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled }}>\n <input\n type=\"radio\"\n id={this.identifier + '_' + index}\n name={this.identifier}\n value={index}\n checked={JSON.stringify(this.value) === JSON.stringify(this.options[index].value)}\n disabled={this.disabled || input.disabled}\n required={this.required}\n onBlur={this.handleBlur}\n onInput={this.handleInput}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.inputs[index] = el;\n }}\n />\n <label htmlFor={this.identifier + '_' + index}>{input.title}</label>\n </li>\n ))}\n </ul>\n )}\n </mg-input>\n );\n }\n}\n"]}