@mgdis/mg-components 6.7.0 → 6.8.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 (115) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/index-1a5a1081.js +2 -2
  3. package/dist/cjs/{index-b7923724.js → index-234e834a.js} +75 -39
  4. package/dist/cjs/index-234e834a.js.map +1 -0
  5. package/dist/cjs/{index.es-903492c5.js → index.es-b90f74d4.js} +2 -2
  6. package/dist/cjs/index.es-b90f74d4.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/{mg-action-more_36.cjs.entry.js → mg-action-more_37.cjs.entry.js} +477 -91
  9. package/dist/cjs/mg-action-more_37.cjs.entry.js.map +1 -0
  10. package/dist/cjs/mg-alert.cjs.entry.js +2 -2
  11. package/dist/cjs/mg-components.cjs.js +1 -1
  12. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +2 -2
  13. package/dist/cjs/mg-loader.cjs.entry.js +3 -3
  14. package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
  15. package/dist/cjs/mg-progress.cjs.entry.js +1 -1
  16. package/dist/collection/collection-manifest.json +1 -0
  17. package/dist/collection/components/atoms/mg-button/mg-button.js +10 -10
  18. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  19. package/dist/collection/components/atoms/mg-icon/mg-icon.js +21 -6
  20. package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
  21. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +2 -2
  22. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
  23. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +1 -1
  24. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -1
  25. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +46 -19
  26. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
  27. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +57 -28
  28. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
  29. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js +7 -1
  30. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js.map +1 -1
  31. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +43 -12
  32. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
  33. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  34. package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
  35. package/dist/collection/components/molecules/mg-table/mg-table.conf.js +13 -0
  36. package/dist/collection/components/molecules/mg-table/mg-table.conf.js.map +1 -0
  37. package/dist/collection/components/molecules/mg-table/mg-table.js +364 -0
  38. package/dist/collection/components/molecules/mg-table/mg-table.js.map +1 -0
  39. package/dist/collection/locales/en/messages.json +33 -16
  40. package/dist/collection/locales/fr/messages.json +36 -19
  41. package/dist/components/index.es.js +1 -1
  42. package/dist/components/index.es.js.map +1 -1
  43. package/dist/components/index2.js +73 -37
  44. package/dist/components/index2.js.map +1 -1
  45. package/dist/components/mg-button2.js +10 -10
  46. package/dist/components/mg-button2.js.map +1 -1
  47. package/dist/components/mg-icon2.js +21 -6
  48. package/dist/components/mg-icon2.js.map +1 -1
  49. package/dist/components/mg-input-checkbox-paginated2.js +2 -2
  50. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  51. package/dist/components/mg-input-date.js +47 -19
  52. package/dist/components/mg-input-date.js.map +1 -1
  53. package/dist/components/mg-input-numeric.js +58 -29
  54. package/dist/components/mg-input-numeric.js.map +1 -1
  55. package/dist/components/mg-input-text2.js +50 -14
  56. package/dist/components/mg-input-text2.js.map +1 -1
  57. package/dist/components/mg-loader.js +1 -1
  58. package/dist/components/mg-loader.js.map +1 -1
  59. package/dist/components/mg-table.d.ts +11 -0
  60. package/dist/components/mg-table.js +320 -0
  61. package/dist/components/mg-table.js.map +1 -0
  62. package/dist/esm/index-5059254f.js +2 -2
  63. package/dist/esm/{index-a58f8b91.js → index-544778a7.js} +75 -39
  64. package/dist/esm/index-544778a7.js.map +1 -0
  65. package/dist/esm/{index.es-b80b758c.js → index.es-517b1bf2.js} +2 -2
  66. package/dist/esm/index.es-517b1bf2.js.map +1 -0
  67. package/dist/esm/loader.js +1 -1
  68. package/dist/esm/{mg-action-more_36.entry.js → mg-action-more_37.entry.js} +477 -92
  69. package/dist/esm/mg-action-more_37.entry.js.map +1 -0
  70. package/dist/esm/mg-alert.entry.js +2 -2
  71. package/dist/esm/mg-components.js +1 -1
  72. package/dist/esm/mg-input-rich-text-editor.entry.js +2 -2
  73. package/dist/esm/mg-loader.entry.js +3 -3
  74. package/dist/esm/mg-loader.entry.js.map +1 -1
  75. package/dist/esm/mg-progress.entry.js +1 -1
  76. package/dist/mg-components/locales/en/messages.json +33 -16
  77. package/dist/mg-components/locales/fr/messages.json +36 -19
  78. package/dist/mg-components/mg-components.esm.js +1 -1
  79. package/dist/mg-components/mg-components.esm.js.map +1 -1
  80. package/dist/mg-components/{p-3c6710be.js → p-12a1edee.js} +2 -2
  81. package/dist/mg-components/p-12a1edee.js.map +1 -0
  82. package/dist/mg-components/p-9bc53279.js +2 -0
  83. package/dist/mg-components/{p-ac8a5083.js.map → p-9bc53279.js.map} +1 -1
  84. package/dist/mg-components/{p-bc6ec847.entry.js → p-ad98f3d8.entry.js} +2 -2
  85. package/dist/mg-components/p-ad98f3d8.entry.js.map +1 -0
  86. package/dist/mg-components/{p-2a633b29.entry.js → p-c10433db.entry.js} +2 -2
  87. package/dist/mg-components/{p-f2e6e7ae.entry.js → p-c67e4934.entry.js} +2 -2
  88. package/dist/mg-components/p-f72efb64.entry.js +2 -0
  89. package/dist/mg-components/p-f72efb64.entry.js.map +1 -0
  90. package/dist/mg-components/{p-361cc090.entry.js → p-fd4a7980.entry.js} +2 -2
  91. package/dist/types/components/atoms/mg-button/mg-button.d.ts +1 -1
  92. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +1 -0
  93. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +6 -5
  94. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.conf.d.ts +4 -2
  95. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +8 -2
  96. package/dist/types/components/molecules/mg-table/mg-table.conf.d.ts +19 -0
  97. package/dist/types/components/molecules/mg-table/mg-table.d.ts +58 -0
  98. package/dist/types/components.d.ts +39 -0
  99. package/ide/intellij/web-types.json +69 -5
  100. package/ide/vscode/html-custom-data.json +85 -1
  101. package/package.json +22 -22
  102. package/dist/cjs/index-b7923724.js.map +0 -1
  103. package/dist/cjs/index.es-903492c5.js.map +0 -1
  104. package/dist/cjs/mg-action-more_36.cjs.entry.js.map +0 -1
  105. package/dist/esm/index-a58f8b91.js.map +0 -1
  106. package/dist/esm/index.es-b80b758c.js.map +0 -1
  107. package/dist/esm/mg-action-more_36.entry.js.map +0 -1
  108. package/dist/mg-components/p-3afebdab.entry.js +0 -2
  109. package/dist/mg-components/p-3afebdab.entry.js.map +0 -1
  110. package/dist/mg-components/p-3c6710be.js.map +0 -1
  111. package/dist/mg-components/p-ac8a5083.js +0 -2
  112. package/dist/mg-components/p-bc6ec847.entry.js.map +0 -1
  113. /package/dist/mg-components/{p-2a633b29.entry.js.map → p-c10433db.entry.js.map} +0 -0
  114. /package/dist/mg-components/{p-f2e6e7ae.entry.js.map → p-c67e4934.entry.js.map} +0 -0
  115. /package/dist/mg-components/{p-361cc090.entry.js.map → p-fd4a7980.entry.js.map} +0 -0
@@ -0,0 +1,364 @@
1
+ import { ClassList, toString, createID, isValidString } from "@mgdis/stencil-helpers";
2
+ import { textAlignments, dataTypes, sizes } from "./mg-table.conf";
3
+ import { initLocales } from "../../../locales";
4
+ /**
5
+ * Check if value is a valid align object
6
+ * @param newValue - New value
7
+ * @returns True if value is a valid align object
8
+ */
9
+ const isValidColumnsObject = (newValue) =>
10
+ // ensure newValue is an object
11
+ typeof newValue === 'object' &&
12
+ !Array.isArray(newValue) &&
13
+ // Ensure every property is well formatted
14
+ Object.entries(newValue).every(([key, value]) =>
15
+ // ensure key is a number
16
+ !isNaN(parseInt(key)) &&
17
+ // ensure value is an object
18
+ typeof value === 'object' &&
19
+ !Array.isArray(value) &&
20
+ // ensure value has at least one of the following properties
21
+ ((value.align !== undefined && textAlignments.includes(value.align)) ||
22
+ (value.sortable !== undefined && typeof value.sortable === 'boolean') ||
23
+ (value.datatype !== undefined && dataTypes.includes(value.datatype))) &&
24
+ // ensure no extra properties are present
25
+ Object.keys(value).every(key => ['align', 'sortable', 'datatype'].includes(key)));
26
+ /**
27
+ * Compare values
28
+ * @param firstValue - First value
29
+ * @param secondValue - Second value
30
+ * @param descending - Define descending order
31
+ * @param datatype - Data type
32
+ * @returns Comparison result
33
+ * @example
34
+ * compareValues('a', 'b', false, 'string'); // -1
35
+ */
36
+ const compareValues = (firstValue, secondValue, descending, datatype) => {
37
+ if (descending) {
38
+ const temp = firstValue;
39
+ firstValue = secondValue;
40
+ secondValue = temp;
41
+ }
42
+ if (datatype === 'date') {
43
+ return new Date(firstValue).getTime() - new Date(secondValue).getTime();
44
+ }
45
+ return firstValue.localeCompare(secondValue, undefined, { numeric: datatype === 'numeric' });
46
+ };
47
+ /**
48
+ * @slot - Table content
49
+ */
50
+ export class MgTable {
51
+ constructor() {
52
+ // Classes
53
+ this.componentClass = 'mg-c-table';
54
+ this.componentWrapperClass = 'mg-c-table-wrapper';
55
+ this.classFullWidth = 'mg-c-table--full-width';
56
+ // Alignment stylesheet
57
+ this.alignmentStylesheet = new CSSStyleSheet();
58
+ /**
59
+ * Define table size
60
+ */
61
+ this.size = 'medium';
62
+ /**
63
+ * Define if table fits its parent element
64
+ */
65
+ this.fullWidth = false;
66
+ /**
67
+ * Class collection
68
+ */
69
+ this.classCollection = new ClassList([this.componentClass]);
70
+ }
71
+ watchSize(newValue, oldValue) {
72
+ if (!sizes.includes(newValue)) {
73
+ throw new Error(`<mg-table> prop "size" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);
74
+ }
75
+ else {
76
+ if (oldValue !== undefined) {
77
+ this.classCollection.delete(`mg-c-table--size-${oldValue}`);
78
+ }
79
+ this.classCollection.add(`mg-c-table--size-${newValue}`);
80
+ }
81
+ }
82
+ watchFullWidth(newValue) {
83
+ if (newValue) {
84
+ this.classCollection.add(this.classFullWidth);
85
+ }
86
+ else {
87
+ this.classCollection.delete(this.classFullWidth);
88
+ }
89
+ }
90
+ watchColumns(newValue) {
91
+ if (newValue !== undefined && !isValidColumnsObject(newValue)) {
92
+ throw new Error(`<mg-table> prop "columns" must be a ColumnsType object. Passed value: ${toString(newValue)}.`);
93
+ }
94
+ }
95
+ /**
96
+ * Render Table
97
+ * @param table - Table element
98
+ */
99
+ renderTable(table) {
100
+ let isSortable = false;
101
+ // Remove table classes
102
+ table.className = '';
103
+ // Add table classes
104
+ table.classList.add(...this.classCollection.classes);
105
+ // Set columns based on columns prop
106
+ if (this.columns !== undefined) {
107
+ // Store original rows
108
+ const rowsDefault = Array.from(table.querySelectorAll('tbody tr'));
109
+ // Apply columns settings
110
+ Object.entries(this.columns).forEach(([key, value]) => {
111
+ // Add alignment to stylesheet
112
+ if (value.align !== undefined) {
113
+ this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:${value.align}}}`);
114
+ }
115
+ // if align is not defined and datatype is number, align right
116
+ else if (value.datatype === 'numeric') {
117
+ this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:right}}`);
118
+ }
119
+ // Define if column is sortable
120
+ if (value.sortable) {
121
+ isSortable = true;
122
+ // Add sortable class to table header
123
+ const sortableHeader = table.querySelector(`thead td:nth-child(${key}),thead th:nth-child(${key})`);
124
+ // Create button
125
+ const button = document.createElement('button');
126
+ button.classList.add('mg-c-table__sort-button');
127
+ // Append button to header
128
+ const sortableHeaderContent = sortableHeader.innerHTML;
129
+ sortableHeader.innerHTML = '';
130
+ button.innerHTML = sortableHeaderContent;
131
+ // Set icon
132
+ const icon = document.createElement('mg-icon');
133
+ icon.setAttribute('icon', 'arrows-up-down');
134
+ // Append icon to button
135
+ button.append(icon);
136
+ sortableHeader.append(button);
137
+ // Add event listener
138
+ button.addEventListener('click', () => {
139
+ // Reset aria pressed
140
+ table.querySelectorAll(`thead td:not(:nth-child(${key})) [aria-pressed],thead th:not(:nth-child(${key})) [aria-pressed]`).forEach(ariaPressed => {
141
+ ariaPressed.removeAttribute('aria-pressed');
142
+ ariaPressed.querySelector('mg-icon').setAttribute('icon', 'arrows-up-down');
143
+ });
144
+ // Reset aria sort
145
+ table.querySelectorAll(`thead td:not(:nth-child(${key}))[aria-sort],thead th:not(:nth-child(${key}))[aria-sort]`).forEach(ariaSort => {
146
+ ariaSort.removeAttribute('aria-sort');
147
+ });
148
+ // Set aria pressed
149
+ button.setAttribute('aria-pressed', 'true');
150
+ // Manage sort order
151
+ // Get sort order
152
+ let sortOrder = sortableHeader.getAttribute('aria-sort');
153
+ // First click sort asc
154
+ if ([null, 'none'].includes(sortOrder)) {
155
+ sortableHeader.setAttribute('aria-sort', 'ascending');
156
+ }
157
+ // Second click sort desc
158
+ else if (sortOrder === 'ascending') {
159
+ sortableHeader.setAttribute('aria-sort', 'descending');
160
+ }
161
+ // Third click remove sort
162
+ else {
163
+ sortableHeader.setAttribute('aria-sort', 'none');
164
+ }
165
+ // Update sort order
166
+ sortOrder = sortableHeader.getAttribute('aria-sort');
167
+ // Update button icon
168
+ const icon = button.querySelector('mg-icon');
169
+ let iconType = 'arrows-up-down';
170
+ if (sortOrder === 'ascending') {
171
+ iconType = 'arrow-up';
172
+ }
173
+ else if (sortOrder === 'descending') {
174
+ iconType = 'arrow-down';
175
+ }
176
+ icon.setAttribute('icon', iconType);
177
+ // If sort order is none, return to original order
178
+ if (sortOrder === 'none') {
179
+ // Append rows to table
180
+ rowsDefault.forEach(row => table.querySelector('tbody').append(row));
181
+ return;
182
+ }
183
+ // Set a copy of rows
184
+ const rows = Array.from(table.querySelectorAll('tbody tr'));
185
+ // Sort rows
186
+ rows.sort((a, b) => {
187
+ var _a, _b;
188
+ // Get cells
189
+ const cellA = a.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);
190
+ const cellB = b.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);
191
+ // Get cell values
192
+ const cellValueA = (_a = cellA.dataset.sort) !== null && _a !== void 0 ? _a : cellA.textContent;
193
+ const cellValueB = (_b = cellB.dataset.sort) !== null && _b !== void 0 ? _b : cellB.textContent;
194
+ // Sort cells based on sort order
195
+ return compareValues(cellValueA, cellValueB, sortOrder === 'descending', value.datatype);
196
+ });
197
+ // Append rows to table
198
+ rows.forEach(row => table.querySelector('tbody').append(row));
199
+ });
200
+ }
201
+ });
202
+ }
203
+ // Add alignment to columns
204
+ this.element.shadowRoot.adoptedStyleSheets = [...this.element.shadowRoot.adoptedStyleSheets, this.alignmentStylesheet];
205
+ // Create div wrapper for responsive behavior
206
+ const divWrapper = document.createElement('div');
207
+ divWrapper.setAttribute('class', this.componentWrapperClass);
208
+ divWrapper.setAttribute('tabindex', '0');
209
+ divWrapper.setAttribute('role', 'region');
210
+ // Get table title
211
+ let captionTable = table.querySelector('caption');
212
+ // If table is sortable we must add a caption
213
+ if (captionTable === null && isSortable) {
214
+ captionTable = document.createElement('caption');
215
+ table.prepend(captionTable);
216
+ }
217
+ if (captionTable !== null) {
218
+ // Ensure caption is not visible (otherwhise the table does not have rounded corners)
219
+ captionTable.className = 'mg-u-visually-hidden';
220
+ // Link caption to div
221
+ if (!isValidString(captionTable.id)) {
222
+ captionTable.setAttribute('id', createID(`${this.componentClass}-caption`));
223
+ }
224
+ divWrapper.setAttribute('aria-labelledby', captionTable.id);
225
+ // Add sortable caption if neeeded
226
+ if (isSortable) {
227
+ captionTable.innerHTML = `${captionTable.innerHTML} ${this.messages.table.sortableCaption}`.trim();
228
+ }
229
+ }
230
+ divWrapper.append(table);
231
+ // Remove existing table from shadow root
232
+ const existingTable = this.element.shadowRoot.querySelector(`.${this.componentWrapperClass}`);
233
+ if (existingTable !== null) {
234
+ existingTable.remove();
235
+ }
236
+ // Append table
237
+ this.element.shadowRoot.append(divWrapper);
238
+ }
239
+ /*************
240
+ * Lifecycle *
241
+ *************/
242
+ componentWillLoad() {
243
+ this.messages = initLocales(this.element).messages;
244
+ }
245
+ /**
246
+ * Set variables and validate props
247
+ */
248
+ componentDidLoad() {
249
+ this.watchSize(this.size);
250
+ this.watchFullWidth(this.fullWidth);
251
+ this.watchColumns(this.columns);
252
+ this.renderTable(this.element.querySelector('table'));
253
+ }
254
+ /**
255
+ * Update table
256
+ */
257
+ componentWillUpdate() {
258
+ this.renderTable(this.element.shadowRoot.querySelector('table'));
259
+ }
260
+ static get is() { return "mg-table"; }
261
+ static get encapsulation() { return "shadow"; }
262
+ static get originalStyleUrls() {
263
+ return {
264
+ "$": ["../../../../node_modules/@mgdis/styles/dist/components/mg-table.css"]
265
+ };
266
+ }
267
+ static get styleUrls() {
268
+ return {
269
+ "$": ["../../../../node_modules/@mgdis/styles/dist/components/mg-table.css"]
270
+ };
271
+ }
272
+ static get properties() {
273
+ return {
274
+ "size": {
275
+ "type": "string",
276
+ "mutable": false,
277
+ "complexType": {
278
+ "original": "TableSizeType",
279
+ "resolved": "\"large\" | \"medium\" | \"small\" | \"xlarge\"",
280
+ "references": {
281
+ "TableSizeType": {
282
+ "location": "import",
283
+ "path": "./mg-table.conf",
284
+ "id": "src/components/molecules/mg-table/mg-table.conf.ts::TableSizeType"
285
+ }
286
+ }
287
+ },
288
+ "required": false,
289
+ "optional": false,
290
+ "docs": {
291
+ "tags": [],
292
+ "text": "Define table size"
293
+ },
294
+ "getter": false,
295
+ "setter": false,
296
+ "attribute": "size",
297
+ "reflect": false,
298
+ "defaultValue": "'medium'"
299
+ },
300
+ "fullWidth": {
301
+ "type": "boolean",
302
+ "mutable": false,
303
+ "complexType": {
304
+ "original": "boolean",
305
+ "resolved": "boolean",
306
+ "references": {}
307
+ },
308
+ "required": false,
309
+ "optional": false,
310
+ "docs": {
311
+ "tags": [],
312
+ "text": "Define if table fits its parent element"
313
+ },
314
+ "getter": false,
315
+ "setter": false,
316
+ "attribute": "full-width",
317
+ "reflect": false,
318
+ "defaultValue": "false"
319
+ },
320
+ "columns": {
321
+ "type": "unknown",
322
+ "mutable": false,
323
+ "complexType": {
324
+ "original": "ColumnsType",
325
+ "resolved": "{ [key: number]: { align?: \"center\" | \"right\" | \"left\"; sortable?: boolean; datatype?: \"string\" | \"numeric\" | \"date\"; }; }",
326
+ "references": {
327
+ "ColumnsType": {
328
+ "location": "import",
329
+ "path": "./mg-table.conf",
330
+ "id": "src/components/molecules/mg-table/mg-table.conf.ts::ColumnsType"
331
+ }
332
+ }
333
+ },
334
+ "required": false,
335
+ "optional": false,
336
+ "docs": {
337
+ "tags": [],
338
+ "text": "Define column properties"
339
+ },
340
+ "getter": false,
341
+ "setter": false
342
+ }
343
+ };
344
+ }
345
+ static get states() {
346
+ return {
347
+ "classCollection": {}
348
+ };
349
+ }
350
+ static get elementRef() { return "element"; }
351
+ static get watchers() {
352
+ return [{
353
+ "propName": "size",
354
+ "methodName": "watchSize"
355
+ }, {
356
+ "propName": "fullWidth",
357
+ "methodName": "watchFullWidth"
358
+ }, {
359
+ "propName": "columns",
360
+ "methodName": "watchColumns"
361
+ }];
362
+ }
363
+ }
364
+ //# sourceMappingURL=mg-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mg-table.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-table/mg-table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,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B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, State, Prop, Watch } from '@stencil/core';\nimport { ClassList, toString, createID, isValidString } from '@mgdis/stencil-helpers';\nimport { type TableSizeType, type ColumnsType, type datatypesType, textAlignments, dataTypes, sizes } from './mg-table.conf';\nimport { initLocales } from '../../../locales';\n\n/**\n * Check if value is a valid align object\n * @param newValue - New value\n * @returns True if value is a valid align object\n */\nconst isValidColumnsObject = (newValue: ColumnsType): boolean =>\n // ensure newValue is an object\n typeof newValue === 'object' &&\n !Array.isArray(newValue) &&\n // Ensure every property is well formatted\n Object.entries(newValue).every(\n ([key, value]) =>\n // ensure key is a number\n !isNaN(parseInt(key)) &&\n // ensure value is an object\n typeof value === 'object' &&\n !Array.isArray(value) &&\n // ensure value has at least one of the following properties\n ((value.align !== undefined && textAlignments.includes(value.align)) ||\n (value.sortable !== undefined && typeof value.sortable === 'boolean') ||\n (value.datatype !== undefined && dataTypes.includes(value.datatype))) &&\n // ensure no extra properties are present\n Object.keys(value).every(key => ['align', 'sortable', 'datatype'].includes(key)),\n );\n\n/**\n * Compare values\n * @param firstValue - First value\n * @param secondValue - Second value\n * @param descending - Define descending order\n * @param datatype - Data type\n * @returns Comparison result\n * @example\n * compareValues('a', 'b', false, 'string'); // -1\n */\nconst compareValues = (firstValue: string, secondValue: string, descending: boolean, datatype: datatypesType): number => {\n if (descending) {\n const temp = firstValue;\n firstValue = secondValue;\n secondValue = temp;\n }\n if (datatype === 'date') {\n return new Date(firstValue).getTime() - new Date(secondValue).getTime();\n }\n return firstValue.localeCompare(secondValue, undefined, { numeric: datatype === 'numeric' });\n};\n\n/**\n * @slot - Table content\n */\n@Component({\n tag: 'mg-table',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-table.css',\n shadow: true,\n})\nexport class MgTable {\n /************\n * Internal *\n ************/\n\n private messages;\n\n // Classes\n private readonly componentClass = 'mg-c-table';\n private readonly componentWrapperClass = 'mg-c-table-wrapper';\n private readonly classFullWidth = 'mg-c-table--full-width';\n\n // Alignment stylesheet\n private alignmentStylesheet = new CSSStyleSheet();\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTableElement;\n\n /**\n * Define table size\n */\n @Prop() size: TableSizeType = 'medium';\n @Watch('size')\n watchSize(newValue: MgTable['size'], oldValue?: MgTable['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<mg-table> prop \"size\" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-table--size-${oldValue}`);\n }\n this.classCollection.add(`mg-c-table--size-${newValue}`);\n }\n }\n\n /**\n * Define if table fits its parent element\n */\n @Prop() fullWidth = false;\n @Watch('fullWidth')\n watchFullWidth(newValue: MgTable['fullWidth']): void {\n if (newValue) {\n this.classCollection.add(this.classFullWidth);\n } else {\n this.classCollection.delete(this.classFullWidth);\n }\n }\n\n /**\n * Define column properties\n */\n @Prop() columns: ColumnsType;\n @Watch('columns')\n watchColumns(newValue: ColumnsType): void {\n if (newValue !== undefined && !isValidColumnsObject(newValue)) {\n throw new Error(`<mg-table> prop \"columns\" must be a ColumnsType object. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Class collection\n */\n @State() classCollection: ClassList = new ClassList([this.componentClass]);\n\n /**\n * Render Table\n * @param table - Table element\n */\n private renderTable(table: HTMLTableElement): void {\n let isSortable = false;\n // Remove table classes\n table.className = '';\n // Add table classes\n table.classList.add(...this.classCollection.classes);\n\n // Set columns based on columns prop\n if (this.columns !== undefined) {\n // Store original rows\n const rowsDefault = Array.from(table.querySelectorAll('tbody tr'));\n\n // Apply columns settings\n Object.entries(this.columns).forEach(([key, value]) => {\n // Add alignment to stylesheet\n if (value.align !== undefined) {\n this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:${value.align}}}`);\n }\n // if align is not defined and datatype is number, align right\n else if (value.datatype === 'numeric') {\n this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:right}}`);\n }\n\n // Define if column is sortable\n if (value.sortable) {\n isSortable = true;\n // Add sortable class to table header\n const sortableHeader = table.querySelector(`thead td:nth-child(${key}),thead th:nth-child(${key})`);\n\n // Create button\n const button = document.createElement('button');\n button.classList.add('mg-c-table__sort-button');\n\n // Append button to header\n const sortableHeaderContent = sortableHeader.innerHTML;\n sortableHeader.innerHTML = '';\n button.innerHTML = sortableHeaderContent;\n\n // Set icon\n const icon = document.createElement('mg-icon');\n icon.setAttribute('icon', 'arrows-up-down');\n\n // Append icon to button\n button.append(icon);\n sortableHeader.append(button);\n\n // Add event listener\n button.addEventListener('click', (): void => {\n // Reset aria pressed\n table.querySelectorAll(`thead td:not(:nth-child(${key})) [aria-pressed],thead th:not(:nth-child(${key})) [aria-pressed]`).forEach(ariaPressed => {\n ariaPressed.removeAttribute('aria-pressed');\n ariaPressed.querySelector('mg-icon').setAttribute('icon', 'arrows-up-down');\n });\n // Reset aria sort\n table.querySelectorAll(`thead td:not(:nth-child(${key}))[aria-sort],thead th:not(:nth-child(${key}))[aria-sort]`).forEach(ariaSort => {\n ariaSort.removeAttribute('aria-sort');\n });\n\n // Set aria pressed\n button.setAttribute('aria-pressed', 'true');\n\n // Manage sort order\n // Get sort order\n let sortOrder = sortableHeader.getAttribute('aria-sort');\n\n // First click sort asc\n if ([null, 'none'].includes(sortOrder)) {\n sortableHeader.setAttribute('aria-sort', 'ascending');\n }\n // Second click sort desc\n else if (sortOrder === 'ascending') {\n sortableHeader.setAttribute('aria-sort', 'descending');\n }\n // Third click remove sort\n else {\n sortableHeader.setAttribute('aria-sort', 'none');\n }\n\n // Update sort order\n sortOrder = sortableHeader.getAttribute('aria-sort');\n\n // Update button icon\n const icon = button.querySelector('mg-icon');\n let iconType = 'arrows-up-down';\n if (sortOrder === 'ascending') {\n iconType = 'arrow-up';\n } else if (sortOrder === 'descending') {\n iconType = 'arrow-down';\n }\n icon.setAttribute('icon', iconType);\n\n // If sort order is none, return to original order\n if (sortOrder === 'none') {\n // Append rows to table\n rowsDefault.forEach(row => table.querySelector('tbody').append(row));\n return;\n }\n\n // Set a copy of rows\n const rows = Array.from(table.querySelectorAll('tbody tr'));\n\n // Sort rows\n rows.sort((a, b) => {\n // Get cells\n const cellA: HTMLTableCellElement = a.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);\n const cellB: HTMLTableCellElement = b.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);\n\n // Get cell values\n const cellValueA = cellA.dataset.sort ?? cellA.textContent;\n const cellValueB = cellB.dataset.sort ?? cellB.textContent;\n\n // Sort cells based on sort order\n return compareValues(cellValueA, cellValueB, sortOrder === 'descending', value.datatype);\n });\n\n // Append rows to table\n rows.forEach(row => table.querySelector('tbody').append(row));\n });\n }\n });\n }\n\n // Add alignment to columns\n this.element.shadowRoot.adoptedStyleSheets = [...this.element.shadowRoot.adoptedStyleSheets, this.alignmentStylesheet];\n\n // Create div wrapper for responsive behavior\n const divWrapper = document.createElement('div');\n divWrapper.setAttribute('class', this.componentWrapperClass);\n divWrapper.setAttribute('tabindex', '0');\n divWrapper.setAttribute('role', 'region');\n\n // Get table title\n let captionTable = table.querySelector('caption');\n\n // If table is sortable we must add a caption\n if (captionTable === null && isSortable) {\n captionTable = document.createElement('caption');\n table.prepend(captionTable);\n }\n\n if (captionTable !== null) {\n // Ensure caption is not visible (otherwhise the table does not have rounded corners)\n captionTable.className = 'mg-u-visually-hidden';\n\n // Link caption to div\n if (!isValidString(captionTable.id)) {\n captionTable.setAttribute('id', createID(`${this.componentClass}-caption`));\n }\n divWrapper.setAttribute('aria-labelledby', captionTable.id);\n\n // Add sortable caption if neeeded\n if (isSortable) {\n captionTable.innerHTML = `${captionTable.innerHTML} ${this.messages.table.sortableCaption}`.trim();\n }\n }\n divWrapper.append(table);\n\n // Remove existing table from shadow root\n const existingTable = this.element.shadowRoot.querySelector(`.${this.componentWrapperClass}`);\n if (existingTable !== null) {\n existingTable.remove();\n }\n // Append table\n this.element.shadowRoot.append(divWrapper);\n }\n\n /*************\n * Lifecycle *\n *************/\n\n componentWillLoad(): void {\n this.messages = initLocales(this.element).messages;\n }\n\n /**\n * Set variables and validate props\n */\n componentDidLoad(): void {\n this.watchSize(this.size);\n this.watchFullWidth(this.fullWidth);\n this.watchColumns(this.columns);\n this.renderTable(this.element.querySelector('table'));\n }\n\n /**\n * Update table\n */\n componentWillUpdate(): void {\n this.renderTable(this.element.shadowRoot.querySelector('table'));\n }\n}\n"]}
@@ -1,17 +1,6 @@
1
1
  {
2
2
  "errors": {
3
- "required": "This field is required.",
4
- "date": {
5
- "badInput": "The date is incorrect, the format must be {pattern}",
6
- "min": "The date cannot be earlier than {min}",
7
- "max": "The date cannot be later than {max}",
8
- "minMax": "The date must be between {min} and {max}"
9
- },
10
- "numeric": {
11
- "min": "The value cannot be less than {min}",
12
- "max": "The value cannot be greater than {max}",
13
- "minMax": "The value must be between {min} and {max}"
14
- }
3
+ "required": "This field is required."
15
4
  },
16
5
  "nbCharLeft": "{counter} characters left.",
17
6
  "input": {
@@ -32,29 +21,54 @@
32
21
  "sections": {
33
22
  "selected": {
34
23
  "title": "Selected",
35
- "titlePlurial": "Selected",
24
+ "titlePlural": "Selected",
36
25
  "action": "Unselect all",
37
26
  "tooltip": "Unselect all current search results"
38
27
  },
39
28
  "notSelected": {
40
29
  "title": "Not selected",
41
- "titlePlurial": "Not selected",
30
+ "titlePlural": "Not selected",
42
31
  "action": "Select all",
43
32
  "tooltip": "Select all current search results"
44
33
  }
45
34
  }
46
35
  },
47
36
  "date": {
48
- "helpText": "Expected format: {pattern} (ex: {date})",
49
37
  "pattern": {
50
38
  "dd": "dd",
51
39
  "mm": "mm",
52
40
  "yyyy": "yyyy"
41
+ },
42
+ "helpText": {
43
+ "expectedFormat": "Expected format: {pattern} (ex: {date})",
44
+ "min": "The date must be after {min}",
45
+ "max": "The date must be before {max}",
46
+ "minMax": "The date must be between {min} and {max}"
47
+ },
48
+ "error": {
49
+ "badInput": "The date is incorrect, the format must be {pattern} (ex: {date})"
50
+ }
51
+ },
52
+ "numeric": {
53
+ "helpText": {
54
+ "min": "The value must be greater than {min}",
55
+ "max": "The value must be less than {max}",
56
+ "minMax": "The value must be between {min} and {max}"
53
57
  }
54
58
  },
55
59
  "password": {
56
60
  "display": "Display password value",
57
61
  "hide": "Hide password value"
62
+ },
63
+ "text": {
64
+ "helpText": {
65
+ "email": "Expected format: name@example.com",
66
+ "emails": "Expected format: first@example.com, second@example.com",
67
+ "url": "Expected format: https://example.com"
68
+ },
69
+ "errors": {
70
+ "typeMismatch": "The value is incorrect."
71
+ }
58
72
  }
59
73
  },
60
74
  "form": {
@@ -101,6 +115,9 @@
101
115
  "label": "Actions"
102
116
  },
103
117
  "loader": {
104
- "inProgess": "Loading in progress…"
118
+ "inProgress": "Loading in progress…"
119
+ },
120
+ "table": {
121
+ "sortableCaption": "(column headers with buttons are sortable)"
105
122
  }
106
123
  }
@@ -1,17 +1,6 @@
1
1
  {
2
2
  "errors": {
3
- "required": "Ce champ est obligatoire.",
4
- "date": {
5
- "badInput": "La date est incorrecte, le format doit être du type {pattern}",
6
- "min": "La date ne peut pas être antérieure au {min}",
7
- "max": "La date ne peut pas être postérieure au {max}",
8
- "minMax": "La date doit être comprise entre le {min} et le {max}"
9
- },
10
- "numeric": {
11
- "min": "La valeur ne peut pas être inférieure à {min}",
12
- "max": "La valeur ne peut pas être supérieure à {max}",
13
- "minMax": "La valeur doit être comprise entre {min} et {max}"
14
- }
3
+ "required": "Ce champ est obligatoire."
15
4
  },
16
5
  "nbCharLeft": "{counter} caractères disponibles.",
17
6
  "input": {
@@ -19,42 +8,67 @@
19
8
  "placeholder": "Sélectionnez une valeur"
20
9
  },
21
10
  "checkbox": {
22
- "selectedValues": "{nb} valeurs selectionnées",
23
- "selectedValue": "{nb} valeur selectionnée",
11
+ "selectedValues": "{nb} valeurs sélectionnées",
12
+ "selectedValue": "{nb} valeur sélectionnée",
24
13
  "editButton": "Modifier",
25
14
  "selectButton": "Sélectionner des valeurs",
26
15
  "showButton": "Voir",
27
16
  "label": "Saisissez une valeur",
28
17
  "result": "résultat",
29
18
  "results": "résultats",
30
- "searchResults": "List de résultat(s) de la recherche.",
19
+ "searchResults": "Liste de résultat(s) de la recherche.",
31
20
  "noResult": "Aucun résultat.",
32
21
  "sections": {
33
22
  "selected": {
34
23
  "title": "Sélectionné",
35
- "titlePlurial": "Sélectionnés",
24
+ "titlePlural": "Sélectionnés",
36
25
  "action": "Tout désélectionner",
37
26
  "tooltip": "Désélectionne tous les résultats de la recherche en cours"
38
27
  },
39
28
  "notSelected": {
40
29
  "title": "Non sélectionné",
41
- "titlePlurial": "Non sélectionnés",
30
+ "titlePlural": "Non sélectionnés",
42
31
  "action": "Tout sélectionner",
43
32
  "tooltip": "Sélectionne tous les résultats de la recherche en cours"
44
33
  }
45
34
  }
46
35
  },
47
36
  "date": {
48
- "helpText": "Format attendu&nbsp;: {pattern} (ex&nbsp;: {date})",
49
37
  "pattern": {
50
38
  "dd": "jj",
51
39
  "mm": "mm",
52
40
  "yyyy": "aaaa"
41
+ },
42
+ "helpText": {
43
+ "expectedFormat": "Format attendu&nbsp;: {pattern} (ex&nbsp;: {date})",
44
+ "min": "La date doit être postérieure au {min}",
45
+ "max": "La date doit être antérieure au {max}",
46
+ "minMax": "La date doit être comprise entre le {min} et le {max}"
47
+ },
48
+ "error": {
49
+ "badInput": "La date est incorrecte, le format doit être du type {pattern} (ex&nbsp;: {date})"
50
+ }
51
+ },
52
+ "numeric": {
53
+ "helpText": {
54
+ "min": "La valeur doit être supérieure à {min}",
55
+ "max": "La valeur doit être inférieure à {max}",
56
+ "minMax": "La valeur doit être comprise entre {min} et {max}"
53
57
  }
54
58
  },
55
59
  "password": {
56
60
  "display": "Afficher le mot de passe",
57
61
  "hide": "Masquer le mot de passe"
62
+ },
63
+ "text": {
64
+ "helpText": {
65
+ "email": "Format attendu&nbsp;: nom@exemple.fr",
66
+ "emails": "Format attendu&nbsp;: premier@exemple.fr, second@exemple.fr",
67
+ "url": "Format attendu&nbsp;: https://exemple.fr"
68
+ },
69
+ "errors": {
70
+ "typeMismatch": "La valeur est incorrecte."
71
+ }
58
72
  }
59
73
  },
60
74
  "form": {
@@ -101,6 +115,9 @@
101
115
  "label": "Actions"
102
116
  },
103
117
  "loader": {
104
- "inProgess": "Chargement en cours…"
118
+ "inProgress": "Chargement en cours…"
119
+ },
120
+ "table": {
121
+ "sortableCaption": "(les en-têtes de colonnes avec des boutons peuvent être triés)"
105
122
  }
106
123
  }
@@ -112,7 +112,7 @@ const ft = (e) => {
112
112
  locale: i,
113
113
  messages: t[o] || t[s] || { lang: s }
114
114
  };
115
- }, ut = (e, t, s) => new Intl.NumberFormat(t, { style: "currency", currency: s }).format(e), dt = (e, t, s = 0) => new Intl.NumberFormat(t, { minimumFractionDigits: s }).format(s > 0 ? Number(e == null ? void 0 : e.toFixed(s)) : e), gt = (e, t, s = 0) => new Intl.NumberFormat(t, {
115
+ }, ut = (e, t, s) => new Intl.NumberFormat(t, { style: "currency", currency: s }).format(e), dt = (e, t, s = 0) => new Intl.NumberFormat(t, { minimumFractionDigits: s }).format(Number(e)), gt = (e, t, s = 0) => new Intl.NumberFormat(t, {
116
116
  style: "percent",
117
117
  minimumFractionDigits: s,
118
118
  maximumFractionDigits: s