@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,392 +1 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { C as ClassList, d as allItemsAreString, t as toString, i as isValidString } from './index2.js';
3
- import { d as defineCustomElement$5, b as classFieldset, c as classReadonly, a as classDisabled } from './mg-input2.js';
4
- import { i as initLocales } from './index3.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
- const mgInputRadioCss = ".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.mg-c-input--fieldset{padding:0;border:0;margin-right:0;margin-left:0}.mg-c-input.mg-c-input--fieldset input[type=radio],.mg-c-input.mg-c-input--fieldset input[type=checkbox]{width:var(--mg-c-input-check-size);height:var(--mg-c-input-check-size);flex-shrink:0;margin:calc((var(--mg-b-font-size)*var(--mg-b-line-height) - var(--mg-c-input-check-size))/2) var(--mg-b-size-8) 0 0}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group{display:flex;align-items:start}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group-container{display:flex;flex-wrap:wrap;padding:0;margin:0;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);gap:var(--mg-b-size-12) var(--mg-b-size-24);list-style:none}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group.mg-c-input__input-group--disabled label{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--fieldset.mg-c-input--vertical-list .mg-c-input__input-group-container,.mg-c-input.mg-c-input--fieldset.mg-c-input--checkbox-multi .mg-c-input__input-group-container{flex-direction:column}.mg-c-input.mg-c-input--fieldset.mg-c-input--label-on-top .mg-c-input__input-group-container{margin-top:var(--mg-b-size-8)}.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}";
11
-
12
- /**
13
- * type Option validation function
14
- * @param option - radio option
15
- * @returns radio option type is valid
16
- */
17
- const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
18
- const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio 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
- /************
28
- * Internal *
29
- ************/
30
- // HTML selector
31
- this.inputs = [];
32
- // classes
33
- this.classVerticalList = 'mg-c-input--vertical-list';
34
- // hasDisplayedError (triggered by blur event)
35
- this.hasDisplayedError = false;
36
- this.customErrorMessage = { lock: false };
37
- /**
38
- * Input name
39
- * If not set the value equals the identifier
40
- */
41
- this.name = this.identifier;
42
- /**
43
- * Define if label is displayed on top
44
- */
45
- this.labelOnTop = false;
46
- /**
47
- * Define if label is visible
48
- */
49
- this.labelHide = false;
50
- /**
51
- * Define if inputs are display verticaly
52
- */
53
- this.inputVerticalList = false;
54
- /**
55
- * Define if input is required
56
- */
57
- this.required = false;
58
- /**
59
- * Define if input is readonly
60
- */
61
- this.readonly = false;
62
- /**
63
- * Define if input is disabled
64
- */
65
- this.disabled = false;
66
- /**
67
- * Define tooltip position
68
- */
69
- this.tooltipPosition = 'input';
70
- /**
71
- * Component classes
72
- */
73
- this.classCollection = new ClassList(['mg-c-input--radio', classFieldset]);
74
- /**
75
- * Handle input event
76
- * @param event - input event
77
- */
78
- this.handleInput = (event) => {
79
- this.checkValidity();
80
- this.value = this.options[event.target.value].value;
81
- };
82
- /**
83
- * Handle blur event
84
- */
85
- this.handleBlur = () => {
86
- this.handlerInProgress = 'blur';
87
- this.checkValidity();
88
- this.setErrorMessage();
89
- // reset guard
90
- this.handlerInProgress = undefined;
91
- };
92
- /**
93
- * Check if input is valid
94
- */
95
- this.checkValidity = () => {
96
- this.setValidity(this.readonly || this.disabled || this.getInvalidElement() === undefined);
97
- };
98
- /**
99
- * Set input error message
100
- * @param fromSetErrorContext - context come from `setError` method
101
- */
102
- this.setErrorMessage = (fromSetErrorContext = false) => {
103
- const invalidElement = this.getInvalidElement();
104
- // Set error message
105
- this.errorMessage = undefined;
106
- if (!this.valid) {
107
- // Does have a new custom error message OR does have a custom error message locked
108
- if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
109
- this.errorMessage = this.customErrorMessage.message;
110
- }
111
- // required
112
- else if (invalidElement.validity.valueMissing) {
113
- this.errorMessage = this.messages.errors.required;
114
- }
115
- }
116
- };
117
- /**
118
- * get invalid element
119
- * @returns element
120
- */
121
- this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
122
- }
123
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
124
- watchValue(newValue) {
125
- var _a;
126
- if (allItemsAreString(this.items) && typeof newValue === 'string') {
127
- this.readonlyValue = newValue;
128
- }
129
- else if (Array.isArray(this.items) && this.items.every(isOption)) {
130
- this.readonlyValue = (_a = this.items.find(item => item.value === newValue)) === null || _a === void 0 ? void 0 : _a.title;
131
- }
132
- else {
133
- this.readonlyValue = null;
134
- }
135
- this.valueChange.emit(newValue);
136
- }
137
- validateItems(newValue) {
138
- // Validate if items have required min length
139
- if (typeof newValue === 'object' && newValue.length < 2) {
140
- throw new Error(`<mg-input-radio> prop "items" require at least 2 items. Passed value: ${toString(newValue)}.`);
141
- }
142
- // String array
143
- else if (allItemsAreString(newValue)) {
144
- this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
145
- }
146
- // Object array
147
- else if (newValue && newValue.every(item => isOption(item))) {
148
- this.options = newValue;
149
- }
150
- else {
151
- 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)}.`);
152
- }
153
- }
154
- watchInputVerticalList(newValue) {
155
- if (newValue)
156
- this.classCollection.add(this.classVerticalList);
157
- else
158
- this.classCollection.delete(this.classVerticalList);
159
- }
160
- watchReadonly(newValue) {
161
- if (newValue)
162
- this.classCollection.add(classReadonly);
163
- else
164
- this.classCollection.delete(classReadonly);
165
- }
166
- handleValidityChange(newValue, _oldValue, prop) {
167
- this.inputs.forEach(input => {
168
- input[prop] = newValue;
169
- });
170
- this.checkValidity();
171
- if (this.hasDisplayedError) {
172
- this.setErrorMessage();
173
- this.hasDisplayedError = false;
174
- }
175
- }
176
- watchDisabled(newValue) {
177
- if (newValue)
178
- this.classCollection.add(classDisabled);
179
- else
180
- this.classCollection.delete(classDisabled);
181
- }
182
- /**
183
- * Set focus on input.
184
- */
185
- async setFocus() {
186
- if (this.inputs.length > 0) {
187
- this.inputs[0].focus();
188
- }
189
- }
190
- /**
191
- * Display input error if it exists.
192
- */
193
- displayError() {
194
- // Use `Promise` as requested for stencil method
195
- // Use `requestAnimationFrame` to ensure:
196
- // - DOM is fully updated before validation
197
- // - Async operations are completed
198
- // - No timing issues with Stencil's render cycle
199
- // - Keep everything in sync both inside and outside the component
200
- return new Promise(resolve => {
201
- requestAnimationFrame(() => {
202
- this.checkValidity();
203
- this.setErrorMessage();
204
- this.hasDisplayedError = this.invalid;
205
- resolve();
206
- });
207
- });
208
- }
209
- /**
210
- * Set an error and display a custom error message.
211
- * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.
212
- * It must be paired with an error message to display for the given context.
213
- * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
214
- * @param valid - value indicating the validity
215
- * @param errorMessage - the error message to display
216
- * @param errorMessageLock - lock the error message and validity state
217
- */
218
- async setError(valid, errorMessage, errorMessageLock = false) {
219
- if (typeof valid !== 'boolean') {
220
- throw new Error('<mg-input-radio> method "setError()" param "valid" must be a boolean.');
221
- }
222
- else if (errorMessage !== undefined && !isValidString(errorMessage)) {
223
- throw new Error('<mg-input-radio> method "setError()" param "errorMessage" must be a string.');
224
- }
225
- else {
226
- this.customErrorMessage = {
227
- lock: valid ? false : errorMessageLock,
228
- message: valid ? undefined : errorMessage,
229
- };
230
- this.setValidity(valid);
231
- this.setErrorMessage(true);
232
- this.hasDisplayedError = this.invalid;
233
- }
234
- }
235
- /**
236
- * Reset value, validity and error state
237
- */
238
- async reset() {
239
- if (!this.readonly) {
240
- this.value = undefined;
241
- // Use `Promise` as requested for stencil method
242
- // Use `requestAnimationFrame` to ensure:
243
- // - DOM is fully updated before validation
244
- // - Async operations are completed
245
- // - No timing issues with Stencil's render cycle
246
- // - Keep everything in sync both inside and outside the component
247
- return new Promise(resolve => {
248
- requestAnimationFrame(() => {
249
- // unlock validity check by reseting customErrorMessage
250
- this.customErrorMessage = { lock: false };
251
- this.checkValidity();
252
- this.errorMessage = undefined;
253
- this.hasDisplayedError = false;
254
- resolve();
255
- });
256
- });
257
- }
258
- }
259
- /**
260
- * Method to set validity values
261
- * @param newValue - valid new value
262
- */
263
- setValidity(newValue) {
264
- const oldValue = this.valid;
265
- if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
266
- this.valid = newValue;
267
- }
268
- this.invalid = !this.valid;
269
- // We need to send valid event even if it is the same value
270
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
271
- this.inputValid.emit(this.valid);
272
- }
273
- /*************
274
- * Lifecycle *
275
- *************/
276
- /**
277
- * Check if component props are well configured on init
278
- * @returns timeout
279
- */
280
- componentWillLoad() {
281
- // Get locales
282
- this.messages = initLocales(this.element).messages;
283
- // Validate
284
- this.validateItems(this.items);
285
- this.watchInputVerticalList(this.inputVerticalList);
286
- this.watchReadonly(this.readonly);
287
- this.watchDisabled(this.disabled);
288
- this.watchValue(this.value);
289
- // Check validity when component is ready
290
- // return a promise to process action only in the FIRST render().
291
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
292
- return setTimeout(() => {
293
- this.checkValidity();
294
- }, 0);
295
- }
296
- /**
297
- * Render
298
- * @returns HTML Element
299
- */
300
- render() {
301
- return (h("mg-input", { key: '9290ab8e5048dd6806985ab55d13bd8b0dd93bd1', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && !this.value ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)) : (h("ul", { class: "mg-c-input__input-group-container", role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: (el) => {
302
- if (el !== null)
303
- this.inputs[index] = el;
304
- } }), h("label", { htmlFor: this.identifier + '_' + index }, input.title))))))));
305
- }
306
- get element() { return this; }
307
- static get watchers() { return {
308
- "value": ["watchValue"],
309
- "items": ["validateItems"],
310
- "inputVerticalList": ["watchInputVerticalList"],
311
- "readonly": ["watchReadonly", "handleValidityChange"],
312
- "required": ["handleValidityChange"],
313
- "disabled": ["handleValidityChange", "watchDisabled"]
314
- }; }
315
- static get style() { return mgInputRadioCss; }
316
- }, [257, "mg-input-radio", {
317
- "value": [1032],
318
- "items": [16],
319
- "identifier": [1],
320
- "name": [1],
321
- "label": [1],
322
- "labelOnTop": [4, "label-on-top"],
323
- "labelHide": [4, "label-hide"],
324
- "inputVerticalList": [4, "input-vertical-list"],
325
- "required": [4],
326
- "readonly": [4],
327
- "disabled": [4],
328
- "tooltip": [1],
329
- "tooltipPosition": [1, "tooltip-position"],
330
- "helpText": [1, "help-text"],
331
- "valid": [1028],
332
- "invalid": [1028],
333
- "classCollection": [32],
334
- "errorMessage": [32],
335
- "options": [32],
336
- "readonlyValue": [32],
337
- "setFocus": [64],
338
- "displayError": [64],
339
- "setError": [64],
340
- "reset": [64]
341
- }, undefined, {
342
- "value": ["watchValue"],
343
- "items": ["validateItems"],
344
- "inputVerticalList": ["watchInputVerticalList"],
345
- "readonly": ["watchReadonly", "handleValidityChange"],
346
- "required": ["handleValidityChange"],
347
- "disabled": ["handleValidityChange", "watchDisabled"]
348
- }]);
349
- function defineCustomElement$1() {
350
- if (typeof customElements === "undefined") {
351
- return;
352
- }
353
- const components = ["mg-input-radio", "mg-icon", "mg-input", "mg-input-title", "mg-tooltip", "mg-tooltip-content"];
354
- components.forEach(tagName => { switch (tagName) {
355
- case "mg-input-radio":
356
- if (!customElements.get(tagName)) {
357
- customElements.define(tagName, MgInputRadio$1);
358
- }
359
- break;
360
- case "mg-icon":
361
- if (!customElements.get(tagName)) {
362
- defineCustomElement$6();
363
- }
364
- break;
365
- case "mg-input":
366
- if (!customElements.get(tagName)) {
367
- defineCustomElement$5();
368
- }
369
- break;
370
- case "mg-input-title":
371
- if (!customElements.get(tagName)) {
372
- defineCustomElement$4();
373
- }
374
- break;
375
- case "mg-tooltip":
376
- if (!customElements.get(tagName)) {
377
- defineCustomElement$3();
378
- }
379
- break;
380
- case "mg-tooltip-content":
381
- if (!customElements.get(tagName)) {
382
- defineCustomElement$2();
383
- }
384
- break;
385
- } });
386
- }
387
- defineCustomElement$1();
388
-
389
- const MgInputRadio = MgInputRadio$1;
390
- const defineCustomElement = defineCustomElement$1;
391
-
392
- export { MgInputRadio, 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,d as r,t as o,i as h}from"./index2.js";import{a as l,c as m,b as p}from"./mg-input.conf.js";import{i as c}from"./index3.js";import{d as u}from"./mg-icon2.js";import{d}from"./mg-input2.js";import{d as g}from"./mg-input-title2.js";import{d as b}from"./mg-tooltip2.js";import{d as v}from"./mg-tooltip-content2.js";const f=t=>"object"==typeof t&&"string"==typeof t.title&&void 0!==t.value,y=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.inputs=[],this.classVerticalList="mg-c-input--vertical-list",this.hasDisplayedError=!1,this.customErrorMessage={lock:!1},this.name=this.identifier,this.labelOnTop=!1,this.labelHide=!1,this.inputVerticalList=!1,this.required=!1,this.readonly=!1,this.disabled=!1,this.tooltipPosition="input",this.classCollection=new a(["mg-c-input--radio",l]),this.handleInput=t=>{this.checkValidity(),this.value=this.options[t.target.value].value},this.handleBlur=()=>{this.handlerInProgress="blur",this.checkValidity(),this.setErrorMessage(),this.handlerInProgress=void 0},this.checkValidity=()=>{this.setValidity(this.readonly||this.disabled||void 0===this.getInvalidElement())},this.setErrorMessage=(t=!1)=>{const i=this.getInvalidElement();this.errorMessage=void 0,this.valid||(t||this.customErrorMessage.lock&&void 0!==this.customErrorMessage.message?this.errorMessage=this.customErrorMessage.message:i.validity.valueMissing&&(this.errorMessage=this.messages.errors.required))},this.getInvalidElement=()=>this.inputs.find((t=>!t.disabled&&!t.readOnly&&!t.checkValidity()))}watchValue(t){var i;this.readonlyValue=r(this.items)&&"string"==typeof t?t:Array.isArray(this.items)&&this.items.every(f)?null===(i=this.items.find((i=>i.value===t)))||void 0===i?void 0:i.title:null,this.valueChange.emit(t)}validateItems(t){if("object"==typeof t&&t.length<2)throw Error(`<mg-input-radio> prop "items" require at least 2 items. Passed value: ${o(t)}.`);if(r(t))this.options=t.map((t=>({title:t,value:t,disabled:this.disabled})));else{if(!t||!t.every((t=>f(t))))throw Error(`<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption. Passed value: ${o(t)}.`);this.options=t}}watchInputVerticalList(t){t?this.classCollection.add(this.classVerticalList):this.classCollection.delete(this.classVerticalList)}watchReadonly(t){t?this.classCollection.add(m):this.classCollection.delete(m)}handleValidityChange(t,i,e){this.inputs.forEach((i=>{i[e]=t})),this.checkValidity(),this.hasDisplayedError&&(this.setErrorMessage(),this.hasDisplayedError=!1)}watchDisabled(t){t?this.classCollection.add(p):this.classCollection.delete(p)}async setFocus(){this.inputs.length>0&&this.inputs[0].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-radio> method "setError()" param "valid" must be a boolean.');if(void 0!==i&&!h(i))throw Error('<mg-input-radio> 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=void 0,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)}componentWillLoad(){return this.messages=c(this.element).messages,this.validateItems(this.items),this.watchInputVerticalList(this.inputVerticalList),this.watchReadonly(this.readonly),this.watchDisabled(this.disabled),this.watchValue(this.value),setTimeout((()=>{this.checkValidity()}),0)}render(){return n("mg-input",{key:"bdeb5a98bc7f4567beb293c1fcf4f99169089fa6",label:this.label,identifier:this.identifier,class:this.classCollection.join(),labelOnTop:this.labelOnTop,labelHide:this.labelHide,required:this.required,tooltip:this.tooltip,tooltipPosition:this.readonly&&!this.value?"label":this.tooltipPosition,helpText:this.helpText,errorMessage:this.errorMessage},this.readonly?this.readonlyValue&&n("b",{class:"mg-c-input__readonly-value"},this.readonlyValue):n("div",{class:"mg-c-input__input-group-container"},this.options.map(((t,i)=>n("div",{key:t.title,class:{"mg-c-input__input-group":!0,"mg-c-input__input-group--disabled":this.disabled||t.disabled}},n("input",{type:"radio",id:this.identifier+"_"+i,name:this.identifier,value:i,checked:JSON.stringify(this.value)===JSON.stringify(this.options[i].value),disabled:this.disabled||t.disabled,required:this.required,onBlur:this.handleBlur,onInput:this.handleInput,ref:t=>{null!==t&&(this.inputs[i]=t)}}),n("label",{htmlFor:this.identifier+"_"+i},t.title))))))}get element(){return this}static get watchers(){return{value:[{watchValue:0}],items:[{validateItems:0}],inputVerticalList:[{watchInputVerticalList:0}],readonly:[{watchReadonly:0},{handleValidityChange:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}]}}static get style(){return".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.mg-c-input--fieldset{padding:0;border:0;margin-right:0;margin-left:0}.mg-c-input.mg-c-input--fieldset input[type=radio],.mg-c-input.mg-c-input--fieldset input[type=checkbox]{width:var(--mg-c-input-check-size);height:var(--mg-c-input-check-size);flex-shrink:0;margin:calc((var(--mg-b-font-size)*var(--mg-b-line-height) - var(--mg-c-input-check-size))/2) var(--mg-b-size-8) 0 0}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group{display:flex;align-items:start}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group-container{display:flex;flex-wrap:wrap;padding:0;margin:0;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);gap:var(--mg-b-size-12) var(--mg-b-size-24);list-style:none}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group.mg-c-input__input-group--disabled label{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--fieldset.mg-c-input--vertical-list .mg-c-input__input-group-container,.mg-c-input.mg-c-input--fieldset.mg-c-input--checkbox-multi .mg-c-input__input-group-container{flex-direction:column}.mg-c-input.mg-c-input--fieldset.mg-c-input--label-on-top .mg-c-input__input-group-container{margin-top:var(--mg-b-size-8)}.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}"}},[1,"mg-input-radio",{value:[1032],items:[16],identifier:[1],name:[1],label:[1],labelOnTop:[4,"label-on-top"],labelHide:[4,"label-hide"],inputVerticalList:[4,"input-vertical-list"],required:[4],readonly:[4],disabled:[4],tooltip:[1],tooltipPosition:[1,"tooltip-position"],helpText:[1,"help-text"],valid:[1028],invalid:[1028],classCollection:[32],errorMessage:[32],options:[32],readonlyValue:[32],setFocus:[64],displayError:[64],setError:[64],reset:[64]},void 0,{value:[{watchValue:0}],items:[{validateItems:0}],inputVerticalList:[{watchInputVerticalList:0}],readonly:[{watchReadonly:0},{handleValidityChange:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}]}]);function w(){"undefined"!=typeof customElements&&["mg-input-radio","mg-icon","mg-input","mg-input-title","mg-tooltip","mg-tooltip-content"].forEach((i=>{switch(i){case"mg-input-radio":customElements.get(t(i))||customElements.define(t(i),y);break;case"mg-icon":customElements.get(t(i))||u();break;case"mg-input":customElements.get(t(i))||d();break;case"mg-input-title":customElements.get(t(i))||g();break;case"mg-tooltip":customElements.get(t(i))||b();break;case"mg-tooltip-content":customElements.get(t(i))||v()}}))}w();const _=y,E=w;export{_ as MgInputRadio,E as defineCustomElement}