@mgdis/mg-components 5.0.0 → 5.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/loader.cjs.js +1 -1
- package/dist/cjs/{mg-badge_24.cjs.entry.js → mg-badge_27.cjs.entry.js} +892 -295
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -1
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +8 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +41 -3
- package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +18 -0
- package/dist/collection/components/atoms/mg-card/mg-card.css +7 -0
- package/dist/collection/components/atoms/mg-card/mg-card.js +26 -0
- package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +18 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.css +9 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +57 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -5
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +0 -20
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +2 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +3 -11
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +41 -20
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +50 -39
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +42 -33
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +36 -17
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +35 -14
- package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +2 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -6
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +36 -17
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +38 -19
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +37 -18
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +1 -0
- package/dist/collection/components/molecules/mg-details/mg-details.css +29 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +26 -4
- package/dist/collection/components/molecules/mg-form/mg-form.js +73 -27
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +6 -6
- package/dist/collection/components/molecules/mg-message/mg-message.js +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +2 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +48 -4
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +5 -14
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -5
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +3 -2
- package/dist/collection/utils/components.utils.js +10 -6
- package/dist/collection/utils/unit.test.utils.js +51 -0
- package/dist/collection/variables.css +23 -8
- package/dist/components/MgInput.js +4 -12
- package/dist/components/components.utils.js +11 -7
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/mg-badge2.js +1 -1
- package/dist/components/mg-button2.js +23 -4
- package/dist/components/mg-card.d.ts +11 -0
- package/dist/components/mg-card.js +42 -0
- package/dist/components/mg-details.js +8 -3
- package/dist/components/mg-divider.d.ts +11 -0
- package/dist/components/mg-divider.js +51 -0
- package/dist/components/mg-form.js +67 -26
- package/dist/components/mg-input-checkbox.js +36 -21
- package/dist/components/mg-input-date.js +44 -39
- package/dist/components/mg-input-numeric.js +37 -34
- package/dist/components/mg-input-password.js +32 -19
- package/dist/components/mg-input-radio.js +30 -15
- package/dist/components/mg-input-select2.js +32 -19
- package/dist/components/mg-input-text2.js +34 -21
- package/dist/components/mg-input-textarea.js +32 -19
- package/dist/components/mg-input-toggle.js +1 -1
- package/dist/components/mg-message.js +1 -1
- package/dist/components/mg-modal.js +49 -5
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover.js +3 -2
- package/dist/components/mg-tag.js +1 -1
- package/dist/components/mg-tooltip2.js +2 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mg-badge_24.entry.js → mg-badge_27.entry.js} +839 -245
- package/dist/esm/mg-components.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-b2b07c3f.entry.js +1 -0
- package/dist/mg-components/variables.css +23 -8
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +8 -2
- package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -0
- package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +15 -0
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +0 -8
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +10 -8
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +3 -8
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +3 -8
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -4
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -3
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +21 -1
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +3 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +11 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +1 -1
- package/dist/types/components.d.ts +55 -6
- package/dist/types/utils/components.utils.d.ts +7 -3
- package/package.json +9 -9
- package/dist/cjs/index-179621c8.js +0 -244
- package/dist/cjs/mg-modal.cjs.entry.js +0 -128
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -20
- package/dist/collection/utils/test.utils.js +0 -38
- package/dist/esm/index-7efedd97.js +0 -238
- package/dist/esm/mg-modal.entry.js +0 -124
- package/dist/mg-components/p-5f89600c.js +0 -1
- package/dist/mg-components/p-b60a4c53.entry.js +0 -1
- package/dist/mg-components/p-df947fa5.entry.js +0 -1
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -8
- package/dist/types/utils/test.utils.d.ts +0 -17
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["mg-
|
|
18
|
+
return index.bootstrapLazy([["mg-badge_27.cjs",[[1,"mg-panel",{"identifier":[1],"panelTitle":[1025,"panel-title"],"titlePattern":[1025,"title-pattern"],"titlePatternErrorMessage":[1025,"title-pattern-error-message"],"expanded":[1028],"expandToggleDisabled":[1028,"expand-toggle-disabled"],"titleEditable":[4,"title-editable"],"classList":[32],"isEditing":[32],"updatedPanelTitle":[32]}],[1,"mg-pagination",{"identifier":[1],"label":[1025],"totalPages":[2,"total-pages"],"currentPage":[1538,"current-page"]}],[1,"mg-input-textarea",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"maxlength":[2],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"pattern":[1],"patternErrorMessage":[1,"pattern-error-message"],"rows":[2],"tooltip":[1],"displayCharacterLeft":[4,"display-character-left"],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"resizable":[1],"classList":[32],"errorMessage":[32],"displayError":[64]}],[1,"mg-input-checkbox",{"value":[1040],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"inputVerticalList":[4,"input-vertical-list"],"required":[4],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"checkboxItems":[32],"displayError":[64]}],[1,"mg-input-date",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"required":[4],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"min":[1],"max":[1],"classList":[32],"errorMessage":[32],"displayError":[64]}],[1,"mg-input-numeric",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"tooltip":[1],"helpText":[1,"help-text"],"type":[1],"currency":[1],"max":[2],"min":[2],"integerLength":[2,"integer-length"],"decimalLength":[2,"decimal-length"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"hasFocus":[32],"displayError":[64]}],[1,"mg-input-password",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"displayError":[64]}],[1,"mg-input-radio",{"value":[1032],"items":[16],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"inputVerticalList":[4,"input-vertical-list"],"required":[4],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"options":[32],"displayError":[64]}],[1,"mg-input-toggle",{"value":[1032],"items":[16],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"isOnOff":[4,"is-on-off"],"isIcon":[4,"is-icon"],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"classList":[32],"options":[32],"checked":[32]}],[1,"mg-message",{"identifier":[1],"delay":[2],"variant":[1],"closeButton":[1028,"close-button"],"hide":[1028],"classList":[32],"hasActions":[32]}],[1,"mg-modal",{"identifier":[1],"modalTitle":[1,"modal-title"],"closeButton":[1028,"close-button"],"hide":[1028],"hasActions":[32],"hasContent":[32],"classList":[32]},[[8,"keydown","handleKeyDown"]]],[1,"mg-popover",{"identifier":[1],"placement":[1],"closeButton":[4,"close-button"],"display":[1028],"disabled":[1028]}],[1,"mg-tabs",{"identifier":[1],"label":[1],"size":[1],"items":[16],"activeTab":[1538,"active-tab"],"tabs":[32],"classList":[32]}],[1,"mg-details",{"toggleClosed":[1,"toggle-closed"],"toggleOpened":[1,"toggle-opened"],"hideSummary":[4,"hide-summary"],"expanded":[1028]}],[1,"mg-card"],[1,"mg-divider",{"size":[1]}],[1,"mg-form",{"identifier":[1],"name":[1],"readonly":[4],"disabled":[4],"valid":[1028],"invalid":[1028],"classList":[32],"requiredMessage":[32],"displayError":[64]}],[1,"mg-illustrated-message",{"size":[1],"direction":[1]}],[1,"mg-tag",{"variant":[1],"outline":[4],"classList":[32]}],[1,"mg-input-text",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"type":[1],"icon":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"maxlength":[2],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"pattern":[1],"patternErrorMessage":[1,"pattern-error-message"],"tooltip":[1],"displayCharacterLeft":[4,"display-character-left"],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"setFocus":[64],"displayError":[64]}],[1,"mg-input-select",{"value":[1032],"items":[16],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1025],"placeholderHide":[4,"placeholder-hide"],"placeholderDisabled":[4,"placeholder-disabled"],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"options":[32],"valueExist":[32],"readonlyValue":[32],"displayError":[64]}],[1,"mg-badge",{"value":[1032],"label":[1],"variant":[1],"outline":[4],"classList":[32]}],[2,"mg-character-left",{"identifier":[1],"characters":[1],"maxlength":[2]}],[1,"mg-button",{"variant":[1],"identifier":[1],"label":[1],"type":[1],"fullWidth":[1028,"full-width"],"form":[1025],"disabled":[1028],"isIcon":[4,"is-icon"],"disableOnClick":[4,"disable-on-click"],"loading":[32],"classList":[32]}],[6,"mg-input-title",{"identifier":[1],"required":[4],"isLegend":[4,"is-legend"],"tagName":[32]}],[1,"mg-tooltip",{"identifier":[1],"message":[1],"placement":[1],"display":[1028],"disabled":[1028]}],[1,"mg-icon",{"icon":[1],"size":[1],"variant":[1],"spin":[4],"classList":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
"entries": [
|
|
3
3
|
"./components/atoms/mg-badge/mg-badge.js",
|
|
4
4
|
"./components/atoms/mg-button/mg-button.js",
|
|
5
|
+
"./components/atoms/mg-card/mg-card.js",
|
|
5
6
|
"./components/atoms/mg-character-left/mg-character-left.js",
|
|
7
|
+
"./components/atoms/mg-divider/mg-divider.js",
|
|
6
8
|
"./components/atoms/mg-icon/mg-icon.js",
|
|
7
9
|
"./components/atoms/mg-input-title/mg-input-title.js",
|
|
8
10
|
"./components/atoms/mg-tag/mg-tag.js",
|
|
@@ -37,6 +37,7 @@ MgButton.args = {
|
|
|
37
37
|
disableOnClick: false,
|
|
38
38
|
isIcon: false,
|
|
39
39
|
type: undefined,
|
|
40
|
+
fullWidth: undefined,
|
|
40
41
|
};
|
|
41
42
|
export const IsIcon = Template.bind({});
|
|
42
43
|
IsIcon.args = Object.assign(Object.assign({}, MgButton.args), { isIcon: true, slot: h("mg-icon", { icon: Object.keys(icons)[0] }) });
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
background: hsla(var(--color-dark), 0.1);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
:host([full-width]) {
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
.mg-button.mg-button--primary {
|
|
25
29
|
border-color: hsl(var(--mg-button-primary-border-color, var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-border-variation) * 10%)));
|
|
26
30
|
color: hsl(var(--mg-button-primary-font-color));
|
|
@@ -140,6 +144,10 @@
|
|
|
140
144
|
background: none;
|
|
141
145
|
border: none;
|
|
142
146
|
}
|
|
147
|
+
.mg-button.mg-button--full-width {
|
|
148
|
+
display: flex;
|
|
149
|
+
justify-content: center;
|
|
150
|
+
}
|
|
143
151
|
.mg-button.mg-button--loading > mg-icon:first-of-type {
|
|
144
152
|
position: absolute;
|
|
145
153
|
left: 50%;
|
|
@@ -9,10 +9,15 @@ export class MgButton {
|
|
|
9
9
|
this.onClickElementFn = null;
|
|
10
10
|
this.classDisabled = 'mg-button--disabled';
|
|
11
11
|
this.classLoading = 'mg-button--loading';
|
|
12
|
+
this.classFullWidth = 'mg-button--full-width';
|
|
12
13
|
/**
|
|
13
14
|
* Define button variant
|
|
14
15
|
*/
|
|
15
16
|
this.variant = variants[0]; // Primary
|
|
17
|
+
/**
|
|
18
|
+
* Set button to full-width
|
|
19
|
+
*/
|
|
20
|
+
this.fullWidth = false;
|
|
16
21
|
/**
|
|
17
22
|
* Define if button is round.
|
|
18
23
|
* Used for icon button.
|
|
@@ -49,7 +54,7 @@ export class MgButton {
|
|
|
49
54
|
}
|
|
50
55
|
};
|
|
51
56
|
/**
|
|
52
|
-
* Handle
|
|
57
|
+
* Handle onKeydown event
|
|
53
58
|
*
|
|
54
59
|
* @param {KeyboardEvent} event keyboard event
|
|
55
60
|
* @returns {void}
|
|
@@ -64,7 +69,7 @@ export class MgButton {
|
|
|
64
69
|
}
|
|
65
70
|
};
|
|
66
71
|
/**
|
|
67
|
-
* Handle
|
|
72
|
+
* Handle onKeyup event
|
|
68
73
|
*
|
|
69
74
|
* @param {KeyboardEvent} event keyboard event
|
|
70
75
|
* @returns {void}
|
|
@@ -87,6 +92,17 @@ export class MgButton {
|
|
|
87
92
|
this.classList.add(`mg-button--${newValue}`);
|
|
88
93
|
}
|
|
89
94
|
}
|
|
95
|
+
validateFullWidth(newValue) {
|
|
96
|
+
if (newValue && this.isIcon) {
|
|
97
|
+
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
98
|
+
}
|
|
99
|
+
else if (newValue) {
|
|
100
|
+
this.classList.add(this.classFullWidth);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.classList.delete(this.classFullWidth);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
90
106
|
disabledHandler(isDisabled) {
|
|
91
107
|
// Remove loading when enable
|
|
92
108
|
// Will be set back onclick
|
|
@@ -119,6 +135,7 @@ export class MgButton {
|
|
|
119
135
|
*/
|
|
120
136
|
componentWillLoad() {
|
|
121
137
|
this.validateVariant(this.variant);
|
|
138
|
+
this.validateFullWidth(this.fullWidth);
|
|
122
139
|
if (this.isIcon) {
|
|
123
140
|
this.classList.add(`mg-button--icon`);
|
|
124
141
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
@@ -135,7 +152,7 @@ export class MgButton {
|
|
|
135
152
|
* @returns {HTMLElement} html element
|
|
136
153
|
*/
|
|
137
154
|
render() {
|
|
138
|
-
return (h(Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick,
|
|
155
|
+
return (h(Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, h("div", { class: this.classList.join(), id: this.identifier }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-button__content" }, h("slot", null)))));
|
|
139
156
|
}
|
|
140
157
|
static get is() { return "mg-button"; }
|
|
141
158
|
static get encapsulation() { return "shadow"; }
|
|
@@ -230,6 +247,24 @@ export class MgButton {
|
|
|
230
247
|
"attribute": "type",
|
|
231
248
|
"reflect": false
|
|
232
249
|
},
|
|
250
|
+
"fullWidth": {
|
|
251
|
+
"type": "boolean",
|
|
252
|
+
"mutable": true,
|
|
253
|
+
"complexType": {
|
|
254
|
+
"original": "boolean",
|
|
255
|
+
"resolved": "boolean",
|
|
256
|
+
"references": {}
|
|
257
|
+
},
|
|
258
|
+
"required": false,
|
|
259
|
+
"optional": false,
|
|
260
|
+
"docs": {
|
|
261
|
+
"tags": [],
|
|
262
|
+
"text": "Set button to full-width"
|
|
263
|
+
},
|
|
264
|
+
"attribute": "full-width",
|
|
265
|
+
"reflect": false,
|
|
266
|
+
"defaultValue": "false"
|
|
267
|
+
},
|
|
233
268
|
"form": {
|
|
234
269
|
"type": "string",
|
|
235
270
|
"mutable": true,
|
|
@@ -313,6 +348,9 @@ export class MgButton {
|
|
|
313
348
|
return [{
|
|
314
349
|
"propName": "variant",
|
|
315
350
|
"methodName": "validateVariant"
|
|
351
|
+
}, {
|
|
352
|
+
"propName": "fullWidth",
|
|
353
|
+
"methodName": "validateFullWidth"
|
|
316
354
|
}, {
|
|
317
355
|
"propName": "disabled",
|
|
318
356
|
"methodName": "disabledHandler"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import { filterArgs } from '../../../../../.storybook/utils';
|
|
3
|
+
export default {
|
|
4
|
+
component: 'mg-card',
|
|
5
|
+
title: 'Atoms/mg-card',
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Template
|
|
9
|
+
*
|
|
10
|
+
* @param {any} args component arguments
|
|
11
|
+
* @returns {HTMLElement} HTMLElement
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
const Template = (args) => h("mg-card", Object.assign({}, filterArgs(args)), args.slot);
|
|
15
|
+
export const MgCard = Template.bind({});
|
|
16
|
+
MgCard.args = {
|
|
17
|
+
slot: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
|
18
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export class MgCard {
|
|
3
|
+
/*************
|
|
4
|
+
* Lifecycle *
|
|
5
|
+
*************/
|
|
6
|
+
/**
|
|
7
|
+
* Render
|
|
8
|
+
*
|
|
9
|
+
* @returns {HTMLElement} HTML Element
|
|
10
|
+
*/
|
|
11
|
+
render() {
|
|
12
|
+
return (h("div", { class: "mg-card" }, h("slot", null)));
|
|
13
|
+
}
|
|
14
|
+
static get is() { return "mg-card"; }
|
|
15
|
+
static get encapsulation() { return "shadow"; }
|
|
16
|
+
static get originalStyleUrls() {
|
|
17
|
+
return {
|
|
18
|
+
"$": ["mg-card.scss"]
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
static get styleUrls() {
|
|
22
|
+
return {
|
|
23
|
+
"$": ["mg-card.css"]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import { filterArgs } from '../../../../../.storybook/utils';
|
|
3
|
+
export default {
|
|
4
|
+
component: 'mg-divider',
|
|
5
|
+
title: 'Atoms/mg-divider',
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Template
|
|
9
|
+
*
|
|
10
|
+
* @param {any} args component arguments
|
|
11
|
+
* @returns {HTMLElement} HTMLElement
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
const Template = (args) => h("mg-divider", Object.assign({}, filterArgs(args, { size: 'regular' })));
|
|
15
|
+
export const MgDivider = Template.bind({});
|
|
16
|
+
MgDivider.args = {
|
|
17
|
+
size: 'regular',
|
|
18
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export class MgDivider {
|
|
3
|
+
constructor() {
|
|
4
|
+
/**************
|
|
5
|
+
* Decorators *
|
|
6
|
+
**************/
|
|
7
|
+
/**
|
|
8
|
+
* Define component size
|
|
9
|
+
*/
|
|
10
|
+
this.size = 'regular';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Render
|
|
14
|
+
*
|
|
15
|
+
* @returns {HTMLElement} HTML Element
|
|
16
|
+
*/
|
|
17
|
+
render() {
|
|
18
|
+
return (h("div", { class: {
|
|
19
|
+
'mg-divider': true,
|
|
20
|
+
'mg-divider--full': this.size === 'full',
|
|
21
|
+
} }));
|
|
22
|
+
}
|
|
23
|
+
static get is() { return "mg-divider"; }
|
|
24
|
+
static get encapsulation() { return "shadow"; }
|
|
25
|
+
static get originalStyleUrls() {
|
|
26
|
+
return {
|
|
27
|
+
"$": ["mg-divider.scss"]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
static get styleUrls() {
|
|
31
|
+
return {
|
|
32
|
+
"$": ["mg-divider.css"]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
static get properties() {
|
|
36
|
+
return {
|
|
37
|
+
"size": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"mutable": false,
|
|
40
|
+
"complexType": {
|
|
41
|
+
"original": "'regular' | 'full'",
|
|
42
|
+
"resolved": "\"full\" | \"regular\"",
|
|
43
|
+
"references": {}
|
|
44
|
+
},
|
|
45
|
+
"required": false,
|
|
46
|
+
"optional": false,
|
|
47
|
+
"docs": {
|
|
48
|
+
"tags": [],
|
|
49
|
+
"text": "Define component size"
|
|
50
|
+
},
|
|
51
|
+
"attribute": "size",
|
|
52
|
+
"reflect": false,
|
|
53
|
+
"defaultValue": "'regular'"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
2
|
import { filterArgs } from '../../../../../.storybook/utils';
|
|
3
|
-
import { placements } from '../mg-tooltip.conf';
|
|
4
3
|
export default {
|
|
5
4
|
component: 'mg-tooltip',
|
|
6
5
|
title: 'Atoms/mg-tooltip',
|
|
@@ -9,11 +8,7 @@ export default {
|
|
|
9
8
|
},
|
|
10
9
|
argTypes: {
|
|
11
10
|
placement: {
|
|
12
|
-
options: placements,
|
|
13
11
|
control: { type: 'select' },
|
|
14
|
-
table: {
|
|
15
|
-
defaultValue: { summary: 'bottom' },
|
|
16
|
-
},
|
|
17
12
|
},
|
|
18
13
|
},
|
|
19
14
|
};
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* List of all possibles placements
|
|
3
|
-
*/
|
|
4
|
-
export const placements = [
|
|
5
|
-
'auto',
|
|
6
|
-
'auto-start',
|
|
7
|
-
'auto-end',
|
|
8
|
-
'top',
|
|
9
|
-
'top-start',
|
|
10
|
-
'top-end',
|
|
11
|
-
'bottom',
|
|
12
|
-
'bottom-start',
|
|
13
|
-
'bottom-end',
|
|
14
|
-
'right',
|
|
15
|
-
'right-start',
|
|
16
|
-
'right-end',
|
|
17
|
-
'left',
|
|
18
|
-
'left-start',
|
|
19
|
-
'left-end',
|
|
20
|
-
];
|
|
21
1
|
export var Guard;
|
|
22
2
|
(function (Guard) {
|
|
23
3
|
Guard["FOCUS"] = "focus";
|
|
@@ -136,6 +136,7 @@ export class MgTooltip {
|
|
|
136
136
|
// Create popperjs tooltip
|
|
137
137
|
this.popper = createPopper(tooltipedElement, this.tooltip, {
|
|
138
138
|
placement: this.placement,
|
|
139
|
+
strategy: 'fixed',
|
|
139
140
|
modifiers: [
|
|
140
141
|
{
|
|
141
142
|
name: 'offset',
|
|
@@ -241,7 +242,7 @@ export class MgTooltip {
|
|
|
241
242
|
"references": {
|
|
242
243
|
"Placement": {
|
|
243
244
|
"location": "import",
|
|
244
|
-
"path": "
|
|
245
|
+
"path": "@popperjs/core"
|
|
245
246
|
}
|
|
246
247
|
}
|
|
247
248
|
},
|
|
@@ -76,15 +76,6 @@ export const MgInput = (props, children, utils) => {
|
|
|
76
76
|
if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
|
|
77
77
|
ariaDescribedbyIDs.add(helpTextErrorId);
|
|
78
78
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Update input(s) in children
|
|
81
|
-
*/
|
|
82
|
-
if (props.readonly) {
|
|
83
|
-
children = children.filter(child => child.$name$ === 'append-input');
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
children = applyAriadescribedBy(children, ariaDescribedbyIDs, utils);
|
|
87
|
-
}
|
|
88
79
|
/**
|
|
89
80
|
* Return template
|
|
90
81
|
*
|
|
@@ -109,9 +100,10 @@ export const MgInput = (props, children, utils) => {
|
|
|
109
100
|
const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip }, h("mg-icon", { icon: "info-circle" })));
|
|
110
101
|
/**
|
|
111
102
|
* Get input title (label) node
|
|
103
|
+
* Display asterisk only if not disabled and not readonly
|
|
112
104
|
*
|
|
113
105
|
* @returns {VNode[]} mg-input-title
|
|
114
106
|
*/
|
|
115
|
-
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));
|
|
116
|
-
return (h(TagName, { class: props.classList.join() }, props.labelOnTop ? (h("div", { class: "mg-input__title" }, getInputTitle(), !props.readonly && props.tooltip && getTooltip())) : (getInputTitle()), props.readonly ? (h("div", { class: "mg-input__input-container" }, h("strong", null, props.readonlyValue || props.value), children)) : (h("div", { class: "mg-input__input-container" }, h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } }, children, !props.labelOnTop && props.tooltip && getTooltip()), props.helpText && h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }), props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
|
|
107
|
+
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
|
|
108
|
+
return (h(TagName, { class: props.classList.join() }, props.labelOnTop ? (h("div", { class: "mg-input__title" }, getInputTitle(), !props.readonly && props.tooltip && getTooltip())) : (getInputTitle()), props.readonly ? (h("div", { class: "mg-input__input-container" }, h("strong", null, props.readonlyValue || props.value), children.filter(child => child.$name$ === 'append-input'))) : (h("div", { class: "mg-input__input-container" }, h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } }, applyAriadescribedBy(children, ariaDescribedbyIDs, utils), !props.labelOnTop && props.tooltip && getTooltip()), props.helpText && h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }), props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
|
|
117
109
|
};
|
|
@@ -16,6 +16,8 @@ export class MgInputCheckbox {
|
|
|
16
16
|
************/
|
|
17
17
|
// HTML selector
|
|
18
18
|
this.inputs = [];
|
|
19
|
+
// hasDisplayedError (triggered by blur event)
|
|
20
|
+
this.hasDisplayedError = false;
|
|
19
21
|
/**
|
|
20
22
|
* Input name
|
|
21
23
|
* If not set the value equals the identifier
|
|
@@ -70,25 +72,27 @@ export class MgInputCheckbox {
|
|
|
70
72
|
this.handleBlur = () => {
|
|
71
73
|
// Check validity
|
|
72
74
|
this.checkValidity();
|
|
73
|
-
this.
|
|
75
|
+
this.setErrorMessage();
|
|
74
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* get invalid element
|
|
79
|
+
*
|
|
80
|
+
* @returns {HTMLInputElement} element
|
|
81
|
+
*/
|
|
82
|
+
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
75
83
|
/**
|
|
76
84
|
* Check if input is valid
|
|
77
85
|
*/
|
|
78
86
|
this.checkValidity = () => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.invalid = !validity;
|
|
84
|
-
//Send event
|
|
85
|
-
this.inputValid.emit(validity);
|
|
86
|
-
}
|
|
87
|
+
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
88
|
+
this.invalid = !this.valid;
|
|
89
|
+
// We need to send valid event even if it is the same value
|
|
90
|
+
this.inputValid.emit(this.valid);
|
|
87
91
|
};
|
|
88
92
|
/**
|
|
89
|
-
*
|
|
93
|
+
* Set input error message
|
|
90
94
|
*/
|
|
91
|
-
this.
|
|
95
|
+
this.setErrorMessage = () => {
|
|
92
96
|
const invalidElement = this.getInvalidElement();
|
|
93
97
|
// Set error message
|
|
94
98
|
this.errorMessage = undefined;
|
|
@@ -96,12 +100,6 @@ export class MgInputCheckbox {
|
|
|
96
100
|
this.errorMessage = this.messages.errors.required;
|
|
97
101
|
}
|
|
98
102
|
};
|
|
99
|
-
/**
|
|
100
|
-
* get invalid element
|
|
101
|
-
*
|
|
102
|
-
* @returns {HTMLInputElement} element
|
|
103
|
-
*/
|
|
104
|
-
this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
|
|
105
103
|
}
|
|
106
104
|
validateValue(newValue) {
|
|
107
105
|
if (newValue && newValue.every(item => isCheckboxItem(item))) {
|
|
@@ -117,6 +115,16 @@ export class MgInputCheckbox {
|
|
|
117
115
|
throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
|
|
118
116
|
}
|
|
119
117
|
}
|
|
118
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
119
|
+
this.inputs.forEach(input => {
|
|
120
|
+
input[prop] = newValue;
|
|
121
|
+
});
|
|
122
|
+
this.checkValidity();
|
|
123
|
+
if (this.hasDisplayedError) {
|
|
124
|
+
this.setErrorMessage();
|
|
125
|
+
this.hasDisplayedError = false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
120
128
|
/**
|
|
121
129
|
* Public method to display errors
|
|
122
130
|
*
|
|
@@ -124,7 +132,8 @@ export class MgInputCheckbox {
|
|
|
124
132
|
*/
|
|
125
133
|
async displayError() {
|
|
126
134
|
this.checkValidity();
|
|
127
|
-
this.
|
|
135
|
+
this.setErrorMessage();
|
|
136
|
+
this.hasDisplayedError = this.invalid;
|
|
128
137
|
}
|
|
129
138
|
/*************
|
|
130
139
|
* Lifecycle *
|
|
@@ -152,11 +161,14 @@ export class MgInputCheckbox {
|
|
|
152
161
|
* @returns {HTMLElement} HTML Element
|
|
153
162
|
*/
|
|
154
163
|
render() {
|
|
155
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly
|
|
164
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
|
|
156
165
|
.filter(item => {
|
|
157
166
|
return !this.readonly || item.value;
|
|
158
167
|
})
|
|
159
|
-
.map(input => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, 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 =>
|
|
168
|
+
.map((input, index) => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, 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 => {
|
|
169
|
+
if (el !== null)
|
|
170
|
+
this.inputs[index] = el;
|
|
171
|
+
} }), h("label", { htmlFor: input.id }, input.title)))))));
|
|
160
172
|
}
|
|
161
173
|
static get is() { return "mg-input-checkbox"; }
|
|
162
174
|
static get encapsulation() { return "shadow"; }
|
|
@@ -494,6 +506,15 @@ export class MgInputCheckbox {
|
|
|
494
506
|
return [{
|
|
495
507
|
"propName": "value",
|
|
496
508
|
"methodName": "validateValue"
|
|
509
|
+
}, {
|
|
510
|
+
"propName": "required",
|
|
511
|
+
"methodName": "handleValidityChange"
|
|
512
|
+
}, {
|
|
513
|
+
"propName": "readonly",
|
|
514
|
+
"methodName": "handleValidityChange"
|
|
515
|
+
}, {
|
|
516
|
+
"propName": "disabled",
|
|
517
|
+
"methodName": "handleValidityChange"
|
|
497
518
|
}];
|
|
498
519
|
}
|
|
499
520
|
}
|