@mgdis/mg-components 6.20.0 → 6.22.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 (205) hide show
  1. package/dist/cjs/{index-TUElr4Wv.js → index-BxB20_Vw.js} +54 -0
  2. package/dist/cjs/{index-Bp6wZzau.js → index-C2viYwrR.js} +1761 -80
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/mg-action-more_37.cjs.entry.js +761 -371
  5. package/dist/cjs/mg-alert.cjs.entry.js +17 -9
  6. package/dist/cjs/mg-breadcrumb.cjs.entry.js +63 -0
  7. package/dist/cjs/mg-components.cjs.js +3 -3
  8. package/dist/cjs/mg-fieldset.cjs.entry.js +24 -7
  9. package/dist/cjs/mg-input-combobox.cjs.entry.js +49 -19
  10. package/dist/cjs/mg-input-file.cjs.entry.js +384 -0
  11. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +40096 -15821
  12. package/dist/cjs/{mg-input.conf-D7jmj_lh.js → mg-input.conf-BNpeATnq.js} +7 -0
  13. package/dist/cjs/mg-loader.cjs.entry.js +8 -6
  14. package/dist/cjs/mg-progress.cjs.entry.js +19 -9
  15. package/dist/collection/assets/icons/index.js +1 -1
  16. package/dist/collection/collection-manifest.json +5 -3
  17. package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js +1 -1
  18. package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js +1 -1
  19. package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
  20. package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.js +2 -2
  22. package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
  23. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +1 -1
  24. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +1 -1
  25. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +6 -0
  26. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +1 -1
  27. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +2 -2
  28. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +2 -2
  29. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +1 -1
  30. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +1 -1
  31. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +1 -1
  32. package/dist/collection/components/molecules/inputs/mg-input-file/mg-input-file.js +877 -0
  33. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
  34. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +2 -2
  35. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
  36. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/custom-properties.scss +212 -0
  37. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.conf.js +1 -0
  38. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/index.js +300 -94
  39. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.conf.js +29 -0
  40. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +163 -53
  41. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +2 -2
  43. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
  44. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
  45. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +3 -36
  46. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.conf.js +0 -4
  47. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +21 -43
  48. package/dist/collection/components/molecules/menus/mg-menu-item/mg-menu-item.js +65 -38
  49. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -2
  50. package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
  51. package/dist/collection/components/molecules/mg-breadcrumb/mg-breadcrumb.conf.js +1 -0
  52. package/dist/collection/components/molecules/mg-breadcrumb/mg-breadcrumb.js +92 -0
  53. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  54. package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +12 -3
  55. package/dist/collection/components/molecules/mg-form/mg-form.js +12 -2
  56. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  57. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  58. package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
  59. package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
  60. package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
  61. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  62. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
  63. package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
  64. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  65. package/dist/collection/components/molecules/mg-table/mg-table.js +37 -0
  66. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +0 -4
  67. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +13 -33
  68. package/dist/collection/locales/en/messages.json +14 -0
  69. package/dist/collection/locales/fr/messages.json +14 -0
  70. package/dist/components/events.utils.js +1 -23
  71. package/dist/components/index.d.ts +2 -0
  72. package/dist/components/index.js +1 -1
  73. package/dist/components/index2.js +1 -408
  74. package/dist/components/index3.js +1 -476
  75. package/dist/components/mg-action-more.js +1 -254
  76. package/dist/components/mg-alert.js +1 -224
  77. package/dist/components/mg-badge.js +1 -6
  78. package/dist/components/mg-badge2.js +1 -113
  79. package/dist/components/mg-breadcrumb.d.ts +11 -0
  80. package/dist/components/mg-breadcrumb.js +1 -0
  81. package/dist/components/mg-button.js +1 -6
  82. package/dist/components/mg-button2.js +1 -275
  83. package/dist/components/mg-card.js +1 -6
  84. package/dist/components/mg-card2.js +1 -92
  85. package/dist/components/mg-character-left.js +1 -6
  86. package/dist/components/mg-character-left2.js +1 -75
  87. package/dist/components/mg-details.js +1 -104
  88. package/dist/components/mg-divider.js +1 -6
  89. package/dist/components/mg-divider2.js +1 -49
  90. package/dist/components/mg-fieldset.js +1 -209
  91. package/dist/components/mg-form.js +1 -302
  92. package/dist/components/mg-icon.js +1 -6
  93. package/dist/components/mg-icon2.js +1 -188
  94. package/dist/components/mg-illustrated-message.js +1 -129
  95. package/dist/components/mg-input-checkbox-paginated.js +1 -6
  96. package/dist/components/mg-input-checkbox-paginated2.js +1 -135
  97. package/dist/components/mg-input-checkbox.js +1 -762
  98. package/dist/components/mg-input-combobox.js +1 -940
  99. package/dist/components/mg-input-date.js +1 -463
  100. package/dist/components/mg-input-file.d.ts +11 -0
  101. package/dist/components/mg-input-file.js +1 -0
  102. package/dist/components/mg-input-numeric.js +1 -592
  103. package/dist/components/mg-input-password.js +1 -360
  104. package/dist/components/mg-input-radio.js +1 -392
  105. package/dist/components/mg-input-rich-text-editor.js +1663 -16797
  106. package/dist/components/mg-input-select.js +1 -6
  107. package/dist/components/mg-input-select2.js +1 -481
  108. package/dist/components/mg-input-text.js +1 -6
  109. package/dist/components/mg-input-text2.js +1 -514
  110. package/dist/components/mg-input-textarea.js +1 -412
  111. package/dist/components/mg-input-title.js +1 -6
  112. package/dist/components/mg-input-title2.js +1 -81
  113. package/dist/components/mg-input-toggle.js +1 -371
  114. package/dist/components/mg-input.conf.js +1 -0
  115. package/dist/components/mg-input.js +1 -6
  116. package/dist/components/mg-input2.js +1 -459
  117. package/dist/components/mg-item-more.js +1 -6
  118. package/dist/components/mg-item-more2.js +1 -505
  119. package/dist/components/mg-loader.js +1 -6
  120. package/dist/components/mg-loader2.js +1 -74
  121. package/dist/components/mg-menu-item.js +1 -6
  122. package/dist/components/mg-menu-item2.js +1 -485
  123. package/dist/components/mg-menu.js +1 -6
  124. package/dist/components/mg-message.js +1 -6
  125. package/dist/components/mg-message2.js +1 -146
  126. package/dist/components/mg-modal.js +1 -184
  127. package/dist/components/mg-pagination.js +1 -234
  128. package/dist/components/mg-panel.js +1 -350
  129. package/dist/components/mg-popover-content.js +1 -6
  130. package/dist/components/mg-popover-content2.js +1 -96
  131. package/dist/components/mg-popover.js +1 -6
  132. package/dist/components/mg-popover2.js +1 -312
  133. package/dist/components/mg-progress.js +1 -123
  134. package/dist/components/mg-skip-links.js +1 -78
  135. package/dist/components/mg-table.js +1 -319
  136. package/dist/components/mg-tabs.js +1 -6
  137. package/dist/components/mg-tabs2.js +1 -315
  138. package/dist/components/mg-tag.js +1 -133
  139. package/dist/components/mg-tooltip-content.js +1 -6
  140. package/dist/components/mg-tooltip-content2.js +1 -42
  141. package/dist/components/mg-tooltip.js +1 -6
  142. package/dist/components/mg-tooltip2.js +1 -421
  143. package/dist/components/popper.js +1 -1790
  144. package/dist/esm/{index-BluNKQ3L.js → index-DFwaH2hS.js} +1761 -80
  145. package/dist/esm/{index-CNX6lq0x.js → index-DSEloqPn.js} +54 -1
  146. package/dist/esm/loader.js +3 -3
  147. package/dist/esm/mg-action-more_37.entry.js +761 -371
  148. package/dist/esm/mg-alert.entry.js +17 -9
  149. package/dist/esm/mg-breadcrumb.entry.js +61 -0
  150. package/dist/esm/mg-components.js +4 -4
  151. package/dist/esm/mg-fieldset.entry.js +24 -7
  152. package/dist/esm/mg-input-combobox.entry.js +49 -19
  153. package/dist/esm/mg-input-file.entry.js +382 -0
  154. package/dist/esm/mg-input-rich-text-editor.entry.js +40083 -15808
  155. package/dist/esm/{mg-input.conf-DDnrE1hD.js → mg-input.conf-C9rmNQIL.js} +7 -1
  156. package/dist/esm/mg-loader.entry.js +8 -6
  157. package/dist/esm/mg-progress.entry.js +19 -9
  158. package/dist/mg-components/locales/en/messages.json +14 -0
  159. package/dist/mg-components/locales/fr/messages.json +14 -0
  160. package/dist/mg-components/mg-components.esm.js +1 -1
  161. package/dist/mg-components/p-0482eb9f.entry.js +1 -0
  162. package/dist/mg-components/{p-7132bca1.entry.js → p-2ee92f38.entry.js} +1 -1
  163. package/dist/mg-components/{p-916dfb6d.entry.js → p-3b653226.entry.js} +1 -1
  164. package/dist/mg-components/p-5745fbea.entry.js +1 -0
  165. package/dist/mg-components/p-C9rmNQIL.js +1 -0
  166. package/dist/mg-components/p-DFwaH2hS.js +2 -0
  167. package/dist/mg-components/p-DSEloqPn.js +1 -0
  168. package/dist/mg-components/p-adec7fcc.entry.js +1 -0
  169. package/dist/mg-components/p-c63f97f0.entry.js +1658 -0
  170. package/dist/mg-components/p-c8c8cfc1.entry.js +1 -0
  171. package/dist/mg-components/p-cc793586.entry.js +1 -0
  172. package/dist/mg-components/p-d5e69c95.entry.js +1 -0
  173. package/dist/types/assets/icons/index.d.ts +2 -0
  174. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +7 -1
  175. package/dist/types/components/molecules/inputs/mg-input-file/mg-input-file.d.ts +210 -0
  176. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.conf.d.ts +17 -0
  177. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/editor/index.d.ts +27 -19
  178. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.conf.d.ts +3 -0
  179. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +50 -16
  180. package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.conf.d.ts +0 -5
  181. package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.d.ts +1 -6
  182. package/dist/types/components/molecules/menus/mg-menu/mg-menu.conf.d.ts +2 -10
  183. package/dist/types/components/molecules/menus/mg-menu/mg-menu.d.ts +7 -7
  184. package/dist/types/components/molecules/menus/mg-menu-item/mg-menu-item.d.ts +12 -8
  185. package/dist/types/components/molecules/mg-breadcrumb/mg-breadcrumb.conf.d.ts +18 -0
  186. package/dist/types/components/molecules/mg-breadcrumb/mg-breadcrumb.d.ts +34 -0
  187. package/dist/types/components/molecules/mg-table/mg-table.d.ts +6 -0
  188. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +1 -9
  189. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +4 -4
  190. package/dist/types/components.d.ts +302 -46
  191. package/dist/types/stencil-public-runtime.d.ts +76 -12
  192. package/ide/intellij/web-types.json +483 -51
  193. package/ide/vscode/css-custom-data.json +10 -2
  194. package/ide/vscode/html-custom-data.json +445 -104
  195. package/package.json +24 -23
  196. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.scss +0 -1
  197. package/dist/mg-components/p-016bd291.entry.js +0 -1
  198. package/dist/mg-components/p-186a6139.entry.js +0 -1
  199. package/dist/mg-components/p-BluNKQ3L.js +0 -2
  200. package/dist/mg-components/p-CNX6lq0x.js +0 -1
  201. package/dist/mg-components/p-DDnrE1hD.js +0 -1
  202. package/dist/mg-components/p-cd061b38.entry.js +0 -1
  203. package/dist/mg-components/p-d2c72f09.entry.js +0 -1
  204. package/dist/mg-components/p-d5a276eb.entry.js +0 -1
  205. package/ide/vscode/custom.css-data.json +0 -425
@@ -1,592 +1 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { C as ClassList, i as isValidString, t as toString } from './index2.js';
3
- import { b as localeNumber, c as localeUnit, d as localePercent, e as localeCurrency, i as initLocales } from './index3.js';
4
- import { d as defineCustomElement$5, c as classReadonly, a as classDisabled, w as widths } from './mg-input2.js';
5
- import { d as defineCustomElement$6 } from './mg-icon2.js';
6
- import { d as defineCustomElement$4 } from './mg-input-title2.js';
7
- import { d as defineCustomElement$3 } from './mg-tooltip2.js';
8
- import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
9
-
10
- /**
11
- * List of all possibles types
12
- */
13
- const types = ['decimal', 'integer'];
14
- const formats = ['none', 'number', 'currency', 'percent', 'unit'];
15
-
16
- const mgInputNumericCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-full .mg-c-input__input-group-container{width:100%;flex-grow:1}.mg-c-input.mg-c-input--width-2.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-4.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-16.mg-c-input--display-character-left .mg-c-input__input-group-container{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input .mg-c-input__box{width:auto;text-align:var(--mg-c-input-text-align, right)}";
17
-
18
- const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class MgInputNumeric extends HTMLElement {
19
- constructor(registerHost) {
20
- super();
21
- if (registerHost !== false) {
22
- this.__registerHost();
23
- }
24
- this.__attachShadow();
25
- this.valueChange = createEvent(this, "value-change", 7);
26
- this.inputValid = createEvent(this, "input-valid", 7);
27
- // hasDisplayedError (triggered by blur event)
28
- this.hasDisplayedError = false;
29
- this.customErrorMessage = { lock: false };
30
- /**
31
- * Input name
32
- * If not set the value equals the identifier
33
- */
34
- this.name = this.identifier;
35
- /**
36
- * Define if label is displayed on top
37
- */
38
- this.labelOnTop = false;
39
- /**
40
- * Define if label is visible
41
- */
42
- this.labelHide = false;
43
- /**
44
- * Define if input is required
45
- */
46
- this.required = false;
47
- /**
48
- * Define if input is readonly
49
- */
50
- this.readonly = false;
51
- /**
52
- * Define if input is disabled
53
- */
54
- this.disabled = false;
55
- /**
56
- * Define tooltip position
57
- */
58
- this.tooltipPosition = 'input';
59
- /**
60
- * Define numeric type
61
- */
62
- this.type = 'decimal';
63
- /**
64
- * Set local formatting.
65
- * Numbers are formatted based on the locale.
66
- */
67
- this.format = 'number';
68
- /**
69
- * Define currency
70
- */
71
- this.currency = 'EUR';
72
- /**
73
- * Define unit display format ('short', 'long', 'narrow')
74
- */
75
- this.unitDisplay = 'short';
76
- /**
77
- * Override integer length
78
- * integer is the number before the decimal point
79
- */
80
- this.integerLength = 13;
81
- /**
82
- * Override decimal length
83
- * decimal is the number after the decimal point
84
- */
85
- this.decimalLength = 2;
86
- /**
87
- * Component classes
88
- */
89
- this.classCollection = new ClassList(['mg-c-input--numeric']);
90
- /**
91
- * Handle input event
92
- */
93
- this.handleInput = () => {
94
- this.value = this.input.value;
95
- // Check validity
96
- this.checkValidity();
97
- if (this.hasDisplayedError) {
98
- this.setErrorMessage();
99
- }
100
- };
101
- /**
102
- * Handle focus event
103
- */
104
- this.handleFocus = () => {
105
- this.hasFocus = true;
106
- };
107
- /**
108
- * Handle blur event
109
- */
110
- this.handleBlur = () => {
111
- if (this.value === '-')
112
- this.value = '';
113
- // Display Error
114
- this.handlerInProgress = 'blur';
115
- this.displayError().finally(() => {
116
- // reset guard
117
- this.handlerInProgress = undefined;
118
- this.hasFocus = false;
119
- });
120
- };
121
- /**
122
- * Check if input is valid
123
- */
124
- this.checkValidity = () => {
125
- this.setValidity(this.readonly || this.disabled || this.getInputError() === null);
126
- };
127
- /**
128
- * Format min/max value for error message
129
- * @param value - value to format
130
- * @returns formatted value according to locale
131
- */
132
- this.formatErrorValue = (value) => localeNumber(value, this.locale, !Number.isInteger(value) && this.type === 'decimal' ? this.decimalLength : 0);
133
- /**
134
- * Set input error message
135
- * @param fromSetErrorContext - context come from `setError` method
136
- */
137
- this.setErrorMessage = (fromSetErrorContext = false) => {
138
- // Set error message
139
- this.errorMessage = undefined;
140
- if (!this.valid) {
141
- const inputError = this.getInputError();
142
- // Does have a new custom error message OR does have a custom error message locked
143
- if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
144
- this.errorMessage = this.customErrorMessage.message;
145
- }
146
- // required
147
- else if (inputError === 'required') {
148
- this.errorMessage = this.messages.errors[inputError];
149
- }
150
- // min/max
151
- else {
152
- const formattedMin = this.formatErrorValue(this.min);
153
- const formattedMax = this.formatErrorValue(this.max);
154
- this.errorMessage = this.messages.input.numeric.error[inputError].replace('{min}', formattedMin).replace('{max}', formattedMax);
155
- }
156
- }
157
- };
158
- /**
159
- * Get input error code
160
- * @returns error code
161
- */
162
- this.getInputError = () => {
163
- const hasNotEmptyValues = (toControl) => !toControl.some(value => [null, undefined].includes(value));
164
- // required
165
- if (!this.input.checkValidity() && this.input.validity.valueMissing) {
166
- return 'required';
167
- }
168
- // Only a min value is set
169
- if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {
170
- return 'min';
171
- }
172
- // Only a max value is set
173
- if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {
174
- return 'max';
175
- }
176
- // both min and max values are set
177
- if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {
178
- return 'minMax';
179
- }
180
- return null;
181
- };
182
- /**
183
- * Format value based on type
184
- * @param value - value to format
185
- * @returns formated local value
186
- */
187
- this.formatValue = (value) => {
188
- switch (this.format) {
189
- case 'number':
190
- return localeNumber(value, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);
191
- case 'currency':
192
- return localeCurrency(value, this.locale, this.currency);
193
- case 'percent':
194
- return localePercent(value / 100, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);
195
- case 'unit':
196
- return localeUnit(value, this.locale, this.unit, this.unitDisplay, this.type === 'decimal' ? this.decimalLength : undefined);
197
- case 'none':
198
- return value.toString();
199
- }
200
- };
201
- /**
202
- * Validate append slot
203
- */
204
- this.validateAppendSlot = () => {
205
- const slotAppendInput = this.element.querySelector('[slot="append-input"]');
206
- if (slotAppendInput !== null) {
207
- if (slotAppendInput.nodeName === 'MG-BUTTON') {
208
- this.classCollection.add('mg-c-input--is-input-group-append');
209
- }
210
- else {
211
- this.classCollection.add('mg-c-input--is-append-input-slot-content');
212
- this.slotContent = slotAppendInput.textContent;
213
- }
214
- }
215
- };
216
- /**
217
- * Format help text to display
218
- * @param helpText - help text format
219
- * @returns formatted help text with range information if applicable
220
- */
221
- this.formatHelpText = (helpText) => {
222
- // If the component is in readonly mode, return undefined because the message will not be rendered
223
- if (this.readonly) {
224
- return undefined;
225
- }
226
- // If a custom helpText is provided, store it but don't return it directly
227
- const text = isValidString(helpText) ? helpText : undefined;
228
- // If neither min nor max are defined, and there's no custom helpText,
229
- // we can return undefined as there's no message to display
230
- if (this.min === undefined && this.max === undefined && text === undefined) {
231
- return undefined;
232
- }
233
- // Return either custom helpText or range message
234
- return text;
235
- };
236
- /**
237
- * Renders the readonly content of the input component.
238
- * @returns The readonly content element.
239
- */
240
- this.renderReadonly = () => {
241
- return this.slotContent !== undefined ? (h("span", { class: "mg-c-input__readonly-value" }, h("b", null, this.readonlyValue), this.slotContent)) : (h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue));
242
- };
243
- }
244
- validateValue(newValue) {
245
- var _a;
246
- // has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type
247
- if (typeof newValue === 'string') {
248
- // Check if integer value starts with '0' (leading zero)
249
- if (newValue.startsWith('0') && parseInt(newValue, 10) > 0) {
250
- // Remove leading zero
251
- newValue = newValue.substring(1);
252
- }
253
- // Split number and decimal
254
- const [integer, decimal = ''] = newValue.replace('-', '').split(/[.,]/);
255
- // Regex
256
- const regex = this.type === 'integer' ? /^(?!-?0\d)-?\d+$/ : /^(?!-?0\d)-?\d+(?:[.,]\d*)?$/;
257
- // Filter input
258
- if (this.isValidValue(newValue, regex, integer, decimal)) {
259
- this.storedValue = newValue;
260
- }
261
- else {
262
- newValue = (_a = this.storedValue) !== null && _a !== void 0 ? _a : null;
263
- }
264
- // Set value and input value
265
- this.updateValues(newValue);
266
- }
267
- }
268
- watchReadonly(newValue) {
269
- if (newValue)
270
- this.classCollection.add(classReadonly);
271
- else
272
- this.classCollection.delete(classReadonly);
273
- }
274
- handleValidityChange(newValue, _oldValue, prop) {
275
- if (this.input !== undefined) {
276
- this.input[prop] = newValue;
277
- this.checkValidity();
278
- if (this.hasDisplayedError) {
279
- this.setErrorMessage();
280
- this.hasDisplayedError = false;
281
- }
282
- }
283
- }
284
- watchDisabled(newValue) {
285
- if (newValue)
286
- this.classCollection.add(classDisabled);
287
- else
288
- this.classCollection.delete(classDisabled);
289
- }
290
- watchMgWidth(newValue) {
291
- // reset width class
292
- widths.forEach(width => {
293
- this.classCollection.delete(`mg-c-input--width-${width}`);
294
- });
295
- // apply new width
296
- if (newValue !== undefined)
297
- this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
298
- }
299
- validateType(newValue) {
300
- if (!types.includes(newValue)) {
301
- throw new Error(`<mg-input-numeric> prop "type" must be one of: ${types.join(', ')}. Passed value: ${toString(newValue)}.`);
302
- }
303
- }
304
- watchFormat(newValue) {
305
- if (!formats.includes(newValue)) {
306
- throw new Error(`<mg-input-numeric> prop "format" must be one of: ${formats.join(', ')}. Passed value: ${toString(newValue)}.`);
307
- }
308
- }
309
- validateIntegerLength(newValue) {
310
- if (newValue < 1) {
311
- throw new Error(`<mg-input-numeric> prop "integer-length" must be a positive number. Passed value: ${toString(newValue)}.`);
312
- }
313
- }
314
- validateDecimalLength(newValue) {
315
- if (newValue < 1) {
316
- 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)}.`);
317
- }
318
- }
319
- /**
320
- * Set focus on input.
321
- */
322
- async setFocus() {
323
- var _a;
324
- (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
325
- }
326
- /**
327
- * Display input error if it exists.
328
- */
329
- displayError() {
330
- // Use `Promise` as requested for stencil method
331
- // Use `requestAnimationFrame` to ensure:
332
- // - DOM is fully updated before validation
333
- // - Async operations are completed
334
- // - No timing issues with Stencil's render cycle
335
- // - Keep everything in sync both inside and outside the component
336
- return new Promise(resolve => {
337
- requestAnimationFrame(() => {
338
- this.checkValidity();
339
- this.setErrorMessage();
340
- this.hasDisplayedError = this.invalid;
341
- resolve();
342
- });
343
- });
344
- }
345
- /**
346
- * Set an error and display a custom error message.
347
- * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.
348
- * It must be paired with an error message to display for the given context.
349
- * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
350
- * @param valid - value indicating the validity
351
- * @param errorMessage - the error message to display
352
- * @param errorMessageLock - lock the error message and validity state
353
- */
354
- async setError(valid, errorMessage, errorMessageLock = false) {
355
- if (typeof valid !== 'boolean') {
356
- throw new Error('<mg-input-numeric> method "setError()" param "valid" must be a boolean.');
357
- }
358
- else if (errorMessage !== undefined && !isValidString(errorMessage)) {
359
- throw new Error('<mg-input-numeric> method "setError()" param "errorMessage" must be a string.');
360
- }
361
- else {
362
- this.customErrorMessage = {
363
- lock: valid ? false : errorMessageLock,
364
- message: valid ? undefined : errorMessage,
365
- };
366
- this.setValidity(valid);
367
- this.setErrorMessage(true);
368
- this.hasDisplayedError = this.invalid;
369
- }
370
- }
371
- /**
372
- * Reset value, validity and error state
373
- */
374
- async reset() {
375
- if (!this.readonly) {
376
- this.value = '';
377
- // Use `Promise` as requested for stencil method
378
- // Use `requestAnimationFrame` to ensure:
379
- // - DOM is fully updated before validation
380
- // - Async operations are completed
381
- // - No timing issues with Stencil's render cycle
382
- // - Keep everything in sync both inside and outside the component
383
- return new Promise(resolve => {
384
- requestAnimationFrame(() => {
385
- // unlock validity check by reseting customErrorMessage
386
- this.customErrorMessage = { lock: false };
387
- this.checkValidity();
388
- this.errorMessage = undefined;
389
- this.hasDisplayedError = false;
390
- resolve();
391
- });
392
- });
393
- }
394
- }
395
- /**
396
- * Method to set validity values
397
- * @param newValue - valid new value
398
- */
399
- setValidity(newValue) {
400
- const oldValue = this.valid;
401
- if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
402
- this.valid = newValue;
403
- }
404
- this.invalid = !this.valid;
405
- // We need to send valid event even if it is the same value
406
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
407
- this.inputValid.emit(this.valid);
408
- }
409
- /**
410
- * Checks if the given value is valid according to the defined rules.
411
- * @param value - The input value to validate.
412
- * @param regex - The regular expression for validation.
413
- * @param integer - The integer part of the value.
414
- * @param decimal - The decimal part of the value.
415
- * @returns Returns true if the value is valid, otherwise false.
416
- */
417
- isValidValue(value, regex, integer, decimal) {
418
- return (['', '-'].includes(value) || (regex.exec(value) !== null && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength)));
419
- }
420
- /**
421
- * Updates the component values based on the validated input value.
422
- * @param newValue - The validated input value.
423
- */
424
- updateValues(newValue) {
425
- this.value = newValue;
426
- if (this.input !== undefined) {
427
- this.input.value = this.value;
428
- }
429
- this.numericValue = !['', null].includes(this.value) && !isNaN(parseFloat(this.value)) ? parseFloat(this.value.replace(',', '.')) : null;
430
- if (newValue === null || (newValue === this.storedValue && !Object.is(this.numericValue, -0))) {
431
- this.valueChange.emit(this.numericValue);
432
- }
433
- this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
434
- }
435
- /**
436
- * Displayed value in input
437
- * Change on focus/blur
438
- * @returns display value
439
- */
440
- displayValue() {
441
- return this.hasFocus ? this.value : this.readonlyValue;
442
- }
443
- /*************
444
- * Lifecycle *
445
- *************/
446
- /**
447
- * Check if component props are well configured on init
448
- * @returns timeout
449
- */
450
- componentWillLoad() {
451
- // Get locales
452
- const locales = initLocales(this.element);
453
- this.locale = locales.locale;
454
- this.messages = locales.messages;
455
- // Validate component config
456
- this.watchFormat(this.format);
457
- this.validateType(this.type);
458
- this.validateIntegerLength(this.integerLength);
459
- this.validateDecimalLength(this.decimalLength);
460
- // validate value
461
- this.validateValue(this.value);
462
- this.validateAppendSlot();
463
- this.watchReadonly(this.readonly);
464
- this.watchDisabled(this.disabled);
465
- this.watchMgWidth(this.mgWidth);
466
- // Check validity when component is ready
467
- // return a promise to process action only in the FIRST render().
468
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
469
- return setTimeout(() => {
470
- this.checkValidity();
471
- }, 0);
472
- }
473
- /**
474
- * Render
475
- * @returns HTML Element
476
- */
477
- render() {
478
- return (h("mg-input", { key: 'c47f7c310587fc3bb4e7d5ffd07854a2297958df', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly
479
- ? this.readonlyValue && this.renderReadonly()
480
- : [
481
- h("input", { key: "input", type: "text", class: "mg-c-input__box mg-c-input__box--width", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
482
- if (el !== null)
483
- this.input = el;
484
- } }),
485
- h("slot", { key: "slot", name: "append-input" }),
486
- ]));
487
- }
488
- get element() { return this; }
489
- static get watchers() { return {
490
- "value": ["validateValue"],
491
- "readonly": ["watchReadonly", "handleValidityChange"],
492
- "required": ["handleValidityChange"],
493
- "disabled": ["handleValidityChange", "watchDisabled"],
494
- "min": ["handleValidityChange"],
495
- "max": ["handleValidityChange"],
496
- "mgWidth": ["watchMgWidth"],
497
- "type": ["validateType"],
498
- "format": ["watchFormat"],
499
- "integerLength": ["validateIntegerLength"],
500
- "decimalLength": ["validateDecimalLength"]
501
- }; }
502
- static get style() { return mgInputNumericCss; }
503
- }, [257, "mg-input-numeric", {
504
- "value": [1537],
505
- "identifier": [1],
506
- "name": [1],
507
- "label": [1],
508
- "labelOnTop": [4, "label-on-top"],
509
- "labelHide": [4, "label-hide"],
510
- "placeholder": [1],
511
- "required": [4],
512
- "readonly": [4],
513
- "max": [2],
514
- "min": [2],
515
- "disabled": [4],
516
- "mgWidth": [8, "mg-width"],
517
- "tooltip": [1],
518
- "tooltipPosition": [1, "tooltip-position"],
519
- "helpText": [1, "help-text"],
520
- "type": [1],
521
- "format": [1],
522
- "currency": [1],
523
- "unit": [1],
524
- "unitDisplay": [1, "unit-display"],
525
- "integerLength": [2, "integer-length"],
526
- "decimalLength": [2, "decimal-length"],
527
- "valid": [1028],
528
- "invalid": [1028],
529
- "classCollection": [32],
530
- "errorMessage": [32],
531
- "hasFocus": [32],
532
- "setFocus": [64],
533
- "displayError": [64],
534
- "setError": [64],
535
- "reset": [64]
536
- }, undefined, {
537
- "value": ["validateValue"],
538
- "readonly": ["watchReadonly", "handleValidityChange"],
539
- "required": ["handleValidityChange"],
540
- "disabled": ["handleValidityChange", "watchDisabled"],
541
- "min": ["handleValidityChange"],
542
- "max": ["handleValidityChange"],
543
- "mgWidth": ["watchMgWidth"],
544
- "type": ["validateType"],
545
- "format": ["watchFormat"],
546
- "integerLength": ["validateIntegerLength"],
547
- "decimalLength": ["validateDecimalLength"]
548
- }]);
549
- function defineCustomElement$1() {
550
- if (typeof customElements === "undefined") {
551
- return;
552
- }
553
- const components = ["mg-input-numeric", "mg-icon", "mg-input", "mg-input-title", "mg-tooltip", "mg-tooltip-content"];
554
- components.forEach(tagName => { switch (tagName) {
555
- case "mg-input-numeric":
556
- if (!customElements.get(tagName)) {
557
- customElements.define(tagName, MgInputNumeric$1);
558
- }
559
- break;
560
- case "mg-icon":
561
- if (!customElements.get(tagName)) {
562
- defineCustomElement$6();
563
- }
564
- break;
565
- case "mg-input":
566
- if (!customElements.get(tagName)) {
567
- defineCustomElement$5();
568
- }
569
- break;
570
- case "mg-input-title":
571
- if (!customElements.get(tagName)) {
572
- defineCustomElement$4();
573
- }
574
- break;
575
- case "mg-tooltip":
576
- if (!customElements.get(tagName)) {
577
- defineCustomElement$3();
578
- }
579
- break;
580
- case "mg-tooltip-content":
581
- if (!customElements.get(tagName)) {
582
- defineCustomElement$2();
583
- }
584
- break;
585
- } });
586
- }
587
- defineCustomElement$1();
588
-
589
- const MgInputNumeric = MgInputNumeric$1;
590
- const defineCustomElement = defineCustomElement$1;
591
-
592
- export { MgInputNumeric, defineCustomElement };
1
+ import{transformTag as t,proxyCustomElement as i,HTMLElement as e,createEvent as s,h as n}from"@stencil/core/internal/client";import{C as a,i as r,t as o}from"./index2.js";import{c as h,d as m,e as c,f as u,i as l}from"./index3.js";import{c as p,b as g,w as d}from"./mg-input.conf.js";import{d as b}from"./mg-icon2.js";import{d as v}from"./mg-input2.js";import{d as f}from"./mg-input-title2.js";import{d as w}from"./mg-tooltip2.js";import{d as y}from"./mg-tooltip-content2.js";const _=["decimal","integer"],x=["none","number","currency","percent","unit"],z=i(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.valueChange=s(this,"value-change",7),this.inputValid=s(this,"input-valid",7),this.hasDisplayedError=!1,this.customErrorMessage={lock:!1},this.name=this.identifier,this.labelOnTop=!1,this.labelHide=!1,this.required=!1,this.readonly=!1,this.disabled=!1,this.tooltipPosition="input",this.type="decimal",this.format="number",this.currency="EUR",this.unitDisplay="short",this.integerLength=13,this.decimalLength=2,this.classCollection=new a(["mg-c-input--numeric"]),this.handleInput=()=>{this.value=this.input.value,this.checkValidity(),this.hasDisplayedError&&this.setErrorMessage()},this.handleFocus=()=>{this.hasFocus=!0},this.handleBlur=()=>{"-"===this.value&&(this.value=""),this.handlerInProgress="blur",this.displayError().finally((()=>{this.handlerInProgress=void 0,this.hasFocus=!1}))},this.checkValidity=()=>{this.setValidity(this.readonly||this.disabled||null===this.getInputError())},this.formatErrorValue=t=>h(t,this.locale,Number.isInteger(t)||"decimal"!==this.type?0:this.decimalLength),this.setErrorMessage=(t=!1)=>{if(this.errorMessage=void 0,!this.valid){const i=this.getInputError();if(t||this.customErrorMessage.lock&&void 0!==this.customErrorMessage.message)this.errorMessage=this.customErrorMessage.message;else if("required"===i)this.errorMessage=this.messages.errors[i];else{const t=this.formatErrorValue(this.min),e=this.formatErrorValue(this.max);this.errorMessage=this.messages.input.numeric.error[i].replace("{min}",t).replace("{max}",e)}}},this.getInputError=()=>{const t=t=>!t.some((t=>[null,void 0].includes(t)));return!this.input.checkValidity()&&this.input.validity.valueMissing?"required":t([this.min,this.numericValue])&&this.numericValue<this.min&&void 0===this.max?"min":t([this.max,this.numericValue])&&this.numericValue>this.max&&void 0===this.min?"max":t([this.min,this.max,this.numericValue])&&(this.numericValue<this.min||this.numericValue>this.max)?"minMax":null},this.formatValue=t=>{switch(this.format){case"number":return h(t,this.locale,"decimal"===this.type?this.decimalLength:void 0);case"currency":return u(t,this.locale,this.currency);case"percent":return c(t/100,this.locale,"decimal"===this.type?this.decimalLength:void 0);case"unit":return m(t,this.locale,this.unit,this.unitDisplay,"decimal"===this.type?this.decimalLength:void 0);case"none":return""+t}},this.validateAppendSlot=()=>{const t=this.element.querySelector('[slot="append-input"]');null!==t&&("MG-BUTTON"===t.nodeName?this.classCollection.add("mg-c-input--is-input-group-append"):(this.classCollection.add("mg-c-input--is-append-input-slot-content"),this.slotContent=t.textContent))},this.formatHelpText=t=>{if(this.readonly)return;const i=r(t)?t:void 0;return void 0!==this.min||void 0!==this.max||void 0!==i?i:void 0},this.renderReadonly=()=>void 0!==this.slotContent?n("span",{class:"mg-c-input__readonly-value"},n("b",null,this.readonlyValue),this.slotContent):n("b",{class:"mg-c-input__readonly-value"},this.readonlyValue)}validateValue(t){var i;if("string"==typeof t){t.startsWith("0")&&parseInt(t,10)>0&&(t=t.substring(1));const[e,s=""]=t.replace("-","").split(/[.,]/);this.isValidValue(t,"integer"===this.type?/^(?!-?0\d)-?\d+$/:/^(?!-?0\d)-?\d+(?:[.,]\d*)?$/,e,s)?this.storedValue=t:t=null!==(i=this.storedValue)&&void 0!==i?i:null,this.updateValues(t)}}watchReadonly(t){t?this.classCollection.add(p):this.classCollection.delete(p)}handleValidityChange(t,i,e){void 0!==this.input&&(this.input[e]=t,this.checkValidity(),this.hasDisplayedError&&(this.setErrorMessage(),this.hasDisplayedError=!1))}watchDisabled(t){t?this.classCollection.add(g):this.classCollection.delete(g)}watchMgWidth(t){d.forEach((t=>{this.classCollection.delete("mg-c-input--width-"+t)})),void 0!==t&&this.classCollection.add("mg-c-input--width-"+this.mgWidth)}validateType(t){if(!_.includes(t))throw Error(`<mg-input-numeric> prop "type" must be one of: ${_.join(", ")}. Passed value: ${o(t)}.`)}watchFormat(t){if(!x.includes(t))throw Error(`<mg-input-numeric> prop "format" must be one of: ${x.join(", ")}. Passed value: ${o(t)}.`)}validateIntegerLength(t){if(t<1)throw Error(`<mg-input-numeric> prop "integer-length" must be a positive number. Passed value: ${o(t)}.`)}validateDecimalLength(t){if(t<1)throw Error(`<mg-input-numeric> prop "decimal-length" must be a positive number, consider using prop "type" to "integer" instead. Passed value: ${o(t)}.`)}async setFocus(){var t;null===(t=this.input)||void 0===t||t.focus()}displayError(){return new Promise((t=>{requestAnimationFrame((()=>{this.checkValidity(),this.setErrorMessage(),this.hasDisplayedError=this.invalid,t()}))}))}async setError(t,i,e=!1){if("boolean"!=typeof t)throw Error('<mg-input-numeric> method "setError()" param "valid" must be a boolean.');if(void 0!==i&&!r(i))throw Error('<mg-input-numeric> method "setError()" param "errorMessage" must be a string.');this.customErrorMessage={lock:!t&&e,message:t?void 0:i},this.setValidity(t),this.setErrorMessage(!0),this.hasDisplayedError=this.invalid}async reset(){if(!this.readonly)return this.value="",new Promise((t=>{requestAnimationFrame((()=>{this.customErrorMessage={lock:!1},this.checkValidity(),this.errorMessage=void 0,this.hasDisplayedError=!1,t()}))}))}setValidity(t){const i=this.valid;this.customErrorMessage.lock&&(void 0===this.customErrorMessage.message||t)||(this.valid=t),this.invalid=!this.valid,(void 0===this.handlerInProgress||"blur"===this.handlerInProgress&&this.valid!==i)&&this.inputValid.emit(this.valid)}isValidValue(t,i,e,s){return["","-"].includes(t)||null!==i.exec(t)&&e.length<=this.integerLength&&s.length<=("integer"===this.type?0:this.decimalLength)}updateValues(t){this.value=t,void 0!==this.input&&(this.input.value=this.value),this.numericValue=["",null].includes(this.value)||isNaN(parseFloat(this.value))?null:parseFloat(this.value.replace(",",".")),(null===t||t===this.storedValue&&!Object.is(this.numericValue,-0))&&this.valueChange.emit(this.numericValue),this.readonlyValue=null!==this.numericValue?this.formatValue(this.numericValue):""}displayValue(){return this.hasFocus?this.value:this.readonlyValue}componentWillLoad(){const t=l(this.element);return this.locale=t.locale,this.messages=t.messages,this.watchFormat(this.format),this.validateType(this.type),this.validateIntegerLength(this.integerLength),this.validateDecimalLength(this.decimalLength),this.validateValue(this.value),this.validateAppendSlot(),this.watchReadonly(this.readonly),this.watchDisabled(this.disabled),this.watchMgWidth(this.mgWidth),setTimeout((()=>{this.checkValidity()}),0)}render(){return n("mg-input",{key:"4529f67fe43372530d723e8e8a7a6c44f5057bbd",label:this.label,identifier:this.identifier,class:this.classCollection.join(),labelOnTop:this.labelOnTop,labelHide:this.labelHide,required:this.required,tooltip:this.tooltip,tooltipPosition:this.readonly&&void 0===this.value?"label":this.tooltipPosition,helpText:this.formatHelpText(this.helpText),errorMessage:this.errorMessage},this.readonly?this.readonlyValue&&this.renderReadonly():[n("input",{key:"input",type:"text",class:"mg-c-input__box mg-c-input__box--width",value:this.displayValue(),id:this.identifier,name:this.name,placeholder:this.placeholder,title:this.placeholder,disabled:this.disabled,required:this.required,autocomplete:"off","aria-invalid":""+(!0===this.invalid),onInput:this.handleInput,onFocus:this.handleFocus,onBlur:this.handleBlur,ref:t=>{null!==t&&(this.input=t)}}),n("slot",{key:"slot",name:"append-input"})])}get element(){return this}static get watchers(){return{value:[{validateValue:0}],readonly:[{watchReadonly:0},{handleValidityChange:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}],min:[{handleValidityChange:0}],max:[{handleValidityChange:0}],mgWidth:[{watchMgWidth:0}],type:[{validateType:0}],format:[{watchFormat:0}],integerLength:[{validateIntegerLength:0}],decimalLength:[{validateDecimalLength:0}]}}static get style(){return".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-full .mg-c-input__input-group-container{width:100%;flex-grow:1}.mg-c-input.mg-c-input--width-2.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-4.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-16.mg-c-input--display-character-left .mg-c-input__input-group-container{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input .mg-c-input__box{width:auto;text-align:var(--mg-c-input-text-align, right)}"}},[257,"mg-input-numeric",{value:[1537],identifier:[1],name:[1],label:[1],labelOnTop:[4,"label-on-top"],labelHide:[4,"label-hide"],placeholder:[1],required:[4],readonly:[4],max:[2],min:[2],disabled:[4],mgWidth:[8,"mg-width"],tooltip:[1],tooltipPosition:[1,"tooltip-position"],helpText:[1,"help-text"],type:[1],format:[1],currency:[1],unit:[1],unitDisplay:[1,"unit-display"],integerLength:[2,"integer-length"],decimalLength:[2,"decimal-length"],valid:[1028],invalid:[1028],classCollection:[32],errorMessage:[32],hasFocus:[32],setFocus:[64],displayError:[64],setError:[64],reset:[64]},void 0,{value:[{validateValue:0}],readonly:[{watchReadonly:0},{handleValidityChange:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}],min:[{handleValidityChange:0}],max:[{handleValidityChange:0}],mgWidth:[{watchMgWidth:0}],type:[{validateType:0}],format:[{watchFormat:0}],integerLength:[{validateIntegerLength:0}],decimalLength:[{validateDecimalLength:0}]}]);function E(){"undefined"!=typeof customElements&&["mg-input-numeric","mg-icon","mg-input","mg-input-title","mg-tooltip","mg-tooltip-content"].forEach((i=>{switch(i){case"mg-input-numeric":customElements.get(t(i))||customElements.define(t(i),z);break;case"mg-icon":customElements.get(t(i))||b();break;case"mg-input":customElements.get(t(i))||v();break;case"mg-input-title":customElements.get(t(i))||f();break;case"mg-tooltip":customElements.get(t(i))||w();break;case"mg-tooltip-content":customElements.get(t(i))||y()}}))}E();const V=z,k=E;export{V as MgInputNumeric,k as defineCustomElement}