@mgdis/mg-components 6.3.0 → 6.4.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 (231) hide show
  1. package/dist/cjs/{index-a5b2cd1b.js → index-911898e4.js} +410 -266
  2. package/dist/cjs/index-911898e4.js.map +1 -0
  3. package/dist/cjs/{index-cc11af95.js → index-a3269bfc.js} +3 -3
  4. package/dist/cjs/{index-cc11af95.js.map → index-a3269bfc.js.map} +1 -1
  5. package/dist/cjs/{index.es-ac7c22e3.js → index.es-325100d7.js} +47 -47
  6. package/dist/cjs/index.es-325100d7.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/cjs/mg-action-more_36.cjs.entry.js +1341 -951
  9. package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
  10. package/dist/cjs/mg-alert.cjs.entry.js +15 -12
  11. package/dist/cjs/mg-alert.cjs.entry.js.map +1 -1
  12. package/dist/cjs/mg-components.cjs.js +3 -3
  13. package/dist/cjs/mg-components.cjs.js.map +1 -1
  14. package/dist/cjs/mg-loader.cjs.entry.js +6 -8
  15. package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
  16. package/dist/cjs/mg-progress.cjs.entry.js +27 -12
  17. package/dist/cjs/mg-progress.cjs.entry.js.map +1 -1
  18. package/dist/collection/collection-manifest.json +2 -2
  19. package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js +10 -3
  20. package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js.map +1 -1
  21. package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js +15 -4
  22. package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js.map +1 -1
  23. package/dist/collection/components/atoms/mg-badge/mg-badge.js +15 -4
  24. package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
  25. package/dist/collection/components/atoms/mg-button/mg-button.js +50 -11
  26. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  27. package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
  28. package/dist/collection/components/atoms/mg-divider/mg-divider.js +9 -1
  29. package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -1
  30. package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -6
  31. package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
  32. package/dist/collection/components/atoms/mg-tag/mg-tag.js +14 -4
  33. package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
  34. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +3 -4
  35. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -1
  36. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +28 -6
  37. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  38. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +50 -13
  39. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js.map +1 -1
  40. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +29 -11
  41. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +106 -33
  43. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
  44. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +99 -36
  45. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
  46. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +130 -35
  47. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
  48. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +87 -25
  49. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
  50. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +86 -26
  51. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
  52. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +92 -30
  53. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
  54. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +108 -31
  55. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
  56. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +109 -29
  57. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
  58. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +67 -21
  59. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
  60. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +16 -70
  61. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js.map +1 -1
  62. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +101 -89
  63. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
  64. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +194 -157
  65. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
  66. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +19 -8
  67. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
  68. package/dist/collection/components/molecules/mg-alert/mg-alert.js +15 -6
  69. package/dist/collection/components/molecules/mg-alert/mg-alert.js.map +1 -1
  70. package/dist/collection/components/molecules/mg-details/mg-details.js +17 -5
  71. package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
  72. package/dist/collection/components/molecules/mg-form/mg-form.js +48 -16
  73. package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
  74. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +13 -3
  75. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
  76. package/dist/collection/components/molecules/mg-loader/mg-loader.js +5 -5
  77. package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
  78. package/dist/collection/components/molecules/mg-message/mg-message.js +22 -6
  79. package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
  80. package/dist/collection/components/molecules/mg-modal/mg-modal.js +37 -9
  81. package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
  82. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +28 -9
  83. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
  84. package/dist/collection/components/molecules/mg-panel/mg-panel.js +48 -13
  85. package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
  86. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +10 -2
  87. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -1
  88. package/dist/collection/components/molecules/mg-popover/mg-popover.js +44 -7
  89. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  90. package/dist/collection/components/molecules/mg-progress/mg-progress.js +26 -1
  91. package/dist/collection/components/molecules/mg-progress/mg-progress.js.map +1 -1
  92. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +3 -2
  93. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -1
  94. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +28 -8
  95. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
  96. package/dist/collection/utils/behaviors.utils.js +44 -107
  97. package/dist/collection/utils/behaviors.utils.js.map +1 -1
  98. package/dist/components/index.es.js +42 -42
  99. package/dist/components/index.es.js.map +1 -1
  100. package/dist/components/index2.js +2 -2
  101. package/dist/components/mg-action-more.js +15 -12
  102. package/dist/components/mg-action-more.js.map +1 -1
  103. package/dist/components/mg-alert.js +13 -10
  104. package/dist/components/mg-alert.js.map +1 -1
  105. package/dist/components/mg-badge2.js +13 -10
  106. package/dist/components/mg-badge2.js.map +1 -1
  107. package/dist/components/mg-button2.js +37 -16
  108. package/dist/components/mg-button2.js.map +1 -1
  109. package/dist/components/mg-card2.js +1 -1
  110. package/dist/components/mg-character-left2.js +8 -7
  111. package/dist/components/mg-character-left2.js.map +1 -1
  112. package/dist/components/mg-details.js +11 -7
  113. package/dist/components/mg-details.js.map +1 -1
  114. package/dist/components/mg-divider2.js +7 -1
  115. package/dist/components/mg-divider2.js.map +1 -1
  116. package/dist/components/mg-form.js +35 -21
  117. package/dist/components/mg-form.js.map +1 -1
  118. package/dist/components/mg-icon2.js +17 -11
  119. package/dist/components/mg-icon2.js.map +1 -1
  120. package/dist/components/mg-illustrated-message.js +10 -4
  121. package/dist/components/mg-illustrated-message.js.map +1 -1
  122. package/dist/components/mg-input-checkbox-paginated2.js +14 -10
  123. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  124. package/dist/components/mg-input-checkbox.js +73 -40
  125. package/dist/components/mg-input-checkbox.js.map +1 -1
  126. package/dist/components/mg-input-date.js +77 -46
  127. package/dist/components/mg-input-date.js.map +1 -1
  128. package/dist/components/mg-input-numeric.js +89 -44
  129. package/dist/components/mg-input-numeric.js.map +1 -1
  130. package/dist/components/mg-input-password.js +55 -27
  131. package/dist/components/mg-input-password.js.map +1 -1
  132. package/dist/components/mg-input-radio.js +59 -31
  133. package/dist/components/mg-input-radio.js.map +1 -1
  134. package/dist/components/mg-input-select2.js +59 -35
  135. package/dist/components/mg-input-select2.js.map +1 -1
  136. package/dist/components/mg-input-text2.js +69 -38
  137. package/dist/components/mg-input-text2.js.map +1 -1
  138. package/dist/components/mg-input-textarea.js +71 -35
  139. package/dist/components/mg-input-textarea.js.map +1 -1
  140. package/dist/components/mg-input-title2.js +11 -8
  141. package/dist/components/mg-input-title2.js.map +1 -1
  142. package/dist/components/mg-input-toggle.js +43 -25
  143. package/dist/components/mg-input-toggle.js.map +1 -1
  144. package/dist/components/mg-input2.js +37 -20
  145. package/dist/components/mg-input2.js.map +1 -1
  146. package/dist/components/mg-item-more2.js +146 -270
  147. package/dist/components/mg-item-more2.js.map +1 -1
  148. package/dist/components/mg-loader.js +4 -6
  149. package/dist/components/mg-loader.js.map +1 -1
  150. package/dist/components/mg-menu-item2.js +193 -149
  151. package/dist/components/mg-menu-item2.js.map +1 -1
  152. package/dist/components/mg-message2.js +21 -9
  153. package/dist/components/mg-message2.js.map +1 -1
  154. package/dist/components/mg-modal.js +33 -15
  155. package/dist/components/mg-modal.js.map +1 -1
  156. package/dist/components/mg-pagination2.js +21 -14
  157. package/dist/components/mg-pagination2.js.map +1 -1
  158. package/dist/components/mg-panel.js +37 -20
  159. package/dist/components/mg-panel.js.map +1 -1
  160. package/dist/components/mg-popover-content2.js +9 -3
  161. package/dist/components/mg-popover-content2.js.map +1 -1
  162. package/dist/components/mg-popover2.js +35 -10
  163. package/dist/components/mg-popover2.js.map +1 -1
  164. package/dist/components/mg-progress.js +26 -11
  165. package/dist/components/mg-progress.js.map +1 -1
  166. package/dist/components/mg-skip-links.js +2 -3
  167. package/dist/components/mg-skip-links.js.map +1 -1
  168. package/dist/components/mg-tabs.js +27 -17
  169. package/dist/components/mg-tabs.js.map +1 -1
  170. package/dist/components/mg-tag.js +12 -8
  171. package/dist/components/mg-tag.js.map +1 -1
  172. package/dist/components/mg-tooltip-content2.js +1 -2
  173. package/dist/components/mg-tooltip-content2.js.map +1 -1
  174. package/dist/components/mg-tooltip2.js +24 -12
  175. package/dist/components/mg-tooltip2.js.map +1 -1
  176. package/dist/esm/{index-eb0e1053.js → index-1f32332a.js} +410 -266
  177. package/dist/esm/index-1f32332a.js.map +1 -0
  178. package/dist/esm/{index-f3d3fb70.js → index-9bd10f5d.js} +3 -3
  179. package/dist/esm/{index-f3d3fb70.js.map → index-9bd10f5d.js.map} +1 -1
  180. package/dist/esm/{index.es-940821a9.js → index.es-a2587b72.js} +43 -43
  181. package/dist/esm/index.es-a2587b72.js.map +1 -0
  182. package/dist/esm/loader.js +3 -3
  183. package/dist/esm/mg-action-more_36.entry.js +1341 -951
  184. package/dist/esm/mg-action-more_36.entry.js.map +1 -1
  185. package/dist/esm/mg-alert.entry.js +15 -12
  186. package/dist/esm/mg-alert.entry.js.map +1 -1
  187. package/dist/esm/mg-components.js +4 -4
  188. package/dist/esm/mg-components.js.map +1 -1
  189. package/dist/esm/mg-loader.entry.js +6 -8
  190. package/dist/esm/mg-loader.entry.js.map +1 -1
  191. package/dist/esm/mg-progress.entry.js +27 -12
  192. package/dist/esm/mg-progress.entry.js.map +1 -1
  193. package/dist/mg-components/mg-components.esm.js +1 -1
  194. package/dist/mg-components/mg-components.esm.js.map +1 -1
  195. package/dist/mg-components/p-0ead5317.entry.js +2 -0
  196. package/dist/mg-components/{p-d0086664.entry.js.map → p-0ead5317.entry.js.map} +1 -1
  197. package/dist/mg-components/p-35898742.js +3 -0
  198. package/dist/mg-components/p-35898742.js.map +1 -0
  199. package/dist/mg-components/p-3b052ac0.entry.js +2 -0
  200. package/dist/mg-components/p-3b052ac0.entry.js.map +1 -0
  201. package/dist/mg-components/p-6810a565.entry.js +2 -0
  202. package/dist/mg-components/p-6810a565.entry.js.map +1 -0
  203. package/dist/mg-components/{p-ee51ec5e.js → p-b986c107.js} +2 -2
  204. package/dist/mg-components/p-b986c107.js.map +1 -0
  205. package/dist/mg-components/{p-a49e2b74.js → p-dc436f3c.js} +2 -2
  206. package/dist/mg-components/p-f48d964f.entry.js +2 -0
  207. package/dist/mg-components/p-f48d964f.entry.js.map +1 -0
  208. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +6 -0
  209. package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.d.ts +1 -15
  210. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +14 -30
  211. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +46 -37
  212. package/dist/types/components.d.ts +0 -5
  213. package/dist/types/utils/behaviors.utils.d.ts +15 -44
  214. package/ide/intellij/web-types.json +3 -7
  215. package/ide/vscode/html-custom-data.json +2 -2
  216. package/package.json +22 -22
  217. package/dist/cjs/index-a5b2cd1b.js.map +0 -1
  218. package/dist/cjs/index.es-ac7c22e3.js.map +0 -1
  219. package/dist/esm/index-eb0e1053.js.map +0 -1
  220. package/dist/esm/index.es-940821a9.js.map +0 -1
  221. package/dist/mg-components/p-15b6849a.js +0 -3
  222. package/dist/mg-components/p-15b6849a.js.map +0 -1
  223. package/dist/mg-components/p-3aecf564.entry.js +0 -2
  224. package/dist/mg-components/p-3aecf564.entry.js.map +0 -1
  225. package/dist/mg-components/p-6f3d70b2.entry.js +0 -2
  226. package/dist/mg-components/p-6f3d70b2.entry.js.map +0 -1
  227. package/dist/mg-components/p-a17ea0af.entry.js +0 -2
  228. package/dist/mg-components/p-a17ea0af.entry.js.map +0 -1
  229. package/dist/mg-components/p-d0086664.entry.js +0 -2
  230. package/dist/mg-components/p-ee51ec5e.js.map +0 -1
  231. /package/dist/mg-components/{p-a49e2b74.js.map → p-dc436f3c.js.map} +0 -0
@@ -5,10 +5,13 @@ import { isValideID, isValidString, toString } from "@mgdis/stencil-helpers";
5
5
  */
6
6
  export class MgInputTitle {
7
7
  constructor() {
8
- this.identifier = undefined;
9
- this.required = undefined;
10
- this.readonly = undefined;
8
+ /**
9
+ * Switch from label to fieldset sementic
10
+ */
11
11
  this.isLegend = false;
12
+ /**
13
+ * Component parent tagname
14
+ */
12
15
  this.tagName = 'label';
13
16
  }
14
17
  validateIdentifier(newValue) {
@@ -39,7 +42,7 @@ export class MgInputTitle {
39
42
  render() {
40
43
  const TagName = this.readonly ? 'span' : this.tagName;
41
44
  // \u00A0 represent a  
42
- return (h(TagName, { key: '2185a08a69a1b749c7e36d430b83079cbce131de', class: "mg-c-input-title", htmlFor: !this.isLegend && this.identifier, id: this.isLegend ? `${this.identifier}-title` : undefined }, h("slot", { key: 'eb7409f94e137a2dacd83fa7df27c6b2635bf660' }), this.required && !this.readonly && (h("span", { key: '6910dd3c0d87ea94ab3c07371e5ee55b212d9342', class: "mg-c-input-title__required" }, "\u00A0", h("span", { key: '45e9d38af05410888be0fc36e04d4641a41f367b', class: "mg-u-is-asterisk" }, "*")))));
45
+ return (h(TagName, { key: 'f8f8baaeb87e7c2cc77e71781f4d33ea5a63f760', class: "mg-c-input-title", htmlFor: !this.isLegend && this.identifier, id: this.isLegend ? `${this.identifier}-title` : undefined }, h("slot", { key: '7f6c0f451dfe789d924e9f608813e03bc72ad88a' }), this.required && !this.readonly && (h("span", { key: 'a78c5191995399e3e2ad346fec8546277581ca9d', class: "mg-c-input-title__required" }, "\u00A0", h("span", { key: 'ae8df5f13d54a1b8419d0d01048ff91dda601ab6', class: "mg-u-is-asterisk" }, "*")))));
43
46
  }
44
47
  static get is() { return "mg-input-title"; }
45
48
  static get encapsulation() { return "scoped"; }
@@ -69,6 +72,8 @@ export class MgInputTitle {
69
72
  "tags": [],
70
73
  "text": "Label input id"
71
74
  },
75
+ "getter": false,
76
+ "setter": false,
72
77
  "attribute": "identifier",
73
78
  "reflect": false
74
79
  },
@@ -86,6 +91,8 @@ export class MgInputTitle {
86
91
  "tags": [],
87
92
  "text": "If input is required an asterisk is added at the end of the label"
88
93
  },
94
+ "getter": false,
95
+ "setter": false,
89
96
  "attribute": "required",
90
97
  "reflect": false
91
98
  },
@@ -103,6 +110,8 @@ export class MgInputTitle {
103
110
  "tags": [],
104
111
  "text": "If input is required an asterisk is added at the end of the label"
105
112
  },
113
+ "getter": false,
114
+ "setter": false,
106
115
  "attribute": "readonly",
107
116
  "reflect": false
108
117
  },
@@ -120,6 +129,8 @@ export class MgInputTitle {
120
129
  "tags": [],
121
130
  "text": "Switch from label to fieldset sementic"
122
131
  },
132
+ "getter": false,
133
+ "setter": false,
123
134
  "attribute": "is-legend",
124
135
  "reflect": false,
125
136
  "defaultValue": "false"
@@ -1 +1 @@
1
- {"version":3,"file":"mg-input-title.js","sour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I,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,QAAQ,CAAC,CAAC,CAAC,SAAS;YACtI,8DAAa;YACZ,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAClC,6DAAM,KAAK,EAAC,4BAA4B;;gBAChC,6DAAM,KAAK,EAAC,kBAAkB,QAAS,CACxC,CACR,CACO,CACX,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Watch } from '@stencil/core';\nimport { isValideID, isValidString, toString } from '@mgdis/stencil-helpers';\n\n/**\n * @internal\n */\n@Component({\n tag: 'mg-input-title',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-title.css',\n scoped: true,\n})\nexport class MgInputTitle {\n /**\n * Label input id\n */\n @Prop() identifier!: string;\n @Watch('identifier')\n validateIdentifier(newValue: MgInputTitle['identifier']): void {\n if (!isValidString(newValue)) {\n throw new Error('<mg-input-title> prop \"identifier\" is required.');\n } else if (!isValideID(newValue)) {\n console.error(`<mg-input-title> prop \"identifier\" value is invalid. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * If input is required an asterisk is added at the end of the label\n */\n @Prop() required?: boolean;\n\n /**\n * If input is required an asterisk is added at the end of the label\n */\n @Prop() readonly?: boolean;\n\n /**\n * Switch from label to fieldset sementic\n */\n @Prop() isLegend = false;\n @Watch('isLegend')\n validateIsLegend(newValue: MgInputTitle['isLegend']) {\n this.tagName = newValue ? 'legend' : 'label';\n }\n\n /**\n * Component parent tagname\n */\n @State() tagName = 'label';\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Init tag name\n */\n componentWillLoad(): void {\n this.validateIdentifier(this.identifier);\n this.validateIsLegend(this.isLegend);\n }\n\n /**\n * Render\n * @returns HTML element\n */\n render(): HTMLElement {\n const TagName = this.readonly ? 'span' : this.tagName;\n // \\u00A0 represent a &nbsp;\n return (\n <TagName class=\"mg-c-input-title\" htmlFor={!this.isLegend && this.identifier} id={this.isLegend ? `${this.identifier}-title` : undefined}>\n <slot></slot>\n {this.required && !this.readonly && (\n <span class=\"mg-c-input-title__required\">\n &nbsp;<span class=\"mg-u-is-asterisk\">*</span>\n </span>\n )}\n </TagName>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mg-input-title.js","sourceRoot":"","sources":["../../../../../src/components/atoms/internals/mg-input-title/mg-input-title.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAE7E;;GAEG;AAMH,MAAM,OAAO,YAAY;IALzB;QA6BE;;WAEG;QACK,aAAQ,GAAG,KAAK,CAAC;QAMzB;;WAEG;QACM,YAAO,GAAG,OAAO,CAAC;KAgC5B;IA9DC,kBAAkB,CAAC,QAAoC;QACrD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;aAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,KAAK,CAAC,sEAAsE,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC7G,CAAC;IACH,CAAC;IAiBD,gBAAgB,CAAC,QAAkC;QACjD,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,CAAC;IAOD;;mBAEe;IAEf;;OAEG;IACH,iBAAiB;QACf,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QACtD,4BAA4B;QAC5B,OAAO,CACL,EAAC,OAAO,qDAAC,KAAK,EAAC,kBAAkB,EAAC,OAAO,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,QAAQ,CAAC,CAAC,CAAC,SAAS;YACtI,8DAAa;YACZ,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAClC,6DAAM,KAAK,EAAC,4BAA4B;;gBAChC,6DAAM,KAAK,EAAC,kBAAkB,QAAS,CACxC,CACR,CACO,CACX,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Watch } from '@stencil/core';\nimport { isValideID, isValidString, toString } from '@mgdis/stencil-helpers';\n\n/**\n * @internal\n */\n@Component({\n tag: 'mg-input-title',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-title.css',\n scoped: true,\n})\nexport class MgInputTitle {\n /**\n * Label input id\n */\n @Prop() identifier!: string;\n @Watch('identifier')\n validateIdentifier(newValue: MgInputTitle['identifier']): void {\n if (!isValidString(newValue)) {\n throw new Error('<mg-input-title> prop \"identifier\" is required.');\n } else if (!isValideID(newValue)) {\n console.error(`<mg-input-title> prop \"identifier\" value is invalid. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * If input is required an asterisk is added at the end of the label\n */\n @Prop() required?: boolean;\n\n /**\n * If input is required an asterisk is added at the end of the label\n */\n @Prop() readonly?: boolean;\n\n /**\n * Switch from label to fieldset sementic\n */\n @Prop() isLegend = false;\n @Watch('isLegend')\n validateIsLegend(newValue: MgInputTitle['isLegend']) {\n this.tagName = newValue ? 'legend' : 'label';\n }\n\n /**\n * Component parent tagname\n */\n @State() tagName = 'label';\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Init tag name\n */\n componentWillLoad(): void {\n this.validateIdentifier(this.identifier);\n this.validateIsLegend(this.isLegend);\n }\n\n /**\n * Render\n * @returns HTML element\n */\n render(): HTMLElement {\n const TagName = this.readonly ? 'span' : this.tagName;\n // \\u00A0 represent a &nbsp;\n return (\n <TagName class=\"mg-c-input-title\" htmlFor={!this.isLegend && this.identifier} id={this.isLegend ? `${this.identifier}-title` : undefined}>\n <slot></slot>\n {this.required && !this.readonly && (\n <span class=\"mg-c-input-title__required\">\n &nbsp;<span class=\"mg-u-is-asterisk\">*</span>\n </span>\n )}\n </TagName>\n );\n }\n}\n"]}
@@ -8,10 +8,13 @@ export class MgBadge {
8
8
  ************/
9
9
  // Classes
10
10
  this.classOutline = `mg-c-badge--outline`;
11
- this.value = undefined;
12
- this.label = undefined;
13
- this.variant = variants[0];
14
- this.outline = undefined;
11
+ /**
12
+ * Define badge variant
13
+ */
14
+ this.variant = variants[0]; // info
15
+ /**
16
+ * Component classes
17
+ */
15
18
  this.classCollection = new ClassList(['mg-c-badge']);
16
19
  }
17
20
  validateValue(newValue) {
@@ -85,6 +88,8 @@ export class MgBadge {
85
88
  "tags": [],
86
89
  "text": "Badge value"
87
90
  },
91
+ "getter": false,
92
+ "setter": false,
88
93
  "attribute": "value",
89
94
  "reflect": false
90
95
  },
@@ -102,6 +107,8 @@ export class MgBadge {
102
107
  "tags": [],
103
108
  "text": "Badge label. Include short description.\nRequired for accessibility"
104
109
  },
110
+ "getter": false,
111
+ "setter": false,
105
112
  "attribute": "label",
106
113
  "reflect": false
107
114
  },
@@ -125,6 +132,8 @@ export class MgBadge {
125
132
  "tags": [],
126
133
  "text": "Define badge variant"
127
134
  },
135
+ "getter": false,
136
+ "setter": false,
128
137
  "attribute": "variant",
129
138
  "reflect": false,
130
139
  "defaultValue": "variants[0]"
@@ -143,6 +152,8 @@ export class MgBadge {
143
152
  "tags": [],
144
153
  "text": "Define if button is using outline style"
145
154
  },
155
+ "getter": false,
156
+ "setter": false,
146
157
  "attribute": "outline",
147
158
  "reflect": false
148
159
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mg-badge.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-badge/mg-badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAoB,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAO5E,MAAM,OAAO,OAAO;;QAClB;;sBAEc;QAEd,UAAU;QACO,iBAAY,GAAG,qBAAqB,CAAC;;;uBAgCjB,QAAQ,CAAC,CAAC,CAAC;;+BA0BV,IAAI,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC;;IA/CnE,aAAa,CAAC,QAA0B;QACtC,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,mGAAmG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5I,CAAC;IACH,CAAC;IAQD,aAAa,CAAC,QAA0B;QACtC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,2EAA2E,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACpH,CAAC;IACH,CAAC;IAOD,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Watch } from '@stencil/core';\nimport { variants, BadgeVariantType } from './mg-badge.conf';\nimport { ClassList, isValidString, toString } from '@mgdis/stencil-helpers';\n\n@Component({\n tag: 'mg-badge',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-badge.css',\n shadow: true,\n})\nexport class MgBadge {\n /************\n * Internal *\n ************/\n\n // Classes\n private readonly classOutline = `mg-c-badge--outline`;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Badge value\n */\n @Prop() value!: string | number;\n @Watch('value')\n validateValue(newValue: MgBadge['value']): void {\n if (/^[^A-Z]+$/i.exec(`${newValue}`) === null) {\n throw new Error(`<mg-badge> prop \"value\" is required and must be integer and/or special character. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Badge label. Include short description.\n * Required for accessibility\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgBadge['label']): void {\n if (!isValidString(newValue)) {\n throw new Error(`<mg-badge> prop \"label\" is required and must be a string. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define badge variant\n */\n @Prop() variant?: BadgeVariantType = variants[0]; // info\n @Watch('variant')\n validateVariant(newValue: MgBadge['variant'], oldValue?: MgBadge['variant']): void {\n if (!variants.includes(newValue)) {\n throw new Error(`<mg-badge> prop \"variant\" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-badge--${oldValue}`);\n }\n this.classCollection.add(`mg-c-badge--${newValue}`);\n }\n }\n\n /**\n * Define if button is using outline style\n */\n @Prop() outline?: boolean;\n @Watch('outline')\n validateOutline(newValue: MgBadge['outline']): void {\n if (newValue) this.classCollection.add(this.classOutline);\n else this.classCollection.delete(this.classOutline);\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-badge']);\n\n /**\n * Check if props are well configured on init\n */\n componentWillLoad(): void {\n this.validateValue(this.value);\n this.validateLabel(this.label);\n this.validateVariant(this.variant);\n this.validateOutline(this.outline);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <span class={this.classCollection.join()}>\n <span class=\"mg-c-badge__value\">{this.value}</span>\n <span class=\"mg-u-visually-hidden\">{this.label}</span>\n </span>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mg-badge.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-badge/mg-badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAoB,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAO5E,MAAM,OAAO,OAAO;IALpB;QAME;;sBAEc;QAEd,UAAU;QACO,iBAAY,GAAG,qBAAqB,CAAC;QA6BtD;;WAEG;QACK,YAAO,GAAsB,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;QAuBzD;;WAEG;QACM,oBAAe,GAAc,IAAI,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;KAwBrE;IAvEC,aAAa,CAAC,QAA0B;QACtC,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,mGAAmG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5I,CAAC;IACH,CAAC;IAQD,aAAa,CAAC,QAA0B;QACtC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,2EA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AAsB,IAAE,IAAI,CAAC,KAAK,CAAQ,CACjD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Watch } from '@stencil/core';\nimport { variants, BadgeVariantType } from './mg-badge.conf';\nimport { ClassList, isValidString, toString } from '@mgdis/stencil-helpers';\n\n@Component({\n tag: 'mg-badge',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-badge.css',\n shadow: true,\n})\nexport class MgBadge {\n /************\n * Internal *\n ************/\n\n // Classes\n private readonly classOutline = `mg-c-badge--outline`;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Badge value\n */\n @Prop() value!: string | number;\n @Watch('value')\n validateValue(newValue: MgBadge['value']): void {\n if (/^[^A-Z]+$/i.exec(`${newValue}`) === null) {\n throw new Error(`<mg-badge> prop \"value\" is required and must be integer and/or special character. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Badge label. Include short description.\n * Required for accessibility\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgBadge['label']): void {\n if (!isValidString(newValue)) {\n throw new Error(`<mg-badge> prop \"label\" is required and must be a string. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define badge variant\n */\n @Prop() variant?: BadgeVariantType = variants[0]; // info\n @Watch('variant')\n validateVariant(newValue: MgBadge['variant'], oldValue?: MgBadge['variant']): void {\n if (!variants.includes(newValue)) {\n throw new Error(`<mg-badge> prop \"variant\" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-badge--${oldValue}`);\n }\n this.classCollection.add(`mg-c-badge--${newValue}`);\n }\n }\n\n /**\n * Define if button is using outline style\n */\n @Prop() outline?: boolean;\n @Watch('outline')\n validateOutline(newValue: MgBadge['outline']): void {\n if (newValue) this.classCollection.add(this.classOutline);\n else this.classCollection.delete(this.classOutline);\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-badge']);\n\n /**\n * Check if props are well configured on init\n */\n componentWillLoad(): void {\n this.validateValue(this.value);\n this.validateLabel(this.label);\n this.validateVariant(this.variant);\n this.validateOutline(this.outline);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <span class={this.classCollection.join()}>\n <span class=\"mg-c-badge__value\">{this.value}</span>\n <span class=\"mg-u-visually-hidden\">{this.label}</span>\n </span>\n );\n }\n}\n"]}
@@ -13,6 +13,38 @@ export class MgButton {
13
13
  this.classDisabled = 'mg-c-button--disabled';
14
14
  this.classLoading = 'mg-c-button--loading';
15
15
  this.classFullWidth = 'mg-c-button--full-width';
16
+ /**
17
+ * Define button variant
18
+ */
19
+ this.variant = variants[0]; // Primary
20
+ /**
21
+ * Define button size
22
+ */
23
+ this.size = sizes[0]; // medium
24
+ /**
25
+ * Set button to full-width
26
+ */
27
+ this.fullWidth = false;
28
+ /**
29
+ * Define if button is round.
30
+ * Used for icon button.
31
+ */
32
+ this.isIcon = false;
33
+ /**
34
+ * Option to set input disable on click, in order to prevent multi-click.
35
+ * Parent component have to remove the attribute 'disabled' when the process ends.
36
+ */
37
+ this.disableOnClick = false;
38
+ /**
39
+ * Define if button is loading, default to false.
40
+ * Trigger when button is clicked or key-up ['enter', 'space], then value change to true.
41
+ * It's required to reset to false when action/promise in parent is done to stop the loading state
42
+ */
43
+ this.loading = false;
44
+ /**
45
+ * Component classes
46
+ */
47
+ this.classCollection = new ClassList(['mg-c-button']);
16
48
  /**
17
49
  * Trigger actions onClick event
18
50
  * @param event - click event
@@ -61,17 +93,6 @@ export class MgButton {
61
93
  (_b = this.element.querySelector('mg-icon')) === null || _b === void 0 ? void 0 : _b.setAttribute('size', this.size);
62
94
  }
63
95
  };
64
- this.variant = variants[0];
65
- this.label = undefined;
66
- this.type = undefined;
67
- this.size = sizes[0];
68
- this.fullWidth = false;
69
- this.form = undefined;
70
- this.disabled = undefined;
71
- this.isIcon = false;
72
- this.disableOnClick = false;
73
- this.loading = false;
74
- this.classCollection = new ClassList(['mg-c-button']);
75
96
  }
76
97
  validateVariant(newValue, oldValue) {
77
98
  // validate new value
@@ -219,6 +240,8 @@ export class MgButton {
219
240
  "tags": [],
220
241
  "text": "Define button variant"
221
242
  },
243
+ "getter": false,
244
+ "setter": false,
222
245
  "attribute": "variant",
223
246
  "reflect": false,
224
247
  "defaultValue": "variants[0]"
@@ -237,6 +260,8 @@ export class MgButton {
237
260
  "tags": [],
238
261
  "text": "aria-label\nIn case button text is not explicit enough"
239
262
  },
263
+ "getter": false,
264
+ "setter": false,
240
265
  "attribute": "label",
241
266
  "reflect": false
242
267
  },
@@ -260,6 +285,8 @@ export class MgButton {
260
285
  "tags": [],
261
286
  "text": "Define button type"
262
287
  },
288
+ "getter": false,
289
+ "setter": false,
263
290
  "attribute": "type",
264
291
  "reflect": false
265
292
  },
@@ -283,6 +310,8 @@ export class MgButton {
283
310
  "tags": [],
284
311
  "text": "Define button size"
285
312
  },
313
+ "getter": false,
314
+ "setter": false,
286
315
  "attribute": "size",
287
316
  "reflect": false,
288
317
  "defaultValue": "sizes[0]"
@@ -301,6 +330,8 @@ export class MgButton {
301
330
  "tags": [],
302
331
  "text": "Set button to full-width"
303
332
  },
333
+ "getter": false,
334
+ "setter": false,
304
335
  "attribute": "full-width",
305
336
  "reflect": false,
306
337
  "defaultValue": "false"
@@ -319,6 +350,8 @@ export class MgButton {
319
350
  "tags": [],
320
351
  "text": "Define form id to attach button with.\nIf this attribute is not set, the `<button>` is associated with its ancestor `<form>` element."
321
352
  },
353
+ "getter": false,
354
+ "setter": false,
322
355
  "attribute": "form",
323
356
  "reflect": false
324
357
  },
@@ -336,6 +369,8 @@ export class MgButton {
336
369
  "tags": [],
337
370
  "text": "Disable button"
338
371
  },
372
+ "getter": false,
373
+ "setter": false,
339
374
  "attribute": "disabled",
340
375
  "reflect": false
341
376
  },
@@ -353,6 +388,8 @@ export class MgButton {
353
388
  "tags": [],
354
389
  "text": "Define if button is round.\nUsed for icon button."
355
390
  },
391
+ "getter": false,
392
+ "setter": false,
356
393
  "attribute": "is-icon",
357
394
  "reflect": false,
358
395
  "defaultValue": "false"
@@ -371,6 +408,8 @@ export class MgButton {
371
408
  "tags": [],
372
409
  "text": "Option to set input disable on click, in order to prevent multi-click.\nParent component have to remove the attribute 'disabled' when the process ends."
373
410
  },
411
+ "getter": false,
412
+ "setter": false,
374
413
  "attribute": "disable-on-click",
375
414
  "reflect": false,
376
415
  "defaultValue": "false"
@@ -1 +1 @@
1
- {"version":3,"file":"mg-button.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-button/mg-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAqC,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEtF;;GAEG;AAMH,MAAM,OAAO,QAAQ;;QACnB;;sBAEc;QAEN,qBAAgB,GAAG,IAAI,CAAC;QACf,kBAAa,GAAG,uBAAuB,CAAC;QACxC,iBAAY,GAAG,sBAAsB,CAAC;QACtC,mBAAc,GAAG,yBAAyB,CAAC;QAqJ5D;;;WAGG;QACK,gBAAW,GAAG,CAAC,KAAiB,EAAQ,EAAE;YAChD,IAAI,IAAI,CAAC,QAAQ;gBAAE,KAAK,CAAC,eAAe,EAAE,CAAC;YAC3C,+BAA+B;iBAC1B,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;gBAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Prop, State, Watch, Host, EventEmitter, Event } from '@stencil/core';\nimport { variants, VariantType, ButtonType, SizeType, sizes } from './mg-button.conf';\nimport { ClassList, isValidString, nextTick, toString } from '@mgdis/stencil-helpers';\n\n/**\n * @slot - Button content\n */\n@Component({\n tag: 'mg-button',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-button.css',\n shadow: true,\n})\nexport class MgButton {\n /************\n * Internal *\n ************/\n\n private onClickElementFn = null;\n private readonly classDisabled = 'mg-c-button--disabled';\n private readonly classLoading = 'mg-c-button--loading';\n private readonly classFullWidth = 'mg-c-button--full-width';\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgButtonElement;\n\n /**\n * Define button variant\n */\n @Prop({ mutable: true }) variant: VariantType = variants[0]; // Primary\n @Watch('variant')\n validateVariant(newValue: VariantType, oldValue?: VariantType): void {\n // validate new value\n if (!variants.includes(newValue)) {\n if ((newValue as string) === '') {\n // Reactive framework like VUE render with `\"\"` when prop is update to undefined\n this.variant = variants[0];\n return;\n }\n throw new Error(`<mg-button> prop \"variant\" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-button--${oldValue}`);\n }\n this.classCollection.add(`mg-c-button--${newValue}`);\n }\n }\n\n /**\n * aria-label\n * In case button text is not explicit enough\n */\n @Prop() label?: string;\n\n /**\n * Define button type\n */\n @Prop() type?: ButtonType;\n\n /**\n * Define button size\n */\n @Prop() size: SizeType = sizes[0]; // medium\n @Watch('size')\n validateSize(newValue: MgButton['size'], oldValue?: MgButton['size']): void {\n // validate new value\n if (!sizes.includes(newValue)) {\n throw new Error(`<mg-button> prop \"size\" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-button--${oldValue}`);\n }\n this.classCollection.add(`mg-c-button--${newValue}`);\n this.setIconSize();\n }\n }\n\n /**\n * Set button to full-width\n */\n @Prop() fullWidth = false;\n @Watch('fullWidth')\n validateFullWidth(newValue: MgButton['fullWidth']): void {\n if (newValue && this.isIcon) {\n throw new Error('<mg-button> prop \"fullWidth\" cannot be used with prop \"isIcon\".');\n } else if (newValue) {\n this.classCollection.add(this.classFullWidth);\n } else {\n this.classCollection.delete(this.classFullWidth);\n }\n }\n\n /**\n * Define form id to attach button with.\n * If this attribute is not set, the `<button>` is associated with its ancestor `<form>` element.\n */\n @Prop() form?: string;\n\n /**\n * Disable button\n */\n @Prop({ mutable: true }) disabled?: boolean;\n @Watch('disabled')\n disabledHandler(isDisabled: MgButton['disabled']): void {\n // Remove loading when enable\n // Will be set back onclick\n if (!isDisabled && this.disableOnClick) {\n this.loading = false;\n }\n // Manage if onclick\n this.element.onclick = isDisabled ? undefined : this.onClickElementFn;\n\n // apply style\n if (isDisabled) {\n this.classCollection.add(this.classDisabled);\n } else {\n this.classCollection.delete(this.classDisabled);\n }\n\n // emit value update\n this.disabledChange.emit(isDisabled);\n }\n /**\n * Define if button is round.\n * Used for icon button.\n */\n @Prop() isIcon = false;\n @Watch('isIcon')\n watchIsIcon(): void {\n this.setIconSize();\n }\n\n /**\n * Option to set input disable on click, in order to prevent multi-click.\n * Parent component have to remove the attribute 'disabled' when the process ends.\n */\n @Prop() disableOnClick = false;\n\n /**\n * Define if button is loading, default to false.\n * Trigger when button is clicked or key-up ['enter', 'space], then value change to true.\n * It's required to reset to false when action/promise in parent is done to stop the loading state\n */\n @State() loading = false;\n @Watch('loading')\n loadingHandler(newValue: MgButton['loading']): void {\n // we add loading style if it newvalue is true else we remove it\n if (newValue) {\n this.classCollection.add(this.classLoading);\n } else {\n this.classCollection.delete(this.classLoading);\n }\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-button']);\n\n /**\n * Emmited event when disabled change\n */\n @Event({ eventName: 'disabled-change' }) disabledChange: EventEmitter<HTMLMgButtonElement['disabled']>;\n\n /**\n * Trigger actions onClick event\n * @param event - click event\n */\n private handleClick = (event: MouseEvent): void => {\n if (this.disabled) event.stopPropagation();\n // Used to prevent multi-click.\n else if (this.disableOnClick) {\n this.loading = true;\n this.disabled = true;\n }\n };\n\n /**\n * Handle onKeydown event\n * @param event - keyboard event\n */\n private handleKeydown = (event: KeyboardEvent): void => {\n if (!this.disabled && event.key === ' ') {\n event.preventDefault();\n } else if (!this.disabled && ['Enter', 'NumpadEnter', 'Space'].includes(event.key)) {\n event.preventDefault();\n this.element.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n }\n };\n\n /**\n * Handle onKeyup event\n * @param event - keyboard event\n */\n private handleKeyup = (event: KeyboardEvent): void => {\n if (!this.disabled && event.key === ' ') {\n event.preventDefault();\n this.element.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n }\n };\n\n /**\n * Set child `<mg-icon>` element `size` prop to follow the current `size` prop\n */\n private setIconSize = (): void => {\n if (this.size === 'medium') {\n this.element.querySelector('mg-icon')?.removeAttribute('size');\n } else if (this.isIcon) {\n this.element.querySelector('mg-icon')?.setAttribute('size', this.size);\n }\n };\n\n /**\n * Check if props are well configured on init\n */\n componentWillLoad(): void {\n this.validateVariant(this.variant);\n this.validateFullWidth(this.fullWidth);\n this.validateSize(this.size);\n this.watchIsIcon();\n if (this.isIcon) {\n this.classCollection.add(`mg-c-button--icon`);\n if (!isValidString(this.label)) {\n throw new Error(`<mg-button> prop \"label\" is mandatory when prop \"isIcon\" is set to true.`);\n }\n }\n // Store the onclick fn\n this.onClickElementFn = this.element.onclick;\n this.disabledHandler(this.disabled);\n }\n\n /**\n * Add listners\n */\n componentDidLoad(): void {\n nextTick(() => {\n const closestForm = this.element.closest('form') || this.element.closest('mg-form')?.shadowRoot.querySelector('form');\n // submit buttons should trigger form submition;\n if (closestForm && ['submit', undefined].includes(this.type)) {\n this.element.addEventListener('click', () => {\n closestForm.dispatchEvent(new SubmitEvent('submit', { bubbles: true, cancelable: true }));\n });\n }\n });\n }\n\n /**\n * Render component\n * @returns html element\n */\n render(): HTMLElement {\n return (\n <Host\n role=\"button\"\n tabIndex={0}\n type={this.type}\n form={this.form}\n full-width={this.fullWidth}\n aria-label={this.label}\n aria-disabled={this.disabled?.toString()}\n onClick={this.handleClick}\n onKeyup={this.handleKeyup}\n onKeydown={this.handleKeydown}\n >\n <div class={this.classCollection.join()}>\n {this.loading && <mg-icon icon=\"loader\" spin></mg-icon>}\n <div class=\"mg-c-button__content\">\n <slot></slot>\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mg-button.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-button/mg-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAqC,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEtF;;GAEG;AAMH,MAAM,OAAO,QAAQ;IALrB;QAME;;sBAEc;QAEN,qBAAgB,GAAG,IAAI,CAAC;QACf,kBAAa,GAAG,uBAAuB,CAAC;QACxC,iBAAY,GAAG,sBAAsB,CAAC;QACtC,mBAAc,GAAG,yBAAyB,CAAC;QAW5D;;WAEG;QACsB,YAAO,GAAgB,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU;QA8BvE;;WAEG;QACK,SAAI,GAAa,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QAe5C;;WAEG;QACK,cAAS,GAAG,KAAK,CAAC;QA0C1B;;;WAGG;QACK,WAAM,GAAG,KAAK,CAAC;QAMvB;;;WAGG;QACK,mBAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Prop, State, Watch, Host, EventEmitter, Event } from '@stencil/core';\nimport { variants, VariantType, ButtonType, SizeType, sizes } from './mg-button.conf';\nimport { ClassList, isValidString, nextTick, toString } from '@mgdis/stencil-helpers';\n\n/**\n * @slot - Button content\n */\n@Component({\n tag: 'mg-button',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-button.css',\n shadow: true,\n})\nexport class MgButton {\n /************\n * Internal *\n ************/\n\n private onClickElementFn = null;\n private readonly classDisabled = 'mg-c-button--disabled';\n private readonly classLoading = 'mg-c-button--loading';\n private readonly classFullWidth = 'mg-c-button--full-width';\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgButtonElement;\n\n /**\n * Define button variant\n */\n @Prop({ mutable: true }) variant: VariantType = variants[0]; // Primary\n @Watch('variant')\n validateVariant(newValue: VariantType, oldValue?: VariantType): void {\n // validate new value\n if (!variants.includes(newValue)) {\n if ((newValue as string) === '') {\n // Reactive framework like VUE render with `\"\"` when prop is update to undefined\n this.variant = variants[0];\n return;\n }\n throw new Error(`<mg-button> prop \"variant\" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-button--${oldValue}`);\n }\n this.classCollection.add(`mg-c-button--${newValue}`);\n }\n }\n\n /**\n * aria-label\n * In case button text is not explicit enough\n */\n @Prop() label?: string;\n\n /**\n * Define button type\n */\n @Prop() type?: ButtonType;\n\n /**\n * Define button size\n */\n @Prop() size: SizeType = sizes[0]; // medium\n @Watch('size')\n validateSize(newValue: MgButton['size'], oldValue?: MgButton['size']): void {\n // validate new value\n if (!sizes.includes(newValue)) {\n throw new Error(`<mg-button> prop \"size\" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-button--${oldValue}`);\n }\n this.classCollection.add(`mg-c-button--${newValue}`);\n this.setIconSize();\n }\n }\n\n /**\n * Set button to full-width\n */\n @Prop() fullWidth = false;\n @Watch('fullWidth')\n validateFullWidth(newValue: MgButton['fullWidth']): void {\n if (newValue && this.isIcon) {\n throw new Error('<mg-button> prop \"fullWidth\" cannot be used with prop \"isIcon\".');\n } else if (newValue) {\n this.classCollection.add(this.classFullWidth);\n } else {\n this.classCollection.delete(this.classFullWidth);\n }\n }\n\n /**\n * Define form id to attach button with.\n * If this attribute is not set, the `<button>` is associated with its ancestor `<form>` element.\n */\n @Prop() form?: string;\n\n /**\n * Disable button\n */\n @Prop({ mutable: true }) disabled?: boolean;\n @Watch('disabled')\n disabledHandler(isDisabled: MgButton['disabled']): void {\n // Remove loading when enable\n // Will be set back onclick\n if (!isDisabled && this.disableOnClick) {\n this.loading = false;\n }\n // Manage if onclick\n this.element.onclick = isDisabled ? undefined : this.onClickElementFn;\n\n // apply style\n if (isDisabled) {\n this.classCollection.add(this.classDisabled);\n } else {\n this.classCollection.delete(this.classDisabled);\n }\n\n // emit value update\n this.disabledChange.emit(isDisabled);\n }\n /**\n * Define if button is round.\n * Used for icon button.\n */\n @Prop() isIcon = false;\n @Watch('isIcon')\n watchIsIcon(): void {\n this.setIconSize();\n }\n\n /**\n * Option to set input disable on click, in order to prevent multi-click.\n * Parent component have to remove the attribute 'disabled' when the process ends.\n */\n @Prop() disableOnClick = false;\n\n /**\n * Define if button is loading, default to false.\n * Trigger when button is clicked or key-up ['enter', 'space], then value change to true.\n * It's required to reset to false when action/promise in parent is done to stop the loading state\n */\n @State() loading = false;\n @Watch('loading')\n loadingHandler(newValue: MgButton['loading']): void {\n // we add loading style if it newvalue is true else we remove it\n if (newValue) {\n this.classCollection.add(this.classLoading);\n } else {\n this.classCollection.delete(this.classLoading);\n }\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-button']);\n\n /**\n * Emmited event when disabled change\n */\n @Event({ eventName: 'disabled-change' }) disabledChange: EventEmitter<HTMLMgButtonElement['disabled']>;\n\n /**\n * Trigger actions onClick event\n * @param event - click event\n */\n private handleClick = (event: MouseEvent): void => {\n if (this.disabled) event.stopPropagation();\n // Used to prevent multi-click.\n else if (this.disableOnClick) {\n this.loading = true;\n this.disabled = true;\n }\n };\n\n /**\n * Handle onKeydown event\n * @param event - keyboard event\n */\n private handleKeydown = (event: KeyboardEvent): void => {\n if (!this.disabled && event.key === ' ') {\n event.preventDefault();\n } else if (!this.disabled && ['Enter', 'NumpadEnter', 'Space'].includes(event.key)) {\n event.preventDefault();\n this.element.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n }\n };\n\n /**\n * Handle onKeyup event\n * @param event - keyboard event\n */\n private handleKeyup = (event: KeyboardEvent): void => {\n if (!this.disabled && event.key === ' ') {\n event.preventDefault();\n this.element.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n }\n };\n\n /**\n * Set child `<mg-icon>` element `size` prop to follow the current `size` prop\n */\n private setIconSize = (): void => {\n if (this.size === 'medium') {\n this.element.querySelector('mg-icon')?.removeAttribute('size');\n } else if (this.isIcon) {\n this.element.querySelector('mg-icon')?.setAttribute('size', this.size);\n }\n };\n\n /**\n * Check if props are well configured on init\n */\n componentWillLoad(): void {\n this.validateVariant(this.variant);\n this.validateFullWidth(this.fullWidth);\n this.validateSize(this.size);\n this.watchIsIcon();\n if (this.isIcon) {\n this.classCollection.add(`mg-c-button--icon`);\n if (!isValidString(this.label)) {\n throw new Error(`<mg-button> prop \"label\" is mandatory when prop \"isIcon\" is set to true.`);\n }\n }\n // Store the onclick fn\n this.onClickElementFn = this.element.onclick;\n this.disabledHandler(this.disabled);\n }\n\n /**\n * Add listners\n */\n componentDidLoad(): void {\n nextTick(() => {\n const closestForm = this.element.closest('form') || this.element.closest('mg-form')?.shadowRoot.querySelector('form');\n // submit buttons should trigger form submition;\n if (closestForm && ['submit', undefined].includes(this.type)) {\n this.element.addEventListener('click', () => {\n closestForm.dispatchEvent(new SubmitEvent('submit', { bubbles: true, cancelable: true }));\n });\n }\n });\n }\n\n /**\n * Render component\n * @returns html element\n */\n render(): HTMLElement {\n return (\n <Host\n role=\"button\"\n tabIndex={0}\n type={this.type}\n form={this.form}\n full-width={this.fullWidth}\n aria-label={this.label}\n aria-disabled={this.disabled?.toString()}\n onClick={this.handleClick}\n onKeyup={this.handleKeyup}\n onKeydown={this.handleKeydown}\n >\n <div class={this.classCollection.join()}>\n {this.loading && <mg-icon icon=\"loader\" spin></mg-icon>}\n <div class=\"mg-c-button__content\">\n <slot></slot>\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -11,7 +11,7 @@ export class MgCard {
11
11
  * @returns HTML Element
12
12
  */
13
13
  render() {
14
- return (h("div", { key: 'b8de627bd3018342b2e33f62e1779de8c53fa61e', class: "mg-c-card" }, h("slot", { key: '210e9b12485a345ab50d4ddb85d091cde58551a8' })));
14
+ return (h("div", { key: 'e59cabb09dbc28c148770b57de98f130c4479b75', class: "mg-c-card" }, h("slot", { key: 'b6e679317bddd23e73443c601992b7b344d6dc72' })));
15
15
  }
16
16
  static get is() { return "mg-card"; }
17
17
  static get encapsulation() { return "shadow"; }
@@ -1,6 +1,12 @@
1
1
  import { h } from "@stencil/core";
2
2
  export class MgDivider {
3
3
  constructor() {
4
+ /**************
5
+ * Decorators *
6
+ **************/
7
+ /**
8
+ * Define component size
9
+ */
4
10
  this.fullWidth = false;
5
11
  }
6
12
  /**
@@ -8,7 +14,7 @@ export class MgDivider {
8
14
  * @returns HTML Element
9
15
  */
10
16
  render() {
11
- return (h("div", { key: 'b7d74c11f15700cbffa553bf4d688ad291473087', class: {
17
+ return (h("div", { key: '60b987cb329c6db14c2cc4a665e7f32b2696a3ee', class: {
12
18
  'mg-c-divider': true,
13
19
  'mg-c-divider--full-width': this.fullWidth,
14
20
  } }));
@@ -41,6 +47,8 @@ export class MgDivider {
41
47
  "tags": [],
42
48
  "text": "Define component size"
43
49
  },
50
+ "getter": false,
51
+ "setter": false,
44
52
  "attribute": "full-width",
45
53
  "reflect": false,
46
54
  "defaultValue": "false"
@@ -1 +1 @@
1
- {"version":3,"file":"mg-divider.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-divider/mg-divider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAOnD,MAAM,OAAO,SAAS;;yBAQA,KAAK;;IAEzB;;;OAGG;IACH,MAAM;QACJ,OAAO,CACL,4DACE,KAAK,EAAE;gBACL,cAAc,EAAE,IAAI;gBACpB,0BAA0B,EAAE,IAAI,CAAC,SAAS;aAC3C,GACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop } from '@stencil/core';\n\n@Component({\n tag: 'mg-divider',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-divider.css',\n shadow: true,\n})\nexport class MgDivider {\n /**************\n * Decorators *\n **************/\n\n /**\n * Define component size\n */\n @Prop() fullWidth = false;\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <div\n class={{\n 'mg-c-divider': true,\n 'mg-c-divider--full-width': this.fullWidth,\n }}\n ></div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mg-divider.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-divider/mg-divider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAOnD,MAAM,OAAO,SAAS;IALtB;QAME;;wBAEgB;QAEhB;;WAEG;QACK,cAAS,GAAG,KAAK,CAAC;KAgB3B;IAdC;;;OAGG;IACH,MAAM;QACJ,OAAO,CACL,4DACE,KAAK,EAAE;gBACL,cAAc,EAAE,IAAI;gBACpB,0BAA0B,EAAE,IAAI,CAAC,SAAS;aAC3C,GACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop } from '@stencil/core';\n\n@Component({\n tag: 'mg-divider',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-divider.css',\n shadow: true,\n})\nexport class MgDivider {\n /**************\n * Decorators *\n **************/\n\n /**\n * Define component size\n */\n @Prop() fullWidth = false;\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <div\n class={{\n 'mg-c-divider': true,\n 'mg-c-divider--full-width': this.fullWidth,\n }}\n ></div>\n );\n }\n}\n"]}
@@ -3,6 +3,18 @@ import { ClassList, toString } from "@mgdis/stencil-helpers";
3
3
  import { icons } from "../../../assets/icons";
4
4
  export class MgIcon {
5
5
  constructor() {
6
+ /**
7
+ * Define icon size
8
+ */
9
+ this.size = 'medium';
10
+ /**
11
+ * Make the icon spin
12
+ */
13
+ this.spin = false;
14
+ /**
15
+ * Component classes
16
+ */
17
+ this.classCollection = new ClassList(['mg-c-icon']);
6
18
  /**
7
19
  * Method to set default varianStyle props
8
20
  * needeed has stencil doesn't know that props is mutated when updated in prop watcher
@@ -23,12 +35,6 @@ export class MgIcon {
23
35
  this.svg.setAttribute('focusable', 'false');
24
36
  this.svg.setAttribute('class', this.classCollection.join());
25
37
  };
26
- this.icon = undefined;
27
- this.size = 'medium';
28
- this.variant = undefined;
29
- this.variantStyle = undefined;
30
- this.spin = false;
31
- this.classCollection = new ClassList(['mg-c-icon']);
32
38
  }
33
39
  validateIcon(newValue, oldValue) {
34
40
  if (!Object.keys(icons).includes(newValue))
@@ -132,6 +138,8 @@ export class MgIcon {
132
138
  "tags": [],
133
139
  "text": "Icon to display."
134
140
  },
141
+ "getter": false,
142
+ "setter": false,
135
143
  "attribute": "icon",
136
144
  "reflect": false
137
145
  },
@@ -155,6 +163,8 @@ export class MgIcon {
155
163
  "tags": [],
156
164
  "text": "Define icon size"
157
165
  },
166
+ "getter": false,
167
+ "setter": false,
158
168
  "attribute": "size",
159
169
  "reflect": false,
160
170
  "defaultValue": "'medium'"
@@ -179,6 +189,8 @@ export class MgIcon {
179
189
  "tags": [],
180
190
  "text": "Define icon variant color"
181
191
  },
192
+ "getter": false,
193
+ "setter": false,
182
194
  "attribute": "variant",
183
195
  "reflect": false
184
196
  },
@@ -202,6 +214,8 @@ export class MgIcon {
202
214
  "tags": [],
203
215
  "text": "Define icon color variant style\nAdd a color to the icon based on variant color with given style\n'full': Used to set a circular background with variant soft color and icon variant color\n'background': Used to set a circular background with variant soft color\n'icon': Used to set a color only to the icon"
204
216
  },
217
+ "getter": false,
218
+ "setter": false,
205
219
  "attribute": "variant-style",
206
220
  "reflect": false
207
221
  },
@@ -219,6 +233,8 @@ export class MgIcon {
219
233
  "tags": [],
220
234
  "text": "Make the icon spin"
221
235
  },
236
+ "getter": false,
237
+ "setter": false,
222
238
  "attribute": "spin",
223
239
  "reflect": false,
224
240
  "defaultValue": "false"
@@ -1 +1 @@
1
- {"version":3,"file":"mg-icon.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-icon/mg-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAiB,KAAK,EAAqB,QAAQ,EAAwB,aAAa,EAA6B,MAAM,gBAAgB,CAAC;AACnJ,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAO9C,MAAM,OAAO,MAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, Watch, State, Element } from '@stencil/core';\nimport { type IconType, sizes, type IconSizeType, variants, type IconVariantType, variantStyles, type IconVariantStyleType } from './mg-icon.conf';\nimport { ClassList, toString } from '@mgdis/stencil-helpers';\nimport { icons } from '../../../assets/icons';\n\n@Component({\n tag: 'mg-icon',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-icon.css',\n shadow: true,\n})\nexport class MgIcon {\n private svg: SVGSVGElement;\n\n /**\n * Icon HTML Element\n */\n @Element() element: HTMLMgIconElement;\n\n /**\n * Icon to display.\n */\n @Prop() icon!: IconType;\n @Watch('icon')\n validateIcon(newValue: MgIcon['icon'], oldValue?: MgIcon['icon']): void {\n if (!Object.keys(icons).includes(newValue)) throw new Error(`<mg-icon> prop \"icon\" must be one of: ${Object.keys(icons).join(', ')}. Passed value: ${toString(newValue)}.`);\n else {\n if (oldValue !== undefined) this.classCollection.delete(`mg-c-icon--${oldValue}`);\n this.classCollection.add(`mg-c-icon--${newValue}`);\n this.renderIcon(newValue);\n }\n }\n\n /**\n * Define icon size\n */\n @Prop() size: IconSizeType = 'medium';\n @Watch('size')\n validateSize(newValue: MgIcon['size'], oldValue?: MgIcon['size']): void {\n if (!sizes.includes(newValue)) throw new Error(`<mg-icon> prop \"size\" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);\n else {\n if (oldValue !== undefined) this.classCollection.delete(`mg-c-icon--size-${oldValue}`);\n this.classCollection.add(`mg-c-icon--size-${newValue}`);\n }\n }\n\n /**\n * Define icon variant color\n */\n @Prop() variant?: IconVariantType;\n @Watch('variant')\n validateVariant(newValue: MgIcon['variant'], oldValue?: MgIcon['variant']): void {\n if (newValue !== undefined) {\n if (!variants.includes(newValue)) throw new Error(`<mg-icon> prop \"variant\" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);\n else {\n this.setDefaultVariantStyle();\n if (oldValue !== undefined) this.classCollection.delete(`mg-c-icon--variant-${oldValue}`);\n this.classCollection.add(`mg-c-icon--variant-${newValue}`);\n }\n }\n }\n\n /**\n * Define icon color variant style\n * Add a color to the icon based on variant color with given style\n * 'full': Used to set a circular background with variant soft color and icon variant color\n * 'background': Used to set a circular background with variant soft color\n * 'icon': Used to set a color only to the icon\n */\n @Prop({ mutable: true }) variantStyle: IconVariantStyleType;\n @Watch('variantStyle')\n validateVariantStyle(newValue: MgIcon['variantStyle'], oldValue?: MgIcon['variantStyle']): void {\n if (newValue !== undefined) {\n if (!variantStyles.includes(newValue)) throw new Error(`<mg-icon> prop \"variantStyle\" must be one of: ${variantStyles.join(', ')}. Passed value: ${toString(newValue)}.`);\n else {\n if (oldValue !== undefined) this.classCollection.delete(`mg-c-icon--variant-style-${oldValue}`);\n this.classCollection.add(`mg-c-icon--variant-style-${newValue}`);\n }\n }\n }\n\n /**\n * Make the icon spin\n */\n @Prop() spin = false;\n @Watch('spin')\n handleSpin(newValue: MgIcon['spin']): void {\n if (newValue) {\n this.classCollection.add('mg-c-icon--spin');\n } else {\n this.classCollection.delete('mg-c-icon--spin');\n }\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-icon']);\n\n /**\n * Method to set default varianStyle props\n * needeed has stencil doesn't know that props is mutated when updated in prop watcher\n */\n private setDefaultVariantStyle = (): void => {\n if (this.variantStyle === undefined) this.variantStyle = 'background';\n };\n\n /**\n * Render icon in shadowroot\n * @param icon - icon to render\n */\n private renderIcon = (icon: IconType): void => {\n this.element.shadowRoot.innerHTML = icons[icon];\n this.svg = this.element.shadowRoot.querySelector('svg');\n // update svg attributes\n this.svg.setAttribute('aria-hidden', 'true');\n this.svg.setAttribute('focusable', 'false');\n this.svg.setAttribute('class', this.classCollection.join());\n };\n\n /**\n * Check if props are well configured on init\n */\n componentWillLoad(): void {\n this.validateIcon(this.icon);\n this.validateSize(this.size);\n this.validateVariant(this.variant);\n this.validateVariantStyle(this.variantStyle);\n this.handleSpin(this.spin);\n // render icon\n this.renderIcon(this.icon);\n }\n\n /**\n * update html when component trigger changes\n */\n componentWillUpdate() {\n this.svg.setAttribute('class', this.classCollection.join());\n }\n}\n"]}
1
+ {"version":3,"file":"mg-icon.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-icon/mg-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAiB,KAAK,EAAqB,QAAQ,EAAwB,aAAa,EAA6B,MAAM,gBAAgB,CAAC;AACnJ,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAO9C,MAAM,OAAO,MAAM;IALnB;QA2BE;;WAEG;QACK,SAAI,GAAiB,QAAQ,CAAC;QA6CtC;;WAEG;QACK,SAAI,GAAG,KAAK,CAAC;QAUrB;;WAEG;QACM,oBAAe,GAAc,IAAI,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QAEnE;;;WAGG;QACK,2BAAsB,GAAG,GAAS,EAAE;YAC1C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS;gBAAE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACxE,CAAC,CAAC;QAEF;;;WAGG;QACK,eAAU,GAAG,CAAC,IAAc,EAAQ,EAAE;YAC5C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;YAChD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACxD,wBAAwB;YACxB,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;YAC7C,I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CAAC;IA4BD;;OAEG;IACH,iBAAiB;QACf,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,cAAc;QACd,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, Watch, State, Element } from '@stencil/core';\nimport { type IconType, sizes, type IconSizeType, variants, type IconVariantType, variantStyles, type IconVariantStyleType } from './mg-icon.conf';\nimport { ClassList, toString } from '@mgdis/stencil-helpers';\nimport { icons } from '../../../assets/icons';\n\n@Component({\n tag: 'mg-icon',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-icon.css',\n shadow: true,\n})\nexport class MgIcon {\n private svg: SVGSVGElement;\n\n /**\n * Icon HTML Element\n */\n @Element() element: HTMLMgIconElement;\n\n /**\n * Icon to display.\n */\n @Prop() icon!: IconType;\n @Watch('icon')\n validateIcon(newValue: MgIcon['icon'], oldValue?: MgIcon['icon']): void {\n if (!Object.keys(icons).includes(newValue)) throw new Error(`<mg-icon> prop \"icon\" must be one of: ${Object.keys(icons).join(', ')}. Passed value: ${toString(newValue)}.`);\n else {\n if (oldValue !== undefined) this.classCollection.delete(`mg-c-icon--${oldValue}`);\n this.classCollection.add(`mg-c-icon--${newValue}`);\n this.renderIcon(newValue);\n }\n }\n\n /**\n * Define icon size\n */\n @Prop() size: IconSizeType = 'medium';\n @Watch('size')\n validateSize(newValue: MgIcon['size'], oldValue?: MgIcon['size']): void {\n if (!sizes.includes(newValue)) throw new Error(`<mg-icon> prop \"size\" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);\n else {\n if (oldValue !== undefined) this.classCollection.delete(`mg-c-icon--size-${oldValue}`);\n this.classCollection.add(`mg-c-icon--size-${newValue}`);\n }\n }\n\n /**\n * Define icon variant color\n */\n @Prop() variant?: IconVariantType;\n @Watch('variant')\n validateVariant(newValue: MgIcon['variant'], oldValue?: MgIcon['variant']): void {\n if (newValue !== undefined) {\n if (!variants.includes(newValue)) throw new Error(`<mg-icon> prop \"variant\" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);\n else {\n this.setDefaultVariantStyle();\n if (oldValue !== undefined) this.classCollection.delete(`mg-c-icon--variant-${oldValue}`);\n this.classCollection.add(`mg-c-icon--variant-${newValue}`);\n }\n }\n }\n\n /**\n * Define icon color variant style\n * Add a color to the icon based on variant color with given style\n * 'full': Used to set a circular background with variant soft color and icon variant color\n * 'background': Used to set a circular background with variant soft color\n * 'icon': Used to set a color only to the icon\n */\n @Prop({ mutable: true }) variantStyle: IconVariantStyleType;\n @Watch('variantStyle')\n validateVariantStyle(newValue: MgIcon['variantStyle'], oldValue?: MgIcon['variantStyle']): void {\n if (newValue !== undefined) {\n if (!variantStyles.includes(newValue)) throw new Error(`<mg-icon> prop \"variantStyle\" must be one of: ${variantStyles.join(', ')}. Passed value: ${toString(newValue)}.`);\n else {\n if (oldValue !== undefined) this.classCollection.delete(`mg-c-icon--variant-style-${oldValue}`);\n this.classCollection.add(`mg-c-icon--variant-style-${newValue}`);\n }\n }\n }\n\n /**\n * Make the icon spin\n */\n @Prop() spin = false;\n @Watch('spin')\n handleSpin(newValue: MgIcon['spin']): void {\n if (newValue) {\n this.classCollection.add('mg-c-icon--spin');\n } else {\n this.classCollection.delete('mg-c-icon--spin');\n }\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-icon']);\n\n /**\n * Method to set default varianStyle props\n * needeed has stencil doesn't know that props is mutated when updated in prop watcher\n */\n private setDefaultVariantStyle = (): void => {\n if (this.variantStyle === undefined) this.variantStyle = 'background';\n };\n\n /**\n * Render icon in shadowroot\n * @param icon - icon to render\n */\n private renderIcon = (icon: IconType): void => {\n this.element.shadowRoot.innerHTML = icons[icon];\n this.svg = this.element.shadowRoot.querySelector('svg');\n // update svg attributes\n this.svg.setAttribute('aria-hidden', 'true');\n this.svg.setAttribute('focusable', 'false');\n this.svg.setAttribute('class', this.classCollection.join());\n };\n\n /**\n * Check if props are well configured on init\n */\n componentWillLoad(): void {\n this.validateIcon(this.icon);\n this.validateSize(this.size);\n this.validateVariant(this.variant);\n this.validateVariantStyle(this.variantStyle);\n this.handleSpin(this.spin);\n // render icon\n this.renderIcon(this.icon);\n }\n\n /**\n * update html when component trigger changes\n */\n componentWillUpdate() {\n this.svg.setAttribute('class', this.classCollection.join());\n }\n}\n"]}
@@ -12,9 +12,13 @@ export class MgTag {
12
12
  // Classes
13
13
  this.classOutline = 'mg-c-tag--outline';
14
14
  this.classSoft = 'mg-c-tag--soft';
15
- this.variant = variants[0];
16
- this.outline = undefined;
17
- this.soft = undefined;
15
+ /**
16
+ * Define tag variant
17
+ */
18
+ this.variant = variants[0]; // primary
19
+ /**
20
+ * Component classes
21
+ */
18
22
  this.classCollection = new ClassList(['mg-c-tag']);
19
23
  }
20
24
  validateVariant(newValue, oldValue) {
@@ -72,7 +76,7 @@ export class MgTag {
72
76
  * @returns HTML Element
73
77
  */
74
78
  render() {
75
- return (h("span", { key: 'bb99306c07ea9ef4ee193a6e52c2c211378d34df', class: this.classCollection.join() }, h("slot", { key: '0e427b1189217e5d863daf9ed15d35de4832d8dd' })));
79
+ return (h("span", { key: 'b3269e3baec3a281bdbe65f8b62636b7ea2fa84c', class: this.classCollection.join() }, h("slot", { key: 'bcca2d8653dbcd6a96d322055a4e2773d85ca87d' })));
76
80
  }
77
81
  static get is() { return "mg-tag"; }
78
82
  static get encapsulation() { return "shadow"; }
@@ -108,6 +112,8 @@ export class MgTag {
108
112
  "tags": [],
109
113
  "text": "Define tag variant"
110
114
  },
115
+ "getter": false,
116
+ "setter": false,
111
117
  "attribute": "variant",
112
118
  "reflect": false,
113
119
  "defaultValue": "variants[0]"
@@ -126,6 +132,8 @@ export class MgTag {
126
132
  "tags": [],
127
133
  "text": "Define if tag is using outline style"
128
134
  },
135
+ "getter": false,
136
+ "setter": false,
129
137
  "attribute": "outline",
130
138
  "reflect": false
131
139
  },
@@ -143,6 +151,8 @@ export class MgTag {
143
151
  "tags": [],
144
152
  "text": "Define if tag is using soft style"
145
153
  },
154
+ "getter": false,
155
+ "setter": false,
146
156
  "attribute": "soft",
147
157
  "reflect": false
148
158
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mg-tag.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-tag/mg-tag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5E;;GAEG;AAMH,MAAM,OAAO,KAAK;;QAChB;;sBAEc;QAEd,UAAU;QACO,iBAAY,GAAG,mBAAmB,CAAC;QACnC,cAAS,GAAG,gBAAgB,CAAC;uBAcZ,QAAQ,CAAC,CAAC,CAAC;;;+BAwCP,IAAI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;;OAEG;IACH,iBAAiB;QACf,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,OAAO,CACL,6DAAM,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE;YACtC,8DAAa,CACR,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Watch, Element } from '@stencil/core';\nimport { TagVariantType, variants } from './mg-tag.conf';\nimport { ClassList, isValidString, toString } from '@mgdis/stencil-helpers';\n/**\n * @slot - Tag content\n */\n@Component({\n tag: 'mg-tag',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tag.css',\n shadow: true,\n})\nexport class MgTag {\n /************\n * Internal *\n ************/\n\n // Classes\n private readonly classOutline = 'mg-c-tag--outline';\n private readonly classSoft = 'mg-c-tag--soft';\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTagElement;\n\n /**\n * Define tag variant\n */\n @Prop() variant: TagVariantType = variants[0]; // primary\n @Watch('variant')\n validateVariant(newValue: MgTag['variant'], oldValue?: MgTag['variant']): void {\n if (!variants.includes(newValue)) {\n throw new Error(`<mg-tag> prop \"variant\" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-tag--${oldValue}`);\n }\n this.classCollection.add(`mg-c-tag--${newValue}`);\n }\n }\n\n /**\n * Define if tag is using outline style\n */\n @Prop() outline?: boolean;\n @Watch('outline')\n validateOutline(newValue: MgTag['outline']): void {\n if (newValue) this.classCollection.add(this.classOutline);\n else this.classCollection.delete(this.classOutline);\n }\n\n /**\n * Define if tag is using soft style\n */\n @Prop() soft?: boolean;\n @Watch('soft')\n validateSoft(newValue: MgTag['soft']): void {\n // usage validation\n if (newValue && this.outline) throw new Error('<mg-tag> prop \"soft\" can NOT be used with prop \"outline\".');\n\n // apply class\n if (newValue) this.classCollection.add(this.classSoft);\n else this.classCollection.delete(this.classSoft);\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-tag']);\n\n /*************\n * Methods *\n *************/\n\n /**\n * Validate the given textContent\n * @param textContent - html element textContent property\n */\n private validateTextContent(textContent: string): void {\n if (!isValidString(textContent)) throw new Error('<mg-tag> slot must contain a text content.');\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if props are well configured on init\n */\n componentWillLoad(): void {\n this.validateVariant(this.variant);\n this.validateOutline(this.outline);\n this.validateSoft(this.soft);\n this.validateTextContent(this.element.textContent);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <span class={this.classCollection.join()}>\n <slot></slot>\n </span>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mg-tag.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-tag/mg-tag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5E;;GAEG;AAMH,MAAM,OAAO,KAAK;IALlB;QAME;;sBAEc;QAEd,UAAU;QACO,iBAAY,GAAG,mBAAmB,CAAC;QACnC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GG;IACK,mBAAmB,CAAC,WAAmB;QAC7C,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IACjG,CAAC;IAED;;mBAEe;IAEf;;OAEG;IACH,iBAAiB;QACf,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,OAAO,CACL,6DAAM,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE;YACtC,8DAAa,CACR,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Watch, Element } from '@stencil/core';\nimport { TagVariantType, variants } from './mg-tag.conf';\nimport { ClassList, isValidString, toString } from '@mgdis/stencil-helpers';\n/**\n * @slot - Tag content\n */\n@Component({\n tag: 'mg-tag',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tag.css',\n shadow: true,\n})\nexport class MgTag {\n /************\n * Internal *\n ************/\n\n // Classes\n private readonly classOutline = 'mg-c-tag--outline';\n private readonly classSoft = 'mg-c-tag--soft';\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTagElement;\n\n /**\n * Define tag variant\n */\n @Prop() variant: TagVariantType = variants[0]; // primary\n @Watch('variant')\n validateVariant(newValue: MgTag['variant'], oldValue?: MgTag['variant']): void {\n if (!variants.includes(newValue)) {\n throw new Error(`<mg-tag> prop \"variant\" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-tag--${oldValue}`);\n }\n this.classCollection.add(`mg-c-tag--${newValue}`);\n }\n }\n\n /**\n * Define if tag is using outline style\n */\n @Prop() outline?: boolean;\n @Watch('outline')\n validateOutline(newValue: MgTag['outline']): void {\n if (newValue) this.classCollection.add(this.classOutline);\n else this.classCollection.delete(this.classOutline);\n }\n\n /**\n * Define if tag is using soft style\n */\n @Prop() soft?: boolean;\n @Watch('soft')\n validateSoft(newValue: MgTag['soft']): void {\n // usage validation\n if (newValue && this.outline) throw new Error('<mg-tag> prop \"soft\" can NOT be used with prop \"outline\".');\n\n // apply class\n if (newValue) this.classCollection.add(this.classSoft);\n else this.classCollection.delete(this.classSoft);\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-tag']);\n\n /*************\n * Methods *\n *************/\n\n /**\n * Validate the given textContent\n * @param textContent - html element textContent property\n */\n private validateTextContent(textContent: string): void {\n if (!isValidString(textContent)) throw new Error('<mg-tag> slot must contain a text content.');\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if props are well configured on init\n */\n componentWillLoad(): void {\n this.validateVariant(this.variant);\n this.validateOutline(this.outline);\n this.validateSoft(this.soft);\n this.validateTextContent(this.element.textContent);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <span class={this.classCollection.join()}>\n <slot></slot>\n </span>\n );\n }\n}\n"]}