@mgdis/mg-components 3.1.0 → 4.0.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-85a4a0b6.js → index-88560a66.js} +123 -48
- package/dist/cjs/index-a39c5567.js +233 -0
- package/dist/cjs/loader.cjs.js +3 -17
- package/dist/cjs/mg-badge_21.cjs.entry.js +3538 -0
- package/dist/cjs/mg-components.cjs.js +3 -7
- package/dist/cjs/mg-modal.cjs.entry.js +117 -0
- package/dist/cjs/mg-popover.cjs.entry.js +170 -0
- package/dist/cjs/popper-71bf3058.js +1790 -0
- package/dist/collection/collection-manifest.json +4 -1
- package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +4 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +26 -10
- package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +7 -2
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.css +46 -49
- package/dist/collection/components/atoms/mg-button/mg-button.js +78 -4
- package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +8 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +20 -46
- package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +104 -9
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +9 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +33 -7
- package/dist/collection/components/atoms/mg-input-title/{mg-input-title.stories.js → doc/mg-input-title.stories.js} +0 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +4 -4
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +14 -3
- package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +4 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +28 -6
- package/dist/collection/components/atoms/mg-tooltip/{mg-tooltip.stories.js → doc/mg-tooltip.stories.js} +14 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +20 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +16 -2
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
- package/dist/collection/components/molecules/inputs/MgInput.js +25 -29
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +25 -11
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +102 -52
- package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +37 -9
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +136 -66
- package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +15 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +38 -10
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +180 -80
- package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +16 -2
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +37 -9
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +108 -47
- package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +25 -11
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +113 -42
- package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +22 -2
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +39 -10
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +145 -71
- package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +17 -8
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +69 -19
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +184 -83
- package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +16 -5
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +69 -13
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +163 -70
- package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +22 -10
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +68 -33
- package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +58 -0
- package/dist/collection/components/molecules/mg-form/mg-form.css +19 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +271 -0
- package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +6 -2
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +26 -11
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +51 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +52 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +240 -0
- package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +47 -28
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +39 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +53 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +356 -0
- package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +10 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +37 -12
- package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +20 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +11 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +17 -3
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +139 -26
- package/dist/collection/locales/index.js +33 -4
- package/dist/collection/stories/helpers.stories.js +33 -0
- package/dist/collection/utils/components.utils.js +16 -9
- package/dist/collection/utils/locale.utils.js +13 -7
- package/dist/collection/utils/test.utils.js +27 -15
- package/dist/collection/variables.css +39 -5
- package/dist/collection/variables.scss +39 -5
- package/dist/components/MgInput.js +26 -37
- package/dist/components/components.utils.js +16 -9
- package/dist/components/index.d.ts +24 -6
- package/dist/components/index.js +23 -0
- package/dist/components/index2.js +116 -17
- package/dist/components/locale.utils.js +13 -8
- package/dist/components/mg-badge2.js +25 -9
- package/dist/components/mg-button2.js +29 -5
- package/dist/components/mg-character-left2.js +14 -26
- package/dist/components/mg-form.d.ts +11 -0
- package/dist/components/mg-form.js +148 -0
- package/dist/components/mg-icon2.js +138 -17
- package/dist/components/mg-input-checkbox.js +66 -53
- package/dist/components/mg-input-date.js +100 -69
- package/dist/components/mg-input-numeric.js +125 -81
- package/dist/components/mg-input-password.js +69 -48
- package/dist/components/mg-input-radio.js +74 -46
- package/dist/components/mg-input-select2.js +103 -71
- package/dist/components/mg-input-text.js +1 -237
- package/dist/components/mg-input-text2.js +300 -0
- package/dist/components/mg-input-textarea.js +100 -46
- package/dist/components/mg-input-title2.js +13 -4
- package/dist/components/mg-input-toggle.js +39 -31
- package/dist/components/mg-message.js +25 -10
- package/dist/components/mg-modal.d.ts +11 -0
- package/dist/components/mg-modal.js +153 -0
- package/dist/components/mg-pagination.js +45 -31
- package/dist/components/mg-panel.d.ts +11 -0
- package/dist/components/mg-panel.js +244 -0
- package/dist/components/mg-popover.js +31 -11
- package/dist/components/mg-tabs.js +113 -23
- package/dist/components/mg-tag.js +27 -5
- package/dist/components/mg-tooltip2.js +10 -1
- package/dist/components/popper.js +6 -2
- package/dist/esm/{index-e3e84606.js → index-bca81100.js} +124 -46
- package/dist/esm/index-e51ae032.js +228 -0
- package/dist/esm/loader.js +3 -17
- package/dist/esm/mg-badge_21.entry.js +3514 -0
- package/dist/esm/mg-components.js +3 -7
- package/dist/esm/mg-modal.entry.js +113 -0
- package/dist/esm/mg-popover.entry.js +166 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/popper-93ecb064.js +1788 -0
- package/dist/index.js +1 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-003a1344.entry.js +1 -0
- package/dist/mg-components/p-462d648a.entry.js +1 -0
- package/dist/mg-components/p-4c66f794.js +1 -0
- package/dist/mg-components/p-5126ab10.entry.js +1 -0
- package/dist/mg-components/p-780bd52d.js +1 -0
- package/dist/mg-components/p-b14a3443.js +2 -0
- package/dist/mg-components/variables.css +39 -5
- package/dist/mg-components/variables.scss +39 -5
- package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +16 -5
- package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +23 -3
- package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +9 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +16 -13
- package/dist/types/components/atoms/mg-icon/{mg-icon.stories.d.ts → doc/mg-icon.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +14 -4
- package/dist/types/components/atoms/mg-input-title/{mg-input-title.stories.d.ts → doc/mg-input-title.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
- package/dist/types/components/atoms/mg-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +18 -4
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +29 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +13 -3
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +6 -4
- package/dist/types/components/molecules/inputs/MgInput.d.ts +7 -8
- package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +36 -13
- package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +46 -15
- package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +11 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +61 -16
- package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +22 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +35 -11
- package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +42 -9
- package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +34 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +37 -9
- package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +13 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +52 -16
- package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +45 -17
- package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +29 -12
- package/dist/types/components/molecules/{mg-popover/mg-popover.stories.d.ts → mg-form/doc/mg-form.stories.d.ts} +3 -4
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +83 -0
- package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +10 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +13 -4
- package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +13 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +85 -0
- package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +5 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +31 -7
- package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +139 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +25 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +8 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +27 -4
- package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +20 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +11 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +70 -6
- package/dist/types/components.d.ts +528 -211
- package/dist/types/locales/index.d.ts +108 -38
- package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
- package/dist/types/utils/components.utils.d.ts +16 -9
- package/dist/types/utils/locale.utils.d.ts +13 -6
- package/dist/types/utils/test.utils.d.ts +13 -1
- package/loader/index.js +1 -1
- package/package.json +45 -14
- package/readme.md +9 -35
- package/dist/cjs/css-shim-a22512c4.js +0 -6
- package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
- package/dist/cjs/shadow-css-8940f82d.js +0 -390
- package/dist/collection/stories/buttons.stories.js +0 -43
- package/dist/collection/stories/messages.stories.js +0 -44
- package/dist/collection/stories/tags.stories.js +0 -13
- package/dist/esm/css-shim-7c240feb.js +0 -4
- package/dist/esm/mg-badge_20.entry.js +0 -4638
- package/dist/esm/shadow-css-5d2d01ce.js +0 -388
- package/dist/esm-es5/css-shim-7c240feb.js +0 -1
- package/dist/esm-es5/index-e3e84606.js +0 -1
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +0 -1
- package/dist/esm-es5/mg-badge_20.entry.js +0 -2
- package/dist/esm-es5/mg-components.js +0 -1
- package/dist/esm-es5/shadow-css-5d2d01ce.js +0 -12
- package/dist/mg-components/mg-components.js +0 -132
- package/dist/mg-components/p-1cd24462.system.js +0 -1
- package/dist/mg-components/p-2e2f6b27.system.entry.js +0 -2
- package/dist/mg-components/p-366a224e.js +0 -1
- package/dist/mg-components/p-422c429b.system.js +0 -1
- package/dist/mg-components/p-50ea2036.system.js +0 -1
- package/dist/mg-components/p-62fa3797.js +0 -1
- package/dist/mg-components/p-71d57b8b.system.js +0 -13
- package/dist/mg-components/p-9a215712.system.js +0 -1
- package/dist/mg-components/p-cbf0464b.entry.js +0 -1
- package/dist/mg-components/p-f6455ab3.js +0 -12
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +0 -9
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +0 -14
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +0 -7
- package/dist/types/stories/messages.stories.d.ts +0 -13
- package/dist/types/stories/tags.stories.d.ts +0 -5
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Component, Element, Event, h, Prop, State, Watch } from '@stencil/core';
|
|
2
2
|
import { createID, ClassList } from '../../../utils/components.utils';
|
|
3
3
|
import { variants } from './mg-message.conf';
|
|
4
|
-
import {
|
|
4
|
+
import { initLocales } from '../../../locales';
|
|
5
5
|
export class MgMessage {
|
|
6
6
|
constructor() {
|
|
7
7
|
/************
|
|
8
8
|
* Internal *
|
|
9
9
|
************/
|
|
10
|
+
// classes
|
|
11
|
+
this.classHide = 'mg-message--hide';
|
|
12
|
+
// IDs
|
|
10
13
|
this.closeButtonId = '';
|
|
11
14
|
// Stored timer setted when hide action is run from setTimeOut
|
|
12
15
|
this.storedTimer = null;
|
|
@@ -18,7 +21,7 @@ export class MgMessage {
|
|
|
18
21
|
/**
|
|
19
22
|
* Message variant
|
|
20
23
|
*/
|
|
21
|
-
this.variant = variants[0];
|
|
24
|
+
this.variant = variants[0]; // info
|
|
22
25
|
/**
|
|
23
26
|
* Define if message has a cross button
|
|
24
27
|
* RG 01: https://jira.mgdis.fr/browse/PDA9-140
|
|
@@ -55,6 +58,8 @@ export class MgMessage {
|
|
|
55
58
|
};
|
|
56
59
|
/**
|
|
57
60
|
* Get icon corresponding to variant
|
|
61
|
+
*
|
|
62
|
+
* @returns {string} icon
|
|
58
63
|
*/
|
|
59
64
|
this.getIcon = () => {
|
|
60
65
|
switch (this.variant) {
|
|
@@ -80,10 +85,12 @@ export class MgMessage {
|
|
|
80
85
|
if (!variants.includes(newValue)) {
|
|
81
86
|
throw new Error(`<mg-message> prop "variant" must be one of : ${variants.join(', ')}`);
|
|
82
87
|
}
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
else {
|
|
89
|
+
if (oldValue !== undefined) {
|
|
90
|
+
this.classList.delete(`mg-message--${oldValue}`);
|
|
91
|
+
}
|
|
92
|
+
this.classList.add(`mg-message--${newValue}`);
|
|
85
93
|
}
|
|
86
|
-
this.classList.add(`mg-message--${this.variant}`);
|
|
87
94
|
}
|
|
88
95
|
validateCloseButton(newValue) {
|
|
89
96
|
if (newValue && this.hasActions) {
|
|
@@ -94,11 +101,11 @@ export class MgMessage {
|
|
|
94
101
|
validateHide(newValue) {
|
|
95
102
|
if (newValue) {
|
|
96
103
|
this.componentHide.emit();
|
|
97
|
-
this.classList.add(
|
|
104
|
+
this.classList.add(this.classHide);
|
|
98
105
|
}
|
|
99
106
|
else {
|
|
100
107
|
this.componentShow.emit();
|
|
101
|
-
this.classList.delete(
|
|
108
|
+
this.classList.delete(this.classHide);
|
|
102
109
|
}
|
|
103
110
|
this.hideWithDelay();
|
|
104
111
|
}
|
|
@@ -109,6 +116,9 @@ export class MgMessage {
|
|
|
109
116
|
* Check if component props are well configured on init
|
|
110
117
|
*/
|
|
111
118
|
componentWillLoad() {
|
|
119
|
+
// Get locales
|
|
120
|
+
this.messages = initLocales(this.element).messages;
|
|
121
|
+
// Validate
|
|
112
122
|
this.validateVariant(this.variant);
|
|
113
123
|
// Check if close button is an can be activated
|
|
114
124
|
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
@@ -120,6 +130,11 @@ export class MgMessage {
|
|
|
120
130
|
this.validateDelay(this.delay);
|
|
121
131
|
this.validateHide(this.hide);
|
|
122
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Render
|
|
135
|
+
*
|
|
136
|
+
* @returns {HTMLElement} HTML Element
|
|
137
|
+
*/
|
|
123
138
|
render() {
|
|
124
139
|
return (h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' },
|
|
125
140
|
h("span", { class: "mg-message__icon" },
|
|
@@ -131,7 +146,7 @@ export class MgMessage {
|
|
|
131
146
|
this.hasActions && (h("span", { class: "mg-message__content-actions-slot" },
|
|
132
147
|
h("slot", { name: "actions" })))),
|
|
133
148
|
this.closeButton && (h("span", { class: "mg-message__close-button" },
|
|
134
|
-
h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.message.closeButton, onClick: this.handleClose },
|
|
149
|
+
h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose },
|
|
135
150
|
h("mg-icon", { icon: "cross" }))))));
|
|
136
151
|
}
|
|
137
152
|
static get is() { return "mg-message"; }
|
|
@@ -198,7 +213,7 @@ export class MgMessage {
|
|
|
198
213
|
},
|
|
199
214
|
"closeButton": {
|
|
200
215
|
"type": "boolean",
|
|
201
|
-
"mutable":
|
|
216
|
+
"mutable": true,
|
|
202
217
|
"complexType": {
|
|
203
218
|
"original": "boolean",
|
|
204
219
|
"resolved": "boolean",
|
|
@@ -245,7 +260,7 @@ export class MgMessage {
|
|
|
245
260
|
"composed": true,
|
|
246
261
|
"docs": {
|
|
247
262
|
"tags": [],
|
|
248
|
-
"text": "
|
|
263
|
+
"text": "Emited event when message is diplayed"
|
|
249
264
|
},
|
|
250
265
|
"complexType": {
|
|
251
266
|
"original": "string",
|
|
@@ -260,7 +275,7 @@ export class MgMessage {
|
|
|
260
275
|
"composed": true,
|
|
261
276
|
"docs": {
|
|
262
277
|
"tags": [],
|
|
263
|
-
"text": "
|
|
278
|
+
"text": "Emited event when message is hidden"
|
|
264
279
|
},
|
|
265
280
|
"complexType": {
|
|
266
281
|
"original": "string",
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* eslint-disable react/jsx-no-bind */
|
|
2
|
+
import { h } from '@stencil/core';
|
|
3
|
+
export default {
|
|
4
|
+
component: 'mg-modal',
|
|
5
|
+
title: 'Molecules/mg-modal',
|
|
6
|
+
parameters: { actions: { handles: ['component-show', 'component-hide'] } },
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
10
|
+
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
11
|
+
*/
|
|
12
|
+
const Template = args => {
|
|
13
|
+
// Extract slot so it won't be render as an attribute
|
|
14
|
+
const slotContent = args.slotContent;
|
|
15
|
+
delete args.slotContent;
|
|
16
|
+
const slotActions = args.slotActions;
|
|
17
|
+
delete args.slotActions;
|
|
18
|
+
const closeButton = args.closeButton;
|
|
19
|
+
delete args.closeButton;
|
|
20
|
+
const modalTitle = args.modalTitle;
|
|
21
|
+
delete args.modalTitle;
|
|
22
|
+
// return element
|
|
23
|
+
return (h("div", null,
|
|
24
|
+
h("mg-button", { controls: "identifier", haspopup: "dialog", onClick: () => {
|
|
25
|
+
const mgModal = document.querySelector('mg-modal');
|
|
26
|
+
const isHide = mgModal.hide === true;
|
|
27
|
+
if (isHide) {
|
|
28
|
+
mgModal.removeAttribute('hide'); // storybook first render is an attribute then we use property
|
|
29
|
+
mgModal.hide = false;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
mgModal.hide = true;
|
|
33
|
+
}
|
|
34
|
+
} }, "Open modal"),
|
|
35
|
+
h("mg-modal", Object.assign({}, args, { "close-button": closeButton, "modal-title": modalTitle }),
|
|
36
|
+
slotContent && h("span", { slot: "content", innerHTML: slotContent }),
|
|
37
|
+
slotActions && h("span", { slot: "actions", innerHTML: slotActions }))));
|
|
38
|
+
};
|
|
39
|
+
export const MgModal = Template.bind({});
|
|
40
|
+
MgModal.args = {
|
|
41
|
+
slotContent: `<p slot="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>`,
|
|
42
|
+
slotActions: ``,
|
|
43
|
+
modalTitle: 'Modal title',
|
|
44
|
+
identifier: 'identifier',
|
|
45
|
+
closeButton: false,
|
|
46
|
+
hide: true,
|
|
47
|
+
};
|
|
48
|
+
export const WithCloseButton = Template.bind({});
|
|
49
|
+
WithCloseButton.args = Object.assign(Object.assign({}, MgModal.args), { closeButton: true });
|
|
50
|
+
export const WithActions = Template.bind({});
|
|
51
|
+
WithActions.args = Object.assign(Object.assign({}, MgModal.args), { closeButton: true, slotActions: `<div slot="actions" class="mg-group-elements mg-group-elements--align-right"><mg-button>Primary</mg-button><mg-button variant="secondary">Secondary</mg-button></div>` });
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.mg-modal {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: center;
|
|
4
|
+
align-items: center;
|
|
5
|
+
position: fixed;
|
|
6
|
+
top: 0;
|
|
7
|
+
right: 0;
|
|
8
|
+
bottom: 0;
|
|
9
|
+
left: 0;
|
|
10
|
+
z-index: 1000;
|
|
11
|
+
padding: 2rem 0;
|
|
12
|
+
background-color: hsla(var(--color-light), 85%);
|
|
13
|
+
}
|
|
14
|
+
.mg-modal__dialog {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
align-self: center;
|
|
18
|
+
row-gap: 3rem;
|
|
19
|
+
padding: 1.5rem 2.5rem;
|
|
20
|
+
width: 60rem;
|
|
21
|
+
height: fit-content;
|
|
22
|
+
max-width: 100%;
|
|
23
|
+
max-height: 100%;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
background-color: hsl(var(--color-light));
|
|
26
|
+
box-shadow: var(--box-shadow);
|
|
27
|
+
border-radius: var(--mg-modal-border-radius);
|
|
28
|
+
}
|
|
29
|
+
.mg-modal__header {
|
|
30
|
+
margin-bottom: 0.5rem;
|
|
31
|
+
}
|
|
32
|
+
.mg-modal__title {
|
|
33
|
+
margin: 0;
|
|
34
|
+
font-family: var(--font-family-heading);
|
|
35
|
+
font-size: var(--mg-modal-title-font-size);
|
|
36
|
+
font-weight: 600;
|
|
37
|
+
}
|
|
38
|
+
.mg-modal__close-button {
|
|
39
|
+
float: right;
|
|
40
|
+
height: var(--mg-modal-title-font-size);
|
|
41
|
+
margin-top: calc((var(--default-size) - var(--mg-modal-title-font-size) * var(--line-height)) / 2 * -1);
|
|
42
|
+
margin-right: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2 * -1);
|
|
43
|
+
}
|
|
44
|
+
.mg-modal .mg-modal__content {
|
|
45
|
+
overflow-y: auto;
|
|
46
|
+
}
|
|
47
|
+
.mg-modal .mg-modal__content::slotted(*) {
|
|
48
|
+
font-size: var(--mg-modal-content-font-size);
|
|
49
|
+
}
|
|
50
|
+
.mg-modal.mg-modal--hide {
|
|
51
|
+
display: none;
|
|
52
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { Component, h, Prop, State, Watch, Element, Event, Listen } from '@stencil/core';
|
|
2
|
+
import { createID, ClassList } from '../../../utils/components.utils';
|
|
3
|
+
import { initLocales } from '../../../locales';
|
|
4
|
+
export class MgModal {
|
|
5
|
+
constructor() {
|
|
6
|
+
/************
|
|
7
|
+
* Internal *
|
|
8
|
+
************/
|
|
9
|
+
// Classes
|
|
10
|
+
this.classHide = 'mg-modal--hide';
|
|
11
|
+
// IDs
|
|
12
|
+
this.closeButtonId = '';
|
|
13
|
+
this.titleId = '';
|
|
14
|
+
/**
|
|
15
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
16
|
+
* If not set, it will be created.
|
|
17
|
+
*/
|
|
18
|
+
this.identifier = createID('mg-modal');
|
|
19
|
+
/**
|
|
20
|
+
* Define if modal has a cross button
|
|
21
|
+
*/
|
|
22
|
+
this.closeButton = false;
|
|
23
|
+
/**
|
|
24
|
+
* Define if modal is hidden
|
|
25
|
+
*/
|
|
26
|
+
this.hide = false;
|
|
27
|
+
/**
|
|
28
|
+
* Define if component is using actions slot
|
|
29
|
+
*/
|
|
30
|
+
this.hasActions = false;
|
|
31
|
+
/**
|
|
32
|
+
* Define if component is using content slot
|
|
33
|
+
*/
|
|
34
|
+
this.hasContent = false;
|
|
35
|
+
/**
|
|
36
|
+
* Component classes
|
|
37
|
+
*/
|
|
38
|
+
this.classList = new ClassList(['mg-modal']);
|
|
39
|
+
/*************
|
|
40
|
+
* Handlers *
|
|
41
|
+
*************/
|
|
42
|
+
/**
|
|
43
|
+
* Handle close button
|
|
44
|
+
*
|
|
45
|
+
* @returns {void}
|
|
46
|
+
*/
|
|
47
|
+
this.handleClose = () => {
|
|
48
|
+
this.hide = true;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
validateHide(newValue) {
|
|
52
|
+
if (newValue) {
|
|
53
|
+
this.componentHide.emit();
|
|
54
|
+
this.classList.add(this.classHide);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.componentShow.emit();
|
|
58
|
+
this.classList.delete(this.classHide);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Handle 'escape' key down
|
|
63
|
+
*
|
|
64
|
+
* @param {KeyboardEvent} event keydown event
|
|
65
|
+
* @returns {void}
|
|
66
|
+
*/
|
|
67
|
+
handleKeyDown(event) {
|
|
68
|
+
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
69
|
+
if (this.closeButton && event.key === 'Escape') {
|
|
70
|
+
this.hide = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/*************
|
|
74
|
+
* Lifecycle *
|
|
75
|
+
*************/
|
|
76
|
+
/**
|
|
77
|
+
* Check if component props are well configured on init
|
|
78
|
+
*
|
|
79
|
+
* @returns {void}
|
|
80
|
+
*/
|
|
81
|
+
componentWillLoad() {
|
|
82
|
+
// Get locales
|
|
83
|
+
this.messages = initLocales(this.element).messages;
|
|
84
|
+
// Validate
|
|
85
|
+
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
86
|
+
this.hasContent = this.element.querySelector('[slot="content"]') !== null;
|
|
87
|
+
if (this.closeButton) {
|
|
88
|
+
this.closeButtonId = `${this.identifier}-close-button`;
|
|
89
|
+
}
|
|
90
|
+
this.titleId = `${this.identifier}-title`;
|
|
91
|
+
this.validateHide(this.hide);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Render
|
|
95
|
+
*
|
|
96
|
+
* @returns {HTMLElement} HTML Element
|
|
97
|
+
*/
|
|
98
|
+
render() {
|
|
99
|
+
return (h("section", { role: "dialog", id: this.identifier, class: this.classList.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide },
|
|
100
|
+
h("article", { class: "mg-modal__dialog" },
|
|
101
|
+
h("header", { class: "mg-modal__header" },
|
|
102
|
+
this.closeButton && (h("span", { class: "mg-modal__close-button" },
|
|
103
|
+
h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose },
|
|
104
|
+
h("mg-icon", { icon: "cross" })))),
|
|
105
|
+
h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)),
|
|
106
|
+
this.hasContent && (h("article", { class: "mg-modal__content" },
|
|
107
|
+
h("slot", { name: "content" }))),
|
|
108
|
+
this.hasActions && (h("footer", { class: "mg-modal__footer" },
|
|
109
|
+
h("slot", { name: "actions" }))))));
|
|
110
|
+
}
|
|
111
|
+
static get is() { return "mg-modal"; }
|
|
112
|
+
static get encapsulation() { return "shadow"; }
|
|
113
|
+
static get originalStyleUrls() { return {
|
|
114
|
+
"$": ["mg-modal.scss"]
|
|
115
|
+
}; }
|
|
116
|
+
static get styleUrls() { return {
|
|
117
|
+
"$": ["mg-modal.css"]
|
|
118
|
+
}; }
|
|
119
|
+
static get properties() { return {
|
|
120
|
+
"identifier": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"mutable": false,
|
|
123
|
+
"complexType": {
|
|
124
|
+
"original": "string",
|
|
125
|
+
"resolved": "string",
|
|
126
|
+
"references": {}
|
|
127
|
+
},
|
|
128
|
+
"required": false,
|
|
129
|
+
"optional": false,
|
|
130
|
+
"docs": {
|
|
131
|
+
"tags": [],
|
|
132
|
+
"text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
|
|
133
|
+
},
|
|
134
|
+
"attribute": "identifier",
|
|
135
|
+
"reflect": false,
|
|
136
|
+
"defaultValue": "createID('mg-modal')"
|
|
137
|
+
},
|
|
138
|
+
"modalTitle": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"mutable": false,
|
|
141
|
+
"complexType": {
|
|
142
|
+
"original": "string",
|
|
143
|
+
"resolved": "string",
|
|
144
|
+
"references": {}
|
|
145
|
+
},
|
|
146
|
+
"required": true,
|
|
147
|
+
"optional": false,
|
|
148
|
+
"docs": {
|
|
149
|
+
"tags": [],
|
|
150
|
+
"text": "Displayed modal title\nrequired"
|
|
151
|
+
},
|
|
152
|
+
"attribute": "modal-title",
|
|
153
|
+
"reflect": false
|
|
154
|
+
},
|
|
155
|
+
"closeButton": {
|
|
156
|
+
"type": "boolean",
|
|
157
|
+
"mutable": true,
|
|
158
|
+
"complexType": {
|
|
159
|
+
"original": "boolean",
|
|
160
|
+
"resolved": "boolean",
|
|
161
|
+
"references": {}
|
|
162
|
+
},
|
|
163
|
+
"required": false,
|
|
164
|
+
"optional": false,
|
|
165
|
+
"docs": {
|
|
166
|
+
"tags": [],
|
|
167
|
+
"text": "Define if modal has a cross button"
|
|
168
|
+
},
|
|
169
|
+
"attribute": "close-button",
|
|
170
|
+
"reflect": false,
|
|
171
|
+
"defaultValue": "false"
|
|
172
|
+
},
|
|
173
|
+
"hide": {
|
|
174
|
+
"type": "boolean",
|
|
175
|
+
"mutable": true,
|
|
176
|
+
"complexType": {
|
|
177
|
+
"original": "boolean",
|
|
178
|
+
"resolved": "boolean",
|
|
179
|
+
"references": {}
|
|
180
|
+
},
|
|
181
|
+
"required": false,
|
|
182
|
+
"optional": false,
|
|
183
|
+
"docs": {
|
|
184
|
+
"tags": [],
|
|
185
|
+
"text": "Define if modal is hidden"
|
|
186
|
+
},
|
|
187
|
+
"attribute": "hide",
|
|
188
|
+
"reflect": false,
|
|
189
|
+
"defaultValue": "false"
|
|
190
|
+
}
|
|
191
|
+
}; }
|
|
192
|
+
static get states() { return {
|
|
193
|
+
"hasActions": {},
|
|
194
|
+
"hasContent": {},
|
|
195
|
+
"classList": {}
|
|
196
|
+
}; }
|
|
197
|
+
static get events() { return [{
|
|
198
|
+
"method": "componentShow",
|
|
199
|
+
"name": "component-show",
|
|
200
|
+
"bubbles": true,
|
|
201
|
+
"cancelable": true,
|
|
202
|
+
"composed": true,
|
|
203
|
+
"docs": {
|
|
204
|
+
"tags": [],
|
|
205
|
+
"text": "Emmited event when modal is diplayed"
|
|
206
|
+
},
|
|
207
|
+
"complexType": {
|
|
208
|
+
"original": "string",
|
|
209
|
+
"resolved": "string",
|
|
210
|
+
"references": {}
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
"method": "componentHide",
|
|
214
|
+
"name": "component-hide",
|
|
215
|
+
"bubbles": true,
|
|
216
|
+
"cancelable": true,
|
|
217
|
+
"composed": true,
|
|
218
|
+
"docs": {
|
|
219
|
+
"tags": [],
|
|
220
|
+
"text": "Emmited event when modal is hidden"
|
|
221
|
+
},
|
|
222
|
+
"complexType": {
|
|
223
|
+
"original": "string",
|
|
224
|
+
"resolved": "string",
|
|
225
|
+
"references": {}
|
|
226
|
+
}
|
|
227
|
+
}]; }
|
|
228
|
+
static get elementRef() { return "element"; }
|
|
229
|
+
static get watchers() { return [{
|
|
230
|
+
"propName": "hide",
|
|
231
|
+
"methodName": "validateHide"
|
|
232
|
+
}]; }
|
|
233
|
+
static get listeners() { return [{
|
|
234
|
+
"name": "keydown",
|
|
235
|
+
"method": "handleKeyDown",
|
|
236
|
+
"target": "window",
|
|
237
|
+
"capture": false,
|
|
238
|
+
"passive": false
|
|
239
|
+
}]; }
|
|
240
|
+
}
|
|
@@ -2,6 +2,7 @@ import { h } from '@stencil/core';
|
|
|
2
2
|
export default {
|
|
3
3
|
component: 'mg-pagination',
|
|
4
4
|
title: 'Molecules/mg-pagination',
|
|
5
|
+
parameters: { actions: { handles: ['current-page-change'] } },
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Component, h, Prop, Watch, Event } from '@stencil/core';
|
|
1
|
+
import { Component, Element, h, Prop, Watch, Event } from '@stencil/core';
|
|
2
2
|
import { createID } from '../../../utils/components.utils';
|
|
3
3
|
import { NavigationAction } from './mg-pagination.conf';
|
|
4
|
-
import {
|
|
4
|
+
import { initLocales } from './../../../locales';
|
|
5
5
|
/**
|
|
6
6
|
* Range generator
|
|
7
7
|
*
|
|
@@ -17,27 +17,19 @@ import { messages } from './../../../locales';
|
|
|
17
17
|
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
18
18
|
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
19
19
|
*
|
|
20
|
-
* @param start
|
|
21
|
-
* @param end
|
|
22
|
-
* @param step
|
|
23
|
-
* @returns {number[]}
|
|
20
|
+
* @param {number} start start range
|
|
21
|
+
* @param {number} end start end
|
|
22
|
+
* @param {number} step step size
|
|
23
|
+
* @returns {number[]} range numbers
|
|
24
24
|
*/
|
|
25
25
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
26
26
|
export class MgPagination {
|
|
27
27
|
constructor() {
|
|
28
|
-
/**************
|
|
29
|
-
* Decorators *
|
|
30
|
-
**************/
|
|
31
28
|
/**
|
|
32
29
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
33
30
|
* If not set, it will be created.
|
|
34
31
|
*/
|
|
35
32
|
this.identifier = createID('mg-pagination');
|
|
36
|
-
/**
|
|
37
|
-
* Panignation label. Is a short description.
|
|
38
|
-
* Customize default value can be usefull to improve accessibility
|
|
39
|
-
*/
|
|
40
|
-
this.label = 'pagination';
|
|
41
33
|
/**
|
|
42
34
|
* Component total pages
|
|
43
35
|
*/
|
|
@@ -48,15 +40,21 @@ export class MgPagination {
|
|
|
48
40
|
this.currentPage = 1;
|
|
49
41
|
/**
|
|
50
42
|
* Change current page from target
|
|
51
|
-
*
|
|
43
|
+
*
|
|
44
|
+
* @param {number} target target page
|
|
45
|
+
* @returns {void}
|
|
52
46
|
*/
|
|
53
|
-
this.goToPage = (target) =>
|
|
47
|
+
this.goToPage = (target) => {
|
|
48
|
+
this.currentPage = target;
|
|
49
|
+
};
|
|
54
50
|
/************
|
|
55
51
|
* Handlers *
|
|
56
52
|
************/
|
|
57
53
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
54
|
+
* select handler
|
|
55
|
+
*
|
|
56
|
+
* @param {InputEvent} event value change event
|
|
57
|
+
* @returns {void}
|
|
60
58
|
*/
|
|
61
59
|
this.handleSelect = (event) => {
|
|
62
60
|
const to = Number(event.target.value);
|
|
@@ -64,9 +62,13 @@ export class MgPagination {
|
|
|
64
62
|
};
|
|
65
63
|
/**
|
|
66
64
|
* Go to 'previous/next' page button handler
|
|
65
|
+
*
|
|
66
|
+
* @param {string} action navigation action
|
|
67
67
|
* @returns {void}
|
|
68
68
|
*/
|
|
69
|
-
this.handleGoToPage = (action) =>
|
|
69
|
+
this.handleGoToPage = (action) => {
|
|
70
|
+
this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
71
|
+
};
|
|
70
72
|
}
|
|
71
73
|
validateTotalPages(newValue) {
|
|
72
74
|
if (newValue < 1) {
|
|
@@ -85,29 +87,46 @@ export class MgPagination {
|
|
|
85
87
|
/*************
|
|
86
88
|
* Lifecycle *
|
|
87
89
|
*************/
|
|
90
|
+
/**
|
|
91
|
+
* Check if props are well configured on init
|
|
92
|
+
*
|
|
93
|
+
* @returns {void}
|
|
94
|
+
*/
|
|
88
95
|
componentWillLoad() {
|
|
96
|
+
// Get locales
|
|
97
|
+
this.messages = initLocales(this.element).messages;
|
|
98
|
+
// Validate
|
|
89
99
|
this.validateTotalPages(this.totalPages);
|
|
90
100
|
this.validateCurrentPage(this.currentPage);
|
|
101
|
+
// Set default label
|
|
102
|
+
if (this.label === undefined || this.label === '') {
|
|
103
|
+
this.label = this.messages.pagination.label;
|
|
104
|
+
}
|
|
91
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Render
|
|
108
|
+
*
|
|
109
|
+
* @returns {HTMLElement} HTML Element
|
|
110
|
+
*/
|
|
92
111
|
render() {
|
|
93
|
-
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: messages.pagination[`${action}Page`],
|
|
112
|
+
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: this.messages.pagination[`${action}Page`],
|
|
94
113
|
// eslint-disable-next-line react/jsx-no-bind
|
|
95
114
|
onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" },
|
|
96
115
|
action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }),
|
|
97
|
-
messages.
|
|
116
|
+
this.messages.general[action],
|
|
98
117
|
action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
|
|
99
118
|
return (h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination__nav" },
|
|
100
119
|
navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS),
|
|
101
|
-
h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }),
|
|
120
|
+
h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }),
|
|
102
121
|
h("span", { class: "sr-only" },
|
|
103
|
-
messages.pagination.page,
|
|
122
|
+
this.messages.pagination.page,
|
|
104
123
|
" ",
|
|
105
124
|
this.currentPage),
|
|
106
125
|
h("span", null,
|
|
107
126
|
"/ ",
|
|
108
127
|
this.totalPages,
|
|
109
128
|
" ",
|
|
110
|
-
this.totalPages > 1 ? messages.pagination.pages : messages.pagination.
|
|
129
|
+
this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page),
|
|
111
130
|
navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
|
|
112
131
|
}
|
|
113
132
|
static get is() { return "mg-pagination"; }
|
|
@@ -128,7 +147,7 @@ export class MgPagination {
|
|
|
128
147
|
"references": {}
|
|
129
148
|
},
|
|
130
149
|
"required": false,
|
|
131
|
-
"optional":
|
|
150
|
+
"optional": false,
|
|
132
151
|
"docs": {
|
|
133
152
|
"tags": [],
|
|
134
153
|
"text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
|
|
@@ -139,7 +158,7 @@ export class MgPagination {
|
|
|
139
158
|
},
|
|
140
159
|
"label": {
|
|
141
160
|
"type": "string",
|
|
142
|
-
"mutable":
|
|
161
|
+
"mutable": true,
|
|
143
162
|
"complexType": {
|
|
144
163
|
"original": "string",
|
|
145
164
|
"resolved": "string",
|
|
@@ -152,8 +171,7 @@ export class MgPagination {
|
|
|
152
171
|
"text": "Panignation label. Is a short description.\nCustomize default value can be usefull to improve accessibility"
|
|
153
172
|
},
|
|
154
173
|
"attribute": "label",
|
|
155
|
-
"reflect": false
|
|
156
|
-
"defaultValue": "'pagination'"
|
|
174
|
+
"reflect": false
|
|
157
175
|
},
|
|
158
176
|
"totalPages": {
|
|
159
177
|
"type": "number",
|
|
@@ -208,6 +226,7 @@ export class MgPagination {
|
|
|
208
226
|
"references": {}
|
|
209
227
|
}
|
|
210
228
|
}]; }
|
|
229
|
+
static get elementRef() { return "element"; }
|
|
211
230
|
static get watchers() { return [{
|
|
212
231
|
"propName": "totalPages",
|
|
213
232
|
"methodName": "validateTotalPages"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export default {
|
|
3
|
+
component: 'mg-panel',
|
|
4
|
+
title: 'Molecules/mg-panel',
|
|
5
|
+
parameters: { actions: { handles: ['title-change'] } },
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
9
|
+
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
10
|
+
*/
|
|
11
|
+
const Template = args => {
|
|
12
|
+
// Extract slot so it won't be render as an attribute
|
|
13
|
+
const panelTitle = args.panelTitle;
|
|
14
|
+
delete args.panelTitle;
|
|
15
|
+
const titleEditable = args.titleEditable;
|
|
16
|
+
delete args.titleEditable;
|
|
17
|
+
const expandToggleDisabled = args.expandToggleDisabled;
|
|
18
|
+
delete args.expandToggleDisabled;
|
|
19
|
+
const titlePattern = args.titlePattern;
|
|
20
|
+
delete args.titlePattern;
|
|
21
|
+
const titlePatternErrorMessage = args.titlePatternErrorMessage;
|
|
22
|
+
delete args.titlePatternErrorMessage;
|
|
23
|
+
// return element
|
|
24
|
+
return (h("mg-panel", Object.assign({}, args, { "panel-title": panelTitle, "title-editable": titleEditable, "expand-toggle-disabled": expandToggleDisabled, "title-pattern": titlePattern, "title-pattern-error-message": titlePatternErrorMessage }),
|
|
25
|
+
h("div", null, "Content"),
|
|
26
|
+
h("div", { slot: "header-right" },
|
|
27
|
+
h("mg-button", { variant: "secondary" },
|
|
28
|
+
h("mg-icon", { icon: "file-upload" }),
|
|
29
|
+
" Upload"),
|
|
30
|
+
h("mg-button", { "is-icon": true, variant: "secondary", label: "delete" },
|
|
31
|
+
h("mg-icon", { icon: "trash" })))));
|
|
32
|
+
};
|
|
33
|
+
export const MgPanel = Template.bind({});
|
|
34
|
+
MgPanel.args = {
|
|
35
|
+
panelTitle: 'title',
|
|
36
|
+
expanded: false,
|
|
37
|
+
titleEditable: true,
|
|
38
|
+
expandToggleDisabled: true,
|
|
39
|
+
};
|