@mgdis/mg-components 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/css-shim-629916b0.js +6 -0
- package/dist/cjs/index-369388eb.js +146 -0
- package/dist/cjs/{index-85a4a0b6.js → index-bead7dbd.js} +78 -2
- package/dist/cjs/loader.cjs.js +4 -4
- package/dist/cjs/mg-badge_21.cjs.entry.js +3313 -0
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-modal.cjs.entry.js +111 -0
- package/dist/cjs/mg-popover.cjs.entry.js +165 -0
- package/dist/cjs/popper-0c3964e7.js +1786 -0
- package/dist/cjs/{shadow-css-8940f82d.js → shadow-css-546083ef.js} +1 -1
- package/dist/collection/collection-manifest.json +4 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +11 -7
- package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +3 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +26 -17
- package/dist/collection/components/atoms/mg-button/mg-button.js +71 -2
- package/dist/collection/components/atoms/mg-button/mg-button.stories.js +5 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +12 -1
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +8 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +8 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +5 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +11 -1
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +4 -4
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +14 -3
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +10 -3
- package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +3 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +9 -0
- package/dist/collection/components/molecules/inputs/MgInput.js +20 -14
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +9 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +103 -40
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +27 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +125 -56
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +27 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +144 -68
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +27 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +101 -35
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +9 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +115 -37
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +132 -51
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +14 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +27 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +155 -53
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +7 -2
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +27 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +108 -42
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +7 -2
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +4 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +60 -31
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +6 -1
- package/dist/collection/components/molecules/mg-form/mg-form.css +15 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +269 -0
- package/dist/collection/components/molecules/mg-form/mg-form.stories.js +58 -0
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +11 -4
- package/dist/collection/components/molecules/mg-message/mg-message.stories.js +5 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +54 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +233 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.stories.js +51 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +32 -12
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +42 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +255 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.stories.js +31 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +19 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +4 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +14 -3
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +68 -20
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +10 -1
- package/dist/collection/stories/messages.stories.js +1 -1
- package/dist/collection/utils/components.utils.js +16 -9
- package/dist/collection/utils/locale.utils.js +6 -3
- package/dist/collection/utils/test.utils.js +27 -15
- package/dist/collection/variables.css +30 -1
- package/dist/collection/variables.scss +30 -1
- package/dist/components/MgInput.js +20 -14
- package/dist/components/components.utils.js +16 -9
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index2.js +22 -12
- package/dist/components/locale.utils.js +6 -3
- package/dist/components/mg-badge2.js +9 -5
- package/dist/components/mg-button2.js +21 -2
- package/dist/components/mg-character-left2.js +12 -1
- package/dist/components/mg-form.d.ts +11 -0
- package/dist/components/mg-form.js +146 -0
- package/dist/components/mg-icon2.js +20 -2
- package/dist/components/mg-input-checkbox.js +65 -36
- package/dist/components/mg-input-date.js +87 -52
- package/dist/components/mg-input-numeric.js +105 -63
- package/dist/components/mg-input-password.js +60 -29
- package/dist/components/mg-input-radio.js +74 -34
- package/dist/components/mg-input-select2.js +89 -46
- package/dist/components/mg-input-text.js +1 -237
- package/dist/components/mg-input-text2.js +288 -0
- package/dist/components/mg-input-textarea.js +67 -36
- package/dist/components/mg-input-title2.js +13 -4
- package/dist/components/mg-input-toggle.js +30 -22
- package/dist/components/mg-message.js +10 -3
- package/dist/components/mg-modal.d.ts +11 -0
- package/dist/components/mg-modal.js +147 -0
- package/dist/components/mg-pagination.js +31 -11
- package/dist/components/mg-panel.d.ts +11 -0
- package/dist/components/mg-panel.js +210 -0
- package/dist/components/mg-popover.js +20 -5
- package/dist/components/mg-tabs.js +43 -11
- package/dist/components/mg-tag.js +8 -1
- package/dist/components/mg-tooltip2.js +9 -0
- package/dist/esm/css-shim-0993aa3b.js +4 -0
- package/dist/esm/{index-e3e84606.js → index-9e877561.js} +78 -2
- package/dist/esm/index-c346f52d.js +139 -0
- package/dist/esm/loader.js +4 -4
- package/dist/esm/mg-badge_21.entry.js +3289 -0
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-modal.entry.js +107 -0
- package/dist/esm/mg-popover.entry.js +161 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/popper-8874fd6c.js +1784 -0
- package/dist/esm/{shadow-css-5d2d01ce.js → shadow-css-dfa0587f.js} +1 -1
- package/dist/esm-es5/css-shim-0993aa3b.js +1 -0
- package/dist/esm-es5/index-9e877561.js +1 -0
- package/dist/esm-es5/index-c346f52d.js +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mg-badge_21.entry.js +2 -0
- package/dist/esm-es5/mg-components.js +1 -1
- package/dist/esm-es5/mg-modal.entry.js +1 -0
- package/dist/esm-es5/mg-popover.entry.js +1 -0
- package/dist/esm-es5/popper-8874fd6c.js +1 -0
- package/dist/esm-es5/{shadow-css-5d2d01ce.js → shadow-css-dfa0587f.js} +0 -0
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/mg-components.js +2 -2
- package/dist/mg-components/p-3633e9e1.system.entry.js +2 -0
- package/dist/mg-components/p-3c14153d.js +1 -0
- package/dist/mg-components/p-55a22b35.system.js +1 -0
- package/dist/mg-components/{p-f6455ab3.js → p-5e796581.js} +0 -0
- package/dist/mg-components/p-656b5efb.system.js +1 -0
- package/dist/mg-components/p-68d6f104.js +1 -0
- package/dist/mg-components/{p-366a224e.js → p-6d49ed95.js} +1 -1
- package/dist/mg-components/p-70177194.entry.js +1 -0
- package/dist/mg-components/{p-71d57b8b.system.js → p-8b2d8a2a.system.js} +0 -0
- package/dist/mg-components/p-8cb61c3f.system.js +1 -0
- package/dist/mg-components/p-ace173b1.js +1 -0
- package/dist/mg-components/p-c46fbd54.entry.js +1 -0
- package/dist/mg-components/p-c90cc4bf.system.js +1 -0
- package/dist/mg-components/p-cd2a4acc.system.entry.js +1 -0
- package/dist/mg-components/p-de1164fa.system.entry.js +1 -0
- package/dist/mg-components/p-dfe25da3.entry.js +1 -0
- package/dist/mg-components/p-e4a502b5.system.js +1 -0
- package/dist/mg-components/variables.css +30 -1
- package/dist/mg-components/variables.scss +30 -1
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -4
- package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +5 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +22 -2
- package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +5 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +13 -2
- package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +9 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +11 -1
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +10 -3
- package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +5 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -2
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +8 -0
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -4
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +31 -11
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +39 -14
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +53 -14
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +28 -9
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +37 -8
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +30 -7
- 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 +46 -10
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +30 -10
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +27 -12
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +5 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +82 -0
- package/dist/types/components/molecules/mg-form/mg-form.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +11 -4
- package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +10 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +83 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.stories.d.ts +13 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +23 -7
- package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +5 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +110 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.stories.d.ts +6 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +18 -3
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +21 -6
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +8 -0
- package/dist/types/components.d.ts +365 -78
- package/dist/types/locales/index.d.ts +15 -8
- package/dist/types/utils/components.utils.d.ts +16 -9
- package/dist/types/utils/locale.utils.d.ts +6 -3
- package/dist/types/utils/test.utils.d.ts +13 -1
- package/package.json +13 -9
- package/readme.md +3 -0
- package/dist/cjs/css-shim-a22512c4.js +0 -6
- package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
- package/dist/esm/css-shim-7c240feb.js +0 -4
- package/dist/esm/mg-badge_20.entry.js +0 -4638
- package/dist/esm-es5/css-shim-7c240feb.js +0 -1
- package/dist/esm-es5/index-e3e84606.js +0 -1
- package/dist/esm-es5/mg-badge_20.entry.js +0 -2
- package/dist/mg-components/p-1cd24462.system.js +0 -1
- package/dist/mg-components/p-2e2f6b27.system.entry.js +0 -2
- package/dist/mg-components/p-422c429b.system.js +0 -1
- package/dist/mg-components/p-62fa3797.js +0 -1
- package/dist/mg-components/p-9a215712.system.js +0 -1
- package/dist/mg-components/p-cbf0464b.entry.js +0 -1
|
@@ -22,6 +22,7 @@ export class MgTooltip {
|
|
|
22
22
|
this.disabled = false;
|
|
23
23
|
/**
|
|
24
24
|
* Show tooltip
|
|
25
|
+
*
|
|
25
26
|
* @returns {void}
|
|
26
27
|
*/
|
|
27
28
|
this.show = () => {
|
|
@@ -34,6 +35,7 @@ export class MgTooltip {
|
|
|
34
35
|
};
|
|
35
36
|
/**
|
|
36
37
|
* Hide tooltip
|
|
38
|
+
*
|
|
37
39
|
* @returns {void}
|
|
38
40
|
*/
|
|
39
41
|
this.hide = () => {
|
|
@@ -58,6 +60,8 @@ export class MgTooltip {
|
|
|
58
60
|
* Get slotted element
|
|
59
61
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
60
62
|
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
63
|
+
*
|
|
64
|
+
* @returns {void}
|
|
61
65
|
*/
|
|
62
66
|
componentDidLoad() {
|
|
63
67
|
var _a;
|
|
@@ -112,6 +116,11 @@ export class MgTooltip {
|
|
|
112
116
|
});
|
|
113
117
|
this.handleDisplay(this.display);
|
|
114
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Render
|
|
121
|
+
*
|
|
122
|
+
* @returns {HTMLElement} HTML Element
|
|
123
|
+
*/
|
|
115
124
|
render() {
|
|
116
125
|
return (h(Host, null,
|
|
117
126
|
h("slot", null),
|
|
@@ -2,10 +2,11 @@ import { h } from '@stencil/core';
|
|
|
2
2
|
import { InputClass } from './MgInput.conf';
|
|
3
3
|
/**
|
|
4
4
|
* Apply in all input child node the aria-describedby attribute
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @
|
|
5
|
+
*
|
|
6
|
+
* @param {VNode[]} children Represent scoped elements
|
|
7
|
+
* @param {Set<string>} ariaDescribedbyIDs List of IDs
|
|
8
|
+
* @param {FunctionalUtilities} utils Stencil.js utils
|
|
9
|
+
* @returns {VNode[]} Children with aria-describedby attribute
|
|
9
10
|
*/
|
|
10
11
|
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
11
12
|
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
@@ -18,7 +19,8 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
|
|
|
18
19
|
});
|
|
19
20
|
/**
|
|
20
21
|
* Add classes based on props
|
|
21
|
-
*
|
|
22
|
+
*
|
|
23
|
+
* @param {MgInputProps} props MgInput Interface Props
|
|
22
24
|
*/
|
|
23
25
|
const manageClasses = (props) => {
|
|
24
26
|
props.classList.add('mg-input');
|
|
@@ -33,17 +35,19 @@ const manageClasses = (props) => {
|
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
+
* Get tagname
|
|
39
|
+
*
|
|
40
|
+
* @param {boolean} isFieldset is fieldset
|
|
38
41
|
* @returns {string} tag name
|
|
39
42
|
*/
|
|
40
43
|
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
41
44
|
/**
|
|
42
45
|
* Get input template
|
|
43
|
-
*
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @
|
|
46
|
+
*
|
|
47
|
+
* @param {MgInputProps} props MgInput Interface Props
|
|
48
|
+
* @param {VNode[]} children Represent scoped elements
|
|
49
|
+
* @param {FunctionalUtilities} utils Stencil.js utils
|
|
50
|
+
* @returns {VNode[]} input template
|
|
47
51
|
*/
|
|
48
52
|
export const MgInput = (props, children, utils) => {
|
|
49
53
|
/**
|
|
@@ -105,15 +109,17 @@ export const MgInput = (props, children, utils) => {
|
|
|
105
109
|
const TagName = getTagName(props.isFieldset);
|
|
106
110
|
/**
|
|
107
111
|
* Get tooltip node
|
|
108
|
-
*
|
|
112
|
+
*
|
|
113
|
+
* @returns {VNode[]} mg-tooltip
|
|
109
114
|
*/
|
|
110
115
|
const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
|
|
111
116
|
h("mg-icon", { icon: "info-circle" })));
|
|
112
117
|
/**
|
|
113
118
|
* Get input title (label) node
|
|
114
|
-
*
|
|
119
|
+
*
|
|
120
|
+
* @returns {VNode[]} mg-input-title
|
|
115
121
|
*/
|
|
116
|
-
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required, "is-legend": props.isFieldset }, props.label));
|
|
122
|
+
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled, "is-legend": props.isFieldset }, props.label));
|
|
117
123
|
return (h(TagName, { class: props.classList.join() },
|
|
118
124
|
props.labelOnTop ? (h("div", { class: "mg-input__title" },
|
|
119
125
|
getInputTitle(),
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
align-items: flex-start;
|
|
11
11
|
min-height: var(--default-size);
|
|
12
12
|
max-width: 100%;
|
|
13
|
+
margin-bottom: var(--mg-inputs-margin-bottom, 0);
|
|
13
14
|
/* Style when input is not valid */
|
|
14
15
|
/* Label */
|
|
15
16
|
/* Label-on-top */
|
|
@@ -91,7 +92,8 @@
|
|
|
91
92
|
*/
|
|
92
93
|
fieldset.mg-input {
|
|
93
94
|
border: 0;
|
|
94
|
-
margin: 0;
|
|
95
|
+
margin-left: 0;
|
|
96
|
+
margin-right: 0;
|
|
95
97
|
padding: 0;
|
|
96
98
|
}
|
|
97
99
|
fieldset.mg-input input[type=radio],
|
|
@@ -108,6 +110,9 @@ fieldset.mg-input input[type=checkbox] {
|
|
|
108
110
|
fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
|
|
109
111
|
margin-top: 0.7rem;
|
|
110
112
|
}
|
|
113
|
+
fieldset.mg-input.is-not-valid .mg-input__input-group {
|
|
114
|
+
color: initial;
|
|
115
|
+
}
|
|
111
116
|
|
|
112
117
|
.mg-input__input-container mg-tooltip {
|
|
113
118
|
margin-left: 2rem;
|
|
@@ -133,6 +138,9 @@ fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
|
|
|
133
138
|
display: flex;
|
|
134
139
|
align-items: top;
|
|
135
140
|
}
|
|
141
|
+
.mg-input__input-group.mg-input__input-group--disabled label {
|
|
142
|
+
opacity: 0.3;
|
|
143
|
+
}
|
|
136
144
|
|
|
137
145
|
/**
|
|
138
146
|
* A11Y
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Component, Event, h, Prop, State, Watch } from '@stencil/core';
|
|
1
|
+
import { Component, Event, h, Prop, State, Watch, Method } from '@stencil/core';
|
|
2
2
|
import { MgInput } from '../MgInput';
|
|
3
3
|
import { createID, ClassList } from '../../../../utils/components.utils';
|
|
4
4
|
import { messages } from '../../../../locales';
|
|
5
5
|
import { InputClass } from '../MgInput.conf';
|
|
6
6
|
/**
|
|
7
7
|
* type CheckboxItem validation function
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
8
|
+
*
|
|
9
|
+
* @param {CheckboxItem} item Checkbox item
|
|
10
|
+
* @returns {boolean} match item expectations
|
|
10
11
|
*/
|
|
11
12
|
const isCheckboxItem = (item) => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined;
|
|
12
13
|
export class MgInputCheckbox {
|
|
@@ -58,7 +59,8 @@ export class MgInputCheckbox {
|
|
|
58
59
|
this.checkboxItems = [];
|
|
59
60
|
/**
|
|
60
61
|
* Handle input event
|
|
61
|
-
*
|
|
62
|
+
*
|
|
63
|
+
* @param {InputEvent} event input event
|
|
62
64
|
*/
|
|
63
65
|
this.handleInput = (event) => {
|
|
64
66
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -69,7 +71,6 @@ export class MgInputCheckbox {
|
|
|
69
71
|
});
|
|
70
72
|
this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
|
|
71
73
|
this.checkValidity();
|
|
72
|
-
this.valueChange.emit(this.value);
|
|
73
74
|
};
|
|
74
75
|
/**
|
|
75
76
|
* Handle blur event
|
|
@@ -79,9 +80,41 @@ export class MgInputCheckbox {
|
|
|
79
80
|
this.checkValidity();
|
|
80
81
|
this.checkError();
|
|
81
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Check if input is valid
|
|
85
|
+
*/
|
|
86
|
+
this.checkValidity = () => {
|
|
87
|
+
if (!this.readonly) {
|
|
88
|
+
const validity = this.getInvalidElement() === undefined;
|
|
89
|
+
// Set validity
|
|
90
|
+
this.valid = validity;
|
|
91
|
+
this.invalid = !validity;
|
|
92
|
+
//Send event
|
|
93
|
+
this.inputValid.emit(validity);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Check input errors
|
|
98
|
+
*/
|
|
99
|
+
this.checkError = () => {
|
|
100
|
+
const invalidElement = this.getInvalidElement();
|
|
101
|
+
// Set error message
|
|
102
|
+
this.errorMessage = undefined;
|
|
103
|
+
if (!this.valid && invalidElement.validity.valueMissing) {
|
|
104
|
+
this.errorMessage = messages.errors.required;
|
|
105
|
+
}
|
|
106
|
+
// Update class
|
|
107
|
+
if (this.valid) {
|
|
108
|
+
this.classList.delete(this.classError);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
this.classList.add(this.classError);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
82
114
|
/**
|
|
83
115
|
* get invalid element
|
|
84
|
-
*
|
|
116
|
+
*
|
|
117
|
+
* @returns {HTMLInputElement} element
|
|
85
118
|
*/
|
|
86
119
|
this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
|
|
87
120
|
}
|
|
@@ -93,6 +126,7 @@ export class MgInputCheckbox {
|
|
|
93
126
|
value: item.value,
|
|
94
127
|
disabled: item.disabled,
|
|
95
128
|
}));
|
|
129
|
+
this.valueChange.emit(newValue);
|
|
96
130
|
}
|
|
97
131
|
else {
|
|
98
132
|
throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
|
|
@@ -102,51 +136,44 @@ export class MgInputCheckbox {
|
|
|
102
136
|
this.classList.delete(this.classError);
|
|
103
137
|
}
|
|
104
138
|
/**
|
|
105
|
-
*
|
|
139
|
+
* Public method to display errors
|
|
140
|
+
*
|
|
141
|
+
* @returns {Promise<void>}
|
|
106
142
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// Set validity
|
|
111
|
-
this.valid = validity;
|
|
112
|
-
this.invalid = !validity;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Check input errors
|
|
117
|
-
*/
|
|
118
|
-
checkError() {
|
|
119
|
-
const invalidElement = this.getInvalidElement();
|
|
120
|
-
// Set error message
|
|
121
|
-
this.errorMessage = undefined;
|
|
122
|
-
if (!this.valid && invalidElement.validity.valueMissing) {
|
|
123
|
-
this.errorMessage = messages.errors.required;
|
|
124
|
-
}
|
|
125
|
-
// Update class
|
|
126
|
-
if (this.valid) {
|
|
127
|
-
this.classList.delete(this.classError);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
this.classList.add(this.classError);
|
|
131
|
-
}
|
|
143
|
+
async displayError() {
|
|
144
|
+
this.checkValidity();
|
|
145
|
+
this.checkError();
|
|
132
146
|
}
|
|
133
147
|
/*************
|
|
134
148
|
* Lifecycle *
|
|
135
149
|
*************/
|
|
150
|
+
/**
|
|
151
|
+
* Check if component props are well configured on init
|
|
152
|
+
*
|
|
153
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
154
|
+
*/
|
|
136
155
|
componentWillLoad() {
|
|
137
156
|
// Check values format
|
|
138
157
|
this.validateValue(this.value);
|
|
158
|
+
// Check validity when component is ready
|
|
139
159
|
// return a promise to process action only in the FIRST render().
|
|
140
160
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
141
|
-
return setTimeout(() =>
|
|
161
|
+
return setTimeout(() => {
|
|
162
|
+
this.checkValidity();
|
|
163
|
+
}, 0);
|
|
142
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Render
|
|
167
|
+
*
|
|
168
|
+
* @returns {HTMLElement} HTML Element
|
|
169
|
+
*/
|
|
143
170
|
render() {
|
|
144
171
|
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined, width: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true },
|
|
145
|
-
h("ul", { class:
|
|
172
|
+
h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
|
|
146
173
|
.filter(item => {
|
|
147
174
|
return !this.readonly || item.value;
|
|
148
175
|
})
|
|
149
|
-
.map(input => (h("li", { class:
|
|
176
|
+
.map(input => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } },
|
|
150
177
|
h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => this.inputs.push(el) }),
|
|
151
178
|
h("label", { htmlFor: input.id }, input.title)))))));
|
|
152
179
|
}
|
|
@@ -188,7 +215,7 @@ export class MgInputCheckbox {
|
|
|
188
215
|
"references": {}
|
|
189
216
|
},
|
|
190
217
|
"required": false,
|
|
191
|
-
"optional":
|
|
218
|
+
"optional": false,
|
|
192
219
|
"docs": {
|
|
193
220
|
"tags": [],
|
|
194
221
|
"text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
|
|
@@ -206,7 +233,7 @@ export class MgInputCheckbox {
|
|
|
206
233
|
"references": {}
|
|
207
234
|
},
|
|
208
235
|
"required": false,
|
|
209
|
-
"optional":
|
|
236
|
+
"optional": false,
|
|
210
237
|
"docs": {
|
|
211
238
|
"tags": [],
|
|
212
239
|
"text": "Input name\nIf not set the value equals the identifier"
|
|
@@ -227,7 +254,7 @@ export class MgInputCheckbox {
|
|
|
227
254
|
"optional": false,
|
|
228
255
|
"docs": {
|
|
229
256
|
"tags": [],
|
|
230
|
-
"text": "Input label
|
|
257
|
+
"text": "Input label"
|
|
231
258
|
},
|
|
232
259
|
"attribute": "label",
|
|
233
260
|
"reflect": false
|
|
@@ -385,7 +412,7 @@ export class MgInputCheckbox {
|
|
|
385
412
|
"optional": false,
|
|
386
413
|
"docs": {
|
|
387
414
|
"tags": [],
|
|
388
|
-
"text": "
|
|
415
|
+
"text": "Define input valid state"
|
|
389
416
|
},
|
|
390
417
|
"attribute": "valid",
|
|
391
418
|
"reflect": false
|
|
@@ -402,7 +429,7 @@ export class MgInputCheckbox {
|
|
|
402
429
|
"optional": false,
|
|
403
430
|
"docs": {
|
|
404
431
|
"tags": [],
|
|
405
|
-
"text": "
|
|
432
|
+
"text": "Define input invalid state"
|
|
406
433
|
},
|
|
407
434
|
"attribute": "invalid",
|
|
408
435
|
"reflect": false
|
|
@@ -433,7 +460,43 @@ export class MgInputCheckbox {
|
|
|
433
460
|
}
|
|
434
461
|
}
|
|
435
462
|
}
|
|
463
|
+
}, {
|
|
464
|
+
"method": "inputValid",
|
|
465
|
+
"name": "input-valid",
|
|
466
|
+
"bubbles": true,
|
|
467
|
+
"cancelable": true,
|
|
468
|
+
"composed": true,
|
|
469
|
+
"docs": {
|
|
470
|
+
"tags": [],
|
|
471
|
+
"text": "Emited event when checking validity"
|
|
472
|
+
},
|
|
473
|
+
"complexType": {
|
|
474
|
+
"original": "boolean",
|
|
475
|
+
"resolved": "boolean",
|
|
476
|
+
"references": {}
|
|
477
|
+
}
|
|
436
478
|
}]; }
|
|
479
|
+
static get methods() { return {
|
|
480
|
+
"displayError": {
|
|
481
|
+
"complexType": {
|
|
482
|
+
"signature": "() => Promise<void>",
|
|
483
|
+
"parameters": [],
|
|
484
|
+
"references": {
|
|
485
|
+
"Promise": {
|
|
486
|
+
"location": "global"
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
"return": "Promise<void>"
|
|
490
|
+
},
|
|
491
|
+
"docs": {
|
|
492
|
+
"text": "Public method to display errors",
|
|
493
|
+
"tags": [{
|
|
494
|
+
"name": "returns",
|
|
495
|
+
"text": undefined
|
|
496
|
+
}]
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}; }
|
|
437
500
|
static get watchers() { return [{
|
|
438
501
|
"propName": "value",
|
|
439
502
|
"methodName": "validateValue"
|
package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js
CHANGED
|
@@ -2,12 +2,17 @@ import { h } from '@stencil/core';
|
|
|
2
2
|
export default {
|
|
3
3
|
component: 'mg-input-checkbox',
|
|
4
4
|
title: 'Molecules/Inputs/mg-input-checkbox',
|
|
5
|
+
parameters: { actions: { handles: ['value-change', 'input-valid'] } },
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
8
9
|
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
10
|
+
*
|
|
11
|
+
* @param {any} args component arguments
|
|
12
|
+
* @returns {HTMLElement} HTMLElement
|
|
9
13
|
*/
|
|
10
|
-
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const Template = (args) => {
|
|
11
16
|
// Extract slot so it won't be render as an attribute
|
|
12
17
|
const labelOnTop = args.labelOnTop;
|
|
13
18
|
delete args.labelOnTop;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
align-items: flex-start;
|
|
11
11
|
min-height: var(--default-size);
|
|
12
12
|
max-width: 100%;
|
|
13
|
+
margin-bottom: var(--mg-inputs-margin-bottom, 0);
|
|
13
14
|
/* Style when input is not valid */
|
|
14
15
|
/* Label */
|
|
15
16
|
/* Label-on-top */
|
|
@@ -96,6 +97,7 @@
|
|
|
96
97
|
*/
|
|
97
98
|
.mg-input__box {
|
|
98
99
|
padding: calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);
|
|
100
|
+
width: 100%;
|
|
99
101
|
height: var(--default-size);
|
|
100
102
|
box-sizing: border-box;
|
|
101
103
|
border-width: var(--mg-inputs-border-width);
|
|
@@ -145,6 +147,31 @@
|
|
|
145
147
|
display: none;
|
|
146
148
|
}
|
|
147
149
|
|
|
150
|
+
.mg-input.mg-input--label-on-top .mg-input__box {
|
|
151
|
+
width: auto;
|
|
152
|
+
max-width: 100%;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]) {
|
|
156
|
+
--mg-button-border-radius-top-right: 0;
|
|
157
|
+
--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
|
+
}
|
|
163
|
+
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)) {
|
|
164
|
+
--mg-button-border-right-width: 0;
|
|
165
|
+
}
|
|
166
|
+
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type) {
|
|
167
|
+
--mg-button-border-radius-top-right: var(--mg-inputs-border-radius);
|
|
168
|
+
--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
|
+
|
|
148
175
|
.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]) {
|
|
149
176
|
padding-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
150
177
|
}
|