@mgdis/mg-components 3.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/LICENSE +29 -0
- package/dist/cjs/css-shim-a22512c4.js +6 -0
- package/dist/cjs/index-85a4a0b6.js +1674 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +35 -0
- package/dist/cjs/mg-badge_20.cjs.entry.js +4661 -0
- package/dist/cjs/mg-components.cjs.js +23 -0
- package/dist/cjs/shadow-css-8940f82d.js +390 -0
- package/dist/collection/collection-manifest.json +31 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +4 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +99 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +148 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +27 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +134 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +236 -0
- package/dist/collection/components/atoms/mg-button/mg-button.stories.js +38 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.css +3 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +133 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +15 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +54 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +57 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +155 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.stories.js +34 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +12 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +95 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +21 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +4 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +73 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +94 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +25 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +44 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +225 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +26 -0
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +7 -0
- package/dist/collection/components/molecules/inputs/MgInput.js +130 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +156 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +444 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +57 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +7 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +171 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +467 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +46 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +11 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +199 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +633 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +68 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +195 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +401 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +43 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +156 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +443 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +65 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +201 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +532 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +70 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +222 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +589 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +115 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +217 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +553 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +52 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +213 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +457 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +73 -0
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js +4 -0
- package/dist/collection/components/molecules/mg-message/mg-message.css +94 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +285 -0
- package/dist/collection/components/molecules/mg-message/mg-message.stories.js +43 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +5 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +39 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +218 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +23 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +59 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +249 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.stories.js +36 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +30 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +212 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +40 -0
- package/dist/collection/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/collection/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/collection/fonts/Poppins-Bold.ttf +0 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/locales/index.js +4 -0
- package/dist/collection/stories/buttons.stories.js +43 -0
- package/dist/collection/stories/grids.stories.js +50 -0
- package/dist/collection/stories/icons.stories.js +20 -0
- package/dist/collection/stories/messages.stories.js +44 -0
- package/dist/collection/stories/tags.stories.js +13 -0
- package/dist/collection/stories/typography.stories.js +28 -0
- package/dist/collection/utils/components.utils.js +67 -0
- package/dist/collection/utils/locale.utils.js +32 -0
- package/dist/collection/utils/test.utils.js +26 -0
- package/dist/collection/variables.css +177 -0
- package/dist/collection/variables.scss +177 -0
- package/dist/components/MgInput.js +140 -0
- package/dist/components/components.utils.js +69 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +54 -0
- package/dist/components/locale.utils.js +35 -0
- package/dist/components/mg-badge.d.ts +11 -0
- package/dist/components/mg-badge.js +6 -0
- package/dist/components/mg-badge2.js +82 -0
- package/dist/components/mg-button.d.ts +11 -0
- package/dist/components/mg-button.js +6 -0
- package/dist/components/mg-button2.js +148 -0
- package/dist/components/mg-character-left.d.ts +11 -0
- package/dist/components/mg-character-left.js +6 -0
- package/dist/components/mg-character-left2.js +77 -0
- package/dist/components/mg-icon.d.ts +11 -0
- package/dist/components/mg-icon.js +6 -0
- package/dist/components/mg-icon2.js +147 -0
- package/dist/components/mg-input-checkbox.d.ts +11 -0
- package/dist/components/mg-input-checkbox.js +222 -0
- package/dist/components/mg-input-date.d.ts +11 -0
- package/dist/components/mg-input-date.js +245 -0
- package/dist/components/mg-input-numeric.d.ts +11 -0
- package/dist/components/mg-input-numeric.js +324 -0
- package/dist/components/mg-input-password.d.ts +11 -0
- package/dist/components/mg-input-password.js +171 -0
- package/dist/components/mg-input-radio.d.ts +11 -0
- package/dist/components/mg-input-radio.js +211 -0
- package/dist/components/mg-input-select.d.ts +11 -0
- package/dist/components/mg-input-select.js +6 -0
- package/dist/components/mg-input-select2.js +243 -0
- package/dist/components/mg-input-text.d.ts +11 -0
- package/dist/components/mg-input-text.js +242 -0
- package/dist/components/mg-input-textarea.d.ts +11 -0
- package/dist/components/mg-input-textarea.js +224 -0
- package/dist/components/mg-input-title.d.ts +11 -0
- package/dist/components/mg-input-title.js +6 -0
- package/dist/components/mg-input-title2.js +55 -0
- package/dist/components/mg-input-toggle.d.ts +11 -0
- package/dist/components/mg-input-toggle.js +247 -0
- package/dist/components/mg-message.d.ts +11 -0
- package/dist/components/mg-message.js +183 -0
- package/dist/components/mg-pagination.d.ts +11 -0
- package/dist/components/mg-pagination.js +175 -0
- package/dist/components/mg-popover.d.ts +11 -0
- package/dist/components/mg-popover.js +183 -0
- package/dist/components/mg-tabs.d.ts +11 -0
- package/dist/components/mg-tabs.js +160 -0
- package/dist/components/mg-tag.d.ts +11 -0
- package/dist/components/mg-tag.js +76 -0
- package/dist/components/mg-tooltip.d.ts +11 -0
- package/dist/components/mg-tooltip.js +6 -0
- package/dist/components/mg-tooltip2.js +150 -0
- package/dist/components/popper.js +1784 -0
- package/dist/esm/css-shim-7c240feb.js +4 -0
- package/dist/esm/index-e3e84606.js +1643 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +31 -0
- package/dist/esm/mg-badge_20.entry.js +4638 -0
- package/dist/esm/mg-components.js +21 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/shadow-css-5d2d01ce.js +388 -0
- package/dist/esm-es5/css-shim-7c240feb.js +1 -0
- package/dist/esm-es5/index-e3e84606.js +1 -0
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +1 -0
- package/dist/esm-es5/mg-badge_20.entry.js +2 -0
- package/dist/esm-es5/mg-components.js +1 -0
- package/dist/esm-es5/shadow-css-5d2d01ce.js +12 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/mg-components/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/mg-components/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/mg-components/fonts/Poppins-Bold.ttf +0 -0
- package/dist/mg-components/index.esm.js +0 -0
- package/dist/mg-components/mg-components.css +1 -0
- package/dist/mg-components/mg-components.esm.js +1 -0
- package/dist/mg-components/mg-components.js +132 -0
- package/dist/mg-components/p-1cd24462.system.js +1 -0
- package/dist/mg-components/p-2e2f6b27.system.entry.js +2 -0
- package/dist/mg-components/p-366a224e.js +1 -0
- package/dist/mg-components/p-422c429b.system.js +1 -0
- package/dist/mg-components/p-50ea2036.system.js +1 -0
- package/dist/mg-components/p-62fa3797.js +1 -0
- package/dist/mg-components/p-71d57b8b.system.js +13 -0
- package/dist/mg-components/p-9a215712.system.js +1 -0
- package/dist/mg-components/p-cbf0464b.entry.js +1 -0
- package/dist/mg-components/p-f6455ab3.js +12 -0
- package/dist/mg-components/variables.css +177 -0
- package/dist/mg-components/variables.scss +177 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +36 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +19 -0
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +4 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +67 -0
- package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +16 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +39 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +7 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +12 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +36 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.stories.d.ts +26 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +24 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +4 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +25 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +14 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +56 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +11 -0
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +10 -0
- package/dist/types/components/molecules/inputs/MgInput.d.ts +35 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +120 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +128 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +7 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +10 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +173 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +21 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +111 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +121 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +15 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +18 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +133 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +160 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +26 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +150 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +8 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +117 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +7 -0
- package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +4 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +76 -0
- package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +16 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.conf.d.ts +4 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +53 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +6 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +62 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +12 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +10 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +63 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +7 -0
- package/dist/types/components.d.ts +1987 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/locales/index.d.ts +44 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/stories/buttons.stories.d.ts +13 -0
- package/dist/types/stories/grids.stories.d.ts +5 -0
- package/dist/types/stories/icons.stories.d.ts +13 -0
- package/dist/types/stories/messages.stories.d.ts +13 -0
- package/dist/types/stories/tags.stories.d.ts +5 -0
- package/dist/types/stories/typography.stories.d.ts +5 -0
- package/dist/types/utils/components.utils.d.ts +43 -0
- package/dist/types/utils/locale.utils.d.ts +22 -0
- package/dist/types/utils/test.utils.d.ts +5 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +86 -0
- package/readme.md +159 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common style for MGDIS inputs
|
|
3
|
+
*/
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.mg-input {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: flex-start;
|
|
11
|
+
min-height: var(--default-size);
|
|
12
|
+
max-width: 100%;
|
|
13
|
+
/* Style when input is not valid */
|
|
14
|
+
/* Label */
|
|
15
|
+
/* Label-on-top */
|
|
16
|
+
}
|
|
17
|
+
.mg-input.is-not-valid {
|
|
18
|
+
color: hsl(var(--color-danger));
|
|
19
|
+
}
|
|
20
|
+
.mg-input.is-not-valid .mg-input__box {
|
|
21
|
+
border-color: hsl(var(--color-danger));
|
|
22
|
+
}
|
|
23
|
+
.mg-input mg-input-title {
|
|
24
|
+
flex-shrink: var(--mg-inputs-shrink, 1);
|
|
25
|
+
width: var(--mg-inputs-title-width, auto);
|
|
26
|
+
margin-top: calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);
|
|
27
|
+
margin-right: var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));
|
|
28
|
+
text-align: right;
|
|
29
|
+
}
|
|
30
|
+
.mg-input.mg-input--label-on-top {
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
}
|
|
33
|
+
.mg-input.mg-input--label-on-top .mg-input__input-container {
|
|
34
|
+
width: 100%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Label-on-top */
|
|
38
|
+
.mg-input__title {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: baseline;
|
|
41
|
+
margin-bottom: 0.3rem;
|
|
42
|
+
}
|
|
43
|
+
.mg-input__title mg-input-title {
|
|
44
|
+
flex-shrink: 1;
|
|
45
|
+
width: auto;
|
|
46
|
+
margin-top: 0;
|
|
47
|
+
margin-right: var(--mg-inputs-spacer);
|
|
48
|
+
text-align: left;
|
|
49
|
+
}
|
|
50
|
+
.mg-input__title mg-tooltip {
|
|
51
|
+
margin-top: 0;
|
|
52
|
+
}
|
|
53
|
+
.mg-input__title mg-icon {
|
|
54
|
+
display: inline-flex;
|
|
55
|
+
vertical-align: text-bottom;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.mg-input__input-container {
|
|
59
|
+
min-height: var(--default-size);
|
|
60
|
+
/* Readonly */
|
|
61
|
+
}
|
|
62
|
+
.mg-input__input-container > strong {
|
|
63
|
+
display: inline-block;
|
|
64
|
+
margin-top: calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);
|
|
65
|
+
min-height: var(--font-size);
|
|
66
|
+
}
|
|
67
|
+
.mg-input__input-container mg-tooltip {
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
width: var(--mg-icon-regular-size);
|
|
70
|
+
height: var(--mg-icon-regular-size);
|
|
71
|
+
margin-left: var(--mg-inputs-spacer);
|
|
72
|
+
}
|
|
73
|
+
.mg-input__input-container mg-icon {
|
|
74
|
+
display: flex;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.mg-input__input {
|
|
78
|
+
display: flex;
|
|
79
|
+
/* Manage space between input and first message */
|
|
80
|
+
}
|
|
81
|
+
.mg-input__input mg-tooltip {
|
|
82
|
+
margin-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
83
|
+
}
|
|
84
|
+
.mg-input__input + * {
|
|
85
|
+
text-align: start;
|
|
86
|
+
margin-top: 0.5rem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Manage style when input needs to be a fieldset, like checkbox and radio.
|
|
91
|
+
*/
|
|
92
|
+
fieldset.mg-input {
|
|
93
|
+
border: 0;
|
|
94
|
+
margin: 0;
|
|
95
|
+
padding: 0;
|
|
96
|
+
}
|
|
97
|
+
fieldset.mg-input input[type=radio],
|
|
98
|
+
fieldset.mg-input input[type=checkbox] {
|
|
99
|
+
flex-shrink: 0;
|
|
100
|
+
/* Ensure checkbox won't resize in flex element */
|
|
101
|
+
width: var(--mg-input-check-size);
|
|
102
|
+
height: var(--mg-input-check-size);
|
|
103
|
+
margin-top: calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);
|
|
104
|
+
margin-right: 0.6rem;
|
|
105
|
+
margin-bottom: 0;
|
|
106
|
+
margin-left: 0;
|
|
107
|
+
}
|
|
108
|
+
fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
|
|
109
|
+
margin-top: 0.7rem;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.mg-input__input-container mg-tooltip {
|
|
113
|
+
margin-left: 2rem;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* input group container */
|
|
117
|
+
.mg-input__input-group-container {
|
|
118
|
+
margin: 0;
|
|
119
|
+
padding: 0;
|
|
120
|
+
list-style: none;
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-wrap: wrap;
|
|
123
|
+
column-gap: 2.3rem;
|
|
124
|
+
row-gap: 1rem;
|
|
125
|
+
margin-top: calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);
|
|
126
|
+
}
|
|
127
|
+
.mg-input__input-group-container--vertical {
|
|
128
|
+
flex-direction: column;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* input group */
|
|
132
|
+
.mg-input__input-group {
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: top;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* A11Y
|
|
139
|
+
*/
|
|
140
|
+
.sr-only {
|
|
141
|
+
border: 0 !important;
|
|
142
|
+
clip: rect(1px, 1px, 1px, 1px) !important;
|
|
143
|
+
-webkit-clip-path: inset(50%) !important;
|
|
144
|
+
clip-path: inset(50%) !important;
|
|
145
|
+
height: 1px !important;
|
|
146
|
+
margin: -1px !important;
|
|
147
|
+
overflow: hidden !important;
|
|
148
|
+
padding: 0 !important;
|
|
149
|
+
position: absolute !important;
|
|
150
|
+
width: 1px !important;
|
|
151
|
+
white-space: nowrap !important;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
*:focus:not(:focus-visible) {
|
|
155
|
+
outline: none;
|
|
156
|
+
}
|
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import { Component, Event, h, Prop, State, Watch } from '@stencil/core';
|
|
2
|
+
import { MgInput } from '../MgInput';
|
|
3
|
+
import { createID, ClassList, allItemsAreString } from '../../../../utils/components.utils';
|
|
4
|
+
import { messages } from '../../../../locales';
|
|
5
|
+
import { InputClass } from '../MgInput.conf';
|
|
6
|
+
/**
|
|
7
|
+
* type Option validation function
|
|
8
|
+
* @param option
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*/
|
|
11
|
+
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
12
|
+
export class MgInputRadio {
|
|
13
|
+
constructor() {
|
|
14
|
+
/************
|
|
15
|
+
* Internal *
|
|
16
|
+
************/
|
|
17
|
+
// classes
|
|
18
|
+
this.classError = InputClass.ERROR;
|
|
19
|
+
// HTML selector
|
|
20
|
+
this.inputs = [];
|
|
21
|
+
/**
|
|
22
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
23
|
+
* If not set, it will be created.
|
|
24
|
+
*/
|
|
25
|
+
this.identifier = createID('mg-input-radio');
|
|
26
|
+
/**
|
|
27
|
+
* Input name
|
|
28
|
+
* If not set the value equals the identifier
|
|
29
|
+
*/
|
|
30
|
+
this.name = this.identifier;
|
|
31
|
+
/**
|
|
32
|
+
* Define if label is displayed on top
|
|
33
|
+
*/
|
|
34
|
+
this.labelOnTop = false;
|
|
35
|
+
/**
|
|
36
|
+
* Define if label is visible
|
|
37
|
+
*/
|
|
38
|
+
this.labelHide = false;
|
|
39
|
+
/**
|
|
40
|
+
* Define if inputs are display verticaly
|
|
41
|
+
*/
|
|
42
|
+
this.inputVerticalList = false;
|
|
43
|
+
/**
|
|
44
|
+
* Define if input is required
|
|
45
|
+
*/
|
|
46
|
+
this.required = false;
|
|
47
|
+
/**
|
|
48
|
+
* Define if input is readonly
|
|
49
|
+
*/
|
|
50
|
+
this.readonly = false;
|
|
51
|
+
/**
|
|
52
|
+
* Define if input is disabled
|
|
53
|
+
*/
|
|
54
|
+
this.disabled = false;
|
|
55
|
+
/**
|
|
56
|
+
* Component classes
|
|
57
|
+
*/
|
|
58
|
+
this.classList = new ClassList(['mg-input--radio']);
|
|
59
|
+
/**
|
|
60
|
+
* Handle input event
|
|
61
|
+
*/
|
|
62
|
+
this.handleInput = (event) => {
|
|
63
|
+
this.checkValidity();
|
|
64
|
+
this.value = this.options[event.target.value].value;
|
|
65
|
+
this.valueChange.emit(this.value);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Handle blur event
|
|
69
|
+
*/
|
|
70
|
+
this.handleBlur = () => {
|
|
71
|
+
this.checkValidity();
|
|
72
|
+
this.checkError();
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* get invalid element
|
|
76
|
+
* @returns element: HTMLInputElement
|
|
77
|
+
*/
|
|
78
|
+
this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
|
|
79
|
+
}
|
|
80
|
+
validateItems(newValue) {
|
|
81
|
+
// Validate if items have required min length
|
|
82
|
+
if (typeof newValue === 'object' && newValue.length < 2) {
|
|
83
|
+
throw new Error('<mg-input-radio> prop "items" require at least 2 items.');
|
|
84
|
+
}
|
|
85
|
+
// String array
|
|
86
|
+
else if (allItemsAreString(newValue)) {
|
|
87
|
+
this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
|
|
88
|
+
}
|
|
89
|
+
// Object array
|
|
90
|
+
else if (newValue && newValue.every(item => isOption(item))) {
|
|
91
|
+
this.options = newValue;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw new Error('<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption.');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if input is valid
|
|
99
|
+
*/
|
|
100
|
+
checkValidity() {
|
|
101
|
+
if (!this.readonly) {
|
|
102
|
+
const validity = this.getInvalidElement() === undefined;
|
|
103
|
+
// Set validity
|
|
104
|
+
this.valid = validity;
|
|
105
|
+
this.invalid = !validity;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Check input errors
|
|
110
|
+
*/
|
|
111
|
+
checkError() {
|
|
112
|
+
const invalidElement = this.getInvalidElement();
|
|
113
|
+
// Set error message
|
|
114
|
+
this.errorMessage = undefined;
|
|
115
|
+
if (!this.valid && invalidElement.validity.valueMissing) {
|
|
116
|
+
this.errorMessage = messages.errors.required;
|
|
117
|
+
}
|
|
118
|
+
// Update class
|
|
119
|
+
if (this.valid) {
|
|
120
|
+
this.classList.delete(this.classError);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.classList.add(this.classError);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/*************
|
|
127
|
+
* Lifecycle *
|
|
128
|
+
*************/
|
|
129
|
+
componentWillLoad() {
|
|
130
|
+
// Check items format
|
|
131
|
+
this.validateItems(this.items);
|
|
132
|
+
// return a promise to process action only in the FIRST render().
|
|
133
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
134
|
+
return setTimeout(() => this.checkValidity(), 0);
|
|
135
|
+
}
|
|
136
|
+
render() {
|
|
137
|
+
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, width: undefined, value: this.value && this.value.toString(), readonlyValue: this.value && this.value.toString(), tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true },
|
|
138
|
+
h("ul", { class: `mg-input__input-group-container${this.inputVerticalList ? ' mg-input__input-group-container--vertical' : ''}` }, this.options.map((input, index) => (h("li", { class: "mg-input__input-group" },
|
|
139
|
+
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) }),
|
|
140
|
+
h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
|
|
141
|
+
}
|
|
142
|
+
static get is() { return "mg-input-radio"; }
|
|
143
|
+
static get encapsulation() { return "shadow"; }
|
|
144
|
+
static get originalStyleUrls() { return {
|
|
145
|
+
"$": ["mg-input-radio.scss"]
|
|
146
|
+
}; }
|
|
147
|
+
static get styleUrls() { return {
|
|
148
|
+
"$": ["mg-input-radio.css"]
|
|
149
|
+
}; }
|
|
150
|
+
static get properties() { return {
|
|
151
|
+
"value": {
|
|
152
|
+
"type": "any",
|
|
153
|
+
"mutable": true,
|
|
154
|
+
"complexType": {
|
|
155
|
+
"original": "any",
|
|
156
|
+
"resolved": "any",
|
|
157
|
+
"references": {}
|
|
158
|
+
},
|
|
159
|
+
"required": false,
|
|
160
|
+
"optional": false,
|
|
161
|
+
"docs": {
|
|
162
|
+
"tags": [],
|
|
163
|
+
"text": "Component value"
|
|
164
|
+
},
|
|
165
|
+
"attribute": "value",
|
|
166
|
+
"reflect": false
|
|
167
|
+
},
|
|
168
|
+
"items": {
|
|
169
|
+
"type": "unknown",
|
|
170
|
+
"mutable": false,
|
|
171
|
+
"complexType": {
|
|
172
|
+
"original": "string[] | RadioOption[]",
|
|
173
|
+
"resolved": "RadioOption[] | string[]",
|
|
174
|
+
"references": {
|
|
175
|
+
"RadioOption": {
|
|
176
|
+
"location": "import",
|
|
177
|
+
"path": "./mg-input-radio.conf"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"required": true,
|
|
182
|
+
"optional": false,
|
|
183
|
+
"docs": {
|
|
184
|
+
"tags": [],
|
|
185
|
+
"text": "Items are the possible options to select\nRequired"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"identifier": {
|
|
189
|
+
"type": "string",
|
|
190
|
+
"mutable": false,
|
|
191
|
+
"complexType": {
|
|
192
|
+
"original": "string",
|
|
193
|
+
"resolved": "string",
|
|
194
|
+
"references": {}
|
|
195
|
+
},
|
|
196
|
+
"required": false,
|
|
197
|
+
"optional": false,
|
|
198
|
+
"docs": {
|
|
199
|
+
"tags": [],
|
|
200
|
+
"text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
|
|
201
|
+
},
|
|
202
|
+
"attribute": "identifier",
|
|
203
|
+
"reflect": false,
|
|
204
|
+
"defaultValue": "createID('mg-input-radio')"
|
|
205
|
+
},
|
|
206
|
+
"name": {
|
|
207
|
+
"type": "string",
|
|
208
|
+
"mutable": false,
|
|
209
|
+
"complexType": {
|
|
210
|
+
"original": "string",
|
|
211
|
+
"resolved": "string",
|
|
212
|
+
"references": {}
|
|
213
|
+
},
|
|
214
|
+
"required": false,
|
|
215
|
+
"optional": false,
|
|
216
|
+
"docs": {
|
|
217
|
+
"tags": [],
|
|
218
|
+
"text": "Input name\nIf not set the value equals the identifier"
|
|
219
|
+
},
|
|
220
|
+
"attribute": "name",
|
|
221
|
+
"reflect": false,
|
|
222
|
+
"defaultValue": "this.identifier"
|
|
223
|
+
},
|
|
224
|
+
"label": {
|
|
225
|
+
"type": "string",
|
|
226
|
+
"mutable": false,
|
|
227
|
+
"complexType": {
|
|
228
|
+
"original": "string",
|
|
229
|
+
"resolved": "string",
|
|
230
|
+
"references": {}
|
|
231
|
+
},
|
|
232
|
+
"required": true,
|
|
233
|
+
"optional": false,
|
|
234
|
+
"docs": {
|
|
235
|
+
"tags": [],
|
|
236
|
+
"text": "Input label\nRequired"
|
|
237
|
+
},
|
|
238
|
+
"attribute": "label",
|
|
239
|
+
"reflect": false
|
|
240
|
+
},
|
|
241
|
+
"labelOnTop": {
|
|
242
|
+
"type": "boolean",
|
|
243
|
+
"mutable": false,
|
|
244
|
+
"complexType": {
|
|
245
|
+
"original": "boolean",
|
|
246
|
+
"resolved": "boolean",
|
|
247
|
+
"references": {}
|
|
248
|
+
},
|
|
249
|
+
"required": false,
|
|
250
|
+
"optional": false,
|
|
251
|
+
"docs": {
|
|
252
|
+
"tags": [],
|
|
253
|
+
"text": "Define if label is displayed on top"
|
|
254
|
+
},
|
|
255
|
+
"attribute": "label-on-top",
|
|
256
|
+
"reflect": false,
|
|
257
|
+
"defaultValue": "false"
|
|
258
|
+
},
|
|
259
|
+
"labelHide": {
|
|
260
|
+
"type": "boolean",
|
|
261
|
+
"mutable": false,
|
|
262
|
+
"complexType": {
|
|
263
|
+
"original": "boolean",
|
|
264
|
+
"resolved": "boolean",
|
|
265
|
+
"references": {}
|
|
266
|
+
},
|
|
267
|
+
"required": false,
|
|
268
|
+
"optional": false,
|
|
269
|
+
"docs": {
|
|
270
|
+
"tags": [],
|
|
271
|
+
"text": "Define if label is visible"
|
|
272
|
+
},
|
|
273
|
+
"attribute": "label-hide",
|
|
274
|
+
"reflect": false,
|
|
275
|
+
"defaultValue": "false"
|
|
276
|
+
},
|
|
277
|
+
"inputVerticalList": {
|
|
278
|
+
"type": "boolean",
|
|
279
|
+
"mutable": false,
|
|
280
|
+
"complexType": {
|
|
281
|
+
"original": "boolean",
|
|
282
|
+
"resolved": "boolean",
|
|
283
|
+
"references": {}
|
|
284
|
+
},
|
|
285
|
+
"required": false,
|
|
286
|
+
"optional": false,
|
|
287
|
+
"docs": {
|
|
288
|
+
"tags": [],
|
|
289
|
+
"text": "Define if inputs are display verticaly"
|
|
290
|
+
},
|
|
291
|
+
"attribute": "input-vertical-list",
|
|
292
|
+
"reflect": false,
|
|
293
|
+
"defaultValue": "false"
|
|
294
|
+
},
|
|
295
|
+
"required": {
|
|
296
|
+
"type": "boolean",
|
|
297
|
+
"mutable": false,
|
|
298
|
+
"complexType": {
|
|
299
|
+
"original": "boolean",
|
|
300
|
+
"resolved": "boolean",
|
|
301
|
+
"references": {}
|
|
302
|
+
},
|
|
303
|
+
"required": false,
|
|
304
|
+
"optional": false,
|
|
305
|
+
"docs": {
|
|
306
|
+
"tags": [],
|
|
307
|
+
"text": "Define if input is required"
|
|
308
|
+
},
|
|
309
|
+
"attribute": "required",
|
|
310
|
+
"reflect": false,
|
|
311
|
+
"defaultValue": "false"
|
|
312
|
+
},
|
|
313
|
+
"readonly": {
|
|
314
|
+
"type": "boolean",
|
|
315
|
+
"mutable": false,
|
|
316
|
+
"complexType": {
|
|
317
|
+
"original": "boolean",
|
|
318
|
+
"resolved": "boolean",
|
|
319
|
+
"references": {}
|
|
320
|
+
},
|
|
321
|
+
"required": false,
|
|
322
|
+
"optional": false,
|
|
323
|
+
"docs": {
|
|
324
|
+
"tags": [],
|
|
325
|
+
"text": "Define if input is readonly"
|
|
326
|
+
},
|
|
327
|
+
"attribute": "readonly",
|
|
328
|
+
"reflect": false,
|
|
329
|
+
"defaultValue": "false"
|
|
330
|
+
},
|
|
331
|
+
"disabled": {
|
|
332
|
+
"type": "boolean",
|
|
333
|
+
"mutable": false,
|
|
334
|
+
"complexType": {
|
|
335
|
+
"original": "boolean",
|
|
336
|
+
"resolved": "boolean",
|
|
337
|
+
"references": {}
|
|
338
|
+
},
|
|
339
|
+
"required": false,
|
|
340
|
+
"optional": false,
|
|
341
|
+
"docs": {
|
|
342
|
+
"tags": [],
|
|
343
|
+
"text": "Define if input is disabled"
|
|
344
|
+
},
|
|
345
|
+
"attribute": "disabled",
|
|
346
|
+
"reflect": false,
|
|
347
|
+
"defaultValue": "false"
|
|
348
|
+
},
|
|
349
|
+
"tooltip": {
|
|
350
|
+
"type": "string",
|
|
351
|
+
"mutable": false,
|
|
352
|
+
"complexType": {
|
|
353
|
+
"original": "string",
|
|
354
|
+
"resolved": "string",
|
|
355
|
+
"references": {}
|
|
356
|
+
},
|
|
357
|
+
"required": false,
|
|
358
|
+
"optional": false,
|
|
359
|
+
"docs": {
|
|
360
|
+
"tags": [],
|
|
361
|
+
"text": "Add a tooltip message next to the input"
|
|
362
|
+
},
|
|
363
|
+
"attribute": "tooltip",
|
|
364
|
+
"reflect": false
|
|
365
|
+
},
|
|
366
|
+
"helpText": {
|
|
367
|
+
"type": "string",
|
|
368
|
+
"mutable": false,
|
|
369
|
+
"complexType": {
|
|
370
|
+
"original": "string",
|
|
371
|
+
"resolved": "string",
|
|
372
|
+
"references": {}
|
|
373
|
+
},
|
|
374
|
+
"required": false,
|
|
375
|
+
"optional": false,
|
|
376
|
+
"docs": {
|
|
377
|
+
"tags": [],
|
|
378
|
+
"text": "Add a help text under the input, usually expected data format and example"
|
|
379
|
+
},
|
|
380
|
+
"attribute": "help-text",
|
|
381
|
+
"reflect": false
|
|
382
|
+
},
|
|
383
|
+
"valid": {
|
|
384
|
+
"type": "boolean",
|
|
385
|
+
"mutable": true,
|
|
386
|
+
"complexType": {
|
|
387
|
+
"original": "boolean",
|
|
388
|
+
"resolved": "boolean",
|
|
389
|
+
"references": {}
|
|
390
|
+
},
|
|
391
|
+
"required": false,
|
|
392
|
+
"optional": false,
|
|
393
|
+
"docs": {
|
|
394
|
+
"tags": [],
|
|
395
|
+
"text": "Force valid component"
|
|
396
|
+
},
|
|
397
|
+
"attribute": "valid",
|
|
398
|
+
"reflect": false
|
|
399
|
+
},
|
|
400
|
+
"invalid": {
|
|
401
|
+
"type": "boolean",
|
|
402
|
+
"mutable": true,
|
|
403
|
+
"complexType": {
|
|
404
|
+
"original": "boolean",
|
|
405
|
+
"resolved": "boolean",
|
|
406
|
+
"references": {}
|
|
407
|
+
},
|
|
408
|
+
"required": false,
|
|
409
|
+
"optional": false,
|
|
410
|
+
"docs": {
|
|
411
|
+
"tags": [],
|
|
412
|
+
"text": "Force invalid component"
|
|
413
|
+
},
|
|
414
|
+
"attribute": "invalid",
|
|
415
|
+
"reflect": false
|
|
416
|
+
}
|
|
417
|
+
}; }
|
|
418
|
+
static get states() { return {
|
|
419
|
+
"classList": {},
|
|
420
|
+
"errorMessage": {},
|
|
421
|
+
"options": {}
|
|
422
|
+
}; }
|
|
423
|
+
static get events() { return [{
|
|
424
|
+
"method": "valueChange",
|
|
425
|
+
"name": "value-change",
|
|
426
|
+
"bubbles": true,
|
|
427
|
+
"cancelable": true,
|
|
428
|
+
"composed": true,
|
|
429
|
+
"docs": {
|
|
430
|
+
"tags": [],
|
|
431
|
+
"text": "Emitted event when value change"
|
|
432
|
+
},
|
|
433
|
+
"complexType": {
|
|
434
|
+
"original": "any",
|
|
435
|
+
"resolved": "any",
|
|
436
|
+
"references": {}
|
|
437
|
+
}
|
|
438
|
+
}]; }
|
|
439
|
+
static get watchers() { return [{
|
|
440
|
+
"propName": "items",
|
|
441
|
+
"methodName": "validateItems"
|
|
442
|
+
}]; }
|
|
443
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export default {
|
|
3
|
+
component: 'mg-input-radio',
|
|
4
|
+
title: 'Molecules/Inputs/mg-input-radio',
|
|
5
|
+
argTypes: {
|
|
6
|
+
value: {
|
|
7
|
+
options: [null, 'ht', 'ttc', 'mixte'],
|
|
8
|
+
control: { type: 'radio' },
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
14
|
+
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
15
|
+
*/
|
|
16
|
+
const Template = args => {
|
|
17
|
+
const labelOnTop = args.labelOnTop;
|
|
18
|
+
delete args.labelOnTop;
|
|
19
|
+
const helpText = args.helpText;
|
|
20
|
+
delete args.helpText;
|
|
21
|
+
const inputVerticalList = args.inputVerticalList;
|
|
22
|
+
delete args.inputVerticalList;
|
|
23
|
+
const labelHide = args.labelHide;
|
|
24
|
+
delete args.labelHide;
|
|
25
|
+
// return element
|
|
26
|
+
return h("mg-input-radio", Object.assign({}, args, { "label-on-top": labelOnTop, "label-hide": labelHide, "help-text": helpText, "input-vertical-list": inputVerticalList }));
|
|
27
|
+
};
|
|
28
|
+
export const MgInputRadio = Template.bind({});
|
|
29
|
+
MgInputRadio.args = {
|
|
30
|
+
// Global
|
|
31
|
+
value: null,
|
|
32
|
+
items: ['ht', 'ttc', 'mixte'],
|
|
33
|
+
identifier: 'identifier',
|
|
34
|
+
name: 'input-name',
|
|
35
|
+
// Label
|
|
36
|
+
label: 'Option',
|
|
37
|
+
labelOnTop: false,
|
|
38
|
+
labelHide: false,
|
|
39
|
+
// placement
|
|
40
|
+
inputVerticalList: false,
|
|
41
|
+
// Input
|
|
42
|
+
required: false,
|
|
43
|
+
disabled: false,
|
|
44
|
+
readonly: false,
|
|
45
|
+
// Tooltip
|
|
46
|
+
tooltip: 'This is a tooltip',
|
|
47
|
+
// Help Text
|
|
48
|
+
helpText: 'Help text with html <strong>bold</strong>, <em>italic</em>.',
|
|
49
|
+
};
|
|
50
|
+
export const ItemsWithOptions = Template.bind({});
|
|
51
|
+
ItemsWithOptions.args = Object.assign(Object.assign({}, MgInputRadio.args), { required: true, items: [
|
|
52
|
+
{
|
|
53
|
+
title: 'HT',
|
|
54
|
+
value: 'ht',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
title: 'TTC',
|
|
58
|
+
value: 'ttc',
|
|
59
|
+
disabled: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
title: 'Mixte (HT/TTC)',
|
|
63
|
+
value: 'mixte',
|
|
64
|
+
},
|
|
65
|
+
] });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|