@mgdis/mg-components 3.3.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.storybook/utils.js +24 -0
- package/dist/cjs/{index-369388eb.js → index-179621c8.js} +108 -10
- package/dist/cjs/{index-bead7dbd.js → index-88560a66.js} +47 -48
- package/dist/cjs/loader.cjs.js +3 -17
- package/dist/cjs/mg-badge_24.cjs.entry.js +5687 -0
- package/dist/cjs/mg-components.cjs.js +3 -7
- package/dist/cjs/mg-modal.cjs.entry.js +12 -6
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +10 -6
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +15 -3
- package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +16 -13
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +6 -30
- package/dist/collection/components/atoms/mg-button/mg-button.js +53 -22
- package/dist/collection/components/atoms/mg-character-left/doc/mg-character-left.stories.js +20 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +10 -47
- package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +12 -4
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +99 -10
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +4 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -6
- package/dist/collection/components/atoms/mg-input-title/doc/mg-input-title.stories.js +21 -0
- package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +10 -8
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +19 -4
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +58 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +26 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +71 -13
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
- package/dist/collection/components/molecules/inputs/MgInput.js +5 -15
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +3 -15
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +22 -15
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +8 -21
- package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +3 -12
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +22 -20
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +19 -18
- package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +9 -13
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +23 -21
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +43 -19
- package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +10 -12
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +22 -20
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +17 -22
- package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +3 -14
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +22 -15
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +8 -15
- package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +10 -16
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +23 -20
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +24 -31
- package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +18 -25
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +54 -30
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +42 -43
- package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +11 -14
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +54 -24
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +64 -37
- package/dist/collection/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.js +57 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +21 -11
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +25 -10
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +25 -0
- package/dist/collection/components/molecules/mg-details/mg-details.css +14 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +141 -0
- package/dist/collection/components/molecules/mg-form/{mg-form.stories.js → doc/mg-form.stories.js} +9 -6
- package/dist/collection/components/molecules/mg-form/mg-form.css +5 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +53 -7
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +22 -0
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css +37 -0
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +74 -0
- package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +10 -16
- package/dist/collection/components/molecules/mg-message/mg-message.js +15 -7
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +43 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +5 -7
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +10 -4
- package/dist/collection/components/molecules/mg-pagination/doc/mg-pagination.stories.js +20 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +17 -18
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +29 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +4 -2
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +12 -16
- package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +22 -16
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +43 -13
- package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +20 -15
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +7 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +3 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +75 -29
- package/dist/collection/locales/index.js +33 -4
- package/dist/collection/stories/helpers.stories.js +41 -0
- package/dist/collection/stories/icons.stories.js +10 -2
- package/dist/collection/stories/typography.stories.js +8 -1
- package/dist/collection/utils/components.utils.js +10 -0
- package/dist/collection/utils/locale.utils.js +7 -4
- package/dist/collection/variables.css +10 -5
- package/dist/collection/variables.scss +10 -5
- package/dist/components/MgInput.js +6 -23
- package/dist/components/components.utils.js +11 -1
- package/dist/components/index.d.ts +25 -5
- package/dist/components/index.js +25 -0
- package/dist/components/index2.js +97 -8
- package/dist/components/locale.utils.js +7 -5
- package/dist/components/mg-badge2.js +16 -4
- package/dist/components/mg-button2.js +14 -17
- package/dist/components/mg-character-left2.js +4 -27
- package/dist/components/mg-details.d.ts +11 -0
- package/dist/components/mg-details.js +87 -0
- package/dist/components/mg-form.js +40 -8
- package/dist/components/mg-icon2.js +122 -17
- package/dist/components/mg-illustrated-message.d.ts +11 -0
- package/dist/components/mg-illustrated-message.js +68 -0
- package/dist/components/mg-input-checkbox.js +11 -27
- package/dist/components/mg-input-date.js +21 -25
- package/dist/components/mg-input-numeric.js +28 -26
- package/dist/components/mg-input-password.js +18 -28
- package/dist/components/mg-input-radio.js +10 -22
- package/dist/components/mg-input-select2.js +24 -35
- package/dist/components/mg-input-text2.js +38 -26
- package/dist/components/mg-input-textarea.js +43 -20
- package/dist/components/mg-input-toggle.js +27 -18
- package/dist/components/mg-message.js +16 -8
- package/dist/components/mg-modal.js +11 -5
- package/dist/components/mg-pagination.js +16 -22
- package/dist/components/mg-panel.js +9 -12
- package/dist/components/mg-popover.js +22 -12
- package/dist/components/mg-tabs.js +77 -22
- package/dist/components/mg-tag.js +20 -5
- package/dist/components/mg-tooltip2.js +74 -12
- package/dist/components/popper.js +6 -2
- package/dist/esm/{index-c346f52d.js → index-7efedd97.js} +107 -8
- package/dist/esm/{index-9e877561.js → index-bca81100.js} +48 -46
- package/dist/esm/loader.js +3 -17
- package/dist/esm/mg-badge_24.entry.js +5660 -0
- package/dist/esm/mg-components.js +3 -7
- package/dist/esm/mg-modal.entry.js +12 -6
- 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-5f89600c.js +1 -0
- package/dist/mg-components/p-a2883dc7.entry.js +1 -0
- package/dist/mg-components/p-b14a3443.js +2 -0
- package/dist/mg-components/p-cffe0519.entry.js +1 -0
- package/dist/mg-components/variables.css +10 -5
- package/dist/mg-components/variables.scss +10 -5
- package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -1
- package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +6 -0
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +12 -1
- package/dist/types/{stories/tags.stories.d.ts → components/atoms/mg-character-left/doc/mg-character-left.stories.d.ts} +2 -1
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +5 -13
- package/dist/types/components/atoms/mg-icon/{mg-icon.stories.d.ts → doc/mg-icon.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -3
- package/dist/types/components/atoms/mg-input-title/{mg-input-title.stories.d.ts → doc/mg-input-title.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +8 -1
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +24 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +13 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +27 -2
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +0 -6
- package/dist/types/components/molecules/inputs/MgInput.d.ts +2 -4
- package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -2
- package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +7 -1
- package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +6 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +8 -2
- package/dist/types/components/molecules/inputs/mg-input-password/{mg-input-password.stories.d.ts → doc/mg-input-password.stories.d.ts} +8 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +7 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -1
- package/dist/types/components/molecules/inputs/mg-input-select/{mg-input-select.stories.d.ts → doc/mg-input-select.stories.d.ts} +11 -5
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +7 -2
- package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +8 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +7 -7
- package/dist/types/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.d.ts → doc/mg-input-textarea.stories.d.ts} +8 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +14 -6
- package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -0
- package/dist/types/components/molecules/mg-details/doc/mg-details.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +49 -0
- package/dist/types/components/molecules/mg-form/{mg-form.stories.d.ts → doc/mg-form.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +14 -0
- package/dist/types/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.d.ts +6 -0
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +28 -0
- package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +2 -0
- package/dist/types/components/molecules/mg-modal/{mg-modal.stories.d.ts → doc/mg-modal.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +2 -0
- package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +8 -0
- package/dist/types/components/molecules/mg-panel/{mg-panel.stories.d.ts → doc/mg-panel.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +5 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +28 -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 +15 -2
- package/dist/types/components/molecules/mg-tabs/{mg-tabs.stories.d.ts → doc/mg-tabs.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +7 -1
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +44 -0
- package/dist/types/components.d.ts +240 -147
- package/dist/types/home/runner/work/mg-components/mg-components/.stencil/.storybook/utils.d.ts +1 -0
- package/dist/types/locales/index.d.ts +109 -46
- package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
- package/dist/types/utils/components.utils.d.ts +8 -0
- package/dist/types/utils/locale.utils.d.ts +7 -3
- package/loader/index.js +1 -1
- package/package.json +16 -16
- package/readme.md +6 -35
- package/dist/cjs/css-shim-629916b0.js +0 -6
- package/dist/cjs/mg-badge_21.cjs.entry.js +0 -3358
- package/dist/cjs/mg-popover.cjs.entry.js +0 -161
- package/dist/cjs/popper-0c3964e7.js +0 -1786
- package/dist/cjs/shadow-css-546083ef.js +0 -390
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +0 -23
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +0 -21
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +0 -26
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +0 -78
- package/dist/collection/components/molecules/mg-modal/mg-modal.stories.js +0 -51
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +0 -24
- package/dist/collection/components/molecules/mg-panel/mg-panel.stories.js +0 -39
- package/dist/collection/stories/buttons.stories.js +0 -43
- package/dist/collection/stories/messages.stories.js +0 -44
- package/dist/collection/stories/tags.stories.js +0 -13
- package/dist/esm/css-shim-0993aa3b.js +0 -4
- package/dist/esm/mg-badge_21.entry.js +0 -3334
- package/dist/esm/mg-popover.entry.js +0 -157
- package/dist/esm/popper-8874fd6c.js +0 -1784
- package/dist/esm/shadow-css-dfa0587f.js +0 -388
- package/dist/esm-es5/css-shim-0993aa3b.js +0 -1
- package/dist/esm-es5/index-9e877561.js +0 -1
- package/dist/esm-es5/index-c346f52d.js +0 -1
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +0 -1
- package/dist/esm-es5/mg-badge_21.entry.js +0 -2
- package/dist/esm-es5/mg-components.js +0 -1
- package/dist/esm-es5/mg-modal.entry.js +0 -1
- package/dist/esm-es5/mg-popover.entry.js +0 -1
- package/dist/esm-es5/popper-8874fd6c.js +0 -1
- package/dist/esm-es5/shadow-css-dfa0587f.js +0 -12
- package/dist/mg-components/mg-components.js +0 -132
- package/dist/mg-components/p-136c8d6f.system.entry.js +0 -2
- package/dist/mg-components/p-3c14153d.js +0 -1
- package/dist/mg-components/p-50ea2036.system.js +0 -1
- package/dist/mg-components/p-55a22b35.system.js +0 -1
- package/dist/mg-components/p-5e796581.js +0 -12
- package/dist/mg-components/p-656b5efb.system.js +0 -1
- package/dist/mg-components/p-68d6f104.js +0 -1
- package/dist/mg-components/p-6d49ed95.js +0 -1
- package/dist/mg-components/p-6f173f62.system.entry.js +0 -1
- package/dist/mg-components/p-70177194.entry.js +0 -1
- package/dist/mg-components/p-8b2d8a2a.system.js +0 -13
- package/dist/mg-components/p-8cb61c3f.system.js +0 -1
- package/dist/mg-components/p-ace173b1.js +0 -1
- package/dist/mg-components/p-b7488a4c.entry.js +0 -1
- package/dist/mg-components/p-c1ffb2e1.entry.js +0 -1
- package/dist/mg-components/p-c90cc4bf.system.js +0 -1
- package/dist/mg-components/p-de1164fa.system.entry.js +0 -1
- package/dist/mg-components/p-e4a502b5.system.js +0 -1
- package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +0 -16
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +0 -12
- package/dist/types/stories/messages.stories.d.ts +0 -13
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component, Element, h, Host, Prop, Watch } from '@stencil/core';
|
|
2
2
|
import { createID } from '../../../utils/components.utils';
|
|
3
3
|
import { createPopper } from '@popperjs/core';
|
|
4
|
+
import { Guard } from './mg-tooltip.conf';
|
|
4
5
|
export class MgTooltip {
|
|
5
6
|
constructor() {
|
|
6
7
|
/**
|
|
@@ -44,9 +45,51 @@ export class MgTooltip {
|
|
|
44
45
|
// Disable the event listeners
|
|
45
46
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
46
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Method to set display prop
|
|
50
|
+
*
|
|
51
|
+
* @param {boolean} newValue display prop new value
|
|
52
|
+
* @param {boolean} condition additionnal condition to apply display prop newValue
|
|
53
|
+
* @returns {void}
|
|
54
|
+
*/
|
|
55
|
+
this.setDisplay = (newValue, condition = true) => {
|
|
56
|
+
if (!this.disabled && condition)
|
|
57
|
+
this.display = newValue;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Action for tooltip element and tooltiped element mouse listener
|
|
61
|
+
*
|
|
62
|
+
* @param {Guard} elementGuard tooltip element guard
|
|
63
|
+
* @param {boolean} isMouseenter mouseenter validation
|
|
64
|
+
* @param {Guard} conditionalGuard guard condition
|
|
65
|
+
* @returns {void}
|
|
66
|
+
*/
|
|
67
|
+
this.tooltipMouseListenerAction = (elementGuard, isMouseenter, conditionalGuard) => {
|
|
68
|
+
// we mutate elementGuard
|
|
69
|
+
if (this.guard !== Guard.FOCUS) {
|
|
70
|
+
this.guard = elementGuard;
|
|
71
|
+
if (!isMouseenter) {
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
this.setDisplay(isMouseenter, this.guard !== conditionalGuard);
|
|
74
|
+
this.resetGuard();
|
|
75
|
+
}, 100);
|
|
76
|
+
}
|
|
77
|
+
else if (isMouseenter && elementGuard === Guard.HOVER_TOOLTIPED_ELEMENT) {
|
|
78
|
+
this.setDisplay(isMouseenter);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Method to reset guard value
|
|
84
|
+
*
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
this.resetGuard = () => {
|
|
88
|
+
this.guard = undefined;
|
|
89
|
+
};
|
|
47
90
|
}
|
|
48
|
-
handleDisplay(
|
|
49
|
-
if (
|
|
91
|
+
handleDisplay(newValue) {
|
|
92
|
+
if (newValue) {
|
|
50
93
|
this.show();
|
|
51
94
|
}
|
|
52
95
|
else {
|
|
@@ -97,21 +140,31 @@ export class MgTooltip {
|
|
|
97
140
|
},
|
|
98
141
|
],
|
|
99
142
|
});
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.display = true;
|
|
105
|
-
});
|
|
143
|
+
// Manage tooltipedElement focus/blur events
|
|
144
|
+
tooltipedElement.addEventListener('focus', () => {
|
|
145
|
+
this.guard = Guard.FOCUS;
|
|
146
|
+
this.setDisplay(true);
|
|
106
147
|
});
|
|
107
|
-
['
|
|
148
|
+
['blur', 'keydown'].forEach(event => {
|
|
108
149
|
tooltipedElement.addEventListener(event, (e) => {
|
|
109
150
|
// we continue to process ONLY for KeyboardEvents 'Escape'
|
|
110
151
|
if (e.type === 'keydown' && e.code !== 'Escape') {
|
|
111
152
|
return;
|
|
112
153
|
}
|
|
113
|
-
|
|
114
|
-
|
|
154
|
+
this.resetGuard();
|
|
155
|
+
this.setDisplay(false);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
// manage tooltipElement & tooltipedElement mouseenter/mouseleave events
|
|
159
|
+
['mouseenter', 'mouseleave'].forEach(event => {
|
|
160
|
+
const isMouseenter = event === 'mouseenter';
|
|
161
|
+
[
|
|
162
|
+
{ element: this.tooltip, action: () => this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, isMouseenter, Guard.HOVER_TOOLTIPED_ELEMENT) },
|
|
163
|
+
{ element: tooltipedElement, action: () => this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, isMouseenter, Guard.HOVER_TOOLTIP_ELEMENT) },
|
|
164
|
+
].forEach(({ element, action }) => {
|
|
165
|
+
element.addEventListener(event, () => {
|
|
166
|
+
action();
|
|
167
|
+
});
|
|
115
168
|
});
|
|
116
169
|
});
|
|
117
170
|
this.handleDisplay(this.display);
|
|
@@ -175,9 +228,14 @@ export class MgTooltip {
|
|
|
175
228
|
"type": "string",
|
|
176
229
|
"mutable": false,
|
|
177
230
|
"complexType": {
|
|
178
|
-
"original": "
|
|
231
|
+
"original": "Placement",
|
|
179
232
|
"resolved": "\"auto\" | \"auto-end\" | \"auto-start\" | \"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
|
|
180
|
-
"references": {
|
|
233
|
+
"references": {
|
|
234
|
+
"Placement": {
|
|
235
|
+
"location": "import",
|
|
236
|
+
"path": "./mg-tooltip.conf"
|
|
237
|
+
}
|
|
238
|
+
}
|
|
181
239
|
},
|
|
182
240
|
"required": false,
|
|
183
241
|
"optional": false,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
-
import { InputClass } from './MgInput.conf';
|
|
3
2
|
/**
|
|
4
3
|
* Apply in all input child node the aria-describedby attribute
|
|
5
4
|
*
|
|
@@ -28,11 +27,8 @@ const manageClasses = (props) => {
|
|
|
28
27
|
props.classList.add('mg-input--label-on-top');
|
|
29
28
|
if (props.readonly)
|
|
30
29
|
props.classList.add('mg-input--readonly');
|
|
31
|
-
if (props.
|
|
32
|
-
props.classList.add(`mg-input--width-${props.
|
|
33
|
-
if (props.readonly || props.disabled) {
|
|
34
|
-
props.classList.delete(InputClass.ERROR);
|
|
35
|
-
}
|
|
30
|
+
if (props.mgWidth !== undefined)
|
|
31
|
+
props.classList.add(`mg-input--width-${props.mgWidth}`);
|
|
36
32
|
};
|
|
37
33
|
/**
|
|
38
34
|
* Get tagname
|
|
@@ -66,12 +62,7 @@ export const MgInput = (props, children, utils) => {
|
|
|
66
62
|
/**
|
|
67
63
|
* a11y IDs
|
|
68
64
|
*/
|
|
69
|
-
const ariaDescribedbyIDs = new Set();
|
|
70
|
-
// Character Left
|
|
71
|
-
const characterLeftId = `${props.identifier}-character-left`;
|
|
72
|
-
if (props.classList.has('is-focused') && props.displayCharacterLeft) {
|
|
73
|
-
ariaDescribedbyIDs.add(characterLeftId);
|
|
74
|
-
}
|
|
65
|
+
const ariaDescribedbyIDs = new Set(props.ariaDescribedbyIDs);
|
|
75
66
|
// Help text
|
|
76
67
|
const helpTextId = `${props.identifier}-help-text`;
|
|
77
68
|
if (typeof props.helpText === 'string' && props.helpText !== '') {
|
|
@@ -127,10 +118,9 @@ export const MgInput = (props, children, utils) => {
|
|
|
127
118
|
props.readonly ? (h("div", { class: "mg-input__input-container" },
|
|
128
119
|
h("strong", null, props.readonlyValue || props.value),
|
|
129
120
|
children)) : (h("div", { class: "mg-input__input-container" },
|
|
130
|
-
h("div", { class:
|
|
121
|
+
h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } },
|
|
131
122
|
children,
|
|
132
123
|
!props.labelOnTop && props.tooltip && getTooltip()),
|
|
133
|
-
props.displayCharacterLeft && props.maxlength && props.classList.has('is-focused') && (h("mg-character-left", { identifier: characterLeftId, characters: props.value, maxlength: props.maxlength, template: props.characterLeftTemplate })),
|
|
134
124
|
props.helpText && h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }),
|
|
135
|
-
props.errorMessage && h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" })))));
|
|
125
|
+
props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
|
|
136
126
|
};
|
|
@@ -1,30 +1,18 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
+
import { filterArgs } from '../../../../../../.storybook/utils';
|
|
2
3
|
export default {
|
|
3
4
|
component: 'mg-input-checkbox',
|
|
4
5
|
title: 'Molecules/Inputs/mg-input-checkbox',
|
|
5
6
|
parameters: { actions: { handles: ['value-change', 'input-valid'] } },
|
|
6
7
|
};
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
9
|
+
* Template
|
|
10
10
|
*
|
|
11
11
|
* @param {any} args component arguments
|
|
12
12
|
* @returns {HTMLElement} HTMLElement
|
|
13
13
|
*/
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const Template = (args) => {
|
|
16
|
-
// Extract slot so it won't be render as an attribute
|
|
17
|
-
const labelOnTop = args.labelOnTop;
|
|
18
|
-
delete args.labelOnTop;
|
|
19
|
-
const helpText = args.helpText;
|
|
20
|
-
delete args.helpText;
|
|
21
|
-
const inputVerticalList = args.inputVerticalList;
|
|
22
|
-
delete args.inputVerticalList;
|
|
23
|
-
const labelHide = args.labelHide;
|
|
24
|
-
delete args.labelHide;
|
|
25
|
-
// return element
|
|
26
|
-
return h("mg-input-checkbox", Object.assign({}, args, { "label-on-top": labelOnTop, "label-hide": labelHide, "help-text": helpText, "input-vertical-list": inputVerticalList }));
|
|
27
|
-
};
|
|
15
|
+
const Template = (args) => h("mg-input-checkbox", Object.assign({}, filterArgs(args)));
|
|
28
16
|
export const MgInputCheckbox = Template.bind({});
|
|
29
17
|
MgInputCheckbox.args = {
|
|
30
18
|
// Global
|
|
@@ -11,16 +11,9 @@
|
|
|
11
11
|
min-height: var(--default-size);
|
|
12
12
|
max-width: 100%;
|
|
13
13
|
margin-bottom: var(--mg-inputs-margin-bottom, 0);
|
|
14
|
-
/* Style when input is not valid */
|
|
15
14
|
/* Label */
|
|
16
15
|
/* Label-on-top */
|
|
17
16
|
}
|
|
18
|
-
.mg-input.is-not-valid {
|
|
19
|
-
color: hsl(var(--color-danger));
|
|
20
|
-
}
|
|
21
|
-
.mg-input.is-not-valid .mg-input__box {
|
|
22
|
-
border-color: hsl(var(--color-danger));
|
|
23
|
-
}
|
|
24
17
|
.mg-input mg-input-title {
|
|
25
18
|
flex-shrink: var(--mg-inputs-shrink, 1);
|
|
26
19
|
width: var(--mg-inputs-title-width, auto);
|
|
@@ -71,8 +64,10 @@
|
|
|
71
64
|
height: var(--mg-icon-regular-size);
|
|
72
65
|
margin-left: var(--mg-inputs-spacer);
|
|
73
66
|
}
|
|
74
|
-
.mg-input__input-container mg-
|
|
75
|
-
|
|
67
|
+
.mg-input__input-container .mg-input__help-text,
|
|
68
|
+
.mg-input__input-container .mg-input__error {
|
|
69
|
+
text-align: start;
|
|
70
|
+
font-size: 1.2rem;
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
.mg-input__input {
|
|
@@ -82,11 +77,26 @@
|
|
|
82
77
|
.mg-input__input mg-tooltip {
|
|
83
78
|
margin-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
84
79
|
}
|
|
85
|
-
.mg-input__input
|
|
86
|
-
|
|
80
|
+
.mg-input__input.mg-input__input--has-error .mg-input__box {
|
|
81
|
+
border-color: hsl(var(--color-danger));
|
|
82
|
+
}
|
|
83
|
+
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
87
84
|
margin-top: 0.5rem;
|
|
88
85
|
}
|
|
89
86
|
|
|
87
|
+
.mg-input__error {
|
|
88
|
+
display: inline-block;
|
|
89
|
+
margin-top: 0.2rem;
|
|
90
|
+
padding: 0.3rem 0.8rem;
|
|
91
|
+
border-radius: 0.3rem;
|
|
92
|
+
background: hsl(var(--mg-inputs-error-bg-color));
|
|
93
|
+
color: hsl(var(--color-danger));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.mg-input__input mg-icon, .mg-input__error mg-icon {
|
|
97
|
+
display: flex;
|
|
98
|
+
}
|
|
99
|
+
|
|
90
100
|
/**
|
|
91
101
|
* Manage style when input needs to be a fieldset, like checkbox and radio.
|
|
92
102
|
*/
|
|
@@ -110,12 +120,9 @@ fieldset.mg-input input[type=checkbox] {
|
|
|
110
120
|
fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
|
|
111
121
|
margin-top: 0.7rem;
|
|
112
122
|
}
|
|
113
|
-
fieldset.mg-input.is-not-valid .mg-input__input-group {
|
|
114
|
-
color: initial;
|
|
115
|
-
}
|
|
116
123
|
|
|
117
124
|
.mg-input__input-container mg-tooltip {
|
|
118
|
-
margin-left:
|
|
125
|
+
margin-left: 3rem;
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
/* input group container */
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Component, Event, h, Prop, State, Watch, Method } from '@stencil/core';
|
|
1
|
+
import { Component, Element, 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
|
-
import {
|
|
5
|
-
import { InputClass } from '../MgInput.conf';
|
|
4
|
+
import { initLocales } from '../../../../locales';
|
|
6
5
|
/**
|
|
7
6
|
* type CheckboxItem validation function
|
|
8
7
|
*
|
|
@@ -15,8 +14,6 @@ export class MgInputCheckbox {
|
|
|
15
14
|
/************
|
|
16
15
|
* Internal *
|
|
17
16
|
************/
|
|
18
|
-
// classes
|
|
19
|
-
this.classError = InputClass.ERROR;
|
|
20
17
|
// HTML selector
|
|
21
18
|
this.inputs = [];
|
|
22
19
|
/**
|
|
@@ -101,14 +98,7 @@ export class MgInputCheckbox {
|
|
|
101
98
|
// Set error message
|
|
102
99
|
this.errorMessage = undefined;
|
|
103
100
|
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);
|
|
101
|
+
this.errorMessage = this.messages.errors.required;
|
|
112
102
|
}
|
|
113
103
|
};
|
|
114
104
|
/**
|
|
@@ -132,9 +122,6 @@ export class MgInputCheckbox {
|
|
|
132
122
|
throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
|
|
133
123
|
}
|
|
134
124
|
}
|
|
135
|
-
handleReadOnly() {
|
|
136
|
-
this.classList.delete(this.classError);
|
|
137
|
-
}
|
|
138
125
|
/**
|
|
139
126
|
* Public method to display errors
|
|
140
127
|
*
|
|
@@ -153,7 +140,9 @@ export class MgInputCheckbox {
|
|
|
153
140
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
154
141
|
*/
|
|
155
142
|
componentWillLoad() {
|
|
156
|
-
//
|
|
143
|
+
// Get locales
|
|
144
|
+
this.messages = initLocales(this.element).messages;
|
|
145
|
+
// Validate
|
|
157
146
|
this.validateValue(this.value);
|
|
158
147
|
// Check validity when component is ready
|
|
159
148
|
// return a promise to process action only in the FIRST render().
|
|
@@ -168,7 +157,7 @@ export class MgInputCheckbox {
|
|
|
168
157
|
* @returns {HTMLElement} HTML Element
|
|
169
158
|
*/
|
|
170
159
|
render() {
|
|
171
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined,
|
|
160
|
+
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 && this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true },
|
|
172
161
|
h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
|
|
173
162
|
.filter(item => {
|
|
174
163
|
return !this.readonly || item.value;
|
|
@@ -497,11 +486,9 @@ export class MgInputCheckbox {
|
|
|
497
486
|
}
|
|
498
487
|
}
|
|
499
488
|
}; }
|
|
489
|
+
static get elementRef() { return "element"; }
|
|
500
490
|
static get watchers() { return [{
|
|
501
491
|
"propName": "value",
|
|
502
492
|
"methodName": "validateValue"
|
|
503
|
-
}, {
|
|
504
|
-
"propName": "readonly",
|
|
505
|
-
"methodName": "handleReadOnly"
|
|
506
493
|
}]; }
|
|
507
494
|
}
|
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
+
import { filterArgs } from '../../../../../../.storybook/utils';
|
|
2
3
|
export default {
|
|
3
4
|
component: 'mg-input-date',
|
|
4
5
|
title: 'Molecules/Inputs/mg-input-date',
|
|
5
6
|
parameters: { actions: { handles: ['value-change', 'input-valid'] } },
|
|
6
7
|
};
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
9
|
+
* Template
|
|
10
10
|
*
|
|
11
11
|
* @param {any} args component arguments
|
|
12
12
|
* @returns {HTMLElement} HTMLElement
|
|
13
13
|
*/
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const Template = (args) => {
|
|
16
|
-
const labelOnTop = args.labelOnTop;
|
|
17
|
-
delete args.labelOnTop;
|
|
18
|
-
const labelHide = args.labelHide;
|
|
19
|
-
delete args.labelHide;
|
|
20
|
-
const helpText = args.helpText;
|
|
21
|
-
delete args.helpText;
|
|
22
|
-
// return element
|
|
23
|
-
return h("mg-input-date", Object.assign({}, args, { "label-on-top": labelOnTop, "label-hide": labelHide, "help-text": helpText }));
|
|
24
|
-
};
|
|
15
|
+
const Template = (args) => h("mg-input-date", Object.assign({}, filterArgs(args)));
|
|
25
16
|
const date = new Date();
|
|
26
17
|
const getFormatedNumber = (number) => {
|
|
27
18
|
return `${number > 9 ? number : '0' + number}`;
|
|
@@ -11,16 +11,9 @@
|
|
|
11
11
|
min-height: var(--default-size);
|
|
12
12
|
max-width: 100%;
|
|
13
13
|
margin-bottom: var(--mg-inputs-margin-bottom, 0);
|
|
14
|
-
/* Style when input is not valid */
|
|
15
14
|
/* Label */
|
|
16
15
|
/* Label-on-top */
|
|
17
16
|
}
|
|
18
|
-
.mg-input.is-not-valid {
|
|
19
|
-
color: hsl(var(--color-danger));
|
|
20
|
-
}
|
|
21
|
-
.mg-input.is-not-valid .mg-input__box {
|
|
22
|
-
border-color: hsl(var(--color-danger));
|
|
23
|
-
}
|
|
24
17
|
.mg-input mg-input-title {
|
|
25
18
|
flex-shrink: var(--mg-inputs-shrink, 1);
|
|
26
19
|
width: var(--mg-inputs-title-width, auto);
|
|
@@ -71,8 +64,10 @@
|
|
|
71
64
|
height: var(--mg-icon-regular-size);
|
|
72
65
|
margin-left: var(--mg-inputs-spacer);
|
|
73
66
|
}
|
|
74
|
-
.mg-input__input-container mg-
|
|
75
|
-
|
|
67
|
+
.mg-input__input-container .mg-input__help-text,
|
|
68
|
+
.mg-input__input-container .mg-input__error {
|
|
69
|
+
text-align: start;
|
|
70
|
+
font-size: 1.2rem;
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
.mg-input__input {
|
|
@@ -82,11 +77,26 @@
|
|
|
82
77
|
.mg-input__input mg-tooltip {
|
|
83
78
|
margin-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
84
79
|
}
|
|
85
|
-
.mg-input__input
|
|
86
|
-
|
|
80
|
+
.mg-input__input.mg-input__input--has-error .mg-input__box {
|
|
81
|
+
border-color: hsl(var(--color-danger));
|
|
82
|
+
}
|
|
83
|
+
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
87
84
|
margin-top: 0.5rem;
|
|
88
85
|
}
|
|
89
86
|
|
|
87
|
+
.mg-input__error {
|
|
88
|
+
display: inline-block;
|
|
89
|
+
margin-top: 0.2rem;
|
|
90
|
+
padding: 0.3rem 0.8rem;
|
|
91
|
+
border-radius: 0.3rem;
|
|
92
|
+
background: hsl(var(--mg-inputs-error-bg-color));
|
|
93
|
+
color: hsl(var(--color-danger));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.mg-input__input mg-icon, .mg-input__error mg-icon {
|
|
97
|
+
display: flex;
|
|
98
|
+
}
|
|
99
|
+
|
|
90
100
|
/**
|
|
91
101
|
* Style for input "box":
|
|
92
102
|
* - input[type="text"]
|
|
@@ -97,7 +107,6 @@
|
|
|
97
107
|
*/
|
|
98
108
|
.mg-input__box {
|
|
99
109
|
padding: calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);
|
|
100
|
-
width: 100%;
|
|
101
110
|
height: var(--default-size);
|
|
102
111
|
box-sizing: border-box;
|
|
103
112
|
border-width: var(--mg-inputs-border-width);
|
|
@@ -108,6 +117,7 @@
|
|
|
108
117
|
font-family: inherit;
|
|
109
118
|
color: hsl(var(--color-dark));
|
|
110
119
|
font-size: var(--font-size);
|
|
120
|
+
text-align: var(--mg-inputs-text-align, left);
|
|
111
121
|
}
|
|
112
122
|
.mg-input__box::placeholder {
|
|
113
123
|
color: var(--mg-inputs-color);
|
|
@@ -155,10 +165,6 @@
|
|
|
155
165
|
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]) {
|
|
156
166
|
--mg-button-border-radius-top-right: 0;
|
|
157
167
|
--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
168
|
}
|
|
163
169
|
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)) {
|
|
164
170
|
--mg-button-border-right-width: 0;
|
|
@@ -166,10 +172,6 @@
|
|
|
166
172
|
.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type) {
|
|
167
173
|
--mg-button-border-radius-top-right: var(--mg-inputs-border-radius);
|
|
168
174
|
--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
175
|
}
|
|
174
176
|
|
|
175
177
|
.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]) {
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import { Component, Event, h, Prop, State, Watch, Method } from '@stencil/core';
|
|
1
|
+
import { Component, Element, Event, h, Prop, State, Watch, Method } from '@stencil/core';
|
|
2
2
|
import { MgInput } from '../MgInput';
|
|
3
3
|
import { InputError } from './mg-input-date.conf';
|
|
4
4
|
import { createID, ClassList } from '../../../../utils/components.utils';
|
|
5
5
|
import { localeDate, dateRegExp } from '../../../../utils/locale.utils';
|
|
6
|
-
import {
|
|
7
|
-
import { InputClass } from '../MgInput.conf';
|
|
6
|
+
import { initLocales } from '../../../../locales';
|
|
8
7
|
export class MgInputDate {
|
|
9
8
|
constructor() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
************/
|
|
13
|
-
// classes
|
|
14
|
-
this.classError = InputClass.ERROR;
|
|
9
|
+
// hasError (triggered by blur event)
|
|
10
|
+
this.hasError = false;
|
|
15
11
|
/**
|
|
16
12
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
17
13
|
* If not set, it will be created.
|
|
@@ -47,14 +43,16 @@ export class MgInputDate {
|
|
|
47
43
|
*/
|
|
48
44
|
this.handleInput = () => {
|
|
49
45
|
this.checkValidity();
|
|
46
|
+
if (this.hasError) {
|
|
47
|
+
this.checkError();
|
|
48
|
+
}
|
|
50
49
|
this.value = this.input.value;
|
|
51
50
|
};
|
|
52
51
|
/**
|
|
53
52
|
* Handle blur event
|
|
54
53
|
*/
|
|
55
54
|
this.handleBlur = () => {
|
|
56
|
-
this.
|
|
57
|
-
this.checkError();
|
|
55
|
+
this.displayError();
|
|
58
56
|
};
|
|
59
57
|
/**
|
|
60
58
|
* Check if input is valid
|
|
@@ -105,16 +103,16 @@ export class MgInputDate {
|
|
|
105
103
|
const inputError = this.getInputError();
|
|
106
104
|
// required
|
|
107
105
|
if (inputError === InputError.REQUIRED) {
|
|
108
|
-
this.errorMessage = messages.errors[inputError];
|
|
106
|
+
this.errorMessage = this.messages.errors[inputError];
|
|
109
107
|
}
|
|
110
108
|
// min, max & minMax
|
|
111
109
|
else if ([InputError.MIN, InputError.MAX, InputError.MINMAX].includes(inputError)) {
|
|
112
|
-
this.errorMessage = messages.errors.date[inputError].replace('{min}', localeDate(this.min)).replace('{max}', localeDate(this.max));
|
|
110
|
+
this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
|
|
113
111
|
}
|
|
114
112
|
// wrong date format
|
|
115
113
|
// element.validity.badInput is default error message
|
|
116
114
|
else {
|
|
117
|
-
this.errorMessage = messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min) : localeDate('1900-01-01'));
|
|
115
|
+
this.errorMessage = this.messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min, this.locale) : localeDate('1900-01-01', this.locale));
|
|
118
116
|
}
|
|
119
117
|
};
|
|
120
118
|
/**
|
|
@@ -127,10 +125,6 @@ export class MgInputDate {
|
|
|
127
125
|
this.errorMessage = undefined;
|
|
128
126
|
if (!this.valid) {
|
|
129
127
|
this.setErrorMessage();
|
|
130
|
-
this.classList.add(this.classError);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
this.classList.delete(this.classError);
|
|
134
128
|
}
|
|
135
129
|
};
|
|
136
130
|
}
|
|
@@ -156,6 +150,7 @@ export class MgInputDate {
|
|
|
156
150
|
async displayError() {
|
|
157
151
|
this.checkValidity();
|
|
158
152
|
this.checkError();
|
|
153
|
+
this.hasError = this.invalid;
|
|
159
154
|
}
|
|
160
155
|
/**
|
|
161
156
|
* Date format validation
|
|
@@ -177,6 +172,11 @@ export class MgInputDate {
|
|
|
177
172
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
178
173
|
*/
|
|
179
174
|
componentWillLoad() {
|
|
175
|
+
// Get locales
|
|
176
|
+
const locales = initLocales(this.element);
|
|
177
|
+
this.locale = locales.locale;
|
|
178
|
+
this.messages = locales.messages;
|
|
179
|
+
// Validate
|
|
180
180
|
this.validateValue(this.value);
|
|
181
181
|
this.validateMin(this.min);
|
|
182
182
|
this.validateMax(this.max);
|
|
@@ -193,7 +193,7 @@ export class MgInputDate {
|
|
|
193
193
|
* @returns {HTMLElement} HTML Element
|
|
194
194
|
*/
|
|
195
195
|
render() {
|
|
196
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly,
|
|
196
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false },
|
|
197
197
|
h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => (this.input = el) })));
|
|
198
198
|
}
|
|
199
199
|
static get is() { return "mg-input-date"; }
|
|
@@ -523,6 +523,7 @@ export class MgInputDate {
|
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
}; }
|
|
526
|
+
static get elementRef() { return "element"; }
|
|
526
527
|
static get watchers() { return [{
|
|
527
528
|
"propName": "value",
|
|
528
529
|
"methodName": "validateValue"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
-
import {
|
|
2
|
+
import { filterArgs } from '../../../../../../.storybook/utils';
|
|
3
|
+
import { types } from '../mg-input-numeric.conf';
|
|
3
4
|
export default {
|
|
4
5
|
component: 'mg-input-numeric',
|
|
5
6
|
title: 'Molecules/Inputs/mg-input-numeric',
|
|
@@ -8,27 +9,21 @@ export default {
|
|
|
8
9
|
options: types,
|
|
9
10
|
control: { type: 'select' },
|
|
10
11
|
},
|
|
12
|
+
mgWidth: {
|
|
13
|
+
options: [undefined, 2, 4, 16, 'full'],
|
|
14
|
+
control: { type: 'select' },
|
|
15
|
+
},
|
|
11
16
|
},
|
|
12
17
|
parameters: { actions: { handles: ['value-change', 'input-valid'] } },
|
|
13
18
|
};
|
|
14
19
|
/**
|
|
15
|
-
*
|
|
16
|
-
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
20
|
+
* Template
|
|
17
21
|
*
|
|
18
22
|
* @param {any} args component arguments
|
|
19
23
|
* @returns {HTMLElement} HTMLElement
|
|
20
24
|
*/
|
|
21
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
const Template = (args) => {
|
|
23
|
-
const labelOnTop = args.labelOnTop;
|
|
24
|
-
delete args.labelOnTop;
|
|
25
|
-
const labelHide = args.labelHide;
|
|
26
|
-
delete args.labelHide;
|
|
27
|
-
const helpText = args.helpText;
|
|
28
|
-
delete args.helpText;
|
|
29
|
-
// return element
|
|
30
|
-
return h("mg-input-numeric", Object.assign({}, args, { "label-on-top": labelOnTop, "label-hide": labelHide, "help-text": helpText }));
|
|
31
|
-
};
|
|
26
|
+
const Template = (args) => h("mg-input-numeric", Object.assign({}, filterArgs(args)));
|
|
32
27
|
/**
|
|
33
28
|
* Global use
|
|
34
29
|
*/
|
|
@@ -50,6 +45,7 @@ MgInputNumeric.args = {
|
|
|
50
45
|
readonly: false,
|
|
51
46
|
max: undefined,
|
|
52
47
|
min: undefined,
|
|
48
|
+
mgWidth: undefined,
|
|
53
49
|
// Tooltip
|
|
54
50
|
tooltip: 'This is a tooltip',
|
|
55
51
|
// Help Text
|