@mgdis/mg-components 3.1.0 → 4.0.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/{index-85a4a0b6.js → index-88560a66.js} +123 -48
- package/dist/cjs/index-a39c5567.js +233 -0
- package/dist/cjs/loader.cjs.js +3 -17
- package/dist/cjs/mg-badge_21.cjs.entry.js +3538 -0
- package/dist/cjs/mg-components.cjs.js +3 -7
- package/dist/cjs/mg-modal.cjs.entry.js +117 -0
- package/dist/cjs/mg-popover.cjs.entry.js +170 -0
- package/dist/cjs/popper-71bf3058.js +1790 -0
- package/dist/collection/collection-manifest.json +4 -1
- package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +4 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +26 -10
- package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +7 -2
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.css +46 -49
- package/dist/collection/components/atoms/mg-button/mg-button.js +78 -4
- package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +8 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +20 -46
- package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +104 -9
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +9 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +33 -7
- package/dist/collection/components/atoms/mg-input-title/{mg-input-title.stories.js → doc/mg-input-title.stories.js} +0 -0
- package/dist/collection/components/atoms/mg-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.stories.js → doc/mg-tag.stories.js} +4 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +28 -6
- package/dist/collection/components/atoms/mg-tooltip/{mg-tooltip.stories.js → doc/mg-tooltip.stories.js} +14 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +20 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +16 -2
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
- package/dist/collection/components/molecules/inputs/MgInput.js +25 -29
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +25 -11
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +102 -52
- package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +37 -9
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +136 -66
- package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +15 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +38 -10
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +180 -80
- package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +16 -2
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +37 -9
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +108 -47
- package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +25 -11
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +113 -42
- package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +22 -2
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +39 -10
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +145 -71
- package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +17 -8
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +69 -19
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +184 -83
- package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +16 -5
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +69 -13
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +163 -70
- package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +22 -10
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +68 -33
- package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +58 -0
- package/dist/collection/components/molecules/mg-form/mg-form.css +19 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +271 -0
- package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +6 -2
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +26 -11
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +51 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +52 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +240 -0
- package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +47 -28
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +39 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +53 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +356 -0
- package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +10 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +37 -12
- package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +20 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +11 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +17 -3
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +139 -26
- package/dist/collection/locales/index.js +33 -4
- package/dist/collection/stories/helpers.stories.js +33 -0
- package/dist/collection/utils/components.utils.js +16 -9
- package/dist/collection/utils/locale.utils.js +13 -7
- package/dist/collection/utils/test.utils.js +27 -15
- package/dist/collection/variables.css +39 -5
- package/dist/collection/variables.scss +39 -5
- package/dist/components/MgInput.js +26 -37
- package/dist/components/components.utils.js +16 -9
- package/dist/components/index.d.ts +24 -6
- package/dist/components/index.js +23 -0
- package/dist/components/index2.js +116 -17
- package/dist/components/locale.utils.js +13 -8
- package/dist/components/mg-badge2.js +25 -9
- package/dist/components/mg-button2.js +29 -5
- package/dist/components/mg-character-left2.js +14 -26
- package/dist/components/mg-form.d.ts +11 -0
- package/dist/components/mg-form.js +148 -0
- package/dist/components/mg-icon2.js +138 -17
- package/dist/components/mg-input-checkbox.js +66 -53
- package/dist/components/mg-input-date.js +100 -69
- package/dist/components/mg-input-numeric.js +125 -81
- package/dist/components/mg-input-password.js +69 -48
- package/dist/components/mg-input-radio.js +74 -46
- package/dist/components/mg-input-select2.js +103 -71
- package/dist/components/mg-input-text.js +1 -237
- package/dist/components/mg-input-text2.js +300 -0
- package/dist/components/mg-input-textarea.js +100 -46
- package/dist/components/mg-input-title2.js +13 -4
- package/dist/components/mg-input-toggle.js +39 -31
- package/dist/components/mg-message.js +25 -10
- package/dist/components/mg-modal.d.ts +11 -0
- package/dist/components/mg-modal.js +153 -0
- package/dist/components/mg-pagination.js +45 -31
- package/dist/components/mg-panel.d.ts +11 -0
- package/dist/components/mg-panel.js +244 -0
- package/dist/components/mg-popover.js +31 -11
- package/dist/components/mg-tabs.js +113 -23
- package/dist/components/mg-tag.js +27 -5
- package/dist/components/mg-tooltip2.js +10 -1
- package/dist/components/popper.js +6 -2
- package/dist/esm/{index-e3e84606.js → index-bca81100.js} +124 -46
- package/dist/esm/index-e51ae032.js +228 -0
- package/dist/esm/loader.js +3 -17
- package/dist/esm/mg-badge_21.entry.js +3514 -0
- package/dist/esm/mg-components.js +3 -7
- package/dist/esm/mg-modal.entry.js +113 -0
- package/dist/esm/mg-popover.entry.js +166 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/popper-93ecb064.js +1788 -0
- package/dist/index.js +1 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-003a1344.entry.js +1 -0
- package/dist/mg-components/p-462d648a.entry.js +1 -0
- package/dist/mg-components/p-4c66f794.js +1 -0
- package/dist/mg-components/p-5126ab10.entry.js +1 -0
- package/dist/mg-components/p-780bd52d.js +1 -0
- package/dist/mg-components/p-b14a3443.js +2 -0
- package/dist/mg-components/variables.css +39 -5
- package/dist/mg-components/variables.scss +39 -5
- package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +16 -5
- package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +23 -3
- package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +9 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +16 -13
- package/dist/types/components/atoms/mg-icon/{mg-icon.stories.d.ts → doc/mg-icon.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +14 -4
- package/dist/types/components/atoms/mg-input-title/{mg-input-title.stories.d.ts → doc/mg-input-title.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
- package/dist/types/components/atoms/mg-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +18 -4
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +29 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +13 -3
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +6 -4
- package/dist/types/components/molecules/inputs/MgInput.d.ts +7 -8
- package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +36 -13
- package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +46 -15
- package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +11 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +61 -16
- package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +22 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +35 -11
- package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.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 +42 -9
- package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +34 -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 +37 -9
- package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +13 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +52 -16
- package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +45 -17
- package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.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 +29 -12
- package/dist/types/components/molecules/{mg-popover/mg-popover.stories.d.ts → mg-form/doc/mg-form.stories.d.ts} +3 -4
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +83 -0
- package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +10 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +13 -4
- package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +13 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +85 -0
- package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +5 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +31 -7
- package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +139 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +25 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +8 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +27 -4
- package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +20 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +11 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +70 -6
- package/dist/types/components.d.ts +528 -211
- package/dist/types/locales/index.d.ts +108 -38
- package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
- package/dist/types/utils/components.utils.d.ts +16 -9
- package/dist/types/utils/locale.utils.d.ts +13 -6
- package/dist/types/utils/test.utils.d.ts +13 -1
- package/loader/index.js +1 -1
- package/package.json +45 -14
- package/readme.md +9 -35
- package/dist/cjs/css-shim-a22512c4.js +0 -6
- package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
- package/dist/cjs/shadow-css-8940f82d.js +0 -390
- package/dist/collection/stories/buttons.stories.js +0 -43
- package/dist/collection/stories/messages.stories.js +0 -44
- package/dist/collection/stories/tags.stories.js +0 -13
- package/dist/esm/css-shim-7c240feb.js +0 -4
- package/dist/esm/mg-badge_20.entry.js +0 -4638
- package/dist/esm/shadow-css-5d2d01ce.js +0 -388
- package/dist/esm-es5/css-shim-7c240feb.js +0 -1
- package/dist/esm-es5/index-e3e84606.js +0 -1
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +0 -1
- package/dist/esm-es5/mg-badge_20.entry.js +0 -2
- package/dist/esm-es5/mg-components.js +0 -1
- package/dist/esm-es5/shadow-css-5d2d01ce.js +0 -12
- package/dist/mg-components/mg-components.js +0 -132
- 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-366a224e.js +0 -1
- package/dist/mg-components/p-422c429b.system.js +0 -1
- package/dist/mg-components/p-50ea2036.system.js +0 -1
- package/dist/mg-components/p-62fa3797.js +0 -1
- package/dist/mg-components/p-71d57b8b.system.js +0 -13
- package/dist/mg-components/p-9a215712.system.js +0 -1
- package/dist/mg-components/p-cbf0464b.entry.js +0 -1
- package/dist/mg-components/p-f6455ab3.js +0 -12
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +0 -9
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +0 -14
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +0 -7
- package/dist/types/stories/messages.stories.d.ts +0 -13
- package/dist/types/stories/tags.stories.d.ts +0 -5
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
3
|
import { Component, Event, h, Prop, State, Watch, Element } from '@stencil/core';
|
|
2
4
|
import { MgInput } from '../MgInput';
|
|
3
5
|
import { createID, ClassList, allItemsAreString } from '../../../../utils/components.utils';
|
|
4
6
|
/**
|
|
5
7
|
* type Option validation function
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
+
*
|
|
9
|
+
* @param {ToggleValue} option radio option
|
|
10
|
+
* @returns {boolean} toggle option type is valid
|
|
8
11
|
*/
|
|
9
12
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
10
13
|
export class MgInputToggle {
|
|
@@ -16,6 +19,8 @@ export class MgInputToggle {
|
|
|
16
19
|
this.classReadonly = 'mg-input--toggle-readonly';
|
|
17
20
|
this.classDisabled = 'mg-input--toggle-disabled';
|
|
18
21
|
this.classIsActive = 'mg-input--toggle-is-active';
|
|
22
|
+
this.classOnOff = 'mg-input--toggle-on-off';
|
|
23
|
+
this.classIcon = 'mg-input--toggle-icon';
|
|
19
24
|
/**
|
|
20
25
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
21
26
|
* If not set, it will be created.
|
|
@@ -56,12 +61,16 @@ export class MgInputToggle {
|
|
|
56
61
|
this.checked = false;
|
|
57
62
|
/**
|
|
58
63
|
* Change checked value
|
|
64
|
+
*
|
|
65
|
+
* @returns {void}
|
|
59
66
|
*/
|
|
60
67
|
this.toggleChecked = () => {
|
|
61
|
-
this.
|
|
68
|
+
this.checked = !this.checked;
|
|
62
69
|
};
|
|
63
70
|
/**
|
|
64
71
|
* Slots validation
|
|
72
|
+
*
|
|
73
|
+
* @returns {void}
|
|
65
74
|
*/
|
|
66
75
|
this.validateSlots = () => {
|
|
67
76
|
const slots = Array.from(this.element.children);
|
|
@@ -75,6 +84,12 @@ export class MgInputToggle {
|
|
|
75
84
|
}
|
|
76
85
|
};
|
|
77
86
|
}
|
|
87
|
+
handleValue(newValue) {
|
|
88
|
+
// Swich to the right option
|
|
89
|
+
this.setChecked();
|
|
90
|
+
// Emit value-change event
|
|
91
|
+
this.valueChange.emit(newValue);
|
|
92
|
+
}
|
|
78
93
|
validateItems(newValue) {
|
|
79
94
|
if (typeof newValue === 'object' && this.items.length !== 2) {
|
|
80
95
|
throw new Error('<mg-input-toggle> prop "items" require 2 items.');
|
|
@@ -93,11 +108,15 @@ export class MgInputToggle {
|
|
|
93
108
|
}
|
|
94
109
|
handleIsOnOff(newValue) {
|
|
95
110
|
if (newValue)
|
|
96
|
-
this.classList.add(
|
|
111
|
+
this.classList.add(this.classOnOff);
|
|
112
|
+
else
|
|
113
|
+
this.classList.delete(this.classOnOff);
|
|
97
114
|
}
|
|
98
115
|
handleIsIcon(newValue) {
|
|
99
116
|
if (newValue)
|
|
100
|
-
this.classList.add(
|
|
117
|
+
this.classList.add(this.classIcon);
|
|
118
|
+
else
|
|
119
|
+
this.classList.delete(this.classIcon);
|
|
101
120
|
}
|
|
102
121
|
handleReadonly(newValue) {
|
|
103
122
|
if (newValue)
|
|
@@ -118,14 +137,14 @@ export class MgInputToggle {
|
|
|
118
137
|
else
|
|
119
138
|
this.classList.delete(this.classIsActive);
|
|
120
139
|
// update value
|
|
121
|
-
this.value = this.options[
|
|
122
|
-
this.valueChange.emit(this.value);
|
|
140
|
+
this.value = this.options[newValue ? 1 : 0].value;
|
|
123
141
|
}
|
|
124
142
|
/**
|
|
125
143
|
* set checked state
|
|
126
|
-
*
|
|
144
|
+
*
|
|
145
|
+
* @returns {void}
|
|
127
146
|
*/
|
|
128
|
-
setChecked(
|
|
147
|
+
setChecked() {
|
|
129
148
|
// has "value" props type is not a boolean, it is bind/render as an attributes/props
|
|
130
149
|
// true props will be represent by "true" string so we convert it has boolean
|
|
131
150
|
// true attribute will be represent by "" string so we convert it has boolean
|
|
@@ -133,15 +152,7 @@ export class MgInputToggle {
|
|
|
133
152
|
if (['', 'true'].includes(this.value) && this.options.find(option => option.value) !== undefined) {
|
|
134
153
|
this.value = true;
|
|
135
154
|
}
|
|
136
|
-
|
|
137
|
-
this.checked = newValue;
|
|
138
|
-
}
|
|
139
|
-
else if (this.value === this.options[1].value) {
|
|
140
|
-
this.checked = true;
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
this.checked = false;
|
|
144
|
-
}
|
|
155
|
+
this.checked = this.value === this.options[1].value;
|
|
145
156
|
}
|
|
146
157
|
/*************
|
|
147
158
|
* Lifecycle *
|
|
@@ -152,6 +163,8 @@ export class MgInputToggle {
|
|
|
152
163
|
componentWillLoad() {
|
|
153
164
|
// Check items format
|
|
154
165
|
this.validateItems(this.items);
|
|
166
|
+
// Check slots
|
|
167
|
+
this.validateSlots();
|
|
155
168
|
// init checked value
|
|
156
169
|
this.setChecked();
|
|
157
170
|
// apply handler
|
|
@@ -159,14 +172,15 @@ export class MgInputToggle {
|
|
|
159
172
|
this.handleIsIcon(this.isIcon);
|
|
160
173
|
this.handleReadonly(this.readonly);
|
|
161
174
|
this.handleDisabled(this.disabled);
|
|
162
|
-
this.validateSlots();
|
|
163
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Render
|
|
178
|
+
*
|
|
179
|
+
* @returns {HTMLElement} HTML Element
|
|
180
|
+
*/
|
|
164
181
|
render() {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
h("button", { type: "button", role: "switch", "aria-checked": this.checked, "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly,
|
|
168
|
-
// eslint-disable-next-line react/jsx-no-bind
|
|
169
|
-
onClick: () => this.toggleChecked() },
|
|
182
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false },
|
|
183
|
+
h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked },
|
|
170
184
|
h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" },
|
|
171
185
|
h("slot", { name: "item-1" })),
|
|
172
186
|
h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" },
|
|
@@ -190,7 +204,7 @@ export class MgInputToggle {
|
|
|
190
204
|
"references": {}
|
|
191
205
|
},
|
|
192
206
|
"required": false,
|
|
193
|
-
"optional":
|
|
207
|
+
"optional": false,
|
|
194
208
|
"docs": {
|
|
195
209
|
"tags": [],
|
|
196
210
|
"text": "Component value"
|
|
@@ -214,8 +228,11 @@ export class MgInputToggle {
|
|
|
214
228
|
"required": true,
|
|
215
229
|
"optional": false,
|
|
216
230
|
"docs": {
|
|
217
|
-
"tags": [
|
|
218
|
-
|
|
231
|
+
"tags": [{
|
|
232
|
+
"name": "returns",
|
|
233
|
+
"text": undefined
|
|
234
|
+
}],
|
|
235
|
+
"text": "Items are the possible options to select"
|
|
219
236
|
}
|
|
220
237
|
},
|
|
221
238
|
"identifier": {
|
|
@@ -227,7 +244,7 @@ export class MgInputToggle {
|
|
|
227
244
|
"references": {}
|
|
228
245
|
},
|
|
229
246
|
"required": false,
|
|
230
|
-
"optional":
|
|
247
|
+
"optional": false,
|
|
231
248
|
"docs": {
|
|
232
249
|
"tags": [],
|
|
233
250
|
"text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
|
|
@@ -245,7 +262,7 @@ export class MgInputToggle {
|
|
|
245
262
|
"references": {}
|
|
246
263
|
},
|
|
247
264
|
"required": false,
|
|
248
|
-
"optional":
|
|
265
|
+
"optional": false,
|
|
249
266
|
"docs": {
|
|
250
267
|
"tags": [],
|
|
251
268
|
"text": "Input name\nIf not set the value equals the identifier"
|
|
@@ -266,7 +283,7 @@ export class MgInputToggle {
|
|
|
266
283
|
"optional": false,
|
|
267
284
|
"docs": {
|
|
268
285
|
"tags": [],
|
|
269
|
-
"text": "Input label
|
|
286
|
+
"text": "Input label"
|
|
270
287
|
},
|
|
271
288
|
"attribute": "label",
|
|
272
289
|
"reflect": false
|
|
@@ -315,7 +332,7 @@ export class MgInputToggle {
|
|
|
315
332
|
"references": {}
|
|
316
333
|
},
|
|
317
334
|
"required": false,
|
|
318
|
-
"optional":
|
|
335
|
+
"optional": false,
|
|
319
336
|
"docs": {
|
|
320
337
|
"tags": [],
|
|
321
338
|
"text": "Define if toggle have on/off style"
|
|
@@ -333,7 +350,7 @@ export class MgInputToggle {
|
|
|
333
350
|
"references": {}
|
|
334
351
|
},
|
|
335
352
|
"required": false,
|
|
336
|
-
"optional":
|
|
353
|
+
"optional": false,
|
|
337
354
|
"docs": {
|
|
338
355
|
"tags": [],
|
|
339
356
|
"text": "Define if toggle display icon"
|
|
@@ -426,16 +443,34 @@ export class MgInputToggle {
|
|
|
426
443
|
"composed": true,
|
|
427
444
|
"docs": {
|
|
428
445
|
"tags": [],
|
|
429
|
-
"text": "
|
|
446
|
+
"text": "Emited event when value change"
|
|
430
447
|
},
|
|
431
448
|
"complexType": {
|
|
432
449
|
"original": "any",
|
|
433
450
|
"resolved": "any",
|
|
434
451
|
"references": {}
|
|
435
452
|
}
|
|
453
|
+
}, {
|
|
454
|
+
"method": "inputValid",
|
|
455
|
+
"name": "input-valid",
|
|
456
|
+
"bubbles": true,
|
|
457
|
+
"cancelable": true,
|
|
458
|
+
"composed": true,
|
|
459
|
+
"docs": {
|
|
460
|
+
"tags": [],
|
|
461
|
+
"text": "Emited event when checking validity"
|
|
462
|
+
},
|
|
463
|
+
"complexType": {
|
|
464
|
+
"original": "boolean",
|
|
465
|
+
"resolved": "boolean",
|
|
466
|
+
"references": {}
|
|
467
|
+
}
|
|
436
468
|
}]; }
|
|
437
469
|
static get elementRef() { return "element"; }
|
|
438
470
|
static get watchers() { return [{
|
|
471
|
+
"propName": "value",
|
|
472
|
+
"methodName": "handleValue"
|
|
473
|
+
}, {
|
|
439
474
|
"propName": "items",
|
|
440
475
|
"methodName": "validateItems"
|
|
441
476
|
}, {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export default {
|
|
3
|
+
component: 'mg-form',
|
|
4
|
+
title: 'Molecules/mg-form',
|
|
5
|
+
parameters: { actions: { handles: ['form-valid'] } },
|
|
6
|
+
};
|
|
7
|
+
const args = {
|
|
8
|
+
identifier: 'identifier',
|
|
9
|
+
name: 'input-name',
|
|
10
|
+
readonly: false,
|
|
11
|
+
disabled: false,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
15
|
+
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
16
|
+
*
|
|
17
|
+
* @param {any} args component arguments
|
|
18
|
+
* @returns {HTMLElement} HTMLElement
|
|
19
|
+
*/
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
const Template = (args) => {
|
|
22
|
+
let form;
|
|
23
|
+
let submit;
|
|
24
|
+
return (h("mg-form", Object.assign({}, args, { ref: el => {
|
|
25
|
+
form = el;
|
|
26
|
+
form.addEventListener('form-valid', e => {
|
|
27
|
+
submit.disabled = !e.detail;
|
|
28
|
+
});
|
|
29
|
+
} }),
|
|
30
|
+
h("mg-input-checkbox", { identifier: "mg-input-checkbox", label: "mg-input-checkbox label", value: [
|
|
31
|
+
{ title: 'oui', value: false },
|
|
32
|
+
{ title: 'non', value: false },
|
|
33
|
+
] }),
|
|
34
|
+
h("mg-input-date", { required: true, identifier: "mg-input-date", label: "mg-input-date label" }),
|
|
35
|
+
h("mg-input-numeric", { identifier: "mg-input-numeric", label: "mg-input-numeric label" }),
|
|
36
|
+
h("mg-input-password", { identifier: "mg-input-password", label: "mg-input-password label" }),
|
|
37
|
+
h("mg-input-radio", { identifier: "mg-input-radio", label: "mg-input-radio label", items: ['blu', 'bli', 'bla', 'blo'] }),
|
|
38
|
+
h("mg-input-select", { identifier: "mg-input-select", label: "mg-input-select label", items: ['blu', 'bli', 'bla', 'blo'] }),
|
|
39
|
+
h("mg-input-text", { identifier: "mg-input-text", label: "mg-input-text label" }),
|
|
40
|
+
h("mg-input-textarea", { identifier: "mg-input-textarea", label: "mg-input-textarea label" }),
|
|
41
|
+
h("mg-input-toggle", { identifier: "mg-input-toggle", label: "mg-input-toggle label", items: [
|
|
42
|
+
{ title: 'non', value: false },
|
|
43
|
+
{ title: 'oui', value: true },
|
|
44
|
+
] },
|
|
45
|
+
h("span", { slot: "item-1" }, "non"),
|
|
46
|
+
h("span", { slot: "item-2" }, "oui")),
|
|
47
|
+
h("div", { slot: "actions", class: "mg-group-elements mg-group-elements--align-right" },
|
|
48
|
+
h("mg-button", { id: "can-submit", disabled: true, ref: e => {
|
|
49
|
+
submit = e;
|
|
50
|
+
} }, "Submit"),
|
|
51
|
+
h("mg-button", { variant: "secondary",
|
|
52
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
53
|
+
onClick: () => {
|
|
54
|
+
form.displayError();
|
|
55
|
+
} }, "Display errors"))));
|
|
56
|
+
};
|
|
57
|
+
export const MgForm = Template.bind({});
|
|
58
|
+
MgForm.args = Object.assign({}, args);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.is-asterisk {
|
|
2
|
+
color: hsl(var(--color-danger));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.mg-form,
|
|
6
|
+
.mg-form-group {
|
|
7
|
+
--mg-inputs-margin-bottom: 1.5rem;
|
|
8
|
+
--mg-inputs-title-horizontal-space: 3rem;
|
|
9
|
+
--mg-inputs-title-width: 15rem;
|
|
10
|
+
--mg-inputs-shrink: 0;
|
|
11
|
+
}
|
|
12
|
+
.mg-form.mg-form--all-required,
|
|
13
|
+
.mg-form-group.mg-form--all-required {
|
|
14
|
+
--mg-input-title-display: none;
|
|
15
|
+
}
|
|
16
|
+
.mg-form > p,
|
|
17
|
+
.mg-form-group > p {
|
|
18
|
+
font-size: 1.2rem;
|
|
19
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { Component, Element, Event, h, Method, Prop, State } from '@stencil/core';
|
|
2
|
+
import { createID, ClassList } from '../../../utils/components.utils';
|
|
3
|
+
import { initLocales } from '../../../locales';
|
|
4
|
+
export class MgForm {
|
|
5
|
+
constructor() {
|
|
6
|
+
/**
|
|
7
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
8
|
+
* If not set, it will be created.
|
|
9
|
+
*/
|
|
10
|
+
this.identifier = createID('mg-form');
|
|
11
|
+
/**
|
|
12
|
+
* Input name
|
|
13
|
+
* If not set the value equals the identifier
|
|
14
|
+
*/
|
|
15
|
+
this.name = this.identifier;
|
|
16
|
+
/**
|
|
17
|
+
* Define if form is readonly
|
|
18
|
+
*/
|
|
19
|
+
this.readonly = false;
|
|
20
|
+
/**
|
|
21
|
+
* Define if form is disabled
|
|
22
|
+
*/
|
|
23
|
+
this.disabled = false;
|
|
24
|
+
/**
|
|
25
|
+
* Component classes
|
|
26
|
+
*/
|
|
27
|
+
this.classList = new ClassList(['mg-form']);
|
|
28
|
+
/**
|
|
29
|
+
* Define required message based on mg-inputs required elements
|
|
30
|
+
* Also
|
|
31
|
+
*
|
|
32
|
+
* @returns {void}
|
|
33
|
+
*/
|
|
34
|
+
this.setRequiredMessage = () => {
|
|
35
|
+
// Get required fields
|
|
36
|
+
const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !this.disabled);
|
|
37
|
+
// All fields are required
|
|
38
|
+
// mg-input-toggle can not be required
|
|
39
|
+
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
40
|
+
this.requiredMessage = this.messages.form.allRequired;
|
|
41
|
+
this.classList.add('mg-form--all-required');
|
|
42
|
+
}
|
|
43
|
+
// Some fields are required
|
|
44
|
+
else if (requiredInputs.length > 0) {
|
|
45
|
+
this.requiredMessage = this.messages.form.required;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Check if form is valid
|
|
50
|
+
*
|
|
51
|
+
* @returns {void}
|
|
52
|
+
*/
|
|
53
|
+
this.checkValidity = () => {
|
|
54
|
+
const validity = !this.mgInputs.some(input => input.invalid);
|
|
55
|
+
this.valid = validity;
|
|
56
|
+
this.invalid = !validity;
|
|
57
|
+
this.formValid.emit(validity);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Public method to display errors
|
|
62
|
+
*
|
|
63
|
+
* @returns {Promise<void>}
|
|
64
|
+
*/
|
|
65
|
+
async displayError() {
|
|
66
|
+
if (!this.readonly) {
|
|
67
|
+
this.mgInputs.forEach(input => {
|
|
68
|
+
input.displayError && input.displayError();
|
|
69
|
+
});
|
|
70
|
+
this.checkValidity();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/*************
|
|
74
|
+
* Lifecycle *
|
|
75
|
+
*************/
|
|
76
|
+
/**
|
|
77
|
+
* Check if component props are well configured on init
|
|
78
|
+
*
|
|
79
|
+
* @returns {void}
|
|
80
|
+
*/
|
|
81
|
+
componentWillLoad() {
|
|
82
|
+
// Get locales
|
|
83
|
+
this.messages = initLocales(this.element).messages;
|
|
84
|
+
// Get slotted mgIputs
|
|
85
|
+
this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
|
|
86
|
+
// Define required message
|
|
87
|
+
this.setRequiredMessage();
|
|
88
|
+
// Check validity when slotted mgImputs are ready
|
|
89
|
+
Promise.all(this.mgInputs.map(async (input) => {
|
|
90
|
+
// Set inputs readonly or disabled based on form configuration
|
|
91
|
+
// Othewise listen to events
|
|
92
|
+
if (this.readonly)
|
|
93
|
+
input.readonly = true;
|
|
94
|
+
else if (this.disabled)
|
|
95
|
+
input.disabled = true;
|
|
96
|
+
else
|
|
97
|
+
input.addEventListener('input-valid', this.checkValidity);
|
|
98
|
+
await input.componentOnReady();
|
|
99
|
+
})).then(() => {
|
|
100
|
+
this.checkValidity();
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Render
|
|
105
|
+
*
|
|
106
|
+
* @returns {HTMLElement} HTML Element
|
|
107
|
+
*/
|
|
108
|
+
render() {
|
|
109
|
+
return (h("form", { class: this.classList.join(), id: this.identifier, name: this.name },
|
|
110
|
+
this.requiredMessage && h("p", { innerHTML: this.requiredMessage }),
|
|
111
|
+
h("slot", null),
|
|
112
|
+
!this.readonly && !this.disabled && h("slot", { name: "actions" })));
|
|
113
|
+
}
|
|
114
|
+
static get is() { return "mg-form"; }
|
|
115
|
+
static get encapsulation() { return "shadow"; }
|
|
116
|
+
static get originalStyleUrls() { return {
|
|
117
|
+
"$": ["mg-form.scss"]
|
|
118
|
+
}; }
|
|
119
|
+
static get styleUrls() { return {
|
|
120
|
+
"$": ["mg-form.css"]
|
|
121
|
+
}; }
|
|
122
|
+
static get properties() { return {
|
|
123
|
+
"identifier": {
|
|
124
|
+
"type": "string",
|
|
125
|
+
"mutable": false,
|
|
126
|
+
"complexType": {
|
|
127
|
+
"original": "string",
|
|
128
|
+
"resolved": "string",
|
|
129
|
+
"references": {}
|
|
130
|
+
},
|
|
131
|
+
"required": false,
|
|
132
|
+
"optional": false,
|
|
133
|
+
"docs": {
|
|
134
|
+
"tags": [],
|
|
135
|
+
"text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
|
|
136
|
+
},
|
|
137
|
+
"attribute": "identifier",
|
|
138
|
+
"reflect": false,
|
|
139
|
+
"defaultValue": "createID('mg-form')"
|
|
140
|
+
},
|
|
141
|
+
"name": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"mutable": false,
|
|
144
|
+
"complexType": {
|
|
145
|
+
"original": "string",
|
|
146
|
+
"resolved": "string",
|
|
147
|
+
"references": {}
|
|
148
|
+
},
|
|
149
|
+
"required": false,
|
|
150
|
+
"optional": false,
|
|
151
|
+
"docs": {
|
|
152
|
+
"tags": [],
|
|
153
|
+
"text": "Input name\nIf not set the value equals the identifier"
|
|
154
|
+
},
|
|
155
|
+
"attribute": "name",
|
|
156
|
+
"reflect": false,
|
|
157
|
+
"defaultValue": "this.identifier"
|
|
158
|
+
},
|
|
159
|
+
"readonly": {
|
|
160
|
+
"type": "boolean",
|
|
161
|
+
"mutable": false,
|
|
162
|
+
"complexType": {
|
|
163
|
+
"original": "boolean",
|
|
164
|
+
"resolved": "boolean",
|
|
165
|
+
"references": {}
|
|
166
|
+
},
|
|
167
|
+
"required": false,
|
|
168
|
+
"optional": false,
|
|
169
|
+
"docs": {
|
|
170
|
+
"tags": [],
|
|
171
|
+
"text": "Define if form is readonly"
|
|
172
|
+
},
|
|
173
|
+
"attribute": "readonly",
|
|
174
|
+
"reflect": false,
|
|
175
|
+
"defaultValue": "false"
|
|
176
|
+
},
|
|
177
|
+
"disabled": {
|
|
178
|
+
"type": "boolean",
|
|
179
|
+
"mutable": false,
|
|
180
|
+
"complexType": {
|
|
181
|
+
"original": "boolean",
|
|
182
|
+
"resolved": "boolean",
|
|
183
|
+
"references": {}
|
|
184
|
+
},
|
|
185
|
+
"required": false,
|
|
186
|
+
"optional": false,
|
|
187
|
+
"docs": {
|
|
188
|
+
"tags": [],
|
|
189
|
+
"text": "Define if form is disabled"
|
|
190
|
+
},
|
|
191
|
+
"attribute": "disabled",
|
|
192
|
+
"reflect": false,
|
|
193
|
+
"defaultValue": "false"
|
|
194
|
+
},
|
|
195
|
+
"valid": {
|
|
196
|
+
"type": "boolean",
|
|
197
|
+
"mutable": true,
|
|
198
|
+
"complexType": {
|
|
199
|
+
"original": "boolean",
|
|
200
|
+
"resolved": "boolean",
|
|
201
|
+
"references": {}
|
|
202
|
+
},
|
|
203
|
+
"required": false,
|
|
204
|
+
"optional": false,
|
|
205
|
+
"docs": {
|
|
206
|
+
"tags": [],
|
|
207
|
+
"text": "Define form valid state"
|
|
208
|
+
},
|
|
209
|
+
"attribute": "valid",
|
|
210
|
+
"reflect": false
|
|
211
|
+
},
|
|
212
|
+
"invalid": {
|
|
213
|
+
"type": "boolean",
|
|
214
|
+
"mutable": true,
|
|
215
|
+
"complexType": {
|
|
216
|
+
"original": "boolean",
|
|
217
|
+
"resolved": "boolean",
|
|
218
|
+
"references": {}
|
|
219
|
+
},
|
|
220
|
+
"required": false,
|
|
221
|
+
"optional": false,
|
|
222
|
+
"docs": {
|
|
223
|
+
"tags": [],
|
|
224
|
+
"text": "Define form invalid state"
|
|
225
|
+
},
|
|
226
|
+
"attribute": "invalid",
|
|
227
|
+
"reflect": false
|
|
228
|
+
}
|
|
229
|
+
}; }
|
|
230
|
+
static get states() { return {
|
|
231
|
+
"classList": {}
|
|
232
|
+
}; }
|
|
233
|
+
static get events() { return [{
|
|
234
|
+
"method": "formValid",
|
|
235
|
+
"name": "form-valid",
|
|
236
|
+
"bubbles": true,
|
|
237
|
+
"cancelable": true,
|
|
238
|
+
"composed": true,
|
|
239
|
+
"docs": {
|
|
240
|
+
"tags": [],
|
|
241
|
+
"text": "Emitted event on form validity check\nTells if form is valid or not"
|
|
242
|
+
},
|
|
243
|
+
"complexType": {
|
|
244
|
+
"original": "boolean",
|
|
245
|
+
"resolved": "boolean",
|
|
246
|
+
"references": {}
|
|
247
|
+
}
|
|
248
|
+
}]; }
|
|
249
|
+
static get methods() { return {
|
|
250
|
+
"displayError": {
|
|
251
|
+
"complexType": {
|
|
252
|
+
"signature": "() => Promise<void>",
|
|
253
|
+
"parameters": [],
|
|
254
|
+
"references": {
|
|
255
|
+
"Promise": {
|
|
256
|
+
"location": "global"
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
"return": "Promise<void>"
|
|
260
|
+
},
|
|
261
|
+
"docs": {
|
|
262
|
+
"text": "Public method to display errors",
|
|
263
|
+
"tags": [{
|
|
264
|
+
"name": "returns",
|
|
265
|
+
"text": undefined
|
|
266
|
+
}]
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}; }
|
|
270
|
+
static get elementRef() { return "element"; }
|
|
271
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
-
import { variants } from '
|
|
2
|
+
import { variants } from '../mg-message.conf';
|
|
3
3
|
export default {
|
|
4
4
|
component: 'mg-message',
|
|
5
5
|
title: 'Molecules/mg-message',
|
|
@@ -7,8 +7,12 @@ export default {
|
|
|
7
7
|
variant: {
|
|
8
8
|
options: variants,
|
|
9
9
|
control: { type: 'select' },
|
|
10
|
+
table: {
|
|
11
|
+
defaultValue: { summary: variants[0] },
|
|
12
|
+
},
|
|
10
13
|
},
|
|
11
14
|
},
|
|
15
|
+
parameters: { actions: { handles: ['component-show', 'component-hide'] } },
|
|
12
16
|
};
|
|
13
17
|
/**
|
|
14
18
|
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
@@ -40,4 +44,4 @@ MgMessage.args = {
|
|
|
40
44
|
export const WithCloseButton = Template.bind({});
|
|
41
45
|
WithCloseButton.args = Object.assign(Object.assign({}, MgMessage.args), { variant: 'danger', closeButton: true });
|
|
42
46
|
export const WithActions = Template.bind({});
|
|
43
|
-
WithActions.args = Object.assign(Object.assign({}, MgMessage.args), { variant: 'warning', slotActions: `<div
|
|
47
|
+
WithActions.args = Object.assign(Object.assign({}, MgMessage.args), { variant: 'warning', slotActions: `<div class="mg-group-elements mg-group-elements--align-right"><mg-button>Primary</mg-button><mg-button variant="secondary">Secondary</mg-button></div>` });
|