@mgdis/mg-components 6.20.0 → 6.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/dist/cjs/{index-TUElr4Wv.js → index-BxB20_Vw.js} +54 -0
  2. package/dist/cjs/{index-Bp6wZzau.js → index-C2viYwrR.js} +1761 -80
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/mg-action-more_37.cjs.entry.js +761 -371
  5. package/dist/cjs/mg-alert.cjs.entry.js +17 -9
  6. package/dist/cjs/mg-breadcrumb.cjs.entry.js +63 -0
  7. package/dist/cjs/mg-components.cjs.js +3 -3
  8. package/dist/cjs/mg-fieldset.cjs.entry.js +24 -7
  9. package/dist/cjs/mg-input-combobox.cjs.entry.js +49 -19
  10. package/dist/cjs/mg-input-file.cjs.entry.js +384 -0
  11. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +40096 -15821
  12. package/dist/cjs/{mg-input.conf-D7jmj_lh.js → mg-input.conf-BNpeATnq.js} +7 -0
  13. package/dist/cjs/mg-loader.cjs.entry.js +8 -6
  14. package/dist/cjs/mg-progress.cjs.entry.js +19 -9
  15. package/dist/collection/assets/icons/index.js +1 -1
  16. package/dist/collection/collection-manifest.json +5 -3
  17. package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js +1 -1
  18. package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js +1 -1
  19. package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
  20. package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.js +2 -2
  22. package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
  23. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +1 -1
  24. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +1 -1
  25. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +6 -0
  26. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +1 -1
  27. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +2 -2
  28. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +2 -2
  29. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +1 -1
  30. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +1 -1
  31. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +1 -1
  32. package/dist/collection/components/molecules/inputs/mg-input-file/mg-input-file.js +877 -0
  33. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
  34. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +2 -2
  35. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
  36. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/custom-properties.scss +212 -0
  37. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.conf.js +1 -0
  38. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/index.js +300 -94
  39. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.conf.js +29 -0
  40. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +163 -53
  41. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +2 -2
  43. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
  44. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
  45. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +3 -36
  46. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.conf.js +0 -4
  47. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +21 -43
  48. package/dist/collection/components/molecules/menus/mg-menu-item/mg-menu-item.js +65 -38
  49. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -2
  50. package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
  51. package/dist/collection/components/molecules/mg-breadcrumb/mg-breadcrumb.conf.js +1 -0
  52. package/dist/collection/components/molecules/mg-breadcrumb/mg-breadcrumb.js +92 -0
  53. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  54. package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +12 -3
  55. package/dist/collection/components/molecules/mg-form/mg-form.js +12 -2
  56. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  57. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  58. package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
  59. package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
  60. package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
  61. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  62. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
  63. package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
  64. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  65. package/dist/collection/components/molecules/mg-table/mg-table.js +37 -0
  66. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +0 -4
  67. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +13 -33
  68. package/dist/collection/locales/en/messages.json +14 -0
  69. package/dist/collection/locales/fr/messages.json +14 -0
  70. package/dist/components/events.utils.js +1 -23
  71. package/dist/components/index.d.ts +2 -0
  72. package/dist/components/index.js +1 -1
  73. package/dist/components/index2.js +1 -408
  74. package/dist/components/index3.js +1 -476
  75. package/dist/components/mg-action-more.js +1 -254
  76. package/dist/components/mg-alert.js +1 -224
  77. package/dist/components/mg-badge.js +1 -6
  78. package/dist/components/mg-badge2.js +1 -113
  79. package/dist/components/mg-breadcrumb.d.ts +11 -0
  80. package/dist/components/mg-breadcrumb.js +1 -0
  81. package/dist/components/mg-button.js +1 -6
  82. package/dist/components/mg-button2.js +1 -275
  83. package/dist/components/mg-card.js +1 -6
  84. package/dist/components/mg-card2.js +1 -92
  85. package/dist/components/mg-character-left.js +1 -6
  86. package/dist/components/mg-character-left2.js +1 -75
  87. package/dist/components/mg-details.js +1 -104
  88. package/dist/components/mg-divider.js +1 -6
  89. package/dist/components/mg-divider2.js +1 -49
  90. package/dist/components/mg-fieldset.js +1 -209
  91. package/dist/components/mg-form.js +1 -302
  92. package/dist/components/mg-icon.js +1 -6
  93. package/dist/components/mg-icon2.js +1 -188
  94. package/dist/components/mg-illustrated-message.js +1 -129
  95. package/dist/components/mg-input-checkbox-paginated.js +1 -6
  96. package/dist/components/mg-input-checkbox-paginated2.js +1 -135
  97. package/dist/components/mg-input-checkbox.js +1 -762
  98. package/dist/components/mg-input-combobox.js +1 -940
  99. package/dist/components/mg-input-date.js +1 -463
  100. package/dist/components/mg-input-file.d.ts +11 -0
  101. package/dist/components/mg-input-file.js +1 -0
  102. package/dist/components/mg-input-numeric.js +1 -592
  103. package/dist/components/mg-input-password.js +1 -360
  104. package/dist/components/mg-input-radio.js +1 -392
  105. package/dist/components/mg-input-rich-text-editor.js +1663 -16797
  106. package/dist/components/mg-input-select.js +1 -6
  107. package/dist/components/mg-input-select2.js +1 -481
  108. package/dist/components/mg-input-text.js +1 -6
  109. package/dist/components/mg-input-text2.js +1 -514
  110. package/dist/components/mg-input-textarea.js +1 -412
  111. package/dist/components/mg-input-title.js +1 -6
  112. package/dist/components/mg-input-title2.js +1 -81
  113. package/dist/components/mg-input-toggle.js +1 -371
  114. package/dist/components/mg-input.conf.js +1 -0
  115. package/dist/components/mg-input.js +1 -6
  116. package/dist/components/mg-input2.js +1 -459
  117. package/dist/components/mg-item-more.js +1 -6
  118. package/dist/components/mg-item-more2.js +1 -505
  119. package/dist/components/mg-loader.js +1 -6
  120. package/dist/components/mg-loader2.js +1 -74
  121. package/dist/components/mg-menu-item.js +1 -6
  122. package/dist/components/mg-menu-item2.js +1 -485
  123. package/dist/components/mg-menu.js +1 -6
  124. package/dist/components/mg-message.js +1 -6
  125. package/dist/components/mg-message2.js +1 -146
  126. package/dist/components/mg-modal.js +1 -184
  127. package/dist/components/mg-pagination.js +1 -234
  128. package/dist/components/mg-panel.js +1 -350
  129. package/dist/components/mg-popover-content.js +1 -6
  130. package/dist/components/mg-popover-content2.js +1 -96
  131. package/dist/components/mg-popover.js +1 -6
  132. package/dist/components/mg-popover2.js +1 -312
  133. package/dist/components/mg-progress.js +1 -123
  134. package/dist/components/mg-skip-links.js +1 -78
  135. package/dist/components/mg-table.js +1 -319
  136. package/dist/components/mg-tabs.js +1 -6
  137. package/dist/components/mg-tabs2.js +1 -315
  138. package/dist/components/mg-tag.js +1 -133
  139. package/dist/components/mg-tooltip-content.js +1 -6
  140. package/dist/components/mg-tooltip-content2.js +1 -42
  141. package/dist/components/mg-tooltip.js +1 -6
  142. package/dist/components/mg-tooltip2.js +1 -421
  143. package/dist/components/popper.js +1 -1790
  144. package/dist/esm/{index-BluNKQ3L.js → index-DFwaH2hS.js} +1761 -80
  145. package/dist/esm/{index-CNX6lq0x.js → index-DSEloqPn.js} +54 -1
  146. package/dist/esm/loader.js +3 -3
  147. package/dist/esm/mg-action-more_37.entry.js +761 -371
  148. package/dist/esm/mg-alert.entry.js +17 -9
  149. package/dist/esm/mg-breadcrumb.entry.js +61 -0
  150. package/dist/esm/mg-components.js +4 -4
  151. package/dist/esm/mg-fieldset.entry.js +24 -7
  152. package/dist/esm/mg-input-combobox.entry.js +49 -19
  153. package/dist/esm/mg-input-file.entry.js +382 -0
  154. package/dist/esm/mg-input-rich-text-editor.entry.js +40083 -15808
  155. package/dist/esm/{mg-input.conf-DDnrE1hD.js → mg-input.conf-C9rmNQIL.js} +7 -1
  156. package/dist/esm/mg-loader.entry.js +8 -6
  157. package/dist/esm/mg-progress.entry.js +19 -9
  158. package/dist/mg-components/locales/en/messages.json +14 -0
  159. package/dist/mg-components/locales/fr/messages.json +14 -0
  160. package/dist/mg-components/mg-components.esm.js +1 -1
  161. package/dist/mg-components/p-0482eb9f.entry.js +1 -0
  162. package/dist/mg-components/{p-7132bca1.entry.js → p-2ee92f38.entry.js} +1 -1
  163. package/dist/mg-components/{p-916dfb6d.entry.js → p-3b653226.entry.js} +1 -1
  164. package/dist/mg-components/p-5745fbea.entry.js +1 -0
  165. package/dist/mg-components/p-C9rmNQIL.js +1 -0
  166. package/dist/mg-components/p-DFwaH2hS.js +2 -0
  167. package/dist/mg-components/p-DSEloqPn.js +1 -0
  168. package/dist/mg-components/p-adec7fcc.entry.js +1 -0
  169. package/dist/mg-components/p-c63f97f0.entry.js +1658 -0
  170. package/dist/mg-components/p-c8c8cfc1.entry.js +1 -0
  171. package/dist/mg-components/p-cc793586.entry.js +1 -0
  172. package/dist/mg-components/p-d5e69c95.entry.js +1 -0
  173. package/dist/types/assets/icons/index.d.ts +2 -0
  174. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +7 -1
  175. package/dist/types/components/molecules/inputs/mg-input-file/mg-input-file.d.ts +210 -0
  176. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.conf.d.ts +17 -0
  177. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/editor/index.d.ts +27 -19
  178. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.conf.d.ts +3 -0
  179. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +50 -16
  180. package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.conf.d.ts +0 -5
  181. package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.d.ts +1 -6
  182. package/dist/types/components/molecules/menus/mg-menu/mg-menu.conf.d.ts +2 -10
  183. package/dist/types/components/molecules/menus/mg-menu/mg-menu.d.ts +7 -7
  184. package/dist/types/components/molecules/menus/mg-menu-item/mg-menu-item.d.ts +12 -8
  185. package/dist/types/components/molecules/mg-breadcrumb/mg-breadcrumb.conf.d.ts +18 -0
  186. package/dist/types/components/molecules/mg-breadcrumb/mg-breadcrumb.d.ts +34 -0
  187. package/dist/types/components/molecules/mg-table/mg-table.d.ts +6 -0
  188. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +1 -9
  189. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +4 -4
  190. package/dist/types/components.d.ts +302 -46
  191. package/dist/types/stencil-public-runtime.d.ts +76 -12
  192. package/ide/intellij/web-types.json +483 -51
  193. package/ide/vscode/css-custom-data.json +10 -2
  194. package/ide/vscode/html-custom-data.json +445 -104
  195. package/package.json +24 -23
  196. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.scss +0 -1
  197. package/dist/mg-components/p-016bd291.entry.js +0 -1
  198. package/dist/mg-components/p-186a6139.entry.js +0 -1
  199. package/dist/mg-components/p-BluNKQ3L.js +0 -2
  200. package/dist/mg-components/p-CNX6lq0x.js +0 -1
  201. package/dist/mg-components/p-DDnrE1hD.js +0 -1
  202. package/dist/mg-components/p-cd061b38.entry.js +0 -1
  203. package/dist/mg-components/p-d2c72f09.entry.js +0 -1
  204. package/dist/mg-components/p-d5a276eb.entry.js +0 -1
  205. package/ide/vscode/custom.css-data.json +0 -425
@@ -1,319 +1 @@
1
- import { proxyCustomElement, HTMLElement } from '@stencil/core/internal/client';
2
- import { C as ClassList, t as toString, i as isValidString, c as createID } from './index2.js';
3
- import { i as initLocales } from './index3.js';
4
- import { d as defineCustomElement$2 } from './mg-icon2.js';
5
-
6
- /**
7
- * Sizes
8
- */
9
- // Define possible sizes
10
- const sizes = ['small', 'medium', 'large', 'xlarge'];
11
- /**
12
- * Columns
13
- */
14
- // Define possible text alignments
15
- const textAlignments = ['left', 'center', 'right'];
16
- // Define possible data types
17
- const dataTypes = ['string', 'numeric', 'date'];
18
-
19
- const mgTableCss = ".mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}@font-face{font-family:\"Open Sans\";src:url(\"fonts/OpenSans-Regular.ttf\") format(\"truetype\")}@font-face{font-family:\"Open Sans\";font-weight:600;src:url(\"fonts/OpenSans-SemiBold.ttf\") format(\"truetype\")}@font-face{font-family:\"Open Sans\";font-weight:700;src:url(\"fonts/OpenSans-Bold.ttf\") format(\"truetype\")}p{margin:0}p+p{margin-top:var(--mg-b-size-8)}h1,.mg-u-h1{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h1);font-weight:bold}h2,.mg-u-h2{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h2);font-weight:bold}h3,.mg-u-h3{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h3);font-weight:bold}h4,.mg-u-h4{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h4);font-weight:bold}h5,.mg-u-h5{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h5);font-weight:bold}h6,.mg-u-h6{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h6);font-weight:bold}small{font-size:var(--mg-b-small-font-size)}.mg-u-text-left{text-align:left !important}.mg-u-text-center{text-align:center !important}.mg-u-text-right{text-align:right !important}.mg-c-table{--mg-c-table-cell-spacing:var(--mg-b-size-8) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-40);--mg-c-table-header-cell-height:calc(var(--mg-b-size-min-height) + 2 * var(--mg-b-size-8));overflow:hidden;border:var(--mg-b-size-border) solid var(--mg-b-color-neutral-30);border-radius:var(--mg-b-size-12);background:var(--mg-b-color-light);border-spacing:0;color:var(--mg-b-color-dark)}.mg-c-table td,.mg-c-table th{height:var(--mg-c-table-cell-height);box-sizing:border-box;padding:var(--mg-c-table-cell-spacing);text-align:start}.mg-c-table thead{height:var(--mg-c-table-header-cell-height)}.mg-c-table thead,.mg-c-table tfoot{background-color:var(--mg-b-color-neutral-10)}.mg-c-table thead td,.mg-c-table tfoot td,.mg-c-table th{font-weight:600}.mg-c-table tr th,.mg-c-table tr td{border-block-end:var(--mg-b-size-border) solid var(--mg-b-color-neutral-30)}.mg-c-table tfoot tr:last-of-type th,.mg-c-table tfoot tr:last-of-type td{border-block-end:none}.mg-c-table.mg-c-table--size-small{--mg-c-table-cell-spacing:var(--mg-b-size-4) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-32);--mg-c-table-header-cell-height:var(--mg-b-size-32)}.mg-c-table.mg-c-table--size-large{--mg-c-table-cell-height:var(--mg-c-table-header-cell-height)}.mg-c-table.mg-c-table--size-xlarge{--mg-c-table-cell-spacing:var(--mg-b-size-12) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-64);--mg-c-table-header-cell-height:var(--mg-b-size-64)}.mg-c-table.mg-c-table--full-width{width:100%}.mg-c-table-wrapper{overflow:auto}.mg-c-table thead td,.mg-c-table thead th{position:relative}.mg-c-table thead td .mg-c-table__sort-button,.mg-c-table thead th .mg-c-table__sort-button{display:inline-flex;align-items:center;padding:0;border:none;margin:0;background:none;color:inherit;font-size:inherit;font-weight:600;gap:var(--mg-b-size-4);text-align:left}.mg-c-table thead td .mg-c-table__sort-button::after,.mg-c-table thead th .mg-c-table__sort-button::after{position:absolute;content:\"\";inset:0}.mg-c-table thead td .mg-c-table__sort-button:hover,.mg-c-table thead th .mg-c-table__sort-button:hover{cursor:pointer}.mg-c-table thead td:has(.mg-c-table__sort-button):hover,.mg-c-table thead td[aria-sort=descending],.mg-c-table thead td[aria-sort=ascending],.mg-c-table thead th:has(.mg-c-table__sort-button):hover,.mg-c-table thead th[aria-sort=descending],.mg-c-table thead th[aria-sort=ascending]{background-color:var(--mg-b-color-neutral-20)}";
20
-
21
- /**
22
- * Check if value is a valid align object
23
- * @param newValue - New value
24
- * @returns True if value is a valid align object
25
- */
26
- const isValidColumnsObject = (newValue) =>
27
- // ensure newValue is an object
28
- typeof newValue === 'object' &&
29
- !Array.isArray(newValue) &&
30
- // Ensure every property is well formatted
31
- Object.entries(newValue).every(([key, value]) =>
32
- // ensure key is a number
33
- !isNaN(parseInt(key)) &&
34
- // ensure value is an object
35
- typeof value === 'object' &&
36
- !Array.isArray(value) &&
37
- // ensure value has at least one of the following properties
38
- ((value.align !== undefined && textAlignments.includes(value.align)) ||
39
- (value.sortable !== undefined && typeof value.sortable === 'boolean') ||
40
- (value.datatype !== undefined && dataTypes.includes(value.datatype))) &&
41
- // ensure no extra properties are present
42
- Object.keys(value).every(key => ['align', 'sortable', 'datatype'].includes(key)));
43
- /**
44
- * Compare values
45
- * @param firstValue - First value
46
- * @param secondValue - Second value
47
- * @param descending - Define descending order
48
- * @param datatype - Data type
49
- * @returns Comparison result
50
- * @example
51
- * compareValues('a', 'b', false, 'string'); // -1
52
- */
53
- const compareValues = (firstValue, secondValue, descending, datatype) => {
54
- if (descending) {
55
- const temp = firstValue;
56
- firstValue = secondValue;
57
- secondValue = temp;
58
- }
59
- if (datatype === 'date') {
60
- return new Date(firstValue).getTime() - new Date(secondValue).getTime();
61
- }
62
- return firstValue.localeCompare(secondValue, undefined, { numeric: datatype === 'numeric' });
63
- };
64
- const MgTable$1 = /*@__PURE__*/ proxyCustomElement(class MgTable extends HTMLElement {
65
- constructor(registerHost) {
66
- super();
67
- if (registerHost !== false) {
68
- this.__registerHost();
69
- }
70
- this.__attachShadow();
71
- // Classes
72
- this.componentClass = 'mg-c-table';
73
- this.componentWrapperClass = 'mg-c-table-wrapper';
74
- this.classFullWidth = 'mg-c-table--full-width';
75
- // Alignment stylesheet
76
- this.alignmentStylesheet = new CSSStyleSheet();
77
- /**
78
- * Define table size
79
- */
80
- this.size = 'medium';
81
- /**
82
- * Define if table fits its parent element
83
- */
84
- this.fullWidth = false;
85
- /**
86
- * Class collection
87
- */
88
- this.classCollection = new ClassList([this.componentClass]);
89
- }
90
- watchSize(newValue, oldValue) {
91
- if (!sizes.includes(newValue)) {
92
- throw new Error(`<mg-table> prop "size" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);
93
- }
94
- else {
95
- if (oldValue !== undefined) {
96
- this.classCollection.delete(`mg-c-table--size-${oldValue}`);
97
- }
98
- this.classCollection.add(`mg-c-table--size-${newValue}`);
99
- }
100
- }
101
- watchFullWidth(newValue) {
102
- if (newValue) {
103
- this.classCollection.add(this.classFullWidth);
104
- }
105
- else {
106
- this.classCollection.delete(this.classFullWidth);
107
- }
108
- }
109
- watchColumns(newValue) {
110
- if (newValue !== undefined && !isValidColumnsObject(newValue)) {
111
- throw new Error(`<mg-table> prop "columns" must be a ColumnsType object. Passed value: ${toString(newValue)}.`);
112
- }
113
- }
114
- /**
115
- * Render Table
116
- * @param table - Table element
117
- */
118
- renderTable(table) {
119
- let isSortable = false;
120
- // Remove table classes
121
- table.className = '';
122
- // Add table classes
123
- table.classList.add(...this.classCollection.classes);
124
- // Set columns based on columns prop
125
- if (this.columns !== undefined) {
126
- // Store original rows
127
- const rowsDefault = Array.from(table.querySelectorAll('tbody tr'));
128
- // Apply columns settings
129
- Object.entries(this.columns).forEach(([key, value]) => {
130
- // Add alignment to stylesheet
131
- if (value.align !== undefined) {
132
- this.alignmentStylesheet.insertRule(`.${this.componentClass} th:nth-child(${key}),td:nth-child(${key}){text-align:${value.align};&>*{display:inline-block;}}`);
133
- }
134
- // if align is not defined and datatype is number, align right
135
- else if (value.datatype === 'numeric') {
136
- this.alignmentStylesheet.insertRule(`.${this.componentClass} th:nth-child(${key}),td:nth-child(${key}){text-align:right;&>*{display:inline-block;}}`);
137
- }
138
- // Define if column is sortable
139
- if (value.sortable) {
140
- isSortable = true;
141
- // Add sortable class to table header
142
- const sortableHeader = table.querySelector(`thead td:nth-child(${key}),thead th:nth-child(${key})`);
143
- // Create button
144
- const button = document.createElement('button');
145
- button.classList.add('mg-c-table__sort-button');
146
- // Append button to header
147
- const sortableHeaderContent = sortableHeader.innerHTML;
148
- sortableHeader.innerHTML = '';
149
- button.innerHTML = sortableHeaderContent;
150
- // Set icon
151
- const icon = document.createElement('mg-icon');
152
- icon.setAttribute('icon', 'arrows-up-down');
153
- // Append icon to button
154
- button.append(icon);
155
- sortableHeader.append(button);
156
- // Add event listener
157
- button.addEventListener('click', () => {
158
- // Reset aria pressed
159
- table.querySelectorAll(`thead td:not(:nth-child(${key})) [aria-pressed],thead th:not(:nth-child(${key})) [aria-pressed]`).forEach(ariaPressed => {
160
- ariaPressed.removeAttribute('aria-pressed');
161
- ariaPressed.querySelector('mg-icon').setAttribute('icon', 'arrows-up-down');
162
- });
163
- // Reset aria sort
164
- table.querySelectorAll(`thead td:not(:nth-child(${key}))[aria-sort],thead th:not(:nth-child(${key}))[aria-sort]`).forEach(ariaSort => {
165
- ariaSort.removeAttribute('aria-sort');
166
- });
167
- // Set aria pressed
168
- button.setAttribute('aria-pressed', 'true');
169
- // Manage sort order
170
- // Get sort order
171
- let sortOrder = sortableHeader.getAttribute('aria-sort');
172
- // First click sort asc
173
- if ([null, 'none'].includes(sortOrder)) {
174
- sortableHeader.setAttribute('aria-sort', 'ascending');
175
- }
176
- // Second click sort desc
177
- else if (sortOrder === 'ascending') {
178
- sortableHeader.setAttribute('aria-sort', 'descending');
179
- }
180
- // Third click remove sort
181
- else {
182
- sortableHeader.setAttribute('aria-sort', 'none');
183
- }
184
- // Update sort order
185
- sortOrder = sortableHeader.getAttribute('aria-sort');
186
- // Update button icon
187
- const icon = button.querySelector('mg-icon');
188
- let iconType = 'arrows-up-down';
189
- if (sortOrder === 'ascending') {
190
- iconType = 'arrow-up';
191
- }
192
- else if (sortOrder === 'descending') {
193
- iconType = 'arrow-down';
194
- }
195
- icon.setAttribute('icon', iconType);
196
- // If sort order is none, return to original order
197
- if (sortOrder === 'none') {
198
- // Append rows to table
199
- rowsDefault.forEach(row => table.querySelector('tbody').append(row));
200
- return;
201
- }
202
- // Set a copy of rows
203
- const rows = Array.from(table.querySelectorAll('tbody tr'));
204
- // Sort rows
205
- rows.sort((a, b) => {
206
- var _a, _b;
207
- // Get cells
208
- const cellA = a.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);
209
- const cellB = b.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);
210
- // Get cell values
211
- const cellValueA = (_a = cellA.dataset.sort) !== null && _a !== void 0 ? _a : cellA.textContent;
212
- const cellValueB = (_b = cellB.dataset.sort) !== null && _b !== void 0 ? _b : cellB.textContent;
213
- // Sort cells based on sort order
214
- return compareValues(cellValueA, cellValueB, sortOrder === 'descending', value.datatype);
215
- });
216
- // Append rows to table
217
- rows.forEach(row => table.querySelector('tbody').append(row));
218
- });
219
- }
220
- });
221
- }
222
- // Add alignment to columns
223
- this.element.shadowRoot.adoptedStyleSheets.push(this.alignmentStylesheet);
224
- // Create div wrapper for responsive behavior
225
- const divWrapper = document.createElement('div');
226
- divWrapper.setAttribute('class', this.componentWrapperClass);
227
- divWrapper.setAttribute('tabindex', '0');
228
- divWrapper.setAttribute('role', 'region');
229
- // Get table title
230
- let captionTable = table.querySelector('caption');
231
- // If table is sortable we must add a caption
232
- if (captionTable === null && isSortable) {
233
- captionTable = document.createElement('caption');
234
- table.prepend(captionTable);
235
- }
236
- if (captionTable !== null) {
237
- // Ensure caption is not visible (otherwhise the table does not have rounded corners)
238
- captionTable.className = 'mg-u-visually-hidden';
239
- // Link caption to div
240
- if (!isValidString(captionTable.id)) {
241
- captionTable.setAttribute('id', createID(`${this.componentClass}-caption`));
242
- }
243
- divWrapper.setAttribute('aria-labelledby', captionTable.id);
244
- // Add sortable caption if neeeded
245
- if (isSortable) {
246
- captionTable.innerHTML = `${captionTable.innerHTML} ${this.messages.table.sortableCaption}`.trim();
247
- }
248
- }
249
- divWrapper.append(table);
250
- // Remove existing table from shadow root
251
- const existingTable = this.element.shadowRoot.querySelector(`.${this.componentWrapperClass}`);
252
- if (existingTable !== null) {
253
- existingTable.remove();
254
- }
255
- // Append table
256
- this.element.shadowRoot.append(divWrapper);
257
- }
258
- /*************
259
- * Lifecycle *
260
- *************/
261
- componentWillLoad() {
262
- this.messages = initLocales(this.element).messages;
263
- }
264
- /**
265
- * Set variables and validate props
266
- */
267
- componentDidLoad() {
268
- this.watchSize(this.size);
269
- this.watchFullWidth(this.fullWidth);
270
- this.watchColumns(this.columns);
271
- this.renderTable(this.element.querySelector('table'));
272
- }
273
- /**
274
- * Update table
275
- */
276
- componentWillUpdate() {
277
- this.renderTable(this.element.shadowRoot.querySelector('table'));
278
- }
279
- get element() { return this; }
280
- static get watchers() { return {
281
- "size": ["watchSize"],
282
- "fullWidth": ["watchFullWidth"],
283
- "columns": ["watchColumns"]
284
- }; }
285
- static get style() { return mgTableCss; }
286
- }, [1, "mg-table", {
287
- "size": [1],
288
- "fullWidth": [4, "full-width"],
289
- "columns": [16],
290
- "classCollection": [32]
291
- }, undefined, {
292
- "size": ["watchSize"],
293
- "fullWidth": ["watchFullWidth"],
294
- "columns": ["watchColumns"]
295
- }]);
296
- function defineCustomElement$1() {
297
- if (typeof customElements === "undefined") {
298
- return;
299
- }
300
- const components = ["mg-table", "mg-icon"];
301
- components.forEach(tagName => { switch (tagName) {
302
- case "mg-table":
303
- if (!customElements.get(tagName)) {
304
- customElements.define(tagName, MgTable$1);
305
- }
306
- break;
307
- case "mg-icon":
308
- if (!customElements.get(tagName)) {
309
- defineCustomElement$2();
310
- }
311
- break;
312
- } });
313
- }
314
- defineCustomElement$1();
315
-
316
- const MgTable = MgTable$1;
317
- const defineCustomElement = defineCustomElement$1;
318
-
319
- export { MgTable, defineCustomElement };
1
+ import{transformTag as t,proxyCustomElement as e,HTMLElement as a}from"@stencil/core/internal/client";import{C as o,t as i,i as r,c as n}from"./index2.js";import{i as l}from"./index3.js";import{d as s}from"./mg-icon2.js";const h=["small","medium","large","xlarge"],c=["left","center","right"],d=["string","numeric","date"],m=e(class extends a{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.componentClass="mg-c-table",this.componentWrapperClass="mg-c-table-wrapper",this.classFullWidth="mg-c-table--full-width",this.classBorderHide="mg-c-table--border-hide",this.alignmentStylesheet=new CSSStyleSheet,this.size="medium",this.fullWidth=!1,this.borderHide=!1,this.classCollection=new o([this.componentClass])}watchSize(t,e){if(!h.includes(t))throw Error(`<mg-table> prop "size" must be one of: ${h.join(", ")}. Passed value: ${i(t)}.`);void 0!==e&&this.classCollection.delete("mg-c-table--size-"+e),this.classCollection.add("mg-c-table--size-"+t)}watchFullWidth(t){t?this.classCollection.add(this.classFullWidth):this.classCollection.delete(this.classFullWidth)}watchBorderHide(t){t?this.classCollection.add(this.classBorderHide):this.classCollection.delete(this.classBorderHide)}watchColumns(t){if(void 0!==t&&!(t=>"object"==typeof t&&!Array.isArray(t)&&Object.entries(t).every((([t,e])=>!isNaN(parseInt(t))&&"object"==typeof e&&!Array.isArray(e)&&(void 0!==e.align&&c.includes(e.align)||void 0!==e.sortable&&"boolean"==typeof e.sortable||void 0!==e.datatype&&d.includes(e.datatype))&&Object.keys(e).every((t=>["align","sortable","datatype"].includes(t))))))(t))throw Error(`<mg-table> prop "columns" must be a ColumnsType object. Passed value: ${i(t)}.`)}renderTable(t){let e=!1;if(t.className="",t.classList.add(...this.classCollection.classes),void 0!==this.columns){const a=Array.from(t.querySelectorAll("tbody tr"));Object.entries(this.columns).forEach((([o,i])=>{if(void 0!==i.align?this.alignmentStylesheet.insertRule(`.${this.componentClass} th:nth-child(${o}),td:nth-child(${o}){text-align:${i.align};&>*{display:inline-block;}}`):"numeric"===i.datatype&&this.alignmentStylesheet.insertRule(`.${this.componentClass} th:nth-child(${o}),td:nth-child(${o}){text-align:right;&>*{display:inline-block;}}`),i.sortable){e=!0;const r=t.querySelector(`thead td:nth-child(${o}),thead th:nth-child(${o})`),n=document.createElement("button");n.classList.add("mg-c-table__sort-button");const l=r.innerHTML;r.innerHTML="",n.innerHTML=l;const s=document.createElement("mg-icon");s.setAttribute("icon","arrows-up-down"),n.append(s),r.append(n),n.addEventListener("click",(()=>{t.querySelectorAll(`thead td:not(:nth-child(${o})) [aria-pressed],thead th:not(:nth-child(${o})) [aria-pressed]`).forEach((t=>{t.removeAttribute("aria-pressed"),t.querySelector("mg-icon").setAttribute("icon","arrows-up-down")})),t.querySelectorAll(`thead td:not(:nth-child(${o}))[aria-sort],thead th:not(:nth-child(${o}))[aria-sort]`).forEach((t=>{t.removeAttribute("aria-sort")})),n.setAttribute("aria-pressed","true");let e=r.getAttribute("aria-sort");r.setAttribute("aria-sort",[null,"none"].includes(e)?"ascending":"ascending"===e?"descending":"none"),e=r.getAttribute("aria-sort");const l=n.querySelector("mg-icon");let s="arrows-up-down";if("ascending"===e?s="arrow-up":"descending"===e&&(s="arrow-down"),l.setAttribute("icon",s),"none"===e)return void a.forEach((e=>t.querySelector("tbody").append(e)));const h=Array.from(t.querySelectorAll("tbody tr"));h.sort(((t,a)=>{var r,n;const l=t.querySelector(`td:nth-child(${o}),th:nth-child(${o})`),s=a.querySelector(`td:nth-child(${o}),th:nth-child(${o})`);return((t,e,a,o)=>{if(a){const a=t;t=e,e=a}return"date"===o?new Date(t).getTime()-new Date(e).getTime():t.localeCompare(e,void 0,{numeric:"numeric"===o})})(null!==(r=l.dataset.sort)&&void 0!==r?r:l.textContent,null!==(n=s.dataset.sort)&&void 0!==n?n:s.textContent,"descending"===e,i.datatype)})),h.forEach((e=>t.querySelector("tbody").append(e)))}))}}))}this.element.shadowRoot.adoptedStyleSheets.push(this.alignmentStylesheet);const a=document.createElement("div");a.setAttribute("class",this.componentWrapperClass),a.setAttribute("tabindex","0"),a.setAttribute("role","region");let o=t.querySelector("caption");null===o&&e&&(o=document.createElement("caption"),t.prepend(o)),null!==o&&(o.className="mg-u-visually-hidden",r(o.id)||o.setAttribute("id",n(this.componentClass+"-caption")),a.setAttribute("aria-labelledby",o.id),e&&(o.innerHTML=`${o.innerHTML} ${this.messages.table.sortableCaption}`.trim())),a.append(t);const i=this.element.shadowRoot.querySelector("."+this.componentWrapperClass);null!==i&&i.remove(),this.element.shadowRoot.append(a)}componentWillLoad(){this.messages=l(this.element).messages}componentDidLoad(){this.watchSize(this.size),this.watchFullWidth(this.fullWidth),this.watchBorderHide(this.borderHide),this.watchColumns(this.columns),this.renderTable(this.element.querySelector("table"))}componentWillUpdate(){this.renderTable(this.element.shadowRoot.querySelector("table"))}get element(){return this}static get watchers(){return{size:[{watchSize:0}],fullWidth:[{watchFullWidth:0}],borderHide:[{watchBorderHide:0}],columns:[{watchColumns: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}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}@font-face{font-family:"Open Sans";src:url("fonts/OpenSans-Regular.ttf") format("truetype")}@font-face{font-family:"Open Sans";font-weight:600;src:url("fonts/OpenSans-SemiBold.ttf") format("truetype")}@font-face{font-family:"Open Sans";font-weight:700;src:url("fonts/OpenSans-Bold.ttf") format("truetype")}p{margin:0}p+p{margin-top:var(--mg-b-size-8)}h1,.mg-u-h1{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h1);font-weight:bold}h2,.mg-u-h2{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h2);font-weight:bold}h3,.mg-u-h3{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h3);font-weight:bold}h4,.mg-u-h4{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h4);font-weight:bold}h5,.mg-u-h5{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h5);font-weight:bold}h6,.mg-u-h6{font-family:var(--mg-b-font-family-heading);font-size:var(--mg-b-font-size-h6);font-weight:bold}small{font-size:var(--mg-b-small-font-size)}.mg-u-text-left{text-align:left !important}.mg-u-text-center{text-align:center !important}.mg-u-text-right{text-align:right !important}.mg-c-table{--mg-c-table-cell-spacing:var(--mg-b-size-8) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-40);overflow:hidden;border:var(--mg-b-size-border) solid var(--mg-b-color-neutral-30);border-radius:var(--mg-b-size-12);background:var(--mg-b-color-light);border-spacing:0;color:var(--mg-b-color-dark)}.mg-c-table td,.mg-c-table th{height:var(--mg-c-table-cell-height);box-sizing:border-box;padding:var(--mg-c-table-cell-spacing);text-align:start}.mg-c-table thead{height:var(--mg-c-table-header-cell-height)}.mg-c-table thead,.mg-c-table tfoot{background-color:var(--mg-c-table-color-head-foot-background, var(--mg-b-color-neutral-10));color:var(--mg-b-color-neutral-90)}.mg-c-table tfoot tr:first-of-type :where(th,td){border-block-start:var(--mg-b-size-border) solid var(--mg-b-color-neutral-30)}.mg-c-table thead td,.mg-c-table tfoot td,.mg-c-table th{font-weight:600}.mg-c-table tr :where(th,td){border-block-end:var(--mg-b-size-border) solid var(--mg-b-color-neutral-30)}.mg-c-table tbody:last-of-type tr:last-of-type :where(th,td),.mg-c-table tfoot tr:last-of-type :where(th,td){border-block-end:none}.mg-c-table tfoot :where(th,td)[rowspan][scope=rowgroup],.mg-c-table tbody:last-of-type :where(th,td)[rowspan][scope=rowgroup]{border-block-end:none}.mg-c-table.mg-c-table--size-small{--mg-c-table-cell-spacing:var(--mg-b-size-4) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-32)}.mg-c-table.mg-c-table--size-large{--mg-c-table-cell-height:calc(var(--mg-b-size-min-height) + 2 * var(--mg-b-size-8))}.mg-c-table.mg-c-table--size-xlarge{--mg-c-table-cell-spacing:var(--mg-b-size-12) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-64)}.mg-c-table.mg-c-table--full-width{width:100%}.mg-c-table.mg-c-table--border-hide{border:unset;border-radius:unset}.mg-c-table-wrapper{overflow:auto}.mg-c-table thead td,.mg-c-table thead th{position:relative}.mg-c-table thead td .mg-c-table__sort-button,.mg-c-table thead th .mg-c-table__sort-button{display:inline-flex;align-items:center;padding:0;border:none;margin:0;background:none;color:inherit;font-size:inherit;font-weight:600;gap:var(--mg-b-size-4);text-align:left}.mg-c-table thead td .mg-c-table__sort-button::after,.mg-c-table thead th .mg-c-table__sort-button::after{position:absolute;content:"";inset:0}.mg-c-table thead td .mg-c-table__sort-button:hover,.mg-c-table thead th .mg-c-table__sort-button:hover{cursor:pointer}.mg-c-table thead td:has(.mg-c-table__sort-button):hover,.mg-c-table thead td[aria-sort=descending],.mg-c-table thead td[aria-sort=ascending],.mg-c-table thead th:has(.mg-c-table__sort-button):hover,.mg-c-table thead th[aria-sort=descending],.mg-c-table thead th[aria-sort=ascending]{background-color:var(--mg-b-color-neutral-20)}'}},[1,"mg-table",{size:[1],fullWidth:[4,"full-width"],borderHide:[4,"border-hide"],columns:[16],classCollection:[32]},void 0,{size:[{watchSize:0}],fullWidth:[{watchFullWidth:0}],borderHide:[{watchBorderHide:0}],columns:[{watchColumns:0}]}]);function g(){"undefined"!=typeof customElements&&["mg-table","mg-icon"].forEach((e=>{switch(e){case"mg-table":customElements.get(t(e))||customElements.define(t(e),m);break;case"mg-icon":customElements.get(t(e))||s()}}))}g();const b=m,f=g;export{b as MgTable,f as defineCustomElement}
@@ -1,6 +1 @@
1
- import { M as MgTabs$1, d as defineCustomElement$1 } from './mg-tabs2.js';
2
-
3
- const MgTabs = MgTabs$1;
4
- const defineCustomElement = defineCustomElement$1;
5
-
6
- export { MgTabs, defineCustomElement };
1
+ import{M as s,d as o}from"./mg-tabs2.js";const t=s,a=o;export{t as MgTabs,a as defineCustomElement}