@mgdis/mg-components 6.19.0 → 6.21.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 (164) hide show
  1. package/dist/cjs/{index-Bp6wZzau.js → index-C2viYwrR.js} +1757 -80
  2. package/dist/cjs/{index-TUElr4Wv.js → index-CCsGMNyq.js} +46 -0
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/mg-action-more_37.cjs.entry.js +735 -337
  5. package/dist/cjs/mg-alert.cjs.entry.js +17 -9
  6. package/dist/cjs/mg-components.cjs.js +3 -3
  7. package/dist/cjs/mg-fieldset.cjs.entry.js +24 -7
  8. package/dist/cjs/mg-input-combobox.cjs.entry.js +63 -29
  9. package/dist/cjs/mg-input-file.cjs.entry.js +384 -0
  10. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +30 -18
  11. package/dist/cjs/{mg-input.conf-D7jmj_lh.js → mg-input.conf-BNpeATnq.js} +7 -0
  12. package/dist/cjs/mg-loader.cjs.entry.js +8 -6
  13. package/dist/cjs/mg-progress.cjs.entry.js +19 -9
  14. package/dist/collection/collection-manifest.json +3 -2
  15. package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
  16. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +6 -0
  17. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
  18. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +15 -11
  19. package/dist/collection/components/molecules/inputs/mg-input-file/mg-input-file.js +877 -0
  20. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
  21. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
  22. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
  23. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +12 -12
  24. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
  25. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +2 -2
  26. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
  27. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +72 -84
  28. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
  29. package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
  30. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  31. package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +12 -3
  32. package/dist/collection/components/molecules/mg-form/mg-form.js +12 -2
  33. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  34. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  35. package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
  36. package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
  37. package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
  38. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  39. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
  40. package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
  41. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  42. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
  43. package/dist/collection/locales/en/messages.json +11 -0
  44. package/dist/collection/locales/fr/messages.json +11 -0
  45. package/dist/components/events.utils.js +1 -23
  46. package/dist/components/index.d.ts +2 -0
  47. package/dist/components/index.js +1 -1
  48. package/dist/components/index2.js +1 -408
  49. package/dist/components/index3.js +1 -476
  50. package/dist/components/mg-action-more.js +1 -254
  51. package/dist/components/mg-alert.js +1 -224
  52. package/dist/components/mg-badge.js +1 -6
  53. package/dist/components/mg-badge2.js +1 -113
  54. package/dist/components/mg-button.js +1 -6
  55. package/dist/components/mg-button2.js +1 -275
  56. package/dist/components/mg-card.js +1 -6
  57. package/dist/components/mg-card2.js +1 -92
  58. package/dist/components/mg-character-left.js +1 -6
  59. package/dist/components/mg-character-left2.js +1 -75
  60. package/dist/components/mg-details.js +1 -104
  61. package/dist/components/mg-divider.js +1 -6
  62. package/dist/components/mg-divider2.js +1 -49
  63. package/dist/components/mg-fieldset.js +1 -209
  64. package/dist/components/mg-form.js +1 -302
  65. package/dist/components/mg-icon.js +1 -6
  66. package/dist/components/mg-icon2.js +1 -188
  67. package/dist/components/mg-illustrated-message.js +1 -129
  68. package/dist/components/mg-input-checkbox-paginated.js +1 -6
  69. package/dist/components/mg-input-checkbox-paginated2.js +1 -135
  70. package/dist/components/mg-input-checkbox.js +1 -762
  71. package/dist/components/mg-input-combobox.js +1 -936
  72. package/dist/components/mg-input-date.js +1 -463
  73. package/dist/components/mg-input-file.d.ts +11 -0
  74. package/dist/components/mg-input-file.js +1 -0
  75. package/dist/components/mg-input-numeric.js +1 -592
  76. package/dist/components/mg-input-password.js +1 -360
  77. package/dist/components/mg-input-radio.js +1 -392
  78. package/dist/components/mg-input-rich-text-editor.js +1 -16797
  79. package/dist/components/mg-input-select.js +1 -6
  80. package/dist/components/mg-input-select2.js +1 -481
  81. package/dist/components/mg-input-text.js +1 -6
  82. package/dist/components/mg-input-text2.js +1 -514
  83. package/dist/components/mg-input-textarea.js +1 -412
  84. package/dist/components/mg-input-title.js +1 -6
  85. package/dist/components/mg-input-title2.js +1 -81
  86. package/dist/components/mg-input-toggle.js +1 -386
  87. package/dist/components/mg-input.conf.js +1 -0
  88. package/dist/components/mg-input.js +1 -6
  89. package/dist/components/mg-input2.js +1 -459
  90. package/dist/components/mg-item-more.js +1 -6
  91. package/dist/components/mg-item-more2.js +1 -505
  92. package/dist/components/mg-loader.js +1 -6
  93. package/dist/components/mg-loader2.js +1 -74
  94. package/dist/components/mg-menu-item.js +1 -6
  95. package/dist/components/mg-menu-item2.js +1 -485
  96. package/dist/components/mg-menu.js +1 -6
  97. package/dist/components/mg-message.js +1 -6
  98. package/dist/components/mg-message2.js +1 -146
  99. package/dist/components/mg-modal.js +1 -184
  100. package/dist/components/mg-pagination.js +1 -234
  101. package/dist/components/mg-panel.js +1 -350
  102. package/dist/components/mg-popover-content.js +1 -6
  103. package/dist/components/mg-popover-content2.js +1 -96
  104. package/dist/components/mg-popover.js +1 -6
  105. package/dist/components/mg-popover2.js +1 -312
  106. package/dist/components/mg-progress.js +1 -123
  107. package/dist/components/mg-skip-links.js +1 -78
  108. package/dist/components/mg-table.js +1 -319
  109. package/dist/components/mg-tabs.js +1 -6
  110. package/dist/components/mg-tabs2.js +1 -315
  111. package/dist/components/mg-tag.js +1 -133
  112. package/dist/components/mg-tooltip-content.js +1 -6
  113. package/dist/components/mg-tooltip-content2.js +1 -42
  114. package/dist/components/mg-tooltip.js +1 -6
  115. package/dist/components/mg-tooltip2.js +1 -421
  116. package/dist/components/popper.js +1 -1790
  117. package/dist/esm/{index-CNX6lq0x.js → index-D-uaxCxH.js} +46 -1
  118. package/dist/esm/{index-BluNKQ3L.js → index-DFwaH2hS.js} +1757 -80
  119. package/dist/esm/loader.js +3 -3
  120. package/dist/esm/mg-action-more_37.entry.js +735 -337
  121. package/dist/esm/mg-alert.entry.js +17 -9
  122. package/dist/esm/mg-components.js +4 -4
  123. package/dist/esm/mg-fieldset.entry.js +24 -7
  124. package/dist/esm/mg-input-combobox.entry.js +63 -29
  125. package/dist/esm/mg-input-file.entry.js +382 -0
  126. package/dist/esm/mg-input-rich-text-editor.entry.js +30 -18
  127. package/dist/esm/{mg-input.conf-DDnrE1hD.js → mg-input.conf-C9rmNQIL.js} +7 -1
  128. package/dist/esm/mg-loader.entry.js +8 -6
  129. package/dist/esm/mg-progress.entry.js +19 -9
  130. package/dist/mg-components/locales/en/messages.json +11 -0
  131. package/dist/mg-components/locales/fr/messages.json +11 -0
  132. package/dist/mg-components/mg-components.esm.js +1 -1
  133. package/dist/mg-components/{p-d5a276eb.entry.js → p-08fa327b.entry.js} +1 -1
  134. package/dist/mg-components/p-4175dcbe.entry.js +1 -0
  135. package/dist/mg-components/p-6b57f249.entry.js +1 -0
  136. package/dist/mg-components/p-6b655830.entry.js +1 -0
  137. package/dist/mg-components/p-988c282e.entry.js +1 -0
  138. package/dist/mg-components/p-C9rmNQIL.js +1 -0
  139. package/dist/mg-components/p-D-uaxCxH.js +1 -0
  140. package/dist/mg-components/p-DFwaH2hS.js +2 -0
  141. package/dist/mg-components/p-a79b1f19.entry.js +1 -0
  142. package/dist/mg-components/{p-916dfb6d.entry.js → p-c3d116b9.entry.js} +1 -1
  143. package/dist/mg-components/p-dd1934f4.entry.js +1 -0
  144. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +7 -1
  145. package/dist/types/components/molecules/inputs/mg-input-file/mg-input-file.d.ts +210 -0
  146. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -4
  147. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +13 -16
  148. package/dist/types/components.d.ts +217 -18
  149. package/dist/types/stencil-public-runtime.d.ts +76 -12
  150. package/ide/intellij/web-types.json +373 -26
  151. package/ide/vscode/css-custom-data.json +12 -0
  152. package/ide/vscode/html-custom-data.json +341 -79
  153. package/package.json +22 -22
  154. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.scss +0 -1
  155. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +0 -1
  156. package/dist/mg-components/p-016bd291.entry.js +0 -1
  157. package/dist/mg-components/p-186a6139.entry.js +0 -1
  158. package/dist/mg-components/p-66a1cb83.entry.js +0 -1
  159. package/dist/mg-components/p-6efd819f.entry.js +0 -1
  160. package/dist/mg-components/p-BluNKQ3L.js +0 -2
  161. package/dist/mg-components/p-CNX6lq0x.js +0 -1
  162. package/dist/mg-components/p-DDnrE1hD.js +0 -1
  163. package/dist/mg-components/p-d2c72f09.entry.js +0 -1
  164. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +0 -8
@@ -1,386 +1 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { C as ClassList, t as toString, d as allItemsAreString, i as isValidString } from './index2.js';
3
- import { d as defineCustomElement$5, c as classReadonly, a as classDisabled } from './mg-input2.js';
4
- import { d as defineCustomElement$6 } from './mg-icon2.js';
5
- import { d as defineCustomElement$4 } from './mg-input-title2.js';
6
- import { d as defineCustomElement$3 } from './mg-tooltip2.js';
7
- import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
8
-
9
- const mgInputToggleCss = ".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-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__toggle-item-container{overflow:hidden;box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-width:var(--mg-b-size-border);border-radius:calc((var(--mg-b-font-size)*var(--mg-b-line-height) + 2*var(--mg-b-size-4))/var(--mg-c-input-toggle-border-radius-ratio));color:var(--mg-b-color-neutral-110);font-weight:unset;text-overflow:ellipsis;white-space:nowrap}.mg-c-input__toggle-item-container:first-of-type{border-style:solid;border-color:var(--mg-b-color-neutral-80);background-color:var(--mg-b-color-light);font-weight:600}.mg-c-input__button-toggle{display:flex;overflow:hidden;min-width:0;align-items:center;padding:.1rem;border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-b-color-neutral-80);border-radius:calc((var(--mg-b-font-size)*var(--mg-b-line-height) + 2*(var(--mg-b-size-4) + var(--mg-b-size-4) + var(--mg-c-input-border-width)))/var(--mg-c-input-toggle-border-radius-ratio));background-color:var(--mg-b-color-neutral-20);cursor:pointer;font-family:var(--mg-b-font-family);font-size:var(--mg-b-small-font-size);line-height:var(--mg-b-size-12)}.mg-c-input__button-toggle:disabled{cursor:default}.mg-c-input__button-toggle:focus{outline-offset:var(--mg-b-size-4)}.mg-c-input.mg-c-input--toggle:not(.mg-c-input--readonly) .mg-c-input__button-toggle{margin-top:var(--mg-b-size-4)}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__button-toggle{background-color:var(--mg-b-color-neutral-110)}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:first-of-type{border:unset;background-color:unset;color:var(--mg-b-color-light);font-weight:unset}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:last-of-type{border-style:solid;background-color:var(--mg-b-color-neutral-20);font-weight:600}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__button-toggle{width:100%;min-width:calc(var(--mg-b-size-20)*2);max-width:calc(var(--mg-b-size-20)*2)}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container{display:flex;overflow:unset;min-width:var(--mg-b-size-20);max-width:var(--mg-b-size-20);height:var(--mg-b-size-20);align-items:center;justify-content:center;padding:0;visibility:hidden}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:first-of-type{visibility:visible}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:last-of-type{width:unset}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container ::slotted(mg-icon){display:flex}.mg-c-input.mg-c-input--toggle-icon.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:first-of-type{min-width:unset;visibility:hidden}.mg-c-input.mg-c-input--toggle-icon.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:last-of-type{margin-left:auto;visibility:visible}.mg-c-input.mg-c-input--toggle-on-off.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:first-of-type ::slotted(*){display:none}";
10
-
11
- /**
12
- * type Option validation function
13
- * @param option - radio option
14
- * @returns toggle option type is valid
15
- */
16
- const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
17
- const MgInputToggle$1 = /*@__PURE__*/ proxyCustomElement(class MgInputToggle extends HTMLElement {
18
- constructor(registerHost) {
19
- super();
20
- if (registerHost !== false) {
21
- this.__registerHost();
22
- }
23
- this.__attachShadow();
24
- this.valueChange = createEvent(this, "value-change", 7);
25
- this.inputValid = createEvent(this, "input-valid", 7);
26
- // Classes
27
- this.classIsActive = 'mg-c-input--toggle-is-active';
28
- this.classOnOff = 'mg-c-input--toggle-on-off';
29
- this.classIcon = 'mg-c-input--toggle-icon';
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 toggle have on/off style,
45
- * the left icon is hidden.
46
- * Only available in combination with the "isIcon" prop.
47
- */
48
- this.isOnOff = false;
49
- /**
50
- * Define if toggle display icon
51
- */
52
- this.isIcon = false;
53
- /**
54
- * Define if input is readonly
55
- */
56
- this.readonly = false;
57
- /**
58
- * Define if input is disabled
59
- */
60
- this.disabled = false;
61
- /**
62
- * Define tooltip position
63
- */
64
- this.tooltipPosition = 'input';
65
- /**
66
- * Component classes
67
- */
68
- this.classCollection = new ClassList(['mg-c-input--toggle']);
69
- /**
70
- * Checked internal value
71
- */
72
- this.checked = false;
73
- /**
74
- * Set input error message
75
- * @param errorMessage - errorMessage override
76
- */
77
- this.setErrorMessage = (errorMessage) => {
78
- // Set error message
79
- this.errorMessage = undefined;
80
- // Does have a custom error message
81
- if (!this.valid && typeof errorMessage === 'string') {
82
- this.errorMessage = errorMessage;
83
- }
84
- };
85
- /**
86
- * Change checked value
87
- */
88
- this.toggleChecked = () => {
89
- this.checked = !this.checked;
90
- };
91
- /**
92
- * Slots validation
93
- */
94
- this.validateSlots = () => {
95
- const slots = Array.from(this.element.children);
96
- // validate slots
97
- if (slots.length !== 2) {
98
- if (this.isOnOff && this.isIcon) {
99
- // ONLY slot="item-2" is required in with isOnOff && isIcon
100
- if (this.element.querySelector('[slot="item-2"]') === null) {
101
- throw new Error('<mg-input-toggle> an element with attribute slot="item-2" is required.');
102
- }
103
- }
104
- else {
105
- throw new Error('<mg-input-toggle> 2 slots are required.');
106
- }
107
- }
108
- // update slots
109
- if (!this.isIcon) {
110
- // Due to text-overflow set to ellipsis
111
- // we need to ensure that slot element have title to display value on mouse over
112
- slots.forEach(slot => slot.setAttribute('title', slot.textContent));
113
- }
114
- else {
115
- slots.forEach(slot => {
116
- if (slot.nodeName === 'MG-ICON') {
117
- slot.size = 'small';
118
- }
119
- });
120
- }
121
- };
122
- /**
123
- * Get checked item
124
- * @param checked - checked item
125
- * @returns toggle value
126
- */
127
- this.getCheckedItem = (checked) => {
128
- var _a;
129
- if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.length) === 2) {
130
- return this.options[checked ? 1 : 0];
131
- }
132
- else {
133
- return null;
134
- }
135
- };
136
- }
137
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
138
- handleValue(newValue) {
139
- // Swich to the right option
140
- this.setChecked();
141
- // Emit value-change event
142
- this.valueChange.emit(newValue);
143
- }
144
- validateItems(newValue) {
145
- if (typeof newValue === 'object' && this.items.length !== 2) {
146
- throw new Error(`<mg-input-toggle> prop "items" require 2 items. Passed value: ${toString(newValue)}.`);
147
- }
148
- // String array
149
- else if (allItemsAreString(newValue)) {
150
- this.options = newValue.map(item => ({ title: item, value: item }));
151
- }
152
- // Object array
153
- else if (Array.isArray(newValue) && newValue.every(isOption)) {
154
- this.options = newValue;
155
- }
156
- else {
157
- throw new Error(`<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleValue. Passed value: ${toString(newValue)}.`);
158
- }
159
- }
160
- watchIsOnOff(newValue) {
161
- if (newValue) {
162
- this.classCollection.add(this.classOnOff);
163
- if (!this.isIcon) {
164
- this.isOnOff = false;
165
- console.warn('<mg-input-toggle> prop "isOnOff" must be used with "isIcon". Setting isOnOff to false.');
166
- }
167
- }
168
- else {
169
- this.classCollection.delete(this.classOnOff);
170
- }
171
- }
172
- watchIsIcon(newValue) {
173
- if (newValue)
174
- this.classCollection.add(this.classIcon);
175
- else
176
- this.classCollection.delete(this.classIcon);
177
- }
178
- watchReadonly(newValue) {
179
- if (newValue)
180
- this.classCollection.add(classReadonly);
181
- else
182
- this.classCollection.delete(classReadonly);
183
- }
184
- watchDisabled(newValue) {
185
- if (newValue)
186
- this.classCollection.add(classDisabled);
187
- else
188
- this.classCollection.delete(classDisabled);
189
- }
190
- handleChecked(newValue) {
191
- // style
192
- if (newValue)
193
- this.classCollection.add(this.classIsActive);
194
- else
195
- this.classCollection.delete(this.classIsActive);
196
- // update value
197
- this.value = this.getCheckedItem(newValue).value;
198
- }
199
- /**
200
- * Set focus on input.
201
- */
202
- async setFocus() {
203
- var _a;
204
- (_a = this.button) === null || _a === void 0 ? void 0 : _a.focus();
205
- }
206
- /**
207
- * Set an error and display a custom error message.
208
- * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.
209
- * It must be paired with an error message to display for the given context.
210
- * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
211
- * @param valid - value indicating the validity
212
- * @param errorMessage - the error message to display
213
- */
214
- async setError(valid, errorMessage) {
215
- if (typeof valid !== 'boolean') {
216
- throw new Error('<mg-input-toggle> method "setError()" param "valid" must be a boolean.');
217
- }
218
- else if (errorMessage !== undefined && !isValidString(errorMessage)) {
219
- throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string.');
220
- }
221
- else {
222
- this.valid = valid;
223
- this.inputValid.emit(valid);
224
- this.setErrorMessage(valid ? undefined : errorMessage);
225
- }
226
- }
227
- /**
228
- * Reset value, validity, error and visual state
229
- */
230
- async reset() {
231
- if (!this.readonly) {
232
- this.value = this.options[0].value;
233
- this.setChecked();
234
- // Use `Promise` as requested for stencil method
235
- // Use `requestAnimationFrame` to ensure:
236
- // - DOM is fully updated before validation
237
- // - Async operations are completed
238
- // - No timing issues with Stencil's render cycle
239
- // - Keep everything in sync both inside and outside the component
240
- return new Promise(resolve => {
241
- requestAnimationFrame(() => {
242
- this.errorMessage = undefined;
243
- resolve();
244
- });
245
- });
246
- }
247
- }
248
- /**
249
- * set checked state
250
- */
251
- setChecked() {
252
- const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);
253
- if ([0, 1].includes(optionTrueValueIndex)) {
254
- // has "value" props type is not a boolean, it is bind/render as an attributes/props
255
- // true props will be represent by "true" string so we convert it has boolean
256
- // true attribute will be represent by "" string so we convert it has boolean
257
- // https://stenciljs.com/docs/properties
258
- if (['', 'true'].includes(this.value) && this.options.find(option => option.value) !== undefined) {
259
- this.value = true;
260
- }
261
- // when options are boolean values and ordered as [true,false] instead [false,true]
262
- // we need to reversed the checked value logic
263
- const selectedValue = this.value === this.options[optionTrueValueIndex].value;
264
- this.checked = optionTrueValueIndex === 0 ? !selectedValue : selectedValue;
265
- }
266
- else {
267
- this.checked = this.value === this.options[1].value;
268
- }
269
- }
270
- /*************
271
- * Lifecycle *
272
- *************/
273
- /**
274
- * Check if component props are well configured on init
275
- */
276
- componentWillLoad() {
277
- // Check items format
278
- this.validateItems(this.items);
279
- // Check slots
280
- this.validateSlots();
281
- // init checked value
282
- this.setChecked();
283
- // apply handler
284
- this.watchIsIcon(this.isIcon);
285
- this.watchIsOnOff(this.isOnOff);
286
- this.watchReadonly(this.readonly);
287
- this.watchDisabled(this.disabled);
288
- }
289
- /**
290
- * Render
291
- * @returns HTML Element
292
- */
293
- render() {
294
- const checkedItem = this.getCheckedItem(this.checked);
295
- return (h("mg-input", { key: '4d87ed13bbd3d3a54303c21001247e1251417326', label: this.label, helpText: this.helpText, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, errorMessage: this.errorMessage }, this.readonly ? (checkedItem && h("b", { class: "mg-c-input__readonly-value" }, checkedItem.title)) : (h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-c-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked, ref: el => {
296
- if (el !== null)
297
- this.button = el;
298
- } }, h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-2" }))))));
299
- }
300
- get element() { return this; }
301
- static get watchers() { return {
302
- "value": ["handleValue"],
303
- "items": ["validateItems"],
304
- "isOnOff": ["watchIsOnOff"],
305
- "isIcon": ["watchIsIcon"],
306
- "readonly": ["watchReadonly"],
307
- "disabled": ["watchDisabled"],
308
- "checked": ["handleChecked"]
309
- }; }
310
- static get style() { return mgInputToggleCss; }
311
- }, [257, "mg-input-toggle", {
312
- "value": [1032],
313
- "items": [16],
314
- "identifier": [1],
315
- "name": [1],
316
- "label": [1],
317
- "labelOnTop": [4, "label-on-top"],
318
- "labelHide": [4, "label-hide"],
319
- "isOnOff": [1028, "is-on-off"],
320
- "isIcon": [4, "is-icon"],
321
- "readonly": [4],
322
- "disabled": [4],
323
- "tooltip": [1],
324
- "tooltipPosition": [1, "tooltip-position"],
325
- "helpText": [1, "help-text"],
326
- "classCollection": [32],
327
- "options": [32],
328
- "errorMessage": [32],
329
- "valid": [32],
330
- "checked": [32],
331
- "setFocus": [64],
332
- "setError": [64],
333
- "reset": [64]
334
- }, undefined, {
335
- "value": ["handleValue"],
336
- "items": ["validateItems"],
337
- "isOnOff": ["watchIsOnOff"],
338
- "isIcon": ["watchIsIcon"],
339
- "readonly": ["watchReadonly"],
340
- "disabled": ["watchDisabled"],
341
- "checked": ["handleChecked"]
342
- }]);
343
- function defineCustomElement$1() {
344
- if (typeof customElements === "undefined") {
345
- return;
346
- }
347
- const components = ["mg-input-toggle", "mg-icon", "mg-input", "mg-input-title", "mg-tooltip", "mg-tooltip-content"];
348
- components.forEach(tagName => { switch (tagName) {
349
- case "mg-input-toggle":
350
- if (!customElements.get(tagName)) {
351
- customElements.define(tagName, MgInputToggle$1);
352
- }
353
- break;
354
- case "mg-icon":
355
- if (!customElements.get(tagName)) {
356
- defineCustomElement$6();
357
- }
358
- break;
359
- case "mg-input":
360
- if (!customElements.get(tagName)) {
361
- defineCustomElement$5();
362
- }
363
- break;
364
- case "mg-input-title":
365
- if (!customElements.get(tagName)) {
366
- defineCustomElement$4();
367
- }
368
- break;
369
- case "mg-tooltip":
370
- if (!customElements.get(tagName)) {
371
- defineCustomElement$3();
372
- }
373
- break;
374
- case "mg-tooltip-content":
375
- if (!customElements.get(tagName)) {
376
- defineCustomElement$2();
377
- }
378
- break;
379
- } });
380
- }
381
- defineCustomElement$1();
382
-
383
- const MgInputToggle = MgInputToggle$1;
384
- const defineCustomElement = defineCustomElement$1;
385
-
386
- export { MgInputToggle, defineCustomElement };
1
+ import{transformTag as t,proxyCustomElement as i,HTMLElement as e,createEvent as o,h as n}from"@stencil/core/internal/client";import{C as s,t as r,d as g,i as a}from"./index2.js";import{c as l,b as m}from"./mg-input.conf.js";import{d as c}from"./mg-icon2.js";import{d as h}from"./mg-input2.js";import{d as u}from"./mg-input-title2.js";import{d as p}from"./mg-tooltip2.js";import{d}from"./mg-tooltip-content2.js";const b=t=>"object"==typeof t&&"string"==typeof t.title,f=i(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.valueChange=o(this,"value-change",7),this.inputValid=o(this,"input-valid",7),this.classIsActive="mg-c-input--toggle-is-active",this.classOnOff="mg-c-input--toggle-on-off",this.classIcon="mg-c-input--toggle-icon",this.name=this.identifier,this.labelOnTop=!1,this.labelHide=!1,this.isOnOff=!1,this.isIcon=!1,this.readonly=!1,this.disabled=!1,this.tooltipPosition="input",this.classCollection=new s(["mg-c-input--toggle"]),this.setErrorMessage=t=>{this.errorMessage=void 0,this.valid||"string"!=typeof t||(this.errorMessage=t)},this.handleSwitchButton=()=>{const t=this.getCurrentOptionIndex(this.value);this.value=this.options[0===t?1:0].value},this.validateSlots=()=>{const t=Array.from(this.element.children);if(2!==t.length){if(!this.isOnOff||!this.isIcon)throw Error("<mg-input-toggle> 2 slots are required.");if(null===this.element.querySelector('[slot="item-2"]'))throw Error('<mg-input-toggle> an element with attribute slot="item-2" is required.')}t.forEach(this.isIcon?t=>{"MG-ICON"===t.nodeName&&(t.size="small")}:t=>t.setAttribute("title",t.textContent))},this.getCurrentOptionIndex=t=>1===this.options.findIndex((i=>r(i.value)===r(t)))?1:0,this.isChecked=t=>1===this.getCurrentOptionIndex(t)}watchValue(t,i){""!==t?["true","false"].includes(t)&&this.options.every((t=>"boolean"==typeof t.value))?this.value="true"===t:(this.isChecked(t)?this.classCollection.add(this.classIsActive):this.classCollection.delete(this.classIsActive),r(t)!==r(i)&&this.valueChange.emit(t)):this.value=!0}watchItems(t){if("object"==typeof t&&2!==this.items.length)throw Error(`<mg-input-toggle> prop "items" require 2 items. Passed value: ${r(t)}.`);if(g(t))this.options=t.map((t=>({title:t,value:t})));else{if(!Array.isArray(t)||!t.every(b))throw Error(`<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleOption. Passed value: ${r(t)}.`);this.options=t}}watchIsOnOff(t){t?(this.classCollection.add(this.classOnOff),this.isIcon||(this.isOnOff=!1,console.warn('<mg-input-toggle> prop "isOnOff" must be used with "isIcon". Setting isOnOff to false.'))):this.classCollection.delete(this.classOnOff)}watchIsIcon(t){t?this.classCollection.add(this.classIcon):this.classCollection.delete(this.classIcon)}watchReadonly(t){t?this.classCollection.add(l):this.classCollection.delete(l)}watchDisabled(t){t?this.classCollection.add(m):this.classCollection.delete(m)}async setFocus(){var t;null===(t=this.button)||void 0===t||t.focus()}async setError(t,i){if("boolean"!=typeof t)throw Error('<mg-input-toggle> method "setError()" param "valid" must be a boolean.');if(void 0!==i&&!a(i))throw Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string.');this.valid=t,this.inputValid.emit(t),this.setErrorMessage(t?void 0:i)}async reset(){if(!this.readonly)return this.value=this.options[0].value,new Promise((t=>{requestAnimationFrame((()=>{this.errorMessage=void 0,t()}))}))}componentWillLoad(){this.watchItems(this.items),this.validateSlots(),this.watchValue(this.value),this.watchIsIcon(this.isIcon),this.watchIsOnOff(this.isOnOff),this.watchReadonly(this.readonly),this.watchDisabled(this.disabled)}render(){const t=this.options[this.getCurrentOptionIndex(this.value)];return n("mg-input",{key:"75a58e79ddd78a6a5656b6a3ef497087fbbb0638",label:this.label,helpText:this.helpText,identifier:this.identifier,class:this.classCollection.join(),labelOnTop:this.labelOnTop,labelHide:this.labelHide,required:void 0,tooltip:this.tooltip,tooltipPosition:this.tooltipPosition,errorMessage:this.errorMessage},this.readonly?t&&n("b",{class:"mg-c-input__readonly-value"},t.title):n("button",{type:"button",role:"switch","aria-checked":""+this.isChecked(this.value),"aria-readonly":this.disabled||this.readonly,id:this.identifier,class:"mg-c-input__button-toggle",disabled:this.disabled||this.readonly,onClick:this.handleSwitchButton,ref:t=>{null!==t&&(this.button=t)}},n("span",{"aria-hidden":"true",class:"mg-c-input__toggle-item-container"},n("slot",{name:"item-1"})),n("span",{"aria-hidden":"true",class:"mg-c-input__toggle-item-container"},n("slot",{name:"item-2"}))))}get element(){return this}static get watchers(){return{value:[{watchValue:0}],items:[{watchItems:0}],isOnOff:[{watchIsOnOff:0}],isIcon:[{watchIsIcon:0}],readonly:[{watchReadonly:0}],disabled:[{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-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__toggle-item-container{overflow:hidden;box-sizing:border-box;padding:.1rem var(--mg-b-size-8);border-width:var(--mg-b-size-border);border-radius:calc((var(--mg-b-font-size)*var(--mg-b-line-height) + 2*var(--mg-b-size-4))/var(--mg-c-input-toggle-border-radius-ratio));color:var(--mg-b-color-neutral-110);font-weight:unset;line-height:var(--mg-b-size-16);text-overflow:ellipsis;white-space:nowrap}.mg-c-input__toggle-item-container:first-of-type{border-style:solid;border-color:var(--mg-b-color-neutral-80);background-color:var(--mg-b-color-light);font-weight:600}.mg-c-input__button-toggle{display:flex;overflow:hidden;min-width:0;align-items:center;padding:.1rem;border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-b-color-neutral-80);border-radius:calc((var(--mg-b-font-size)*var(--mg-b-line-height) + 2*(var(--mg-b-size-4) + var(--mg-b-size-4) + var(--mg-c-input-border-width)))/var(--mg-c-input-toggle-border-radius-ratio));background-color:var(--mg-b-color-neutral-20);cursor:pointer;font-family:var(--mg-b-font-family);font-size:var(--mg-b-small-font-size);line-height:var(--mg-b-size-12)}.mg-c-input__button-toggle:disabled{cursor:default}.mg-c-input__button-toggle:focus{outline-offset:var(--mg-b-size-4)}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__button-toggle{border-color:var(--mg-b-color-neutral-110);background-color:var(--mg-b-color-neutral-110)}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:first-of-type{border:unset;background-color:unset;color:var(--mg-b-color-light);font-weight:unset}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:last-of-type{border-style:solid;border-color:var(--mg-b-color-light);background-color:var(--mg-b-color-light);font-weight:600}.mg-c-input.mg-c-input--toggle:not(.mg-c-input--readonly) .mg-c-input__button-toggle,.mg-c-input.mg-c-input--toggle:not(.mg-c-input--readonly).mg-c-input--label-on-top .mg-c-input__button-toggle{margin-top:var(--mg-b-size-4)}@media screen and (min-width: 768px){.mg-c-input.mg-c-input--toggle:not(.mg-c-input--readonly) .mg-c-input__button-toggle{margin-top:calc((var(--mg-b-size-min-height) - (var(--mg-b-size-20) + var(--mg-b-size-4)) + .1rem)/2)}}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__button-toggle{width:100%;min-width:calc(var(--mg-b-size-20)*2);max-width:calc(var(--mg-b-size-20)*2)}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container{display:flex;overflow:unset;min-width:var(--mg-b-size-20);max-width:var(--mg-b-size-20);height:var(--mg-b-size-20);align-items:center;justify-content:center;padding:0;visibility:hidden}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:first-of-type{visibility:visible}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:last-of-type{width:unset}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container ::slotted(mg-icon){display:flex}.mg-c-input.mg-c-input--toggle-icon.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:first-of-type{min-width:unset;visibility:hidden}.mg-c-input.mg-c-input--toggle-icon.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:last-of-type{margin-left:auto;visibility:visible}.mg-c-input.mg-c-input--toggle-on-off.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:first-of-type ::slotted(*){display:none}"}},[257,"mg-input-toggle",{value:[1040],items:[16],identifier:[1],name:[1],label:[1],labelOnTop:[4,"label-on-top"],labelHide:[4,"label-hide"],isOnOff:[1028,"is-on-off"],isIcon:[4,"is-icon"],readonly:[4],disabled:[4],tooltip:[1],tooltipPosition:[1,"tooltip-position"],helpText:[1,"help-text"],classCollection:[32],options:[32],errorMessage:[32],valid:[32],setFocus:[64],setError:[64],reset:[64]},void 0,{value:[{watchValue:0}],items:[{watchItems:0}],isOnOff:[{watchIsOnOff:0}],isIcon:[{watchIsIcon:0}],readonly:[{watchReadonly:0}],disabled:[{watchDisabled:0}]}]);function v(){"undefined"!=typeof customElements&&["mg-input-toggle","mg-icon","mg-input","mg-input-title","mg-tooltip","mg-tooltip-content"].forEach((i=>{switch(i){case"mg-input-toggle":customElements.get(t(i))||customElements.define(t(i),f);break;case"mg-icon":customElements.get(t(i))||c();break;case"mg-input":customElements.get(t(i))||h();break;case"mg-input-title":customElements.get(t(i))||u();break;case"mg-tooltip":customElements.get(t(i))||p();break;case"mg-tooltip-content":customElements.get(t(i))||d()}}))}v();const w=f,y=v;export{w as MgInputToggle,y as defineCustomElement}
@@ -0,0 +1 @@
1
+ const a=[2,4,16,"full"],s=["input","label"],t=["h1","h2","h3","h4","h5","h6"],i=a=>"MG-INPUT-FILE"===a.nodeName,l="mg-c-input--fieldset",c="mg-c-input--disabled",e="mg-c-input--readonly",n="mg-c-input--vertical-list",p="mg-c-input--display-character-left";export{l as a,c as b,e as c,n as d,p as e,i,t as l,s as t,a as w}
@@ -1,6 +1 @@
1
- import { M as MgInput$1, d as defineCustomElement$1 } from './mg-input2.js';
2
-
3
- const MgInput = MgInput$1;
4
- const defineCustomElement = defineCustomElement$1;
5
-
6
- export { MgInput, defineCustomElement };
1
+ import{M as o,d as s}from"./mg-input2.js";const t=o,m=s;export{t as MgInput,m as defineCustomElement}