@mgdis/mg-components 6.20.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 (159) 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 +684 -273
  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 +48 -18
  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-file/mg-input-file.js +877 -0
  19. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
  20. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
  21. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
  22. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +12 -12
  23. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
  24. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +2 -2
  25. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
  26. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
  27. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
  28. package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
  29. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  30. package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +12 -3
  31. package/dist/collection/components/molecules/mg-form/mg-form.js +12 -2
  32. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  33. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  34. package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
  35. package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
  36. package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
  37. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  38. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
  39. package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
  40. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  41. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
  42. package/dist/collection/locales/en/messages.json +11 -0
  43. package/dist/collection/locales/fr/messages.json +11 -0
  44. package/dist/components/events.utils.js +1 -23
  45. package/dist/components/index.d.ts +2 -0
  46. package/dist/components/index.js +1 -1
  47. package/dist/components/index2.js +1 -408
  48. package/dist/components/index3.js +1 -476
  49. package/dist/components/mg-action-more.js +1 -254
  50. package/dist/components/mg-alert.js +1 -224
  51. package/dist/components/mg-badge.js +1 -6
  52. package/dist/components/mg-badge2.js +1 -113
  53. package/dist/components/mg-button.js +1 -6
  54. package/dist/components/mg-button2.js +1 -275
  55. package/dist/components/mg-card.js +1 -6
  56. package/dist/components/mg-card2.js +1 -92
  57. package/dist/components/mg-character-left.js +1 -6
  58. package/dist/components/mg-character-left2.js +1 -75
  59. package/dist/components/mg-details.js +1 -104
  60. package/dist/components/mg-divider.js +1 -6
  61. package/dist/components/mg-divider2.js +1 -49
  62. package/dist/components/mg-fieldset.js +1 -209
  63. package/dist/components/mg-form.js +1 -302
  64. package/dist/components/mg-icon.js +1 -6
  65. package/dist/components/mg-icon2.js +1 -188
  66. package/dist/components/mg-illustrated-message.js +1 -129
  67. package/dist/components/mg-input-checkbox-paginated.js +1 -6
  68. package/dist/components/mg-input-checkbox-paginated2.js +1 -135
  69. package/dist/components/mg-input-checkbox.js +1 -762
  70. package/dist/components/mg-input-combobox.js +1 -940
  71. package/dist/components/mg-input-date.js +1 -463
  72. package/dist/components/mg-input-file.d.ts +11 -0
  73. package/dist/components/mg-input-file.js +1 -0
  74. package/dist/components/mg-input-numeric.js +1 -592
  75. package/dist/components/mg-input-password.js +1 -360
  76. package/dist/components/mg-input-radio.js +1 -392
  77. package/dist/components/mg-input-rich-text-editor.js +1 -16797
  78. package/dist/components/mg-input-select.js +1 -6
  79. package/dist/components/mg-input-select2.js +1 -481
  80. package/dist/components/mg-input-text.js +1 -6
  81. package/dist/components/mg-input-text2.js +1 -514
  82. package/dist/components/mg-input-textarea.js +1 -412
  83. package/dist/components/mg-input-title.js +1 -6
  84. package/dist/components/mg-input-title2.js +1 -81
  85. package/dist/components/mg-input-toggle.js +1 -371
  86. package/dist/components/mg-input.conf.js +1 -0
  87. package/dist/components/mg-input.js +1 -6
  88. package/dist/components/mg-input2.js +1 -459
  89. package/dist/components/mg-item-more.js +1 -6
  90. package/dist/components/mg-item-more2.js +1 -505
  91. package/dist/components/mg-loader.js +1 -6
  92. package/dist/components/mg-loader2.js +1 -74
  93. package/dist/components/mg-menu-item.js +1 -6
  94. package/dist/components/mg-menu-item2.js +1 -485
  95. package/dist/components/mg-menu.js +1 -6
  96. package/dist/components/mg-message.js +1 -6
  97. package/dist/components/mg-message2.js +1 -146
  98. package/dist/components/mg-modal.js +1 -184
  99. package/dist/components/mg-pagination.js +1 -234
  100. package/dist/components/mg-panel.js +1 -350
  101. package/dist/components/mg-popover-content.js +1 -6
  102. package/dist/components/mg-popover-content2.js +1 -96
  103. package/dist/components/mg-popover.js +1 -6
  104. package/dist/components/mg-popover2.js +1 -312
  105. package/dist/components/mg-progress.js +1 -123
  106. package/dist/components/mg-skip-links.js +1 -78
  107. package/dist/components/mg-table.js +1 -319
  108. package/dist/components/mg-tabs.js +1 -6
  109. package/dist/components/mg-tabs2.js +1 -315
  110. package/dist/components/mg-tag.js +1 -133
  111. package/dist/components/mg-tooltip-content.js +1 -6
  112. package/dist/components/mg-tooltip-content2.js +1 -42
  113. package/dist/components/mg-tooltip.js +1 -6
  114. package/dist/components/mg-tooltip2.js +1 -421
  115. package/dist/components/popper.js +1 -1790
  116. package/dist/esm/{index-CNX6lq0x.js → index-D-uaxCxH.js} +46 -1
  117. package/dist/esm/{index-BluNKQ3L.js → index-DFwaH2hS.js} +1757 -80
  118. package/dist/esm/loader.js +3 -3
  119. package/dist/esm/mg-action-more_37.entry.js +684 -273
  120. package/dist/esm/mg-alert.entry.js +17 -9
  121. package/dist/esm/mg-components.js +4 -4
  122. package/dist/esm/mg-fieldset.entry.js +24 -7
  123. package/dist/esm/mg-input-combobox.entry.js +48 -18
  124. package/dist/esm/mg-input-file.entry.js +382 -0
  125. package/dist/esm/mg-input-rich-text-editor.entry.js +30 -18
  126. package/dist/esm/{mg-input.conf-DDnrE1hD.js → mg-input.conf-C9rmNQIL.js} +7 -1
  127. package/dist/esm/mg-loader.entry.js +8 -6
  128. package/dist/esm/mg-progress.entry.js +19 -9
  129. package/dist/mg-components/locales/en/messages.json +11 -0
  130. package/dist/mg-components/locales/fr/messages.json +11 -0
  131. package/dist/mg-components/mg-components.esm.js +1 -1
  132. package/dist/mg-components/{p-d5a276eb.entry.js → p-08fa327b.entry.js} +1 -1
  133. package/dist/mg-components/p-4175dcbe.entry.js +1 -0
  134. package/dist/mg-components/{p-7132bca1.entry.js → p-6b57f249.entry.js} +1 -1
  135. package/dist/mg-components/p-6b655830.entry.js +1 -0
  136. package/dist/mg-components/p-988c282e.entry.js +1 -0
  137. package/dist/mg-components/p-C9rmNQIL.js +1 -0
  138. package/dist/mg-components/p-D-uaxCxH.js +1 -0
  139. package/dist/mg-components/p-DFwaH2hS.js +2 -0
  140. package/dist/mg-components/p-a79b1f19.entry.js +1 -0
  141. package/dist/mg-components/{p-916dfb6d.entry.js → p-c3d116b9.entry.js} +1 -1
  142. package/dist/mg-components/p-dd1934f4.entry.js +1 -0
  143. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +7 -1
  144. package/dist/types/components/molecules/inputs/mg-input-file/mg-input-file.d.ts +210 -0
  145. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -4
  146. package/dist/types/components.d.ts +211 -10
  147. package/dist/types/stencil-public-runtime.d.ts +76 -12
  148. package/ide/intellij/web-types.json +356 -12
  149. package/ide/vscode/html-custom-data.json +338 -76
  150. package/package.json +19 -19
  151. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.scss +0 -1
  152. package/dist/mg-components/p-016bd291.entry.js +0 -1
  153. package/dist/mg-components/p-186a6139.entry.js +0 -1
  154. package/dist/mg-components/p-BluNKQ3L.js +0 -2
  155. package/dist/mg-components/p-CNX6lq0x.js +0 -1
  156. package/dist/mg-components/p-DDnrE1hD.js +0 -1
  157. package/dist/mg-components/p-cd061b38.entry.js +0 -1
  158. package/dist/mg-components/p-d2c72f09.entry.js +0 -1
  159. package/ide/vscode/custom.css-data.json +0 -425
@@ -1,254 +1 @@
1
- import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
- import { c as createID, t as toString } from './index2.js';
3
- import { d as defineCustomElement$4, a as directions, S as Status } from './mg-menu-item2.js';
4
- import { i as initLocales } from './index3.js';
5
- import { d as defineCustomElement$b } from './mg-badge2.js';
6
- import { d as defineCustomElement$a } from './mg-button2.js';
7
- import { d as defineCustomElement$9 } from './mg-card2.js';
8
- import { d as defineCustomElement$8 } from './mg-divider2.js';
9
- import { d as defineCustomElement$7 } from './mg-icon2.js';
10
- import { b as defineCustomElement$5, d as defineCustomElement$6 } from './mg-item-more2.js';
11
- import { d as defineCustomElement$3 } from './mg-popover2.js';
12
- import { d as defineCustomElement$2 } from './mg-popover-content2.js';
13
-
14
- const mgActionMoreCss = ".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}}:host{--mg-c-popover-padding-vertical:var(--mg-b-size-8);--mg-c-popover-padding-horizontal:0;--mg-c-popover-max-width:unset}.mg-c-action-more__divider{--mg-c-divider-spacing-vertical:var(--mg-b-size-4)}.mg-c-action-more__chevron{transition:200ms}.mg-c-action-more__chevron--rotate.mg-c-action-more__chevron{transform:rotate(180deg)}";
15
-
16
- /**
17
- * MgActionMore['items'] type guard
18
- * @param prop - commponent items prop
19
- * @returns return true if type is valid
20
- */
21
- const isMgActionMoreItems = (prop) => {
22
- const items = prop;
23
- return (typeof items === 'object' &&
24
- items.every(item => (typeof item === 'object' && typeof item.label === 'string' && typeof item.mouseEventHandler === 'function') || isMgActionMoreDivider(item)));
25
- };
26
- /**
27
- * MgActionMoreDividerType type guard
28
- * @param item - component item
29
- * @returns return true if type is valid
30
- */
31
- const isMgActionMoreDivider = (item) => typeof item === 'object' && item.isDivider;
32
- /**
33
- * MgActionMore['button'] type guard
34
- * @param prop - commponent button prop
35
- * @returns return true if type is valid
36
- */
37
- const isMgActionMoreButton = (prop) => {
38
- const button = prop;
39
- return typeof button === 'object' && typeof button.variant === 'string' && typeof button.isIcon === 'boolean';
40
- };
41
- /**
42
- * MgActionMore['icon'] type guard
43
- * @param prop - commponent icon prop
44
- * @returns return true if type is valid
45
- */
46
- const isMgActionMoreIcon = (prop) => {
47
- const icon = prop;
48
- return typeof icon === 'object' && typeof icon.icon === 'string';
49
- };
50
- const MgActionMore$1 = /*@__PURE__*/ proxyCustomElement(class MgActionMore extends HTMLElement {
51
- constructor(registerHost) {
52
- super();
53
- if (registerHost !== false) {
54
- this.__registerHost();
55
- }
56
- this.__attachShadow();
57
- /************
58
- * Internal *
59
- ************/
60
- this.name = 'mg-action-more';
61
- this.classBase = 'mg-c-action-more';
62
- this.mgPopoverIdentifier = createID(this.name);
63
- /**
64
- * Define button properties
65
- */
66
- this.button = { variant: 'flat', isIcon: true };
67
- /**
68
- * Define if chevron is display
69
- */
70
- this.displayChevron = false;
71
- /**
72
- * Menu expanded state
73
- */
74
- this.expanded = false;
75
- /************
76
- * Methods *
77
- ***********/
78
- /**
79
- * Toggle expanded props
80
- */
81
- this.toggleExpanded = () => {
82
- this.expanded = !this.expanded;
83
- };
84
- /**
85
- * Handle popover display change value
86
- * @param event - display change updated value
87
- */
88
- this.handleDisplayChange = (event) => {
89
- this.expanded = event.detail;
90
- };
91
- /**
92
- * Button click handler
93
- */
94
- this.handleButton = () => {
95
- this.toggleExpanded();
96
- };
97
- /**
98
- * Item click handler
99
- * @param event - click event
100
- * @param customHandler - item['mouseEventHandler']
101
- */
102
- this.handleItemClick = (event, customHandler) => {
103
- this.expanded = false;
104
- customHandler(event);
105
- };
106
- }
107
- validateItems(newValue) {
108
- if (!isMgActionMoreItems(newValue)) {
109
- throw new Error(`<${this.name}> prop "items" is required and all values must be the same type, MgActionMoreItemType or MgActionMoreDividerType. Passed value: ${toString(newValue)}.`);
110
- }
111
- else if (isMgActionMoreItems(newValue) && newValue.length > 0 && (isMgActionMoreDivider(newValue[0]) || isMgActionMoreDivider(newValue[newValue.length - 1]))) {
112
- throw new Error(`<${this.name}> prop "items" can’t have a divider at the beginning or the end of the array. Passed value: ${toString(newValue)}.`);
113
- }
114
- }
115
- validateIcon(newValue) {
116
- if (newValue && !isMgActionMoreIcon(newValue)) {
117
- throw new Error(`<${this.name}> prop "icon" must match MgActionMoreIconType. Passed value: ${toString(newValue)}.`);
118
- }
119
- else if ((newValue === null || newValue === void 0 ? void 0 : newValue.icon) === undefined && Boolean(this.button.isIcon)) {
120
- this.icon = { icon: 'ellipsis' };
121
- }
122
- }
123
- validateButton(newValue) {
124
- if (newValue && !isMgActionMoreButton(newValue)) {
125
- throw new Error(`<${this.name}> prop "button" must match MgActionMoreButtonType. Passed value: ${toString(newValue)}.`);
126
- }
127
- }
128
- validateDisplayChevron(newValue) {
129
- if (newValue && this.button.isIcon === true) {
130
- throw new Error(`<${this.name}> prop "displayChevron" can't be used with a 'button" prop "isIcon" attribute.`);
131
- }
132
- }
133
- /*************
134
- * Lifecycle *
135
- *************/
136
- /**
137
- * Validate props
138
- */
139
- componentWillLoad() {
140
- this.messages = initLocales(this.element).messages.actionMore;
141
- this.validateItems(this.items);
142
- this.validateButton(this.button);
143
- this.validateIcon(this.icon);
144
- this.validateDisplayChevron(this.displayChevron);
145
- }
146
- /**
147
- * Render
148
- * @returns HTML Element
149
- */
150
- render() {
151
- const buttonLabel = this.button.label || this.messages.label;
152
- const buttonContent = [buttonLabel];
153
- if (!this.button.isIcon && this.displayChevron) {
154
- buttonContent.push(h("span", { class: {
155
- [`${this.classBase}__chevron`]: true,
156
- [`${this.classBase}__chevron--rotate`]: this.expanded === true,
157
- } }, h("mg-icon", { icon: "chevron-down" })));
158
- }
159
- return (h(Host, { key: 'd75e1a5326ea3a1414f8048858e5ee3fee51760e', "data-mg-popover-guard": this.mgPopoverIdentifier }, h("span", { key: 'b671a6c35cb3a9fa6eb7b2329f0f595e78b573b5', class: this.classBase }, h("mg-popover", { key: '38a38123d34ca868d0587123c2ab6b11550da8f0', identifier: this.mgPopoverIdentifier, display: this.expanded, "onDisplay-change": this.handleDisplayChange }, h("mg-button", { key: '030b9360917b79edfc8df325d5ca5cfa08356c81', variant: this.button.variant, isIcon: this.button.isIcon, disabled: this.button.disabled, type: "button", label: buttonLabel, onClick: this.handleButton }, this.icon && h("mg-icon", Object.assign({ key: 'a47ca6b078ca160d1cbb13c964df3abede5f373c' }, this.icon)), !this.button.isIcon && buttonContent), h("div", { key: 'ac38c705625cb5716a7e8aabd25d596db3d5adef', slot: "content" }, h("mg-menu", { key: 'cd382a65f69ba3c303a74d6b7444fcf0ccf9d1c5', direction: directions.VERTICAL, label: this.messages.label }, this.items.map(item => {
160
- var _a, _b;
161
- return isMgActionMoreDivider(item) ? (h("mg-divider", { class: "mg-c-action-more__divider", key: "divider", "full-width": true })) : (h("mg-menu-item", { key: item.label, status: item.status || Status.VISIBLE, target: item.target, href: item.href,
162
- // eslint-disable-next-line react/jsx-no-bind
163
- onClick: e => this.handleItemClick(e, item.mouseEventHandler) }, ((_a = item.icon) === null || _a === void 0 ? void 0 : _a.icon) && h("mg-icon", { icon: item.icon.icon, variant: item.icon.variant, variantStyle: item.icon.variantStyle, slot: "image" }), h("span", { slot: "label" }, item.label), ((_b = item.badge) === null || _b === void 0 ? void 0 : _b.label) && h("mg-badge", { label: item.badge.label, value: item.badge.value, slot: "information", variant: "text-color" })));
164
- })))))));
165
- }
166
- get element() { return this; }
167
- static get watchers() { return {
168
- "items": ["validateItems"],
169
- "icon": ["validateIcon"],
170
- "button": ["validateButton"],
171
- "displayChevron": ["validateDisplayChevron"]
172
- }; }
173
- static get style() { return mgActionMoreCss; }
174
- }, [257, "mg-action-more", {
175
- "items": [16],
176
- "icon": [1040],
177
- "button": [16],
178
- "displayChevron": [4, "display-chevron"],
179
- "expanded": [32]
180
- }, undefined, {
181
- "items": ["validateItems"],
182
- "icon": ["validateIcon"],
183
- "button": ["validateButton"],
184
- "displayChevron": ["validateDisplayChevron"]
185
- }]);
186
- function defineCustomElement$1() {
187
- if (typeof customElements === "undefined") {
188
- return;
189
- }
190
- const components = ["mg-action-more", "mg-badge", "mg-button", "mg-card", "mg-divider", "mg-icon", "mg-item-more", "mg-menu", "mg-menu-item", "mg-popover", "mg-popover-content"];
191
- components.forEach(tagName => { switch (tagName) {
192
- case "mg-action-more":
193
- if (!customElements.get(tagName)) {
194
- customElements.define(tagName, MgActionMore$1);
195
- }
196
- break;
197
- case "mg-badge":
198
- if (!customElements.get(tagName)) {
199
- defineCustomElement$b();
200
- }
201
- break;
202
- case "mg-button":
203
- if (!customElements.get(tagName)) {
204
- defineCustomElement$a();
205
- }
206
- break;
207
- case "mg-card":
208
- if (!customElements.get(tagName)) {
209
- defineCustomElement$9();
210
- }
211
- break;
212
- case "mg-divider":
213
- if (!customElements.get(tagName)) {
214
- defineCustomElement$8();
215
- }
216
- break;
217
- case "mg-icon":
218
- if (!customElements.get(tagName)) {
219
- defineCustomElement$7();
220
- }
221
- break;
222
- case "mg-item-more":
223
- if (!customElements.get(tagName)) {
224
- defineCustomElement$6();
225
- }
226
- break;
227
- case "mg-menu":
228
- if (!customElements.get(tagName)) {
229
- defineCustomElement$5();
230
- }
231
- break;
232
- case "mg-menu-item":
233
- if (!customElements.get(tagName)) {
234
- defineCustomElement$4();
235
- }
236
- break;
237
- case "mg-popover":
238
- if (!customElements.get(tagName)) {
239
- defineCustomElement$3();
240
- }
241
- break;
242
- case "mg-popover-content":
243
- if (!customElements.get(tagName)) {
244
- defineCustomElement$2();
245
- }
246
- break;
247
- } });
248
- }
249
- defineCustomElement$1();
250
-
251
- const MgActionMore = MgActionMore$1;
252
- const defineCustomElement = defineCustomElement$1;
253
-
254
- export { MgActionMore, defineCustomElement };
1
+ import{transformTag as t,proxyCustomElement as e,HTMLElement as i,h as o,Host as s}from"@stencil/core/internal/client";import{c as a,t as r}from"./index2.js";import{d as n,a as m,S as c}from"./mg-menu-item2.js";import{i as d}from"./index3.js";import{d as p}from"./mg-badge2.js";import{d as h}from"./mg-button2.js";import{d as l}from"./mg-card2.js";import{d as g}from"./mg-divider2.js";import{d as v}from"./mg-icon2.js";import{b as u,d as b}from"./mg-item-more2.js";import{d as f}from"./mg-popover2.js";import{d as y}from"./mg-popover-content2.js";const k=t=>"object"==typeof t&&t.every((t=>"object"==typeof t&&"string"==typeof t.label&&"function"==typeof t.mouseEventHandler||E(t))),E=t=>"object"==typeof t&&t.isDivider,j=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.name="mg-action-more",this.classBase="mg-c-action-more",this.mgPopoverIdentifier=a(this.name),this.button={variant:"flat",isIcon:!0},this.displayChevron=!1,this.expanded=!1,this.toggleExpanded=()=>{this.expanded=!this.expanded},this.handleDisplayChange=t=>{this.expanded=t.detail},this.handleButton=()=>{this.toggleExpanded()},this.handleItemClick=(t,e)=>{this.expanded=!1,e(t)}}validateItems(t){if(!k(t))throw Error(`<${this.name}> prop "items" is required and all values must be the same type, MgActionMoreItemType or MgActionMoreDividerType. Passed value: ${r(t)}.`);if(k(t)&&t.length>0&&(E(t[0])||E(t[t.length-1])))throw Error(`<${this.name}> prop "items" can’t have a divider at the beginning or the end of the array. Passed value: ${r(t)}.`)}validateIcon(t){if(t&&!(t=>"object"==typeof t&&"string"==typeof t.icon)(t))throw Error(`<${this.name}> prop "icon" must match MgActionMoreIconType. Passed value: ${r(t)}.`);void 0===(null==t?void 0:t.icon)&&this.button.isIcon&&(this.icon={icon:"ellipsis"})}validateButton(t){if(t&&!(t=>"object"==typeof t&&"string"==typeof t.variant&&"boolean"==typeof t.isIcon)(t))throw Error(`<${this.name}> prop "button" must match MgActionMoreButtonType. Passed value: ${r(t)}.`)}validateDisplayChevron(t){if(t&&!0===this.button.isIcon)throw Error(`<${this.name}> prop "displayChevron" can't be used with a 'button" prop "isIcon" attribute.`)}componentWillLoad(){this.messages=d(this.element).messages.actionMore,this.validateItems(this.items),this.validateButton(this.button),this.validateIcon(this.icon),this.validateDisplayChevron(this.displayChevron)}render(){const t=this.button.label||this.messages.label,e=[t];return!this.button.isIcon&&this.displayChevron&&e.push(o("span",{class:{[this.classBase+"__chevron"]:!0,[this.classBase+"__chevron--rotate"]:!0===this.expanded}},o("mg-icon",{icon:"chevron-down"}))),o(s,{key:"bef7d0e0c5a991f321ca930d65fa458873fc7564","data-mg-popover-guard":this.mgPopoverIdentifier},o("span",{key:"4e47d1513749cc1ac15ef8febd2fb914e362bbee",class:this.classBase},o("mg-popover",{key:"ab6dfc93422f03b49a78d2896196aa6901841aef",identifier:this.mgPopoverIdentifier,display:this.expanded,"onDisplay-change":this.handleDisplayChange},o("mg-button",{key:"921f17c4ede5f1783dc336429539b0b082902fdd",variant:this.button.variant,isIcon:this.button.isIcon,disabled:this.button.disabled,type:"button",label:t,onClick:this.handleButton},this.icon&&o("mg-icon",Object.assign({key:"19bf9e015cbd82d8dffc62269de735607ab4f2bb"},this.icon)),!this.button.isIcon&&e),o("div",{key:"56a43a5adebd31264742c0ef8905ccb0bd8fb581",slot:"content"},o("mg-menu",{key:"70520957ac07a3190ef753ee435996af96dbc5b5",direction:m.VERTICAL,label:this.messages.label},this.items.map((t=>{var e,i;return E(t)?o("mg-divider",{class:"mg-c-action-more__divider",key:"divider","full-width":!0}):o("mg-menu-item",{key:t.label,status:t.status||c.VISIBLE,target:t.target,href:t.href,onClick:e=>this.handleItemClick(e,t.mouseEventHandler)},(null===(e=t.icon)||void 0===e?void 0:e.icon)&&o("mg-icon",{icon:t.icon.icon,variant:t.icon.variant,variantStyle:t.icon.variantStyle,slot:"image"}),o("span",{slot:"label"},t.label),(null===(i=t.badge)||void 0===i?void 0:i.label)&&o("mg-badge",{label:t.badge.label,value:t.badge.value,slot:"information",variant:"text-color"}))})))))))}get element(){return this}static get watchers(){return{items:[{validateItems:0}],icon:[{validateIcon:0}],button:[{validateButton:0}],displayChevron:[{validateDisplayChevron:0}]}}static get style(){return".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}}:host{--mg-c-popover-padding-vertical:var(--mg-b-size-8);--mg-c-popover-padding-horizontal:0;--mg-c-popover-max-width:unset}.mg-c-action-more__divider{--mg-c-divider-spacing-vertical:var(--mg-b-size-4)}.mg-c-action-more__chevron{transition:200ms}.mg-c-action-more__chevron--rotate.mg-c-action-more__chevron{transform:rotate(180deg)}"}},[1,"mg-action-more",{items:[16],icon:[1040],button:[16],displayChevron:[4,"display-chevron"],expanded:[32]},void 0,{items:[{validateItems:0}],icon:[{validateIcon:0}],button:[{validateButton:0}],displayChevron:[{validateDisplayChevron:0}]}]);function w(){"undefined"!=typeof customElements&&["mg-action-more","mg-badge","mg-button","mg-card","mg-divider","mg-icon","mg-item-more","mg-menu","mg-menu-item","mg-popover","mg-popover-content"].forEach((e=>{switch(e){case"mg-action-more":customElements.get(t(e))||customElements.define(t(e),j);break;case"mg-badge":customElements.get(t(e))||p();break;case"mg-button":customElements.get(t(e))||h();break;case"mg-card":customElements.get(t(e))||l();break;case"mg-divider":customElements.get(t(e))||g();break;case"mg-icon":customElements.get(t(e))||v();break;case"mg-item-more":customElements.get(t(e))||b();break;case"mg-menu":customElements.get(t(e))||u();break;case"mg-menu-item":customElements.get(t(e))||n();break;case"mg-popover":customElements.get(t(e))||f();break;case"mg-popover-content":customElements.get(t(e))||y()}}))}w();const _=j,I=w;export{_ as MgActionMore,I as defineCustomElement}
@@ -1,224 +1 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, forceUpdate, h } from '@stencil/core/internal/client';
2
- import { C as ClassList, t as toString } from './index2.js';
3
- import { i as initLocales } from './index3.js';
4
- import { d as defineCustomElement$5 } from './mg-button2.js';
5
- import { d as defineCustomElement$4 } from './mg-card2.js';
6
- import { d as defineCustomElement$3 } from './mg-icon2.js';
7
- import { d as defineCustomElement$2 } from './mg-message2.js';
8
-
9
- /**
10
- * List available variants
11
- */
12
- const variants = ['info', 'warning', 'success', 'danger'];
13
- /**
14
- * List available variant styles
15
- */
16
- const variantStyles = ['bar-left', 'background'];
17
-
18
- const mgAlertCss = ".mg-c-alert__close-button{position:absolute;top:0;right:0}.mg-c-alert.mg-c-alert--close-button{--mg-c-card-spacing:0 var(--mg-b-size-min-height) 0 0}";
19
-
20
- const MgAlert$1 = /*@__PURE__*/ proxyCustomElement(class MgAlert extends HTMLElement {
21
- constructor(registerHost) {
22
- super();
23
- if (registerHost !== false) {
24
- this.__registerHost();
25
- }
26
- this.__attachShadow();
27
- this.componentShow = createEvent(this, "component-show", 3);
28
- this.componentHide = createEvent(this, "component-hide", 3);
29
- this.componentClose = createEvent(this, "component-close", 3);
30
- /************
31
- * Internal *
32
- ************/
33
- // Classes
34
- this.classCloseButton = 'mg-c-alert--close-button';
35
- // Stored timer setted when hide action is run from setTimeOut
36
- this.storedTimer = null;
37
- // Manage hover
38
- this.isFocused = false;
39
- this.isHovered = false;
40
- /**
41
- * Define variant
42
- */
43
- this.variant = 'info';
44
- /**
45
- * Define variant style
46
- */
47
- this.variantStyle = 'bar-left';
48
- /**
49
- * Component classes
50
- */
51
- this.classCollection = new ClassList(['mg-c-alert']);
52
- /**
53
- * Define if component is using actions slot
54
- */
55
- this.hasActions = false;
56
- /**
57
- * Set timer
58
- */
59
- this.setTimer = () => {
60
- this.storedTimer = setTimeout(() => (this.element.hidden = true), this.delay * 1000);
61
- };
62
- /**
63
- * Clear timer
64
- */
65
- this.clearTimer = () => {
66
- clearTimeout(this.storedTimer);
67
- };
68
- /**
69
- * Event to add on element
70
- * @param event - event
71
- */
72
- this.timerEvents = (event) => {
73
- this.clearTimer();
74
- const isMouseEvent = event.type === 'mouseenter';
75
- // Needed to ensure we don't start the timer
76
- this[isMouseEvent ? 'isHovered' : 'isFocused'] = true;
77
- // Restart timer when loose focus AND mouse leave
78
- this.element.addEventListener(isMouseEvent ? 'mouseleave' : 'focusout', eventOut => {
79
- this[eventOut.type === 'mouseleave' ? 'isHovered' : 'isFocused'] = false;
80
- // Start timer if needed
81
- if (!this.isFocused && !this.isHovered)
82
- this.setTimer();
83
- }, { once: true });
84
- };
85
- /**
86
- * Handle close button
87
- */
88
- this.handleClose = () => {
89
- this.element.hidden = true;
90
- this.componentClose.emit();
91
- };
92
- }
93
- watchDelay(newValue) {
94
- if (newValue !== undefined && newValue < 2) {
95
- throw new Error(`<mg-alert> prop "delay" must be greater than 2 seconds. Passed value: ${toString(newValue)}.`);
96
- }
97
- }
98
- watchVariant(newValue) {
99
- if (newValue && !variants.includes(newValue)) {
100
- throw new Error(`<mg-alert> prop "variant" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);
101
- }
102
- }
103
- watchVariantStyle(newValue) {
104
- if (newValue && !variantStyles.includes(newValue)) {
105
- throw new Error(`<mg-alert> prop "variantStyle" must be one of: ${variantStyles.join(', ')}. Passed value: ${toString(newValue)}.`);
106
- }
107
- }
108
- /**
109
- * Watch hidden prop
110
- */
111
- // eslint-disable-next-line @stencil-community/no-unused-watch
112
- watchHidden(newValue) {
113
- if (typeof newValue === 'string' && newValue === '') {
114
- newValue = true;
115
- }
116
- if (newValue) {
117
- this.componentHide.emit();
118
- // Remove event Listener
119
- ['focusin', 'mouseenter'].forEach(event => {
120
- this.element.removeEventListener(event, this.timerEvents);
121
- });
122
- // Clear Timer
123
- this.clearTimer();
124
- }
125
- else {
126
- this.componentShow.emit();
127
- // If delay is set
128
- if (this.delay > 1) {
129
- // Start timer
130
- this.setTimer();
131
- // Stop timer when get focus or mouse enter
132
- ['focusin', 'mouseenter'].forEach(event => {
133
- this.element.addEventListener(event, this.timerEvents);
134
- });
135
- }
136
- }
137
- forceUpdate(this);
138
- }
139
- /*************
140
- * Lifecycle *
141
- *************/
142
- /**
143
- * Check if component props are well configured on init
144
- */
145
- componentWillLoad() {
146
- // Get locales
147
- this.messages = initLocales(this.element).messages;
148
- // Validate
149
- this.watchVariant(this.variant);
150
- this.watchVariantStyle(this.variantStyle);
151
- this.watchDelay(this.delay);
152
- this.watchHidden(this.element.hidden);
153
- // Check if component has actions slot
154
- this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
155
- if (!this.hasActions) {
156
- this.classCollection.add(this.classCloseButton);
157
- }
158
- }
159
- /**
160
- * Render
161
- * @returns HTML Element
162
- */
163
- render() {
164
- return (h("mg-message", { key: '4b974a10812e527a2c481ec00f22324ab490a135', class: this.classCollection.join(), role: ['info', 'success'].includes(this.variant) ? 'status' : 'alert', variant: this.variant, variantStyle: this.variantStyle }, h("slot", { key: '9133a3cca56d67e75e8c3f018c52838c31e908f2' }), this.hasActions ? (h("span", { slot: "actions" }, h("slot", { name: "actions" }))) : (h("span", { class: "mg-c-alert__close-button" }, h("mg-button", { "is-icon": true, variant: "flat", label: this.messages.alert.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" }))))));
165
- }
166
- get element() { return this; }
167
- static get watchers() { return {
168
- "delay": ["watchDelay"],
169
- "variant": ["watchVariant"],
170
- "variantStyle": ["watchVariantStyle"],
171
- "hidden": ["watchHidden"]
172
- }; }
173
- static get style() { return mgAlertCss; }
174
- }, [257, "mg-alert", {
175
- "delay": [2],
176
- "variant": [1],
177
- "variantStyle": [1, "variant-style"],
178
- "classCollection": [32],
179
- "hasActions": [32]
180
- }, undefined, {
181
- "delay": ["watchDelay"],
182
- "variant": ["watchVariant"],
183
- "variantStyle": ["watchVariantStyle"],
184
- "hidden": ["watchHidden"]
185
- }]);
186
- function defineCustomElement$1() {
187
- if (typeof customElements === "undefined") {
188
- return;
189
- }
190
- const components = ["mg-alert", "mg-button", "mg-card", "mg-icon", "mg-message"];
191
- components.forEach(tagName => { switch (tagName) {
192
- case "mg-alert":
193
- if (!customElements.get(tagName)) {
194
- customElements.define(tagName, MgAlert$1);
195
- }
196
- break;
197
- case "mg-button":
198
- if (!customElements.get(tagName)) {
199
- defineCustomElement$5();
200
- }
201
- break;
202
- case "mg-card":
203
- if (!customElements.get(tagName)) {
204
- defineCustomElement$4();
205
- }
206
- break;
207
- case "mg-icon":
208
- if (!customElements.get(tagName)) {
209
- defineCustomElement$3();
210
- }
211
- break;
212
- case "mg-message":
213
- if (!customElements.get(tagName)) {
214
- defineCustomElement$2();
215
- }
216
- break;
217
- } });
218
- }
219
- defineCustomElement$1();
220
-
221
- const MgAlert = MgAlert$1;
222
- const defineCustomElement = defineCustomElement$1;
223
-
224
- export { MgAlert, defineCustomElement };
1
+ import{transformTag as t,proxyCustomElement as s,HTMLElement as e,createEvent as i,forceUpdate as a,h as o}from"@stencil/core/internal/client";import{C as n,t as r}from"./index2.js";import{i as h}from"./index3.js";import{d as c}from"./mg-button2.js";import{d as m}from"./mg-card2.js";import{d as l}from"./mg-icon2.js";import{d}from"./mg-message2.js";const u=["info","warning","success","danger"],g=["bar-left","background"],f=s(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.componentShow=i(this,"component-show",3),this.componentHide=i(this,"component-hide",3),this.componentClose=i(this,"component-close",3),this.classCloseButton="mg-c-alert--close-button",this.storedTimer=null,this.isFocused=!1,this.isHovered=!1,this.variant="info",this.variantStyle="bar-left",this.classCollection=new n(["mg-c-alert"]),this.hasActions=!1,this.setTimer=()=>{this.storedTimer=setTimeout((()=>this.element.hidden=!0),1e3*this.delay)},this.clearTimer=()=>{clearTimeout(this.storedTimer)},this.timerEvents=t=>{this.clearTimer();const s="mouseenter"===t.type;this[s?"isHovered":"isFocused"]=!0,this.element.addEventListener(s?"mouseleave":"focusout",(t=>{this["mouseleave"===t.type?"isHovered":"isFocused"]=!1,this.isFocused||this.isHovered||this.setTimer()}),{once:!0})},this.handleClose=()=>{this.element.hidden=!0,this.componentClose.emit()}}watchDelay(t){if(void 0!==t&&t<2)throw Error(`<mg-alert> prop "delay" must be greater than 2 seconds. Passed value: ${r(t)}.`)}watchVariant(t){if(t&&!u.includes(t))throw Error(`<mg-alert> prop "variant" must be one of: ${u.join(", ")}. Passed value: ${r(t)}.`)}watchVariantStyle(t){if(t&&!g.includes(t))throw Error(`<mg-alert> prop "variantStyle" must be one of: ${g.join(", ")}. Passed value: ${r(t)}.`)}watchHidden(t){"string"==typeof t&&""===t&&(t=!0),t?(this.componentHide.emit(),["focusin","mouseenter"].forEach((t=>{this.element.removeEventListener(t,this.timerEvents)})),this.clearTimer()):(this.componentShow.emit(),this.delay>1&&(this.setTimer(),["focusin","mouseenter"].forEach((t=>{this.element.addEventListener(t,this.timerEvents)})))),a(this)}componentWillLoad(){this.messages=h(this.element).messages,this.watchVariant(this.variant),this.watchVariantStyle(this.variantStyle),this.watchDelay(this.delay),this.watchHidden(this.element.hidden),this.hasActions=null!==this.element.querySelector('[slot="actions"]'),this.hasActions||this.classCollection.add(this.classCloseButton)}render(){return o("mg-message",{key:"6085a45d00c4762bae88d98e89f44c20d5f9b6c4",class:this.classCollection.join(),role:["info","success"].includes(this.variant)?"status":"alert",variant:this.variant,variantStyle:this.variantStyle},o("slot",{key:"55491d1b41609883958680c14a2ddb8dd84a3bd4"}),this.hasActions?o("span",{slot:"actions"},o("slot",{name:"actions"})):o("span",{class:"mg-c-alert__close-button"},o("mg-button",{"is-icon":!0,variant:"flat",label:this.messages.alert.closeButton,onClick:this.handleClose},o("mg-icon",{icon:"cross"}))))}get element(){return this}static get watchers(){return{delay:[{watchDelay:0}],variant:[{watchVariant:0}],variantStyle:[{watchVariantStyle:0}],hidden:[{watchHidden:0}]}}static get style(){return".mg-c-alert__close-button{position:absolute;top:0;right:0}.mg-c-alert.mg-c-alert--close-button{--mg-c-card-spacing:0 var(--mg-b-size-min-height) 0 0}"}},[257,"mg-alert",{delay:[2],variant:[1],variantStyle:[1,"variant-style"],classCollection:[32],hasActions:[32]},void 0,{delay:[{watchDelay:0}],variant:[{watchVariant:0}],variantStyle:[{watchVariantStyle:0}],hidden:[{watchHidden:0}]}]);function b(){"undefined"!=typeof customElements&&["mg-alert","mg-button","mg-card","mg-icon","mg-message"].forEach((s=>{switch(s){case"mg-alert":customElements.get(t(s))||customElements.define(t(s),f);break;case"mg-button":customElements.get(t(s))||c();break;case"mg-card":customElements.get(t(s))||m();break;case"mg-icon":customElements.get(t(s))||l();break;case"mg-message":customElements.get(t(s))||d()}}))}b();const p=f,y=b;export{p as MgAlert,y as defineCustomElement}
@@ -1,6 +1 @@
1
- import { M as MgBadge$1, d as defineCustomElement$1 } from './mg-badge2.js';
2
-
3
- const MgBadge = MgBadge$1;
4
- const defineCustomElement = defineCustomElement$1;
5
-
6
- export { MgBadge, defineCustomElement };
1
+ import{M as o,d as s}from"./mg-badge2.js";const a=o,m=s;export{a as MgBadge,m as defineCustomElement}
@@ -1,113 +1 @@
1
- import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
- import { C as ClassList, t as toString, i as isValidString } from './index2.js';
3
-
4
- /**
5
- * List of all possibles variants
6
- */
7
- const variants = ['info', 'primary', 'secondary', 'success', 'warning', 'danger', 'text-color'];
8
-
9
- const mgBadgeCss = ".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}}/*!\n * @prop --mg-c-badge-size: Defines the height and minimum width of the badge. The default value is `--mg-b-size-16`.\n * @prop --mg-c-badge-font-size: Defines the font size of the badge. The default value is `--mg-b-font-size-small`.\n * @prop --mg-c-badge-color-text: Defines the font color of the badge when used with the `text-color` variant and without `outline`. The default value is `--mg-b-color-light`.\n */.mg-c-badge{min-width:var(--mg-c-badge-size);height:var(--mg-c-badge-size);box-sizing:border-box;padding:0 var(--mg-b-size-4);border:var(--mg-b-size-border) solid;border-radius:calc(var(--mg-c-badge-size)/2);font-size:var(--mg-c-badge-font-size);font-weight:600;line-height:var(--mg-c-badge-size);text-align:center}.mg-c-badge.mg-c-badge--primary{border-color:var(--mg-b-color-primary);background-color:var(--mg-b-color-primary);color:var(--mg-b-color-text-on-primary)}.mg-c-badge.mg-c-badge--primary.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-primary)}.mg-c-badge.mg-c-badge--secondary{border-color:var(--mg-b-color-secondary);background-color:var(--mg-b-color-secondary);color:var(--mg-b-color-text-on-secondary)}.mg-c-badge.mg-c-badge--secondary.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-secondary)}.mg-c-badge.mg-c-badge--danger{border-color:var(--mg-b-color-danger);background-color:var(--mg-b-color-danger);color:var(--mg-b-color-text-on-danger)}.mg-c-badge.mg-c-badge--danger.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-danger)}.mg-c-badge.mg-c-badge--info{border-color:var(--mg-b-color-info);background-color:var(--mg-b-color-info);color:var(--mg-b-color-text-on-info)}.mg-c-badge.mg-c-badge--info.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-info)}.mg-c-badge.mg-c-badge--success{border-color:var(--mg-b-color-success);background-color:var(--mg-b-color-success);color:var(--mg-b-color-text-on-success)}.mg-c-badge.mg-c-badge--success.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-success)}.mg-c-badge.mg-c-badge--warning{border-color:var(--mg-b-color-warning);background-color:var(--mg-b-color-warning);color:var(--mg-b-color-text-on-warning)}.mg-c-badge.mg-c-badge--warning.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-warning)}.mg-c-badge.mg-c-badge--text-color{border-color:currentcolor;background-color:currentcolor}.mg-c-badge.mg-c-badge--text-color .mg-c-badge__value{color:var(--mg-c-badge-color-text, var(--mg-b-color-light))}.mg-c-badge.mg-c-badge--text-color.mg-c-badge--outline{background-color:rgba(0,0,0,0)}.mg-c-badge.mg-c-badge--text-color.mg-c-badge--outline .mg-c-badge__value{color:currentcolor}.mg-c-badge,mg-badge{display:inline-flex;align-items:center;justify-content:center}";
10
-
11
- const MgBadge = /*@__PURE__*/ proxyCustomElement(class MgBadge extends HTMLElement {
12
- constructor(registerHost) {
13
- super();
14
- if (registerHost !== false) {
15
- this.__registerHost();
16
- }
17
- this.__attachShadow();
18
- /************
19
- * Internal *
20
- ************/
21
- // Classes
22
- this.classOutline = `mg-c-badge--outline`;
23
- /**
24
- * Define badge variant
25
- */
26
- this.variant = 'info';
27
- /**
28
- * Define if button is using outline style
29
- */
30
- this.outline = false;
31
- /**
32
- * Component classes
33
- */
34
- this.classCollection = new ClassList(['mg-c-badge']);
35
- }
36
- validateValue(newValue) {
37
- if (/^[^A-Z]+$/i.exec(`${newValue}`) === null) {
38
- throw new Error(`<mg-badge> prop "value" is required and must be integer and/or special character. Passed value: ${toString(newValue)}.`);
39
- }
40
- }
41
- validateLabel(newValue) {
42
- if (!isValidString(newValue)) {
43
- throw new Error(`<mg-badge> prop "label" is required and must be a string. Passed value: ${toString(newValue)}.`);
44
- }
45
- }
46
- validateVariant(newValue, oldValue) {
47
- if (!variants.includes(newValue)) {
48
- throw new Error(`<mg-badge> prop "variant" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);
49
- }
50
- else {
51
- if (oldValue !== undefined) {
52
- this.classCollection.delete(`mg-c-badge--${oldValue}`);
53
- }
54
- this.classCollection.add(`mg-c-badge--${newValue}`);
55
- }
56
- }
57
- validateOutline(newValue) {
58
- if (newValue)
59
- this.classCollection.add(this.classOutline);
60
- else
61
- this.classCollection.delete(this.classOutline);
62
- }
63
- /**
64
- * Check if props are well configured on init
65
- */
66
- componentWillLoad() {
67
- this.validateValue(this.value);
68
- this.validateLabel(this.label);
69
- this.validateVariant(this.variant);
70
- this.validateOutline(this.outline);
71
- }
72
- /**
73
- * Render
74
- * @returns HTML Element
75
- */
76
- render() {
77
- return (h("span", { key: '27e42212d525a31576dbe826babca52d99a3476b', class: this.classCollection.join() }, h("span", { key: 'f24658252cc62a38879a1e8321c477723c2dc919', class: "mg-c-badge__value" }, this.value), h("span", { key: '9f51fe7c868a8d53d9f138ec4229e1ba09e7284e', class: "mg-u-visually-hidden" }, this.label)));
78
- }
79
- static get watchers() { return {
80
- "value": ["validateValue"],
81
- "label": ["validateLabel"],
82
- "variant": ["validateVariant"],
83
- "outline": ["validateOutline"]
84
- }; }
85
- static get style() { return mgBadgeCss; }
86
- }, [257, "mg-badge", {
87
- "value": [8],
88
- "label": [1],
89
- "variant": [1],
90
- "outline": [4],
91
- "classCollection": [32]
92
- }, undefined, {
93
- "value": ["validateValue"],
94
- "label": ["validateLabel"],
95
- "variant": ["validateVariant"],
96
- "outline": ["validateOutline"]
97
- }]);
98
- function defineCustomElement() {
99
- if (typeof customElements === "undefined") {
100
- return;
101
- }
102
- const components = ["mg-badge"];
103
- components.forEach(tagName => { switch (tagName) {
104
- case "mg-badge":
105
- if (!customElements.get(tagName)) {
106
- customElements.define(tagName, MgBadge);
107
- }
108
- break;
109
- } });
110
- }
111
- defineCustomElement();
112
-
113
- export { MgBadge as M, defineCustomElement as d };
1
+ import{transformTag as r,proxyCustomElement as a,HTMLElement as e,h as o}from"@stencil/core/internal/client";import{C as c,t as g,i as t}from"./index2.js";const i=["info","primary","secondary","success","warning","danger","text-color"],n=a(class extends e{constructor(r){super(),!1!==r&&this.__registerHost(),this.__attachShadow(),this.classOutline="mg-c-badge--outline",this.variant="info",this.outline=!1,this.classCollection=new c(["mg-c-badge"])}validateValue(r){if(null===/^[^A-Z]+$/i.exec(`${r}`))throw new Error(`<mg-badge> prop "value" is required and must be integer and/or special character. Passed value: ${g(r)}.`)}validateLabel(r){if(!t(r))throw new Error(`<mg-badge> prop "label" is required and must be a string. Passed value: ${g(r)}.`)}validateVariant(r,a){if(!i.includes(r))throw new Error(`<mg-badge> prop "variant" must be one of: ${i.join(", ")}. Passed value: ${g(r)}.`);void 0!==a&&this.classCollection.delete(`mg-c-badge--${a}`),this.classCollection.add(`mg-c-badge--${r}`)}validateOutline(r){r?this.classCollection.add(this.classOutline):this.classCollection.delete(this.classOutline)}componentWillLoad(){this.validateValue(this.value),this.validateLabel(this.label),this.validateVariant(this.variant),this.validateOutline(this.outline)}render(){return o("span",{key:"27e42212d525a31576dbe826babca52d99a3476b",class:this.classCollection.join()},o("span",{key:"f24658252cc62a38879a1e8321c477723c2dc919",class:"mg-c-badge__value"},this.value),o("span",{key:"9f51fe7c868a8d53d9f138ec4229e1ba09e7284e",class:"mg-u-visually-hidden"},this.label))}static get watchers(){return{value:[{validateValue:0}],label:[{validateLabel:0}],variant:[{validateVariant:0}],outline:[{validateOutline:0}]}}static get style(){return".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}}.mg-c-badge{min-width:var(--mg-c-badge-size);height:var(--mg-c-badge-size);box-sizing:border-box;padding:0 var(--mg-b-size-4);border:var(--mg-b-size-border) solid;border-radius:calc(var(--mg-c-badge-size)/2);font-size:var(--mg-c-badge-font-size);font-weight:600;line-height:var(--mg-c-badge-size);text-align:center}.mg-c-badge.mg-c-badge--primary{border-color:var(--mg-b-color-primary);background-color:var(--mg-b-color-primary);color:var(--mg-b-color-text-on-primary)}.mg-c-badge.mg-c-badge--primary.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-primary)}.mg-c-badge.mg-c-badge--secondary{border-color:var(--mg-b-color-secondary);background-color:var(--mg-b-color-secondary);color:var(--mg-b-color-text-on-secondary)}.mg-c-badge.mg-c-badge--secondary.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-secondary)}.mg-c-badge.mg-c-badge--danger{border-color:var(--mg-b-color-danger);background-color:var(--mg-b-color-danger);color:var(--mg-b-color-text-on-danger)}.mg-c-badge.mg-c-badge--danger.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-danger)}.mg-c-badge.mg-c-badge--info{border-color:var(--mg-b-color-info);background-color:var(--mg-b-color-info);color:var(--mg-b-color-text-on-info)}.mg-c-badge.mg-c-badge--info.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-info)}.mg-c-badge.mg-c-badge--success{border-color:var(--mg-b-color-success);background-color:var(--mg-b-color-success);color:var(--mg-b-color-text-on-success)}.mg-c-badge.mg-c-badge--success.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-success)}.mg-c-badge.mg-c-badge--warning{border-color:var(--mg-b-color-warning);background-color:var(--mg-b-color-warning);color:var(--mg-b-color-text-on-warning)}.mg-c-badge.mg-c-badge--warning.mg-c-badge--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-warning)}.mg-c-badge.mg-c-badge--text-color{border-color:currentcolor;background-color:currentcolor}.mg-c-badge.mg-c-badge--text-color .mg-c-badge__value{color:var(--mg-c-badge-color-text, var(--mg-b-color-light))}.mg-c-badge.mg-c-badge--text-color.mg-c-badge--outline{background-color:rgba(0,0,0,0)}.mg-c-badge.mg-c-badge--text-color.mg-c-badge--outline .mg-c-badge__value{color:currentcolor}.mg-c-badge,mg-badge{display:inline-flex;align-items:center;justify-content:center}"}},[1,"mg-badge",{value:[8],label:[1],variant:[1],outline:[4],classCollection:[32]},void 0,{value:[{validateValue:0}],label:[{validateLabel:0}],variant:[{validateVariant:0}],outline:[{validateOutline:0}]}]);function l(){"undefined"!=typeof customElements&&["mg-badge"].forEach((a=>{"mg-badge"===a&&(customElements.get(r(a))||customElements.define(r(a),n))}))}l();export{n as M,l as d}
@@ -1,6 +1 @@
1
- import { M as MgButton$1, d as defineCustomElement$1 } from './mg-button2.js';
2
-
3
- const MgButton = MgButton$1;
4
- const defineCustomElement = defineCustomElement$1;
5
-
6
- export { MgButton, defineCustomElement };
1
+ import{M as o,d as t}from"./mg-button2.js";const s=o,m=t;export{s as MgButton,m as defineCustomElement}