@mgdis/mg-components 3.2.0 → 4.0.1
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-bead7dbd.js → index-88560a66.js} +47 -48
- package/dist/cjs/{index-369388eb.js → index-a39c5567.js} +97 -10
- package/dist/cjs/loader.cjs.js +3 -17
- package/dist/cjs/mg-badge_21.cjs.entry.js +519 -294
- package/dist/cjs/mg-components.cjs.js +3 -7
- package/dist/cjs/mg-modal.cjs.entry.js +12 -6
- package/dist/cjs/mg-popover.cjs.entry.js +15 -10
- package/dist/cjs/{popper-0c3964e7.js → popper-71bf3058.js} +6 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.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 +15 -3
- package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +2 -2
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.css +20 -32
- package/dist/collection/components/atoms/mg-button/mg-button.js +8 -3
- package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +1 -1
- 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} +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +97 -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/{mg-input-title.stories.js → doc/mg-input-title.stories.js} +0 -0
- package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +1 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +19 -4
- 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 +7 -2
- 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} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +19 -13
- 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} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +19 -18
- 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 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +20 -19
- 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 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +19 -18
- 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} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +19 -13
- 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 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +20 -18
- 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} +11 -7
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +51 -28
- 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} +10 -4
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +51 -22
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +66 -39
- package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +18 -9
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +10 -4
- package/dist/collection/components/molecules/mg-form/{mg-form.stories.js → doc/mg-form.stories.js} +0 -0
- package/dist/collection/components/molecules/mg-form/mg-form.css +4 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +5 -3
- package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +15 -7
- package/dist/collection/components/molecules/mg-modal/{mg-modal.stories.js → doc/mg-modal.stories.js} +0 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +5 -7
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +12 -5
- package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +0 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +17 -18
- package/dist/collection/components/molecules/mg-panel/{mg-panel.stories.js → doc/mg-panel.stories.js} +9 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +13 -4
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +119 -18
- 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.js +19 -9
- package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +12 -5
- 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 +92 -27
- package/dist/collection/locales/index.js +33 -4
- package/dist/collection/stories/helpers.stories.js +33 -0
- package/dist/collection/utils/locale.utils.js +7 -4
- package/dist/collection/variables.css +9 -4
- package/dist/collection/variables.scss +9 -4
- package/dist/components/MgInput.js +6 -23
- package/dist/components/index.d.ts +23 -5
- package/dist/components/index.js +23 -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 +10 -5
- package/dist/components/mg-character-left2.js +4 -27
- package/dist/components/mg-form.js +6 -4
- package/dist/components/mg-icon2.js +120 -17
- 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 +44 -21
- package/dist/components/mg-input-toggle.js +11 -11
- 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 +51 -17
- package/dist/components/mg-popover.js +13 -8
- package/dist/components/mg-tabs.js +80 -22
- package/dist/components/mg-tag.js +20 -5
- package/dist/components/mg-tooltip2.js +1 -1
- package/dist/components/popper.js +6 -2
- package/dist/esm/{index-9e877561.js → index-bca81100.js} +48 -46
- package/dist/esm/{index-c346f52d.js → index-e51ae032.js} +97 -8
- package/dist/esm/loader.js +3 -17
- package/dist/esm/mg-badge_21.entry.js +516 -291
- package/dist/esm/mg-components.js +3 -7
- package/dist/esm/mg-modal.entry.js +12 -6
- package/dist/esm/mg-popover.entry.js +15 -10
- package/dist/esm/{popper-8874fd6c.js → popper-93ecb064.js} +6 -2
- 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-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-766c918b.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 +9 -4
- package/dist/mg-components/variables.scss +9 -4
- 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} +0 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +1 -1
- package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +0 -0
- 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 +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 +2 -1
- 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/doc/mg-input-textarea.stories.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +15 -7
- 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-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 +1 -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/{inputs/mg-input-textarea/mg-input-textarea.stories.d.ts → mg-panel/doc/mg-panel.stories.d.ts} +1 -1
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +29 -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 +9 -1
- package/dist/types/components/molecules/mg-tabs/{mg-tabs.stories.d.ts → doc/mg-tabs.stories.d.ts} +5 -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 +49 -0
- package/dist/types/components.d.ts +181 -151
- 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/locale.utils.d.ts +7 -3
- package/loader/index.js +1 -1
- package/package.json +14 -14
- package/readme.md +6 -35
- package/dist/cjs/css-shim-629916b0.js +0 -6
- package/dist/cjs/shadow-css-546083ef.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-0993aa3b.js +0 -4
- 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-3633e9e1.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-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-c46fbd54.entry.js +0 -1
- package/dist/mg-components/p-c90cc4bf.system.js +0 -1
- package/dist/mg-components/p-cd2a4acc.system.entry.js +0 -1
- package/dist/mg-components/p-de1164fa.system.entry.js +0 -1
- package/dist/mg-components/p-dfe25da3.entry.js +0 -1
- package/dist/mg-components/p-e4a502b5.system.js +0 -1
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-panel/mg-panel.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +0 -12
- package/dist/types/stories/messages.stories.d.ts +0 -13
- package/dist/types/stories/tags.stories.d.ts +0 -5
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { M as MgInput } from './MgInput.js';
|
|
3
3
|
import { c as createID, C as ClassList, a as allItemsAreString } from './components.utils.js';
|
|
4
|
-
import {
|
|
5
|
-
import { d as defineCustomElement$4 } from './mg-character-left2.js';
|
|
4
|
+
import { i as initLocales } from './index2.js';
|
|
6
5
|
import { d as defineCustomElement$3 } from './mg-icon2.js';
|
|
7
6
|
import { d as defineCustomElement$2 } from './mg-input-title2.js';
|
|
8
7
|
import { d as defineCustomElement$1 } from './mg-tooltip2.js';
|
|
9
8
|
|
|
10
|
-
const mgInputSelectCss = ":host{display:block}.mg-input{display
|
|
9
|
+
const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input__box{width:100%;padding-top:0;padding-bottom:0;padding-right:1rem}";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Check if item is a well configured option
|
|
@@ -15,7 +14,7 @@ const mgInputSelectCss = ":host{display:block}.mg-input{display:-ms-flexbox;disp
|
|
|
15
14
|
* @param {SelectOption} option select option
|
|
16
15
|
* @returns {boolean} select option type is valid
|
|
17
16
|
*/
|
|
18
|
-
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string'
|
|
17
|
+
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
19
18
|
/**
|
|
20
19
|
* Group options
|
|
21
20
|
*
|
|
@@ -52,11 +51,8 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
52
51
|
this.__attachShadow();
|
|
53
52
|
this.valueChange = createEvent(this, "value-change", 7);
|
|
54
53
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
************/
|
|
58
|
-
// classes
|
|
59
|
-
this.classError = InputClass.ERROR;
|
|
54
|
+
// hasError (triggered by blur event)
|
|
55
|
+
this.hasError = false;
|
|
60
56
|
/**
|
|
61
57
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
62
58
|
* If not set, it will be created.
|
|
@@ -71,11 +67,6 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
71
67
|
* Define if label is visible
|
|
72
68
|
*/
|
|
73
69
|
this.labelHide = false;
|
|
74
|
-
/**
|
|
75
|
-
* Input placeholder.
|
|
76
|
-
* It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.
|
|
77
|
-
*/
|
|
78
|
-
this.placeholder = messages.input.select.placeholder;
|
|
79
70
|
/**
|
|
80
71
|
* Option to remove placeholder
|
|
81
72
|
*/
|
|
@@ -105,6 +96,9 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
105
96
|
*/
|
|
106
97
|
this.handleInput = () => {
|
|
107
98
|
this.checkValidity();
|
|
99
|
+
if (this.hasError) {
|
|
100
|
+
this.checkError();
|
|
101
|
+
}
|
|
108
102
|
if (this.input.value !== '') {
|
|
109
103
|
this.value = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
|
|
110
104
|
}
|
|
@@ -116,8 +110,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
116
110
|
* Handle blur event
|
|
117
111
|
*/
|
|
118
112
|
this.handleBlur = () => {
|
|
119
|
-
this.
|
|
120
|
-
this.checkError();
|
|
113
|
+
this.displayError();
|
|
121
114
|
};
|
|
122
115
|
/**
|
|
123
116
|
* Check if input is valid
|
|
@@ -139,14 +132,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
139
132
|
// Set error message
|
|
140
133
|
this.errorMessage = undefined;
|
|
141
134
|
if (!this.valid && this.input.validity.valueMissing) {
|
|
142
|
-
this.errorMessage = messages.errors.required;
|
|
143
|
-
}
|
|
144
|
-
// Update class
|
|
145
|
-
if (this.valid) {
|
|
146
|
-
this.classList.delete(this.classError);
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
this.classList.add(this.classError);
|
|
135
|
+
this.errorMessage = this.messages.errors.required;
|
|
150
136
|
}
|
|
151
137
|
};
|
|
152
138
|
}
|
|
@@ -189,6 +175,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
189
175
|
async displayError() {
|
|
190
176
|
this.checkValidity();
|
|
191
177
|
this.checkError();
|
|
178
|
+
this.hasError = this.invalid;
|
|
192
179
|
}
|
|
193
180
|
/*************
|
|
194
181
|
* Lifecycle *
|
|
@@ -199,8 +186,14 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
199
186
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
200
187
|
*/
|
|
201
188
|
componentWillLoad() {
|
|
202
|
-
//
|
|
189
|
+
// Get locales
|
|
190
|
+
this.messages = initLocales(this.element).messages;
|
|
191
|
+
// Validate
|
|
203
192
|
this.validateItems(this.items);
|
|
193
|
+
// Set default placeholder
|
|
194
|
+
if (this.placeholder === undefined || this.placeholder === '') {
|
|
195
|
+
this.placeholder = this.messages.input.select.placeholder;
|
|
196
|
+
}
|
|
204
197
|
// Check validity when component is ready
|
|
205
198
|
// return a promise to process action only in the FIRST render().
|
|
206
199
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
@@ -214,9 +207,10 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
214
207
|
* @returns {HTMLElement} HTML Element
|
|
215
208
|
*/
|
|
216
209
|
render() {
|
|
217
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly,
|
|
210
|
+
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: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
218
211
|
h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(option => option.group !== undefined ? (h("optgroup", { label: option.group }, option.options.map(optgroup => (h("option", { value: optgroup.title, selected: JSON.stringify(this.value) === JSON.stringify(optgroup.value), disabled: optgroup.disabled }, optgroup.title))))) : (h("option", { value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title))))));
|
|
219
212
|
}
|
|
213
|
+
get element() { return this; }
|
|
220
214
|
static get watchers() { return {
|
|
221
215
|
"value": ["handleValue"],
|
|
222
216
|
"items": ["validateItems"]
|
|
@@ -230,13 +224,13 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
230
224
|
"label": [1],
|
|
231
225
|
"labelOnTop": [4, "label-on-top"],
|
|
232
226
|
"labelHide": [4, "label-hide"],
|
|
233
|
-
"placeholder": [
|
|
227
|
+
"placeholder": [1025],
|
|
234
228
|
"placeholderHide": [4, "placeholder-hide"],
|
|
235
229
|
"placeholderDisabled": [4, "placeholder-disabled"],
|
|
236
230
|
"required": [4],
|
|
237
231
|
"readonly": [4],
|
|
238
232
|
"disabled": [4],
|
|
239
|
-
"
|
|
233
|
+
"mgWidth": [8, "mg-width"],
|
|
240
234
|
"tooltip": [1],
|
|
241
235
|
"helpText": [1, "help-text"],
|
|
242
236
|
"valid": [1028],
|
|
@@ -252,18 +246,13 @@ function defineCustomElement() {
|
|
|
252
246
|
if (typeof customElements === "undefined") {
|
|
253
247
|
return;
|
|
254
248
|
}
|
|
255
|
-
const components = ["mg-input-select", "mg-
|
|
249
|
+
const components = ["mg-input-select", "mg-icon", "mg-input-title", "mg-tooltip"];
|
|
256
250
|
components.forEach(tagName => { switch (tagName) {
|
|
257
251
|
case "mg-input-select":
|
|
258
252
|
if (!customElements.get(tagName)) {
|
|
259
253
|
customElements.define(tagName, MgInputSelect);
|
|
260
254
|
}
|
|
261
255
|
break;
|
|
262
|
-
case "mg-character-left":
|
|
263
|
-
if (!customElements.get(tagName)) {
|
|
264
|
-
defineCustomElement$4();
|
|
265
|
-
}
|
|
266
|
-
break;
|
|
267
256
|
case "mg-icon":
|
|
268
257
|
if (!customElements.get(tagName)) {
|
|
269
258
|
defineCustomElement$3();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { M as MgInput } from './MgInput.js';
|
|
3
3
|
import { c as createID, C as ClassList } from './components.utils.js';
|
|
4
|
-
import {
|
|
4
|
+
import { i as initLocales } from './index2.js';
|
|
5
5
|
import { d as defineCustomElement$4 } from './mg-character-left2.js';
|
|
6
6
|
import { d as defineCustomElement$3 } from './mg-icon2.js';
|
|
7
7
|
import { d as defineCustomElement$2 } from './mg-input-title2.js';
|
|
8
8
|
import { d as defineCustomElement$1 } from './mg-tooltip2.js';
|
|
9
9
|
|
|
10
|
-
const mgInputTextCss = ":host{display:block}.mg-input{display
|
|
10
|
+
const mgInputTextCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input.mg-input--has-icon .mg-input__with-character-left>mg-icon{position:absolute;top:50%;left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__with-character-left .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}.mg-input__with-character-left{position:relative;display:inline-flex;width:100%}.mg-input.is-focused .mg-input__with-character-left .mg-input__box{padding-right:calc(var(--mg-character-left-message-length) * 1ch + 0.8rem)}.mg-input__with-character-left mg-character-left{position:absolute;display:none;top:50%;right:1rem;opacity:0.6;transform:translateY(-50%);font-size:1.1rem}.mg-input.is-focused .mg-input__with-character-left mg-character-left{display:block}";
|
|
11
11
|
|
|
12
12
|
const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
13
13
|
constructor() {
|
|
@@ -21,8 +21,10 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
21
21
|
************/
|
|
22
22
|
// classes
|
|
23
23
|
this.classFocus = 'is-focused';
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
24
|
+
this.classIsInputGroupAppend = 'mg-input--is-input-group-append';
|
|
25
|
+
this.classHasIcon = 'mg-input--has-icon';
|
|
26
|
+
// hasError (triggered by blur event)
|
|
27
|
+
this.hasError = false;
|
|
26
28
|
/**
|
|
27
29
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
28
30
|
* If not set, it will be created.
|
|
@@ -60,7 +62,7 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
60
62
|
/**
|
|
61
63
|
* Define input width
|
|
62
64
|
*/
|
|
63
|
-
this.
|
|
65
|
+
this.mgWidth = 'full';
|
|
64
66
|
/**
|
|
65
67
|
* Define if component should display character left
|
|
66
68
|
*/
|
|
@@ -76,6 +78,9 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
76
78
|
*/
|
|
77
79
|
this.handleInput = () => {
|
|
78
80
|
this.checkValidity();
|
|
81
|
+
if (this.hasError) {
|
|
82
|
+
this.checkError();
|
|
83
|
+
}
|
|
79
84
|
this.value = this.input.value;
|
|
80
85
|
};
|
|
81
86
|
/**
|
|
@@ -96,9 +101,8 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
96
101
|
// Manage focus
|
|
97
102
|
this.classList.delete(this.classFocus);
|
|
98
103
|
this.classList = new ClassList(this.classList.classes);
|
|
99
|
-
//
|
|
100
|
-
this.
|
|
101
|
-
this.checkError();
|
|
104
|
+
// Display Error
|
|
105
|
+
this.displayError();
|
|
102
106
|
};
|
|
103
107
|
/**
|
|
104
108
|
* Check if input is valid
|
|
@@ -129,14 +133,7 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
129
133
|
}
|
|
130
134
|
// required
|
|
131
135
|
else if (!this.valid && this.input.validity.valueMissing) {
|
|
132
|
-
this.errorMessage = messages.errors.required;
|
|
133
|
-
}
|
|
134
|
-
// Update class
|
|
135
|
-
if (this.valid) {
|
|
136
|
-
this.classList.delete(this.classError);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
this.classList.add(this.classError);
|
|
136
|
+
this.errorMessage = this.messages.errors.required;
|
|
140
137
|
}
|
|
141
138
|
};
|
|
142
139
|
/**
|
|
@@ -160,10 +157,10 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
160
157
|
this.validateAppendSlot = () => {
|
|
161
158
|
const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
|
|
162
159
|
if (slotAppendInput.length === 1) {
|
|
163
|
-
this.classList.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.
|
|
160
|
+
this.classList.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.classIsInputGroupAppend : 'mg-input--is-append-input-slot-content');
|
|
164
161
|
}
|
|
165
162
|
else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
|
|
166
|
-
this.classList.add(this.
|
|
163
|
+
this.classList.add(this.classIsInputGroupAppend);
|
|
167
164
|
this.classList.add('mg-input--has-buttons-group-append');
|
|
168
165
|
}
|
|
169
166
|
};
|
|
@@ -171,6 +168,14 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
171
168
|
handleValue(newValue) {
|
|
172
169
|
this.valueChange.emit(newValue);
|
|
173
170
|
}
|
|
171
|
+
validateIcon(newValue) {
|
|
172
|
+
if (newValue !== undefined) {
|
|
173
|
+
this.classList.add(this.classHasIcon);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
this.classList.delete(this.classHasIcon);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
174
179
|
/**
|
|
175
180
|
* Public method to play input focus
|
|
176
181
|
*
|
|
@@ -187,6 +192,7 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
187
192
|
async displayError() {
|
|
188
193
|
this.checkValidity();
|
|
189
194
|
this.checkError();
|
|
195
|
+
this.hasError = this.invalid;
|
|
190
196
|
}
|
|
191
197
|
/*************
|
|
192
198
|
* Lifecycle *
|
|
@@ -197,9 +203,11 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
197
203
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
198
204
|
*/
|
|
199
205
|
componentWillLoad() {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
206
|
+
// Get locales
|
|
207
|
+
this.messages = initLocales(this.element).messages;
|
|
208
|
+
this.characterLeftId = `${this.identifier}-character-left`;
|
|
209
|
+
// Validate
|
|
210
|
+
this.validateIcon(this.icon);
|
|
203
211
|
this.validatePattern();
|
|
204
212
|
this.validateAppendSlot();
|
|
205
213
|
// Check validity when component is ready
|
|
@@ -215,11 +223,16 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
215
223
|
* @returns {HTMLElement} HTML Element
|
|
216
224
|
*/
|
|
217
225
|
render() {
|
|
218
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly,
|
|
226
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("div", { class: "mg-input__with-character-left", style: {
|
|
227
|
+
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
228
|
+
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
229
|
+
: 0).toString(),
|
|
230
|
+
} }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type, class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), this.displayCharacterLeft && this.maxlength && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), h("slot", { name: "append-input" })));
|
|
219
231
|
}
|
|
220
232
|
get element() { return this; }
|
|
221
233
|
static get watchers() { return {
|
|
222
|
-
"value": ["handleValue"]
|
|
234
|
+
"value": ["handleValue"],
|
|
235
|
+
"icon": ["validateIcon"]
|
|
223
236
|
}; }
|
|
224
237
|
static get style() { return mgInputTextCss; }
|
|
225
238
|
}, [1, "mg-input-text", {
|
|
@@ -236,12 +249,11 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
236
249
|
"required": [4],
|
|
237
250
|
"readonly": [4],
|
|
238
251
|
"disabled": [4],
|
|
239
|
-
"
|
|
252
|
+
"mgWidth": [8, "mg-width"],
|
|
240
253
|
"pattern": [1],
|
|
241
254
|
"patternErrorMessage": [1, "pattern-error-message"],
|
|
242
255
|
"tooltip": [1],
|
|
243
256
|
"displayCharacterLeft": [4, "display-character-left"],
|
|
244
|
-
"characterLeftTemplate": [1, "character-left-template"],
|
|
245
257
|
"helpText": [1, "help-text"],
|
|
246
258
|
"valid": [1028],
|
|
247
259
|
"invalid": [1028],
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { M as MgInput } from './MgInput.js';
|
|
3
3
|
import { c as createID, C as ClassList } from './components.utils.js';
|
|
4
|
-
import {
|
|
4
|
+
import { i as initLocales } from './index2.js';
|
|
5
5
|
import { d as defineCustomElement$5 } from './mg-character-left2.js';
|
|
6
6
|
import { d as defineCustomElement$4 } from './mg-icon2.js';
|
|
7
7
|
import { d as defineCustomElement$3 } from './mg-input-title2.js';
|
|
8
8
|
import { d as defineCustomElement$2 } from './mg-tooltip2.js';
|
|
9
9
|
|
|
10
|
-
const mgInputTextareaCss = ":host{display:block}.mg-input{display
|
|
10
|
+
const mgInputTextareaCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{display:block;height:auto;resize:none}.mg-input .mg-input__box.mg-input__box--resizable{resize:both}.mg-input .mg-input__box.mg-input__box--resizable-horizontal{resize:horizontal}.mg-input .mg-input__box.mg-input__box--resizable-vertical{resize:vertical}.mg-input__with-character-left{width:100%}.mg-input__with-character-left mg-character-left{display:block;visibility:hidden;margin-top:0.2rem;text-align:end}.mg-input.is-focused .mg-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
|
|
11
11
|
|
|
12
12
|
const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
13
13
|
constructor() {
|
|
@@ -21,7 +21,9 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
21
21
|
************/
|
|
22
22
|
// classes
|
|
23
23
|
this.classFocus = 'is-focused';
|
|
24
|
-
this.
|
|
24
|
+
this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
|
|
25
|
+
// hasError (triggered by blur event)
|
|
26
|
+
this.hasError = false;
|
|
25
27
|
/**
|
|
26
28
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
27
29
|
* If not set, it will be created.
|
|
@@ -55,15 +57,19 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
55
57
|
/**
|
|
56
58
|
* Define input width
|
|
57
59
|
*/
|
|
58
|
-
this.
|
|
60
|
+
this.mgWidth = 'full';
|
|
59
61
|
/**
|
|
60
|
-
* Define
|
|
62
|
+
* Define the number of visible text lines for the control
|
|
61
63
|
*/
|
|
62
64
|
this.rows = 3;
|
|
63
65
|
/**
|
|
64
66
|
* Define if component should display character left
|
|
65
67
|
*/
|
|
66
68
|
this.displayCharacterLeft = true;
|
|
69
|
+
/**
|
|
70
|
+
* Define if input is resizable
|
|
71
|
+
*/
|
|
72
|
+
this.resizable = 'none';
|
|
67
73
|
/**
|
|
68
74
|
* Component classes
|
|
69
75
|
*/
|
|
@@ -72,6 +78,10 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
72
78
|
* Handle input event
|
|
73
79
|
*/
|
|
74
80
|
this.handleInput = () => {
|
|
81
|
+
if (this.hasError) {
|
|
82
|
+
this.checkValidity();
|
|
83
|
+
this.checkError();
|
|
84
|
+
}
|
|
75
85
|
this.value = this.input.value;
|
|
76
86
|
};
|
|
77
87
|
/**
|
|
@@ -88,9 +98,8 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
88
98
|
// Manage focus
|
|
89
99
|
this.classList.delete(this.classFocus);
|
|
90
100
|
this.classList = new ClassList(this.classList.classes);
|
|
91
|
-
//
|
|
92
|
-
this.
|
|
93
|
-
this.checkError();
|
|
101
|
+
// Display Error
|
|
102
|
+
this.displayError();
|
|
94
103
|
};
|
|
95
104
|
/**
|
|
96
105
|
* Get pattern validity
|
|
@@ -124,14 +133,7 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
124
133
|
}
|
|
125
134
|
// required
|
|
126
135
|
else if (!this.valid && this.input.validity.valueMissing) {
|
|
127
|
-
this.errorMessage = messages.errors.required;
|
|
128
|
-
}
|
|
129
|
-
// Update class
|
|
130
|
-
if (this.valid) {
|
|
131
|
-
this.classList.delete(this.classError);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
this.classList.add(this.classError);
|
|
136
|
+
this.errorMessage = this.messages.errors.required;
|
|
135
137
|
}
|
|
136
138
|
};
|
|
137
139
|
/**
|
|
@@ -150,6 +152,14 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
150
152
|
this.checkValidity();
|
|
151
153
|
this.valueChange.emit(newValue);
|
|
152
154
|
}
|
|
155
|
+
validateDisplayCharacterLeft(newValue) {
|
|
156
|
+
if (newValue) {
|
|
157
|
+
this.classList.add(this.classHasDisplayCharacterLeft);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
this.classList.delete(this.classHasDisplayCharacterLeft);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
153
163
|
/**
|
|
154
164
|
* Public method to display errors
|
|
155
165
|
*
|
|
@@ -158,6 +168,7 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
158
168
|
async displayError() {
|
|
159
169
|
this.checkValidity();
|
|
160
170
|
this.checkError();
|
|
171
|
+
this.hasError = this.invalid;
|
|
161
172
|
}
|
|
162
173
|
/*************
|
|
163
174
|
* Lifecycle *
|
|
@@ -168,6 +179,11 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
168
179
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
169
180
|
*/
|
|
170
181
|
componentWillLoad() {
|
|
182
|
+
// Get locales
|
|
183
|
+
this.messages = initLocales(this.element).messages;
|
|
184
|
+
this.characterLeftId = `${this.identifier}-character-left`;
|
|
185
|
+
// Validate
|
|
186
|
+
this.validateDisplayCharacterLeft(this.displayCharacterLeft);
|
|
171
187
|
this.validatePattern();
|
|
172
188
|
// Check validity when component is ready
|
|
173
189
|
// return a promise to process action only in the FIRST render().
|
|
@@ -182,10 +198,17 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
182
198
|
* @returns {HTMLElement} HTML Element
|
|
183
199
|
*/
|
|
184
200
|
render() {
|
|
185
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly,
|
|
201
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("div", { class: "mg-input__with-character-left" }, h("textarea", { class: {
|
|
202
|
+
'mg-input__box': true,
|
|
203
|
+
'mg-input__box--resizable': this.resizable === 'both',
|
|
204
|
+
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
205
|
+
'mg-input__box--resizable-vertical': this.resizable === 'vertical',
|
|
206
|
+
}, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), this.displayCharacterLeft && this.maxlength && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
|
|
186
207
|
}
|
|
208
|
+
get element() { return this; }
|
|
187
209
|
static get watchers() { return {
|
|
188
|
-
"value": ["handleValue"]
|
|
210
|
+
"value": ["handleValue"],
|
|
211
|
+
"displayCharacterLeft": ["validateDisplayCharacterLeft"]
|
|
189
212
|
}; }
|
|
190
213
|
static get style() { return mgInputTextareaCss; }
|
|
191
214
|
}, [1, "mg-input-textarea", {
|
|
@@ -200,16 +223,16 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
200
223
|
"required": [4],
|
|
201
224
|
"readonly": [4],
|
|
202
225
|
"disabled": [4],
|
|
203
|
-
"
|
|
226
|
+
"mgWidth": [8, "mg-width"],
|
|
204
227
|
"pattern": [1],
|
|
205
228
|
"patternErrorMessage": [1, "pattern-error-message"],
|
|
206
229
|
"rows": [2],
|
|
207
230
|
"tooltip": [1],
|
|
208
231
|
"displayCharacterLeft": [4, "display-character-left"],
|
|
209
|
-
"characterLeftTemplate": [1, "character-left-template"],
|
|
210
232
|
"helpText": [1, "help-text"],
|
|
211
233
|
"valid": [1028],
|
|
212
234
|
"invalid": [1028],
|
|
235
|
+
"resizable": [1],
|
|
213
236
|
"classList": [32],
|
|
214
237
|
"errorMessage": [32],
|
|
215
238
|
"displayError": [64]
|