@mgdis/mg-components 3.3.0 → 4.1.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/.storybook/utils.js +24 -0
- package/dist/cjs/{index-369388eb.js → index-179621c8.js} +108 -10
- package/dist/cjs/{index-bead7dbd.js → index-88560a66.js} +47 -48
- package/dist/cjs/loader.cjs.js +3 -17
- package/dist/cjs/mg-badge_24.cjs.entry.js +5687 -0
- package/dist/cjs/mg-components.cjs.js +3 -7
- package/dist/cjs/mg-modal.cjs.entry.js +12 -6
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +10 -6
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +15 -3
- package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +16 -13
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +6 -30
- package/dist/collection/components/atoms/mg-button/mg-button.js +53 -22
- package/dist/collection/components/atoms/mg-character-left/doc/mg-character-left.stories.js +20 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +10 -47
- package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +12 -4
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +99 -10
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +4 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -6
- package/dist/collection/components/atoms/mg-input-title/doc/mg-input-title.stories.js +21 -0
- package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +10 -8
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +19 -4
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +58 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +26 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +71 -13
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
- package/dist/collection/components/molecules/inputs/MgInput.js +5 -15
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +3 -15
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +22 -15
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +8 -21
- package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +3 -12
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +22 -20
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +19 -18
- package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +9 -13
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +23 -21
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +43 -19
- package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +10 -12
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +22 -20
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +17 -22
- package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +3 -14
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +22 -15
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +8 -15
- package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +10 -16
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +23 -20
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +24 -31
- package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +18 -25
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +54 -30
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +42 -43
- package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +11 -14
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +54 -24
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +64 -37
- package/dist/collection/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.js +57 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +21 -11
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +25 -10
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +25 -0
- package/dist/collection/components/molecules/mg-details/mg-details.css +14 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +141 -0
- package/dist/collection/components/molecules/mg-form/{mg-form.stories.js → doc/mg-form.stories.js} +9 -6
- package/dist/collection/components/molecules/mg-form/mg-form.css +5 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +53 -7
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +22 -0
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css +37 -0
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +74 -0
- package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +10 -16
- package/dist/collection/components/molecules/mg-message/mg-message.js +15 -7
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +43 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +5 -7
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +10 -4
- package/dist/collection/components/molecules/mg-pagination/doc/mg-pagination.stories.js +20 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +17 -18
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +29 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +4 -2
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +12 -16
- package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +22 -16
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +43 -13
- package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +20 -15
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +7 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +3 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +75 -29
- package/dist/collection/locales/index.js +33 -4
- package/dist/collection/stories/helpers.stories.js +41 -0
- package/dist/collection/stories/icons.stories.js +10 -2
- package/dist/collection/stories/typography.stories.js +8 -1
- package/dist/collection/utils/components.utils.js +10 -0
- package/dist/collection/utils/locale.utils.js +7 -4
- package/dist/collection/variables.css +10 -5
- package/dist/collection/variables.scss +10 -5
- package/dist/components/MgInput.js +6 -23
- package/dist/components/components.utils.js +11 -1
- package/dist/components/index.d.ts +25 -5
- package/dist/components/index.js +25 -0
- package/dist/components/index2.js +97 -8
- package/dist/components/locale.utils.js +7 -5
- package/dist/components/mg-badge2.js +16 -4
- package/dist/components/mg-button2.js +14 -17
- package/dist/components/mg-character-left2.js +4 -27
- package/dist/components/mg-details.d.ts +11 -0
- package/dist/components/mg-details.js +87 -0
- package/dist/components/mg-form.js +40 -8
- package/dist/components/mg-icon2.js +122 -17
- package/dist/components/mg-illustrated-message.d.ts +11 -0
- package/dist/components/mg-illustrated-message.js +68 -0
- package/dist/components/mg-input-checkbox.js +11 -27
- package/dist/components/mg-input-date.js +21 -25
- package/dist/components/mg-input-numeric.js +28 -26
- package/dist/components/mg-input-password.js +18 -28
- package/dist/components/mg-input-radio.js +10 -22
- package/dist/components/mg-input-select2.js +24 -35
- package/dist/components/mg-input-text2.js +38 -26
- package/dist/components/mg-input-textarea.js +43 -20
- package/dist/components/mg-input-toggle.js +27 -18
- package/dist/components/mg-message.js +16 -8
- package/dist/components/mg-modal.js +11 -5
- package/dist/components/mg-pagination.js +16 -22
- package/dist/components/mg-panel.js +9 -12
- package/dist/components/mg-popover.js +22 -12
- package/dist/components/mg-tabs.js +77 -22
- package/dist/components/mg-tag.js +20 -5
- package/dist/components/mg-tooltip2.js +74 -12
- package/dist/components/popper.js +6 -2
- package/dist/esm/{index-c346f52d.js → index-7efedd97.js} +107 -8
- package/dist/esm/{index-9e877561.js → index-bca81100.js} +48 -46
- package/dist/esm/loader.js +3 -17
- package/dist/esm/mg-badge_24.entry.js +5660 -0
- package/dist/esm/mg-components.js +3 -7
- package/dist/esm/mg-modal.entry.js +12 -6
- 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-5f89600c.js +1 -0
- package/dist/mg-components/p-a2883dc7.entry.js +1 -0
- package/dist/mg-components/p-b14a3443.js +2 -0
- package/dist/mg-components/p-cffe0519.entry.js +1 -0
- package/dist/mg-components/variables.css +10 -5
- package/dist/mg-components/variables.scss +10 -5
- package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -1
- package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +6 -0
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +12 -1
- package/dist/types/{stories/tags.stories.d.ts → components/atoms/mg-character-left/doc/mg-character-left.stories.d.ts} +2 -1
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +5 -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.d.ts +3 -3
- 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-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +8 -1
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +24 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +13 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +27 -2
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +0 -6
- package/dist/types/components/molecules/inputs/MgInput.d.ts +2 -4
- package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -2
- package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +7 -1
- package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +6 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +8 -2
- package/dist/types/components/molecules/inputs/mg-input-password/{mg-input-password.stories.d.ts → doc/mg-input-password.stories.d.ts} +8 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +7 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -1
- package/dist/types/components/molecules/inputs/mg-input-select/{mg-input-select.stories.d.ts → doc/mg-input-select.stories.d.ts} +11 -5
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +7 -2
- package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +8 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +7 -7
- package/dist/types/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.d.ts → doc/mg-input-textarea.stories.d.ts} +8 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +14 -6
- package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -0
- package/dist/types/components/molecules/mg-details/doc/mg-details.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +49 -0
- package/dist/types/components/molecules/mg-form/{mg-form.stories.d.ts → doc/mg-form.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +14 -0
- package/dist/types/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.d.ts +6 -0
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +28 -0
- package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +2 -0
- package/dist/types/components/molecules/mg-modal/{mg-modal.stories.d.ts → doc/mg-modal.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +2 -0
- package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +8 -0
- package/dist/types/components/molecules/mg-panel/{mg-panel.stories.d.ts → doc/mg-panel.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +5 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +28 -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 +15 -2
- package/dist/types/components/molecules/mg-tabs/{mg-tabs.stories.d.ts → doc/mg-tabs.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +7 -1
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +44 -0
- package/dist/types/components.d.ts +240 -147
- package/dist/types/home/runner/work/mg-components/mg-components/.stencil/.storybook/utils.d.ts +1 -0
- package/dist/types/locales/index.d.ts +109 -46
- package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
- package/dist/types/utils/components.utils.d.ts +8 -0
- package/dist/types/utils/locale.utils.d.ts +7 -3
- package/loader/index.js +1 -1
- package/package.json +16 -16
- package/readme.md +6 -35
- package/dist/cjs/css-shim-629916b0.js +0 -6
- package/dist/cjs/mg-badge_21.cjs.entry.js +0 -3358
- package/dist/cjs/mg-popover.cjs.entry.js +0 -161
- package/dist/cjs/popper-0c3964e7.js +0 -1786
- package/dist/cjs/shadow-css-546083ef.js +0 -390
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +0 -23
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +0 -21
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +0 -26
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +0 -78
- package/dist/collection/components/molecules/mg-modal/mg-modal.stories.js +0 -51
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +0 -24
- package/dist/collection/components/molecules/mg-panel/mg-panel.stories.js +0 -39
- 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-0993aa3b.js +0 -4
- package/dist/esm/mg-badge_21.entry.js +0 -3334
- package/dist/esm/mg-popover.entry.js +0 -157
- package/dist/esm/popper-8874fd6c.js +0 -1784
- package/dist/esm/shadow-css-dfa0587f.js +0 -388
- package/dist/esm-es5/css-shim-0993aa3b.js +0 -1
- package/dist/esm-es5/index-9e877561.js +0 -1
- package/dist/esm-es5/index-c346f52d.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_21.entry.js +0 -2
- package/dist/esm-es5/mg-components.js +0 -1
- package/dist/esm-es5/mg-modal.entry.js +0 -1
- package/dist/esm-es5/mg-popover.entry.js +0 -1
- package/dist/esm-es5/popper-8874fd6c.js +0 -1
- package/dist/esm-es5/shadow-css-dfa0587f.js +0 -12
- package/dist/mg-components/mg-components.js +0 -132
- package/dist/mg-components/p-136c8d6f.system.entry.js +0 -2
- package/dist/mg-components/p-3c14153d.js +0 -1
- package/dist/mg-components/p-50ea2036.system.js +0 -1
- package/dist/mg-components/p-55a22b35.system.js +0 -1
- package/dist/mg-components/p-5e796581.js +0 -12
- package/dist/mg-components/p-656b5efb.system.js +0 -1
- package/dist/mg-components/p-68d6f104.js +0 -1
- package/dist/mg-components/p-6d49ed95.js +0 -1
- package/dist/mg-components/p-6f173f62.system.entry.js +0 -1
- package/dist/mg-components/p-70177194.entry.js +0 -1
- package/dist/mg-components/p-8b2d8a2a.system.js +0 -13
- package/dist/mg-components/p-8cb61c3f.system.js +0 -1
- package/dist/mg-components/p-ace173b1.js +0 -1
- package/dist/mg-components/p-b7488a4c.entry.js +0 -1
- package/dist/mg-components/p-c1ffb2e1.entry.js +0 -1
- package/dist/mg-components/p-c90cc4bf.system.js +0 -1
- package/dist/mg-components/p-de1164fa.system.entry.js +0 -1
- package/dist/mg-components/p-e4a502b5.system.js +0 -1
- package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +0 -16
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +0 -12
- package/dist/types/stories/messages.stories.d.ts +0 -13
|
@@ -11,16 +11,9 @@
|
|
|
11
11
|
min-height: var(--default-size);
|
|
12
12
|
max-width: 100%;
|
|
13
13
|
margin-bottom: var(--mg-inputs-margin-bottom, 0);
|
|
14
|
-
/* Style when input is not valid */
|
|
15
14
|
/* Label */
|
|
16
15
|
/* Label-on-top */
|
|
17
16
|
}
|
|
18
|
-
.mg-input.is-not-valid {
|
|
19
|
-
color: hsl(var(--color-danger));
|
|
20
|
-
}
|
|
21
|
-
.mg-input.is-not-valid .mg-input__box {
|
|
22
|
-
border-color: hsl(var(--color-danger));
|
|
23
|
-
}
|
|
24
17
|
.mg-input mg-input-title {
|
|
25
18
|
flex-shrink: var(--mg-inputs-shrink, 1);
|
|
26
19
|
width: var(--mg-inputs-title-width, auto);
|
|
@@ -71,8 +64,10 @@
|
|
|
71
64
|
height: var(--mg-icon-regular-size);
|
|
72
65
|
margin-left: var(--mg-inputs-spacer);
|
|
73
66
|
}
|
|
74
|
-
.mg-input__input-container mg-
|
|
75
|
-
|
|
67
|
+
.mg-input__input-container .mg-input__help-text,
|
|
68
|
+
.mg-input__input-container .mg-input__error {
|
|
69
|
+
text-align: start;
|
|
70
|
+
font-size: 1.2rem;
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
.mg-input__input {
|
|
@@ -82,11 +77,26 @@
|
|
|
82
77
|
.mg-input__input mg-tooltip {
|
|
83
78
|
margin-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
84
79
|
}
|
|
85
|
-
.mg-input__input
|
|
86
|
-
|
|
80
|
+
.mg-input__input.mg-input__input--has-error .mg-input__box {
|
|
81
|
+
border-color: hsl(var(--color-danger));
|
|
82
|
+
}
|
|
83
|
+
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
87
84
|
margin-top: 0.5rem;
|
|
88
85
|
}
|
|
89
86
|
|
|
87
|
+
.mg-input__error {
|
|
88
|
+
display: inline-block;
|
|
89
|
+
margin-top: 0.2rem;
|
|
90
|
+
padding: 0.3rem 0.8rem;
|
|
91
|
+
border-radius: 0.3rem;
|
|
92
|
+
background: hsl(var(--mg-inputs-error-bg-color));
|
|
93
|
+
color: hsl(var(--color-danger));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.mg-input__input mg-icon, .mg-input__error mg-icon {
|
|
97
|
+
display: flex;
|
|
98
|
+
}
|
|
99
|
+
|
|
90
100
|
/**
|
|
91
101
|
* A11Y
|
|
92
102
|
*/
|
|
@@ -19,6 +19,8 @@ export class MgInputToggle {
|
|
|
19
19
|
this.classReadonly = 'mg-input--toggle-readonly';
|
|
20
20
|
this.classDisabled = 'mg-input--toggle-disabled';
|
|
21
21
|
this.classIsActive = 'mg-input--toggle-is-active';
|
|
22
|
+
this.classOnOff = 'mg-input--toggle-on-off';
|
|
23
|
+
this.classIcon = 'mg-input--toggle-icon';
|
|
22
24
|
/**
|
|
23
25
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
24
26
|
* If not set, it will be created.
|
|
@@ -106,11 +108,15 @@ export class MgInputToggle {
|
|
|
106
108
|
}
|
|
107
109
|
handleIsOnOff(newValue) {
|
|
108
110
|
if (newValue)
|
|
109
|
-
this.classList.add(
|
|
111
|
+
this.classList.add(this.classOnOff);
|
|
112
|
+
else
|
|
113
|
+
this.classList.delete(this.classOnOff);
|
|
110
114
|
}
|
|
111
115
|
handleIsIcon(newValue) {
|
|
112
116
|
if (newValue)
|
|
113
|
-
this.classList.add(
|
|
117
|
+
this.classList.add(this.classIcon);
|
|
118
|
+
else
|
|
119
|
+
this.classList.delete(this.classIcon);
|
|
114
120
|
}
|
|
115
121
|
handleReadonly(newValue) {
|
|
116
122
|
if (newValue)
|
|
@@ -139,14 +145,23 @@ export class MgInputToggle {
|
|
|
139
145
|
* @returns {void}
|
|
140
146
|
*/
|
|
141
147
|
setChecked() {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);
|
|
149
|
+
if ([0, 1].includes(optionTrueValueIndex)) {
|
|
150
|
+
// has "value" props type is not a boolean, it is bind/render as an attributes/props
|
|
151
|
+
// true props will be represent by "true" string so we convert it has boolean
|
|
152
|
+
// true attribute will be represent by "" string so we convert it has boolean
|
|
153
|
+
// https://stenciljs.com/docs/properties
|
|
154
|
+
if (['', 'true'].includes(this.value) && this.options.find(option => option.value) !== undefined) {
|
|
155
|
+
this.value = true;
|
|
156
|
+
}
|
|
157
|
+
// when options are boolean values and ordered as [true,false] instead [false,true]
|
|
158
|
+
// we need to reversed the checked value logic
|
|
159
|
+
const selectedValue = this.value === this.options[optionTrueValueIndex].value;
|
|
160
|
+
this.checked = optionTrueValueIndex === 0 ? !selectedValue : selectedValue;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
this.checked = this.value === this.options[1].value;
|
|
148
164
|
}
|
|
149
|
-
this.checked = this.value === this.options[1].value;
|
|
150
165
|
}
|
|
151
166
|
/*************
|
|
152
167
|
* Lifecycle *
|
|
@@ -173,7 +188,7 @@ export class MgInputToggle {
|
|
|
173
188
|
* @returns {HTMLElement} HTML Element
|
|
174
189
|
*/
|
|
175
190
|
render() {
|
|
176
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined,
|
|
191
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false },
|
|
177
192
|
h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked },
|
|
178
193
|
h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" },
|
|
179
194
|
h("slot", { name: "item-1" })),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import { filterArgs } from '../../../../../.storybook/utils';
|
|
3
|
+
export default {
|
|
4
|
+
component: 'mg-details',
|
|
5
|
+
title: 'Molecules/mg-details',
|
|
6
|
+
parameters: { actions: { handles: ['expanded-change'] } },
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Template
|
|
10
|
+
*
|
|
11
|
+
* @param {any} args component arguments
|
|
12
|
+
* @returns {HTMLElement} HTMLElement
|
|
13
|
+
*/
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const Template = (args) => (h("mg-details", Object.assign({}, filterArgs(args)),
|
|
16
|
+
args.slotSummary && h("span", { slot: "summary", innerHTML: args.slotSummary }),
|
|
17
|
+
args.slotDetails && h("p", { slot: "details", innerHTML: args.slotDetails })));
|
|
18
|
+
export const MgDetails = Template.bind({});
|
|
19
|
+
MgDetails.args = {
|
|
20
|
+
slotSummary: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
21
|
+
slotDetails: '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.',
|
|
22
|
+
toggleClosed: 'Show details',
|
|
23
|
+
toggleOpened: 'Hide details',
|
|
24
|
+
expanded: false,
|
|
25
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Component, Event, h, Prop, Watch } from '@stencil/core';
|
|
2
|
+
export class MgDetails {
|
|
3
|
+
constructor() {
|
|
4
|
+
/**
|
|
5
|
+
* Define if details are diplayed
|
|
6
|
+
*/
|
|
7
|
+
this.expanded = false;
|
|
8
|
+
/**
|
|
9
|
+
* Handle details toggle
|
|
10
|
+
*
|
|
11
|
+
* @returns {void}
|
|
12
|
+
*/
|
|
13
|
+
this.handleToggle = () => {
|
|
14
|
+
this.expanded = this.details.open;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
validateTitles(newValue) {
|
|
18
|
+
if (newValue === undefined || newValue === '') {
|
|
19
|
+
throw new Error('<mg-details> prop "toggleClosed" and "toggleOpened" must be defined.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
handleExpanded(newValue) {
|
|
23
|
+
this.expandedChange.emit(newValue);
|
|
24
|
+
}
|
|
25
|
+
/*************
|
|
26
|
+
* Lifecycle *
|
|
27
|
+
*************/
|
|
28
|
+
/**
|
|
29
|
+
* Check if component props are well configured on init
|
|
30
|
+
*
|
|
31
|
+
* @returns {void}
|
|
32
|
+
*/
|
|
33
|
+
componentWillLoad() {
|
|
34
|
+
this.validateTitles(this.toggleClosed);
|
|
35
|
+
this.validateTitles(this.toggleOpened);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Render
|
|
39
|
+
*
|
|
40
|
+
* @returns {HTMLElement} HTML Element
|
|
41
|
+
*/
|
|
42
|
+
render() {
|
|
43
|
+
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) },
|
|
44
|
+
h("summary", null,
|
|
45
|
+
h("slot", { name: "summary" }),
|
|
46
|
+
h("span", { class: "mg-details__toggle" },
|
|
47
|
+
h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }),
|
|
48
|
+
" ",
|
|
49
|
+
this.expanded ? this.toggleOpened : this.toggleClosed)),
|
|
50
|
+
h("div", { class: "mg-details__details" },
|
|
51
|
+
h("slot", { name: "details" }))));
|
|
52
|
+
}
|
|
53
|
+
static get is() { return "mg-details"; }
|
|
54
|
+
static get encapsulation() { return "shadow"; }
|
|
55
|
+
static get originalStyleUrls() { return {
|
|
56
|
+
"$": ["mg-details.scss"]
|
|
57
|
+
}; }
|
|
58
|
+
static get styleUrls() { return {
|
|
59
|
+
"$": ["mg-details.css"]
|
|
60
|
+
}; }
|
|
61
|
+
static get properties() { return {
|
|
62
|
+
"toggleClosed": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"mutable": false,
|
|
65
|
+
"complexType": {
|
|
66
|
+
"original": "string",
|
|
67
|
+
"resolved": "string",
|
|
68
|
+
"references": {}
|
|
69
|
+
},
|
|
70
|
+
"required": false,
|
|
71
|
+
"optional": false,
|
|
72
|
+
"docs": {
|
|
73
|
+
"tags": [],
|
|
74
|
+
"text": "Displayed title when details are closed"
|
|
75
|
+
},
|
|
76
|
+
"attribute": "toggle-closed",
|
|
77
|
+
"reflect": false
|
|
78
|
+
},
|
|
79
|
+
"toggleOpened": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"mutable": false,
|
|
82
|
+
"complexType": {
|
|
83
|
+
"original": "string",
|
|
84
|
+
"resolved": "string",
|
|
85
|
+
"references": {}
|
|
86
|
+
},
|
|
87
|
+
"required": false,
|
|
88
|
+
"optional": false,
|
|
89
|
+
"docs": {
|
|
90
|
+
"tags": [],
|
|
91
|
+
"text": "Displayed title when details are opened"
|
|
92
|
+
},
|
|
93
|
+
"attribute": "toggle-opened",
|
|
94
|
+
"reflect": false
|
|
95
|
+
},
|
|
96
|
+
"expanded": {
|
|
97
|
+
"type": "boolean",
|
|
98
|
+
"mutable": true,
|
|
99
|
+
"complexType": {
|
|
100
|
+
"original": "boolean",
|
|
101
|
+
"resolved": "boolean",
|
|
102
|
+
"references": {}
|
|
103
|
+
},
|
|
104
|
+
"required": false,
|
|
105
|
+
"optional": false,
|
|
106
|
+
"docs": {
|
|
107
|
+
"tags": [],
|
|
108
|
+
"text": "Define if details are diplayed"
|
|
109
|
+
},
|
|
110
|
+
"attribute": "expanded",
|
|
111
|
+
"reflect": false,
|
|
112
|
+
"defaultValue": "false"
|
|
113
|
+
}
|
|
114
|
+
}; }
|
|
115
|
+
static get events() { return [{
|
|
116
|
+
"method": "expandedChange",
|
|
117
|
+
"name": "expanded-change",
|
|
118
|
+
"bubbles": true,
|
|
119
|
+
"cancelable": true,
|
|
120
|
+
"composed": true,
|
|
121
|
+
"docs": {
|
|
122
|
+
"tags": [],
|
|
123
|
+
"text": "Emmited event when expanded change"
|
|
124
|
+
},
|
|
125
|
+
"complexType": {
|
|
126
|
+
"original": "boolean",
|
|
127
|
+
"resolved": "boolean",
|
|
128
|
+
"references": {}
|
|
129
|
+
}
|
|
130
|
+
}]; }
|
|
131
|
+
static get watchers() { return [{
|
|
132
|
+
"propName": "toggleClosed",
|
|
133
|
+
"methodName": "validateTitles"
|
|
134
|
+
}, {
|
|
135
|
+
"propName": "toggleOpened",
|
|
136
|
+
"methodName": "validateTitles"
|
|
137
|
+
}, {
|
|
138
|
+
"propName": "expanded",
|
|
139
|
+
"methodName": "handleExpanded"
|
|
140
|
+
}]; }
|
|
141
|
+
}
|
package/dist/collection/components/molecules/mg-form/{mg-form.stories.js → doc/mg-form.stories.js}
RENAMED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
+
import { filterArgs } from '../../../../../.storybook/utils';
|
|
2
3
|
export default {
|
|
3
4
|
component: 'mg-form',
|
|
4
5
|
title: 'Molecules/mg-form',
|
|
5
|
-
parameters: { actions: { handles: ['form-valid'] } },
|
|
6
|
+
parameters: { actions: { handles: ['form-valid', 'form-submit'] } },
|
|
6
7
|
};
|
|
7
8
|
const args = {
|
|
8
9
|
identifier: 'identifier',
|
|
@@ -11,8 +12,7 @@ const args = {
|
|
|
11
12
|
disabled: false,
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
-
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
15
|
+
* Template
|
|
16
16
|
*
|
|
17
17
|
* @param {any} args component arguments
|
|
18
18
|
* @returns {HTMLElement} HTMLElement
|
|
@@ -21,17 +21,20 @@ const args = {
|
|
|
21
21
|
const Template = (args) => {
|
|
22
22
|
let form;
|
|
23
23
|
let submit;
|
|
24
|
-
return (h("mg-form", Object.assign({}, args, { ref: el => {
|
|
24
|
+
return (h("mg-form", Object.assign({}, filterArgs(args), { ref: el => {
|
|
25
25
|
form = el;
|
|
26
26
|
form.addEventListener('form-valid', e => {
|
|
27
27
|
submit.disabled = !e.detail;
|
|
28
28
|
});
|
|
29
|
+
form.addEventListener('form-submit', () => {
|
|
30
|
+
window.alert('Your form has been submitted');
|
|
31
|
+
});
|
|
29
32
|
} }),
|
|
30
33
|
h("mg-input-checkbox", { identifier: "mg-input-checkbox", label: "mg-input-checkbox label", value: [
|
|
31
34
|
{ title: 'oui', value: false },
|
|
32
35
|
{ title: 'non', value: false },
|
|
33
36
|
] }),
|
|
34
|
-
h("mg-input-date", { required: true, identifier: "mg-input-date", label: "mg-input-date label" }),
|
|
37
|
+
h("mg-input-date", Object.assign({}, filterArgs({ required: true }), { identifier: "mg-input-date", label: "mg-input-date label" })),
|
|
35
38
|
h("mg-input-numeric", { identifier: "mg-input-numeric", label: "mg-input-numeric label" }),
|
|
36
39
|
h("mg-input-password", { identifier: "mg-input-password", label: "mg-input-password label" }),
|
|
37
40
|
h("mg-input-radio", { identifier: "mg-input-radio", label: "mg-input-radio label", items: ['blu', 'bli', 'bla', 'blo'] }),
|
|
@@ -48,7 +51,7 @@ const Template = (args) => {
|
|
|
48
51
|
h("mg-button", { id: "can-submit", disabled: true, ref: e => {
|
|
49
52
|
submit = e;
|
|
50
53
|
} }, "Submit"),
|
|
51
|
-
h("mg-button", { variant: "secondary",
|
|
54
|
+
h("mg-button", { variant: "secondary", type: "button",
|
|
52
55
|
// eslint-disable-next-line react/jsx-no-bind
|
|
53
56
|
onClick: () => {
|
|
54
57
|
form.displayError();
|
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
.mg-form,
|
|
6
6
|
.mg-form-group {
|
|
7
|
+
--mg-inputs-title-width: var(--mg-form-inputs-title-width, 15rem);
|
|
7
8
|
--mg-inputs-margin-bottom: 1.5rem;
|
|
8
9
|
--mg-inputs-title-horizontal-space: 3rem;
|
|
9
|
-
--mg-inputs-title-width: 15rem;
|
|
10
10
|
--mg-inputs-shrink: 0;
|
|
11
11
|
}
|
|
12
12
|
.mg-form.mg-form--all-required,
|
|
13
13
|
.mg-form-group.mg-form--all-required {
|
|
14
14
|
--mg-input-title-display: none;
|
|
15
|
+
}
|
|
16
|
+
.mg-form > p,
|
|
17
|
+
.mg-form-group > p {
|
|
18
|
+
font-size: 1.2rem;
|
|
15
19
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, Element, Event, h, Method, Prop, State } from '@stencil/core';
|
|
2
2
|
import { createID, ClassList } from '../../../utils/components.utils';
|
|
3
|
-
import {
|
|
3
|
+
import { initLocales } from '../../../locales';
|
|
4
4
|
export class MgForm {
|
|
5
5
|
constructor() {
|
|
6
6
|
/**
|
|
@@ -37,12 +37,12 @@ export class MgForm {
|
|
|
37
37
|
// All fields are required
|
|
38
38
|
// mg-input-toggle can not be required
|
|
39
39
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
40
|
-
this.requiredMessage = messages.form.allRequired;
|
|
40
|
+
this.requiredMessage = this.messages.form.allRequired;
|
|
41
41
|
this.classList.add('mg-form--all-required');
|
|
42
42
|
}
|
|
43
43
|
// Some fields are required
|
|
44
44
|
else if (requiredInputs.length > 0) {
|
|
45
|
-
this.requiredMessage = messages.form.required;
|
|
45
|
+
this.requiredMessage = this.messages.form.required;
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
@@ -56,6 +56,10 @@ export class MgForm {
|
|
|
56
56
|
this.invalid = !validity;
|
|
57
57
|
this.formValid.emit(validity);
|
|
58
58
|
};
|
|
59
|
+
this.handleFormSubmit = (event) => {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
this.formSubmit.emit();
|
|
62
|
+
};
|
|
59
63
|
}
|
|
60
64
|
/**
|
|
61
65
|
* Public method to display errors
|
|
@@ -79,11 +83,19 @@ export class MgForm {
|
|
|
79
83
|
* @returns {void}
|
|
80
84
|
*/
|
|
81
85
|
componentWillLoad() {
|
|
82
|
-
// Get
|
|
86
|
+
// Get locales
|
|
87
|
+
this.messages = initLocales(this.element).messages;
|
|
88
|
+
// Get slotted mgInputs
|
|
83
89
|
this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
|
|
90
|
+
// Get slotted mgButtons
|
|
91
|
+
this.mgButtons = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-BUTTON'));
|
|
92
|
+
// Set button form identifier
|
|
93
|
+
this.mgButtons.forEach(mgButton => {
|
|
94
|
+
mgButton.setAttribute('form', this.identifier);
|
|
95
|
+
});
|
|
84
96
|
// Define required message
|
|
85
97
|
this.setRequiredMessage();
|
|
86
|
-
// Check validity when slotted
|
|
98
|
+
// Check validity when slotted mgInputs are ready
|
|
87
99
|
Promise.all(this.mgInputs.map(async (input) => {
|
|
88
100
|
// Set inputs readonly or disabled based on form configuration
|
|
89
101
|
// Othewise listen to events
|
|
@@ -93,18 +105,37 @@ export class MgForm {
|
|
|
93
105
|
input.disabled = true;
|
|
94
106
|
else
|
|
95
107
|
input.addEventListener('input-valid', this.checkValidity);
|
|
96
|
-
|
|
108
|
+
try {
|
|
109
|
+
await input.componentOnReady();
|
|
110
|
+
}
|
|
111
|
+
catch (_a) { } // prevent error with VueJS first render
|
|
97
112
|
})).then(() => {
|
|
98
113
|
this.checkValidity();
|
|
99
114
|
});
|
|
100
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Add slot listeners
|
|
118
|
+
*
|
|
119
|
+
* @returns {void}
|
|
120
|
+
*/
|
|
121
|
+
componentDidLoad() {
|
|
122
|
+
this.mgButtons.forEach(mgButton => {
|
|
123
|
+
// submit buttons should trigger form submition
|
|
124
|
+
const button = mgButton.querySelector('button');
|
|
125
|
+
if (['submit', null].includes(button.getAttribute('type'))) {
|
|
126
|
+
mgButton.addEventListener('click', () => {
|
|
127
|
+
this.form.dispatchEvent(new CustomEvent('submit', { bubbles: true }));
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
101
132
|
/**
|
|
102
133
|
* Render
|
|
103
134
|
*
|
|
104
135
|
* @returns {HTMLElement} HTML Element
|
|
105
136
|
*/
|
|
106
137
|
render() {
|
|
107
|
-
return (h("form", { class: this.classList.join(), id: this.identifier, name: this.name },
|
|
138
|
+
return (h("form", { class: this.classList.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit },
|
|
108
139
|
this.requiredMessage && h("p", { innerHTML: this.requiredMessage }),
|
|
109
140
|
h("slot", null),
|
|
110
141
|
!this.readonly && !this.disabled && h("slot", { name: "actions" })));
|
|
@@ -243,6 +274,21 @@ export class MgForm {
|
|
|
243
274
|
"resolved": "boolean",
|
|
244
275
|
"references": {}
|
|
245
276
|
}
|
|
277
|
+
}, {
|
|
278
|
+
"method": "formSubmit",
|
|
279
|
+
"name": "form-submit",
|
|
280
|
+
"bubbles": true,
|
|
281
|
+
"cancelable": true,
|
|
282
|
+
"composed": true,
|
|
283
|
+
"docs": {
|
|
284
|
+
"tags": [],
|
|
285
|
+
"text": "Emitted event on form submit"
|
|
286
|
+
},
|
|
287
|
+
"complexType": {
|
|
288
|
+
"original": "boolean",
|
|
289
|
+
"resolved": "boolean",
|
|
290
|
+
"references": {}
|
|
291
|
+
}
|
|
246
292
|
}]; }
|
|
247
293
|
static get methods() { return {
|
|
248
294
|
"displayError": {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export default {
|
|
3
|
+
component: 'mg-illustrated-message',
|
|
4
|
+
title: 'Molecules/mg-illustrated-message',
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
8
|
+
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
9
|
+
*/
|
|
10
|
+
const Template = args => {
|
|
11
|
+
// return element
|
|
12
|
+
return (h("mg-illustrated-message", Object.assign({}, args),
|
|
13
|
+
h("svg", { slot: "illustration", width: "190", height: "350", viewBox: "0 0 190 350", xmlns: "http://www.w3.org/2000/svg" },
|
|
14
|
+
h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M0 0H15C23.2843 0 30 6.71573 30 15V290H40V15C40 6.71573 46.7157 0 55 0C63.2843 0 70 6.71573 70 15V275C70 277.761 67.7615 280 65 280H60V40H50V340H60V290H65C67.7615 290 70 292.239 70 295V340H80V295C80 291.158 78.5558 287.654 76.1805 285C78.5558 282.346 80 278.842 80 275V0H95C103.284 0 110 6.71573 110 15V25C110 28.8418 108.556 32.3462 106.181 35C108.556 37.6538 110 41.1582 110 45V305C110 307.761 107.761 310 105 310H100V45C100 42.2386 97.7615 40 95 40H90V325C90 333.284 96.7157 340 105 340H120V330H105C102.239 330 100 327.761 100 325V320H105C113.284 320 120 313.284 120 305V15C120 6.71573 126.716 0 135 0C143.284 0 150 6.71573 150 15V330H140V15C140 12.2386 137.761 10 135 10C132.239 10 130 12.2386 130 15V340H165C173.284 340 180 333.284 180 325V15C180 12.2386 177.761 10 175 10H170V325C170 327.761 167.761 330 165 330H160V0H175C183.284 0 190 6.71573 190 15V350H0V0ZM10 325C10 333.284 16.7157 340 25 340C33.2843 340 40 333.284 40 325V300H30V325C30 327.761 27.7615 330 25 330C22.2385 330 20 327.761 20 325V15C20 12.2386 17.7615 10 15 10H10V325ZM60 15V30H50V15C50 12.2386 52.2385 10 55 10C57.7615 10 60 12.2386 60 15ZM95 30H90V10H95C97.7615 10 100 12.2386 100 15V25C100 27.7614 97.7615 30 95 30Z", fill: "black" })),
|
|
15
|
+
h("h2", { slot: "title" }, "Lorem Ipsum"),
|
|
16
|
+
h("h3", { slot: "details" }, "The standard Lorem Ipsum passage, used since the 1500s"),
|
|
17
|
+
h("div", { slot: "details" }, "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.")));
|
|
18
|
+
};
|
|
19
|
+
export const MgIllustratedMessage = Template.bind({});
|
|
20
|
+
MgIllustratedMessage.args = {
|
|
21
|
+
size: 'regular',
|
|
22
|
+
};
|
package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.mg-illustrated-message {
|
|
2
|
+
margin: auto;
|
|
3
|
+
padding: 0 1.5rem;
|
|
4
|
+
max-width: 47.5rem;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
text-align: center;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.mg-illustrated-message__illustration {
|
|
10
|
+
max-height: 33.5rem;
|
|
11
|
+
}
|
|
12
|
+
.mg-illustrated-message__illustration ::slotted([slot=illustration]) {
|
|
13
|
+
width: auto;
|
|
14
|
+
height: auto;
|
|
15
|
+
max-width: 100%;
|
|
16
|
+
max-height: 33.5rem;
|
|
17
|
+
}
|
|
18
|
+
.mg-illustrated-message__illustration.mg-illustrated-message__illustration--small {
|
|
19
|
+
max-height: 6rem;
|
|
20
|
+
}
|
|
21
|
+
.mg-illustrated-message__illustration.mg-illustrated-message__illustration--small ::slotted([slot=illustration]) {
|
|
22
|
+
max-height: 6rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.mg-illustrated-message__title {
|
|
26
|
+
margin: 3rem 0 0;
|
|
27
|
+
}
|
|
28
|
+
.mg-illustrated-message__title ::slotted([slot=title]) {
|
|
29
|
+
margin: 0;
|
|
30
|
+
font-size: 2rem !important;
|
|
31
|
+
font-family: var(--font-family) !important;
|
|
32
|
+
font-weight: 400;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.mg-illustrated-message__details ::slotted([slot=details]) {
|
|
36
|
+
margin: 2rem 0 0;
|
|
37
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Component, Element, h, Prop } from '@stencil/core';
|
|
2
|
+
import { isTagName } from '../../../utils/components.utils';
|
|
3
|
+
export class MgIllustratedMessage {
|
|
4
|
+
constructor() {
|
|
5
|
+
/**
|
|
6
|
+
* Define illustration size
|
|
7
|
+
*/
|
|
8
|
+
this.size = 'regular';
|
|
9
|
+
}
|
|
10
|
+
/*************
|
|
11
|
+
* Lifecycle *
|
|
12
|
+
*************/
|
|
13
|
+
/**
|
|
14
|
+
* Check if component props are well configured on init
|
|
15
|
+
*
|
|
16
|
+
* @returns {void}
|
|
17
|
+
*/
|
|
18
|
+
componentDidLoad() {
|
|
19
|
+
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
20
|
+
const imageTags = ['img', 'svg'];
|
|
21
|
+
if (!isTagName(this.element.querySelector('[slot="title"]'), headingTags)) {
|
|
22
|
+
throw new Error(`<mg-illustrated-message> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
23
|
+
}
|
|
24
|
+
else if (!isTagName(this.element.querySelector('[slot="illustration"]'), imageTags)) {
|
|
25
|
+
throw new Error(`<mg-illustrated-message> Slotted illustration must be an image: ${imageTags.join(', ')}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Render
|
|
30
|
+
*
|
|
31
|
+
* @returns {HTMLElement} HTML Element
|
|
32
|
+
*/
|
|
33
|
+
render() {
|
|
34
|
+
return (h("div", { class: "mg-illustrated-message" },
|
|
35
|
+
h("div", { class: {
|
|
36
|
+
'mg-illustrated-message__illustration': true,
|
|
37
|
+
'mg-illustrated-message__illustration--small': this.size === 'small',
|
|
38
|
+
} },
|
|
39
|
+
h("slot", { name: "illustration" })),
|
|
40
|
+
h("div", { class: "mg-illustrated-message__title" },
|
|
41
|
+
h("slot", { name: "title" })),
|
|
42
|
+
h("div", { class: "mg-illustrated-message__details" },
|
|
43
|
+
h("slot", { name: "details" }))));
|
|
44
|
+
}
|
|
45
|
+
static get is() { return "mg-illustrated-message"; }
|
|
46
|
+
static get encapsulation() { return "shadow"; }
|
|
47
|
+
static get originalStyleUrls() { return {
|
|
48
|
+
"$": ["mg-illustrated-message.scss"]
|
|
49
|
+
}; }
|
|
50
|
+
static get styleUrls() { return {
|
|
51
|
+
"$": ["mg-illustrated-message.css"]
|
|
52
|
+
}; }
|
|
53
|
+
static get properties() { return {
|
|
54
|
+
"size": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"mutable": false,
|
|
57
|
+
"complexType": {
|
|
58
|
+
"original": "'regular' | 'small'",
|
|
59
|
+
"resolved": "\"regular\" | \"small\"",
|
|
60
|
+
"references": {}
|
|
61
|
+
},
|
|
62
|
+
"required": false,
|
|
63
|
+
"optional": false,
|
|
64
|
+
"docs": {
|
|
65
|
+
"tags": [],
|
|
66
|
+
"text": "Define illustration size"
|
|
67
|
+
},
|
|
68
|
+
"attribute": "size",
|
|
69
|
+
"reflect": false,
|
|
70
|
+
"defaultValue": "'regular'"
|
|
71
|
+
}
|
|
72
|
+
}; }
|
|
73
|
+
static get elementRef() { return "element"; }
|
|
74
|
+
}
|