@mgdis/mg-components 5.9.1 → 5.10.1
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/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_31.cjs.entry.js +345 -648
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +19 -43
- package/dist/cjs/{mg-menu.conf-9afe6571.js → mg-menu.conf-196151fe.js} +16 -21
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +9 -12
- package/dist/collection/components/atoms/mg-button/mg-button.js +18 -27
- package/dist/collection/components/atoms/mg-card/mg-card.js +22 -15
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -4
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -2
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +26 -23
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -4
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +11 -16
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +12 -34
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +26 -24
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +10 -20
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +7 -17
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +14 -34
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +6 -13
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -27
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -45
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +17 -43
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +14 -22
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +17 -28
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +11 -29
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +20 -47
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +11 -23
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -6
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -27
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -4
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -12
- package/dist/collection/components/molecules/mg-message/mg-message.js +12 -20
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -17
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +11 -19
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +11 -30
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +8 -21
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +3 -8
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +20 -36
- package/dist/collection/locales/index.js +2 -3
- package/dist/collection/utils/behaviors.utils.js +16 -32
- package/dist/collection/utils/components.utils.js +22 -33
- package/dist/collection/utils/locale.utils.js +14 -18
- package/dist/collection/utils/unit.test.utils.js +7 -15
- package/dist/components/MgInput.js +30 -24
- package/dist/components/components.utils.js +22 -33
- package/dist/components/index2.js +16 -21
- package/dist/components/mg-action-more.js +9 -21
- package/dist/components/mg-badge2.js +9 -12
- package/dist/components/mg-button2.js +18 -27
- package/dist/components/mg-card2.js +20 -13
- package/dist/components/mg-character-left2.js +1 -4
- package/dist/components/mg-details.js +1 -6
- package/dist/components/mg-divider.js +1 -2
- package/dist/components/mg-form.js +7 -23
- package/dist/components/mg-icon2.js +26 -23
- package/dist/components/mg-illustrated-message.js +1 -4
- package/dist/components/mg-input-checkbox.js +9 -16
- package/dist/components/mg-input-date.js +6 -13
- package/dist/components/mg-input-numeric.js +13 -30
- package/dist/components/mg-input-password.js +5 -9
- package/dist/components/mg-input-radio.js +9 -23
- package/dist/components/mg-input-select2.js +20 -41
- package/dist/components/mg-input-text2.js +15 -35
- package/dist/components/mg-input-textarea.js +13 -18
- package/dist/components/mg-input-title2.js +1 -4
- package/dist/components/mg-input-toggle.js +16 -24
- package/dist/components/mg-item-more.js +18 -42
- package/dist/components/mg-menu-item2.js +17 -44
- package/dist/components/mg-menu2.js +9 -27
- package/dist/components/mg-message.js +12 -20
- package/dist/components/mg-modal.js +8 -17
- package/dist/components/mg-pagination.js +11 -19
- package/dist/components/mg-panel.js +11 -30
- package/dist/components/mg-popover2.js +8 -21
- package/dist/components/mg-skip-links.js +3 -8
- package/dist/components/mg-tabs.js +20 -36
- package/dist/components/mg-tag.js +11 -16
- package/dist/components/mg-tooltip2.js +12 -34
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_31.entry.js +345 -648
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +19 -43
- package/dist/esm/{mg-menu.conf-881fbd82.js → mg-menu.conf-9ca023ee.js} +16 -21
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-67ce7cb8.entry.js → p-97aaca3e.entry.js} +1 -1
- package/dist/mg-components/p-d891e707.entry.js +1 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +2 -5
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -14
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -8
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -4
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -2
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +8 -7
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -4
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -8
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -33
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -6
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -11
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -11
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +7 -26
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +3 -7
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -18
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +9 -22
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -23
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -9
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -11
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +10 -29
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +21 -49
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +3 -15
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -6
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -19
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +1 -4
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +2 -12
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +4 -12
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -12
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +5 -14
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -23
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +3 -16
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +2 -7
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +15 -30
- package/dist/types/components.d.ts +22 -34
- package/dist/types/locales/index.d.ts +2 -3
- package/dist/types/utils/behaviors.utils.d.ts +14 -29
- package/dist/types/utils/components.utils.d.ts +19 -29
- package/dist/types/utils/locale.utils.d.ts +14 -18
- package/dist/types/utils/unit.test.utils.d.ts +11 -24
- package/package.json +11 -12
- package/dist/mg-components/p-9a93b7af.entry.js +0 -1
- /package/dist/mg-components/{p-367f92d2.js → p-0d3146d9.js} +0 -0
|
@@ -46,33 +46,27 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
46
46
|
**********/
|
|
47
47
|
/**
|
|
48
48
|
* Toggle expanded prop value
|
|
49
|
-
*
|
|
50
|
-
* @returns {void}
|
|
51
49
|
*/
|
|
52
50
|
this.toggleExpanded = () => {
|
|
53
51
|
this.expanded = !this.expanded;
|
|
54
52
|
};
|
|
55
53
|
/**
|
|
56
54
|
* Does an Element have given Status
|
|
57
|
-
*
|
|
58
|
-
* @param
|
|
59
|
-
* @
|
|
60
|
-
* @returns {boolean} true if element with status is found
|
|
55
|
+
* @param mgMenuItemElement - to parse
|
|
56
|
+
* @param status - to check
|
|
57
|
+
* @returns true if element with status is found
|
|
61
58
|
*/
|
|
62
59
|
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
63
60
|
/**
|
|
64
61
|
* Is component contextual direction match the given direction
|
|
65
|
-
*
|
|
66
|
-
* @param
|
|
67
|
-
* @
|
|
68
|
-
* @returns {boolean} true is direction match the direction propertie
|
|
62
|
+
* @param direction - in parent menu
|
|
63
|
+
* @param compareWith - direction to compare with. Default: `this.direction`
|
|
64
|
+
* @returns true is direction match the direction propertie
|
|
69
65
|
*/
|
|
70
66
|
this.isDirection = (direction, compareWith = this.direction) => direction === compareWith;
|
|
71
67
|
/**
|
|
72
68
|
* Update displayNotificationBadge
|
|
73
69
|
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
74
|
-
*
|
|
75
|
-
* @returns {void} update displayNotificationBadge value
|
|
76
70
|
*/
|
|
77
71
|
this.updateDisplayNotificationBadge = () => {
|
|
78
72
|
const childMenu = this.element.querySelector('mg-menu');
|
|
@@ -82,8 +76,7 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
82
76
|
};
|
|
83
77
|
/**
|
|
84
78
|
* Method to control if one of component children have active status
|
|
85
|
-
*
|
|
86
|
-
* @returns {boolean} truthy if component has active child
|
|
79
|
+
* @returns truthy if component has active child
|
|
87
80
|
*/
|
|
88
81
|
this.hasActiveChild = () => {
|
|
89
82
|
var _a;
|
|
@@ -91,9 +84,7 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
91
84
|
};
|
|
92
85
|
/**
|
|
93
86
|
* Validate slots
|
|
94
|
-
*
|
|
95
|
-
* @param {boolean} guard prevent action whith guard. Default: false.
|
|
96
|
-
* @returns {void}
|
|
87
|
+
* @param guard - prevent action whith guard. Default: false.
|
|
97
88
|
*/
|
|
98
89
|
this.validateSlot = (guard = false) => {
|
|
99
90
|
// slot title AND metadata validation
|
|
@@ -111,9 +102,7 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
111
102
|
};
|
|
112
103
|
/**
|
|
113
104
|
* Update status
|
|
114
|
-
*
|
|
115
|
-
* @param {Status[]} guard status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
116
|
-
* @returns {void}
|
|
105
|
+
* @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
117
106
|
*/
|
|
118
107
|
this.updateStatus = (guard = []) => {
|
|
119
108
|
if (![Status.HIDDEN, Status.DISABLED, ...guard].includes(this.status)) {
|
|
@@ -122,8 +111,6 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
122
111
|
};
|
|
123
112
|
/**
|
|
124
113
|
* Init event-listeners
|
|
125
|
-
*
|
|
126
|
-
* @returns {void}
|
|
127
114
|
*/
|
|
128
115
|
this.initListeners = () => {
|
|
129
116
|
var _a;
|
|
@@ -139,14 +126,12 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
139
126
|
};
|
|
140
127
|
/**
|
|
141
128
|
* Get mg-popover identifier
|
|
142
|
-
*
|
|
143
|
-
* @returns {MgPopover['identifier']} generated mg-popover identifier
|
|
129
|
+
* @returns generated mg-popover identifier
|
|
144
130
|
*/
|
|
145
131
|
this.getPopoverIdentifier = () => `${this.identifier}-popover`;
|
|
146
132
|
/**
|
|
147
133
|
* Condition to know if component should display a mg-popover
|
|
148
|
-
*
|
|
149
|
-
* @returns {boolean} truthy if component display popover
|
|
134
|
+
* @returns truthy if component display popover
|
|
150
135
|
*/
|
|
151
136
|
this.displayPopover = () => this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
|
|
152
137
|
/************
|
|
@@ -154,9 +139,7 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
154
139
|
************/
|
|
155
140
|
/**
|
|
156
141
|
* Handle interacrtive element click
|
|
157
|
-
*
|
|
158
|
-
* @param {MouseEvent} event click on element
|
|
159
|
-
* @returns {void}
|
|
142
|
+
* @param event - click on element
|
|
160
143
|
*/
|
|
161
144
|
this.handleElementCLick = (event) => {
|
|
162
145
|
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status.DISABLED) {
|
|
@@ -169,17 +152,14 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
169
152
|
};
|
|
170
153
|
/**
|
|
171
154
|
* Handle popover element display-change event
|
|
172
|
-
*
|
|
173
|
-
* @param {CustomEvent} event popover display event
|
|
174
|
-
* @returns {void}
|
|
155
|
+
* @param event - popover display event
|
|
175
156
|
*/
|
|
176
157
|
this.handlePopoverDisplay = (event) => {
|
|
177
158
|
this.expanded = event.detail;
|
|
178
159
|
};
|
|
179
160
|
/**
|
|
180
161
|
* Render slot
|
|
181
|
-
*
|
|
182
|
-
* @returns {HTMLElement} HTML Element
|
|
162
|
+
* @returns HTML Element
|
|
183
163
|
*/
|
|
184
164
|
this.renderSlot = () => h("slot", null);
|
|
185
165
|
this.identifier = createID('mg-menu-item');
|
|
@@ -245,8 +225,6 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
245
225
|
}
|
|
246
226
|
/**
|
|
247
227
|
* Render popover clickoutside guard for content slot
|
|
248
|
-
*
|
|
249
|
-
* @returns {void}
|
|
250
228
|
*/
|
|
251
229
|
updatePopoverGuard() {
|
|
252
230
|
if (this.displayPopover())
|
|
@@ -259,8 +237,6 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
259
237
|
*************/
|
|
260
238
|
/**
|
|
261
239
|
* Validate props
|
|
262
|
-
*
|
|
263
|
-
* @returns {void}
|
|
264
240
|
*/
|
|
265
241
|
componentWillLoad() {
|
|
266
242
|
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
@@ -276,8 +252,7 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
276
252
|
}
|
|
277
253
|
/**
|
|
278
254
|
* Check if component slots configuration
|
|
279
|
-
*
|
|
280
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
255
|
+
* @returns timeout
|
|
281
256
|
*/
|
|
282
257
|
componentDidLoad() {
|
|
283
258
|
// validation
|
|
@@ -316,8 +291,7 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
316
291
|
}
|
|
317
292
|
/**
|
|
318
293
|
* Render ineractive element
|
|
319
|
-
*
|
|
320
|
-
* @returns {HTMLElement} HTML Element
|
|
294
|
+
* @returns HTML Element
|
|
321
295
|
*/
|
|
322
296
|
renderInteractiveElement() {
|
|
323
297
|
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
@@ -329,8 +303,7 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
329
303
|
}
|
|
330
304
|
/**
|
|
331
305
|
* Render
|
|
332
|
-
*
|
|
333
|
-
* @returns {HTMLElement} HTML Element
|
|
306
|
+
* @returns HTML Element
|
|
334
307
|
*/
|
|
335
308
|
render() {
|
|
336
309
|
const getContainerClasses = () => ({
|
|
@@ -19,10 +19,8 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
19
19
|
*************/
|
|
20
20
|
/**
|
|
21
21
|
* Close matching menu-item
|
|
22
|
-
*
|
|
23
|
-
* @param
|
|
24
|
-
* @param {boolean} condition addionnal condition
|
|
25
|
-
* @returns {void}
|
|
22
|
+
* @param item - menu-item to close
|
|
23
|
+
* @param condition - addionnal condition
|
|
26
24
|
*/
|
|
27
25
|
this.closeMenuItem = (item, condition) => {
|
|
28
26
|
if (!this.isChildMenu && condition) {
|
|
@@ -31,22 +29,18 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
31
29
|
};
|
|
32
30
|
/**
|
|
33
31
|
* get mg-item-more element
|
|
34
|
-
*
|
|
35
|
-
* @returns {HTMLMgItemMoreElement} mg-item-more element
|
|
32
|
+
* @returns mg-item-more element
|
|
36
33
|
*/
|
|
37
34
|
this.getItemMore = () => this.element.querySelector('mg-item-more');
|
|
38
35
|
/**
|
|
39
|
-
* get mg-item-more
|
|
40
|
-
*
|
|
41
|
-
* @returns {HTMLMgMenuItemElement} mg-item-more >>> mg-menu-item element
|
|
36
|
+
* get mg-item-more child mg-menu-item element
|
|
37
|
+
* @returns mg-menu-item element
|
|
42
38
|
*/
|
|
43
39
|
this.getItemMoreMenuItem = () => { var _a, _b; return (_b = (_a = this.getItemMore()) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mg-menu-item'); };
|
|
44
40
|
/**
|
|
45
41
|
* Set item listend
|
|
46
|
-
*
|
|
47
|
-
* @param
|
|
48
|
-
* @param {MgMenu['focusedMenuItem']} index number
|
|
49
|
-
* @returns {void}
|
|
42
|
+
* @param item - mg-menu-item element
|
|
43
|
+
* @param index - number
|
|
50
44
|
*/
|
|
51
45
|
this.setItemListener = (item, index) => {
|
|
52
46
|
['click', 'focus'].forEach(trigger => {
|
|
@@ -61,8 +55,6 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
61
55
|
};
|
|
62
56
|
/**
|
|
63
57
|
* Store menu-items on component init and add listeners
|
|
64
|
-
*
|
|
65
|
-
* @returns {void}
|
|
66
58
|
*/
|
|
67
59
|
this.initMenuItemsListeners = () => {
|
|
68
60
|
// add listeners on menu item and edit index
|
|
@@ -72,16 +64,12 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
72
64
|
};
|
|
73
65
|
/**
|
|
74
66
|
* Handle item-loaded event on mg-item-more element
|
|
75
|
-
*
|
|
76
|
-
* @returns {void}
|
|
77
67
|
*/
|
|
78
68
|
this.handleItemLoaded = () => {
|
|
79
69
|
this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);
|
|
80
70
|
};
|
|
81
71
|
/**
|
|
82
72
|
* render mg-item-more
|
|
83
|
-
*
|
|
84
|
-
* @returns {void}
|
|
85
73
|
*/
|
|
86
74
|
this.renderMgItemMore = () => {
|
|
87
75
|
// /!\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement
|
|
@@ -123,8 +111,6 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
123
111
|
*************/
|
|
124
112
|
/**
|
|
125
113
|
* Validate props
|
|
126
|
-
*
|
|
127
|
-
* @returns {void}
|
|
128
114
|
*/
|
|
129
115
|
componentWillLoad() {
|
|
130
116
|
this.validateDirection(this.direction);
|
|
@@ -134,8 +120,7 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
134
120
|
}
|
|
135
121
|
/**
|
|
136
122
|
* Check if component slots configuration
|
|
137
|
-
*
|
|
138
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
123
|
+
* @returns timeout
|
|
139
124
|
*/
|
|
140
125
|
componentDidLoad() {
|
|
141
126
|
// update props and states after componentDidLoad hook
|
|
@@ -165,16 +150,13 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
165
150
|
}
|
|
166
151
|
/**
|
|
167
152
|
* Add listeners to items
|
|
168
|
-
*
|
|
169
|
-
* @returns {void}
|
|
170
153
|
*/
|
|
171
154
|
componentDidRender() {
|
|
172
155
|
this.initMenuItemsListeners();
|
|
173
156
|
}
|
|
174
157
|
/**
|
|
175
158
|
* Render
|
|
176
|
-
*
|
|
177
|
-
* @returns {HTMLElement} HTML Element
|
|
159
|
+
* @returns HTML Element
|
|
178
160
|
*/
|
|
179
161
|
render() {
|
|
180
162
|
return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, h("slot", null)));
|
|
@@ -33,25 +33,19 @@ const MgMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
33
33
|
this.isHovered = false;
|
|
34
34
|
/**
|
|
35
35
|
* Set timer
|
|
36
|
-
*
|
|
37
|
-
* @returns {void}
|
|
38
36
|
*/
|
|
39
37
|
this.setTimer = () => {
|
|
40
38
|
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
41
39
|
};
|
|
42
40
|
/**
|
|
43
41
|
* Clear timer
|
|
44
|
-
*
|
|
45
|
-
* @returns {void}
|
|
46
42
|
*/
|
|
47
43
|
this.clearTimer = () => {
|
|
48
44
|
clearTimeout(this.storedTimer);
|
|
49
45
|
};
|
|
50
46
|
/**
|
|
51
47
|
* Event to add on element
|
|
52
|
-
*
|
|
53
|
-
* @param {MouseEvent | FocusEvent} event event
|
|
54
|
-
* @returns {void}
|
|
48
|
+
* @param event - event
|
|
55
49
|
*/
|
|
56
50
|
this.timerEvents = (event) => {
|
|
57
51
|
this.clearTimer();
|
|
@@ -74,8 +68,7 @@ const MgMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
74
68
|
};
|
|
75
69
|
/**
|
|
76
70
|
* Get icon corresponding to variant
|
|
77
|
-
*
|
|
78
|
-
* @returns {string} icon
|
|
71
|
+
* @returns icon
|
|
79
72
|
*/
|
|
80
73
|
this.getIcon = () => {
|
|
81
74
|
switch (this.variant) {
|
|
@@ -94,11 +87,11 @@ const MgMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
94
87
|
this.variant = variants[0];
|
|
95
88
|
this.closeButton = false;
|
|
96
89
|
this.hide = false;
|
|
97
|
-
this.
|
|
90
|
+
this.classCollection = new ClassList(['mg-message']);
|
|
98
91
|
this.hasActions = false;
|
|
99
92
|
}
|
|
100
93
|
validateDelay(newValue) {
|
|
101
|
-
if (newValue && newValue < 2) {
|
|
94
|
+
if (newValue !== undefined && newValue < 2) {
|
|
102
95
|
throw new Error(`<mg-message> prop "delay" must be greater than 2 seconds.`);
|
|
103
96
|
}
|
|
104
97
|
}
|
|
@@ -108,9 +101,9 @@ const MgMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
108
101
|
}
|
|
109
102
|
else {
|
|
110
103
|
if (oldValue !== undefined) {
|
|
111
|
-
this.
|
|
104
|
+
this.classCollection.delete(`mg-message--${oldValue}`);
|
|
112
105
|
}
|
|
113
|
-
this.
|
|
106
|
+
this.classCollection.add(`mg-message--${newValue}`);
|
|
114
107
|
}
|
|
115
108
|
}
|
|
116
109
|
validateCloseButton(newValue) {
|
|
@@ -122,7 +115,7 @@ const MgMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
122
115
|
validateHide(newValue) {
|
|
123
116
|
if (newValue) {
|
|
124
117
|
this.componentHide.emit();
|
|
125
|
-
this.
|
|
118
|
+
this.classCollection.add(this.classHide);
|
|
126
119
|
// Remove event Listener
|
|
127
120
|
['focusin', 'mouseenter'].forEach(event => {
|
|
128
121
|
this.element.removeEventListener(event, this.timerEvents);
|
|
@@ -132,7 +125,7 @@ const MgMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
132
125
|
}
|
|
133
126
|
else {
|
|
134
127
|
this.componentShow.emit();
|
|
135
|
-
this.
|
|
128
|
+
this.classCollection.delete(this.classHide);
|
|
136
129
|
// If delay is set
|
|
137
130
|
if (this.delay > 1) {
|
|
138
131
|
// Start timer
|
|
@@ -159,7 +152,7 @@ const MgMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
159
152
|
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
160
153
|
this.validateCloseButton(this.closeButton);
|
|
161
154
|
if (this.closeButton) {
|
|
162
|
-
this.
|
|
155
|
+
this.classCollection.add('mg-message--close-button');
|
|
163
156
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
164
157
|
}
|
|
165
158
|
this.validateDelay(this.delay);
|
|
@@ -167,11 +160,10 @@ const MgMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
167
160
|
}
|
|
168
161
|
/**
|
|
169
162
|
* Render
|
|
170
|
-
*
|
|
171
|
-
* @returns {HTMLElement} HTML Element
|
|
163
|
+
* @returns HTML Element
|
|
172
164
|
*/
|
|
173
165
|
render() {
|
|
174
|
-
return (h("div", { id: this.identifier, class: this.
|
|
166
|
+
return (h("div", { id: this.identifier, class: this.classCollection.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("mg-card", { variant: this.variant, "variant-style": "bar-left" }, h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))))));
|
|
175
167
|
}
|
|
176
168
|
get element() { return this; }
|
|
177
169
|
static get watchers() { return {
|
|
@@ -187,7 +179,7 @@ const MgMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
187
179
|
"variant": [1],
|
|
188
180
|
"closeButton": [1028, "close-button"],
|
|
189
181
|
"hide": [1028],
|
|
190
|
-
"
|
|
182
|
+
"classCollection": [32],
|
|
191
183
|
"hasActions": [32]
|
|
192
184
|
}]);
|
|
193
185
|
function defineCustomElement$1() {
|
|
@@ -55,8 +55,6 @@ const MgModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
55
55
|
*************/
|
|
56
56
|
/**
|
|
57
57
|
* Handle close button
|
|
58
|
-
*
|
|
59
|
-
* @returns {void}
|
|
60
58
|
*/
|
|
61
59
|
this.handleClose = () => {
|
|
62
60
|
this.hide = true;
|
|
@@ -67,7 +65,7 @@ const MgModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
67
65
|
this.hide = false;
|
|
68
66
|
this.hasActions = false;
|
|
69
67
|
this.hasContent = false;
|
|
70
|
-
this.
|
|
68
|
+
this.classCollection = new ClassList(['mg-modal']);
|
|
71
69
|
}
|
|
72
70
|
validateModalTitle(newValue) {
|
|
73
71
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -77,20 +75,18 @@ const MgModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
77
75
|
validateHide(newValue) {
|
|
78
76
|
if (newValue) {
|
|
79
77
|
this.componentHide.emit();
|
|
80
|
-
this.
|
|
78
|
+
this.classCollection.add(this.classHide);
|
|
81
79
|
document.body.style.overflow = this.bodyOverflow;
|
|
82
80
|
}
|
|
83
81
|
else {
|
|
84
82
|
this.componentShow.emit();
|
|
85
|
-
this.
|
|
83
|
+
this.classCollection.delete(this.classHide);
|
|
86
84
|
document.body.style.overflow = 'hidden';
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
/**
|
|
90
88
|
* Handle 'escape' key down
|
|
91
|
-
*
|
|
92
|
-
* @param {KeyboardEvent} event keydown event
|
|
93
|
-
* @returns {void}
|
|
89
|
+
* @param event - keydown event
|
|
94
90
|
*/
|
|
95
91
|
handleKeyDown(event) {
|
|
96
92
|
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
@@ -103,8 +99,6 @@ const MgModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
103
99
|
*************/
|
|
104
100
|
/**
|
|
105
101
|
* Check if component props are well configured on init
|
|
106
|
-
*
|
|
107
|
-
* @returns {void}
|
|
108
102
|
*/
|
|
109
103
|
componentWillLoad() {
|
|
110
104
|
// Store body overflow
|
|
@@ -123,8 +117,6 @@ const MgModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
123
117
|
}
|
|
124
118
|
/**
|
|
125
119
|
* Add observer on component to set focus when displayed
|
|
126
|
-
*
|
|
127
|
-
* @returns {void}
|
|
128
120
|
*/
|
|
129
121
|
componentDidLoad() {
|
|
130
122
|
new MutationObserver(mutationList => {
|
|
@@ -139,11 +131,10 @@ const MgModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
139
131
|
}
|
|
140
132
|
/**
|
|
141
133
|
* Render
|
|
142
|
-
*
|
|
143
|
-
* @returns {HTMLElement} HTML Element
|
|
134
|
+
* @returns HTML Element
|
|
144
135
|
*/
|
|
145
136
|
render() {
|
|
146
|
-
return (h("div", { role: "alertdialog", id: this.identifier, class: this.
|
|
137
|
+
return (h("div", { role: "alertdialog", id: this.identifier, class: this.classCollection.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, h("mg-card", null, h("div", { class: "mg-modal__dialog" }, h("header", { class: "mg-modal__header" }, this.closeButton && (h("span", { class: "mg-modal__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))), h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (h("article", { class: "mg-modal__content" }, h("slot", { name: "content" }))), this.hasActions && (h("footer", { class: "mg-modal__footer" }, h("slot", { name: "actions" })))))));
|
|
147
138
|
}
|
|
148
139
|
get element() { return this; }
|
|
149
140
|
static get watchers() { return {
|
|
@@ -154,11 +145,11 @@ const MgModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
154
145
|
}, [1, "mg-modal", {
|
|
155
146
|
"identifier": [1],
|
|
156
147
|
"modalTitle": [1, "modal-title"],
|
|
157
|
-
"closeButton": [
|
|
148
|
+
"closeButton": [4, "close-button"],
|
|
158
149
|
"hide": [1028],
|
|
159
150
|
"hasActions": [32],
|
|
160
151
|
"hasContent": [32],
|
|
161
|
-
"
|
|
152
|
+
"classCollection": [32]
|
|
162
153
|
}, [[8, "keydown", "handleKeyDown"]]]);
|
|
163
154
|
function defineCustomElement$1() {
|
|
164
155
|
if (typeof customElements === "undefined") {
|
|
@@ -18,6 +18,7 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
18
18
|
/**
|
|
19
19
|
* Range generator
|
|
20
20
|
*
|
|
21
|
+
* ```
|
|
21
22
|
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
22
23
|
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
23
24
|
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
@@ -25,15 +26,15 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
25
26
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
26
27
|
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
27
28
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
29
|
+
* ```
|
|
28
30
|
*
|
|
29
31
|
* range(1, 1) = [1]
|
|
30
32
|
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
31
33
|
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
32
|
-
*
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @
|
|
36
|
-
* @returns {number[]} range numbers
|
|
34
|
+
* @param start - start range
|
|
35
|
+
* @param end - start end
|
|
36
|
+
* @param step - step size
|
|
37
|
+
* @returns range numbers
|
|
37
38
|
*/
|
|
38
39
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
39
40
|
const MgPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
@@ -44,9 +45,7 @@ const MgPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
44
45
|
this.currentPageChange = createEvent(this, "current-page-change", 7);
|
|
45
46
|
/**
|
|
46
47
|
* Change current page from target
|
|
47
|
-
*
|
|
48
|
-
* @param {number} target target page
|
|
49
|
-
* @returns {void}
|
|
48
|
+
* @param target - target page
|
|
50
49
|
*/
|
|
51
50
|
this.goToPage = (target) => {
|
|
52
51
|
this.currentPage = target;
|
|
@@ -56,9 +55,7 @@ const MgPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
56
55
|
************/
|
|
57
56
|
/**
|
|
58
57
|
* select handler
|
|
59
|
-
*
|
|
60
|
-
* @param {InputEvent} event value change event
|
|
61
|
-
* @returns {void}
|
|
58
|
+
* @param event - value change event
|
|
62
59
|
*/
|
|
63
60
|
this.handleSelect = (event) => {
|
|
64
61
|
const to = Number(event.target.value);
|
|
@@ -66,10 +63,8 @@ const MgPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
66
63
|
};
|
|
67
64
|
/**
|
|
68
65
|
* Go to 'previous/next' page button handler
|
|
69
|
-
*
|
|
70
|
-
* @param
|
|
71
|
-
* @param {boolean} disabled button disable state
|
|
72
|
-
* @returns {void}
|
|
66
|
+
* @param action - navigation action
|
|
67
|
+
* @param disabled - button disable state
|
|
73
68
|
*/
|
|
74
69
|
this.handleGoToPage = (action, disabled) => {
|
|
75
70
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
@@ -99,8 +94,6 @@ const MgPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
99
94
|
*************/
|
|
100
95
|
/**
|
|
101
96
|
* Check if props are well configured on init
|
|
102
|
-
*
|
|
103
|
-
* @returns {void}
|
|
104
97
|
*/
|
|
105
98
|
componentWillLoad() {
|
|
106
99
|
// Get locales
|
|
@@ -115,8 +108,7 @@ const MgPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
115
108
|
}
|
|
116
109
|
/**
|
|
117
110
|
* Render
|
|
118
|
-
*
|
|
119
|
-
* @returns {HTMLElement} HTML Element
|
|
111
|
+
* @returns HTML Element
|
|
120
112
|
*/
|
|
121
113
|
render() {
|
|
122
114
|
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|