@mgdis/mg-components 3.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-85a4a0b6.js → index-88560a66.js} +123 -48
- package/dist/cjs/index-a39c5567.js +233 -0
- package/dist/cjs/loader.cjs.js +3 -17
- package/dist/cjs/mg-badge_21.cjs.entry.js +3538 -0
- package/dist/cjs/mg-components.cjs.js +3 -7
- package/dist/cjs/mg-modal.cjs.entry.js +117 -0
- package/dist/cjs/mg-popover.cjs.entry.js +170 -0
- package/dist/cjs/popper-71bf3058.js +1790 -0
- package/dist/collection/collection-manifest.json +4 -1
- package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +4 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +26 -10
- package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +7 -2
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.css +46 -49
- package/dist/collection/components/atoms/mg-button/mg-button.js +78 -4
- package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +8 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +20 -46
- package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +104 -9
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +9 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +33 -7
- package/dist/collection/components/atoms/mg-input-title/{mg-input-title.stories.js → doc/mg-input-title.stories.js} +0 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +4 -4
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +14 -3
- package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +4 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +28 -6
- package/dist/collection/components/atoms/mg-tooltip/{mg-tooltip.stories.js → doc/mg-tooltip.stories.js} +14 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +20 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +16 -2
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
- package/dist/collection/components/molecules/inputs/MgInput.js +25 -29
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +25 -11
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +102 -52
- package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +37 -9
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +136 -66
- package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +15 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +38 -10
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +180 -80
- package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +16 -2
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +37 -9
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +108 -47
- package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +25 -11
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +113 -42
- package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +22 -2
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +39 -10
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +145 -71
- package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +17 -8
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +69 -19
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +184 -83
- package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +16 -5
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +69 -13
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +163 -70
- package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +22 -10
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +68 -33
- package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +58 -0
- package/dist/collection/components/molecules/mg-form/mg-form.css +19 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +271 -0
- package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +6 -2
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +26 -11
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +51 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +52 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +240 -0
- package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +47 -28
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +39 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +53 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +356 -0
- package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +10 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +37 -12
- package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +20 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +11 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +17 -3
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +139 -26
- package/dist/collection/locales/index.js +33 -4
- package/dist/collection/stories/helpers.stories.js +33 -0
- package/dist/collection/utils/components.utils.js +16 -9
- package/dist/collection/utils/locale.utils.js +13 -7
- package/dist/collection/utils/test.utils.js +27 -15
- package/dist/collection/variables.css +39 -5
- package/dist/collection/variables.scss +39 -5
- package/dist/components/MgInput.js +26 -37
- package/dist/components/components.utils.js +16 -9
- package/dist/components/index.d.ts +24 -6
- package/dist/components/index.js +23 -0
- package/dist/components/index2.js +116 -17
- package/dist/components/locale.utils.js +13 -8
- package/dist/components/mg-badge2.js +25 -9
- package/dist/components/mg-button2.js +29 -5
- package/dist/components/mg-character-left2.js +14 -26
- package/dist/components/mg-form.d.ts +11 -0
- package/dist/components/mg-form.js +148 -0
- package/dist/components/mg-icon2.js +138 -17
- package/dist/components/mg-input-checkbox.js +66 -53
- package/dist/components/mg-input-date.js +100 -69
- package/dist/components/mg-input-numeric.js +125 -81
- package/dist/components/mg-input-password.js +69 -48
- package/dist/components/mg-input-radio.js +74 -46
- package/dist/components/mg-input-select2.js +103 -71
- package/dist/components/mg-input-text.js +1 -237
- package/dist/components/mg-input-text2.js +300 -0
- package/dist/components/mg-input-textarea.js +100 -46
- package/dist/components/mg-input-title2.js +13 -4
- package/dist/components/mg-input-toggle.js +39 -31
- package/dist/components/mg-message.js +25 -10
- package/dist/components/mg-modal.d.ts +11 -0
- package/dist/components/mg-modal.js +153 -0
- package/dist/components/mg-pagination.js +45 -31
- package/dist/components/mg-panel.d.ts +11 -0
- package/dist/components/mg-panel.js +244 -0
- package/dist/components/mg-popover.js +31 -11
- package/dist/components/mg-tabs.js +113 -23
- package/dist/components/mg-tag.js +27 -5
- package/dist/components/mg-tooltip2.js +10 -1
- package/dist/components/popper.js +6 -2
- package/dist/esm/{index-e3e84606.js → index-bca81100.js} +124 -46
- package/dist/esm/index-e51ae032.js +228 -0
- package/dist/esm/loader.js +3 -17
- package/dist/esm/mg-badge_21.entry.js +3514 -0
- package/dist/esm/mg-components.js +3 -7
- package/dist/esm/mg-modal.entry.js +113 -0
- package/dist/esm/mg-popover.entry.js +166 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/popper-93ecb064.js +1788 -0
- package/dist/index.js +1 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-003a1344.entry.js +1 -0
- package/dist/mg-components/p-462d648a.entry.js +1 -0
- package/dist/mg-components/p-4c66f794.js +1 -0
- package/dist/mg-components/p-5126ab10.entry.js +1 -0
- package/dist/mg-components/p-780bd52d.js +1 -0
- package/dist/mg-components/p-b14a3443.js +2 -0
- package/dist/mg-components/variables.css +39 -5
- package/dist/mg-components/variables.scss +39 -5
- package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +16 -5
- package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +23 -3
- package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +9 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +16 -13
- package/dist/types/components/atoms/mg-icon/{mg-icon.stories.d.ts → doc/mg-icon.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +14 -4
- package/dist/types/components/atoms/mg-input-title/{mg-input-title.stories.d.ts → doc/mg-input-title.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
- package/dist/types/components/atoms/mg-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +18 -4
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +29 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +13 -3
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +6 -4
- package/dist/types/components/molecules/inputs/MgInput.d.ts +7 -8
- package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +36 -13
- package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +46 -15
- package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +11 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +61 -16
- package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +22 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +35 -11
- package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +42 -9
- package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +34 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +37 -9
- package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +13 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +52 -16
- package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +45 -17
- package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +29 -12
- package/dist/types/components/molecules/{mg-popover/mg-popover.stories.d.ts → mg-form/doc/mg-form.stories.d.ts} +3 -4
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +83 -0
- package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +10 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +13 -4
- package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +13 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +85 -0
- package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +5 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +31 -7
- package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +139 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +25 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +8 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +27 -4
- package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +20 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +11 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +70 -6
- package/dist/types/components.d.ts +528 -211
- package/dist/types/locales/index.d.ts +108 -38
- package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
- package/dist/types/utils/components.utils.d.ts +16 -9
- package/dist/types/utils/locale.utils.d.ts +13 -6
- package/dist/types/utils/test.utils.d.ts +13 -1
- package/loader/index.js +1 -1
- package/package.json +45 -14
- package/readme.md +9 -35
- package/dist/cjs/css-shim-a22512c4.js +0 -6
- package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
- package/dist/cjs/shadow-css-8940f82d.js +0 -390
- package/dist/collection/stories/buttons.stories.js +0 -43
- package/dist/collection/stories/messages.stories.js +0 -44
- package/dist/collection/stories/tags.stories.js +0 -13
- package/dist/esm/css-shim-7c240feb.js +0 -4
- package/dist/esm/mg-badge_20.entry.js +0 -4638
- package/dist/esm/shadow-css-5d2d01ce.js +0 -388
- package/dist/esm-es5/css-shim-7c240feb.js +0 -1
- package/dist/esm-es5/index-e3e84606.js +0 -1
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +0 -1
- package/dist/esm-es5/mg-badge_20.entry.js +0 -2
- package/dist/esm-es5/mg-components.js +0 -1
- package/dist/esm-es5/shadow-css-5d2d01ce.js +0 -12
- package/dist/mg-components/mg-components.js +0 -132
- package/dist/mg-components/p-1cd24462.system.js +0 -1
- package/dist/mg-components/p-2e2f6b27.system.entry.js +0 -2
- package/dist/mg-components/p-366a224e.js +0 -1
- package/dist/mg-components/p-422c429b.system.js +0 -1
- package/dist/mg-components/p-50ea2036.system.js +0 -1
- package/dist/mg-components/p-62fa3797.js +0 -1
- package/dist/mg-components/p-71d57b8b.system.js +0 -13
- package/dist/mg-components/p-9a215712.system.js +0 -1
- package/dist/mg-components/p-cbf0464b.entry.js +0 -1
- package/dist/mg-components/p-f6455ab3.js +0 -12
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +0 -9
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +0 -14
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +0 -7
- package/dist/types/stories/messages.stories.d.ts +0 -13
- package/dist/types/stories/tags.stories.d.ts +0 -5
|
@@ -1,37 +1,38 @@
|
|
|
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
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
13
|
+
*
|
|
14
|
+
* @param {SelectOption} option select option
|
|
15
|
+
* @returns {boolean} select option type is valid
|
|
16
16
|
*/
|
|
17
|
-
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string'
|
|
17
|
+
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
18
18
|
/**
|
|
19
19
|
* Group options
|
|
20
|
-
*
|
|
21
|
-
* @param {SelectOption}
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {string} item.
|
|
24
|
-
* @param {
|
|
25
|
-
* @param {
|
|
26
|
-
* @
|
|
20
|
+
*
|
|
21
|
+
* @param {(SelectOption | OptGroup)[]} acc reduce accumulator
|
|
22
|
+
* @param {SelectOption} item item to add
|
|
23
|
+
* @param {string} item.group item group
|
|
24
|
+
* @param {string} item.title item title
|
|
25
|
+
* @param {unknown} item.value item value
|
|
26
|
+
* @param {boolean} item.disabled is item disabled
|
|
27
|
+
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
27
28
|
*/
|
|
28
29
|
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
29
30
|
if (group !== undefined) {
|
|
30
31
|
// Check if group is already created
|
|
31
|
-
const
|
|
32
|
+
const optGroup = acc.find(grp => grp.group === group);
|
|
32
33
|
// Add to group
|
|
33
|
-
if (
|
|
34
|
-
|
|
34
|
+
if (optGroup !== undefined) {
|
|
35
|
+
optGroup.options.push({ title, value, disabled });
|
|
35
36
|
}
|
|
36
37
|
// Create group
|
|
37
38
|
else {
|
|
@@ -49,11 +50,9 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
49
50
|
this.__registerHost();
|
|
50
51
|
this.__attachShadow();
|
|
51
52
|
this.valueChange = createEvent(this, "value-change", 7);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// classes
|
|
56
|
-
this.classError = InputClass.ERROR;
|
|
53
|
+
this.inputValid = createEvent(this, "input-valid", 7);
|
|
54
|
+
// hasError (triggered by blur event)
|
|
55
|
+
this.hasError = false;
|
|
57
56
|
/**
|
|
58
57
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
59
58
|
* If not set, it will be created.
|
|
@@ -68,11 +67,6 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
68
67
|
* Define if label is visible
|
|
69
68
|
*/
|
|
70
69
|
this.labelHide = false;
|
|
71
|
-
/**
|
|
72
|
-
* Input placeholder.
|
|
73
|
-
* It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.
|
|
74
|
-
*/
|
|
75
|
-
this.placeholder = messages.input.select.placeholder;
|
|
76
70
|
/**
|
|
77
71
|
* Option to remove placeholder
|
|
78
72
|
*/
|
|
@@ -102,28 +96,66 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
102
96
|
*/
|
|
103
97
|
this.handleInput = () => {
|
|
104
98
|
this.checkValidity();
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
if (this.hasError) {
|
|
100
|
+
this.checkError();
|
|
101
|
+
}
|
|
102
|
+
if (this.input.value !== '') {
|
|
103
|
+
this.value = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
this.value = null;
|
|
107
|
+
}
|
|
107
108
|
};
|
|
108
109
|
/**
|
|
109
110
|
* Handle blur event
|
|
110
111
|
*/
|
|
111
112
|
this.handleBlur = () => {
|
|
112
|
-
this.
|
|
113
|
-
|
|
113
|
+
this.displayError();
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Check if input is valid
|
|
117
|
+
*/
|
|
118
|
+
this.checkValidity = () => {
|
|
119
|
+
if (!this.readonly && this.input !== undefined) {
|
|
120
|
+
const validity = this.input.checkValidity && this.input.checkValidity();
|
|
121
|
+
// Set validity
|
|
122
|
+
this.valid = validity;
|
|
123
|
+
this.invalid = !validity;
|
|
124
|
+
//Send event
|
|
125
|
+
this.inputValid.emit(validity);
|
|
126
|
+
}
|
|
114
127
|
};
|
|
128
|
+
/**
|
|
129
|
+
* Check input errors
|
|
130
|
+
*/
|
|
131
|
+
this.checkError = () => {
|
|
132
|
+
// Set error message
|
|
133
|
+
this.errorMessage = undefined;
|
|
134
|
+
if (!this.valid && this.input.validity.valueMissing) {
|
|
135
|
+
this.errorMessage = this.messages.errors.required;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
handleValue(newValue) {
|
|
140
|
+
if (newValue !== null) {
|
|
141
|
+
this.readonlyValue = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.value === newValue).title;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
this.readonlyValue = null;
|
|
145
|
+
}
|
|
146
|
+
this.valueChange.emit(newValue);
|
|
115
147
|
}
|
|
116
148
|
validateItems(newValue) {
|
|
117
149
|
// String array
|
|
118
150
|
if (allItemsAreString(newValue)) {
|
|
119
151
|
this.valueExist = newValue.includes(this.value);
|
|
120
|
-
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
152
|
+
this.options = newValue.map((item) => ({ title: item, value: item }));
|
|
121
153
|
}
|
|
122
154
|
// Object array
|
|
123
155
|
else if (newValue && newValue.every(item => isOption(item))) {
|
|
124
156
|
this.valueExist = newValue.map(item => item.value).includes(this.value);
|
|
125
157
|
// Grouped object options
|
|
126
|
-
if (newValue.some(
|
|
158
|
+
if (newValue.some(item => item.group !== undefined)) {
|
|
127
159
|
this.options = newValue.reduce(groupOptions, []);
|
|
128
160
|
}
|
|
129
161
|
// Standart object options
|
|
@@ -136,48 +168,51 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
136
168
|
}
|
|
137
169
|
}
|
|
138
170
|
/**
|
|
139
|
-
*
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (!this.readonly && this.input !== undefined) {
|
|
143
|
-
const validity = this.input.checkValidity && this.input.checkValidity();
|
|
144
|
-
// Set validity
|
|
145
|
-
this.valid = validity;
|
|
146
|
-
this.invalid = !validity;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Check input errors
|
|
171
|
+
* Public method to display errors
|
|
172
|
+
*
|
|
173
|
+
* @returns {Promise<void>}
|
|
151
174
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.
|
|
155
|
-
|
|
156
|
-
this.errorMessage = messages.errors.required;
|
|
157
|
-
}
|
|
158
|
-
// Update class
|
|
159
|
-
if (this.valid) {
|
|
160
|
-
this.classList.delete(this.classError);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
this.classList.add(this.classError);
|
|
164
|
-
}
|
|
175
|
+
async displayError() {
|
|
176
|
+
this.checkValidity();
|
|
177
|
+
this.checkError();
|
|
178
|
+
this.hasError = this.invalid;
|
|
165
179
|
}
|
|
166
180
|
/*************
|
|
167
181
|
* Lifecycle *
|
|
168
182
|
*************/
|
|
183
|
+
/**
|
|
184
|
+
* Check if component props are well configured on init
|
|
185
|
+
*
|
|
186
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
187
|
+
*/
|
|
169
188
|
componentWillLoad() {
|
|
170
|
-
//
|
|
189
|
+
// Get locales
|
|
190
|
+
this.messages = initLocales(this.element).messages;
|
|
191
|
+
// Validate
|
|
171
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
|
+
}
|
|
197
|
+
// Check validity when component is ready
|
|
172
198
|
// return a promise to process action only in the FIRST render().
|
|
173
199
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
174
|
-
return setTimeout(() =>
|
|
200
|
+
return setTimeout(() => {
|
|
201
|
+
this.checkValidity();
|
|
202
|
+
}, 0);
|
|
175
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Render
|
|
206
|
+
*
|
|
207
|
+
* @returns {HTMLElement} HTML Element
|
|
208
|
+
*/
|
|
176
209
|
render() {
|
|
177
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly,
|
|
178
|
-
h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(
|
|
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
|
|
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))))));
|
|
179
212
|
}
|
|
213
|
+
get element() { return this; }
|
|
180
214
|
static get watchers() { return {
|
|
215
|
+
"value": ["handleValue"],
|
|
181
216
|
"items": ["validateItems"]
|
|
182
217
|
}; }
|
|
183
218
|
static get style() { return mgInputSelectCss; }
|
|
@@ -189,13 +224,13 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
189
224
|
"label": [1],
|
|
190
225
|
"labelOnTop": [4, "label-on-top"],
|
|
191
226
|
"labelHide": [4, "label-hide"],
|
|
192
|
-
"placeholder": [
|
|
227
|
+
"placeholder": [1025],
|
|
193
228
|
"placeholderHide": [4, "placeholder-hide"],
|
|
194
229
|
"placeholderDisabled": [4, "placeholder-disabled"],
|
|
195
230
|
"required": [4],
|
|
196
231
|
"readonly": [4],
|
|
197
232
|
"disabled": [4],
|
|
198
|
-
"
|
|
233
|
+
"mgWidth": [8, "mg-width"],
|
|
199
234
|
"tooltip": [1],
|
|
200
235
|
"helpText": [1, "help-text"],
|
|
201
236
|
"valid": [1028],
|
|
@@ -203,24 +238,21 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
203
238
|
"classList": [32],
|
|
204
239
|
"errorMessage": [32],
|
|
205
240
|
"options": [32],
|
|
206
|
-
"valueExist": [32]
|
|
241
|
+
"valueExist": [32],
|
|
242
|
+
"readonlyValue": [32],
|
|
243
|
+
"displayError": [64]
|
|
207
244
|
}]);
|
|
208
245
|
function defineCustomElement() {
|
|
209
246
|
if (typeof customElements === "undefined") {
|
|
210
247
|
return;
|
|
211
248
|
}
|
|
212
|
-
const components = ["mg-input-select", "mg-
|
|
249
|
+
const components = ["mg-input-select", "mg-icon", "mg-input-title", "mg-tooltip"];
|
|
213
250
|
components.forEach(tagName => { switch (tagName) {
|
|
214
251
|
case "mg-input-select":
|
|
215
252
|
if (!customElements.get(tagName)) {
|
|
216
253
|
customElements.define(tagName, MgInputSelect);
|
|
217
254
|
}
|
|
218
255
|
break;
|
|
219
|
-
case "mg-character-left":
|
|
220
|
-
if (!customElements.get(tagName)) {
|
|
221
|
-
defineCustomElement$4();
|
|
222
|
-
}
|
|
223
|
-
break;
|
|
224
256
|
case "mg-icon":
|
|
225
257
|
if (!customElements.get(tagName)) {
|
|
226
258
|
defineCustomElement$3();
|
|
@@ -1,240 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { I as InputClass, M as MgInput } from './MgInput.js';
|
|
3
|
-
import { c as createID, C as ClassList } from './components.utils.js';
|
|
4
|
-
import { m as messages } from './index2.js';
|
|
5
|
-
import { d as defineCustomElement$5 } from './mg-character-left2.js';
|
|
6
|
-
import { d as defineCustomElement$4 } from './mg-icon2.js';
|
|
7
|
-
import { d as defineCustomElement$3 } from './mg-input-title2.js';
|
|
8
|
-
import { d as defineCustomElement$2 } from './mg-tooltip2.js';
|
|
9
|
-
|
|
10
|
-
const mgInputTextCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);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{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;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:-ms-inline-flexbox;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:-ms-inline-flexbox;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:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);-webkit-box-sizing:border-box;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)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);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--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){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;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{display:none}.mg-input.is-focused mg-character-left{display:block}.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__input{position:relative}.mg-input.mg-input--has-icon .mg-input__input>mg-icon{position:absolute;top:calc(var(--default-size) - var(--mg-icon-regular-size));left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);-webkit-transform:translateY(-50%);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__input .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}";
|
|
11
|
-
|
|
12
|
-
const MgInputText$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
13
|
-
constructor() {
|
|
14
|
-
super();
|
|
15
|
-
this.__registerHost();
|
|
16
|
-
this.__attachShadow();
|
|
17
|
-
this.valueChange = createEvent(this, "value-change", 7);
|
|
18
|
-
/************
|
|
19
|
-
* Internal *
|
|
20
|
-
************/
|
|
21
|
-
// classes
|
|
22
|
-
this.classFocus = 'is-focused';
|
|
23
|
-
this.classError = InputClass.ERROR;
|
|
24
|
-
/**
|
|
25
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
26
|
-
* If not set, it will be created.
|
|
27
|
-
*/
|
|
28
|
-
this.identifier = createID('mg-input-text');
|
|
29
|
-
/**
|
|
30
|
-
* Input name
|
|
31
|
-
* If not set the value equals the identifier
|
|
32
|
-
*/
|
|
33
|
-
this.name = this.identifier;
|
|
34
|
-
/**
|
|
35
|
-
* Input type
|
|
36
|
-
*/
|
|
37
|
-
this.type = 'text';
|
|
38
|
-
/**
|
|
39
|
-
* Define if label is visible
|
|
40
|
-
*/
|
|
41
|
-
this.labelHide = false;
|
|
42
|
-
/**
|
|
43
|
-
* Input max length
|
|
44
|
-
*/
|
|
45
|
-
this.maxlength = 400;
|
|
46
|
-
/**
|
|
47
|
-
* Define if input is required
|
|
48
|
-
*/
|
|
49
|
-
this.required = false;
|
|
50
|
-
/**
|
|
51
|
-
* Define if input is readonly
|
|
52
|
-
*/
|
|
53
|
-
this.readonly = false;
|
|
54
|
-
/**
|
|
55
|
-
* Define if input is disabled
|
|
56
|
-
*/
|
|
57
|
-
this.disabled = false;
|
|
58
|
-
/**
|
|
59
|
-
* Define input width
|
|
60
|
-
*/
|
|
61
|
-
this.width = 'full';
|
|
62
|
-
/**
|
|
63
|
-
* Define if component should display character left
|
|
64
|
-
*/
|
|
65
|
-
this.displayCharacterLeft = true;
|
|
66
|
-
/**
|
|
67
|
-
* Component classes
|
|
68
|
-
*/
|
|
69
|
-
this.classList = new ClassList(['mg-input--text']);
|
|
70
|
-
/**
|
|
71
|
-
* Handle input event
|
|
72
|
-
*/
|
|
73
|
-
this.handleInput = () => {
|
|
74
|
-
this.checkValidity();
|
|
75
|
-
this.value = this.input.value;
|
|
76
|
-
this.valueChange.emit(this.value);
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Handle focus event
|
|
80
|
-
*/
|
|
81
|
-
this.handleFocus = () => {
|
|
82
|
-
this.classList.add(this.classFocus);
|
|
83
|
-
this.classList = new ClassList(this.classList.classes);
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Handle blur event
|
|
87
|
-
*/
|
|
88
|
-
this.handleBlur = () => {
|
|
89
|
-
// Manage focus
|
|
90
|
-
this.classList.delete(this.classFocus);
|
|
91
|
-
this.classList = new ClassList(this.classList.classes);
|
|
92
|
-
// Check validity
|
|
93
|
-
this.checkValidity();
|
|
94
|
-
this.checkError();
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Validate patern configuration
|
|
98
|
-
*/
|
|
99
|
-
this.validatePattern = () => {
|
|
100
|
-
if (this.pattern &&
|
|
101
|
-
typeof this.pattern === 'string' &&
|
|
102
|
-
this.pattern !== '' &&
|
|
103
|
-
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
104
|
-
throw new Error('<mg-input-text> prop "pattern" must be paired with the prop "patternErrorMessage"');
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Check if input is valid
|
|
110
|
-
*/
|
|
111
|
-
checkValidity() {
|
|
112
|
-
if (!this.readonly && this.input !== undefined) {
|
|
113
|
-
const validity = this.input.checkValidity();
|
|
114
|
-
// Set validity
|
|
115
|
-
this.valid = validity;
|
|
116
|
-
this.invalid = !validity;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Check input errors
|
|
121
|
-
*/
|
|
122
|
-
checkError() {
|
|
123
|
-
// Set error message
|
|
124
|
-
this.errorMessage = undefined;
|
|
125
|
-
// Does not match pattern
|
|
126
|
-
if (!this.valid && this.input.validity.patternMismatch) {
|
|
127
|
-
this.errorMessage = this.patternErrorMessage;
|
|
128
|
-
}
|
|
129
|
-
// required
|
|
130
|
-
else if (!this.valid && this.input.validity.valueMissing) {
|
|
131
|
-
this.errorMessage = messages.errors.required;
|
|
132
|
-
}
|
|
133
|
-
// Update class
|
|
134
|
-
if (this.valid) {
|
|
135
|
-
this.classList.delete(this.classError);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
this.classList.add(this.classError);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Validate append slot
|
|
143
|
-
*/
|
|
144
|
-
validateAppendSlot() {
|
|
145
|
-
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
146
|
-
if (slotAppendInput !== null && slotAppendInput.querySelector('.mg-button') !== null) {
|
|
147
|
-
this.classList.add('mg-input--is-input-group-append');
|
|
148
|
-
this.classList = new ClassList(this.classList.classes);
|
|
149
|
-
}
|
|
150
|
-
else if (slotAppendInput !== null) {
|
|
151
|
-
this.classList.add('mg-input--is-append-input-slot-content');
|
|
152
|
-
this.classList = new ClassList(this.classList.classes);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/*************
|
|
156
|
-
* Lifecycle *
|
|
157
|
-
*************/
|
|
158
|
-
/**
|
|
159
|
-
* Check if component props are well configured on init
|
|
160
|
-
*/
|
|
161
|
-
componentWillLoad() {
|
|
162
|
-
if (this.icon !== undefined) {
|
|
163
|
-
this.classList.add('mg-input--has-icon');
|
|
164
|
-
}
|
|
165
|
-
this.validatePattern();
|
|
166
|
-
// return a promise to process action only in the FIRST render().
|
|
167
|
-
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
168
|
-
return setTimeout(() => this.checkValidity(), 0);
|
|
169
|
-
}
|
|
170
|
-
componentDidLoad() {
|
|
171
|
-
this.validateAppendSlot();
|
|
172
|
-
}
|
|
173
|
-
render() {
|
|
174
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, displayCharacterLeft: this.displayCharacterLeft, characterLeftTemplate: this.characterLeftTemplate, maxlength: this.maxlength, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, 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) }), h("slot", { name: "append-input" })));
|
|
175
|
-
}
|
|
176
|
-
get element() { return this; }
|
|
177
|
-
static get style() { return mgInputTextCss; }
|
|
178
|
-
}, [1, "mg-input-text", {
|
|
179
|
-
"value": [1537],
|
|
180
|
-
"identifier": [1],
|
|
181
|
-
"name": [1],
|
|
182
|
-
"label": [1],
|
|
183
|
-
"type": [1],
|
|
184
|
-
"icon": [1],
|
|
185
|
-
"labelOnTop": [4, "label-on-top"],
|
|
186
|
-
"labelHide": [4, "label-hide"],
|
|
187
|
-
"placeholder": [1],
|
|
188
|
-
"maxlength": [2],
|
|
189
|
-
"required": [4],
|
|
190
|
-
"readonly": [4],
|
|
191
|
-
"disabled": [4],
|
|
192
|
-
"width": [8],
|
|
193
|
-
"pattern": [1],
|
|
194
|
-
"patternErrorMessage": [1, "pattern-error-message"],
|
|
195
|
-
"tooltip": [1],
|
|
196
|
-
"displayCharacterLeft": [4, "display-character-left"],
|
|
197
|
-
"characterLeftTemplate": [1, "character-left-template"],
|
|
198
|
-
"helpText": [1, "help-text"],
|
|
199
|
-
"valid": [1028],
|
|
200
|
-
"invalid": [1028],
|
|
201
|
-
"classList": [32],
|
|
202
|
-
"errorMessage": [32]
|
|
203
|
-
}]);
|
|
204
|
-
function defineCustomElement$1() {
|
|
205
|
-
if (typeof customElements === "undefined") {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
const components = ["mg-input-text", "mg-character-left", "mg-icon", "mg-input-title", "mg-tooltip"];
|
|
209
|
-
components.forEach(tagName => { switch (tagName) {
|
|
210
|
-
case "mg-input-text":
|
|
211
|
-
if (!customElements.get(tagName)) {
|
|
212
|
-
customElements.define(tagName, MgInputText$1);
|
|
213
|
-
}
|
|
214
|
-
break;
|
|
215
|
-
case "mg-character-left":
|
|
216
|
-
if (!customElements.get(tagName)) {
|
|
217
|
-
defineCustomElement$5();
|
|
218
|
-
}
|
|
219
|
-
break;
|
|
220
|
-
case "mg-icon":
|
|
221
|
-
if (!customElements.get(tagName)) {
|
|
222
|
-
defineCustomElement$4();
|
|
223
|
-
}
|
|
224
|
-
break;
|
|
225
|
-
case "mg-input-title":
|
|
226
|
-
if (!customElements.get(tagName)) {
|
|
227
|
-
defineCustomElement$3();
|
|
228
|
-
}
|
|
229
|
-
break;
|
|
230
|
-
case "mg-tooltip":
|
|
231
|
-
if (!customElements.get(tagName)) {
|
|
232
|
-
defineCustomElement$2();
|
|
233
|
-
}
|
|
234
|
-
break;
|
|
235
|
-
} });
|
|
236
|
-
}
|
|
237
|
-
defineCustomElement$1();
|
|
1
|
+
import { M as MgInputText$1, d as defineCustomElement$1 } from './mg-input-text2.js';
|
|
238
2
|
|
|
239
3
|
const MgInputText = MgInputText$1;
|
|
240
4
|
const defineCustomElement = defineCustomElement$1;
|