@mgdis/mg-components 3.2.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-bead7dbd.js → index-88560a66.js} +47 -48
- package/dist/cjs/{index-369388eb.js → index-a39c5567.js} +97 -10
- package/dist/cjs/loader.cjs.js +3 -17
- package/dist/cjs/mg-badge_21.cjs.entry.js +519 -294
- package/dist/cjs/mg-components.cjs.js +3 -7
- package/dist/cjs/mg-modal.cjs.entry.js +12 -6
- package/dist/cjs/mg-popover.cjs.entry.js +15 -10
- package/dist/cjs/{popper-0c3964e7.js → popper-71bf3058.js} +6 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.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 +15 -3
- package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +2 -2
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.css +20 -32
- package/dist/collection/components/atoms/mg-button/mg-button.js +8 -3
- package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +1 -1
- 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} +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +97 -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/{mg-input-title.stories.js → doc/mg-input-title.stories.js} +0 -0
- package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +1 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +19 -4
- 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 +7 -2
- 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} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +19 -13
- 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} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +19 -18
- 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 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +20 -19
- 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 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +19 -18
- 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} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +19 -13
- 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 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +20 -18
- 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} +11 -7
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +51 -28
- 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} +10 -4
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +51 -22
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +66 -39
- package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +18 -9
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +10 -4
- package/dist/collection/components/molecules/mg-form/{mg-form.stories.js → doc/mg-form.stories.js} +0 -0
- package/dist/collection/components/molecules/mg-form/mg-form.css +4 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +5 -3
- package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +15 -7
- package/dist/collection/components/molecules/mg-modal/{mg-modal.stories.js → doc/mg-modal.stories.js} +0 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +5 -7
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +12 -5
- package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +0 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +17 -18
- package/dist/collection/components/molecules/mg-panel/{mg-panel.stories.js → doc/mg-panel.stories.js} +9 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +13 -4
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +119 -18
- 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.js +19 -9
- package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +12 -5
- 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 +92 -27
- package/dist/collection/locales/index.js +33 -4
- package/dist/collection/stories/helpers.stories.js +33 -0
- package/dist/collection/utils/locale.utils.js +7 -4
- package/dist/collection/variables.css +9 -4
- package/dist/collection/variables.scss +9 -4
- package/dist/components/MgInput.js +6 -23
- package/dist/components/index.d.ts +23 -5
- package/dist/components/index.js +23 -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 +10 -5
- package/dist/components/mg-character-left2.js +4 -27
- package/dist/components/mg-form.js +6 -4
- package/dist/components/mg-icon2.js +120 -17
- 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 +44 -21
- package/dist/components/mg-input-toggle.js +11 -11
- 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 +51 -17
- package/dist/components/mg-popover.js +13 -8
- package/dist/components/mg-tabs.js +80 -22
- package/dist/components/mg-tag.js +20 -5
- package/dist/components/mg-tooltip2.js +1 -1
- package/dist/components/popper.js +6 -2
- package/dist/esm/{index-9e877561.js → index-bca81100.js} +48 -46
- package/dist/esm/{index-c346f52d.js → index-e51ae032.js} +97 -8
- package/dist/esm/loader.js +3 -17
- package/dist/esm/mg-badge_21.entry.js +516 -291
- package/dist/esm/mg-components.js +3 -7
- package/dist/esm/mg-modal.entry.js +12 -6
- package/dist/esm/mg-popover.entry.js +15 -10
- package/dist/esm/{popper-8874fd6c.js → popper-93ecb064.js} +6 -2
- 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-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-766c918b.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 +9 -4
- package/dist/mg-components/variables.scss +9 -4
- 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} +0 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +1 -1
- package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +0 -0
- 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 +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 +2 -1
- 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/doc/mg-input-textarea.stories.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +15 -7
- 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-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 +1 -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/{inputs/mg-input-textarea/mg-input-textarea.stories.d.ts → mg-panel/doc/mg-panel.stories.d.ts} +1 -1
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +29 -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 +9 -1
- package/dist/types/components/molecules/mg-tabs/{mg-tabs.stories.d.ts → doc/mg-tabs.stories.d.ts} +5 -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 +49 -0
- package/dist/types/components.d.ts +181 -151
- 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/locale.utils.d.ts +7 -3
- package/loader/index.js +1 -1
- package/package.json +14 -14
- package/readme.md +6 -35
- package/dist/cjs/css-shim-629916b0.js +0 -6
- package/dist/cjs/shadow-css-546083ef.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-0993aa3b.js +0 -4
- 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-3633e9e1.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-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-c46fbd54.entry.js +0 -1
- package/dist/mg-components/p-c90cc4bf.system.js +0 -1
- package/dist/mg-components/p-cd2a4acc.system.entry.js +0 -1
- package/dist/mg-components/p-de1164fa.system.entry.js +0 -1
- package/dist/mg-components/p-dfe25da3.entry.js +0 -1
- package/dist/mg-components/p-e4a502b5.system.js +0 -1
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-panel/mg-panel.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +0 -12
- package/dist/types/stories/messages.stories.d.ts +0 -13
- package/dist/types/stories/tags.stories.d.ts +0 -5
|
@@ -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);
|
|
@@ -74,6 +67,11 @@
|
|
|
74
67
|
.mg-input__input-container mg-icon {
|
|
75
68
|
display: flex;
|
|
76
69
|
}
|
|
70
|
+
.mg-input__input-container .mg-input__help-text,
|
|
71
|
+
.mg-input__input-container .mg-input__error {
|
|
72
|
+
text-align: start;
|
|
73
|
+
font-size: 1.2rem;
|
|
74
|
+
}
|
|
77
75
|
|
|
78
76
|
.mg-input__input {
|
|
79
77
|
display: flex;
|
|
@@ -82,11 +80,22 @@
|
|
|
82
80
|
.mg-input__input mg-tooltip {
|
|
83
81
|
margin-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
84
82
|
}
|
|
85
|
-
.mg-input__input
|
|
86
|
-
|
|
83
|
+
.mg-input__input.mg-input__input--has-error .mg-input__box {
|
|
84
|
+
border-color: hsl(var(--color-danger));
|
|
85
|
+
}
|
|
86
|
+
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
87
87
|
margin-top: 0.5rem;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
.mg-input__error {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
margin-top: 0.2rem;
|
|
93
|
+
padding: 0.3rem 0.8rem;
|
|
94
|
+
border-radius: 0.3rem;
|
|
95
|
+
background: hsl(var(--mg-inputs-error-bg-color));
|
|
96
|
+
color: hsl(var(--color-danger));
|
|
97
|
+
}
|
|
98
|
+
|
|
90
99
|
/**
|
|
91
100
|
* Style for input "box":
|
|
92
101
|
* - input[type="text"]
|
|
@@ -97,7 +106,6 @@
|
|
|
97
106
|
*/
|
|
98
107
|
.mg-input__box {
|
|
99
108
|
padding: calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);
|
|
100
|
-
width: 100%;
|
|
101
109
|
height: var(--default-size);
|
|
102
110
|
box-sizing: border-box;
|
|
103
111
|
border-width: var(--mg-inputs-border-width);
|
|
@@ -108,6 +116,7 @@
|
|
|
108
116
|
font-family: inherit;
|
|
109
117
|
color: hsl(var(--color-dark));
|
|
110
118
|
font-size: var(--font-size);
|
|
119
|
+
text-align: var(--mg-inputs-text-align, left);
|
|
111
120
|
}
|
|
112
121
|
.mg-input__box::placeholder {
|
|
113
122
|
color: var(--mg-inputs-color);
|
|
@@ -155,10 +164,6 @@
|
|
|
155
164
|
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]) {
|
|
156
165
|
--mg-button-border-radius-top-right: 0;
|
|
157
166
|
--mg-button-border-radius-bottom-right: 0;
|
|
158
|
-
--mg-button-border-radius-top-left: 0;
|
|
159
|
-
/* IE FIX */
|
|
160
|
-
--mg-button-border-radius-bottom-left: 0;
|
|
161
|
-
/* IE FIX */
|
|
162
167
|
}
|
|
163
168
|
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)) {
|
|
164
169
|
--mg-button-border-right-width: 0;
|
|
@@ -166,10 +171,6 @@
|
|
|
166
171
|
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type) {
|
|
167
172
|
--mg-button-border-radius-top-right: var(--mg-inputs-border-radius);
|
|
168
173
|
--mg-button-border-radius-bottom-right: var(--mg-inputs-border-radius);
|
|
169
|
-
--mg-button-border-radius-top-left: 0;
|
|
170
|
-
/* IE FIX */
|
|
171
|
-
--mg-button-border-radius-bottom-left: 0;
|
|
172
|
-
/* IE FIX */
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]) {
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { Component, Event, h, Prop, State, Method, Watch } from '@stencil/core';
|
|
1
|
+
import { Component, Element, Event, h, Prop, State, Method, Watch } from '@stencil/core';
|
|
2
2
|
import { MgInput } from '../MgInput';
|
|
3
|
-
import { InputClass } from '../MgInput.conf';
|
|
4
3
|
import { createID, ClassList } from '../../../../utils/components.utils';
|
|
5
|
-
import {
|
|
4
|
+
import { initLocales } from '../../../../locales';
|
|
6
5
|
export class MgInputPassword {
|
|
7
6
|
constructor() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
************/
|
|
11
|
-
// classes
|
|
12
|
-
this.classError = InputClass.ERROR;
|
|
7
|
+
// hasError (triggered by blur event)
|
|
8
|
+
this.hasError = false;
|
|
13
9
|
/**
|
|
14
10
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
15
11
|
* If not set, it will be created.
|
|
@@ -39,7 +35,7 @@ export class MgInputPassword {
|
|
|
39
35
|
/**
|
|
40
36
|
* Define input width
|
|
41
37
|
*/
|
|
42
|
-
this.
|
|
38
|
+
this.mgWidth = 'full';
|
|
43
39
|
/**
|
|
44
40
|
* Component classes
|
|
45
41
|
*/
|
|
@@ -49,14 +45,16 @@ export class MgInputPassword {
|
|
|
49
45
|
*/
|
|
50
46
|
this.handleInput = () => {
|
|
51
47
|
this.checkValidity();
|
|
48
|
+
if (this.hasError) {
|
|
49
|
+
this.checkError();
|
|
50
|
+
}
|
|
52
51
|
this.value = this.input.value;
|
|
53
52
|
};
|
|
54
53
|
/**
|
|
55
54
|
* Handle blur event
|
|
56
55
|
*/
|
|
57
56
|
this.handleBlur = () => {
|
|
58
|
-
this.
|
|
59
|
-
this.checkError();
|
|
57
|
+
this.displayError();
|
|
60
58
|
};
|
|
61
59
|
/**
|
|
62
60
|
* Check if input is valid
|
|
@@ -79,14 +77,7 @@ export class MgInputPassword {
|
|
|
79
77
|
this.errorMessage = undefined;
|
|
80
78
|
// required
|
|
81
79
|
if (!this.valid && this.input.validity.valueMissing) {
|
|
82
|
-
this.errorMessage = messages.errors.required;
|
|
83
|
-
}
|
|
84
|
-
// Update class
|
|
85
|
-
if (this.valid) {
|
|
86
|
-
this.classList.delete(this.classError);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
this.classList.add(this.classError);
|
|
80
|
+
this.errorMessage = this.messages.errors.required;
|
|
90
81
|
}
|
|
91
82
|
};
|
|
92
83
|
}
|
|
@@ -101,6 +92,7 @@ export class MgInputPassword {
|
|
|
101
92
|
async displayError() {
|
|
102
93
|
this.checkValidity();
|
|
103
94
|
this.checkError();
|
|
95
|
+
this.hasError = this.invalid;
|
|
104
96
|
}
|
|
105
97
|
/*************
|
|
106
98
|
* Lifecycle *
|
|
@@ -111,6 +103,8 @@ export class MgInputPassword {
|
|
|
111
103
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
112
104
|
*/
|
|
113
105
|
componentWillLoad() {
|
|
106
|
+
// Get locales
|
|
107
|
+
this.messages = initLocales(this.element).messages;
|
|
114
108
|
// Check validity when component is ready
|
|
115
109
|
// return a promise to process action only in the FIRST render().
|
|
116
110
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
@@ -124,7 +118,7 @@ export class MgInputPassword {
|
|
|
124
118
|
* @returns {HTMLElement} HTML Element
|
|
125
119
|
*/
|
|
126
120
|
render() {
|
|
127
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly,
|
|
121
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false },
|
|
128
122
|
h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) })));
|
|
129
123
|
}
|
|
130
124
|
static get is() { return "mg-input-password"; }
|
|
@@ -312,7 +306,7 @@ export class MgInputPassword {
|
|
|
312
306
|
"reflect": false,
|
|
313
307
|
"defaultValue": "false"
|
|
314
308
|
},
|
|
315
|
-
"
|
|
309
|
+
"mgWidth": {
|
|
316
310
|
"type": "any",
|
|
317
311
|
"mutable": false,
|
|
318
312
|
"complexType": {
|
|
@@ -331,7 +325,7 @@ export class MgInputPassword {
|
|
|
331
325
|
"tags": [],
|
|
332
326
|
"text": "Define input width"
|
|
333
327
|
},
|
|
334
|
-
"attribute": "width",
|
|
328
|
+
"attribute": "mg-width",
|
|
335
329
|
"reflect": false,
|
|
336
330
|
"defaultValue": "'full'"
|
|
337
331
|
},
|
|
@@ -460,6 +454,7 @@ export class MgInputPassword {
|
|
|
460
454
|
}
|
|
461
455
|
}
|
|
462
456
|
}; }
|
|
457
|
+
static get elementRef() { return "element"; }
|
|
463
458
|
static get watchers() { return [{
|
|
464
459
|
"propName": "value",
|
|
465
460
|
"methodName": "handleValue"
|
|
File without changes
|
|
@@ -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);
|
|
@@ -74,6 +67,11 @@
|
|
|
74
67
|
.mg-input__input-container mg-icon {
|
|
75
68
|
display: flex;
|
|
76
69
|
}
|
|
70
|
+
.mg-input__input-container .mg-input__help-text,
|
|
71
|
+
.mg-input__input-container .mg-input__error {
|
|
72
|
+
text-align: start;
|
|
73
|
+
font-size: 1.2rem;
|
|
74
|
+
}
|
|
77
75
|
|
|
78
76
|
.mg-input__input {
|
|
79
77
|
display: flex;
|
|
@@ -82,11 +80,22 @@
|
|
|
82
80
|
.mg-input__input mg-tooltip {
|
|
83
81
|
margin-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
84
82
|
}
|
|
85
|
-
.mg-input__input
|
|
86
|
-
|
|
83
|
+
.mg-input__input.mg-input__input--has-error .mg-input__box {
|
|
84
|
+
border-color: hsl(var(--color-danger));
|
|
85
|
+
}
|
|
86
|
+
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
87
87
|
margin-top: 0.5rem;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
.mg-input__error {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
margin-top: 0.2rem;
|
|
93
|
+
padding: 0.3rem 0.8rem;
|
|
94
|
+
border-radius: 0.3rem;
|
|
95
|
+
background: hsl(var(--mg-inputs-error-bg-color));
|
|
96
|
+
color: hsl(var(--color-danger));
|
|
97
|
+
}
|
|
98
|
+
|
|
90
99
|
/**
|
|
91
100
|
* Manage style when input needs to be a fieldset, like checkbox and radio.
|
|
92
101
|
*/
|
|
@@ -110,12 +119,9 @@ fieldset.mg-input input[type=checkbox] {
|
|
|
110
119
|
fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
|
|
111
120
|
margin-top: 0.7rem;
|
|
112
121
|
}
|
|
113
|
-
fieldset.mg-input.is-not-valid .mg-input__input-group {
|
|
114
|
-
color: initial;
|
|
115
|
-
}
|
|
116
122
|
|
|
117
123
|
.mg-input__input-container mg-tooltip {
|
|
118
|
-
margin-left:
|
|
124
|
+
margin-left: 3rem;
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
/* input group container */
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
import { Component, Event, h, Prop, State, Watch, Method } from '@stencil/core';
|
|
3
|
+
import { Component, Element, Event, h, Prop, State, Watch, Method } from '@stencil/core';
|
|
4
4
|
import { MgInput } from '../MgInput';
|
|
5
5
|
import { createID, ClassList, allItemsAreString } from '../../../../utils/components.utils';
|
|
6
|
-
import {
|
|
7
|
-
import { InputClass } from '../MgInput.conf';
|
|
6
|
+
import { initLocales } from '../../../../locales';
|
|
8
7
|
/**
|
|
9
8
|
* type Option validation function
|
|
10
9
|
*
|
|
@@ -17,8 +16,6 @@ export class MgInputRadio {
|
|
|
17
16
|
/************
|
|
18
17
|
* Internal *
|
|
19
18
|
************/
|
|
20
|
-
// classes
|
|
21
|
-
this.classError = InputClass.ERROR;
|
|
22
19
|
// HTML selector
|
|
23
20
|
this.inputs = [];
|
|
24
21
|
/**
|
|
@@ -103,14 +100,7 @@ export class MgInputRadio {
|
|
|
103
100
|
// Set error message
|
|
104
101
|
this.errorMessage = undefined;
|
|
105
102
|
if (!this.valid && invalidElement.validity.valueMissing) {
|
|
106
|
-
this.errorMessage = messages.errors.required;
|
|
107
|
-
}
|
|
108
|
-
// Update class
|
|
109
|
-
if (this.valid) {
|
|
110
|
-
this.classList.delete(this.classError);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this.classList.add(this.classError);
|
|
103
|
+
this.errorMessage = this.messages.errors.required;
|
|
114
104
|
}
|
|
115
105
|
};
|
|
116
106
|
/**
|
|
@@ -158,7 +148,9 @@ export class MgInputRadio {
|
|
|
158
148
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
159
149
|
*/
|
|
160
150
|
componentWillLoad() {
|
|
161
|
-
//
|
|
151
|
+
// Get locales
|
|
152
|
+
this.messages = initLocales(this.element).messages;
|
|
153
|
+
// Validate
|
|
162
154
|
this.validateItems(this.items);
|
|
163
155
|
// Check validity when component is ready
|
|
164
156
|
// return a promise to process action only in the FIRST render().
|
|
@@ -173,7 +165,7 @@ export class MgInputRadio {
|
|
|
173
165
|
* @returns {HTMLElement} HTML Element
|
|
174
166
|
*/
|
|
175
167
|
render() {
|
|
176
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly,
|
|
168
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true },
|
|
177
169
|
h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index) => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } },
|
|
178
170
|
h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => this.inputs.push(el) }),
|
|
179
171
|
h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
|
|
@@ -511,6 +503,7 @@ export class MgInputRadio {
|
|
|
511
503
|
}
|
|
512
504
|
}
|
|
513
505
|
}; }
|
|
506
|
+
static get elementRef() { return "element"; }
|
|
514
507
|
static get watchers() { return [{
|
|
515
508
|
"propName": "value",
|
|
516
509
|
"methodName": "handleValue"
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
-
import
|
|
2
|
+
import messages from '../../../../../locales/en/messages.json';
|
|
3
3
|
export default {
|
|
4
4
|
component: 'mg-input-select',
|
|
5
5
|
title: 'Molecules/Inputs/mg-input-select',
|
|
6
|
-
parameters: { actions: { handles: ['value-change', 'input-valid'] } },
|
|
7
6
|
argTypes: {
|
|
8
7
|
placeholder: {
|
|
9
8
|
table: {
|
|
10
9
|
defaultValue: { summary: messages.input.select.placeholder },
|
|
11
10
|
},
|
|
12
11
|
},
|
|
12
|
+
mgWidth: {
|
|
13
|
+
options: [undefined, 2, 4, 16, 'full'],
|
|
14
|
+
control: { type: 'select' },
|
|
15
|
+
},
|
|
13
16
|
},
|
|
17
|
+
parameters: { actions: { handles: ['value-change', 'input-valid'] } },
|
|
14
18
|
};
|
|
15
19
|
/**
|
|
16
20
|
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
@@ -31,8 +35,10 @@ const Template = (args) => {
|
|
|
31
35
|
delete args.placeholderDisabled;
|
|
32
36
|
const placeholderHide = args.placeholderHide;
|
|
33
37
|
delete args.placeholderHide;
|
|
38
|
+
const mgWidth = args.mgWidth;
|
|
39
|
+
delete args.mgWidth;
|
|
34
40
|
// return element
|
|
35
|
-
return (h("mg-input-select", Object.assign({}, args, { "label-on-top": labelOnTop, "label-hide": labelHide, "help-text": helpText, "placeholder-hide": placeholderHide, "placeholder-disabled": placeholderDisabled })));
|
|
41
|
+
return (h("mg-input-select", Object.assign({}, args, { "label-on-top": labelOnTop, "label-hide": labelHide, "help-text": helpText, "placeholder-hide": placeholderHide, "placeholder-disabled": placeholderDisabled, "mg-width": mgWidth })));
|
|
36
42
|
};
|
|
37
43
|
export const MgInputSelect = Template.bind({});
|
|
38
44
|
MgInputSelect.args = {
|
|
@@ -49,6 +55,7 @@ MgInputSelect.args = {
|
|
|
49
55
|
readonly: false,
|
|
50
56
|
disabled: false,
|
|
51
57
|
items: ['blu', 'bli', 'blo', 'bla'],
|
|
58
|
+
mgWidth: undefined,
|
|
52
59
|
// Tooltip
|
|
53
60
|
tooltip: 'This is a tooltip',
|
|
54
61
|
// Help Text
|
|
@@ -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);
|
|
@@ -74,6 +67,11 @@
|
|
|
74
67
|
.mg-input__input-container mg-icon {
|
|
75
68
|
display: flex;
|
|
76
69
|
}
|
|
70
|
+
.mg-input__input-container .mg-input__help-text,
|
|
71
|
+
.mg-input__input-container .mg-input__error {
|
|
72
|
+
text-align: start;
|
|
73
|
+
font-size: 1.2rem;
|
|
74
|
+
}
|
|
77
75
|
|
|
78
76
|
.mg-input__input {
|
|
79
77
|
display: flex;
|
|
@@ -82,11 +80,22 @@
|
|
|
82
80
|
.mg-input__input mg-tooltip {
|
|
83
81
|
margin-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
84
82
|
}
|
|
85
|
-
.mg-input__input
|
|
86
|
-
|
|
83
|
+
.mg-input__input.mg-input__input--has-error .mg-input__box {
|
|
84
|
+
border-color: hsl(var(--color-danger));
|
|
85
|
+
}
|
|
86
|
+
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
87
87
|
margin-top: 0.5rem;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
.mg-input__error {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
margin-top: 0.2rem;
|
|
93
|
+
padding: 0.3rem 0.8rem;
|
|
94
|
+
border-radius: 0.3rem;
|
|
95
|
+
background: hsl(var(--mg-inputs-error-bg-color));
|
|
96
|
+
color: hsl(var(--color-danger));
|
|
97
|
+
}
|
|
98
|
+
|
|
90
99
|
/**
|
|
91
100
|
* Style for input "box":
|
|
92
101
|
* - input[type="text"]
|
|
@@ -97,7 +106,6 @@
|
|
|
97
106
|
*/
|
|
98
107
|
.mg-input__box {
|
|
99
108
|
padding: calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);
|
|
100
|
-
width: 100%;
|
|
101
109
|
height: var(--default-size);
|
|
102
110
|
box-sizing: border-box;
|
|
103
111
|
border-width: var(--mg-inputs-border-width);
|
|
@@ -108,6 +116,7 @@
|
|
|
108
116
|
font-family: inherit;
|
|
109
117
|
color: hsl(var(--color-dark));
|
|
110
118
|
font-size: var(--font-size);
|
|
119
|
+
text-align: var(--mg-inputs-text-align, left);
|
|
111
120
|
}
|
|
112
121
|
.mg-input__box::placeholder {
|
|
113
122
|
color: var(--mg-inputs-color);
|
|
@@ -155,10 +164,6 @@
|
|
|
155
164
|
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]) {
|
|
156
165
|
--mg-button-border-radius-top-right: 0;
|
|
157
166
|
--mg-button-border-radius-bottom-right: 0;
|
|
158
|
-
--mg-button-border-radius-top-left: 0;
|
|
159
|
-
/* IE FIX */
|
|
160
|
-
--mg-button-border-radius-bottom-left: 0;
|
|
161
|
-
/* IE FIX */
|
|
162
167
|
}
|
|
163
168
|
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)) {
|
|
164
169
|
--mg-button-border-right-width: 0;
|
|
@@ -166,10 +171,6 @@
|
|
|
166
171
|
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type) {
|
|
167
172
|
--mg-button-border-radius-top-right: var(--mg-inputs-border-radius);
|
|
168
173
|
--mg-button-border-radius-bottom-right: var(--mg-inputs-border-radius);
|
|
169
|
-
--mg-button-border-radius-top-left: 0;
|
|
170
|
-
/* IE FIX */
|
|
171
|
-
--mg-button-border-radius-bottom-left: 0;
|
|
172
|
-
/* IE FIX */
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]) {
|
|
@@ -222,6 +223,7 @@
|
|
|
222
223
|
}
|
|
223
224
|
|
|
224
225
|
.mg-input__box {
|
|
226
|
+
width: 100%;
|
|
225
227
|
padding-top: 0;
|
|
226
228
|
padding-bottom: 0;
|
|
227
229
|
padding-right: 1rem;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
import { Component, Event, h, Prop, State, Watch, Method } from '@stencil/core';
|
|
3
|
+
import { Component, Element, Event, h, Prop, State, Watch, Method } from '@stencil/core';
|
|
4
4
|
import { MgInput } from '../MgInput';
|
|
5
|
-
import { InputClass } from '../MgInput.conf';
|
|
6
5
|
import { createID, ClassList, allItemsAreString } from '../../../../utils/components.utils';
|
|
7
|
-
import {
|
|
6
|
+
import { initLocales } from '../../../../locales';
|
|
8
7
|
/**
|
|
9
8
|
* Check if item is a well configured option
|
|
10
9
|
*
|
|
11
10
|
* @param {SelectOption} option select option
|
|
12
11
|
* @returns {boolean} select option type is valid
|
|
13
12
|
*/
|
|
14
|
-
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string'
|
|
13
|
+
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
15
14
|
/**
|
|
16
15
|
* Group options
|
|
17
16
|
*
|
|
@@ -43,11 +42,8 @@ const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
|
43
42
|
};
|
|
44
43
|
export class MgInputSelect {
|
|
45
44
|
constructor() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
************/
|
|
49
|
-
// classes
|
|
50
|
-
this.classError = InputClass.ERROR;
|
|
45
|
+
// hasError (triggered by blur event)
|
|
46
|
+
this.hasError = false;
|
|
51
47
|
/**
|
|
52
48
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
53
49
|
* If not set, it will be created.
|
|
@@ -62,11 +58,6 @@ export class MgInputSelect {
|
|
|
62
58
|
* Define if label is visible
|
|
63
59
|
*/
|
|
64
60
|
this.labelHide = false;
|
|
65
|
-
/**
|
|
66
|
-
* Input placeholder.
|
|
67
|
-
* It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.
|
|
68
|
-
*/
|
|
69
|
-
this.placeholder = messages.input.select.placeholder;
|
|
70
61
|
/**
|
|
71
62
|
* Option to remove placeholder
|
|
72
63
|
*/
|
|
@@ -96,6 +87,9 @@ export class MgInputSelect {
|
|
|
96
87
|
*/
|
|
97
88
|
this.handleInput = () => {
|
|
98
89
|
this.checkValidity();
|
|
90
|
+
if (this.hasError) {
|
|
91
|
+
this.checkError();
|
|
92
|
+
}
|
|
99
93
|
if (this.input.value !== '') {
|
|
100
94
|
this.value = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
|
|
101
95
|
}
|
|
@@ -107,8 +101,7 @@ export class MgInputSelect {
|
|
|
107
101
|
* Handle blur event
|
|
108
102
|
*/
|
|
109
103
|
this.handleBlur = () => {
|
|
110
|
-
this.
|
|
111
|
-
this.checkError();
|
|
104
|
+
this.displayError();
|
|
112
105
|
};
|
|
113
106
|
/**
|
|
114
107
|
* Check if input is valid
|
|
@@ -130,14 +123,7 @@ export class MgInputSelect {
|
|
|
130
123
|
// Set error message
|
|
131
124
|
this.errorMessage = undefined;
|
|
132
125
|
if (!this.valid && this.input.validity.valueMissing) {
|
|
133
|
-
this.errorMessage = messages.errors.required;
|
|
134
|
-
}
|
|
135
|
-
// Update class
|
|
136
|
-
if (this.valid) {
|
|
137
|
-
this.classList.delete(this.classError);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
this.classList.add(this.classError);
|
|
126
|
+
this.errorMessage = this.messages.errors.required;
|
|
141
127
|
}
|
|
142
128
|
};
|
|
143
129
|
}
|
|
@@ -180,6 +166,7 @@ export class MgInputSelect {
|
|
|
180
166
|
async displayError() {
|
|
181
167
|
this.checkValidity();
|
|
182
168
|
this.checkError();
|
|
169
|
+
this.hasError = this.invalid;
|
|
183
170
|
}
|
|
184
171
|
/*************
|
|
185
172
|
* Lifecycle *
|
|
@@ -190,8 +177,14 @@ export class MgInputSelect {
|
|
|
190
177
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
191
178
|
*/
|
|
192
179
|
componentWillLoad() {
|
|
193
|
-
//
|
|
180
|
+
// Get locales
|
|
181
|
+
this.messages = initLocales(this.element).messages;
|
|
182
|
+
// Validate
|
|
194
183
|
this.validateItems(this.items);
|
|
184
|
+
// Set default placeholder
|
|
185
|
+
if (this.placeholder === undefined || this.placeholder === '') {
|
|
186
|
+
this.placeholder = this.messages.input.select.placeholder;
|
|
187
|
+
}
|
|
195
188
|
// Check validity when component is ready
|
|
196
189
|
// return a promise to process action only in the FIRST render().
|
|
197
190
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
@@ -205,7 +198,7 @@ export class MgInputSelect {
|
|
|
205
198
|
* @returns {HTMLElement} HTML Element
|
|
206
199
|
*/
|
|
207
200
|
render() {
|
|
208
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly,
|
|
201
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false },
|
|
209
202
|
h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) },
|
|
210
203
|
(!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
211
204
|
h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)),
|
|
@@ -347,7 +340,7 @@ export class MgInputSelect {
|
|
|
347
340
|
},
|
|
348
341
|
"placeholder": {
|
|
349
342
|
"type": "string",
|
|
350
|
-
"mutable":
|
|
343
|
+
"mutable": true,
|
|
351
344
|
"complexType": {
|
|
352
345
|
"original": "string",
|
|
353
346
|
"resolved": "string",
|
|
@@ -360,8 +353,7 @@ export class MgInputSelect {
|
|
|
360
353
|
"text": "Input placeholder.\nIt should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text."
|
|
361
354
|
},
|
|
362
355
|
"attribute": "placeholder",
|
|
363
|
-
"reflect": false
|
|
364
|
-
"defaultValue": "messages.input.select.placeholder"
|
|
356
|
+
"reflect": false
|
|
365
357
|
},
|
|
366
358
|
"placeholderHide": {
|
|
367
359
|
"type": "boolean",
|
|
@@ -453,7 +445,7 @@ export class MgInputSelect {
|
|
|
453
445
|
"reflect": false,
|
|
454
446
|
"defaultValue": "false"
|
|
455
447
|
},
|
|
456
|
-
"
|
|
448
|
+
"mgWidth": {
|
|
457
449
|
"type": "any",
|
|
458
450
|
"mutable": false,
|
|
459
451
|
"complexType": {
|
|
@@ -472,7 +464,7 @@ export class MgInputSelect {
|
|
|
472
464
|
"tags": [],
|
|
473
465
|
"text": "Define input width"
|
|
474
466
|
},
|
|
475
|
-
"attribute": "width",
|
|
467
|
+
"attribute": "mg-width",
|
|
476
468
|
"reflect": false
|
|
477
469
|
},
|
|
478
470
|
"tooltip": {
|
|
@@ -603,6 +595,7 @@ export class MgInputSelect {
|
|
|
603
595
|
}
|
|
604
596
|
}
|
|
605
597
|
}; }
|
|
598
|
+
static get elementRef() { return "element"; }
|
|
606
599
|
static get watchers() { return [{
|
|
607
600
|
"propName": "value",
|
|
608
601
|
"methodName": "handleValue"
|