@mgdis/mg-components 6.20.0 → 6.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-Bp6wZzau.js → index-C2viYwrR.js} +1757 -80
- package/dist/cjs/{index-TUElr4Wv.js → index-CCsGMNyq.js} +46 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_37.cjs.entry.js +684 -273
- package/dist/cjs/mg-alert.cjs.entry.js +17 -9
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-fieldset.cjs.entry.js +24 -7
- package/dist/cjs/mg-input-combobox.cjs.entry.js +48 -18
- package/dist/cjs/mg-input-file.cjs.entry.js +384 -0
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +30 -18
- package/dist/cjs/{mg-input.conf-D7jmj_lh.js → mg-input.conf-BNpeATnq.js} +7 -0
- package/dist/cjs/mg-loader.cjs.entry.js +8 -6
- package/dist/cjs/mg-progress.cjs.entry.js +19 -9
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +6 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-file/mg-input-file.js +877 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +12 -12
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
- package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +12 -3
- package/dist/collection/components/molecules/mg-form/mg-form.js +12 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/collection/locales/en/messages.json +11 -0
- package/dist/collection/locales/fr/messages.json +11 -0
- package/dist/components/events.utils.js +1 -23
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -1
- package/dist/components/index2.js +1 -408
- package/dist/components/index3.js +1 -476
- package/dist/components/mg-action-more.js +1 -254
- package/dist/components/mg-alert.js +1 -224
- package/dist/components/mg-badge.js +1 -6
- package/dist/components/mg-badge2.js +1 -113
- package/dist/components/mg-button.js +1 -6
- package/dist/components/mg-button2.js +1 -275
- package/dist/components/mg-card.js +1 -6
- package/dist/components/mg-card2.js +1 -92
- package/dist/components/mg-character-left.js +1 -6
- package/dist/components/mg-character-left2.js +1 -75
- package/dist/components/mg-details.js +1 -104
- package/dist/components/mg-divider.js +1 -6
- package/dist/components/mg-divider2.js +1 -49
- package/dist/components/mg-fieldset.js +1 -209
- package/dist/components/mg-form.js +1 -302
- package/dist/components/mg-icon.js +1 -6
- package/dist/components/mg-icon2.js +1 -188
- package/dist/components/mg-illustrated-message.js +1 -129
- package/dist/components/mg-input-checkbox-paginated.js +1 -6
- package/dist/components/mg-input-checkbox-paginated2.js +1 -135
- package/dist/components/mg-input-checkbox.js +1 -762
- package/dist/components/mg-input-combobox.js +1 -940
- package/dist/components/mg-input-date.js +1 -463
- package/dist/components/mg-input-file.d.ts +11 -0
- package/dist/components/mg-input-file.js +1 -0
- package/dist/components/mg-input-numeric.js +1 -592
- package/dist/components/mg-input-password.js +1 -360
- package/dist/components/mg-input-radio.js +1 -392
- package/dist/components/mg-input-rich-text-editor.js +1 -16797
- package/dist/components/mg-input-select.js +1 -6
- package/dist/components/mg-input-select2.js +1 -481
- package/dist/components/mg-input-text.js +1 -6
- package/dist/components/mg-input-text2.js +1 -514
- package/dist/components/mg-input-textarea.js +1 -412
- package/dist/components/mg-input-title.js +1 -6
- package/dist/components/mg-input-title2.js +1 -81
- package/dist/components/mg-input-toggle.js +1 -371
- package/dist/components/mg-input.conf.js +1 -0
- package/dist/components/mg-input.js +1 -6
- package/dist/components/mg-input2.js +1 -459
- package/dist/components/mg-item-more.js +1 -6
- package/dist/components/mg-item-more2.js +1 -505
- package/dist/components/mg-loader.js +1 -6
- package/dist/components/mg-loader2.js +1 -74
- package/dist/components/mg-menu-item.js +1 -6
- package/dist/components/mg-menu-item2.js +1 -485
- package/dist/components/mg-menu.js +1 -6
- package/dist/components/mg-message.js +1 -6
- package/dist/components/mg-message2.js +1 -146
- package/dist/components/mg-modal.js +1 -184
- package/dist/components/mg-pagination.js +1 -234
- package/dist/components/mg-panel.js +1 -350
- package/dist/components/mg-popover-content.js +1 -6
- package/dist/components/mg-popover-content2.js +1 -96
- package/dist/components/mg-popover.js +1 -6
- package/dist/components/mg-popover2.js +1 -312
- package/dist/components/mg-progress.js +1 -123
- package/dist/components/mg-skip-links.js +1 -78
- package/dist/components/mg-table.js +1 -319
- package/dist/components/mg-tabs.js +1 -6
- package/dist/components/mg-tabs2.js +1 -315
- package/dist/components/mg-tag.js +1 -133
- package/dist/components/mg-tooltip-content.js +1 -6
- package/dist/components/mg-tooltip-content2.js +1 -42
- package/dist/components/mg-tooltip.js +1 -6
- package/dist/components/mg-tooltip2.js +1 -421
- package/dist/components/popper.js +1 -1790
- package/dist/esm/{index-CNX6lq0x.js → index-D-uaxCxH.js} +46 -1
- package/dist/esm/{index-BluNKQ3L.js → index-DFwaH2hS.js} +1757 -80
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_37.entry.js +684 -273
- package/dist/esm/mg-alert.entry.js +17 -9
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-fieldset.entry.js +24 -7
- package/dist/esm/mg-input-combobox.entry.js +48 -18
- package/dist/esm/mg-input-file.entry.js +382 -0
- package/dist/esm/mg-input-rich-text-editor.entry.js +30 -18
- package/dist/esm/{mg-input.conf-DDnrE1hD.js → mg-input.conf-C9rmNQIL.js} +7 -1
- package/dist/esm/mg-loader.entry.js +8 -6
- package/dist/esm/mg-progress.entry.js +19 -9
- package/dist/mg-components/locales/en/messages.json +11 -0
- package/dist/mg-components/locales/fr/messages.json +11 -0
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-d5a276eb.entry.js → p-08fa327b.entry.js} +1 -1
- package/dist/mg-components/p-4175dcbe.entry.js +1 -0
- package/dist/mg-components/{p-7132bca1.entry.js → p-6b57f249.entry.js} +1 -1
- package/dist/mg-components/p-6b655830.entry.js +1 -0
- package/dist/mg-components/p-988c282e.entry.js +1 -0
- package/dist/mg-components/p-C9rmNQIL.js +1 -0
- package/dist/mg-components/p-D-uaxCxH.js +1 -0
- package/dist/mg-components/p-DFwaH2hS.js +2 -0
- package/dist/mg-components/p-a79b1f19.entry.js +1 -0
- package/dist/mg-components/{p-916dfb6d.entry.js → p-c3d116b9.entry.js} +1 -1
- package/dist/mg-components/p-dd1934f4.entry.js +1 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +7 -1
- package/dist/types/components/molecules/inputs/mg-input-file/mg-input-file.d.ts +210 -0
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -4
- package/dist/types/components.d.ts +211 -10
- package/dist/types/stencil-public-runtime.d.ts +76 -12
- package/ide/intellij/web-types.json +356 -12
- package/ide/vscode/html-custom-data.json +338 -76
- package/package.json +19 -19
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.scss +0 -1
- package/dist/mg-components/p-016bd291.entry.js +0 -1
- package/dist/mg-components/p-186a6139.entry.js +0 -1
- package/dist/mg-components/p-BluNKQ3L.js +0 -2
- package/dist/mg-components/p-CNX6lq0x.js +0 -1
- package/dist/mg-components/p-DDnrE1hD.js +0 -1
- package/dist/mg-components/p-cd061b38.entry.js +0 -1
- package/dist/mg-components/p-d2c72f09.entry.js +0 -1
- package/ide/vscode/custom.css-data.json +0 -425
|
@@ -1,319 +1 @@
|
|
|
1
|
-
import
|
|
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 i,t as o,i as n,c as l}from"./index2.js";import{i as r}from"./index3.js";import{d as s}from"./mg-icon2.js";const c=["small","medium","large","xlarge"],h=["left","center","right"],m=["string","numeric","date"],g=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.alignmentStylesheet=new CSSStyleSheet,this.size="medium",this.fullWidth=!1,this.classCollection=new i([this.componentClass])}watchSize(t,e){if(!c.includes(t))throw Error(`<mg-table> prop "size" must be one of: ${c.join(", ")}. Passed value: ${o(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)}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&&h.includes(e.align)||void 0!==e.sortable&&"boolean"==typeof e.sortable||void 0!==e.datatype&&m.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: ${o(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((([i,o])=>{if(void 0!==o.align?this.alignmentStylesheet.insertRule(`.${this.componentClass} th:nth-child(${i}),td:nth-child(${i}){text-align:${o.align};&>*{display:inline-block;}}`):"numeric"===o.datatype&&this.alignmentStylesheet.insertRule(`.${this.componentClass} th:nth-child(${i}),td:nth-child(${i}){text-align:right;&>*{display:inline-block;}}`),o.sortable){e=!0;const n=t.querySelector(`thead td:nth-child(${i}),thead th:nth-child(${i})`),l=document.createElement("button");l.classList.add("mg-c-table__sort-button");const r=n.innerHTML;n.innerHTML="",l.innerHTML=r;const s=document.createElement("mg-icon");s.setAttribute("icon","arrows-up-down"),l.append(s),n.append(l),l.addEventListener("click",(()=>{t.querySelectorAll(`thead td:not(:nth-child(${i})) [aria-pressed],thead th:not(:nth-child(${i})) [aria-pressed]`).forEach((t=>{t.removeAttribute("aria-pressed"),t.querySelector("mg-icon").setAttribute("icon","arrows-up-down")})),t.querySelectorAll(`thead td:not(:nth-child(${i}))[aria-sort],thead th:not(:nth-child(${i}))[aria-sort]`).forEach((t=>{t.removeAttribute("aria-sort")})),l.setAttribute("aria-pressed","true");let e=n.getAttribute("aria-sort");n.setAttribute("aria-sort",[null,"none"].includes(e)?"ascending":"ascending"===e?"descending":"none"),e=n.getAttribute("aria-sort");const r=l.querySelector("mg-icon");let s="arrows-up-down";if("ascending"===e?s="arrow-up":"descending"===e&&(s="arrow-down"),r.setAttribute("icon",s),"none"===e)return void a.forEach((e=>t.querySelector("tbody").append(e)));const c=Array.from(t.querySelectorAll("tbody tr"));c.sort(((t,a)=>{var n,l;const r=t.querySelector(`td:nth-child(${i}),th:nth-child(${i})`),s=a.querySelector(`td:nth-child(${i}),th:nth-child(${i})`);return((t,e,a,i)=>{if(a){const a=t;t=e,e=a}return"date"===i?new Date(t).getTime()-new Date(e).getTime():t.localeCompare(e,void 0,{numeric:"numeric"===i})})(null!==(n=r.dataset.sort)&&void 0!==n?n:r.textContent,null!==(l=s.dataset.sort)&&void 0!==l?l:s.textContent,"descending"===e,o.datatype)})),c.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 i=t.querySelector("caption");null===i&&e&&(i=document.createElement("caption"),t.prepend(i)),null!==i&&(i.className="mg-u-visually-hidden",n(i.id)||i.setAttribute("id",l(this.componentClass+"-caption")),a.setAttribute("aria-labelledby",i.id),e&&(i.innerHTML=`${i.innerHTML} ${this.messages.table.sortableCaption}`.trim())),a.append(t);const o=this.element.shadowRoot.querySelector("."+this.componentWrapperClass);null!==o&&o.remove(),this.element.shadowRoot.append(a)}componentWillLoad(){this.messages=r(this.element).messages}componentDidLoad(){this.watchSize(this.size),this.watchFullWidth(this.fullWidth),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}],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);--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)}'}},[1,"mg-table",{size:[1],fullWidth:[4,"full-width"],columns:[16],classCollection:[32]},void 0,{size:[{watchSize:0}],fullWidth:[{watchFullWidth:0}],columns:[{watchColumns:0}]}]);function d(){"undefined"!=typeof customElements&&["mg-table","mg-icon"].forEach((e=>{switch(e){case"mg-table":customElements.get(t(e))||customElements.define(t(e),g);break;case"mg-icon":customElements.get(t(e))||s()}}))}d();const b=g,f=d;export{b as MgTable,f as defineCustomElement}
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
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}
|