@mgdis/mg-components 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +29 -0
- package/dist/cjs/css-shim-a22512c4.js +6 -0
- package/dist/cjs/index-85a4a0b6.js +1674 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +35 -0
- package/dist/cjs/mg-badge_20.cjs.entry.js +4661 -0
- package/dist/cjs/mg-components.cjs.js +23 -0
- package/dist/cjs/shadow-css-8940f82d.js +390 -0
- package/dist/collection/collection-manifest.json +31 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +4 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +99 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +148 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +27 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +134 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +236 -0
- package/dist/collection/components/atoms/mg-button/mg-button.stories.js +38 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.css +3 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +133 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +15 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +54 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +57 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +155 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.stories.js +34 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +12 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +95 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +21 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +4 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +73 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +94 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +25 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +44 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +225 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +26 -0
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +7 -0
- package/dist/collection/components/molecules/inputs/MgInput.js +130 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +156 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +444 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +57 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +7 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +171 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +467 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +46 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +11 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +199 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +633 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +68 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +195 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +401 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +43 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +156 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +443 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +65 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +201 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +532 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +70 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +222 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +589 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +115 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +217 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +553 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +52 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +213 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +457 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +73 -0
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js +4 -0
- package/dist/collection/components/molecules/mg-message/mg-message.css +94 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +285 -0
- package/dist/collection/components/molecules/mg-message/mg-message.stories.js +43 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +5 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +39 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +218 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +23 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +59 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +249 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.stories.js +36 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +30 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +212 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +40 -0
- package/dist/collection/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/collection/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/collection/fonts/Poppins-Bold.ttf +0 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/locales/index.js +4 -0
- package/dist/collection/stories/buttons.stories.js +43 -0
- package/dist/collection/stories/grids.stories.js +50 -0
- package/dist/collection/stories/icons.stories.js +20 -0
- package/dist/collection/stories/messages.stories.js +44 -0
- package/dist/collection/stories/tags.stories.js +13 -0
- package/dist/collection/stories/typography.stories.js +28 -0
- package/dist/collection/utils/components.utils.js +67 -0
- package/dist/collection/utils/locale.utils.js +32 -0
- package/dist/collection/utils/test.utils.js +26 -0
- package/dist/collection/variables.css +177 -0
- package/dist/collection/variables.scss +177 -0
- package/dist/components/MgInput.js +140 -0
- package/dist/components/components.utils.js +69 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +54 -0
- package/dist/components/locale.utils.js +35 -0
- package/dist/components/mg-badge.d.ts +11 -0
- package/dist/components/mg-badge.js +6 -0
- package/dist/components/mg-badge2.js +82 -0
- package/dist/components/mg-button.d.ts +11 -0
- package/dist/components/mg-button.js +6 -0
- package/dist/components/mg-button2.js +148 -0
- package/dist/components/mg-character-left.d.ts +11 -0
- package/dist/components/mg-character-left.js +6 -0
- package/dist/components/mg-character-left2.js +77 -0
- package/dist/components/mg-icon.d.ts +11 -0
- package/dist/components/mg-icon.js +6 -0
- package/dist/components/mg-icon2.js +147 -0
- package/dist/components/mg-input-checkbox.d.ts +11 -0
- package/dist/components/mg-input-checkbox.js +222 -0
- package/dist/components/mg-input-date.d.ts +11 -0
- package/dist/components/mg-input-date.js +245 -0
- package/dist/components/mg-input-numeric.d.ts +11 -0
- package/dist/components/mg-input-numeric.js +324 -0
- package/dist/components/mg-input-password.d.ts +11 -0
- package/dist/components/mg-input-password.js +171 -0
- package/dist/components/mg-input-radio.d.ts +11 -0
- package/dist/components/mg-input-radio.js +211 -0
- package/dist/components/mg-input-select.d.ts +11 -0
- package/dist/components/mg-input-select.js +6 -0
- package/dist/components/mg-input-select2.js +243 -0
- package/dist/components/mg-input-text.d.ts +11 -0
- package/dist/components/mg-input-text.js +242 -0
- package/dist/components/mg-input-textarea.d.ts +11 -0
- package/dist/components/mg-input-textarea.js +224 -0
- package/dist/components/mg-input-title.d.ts +11 -0
- package/dist/components/mg-input-title.js +6 -0
- package/dist/components/mg-input-title2.js +55 -0
- package/dist/components/mg-input-toggle.d.ts +11 -0
- package/dist/components/mg-input-toggle.js +247 -0
- package/dist/components/mg-message.d.ts +11 -0
- package/dist/components/mg-message.js +183 -0
- package/dist/components/mg-pagination.d.ts +11 -0
- package/dist/components/mg-pagination.js +175 -0
- package/dist/components/mg-popover.d.ts +11 -0
- package/dist/components/mg-popover.js +183 -0
- package/dist/components/mg-tabs.d.ts +11 -0
- package/dist/components/mg-tabs.js +160 -0
- package/dist/components/mg-tag.d.ts +11 -0
- package/dist/components/mg-tag.js +76 -0
- package/dist/components/mg-tooltip.d.ts +11 -0
- package/dist/components/mg-tooltip.js +6 -0
- package/dist/components/mg-tooltip2.js +150 -0
- package/dist/components/popper.js +1784 -0
- package/dist/esm/css-shim-7c240feb.js +4 -0
- package/dist/esm/index-e3e84606.js +1643 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +31 -0
- package/dist/esm/mg-badge_20.entry.js +4638 -0
- package/dist/esm/mg-components.js +21 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/shadow-css-5d2d01ce.js +388 -0
- package/dist/esm-es5/css-shim-7c240feb.js +1 -0
- package/dist/esm-es5/index-e3e84606.js +1 -0
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +1 -0
- package/dist/esm-es5/mg-badge_20.entry.js +2 -0
- package/dist/esm-es5/mg-components.js +1 -0
- package/dist/esm-es5/shadow-css-5d2d01ce.js +12 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/mg-components/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/mg-components/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/mg-components/fonts/Poppins-Bold.ttf +0 -0
- package/dist/mg-components/index.esm.js +0 -0
- package/dist/mg-components/mg-components.css +1 -0
- package/dist/mg-components/mg-components.esm.js +1 -0
- package/dist/mg-components/mg-components.js +132 -0
- package/dist/mg-components/p-1cd24462.system.js +1 -0
- package/dist/mg-components/p-2e2f6b27.system.entry.js +2 -0
- package/dist/mg-components/p-366a224e.js +1 -0
- package/dist/mg-components/p-422c429b.system.js +1 -0
- package/dist/mg-components/p-50ea2036.system.js +1 -0
- package/dist/mg-components/p-62fa3797.js +1 -0
- package/dist/mg-components/p-71d57b8b.system.js +13 -0
- package/dist/mg-components/p-9a215712.system.js +1 -0
- package/dist/mg-components/p-cbf0464b.entry.js +1 -0
- package/dist/mg-components/p-f6455ab3.js +12 -0
- package/dist/mg-components/variables.css +177 -0
- package/dist/mg-components/variables.scss +177 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +36 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +19 -0
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +4 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +67 -0
- package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +16 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +39 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +7 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +12 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +36 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.stories.d.ts +26 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +24 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +4 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +25 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +14 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +56 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +11 -0
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +10 -0
- package/dist/types/components/molecules/inputs/MgInput.d.ts +35 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +120 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +128 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +7 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +10 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +173 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +21 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +111 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +121 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +15 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +18 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +133 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +160 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +26 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +150 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +8 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +117 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +7 -0
- package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +4 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +76 -0
- package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +16 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.conf.d.ts +4 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +53 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +6 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +62 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +12 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +10 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +63 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +7 -0
- package/dist/types/components.d.ts +1987 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/locales/index.d.ts +44 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/stories/buttons.stories.d.ts +13 -0
- package/dist/types/stories/grids.stories.d.ts +5 -0
- package/dist/types/stories/icons.stories.d.ts +13 -0
- package/dist/types/stories/messages.stories.d.ts +13 -0
- package/dist/types/stories/tags.stories.d.ts +5 -0
- package/dist/types/stories/typography.stories.d.ts +5 -0
- package/dist/types/utils/components.utils.d.ts +43 -0
- package/dist/types/utils/locale.utils.d.ts +22 -0
- package/dist/types/utils/test.utils.d.ts +5 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +86 -0
- package/readme.md +159 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
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 { a as localeCurrency, b as localeNumber } from './locale.utils.js';
|
|
6
|
+
import { d as defineCustomElement$5 } from './mg-character-left2.js';
|
|
7
|
+
import { d as defineCustomElement$4 } from './mg-icon2.js';
|
|
8
|
+
import { d as defineCustomElement$3 } from './mg-input-title2.js';
|
|
9
|
+
import { d as defineCustomElement$2 } from './mg-tooltip2.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* List of all possibles types
|
|
13
|
+
*/
|
|
14
|
+
const types = ['decimal', 'integer', 'currency'];
|
|
15
|
+
var InputError;
|
|
16
|
+
(function (InputError) {
|
|
17
|
+
InputError["MIN"] = "min";
|
|
18
|
+
InputError["MAX"] = "max";
|
|
19
|
+
InputError["MINMAX"] = "minMax";
|
|
20
|
+
InputError["REQUIRED"] = "required";
|
|
21
|
+
})(InputError || (InputError = {}));
|
|
22
|
+
|
|
23
|
+
const mgInputNumericCss = ":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}.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{text-align:right}";
|
|
24
|
+
|
|
25
|
+
const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this.__registerHost();
|
|
29
|
+
this.__attachShadow();
|
|
30
|
+
this.valueChange = createEvent(this, "value-change", 7);
|
|
31
|
+
// Classes
|
|
32
|
+
this.classError = InputClass.ERROR;
|
|
33
|
+
/**
|
|
34
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
35
|
+
* If not set, it will be created.
|
|
36
|
+
*/
|
|
37
|
+
this.identifier = createID('mg-input-numeric');
|
|
38
|
+
/**
|
|
39
|
+
* Input name
|
|
40
|
+
* If not set the value equals the identifier
|
|
41
|
+
*/
|
|
42
|
+
this.name = this.identifier;
|
|
43
|
+
/**
|
|
44
|
+
* Define if label is visible
|
|
45
|
+
*/
|
|
46
|
+
this.labelHide = false;
|
|
47
|
+
/**
|
|
48
|
+
* Define if input is required
|
|
49
|
+
*/
|
|
50
|
+
this.required = false;
|
|
51
|
+
/**
|
|
52
|
+
* Define if input is readonly
|
|
53
|
+
*/
|
|
54
|
+
this.readonly = false;
|
|
55
|
+
/**
|
|
56
|
+
* Define if input is disabled
|
|
57
|
+
*/
|
|
58
|
+
this.disabled = false;
|
|
59
|
+
/**
|
|
60
|
+
* Define numeric type
|
|
61
|
+
*/
|
|
62
|
+
this.type = types[0];
|
|
63
|
+
/**
|
|
64
|
+
* Override integer length
|
|
65
|
+
* integer is the number before the decimal point
|
|
66
|
+
*/
|
|
67
|
+
this.integerLength = 13;
|
|
68
|
+
/**
|
|
69
|
+
* Override decimal length
|
|
70
|
+
* decimal is the number after the decimal point
|
|
71
|
+
*/
|
|
72
|
+
this.decimalLength = 2;
|
|
73
|
+
/**
|
|
74
|
+
* Component classes
|
|
75
|
+
*/
|
|
76
|
+
this.classList = new ClassList(['mg-input--numeric']);
|
|
77
|
+
/**
|
|
78
|
+
* Handle input event
|
|
79
|
+
*/
|
|
80
|
+
this.handleInput = () => {
|
|
81
|
+
// Check validity
|
|
82
|
+
this.checkValidity();
|
|
83
|
+
this.value = this.input.value;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Handle focus event
|
|
87
|
+
*/
|
|
88
|
+
this.handleFocus = () => {
|
|
89
|
+
this.displayValue = this.value;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Handle blur event
|
|
93
|
+
*/
|
|
94
|
+
this.handleBlur = () => {
|
|
95
|
+
// Check validity
|
|
96
|
+
this.checkValidity();
|
|
97
|
+
this.checkError();
|
|
98
|
+
// Display readonly value
|
|
99
|
+
this.displayValue = this.readonlyValue;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* get input error code
|
|
103
|
+
* @returns {null | InputError}
|
|
104
|
+
*/
|
|
105
|
+
this.getInputError = () => {
|
|
106
|
+
let inputError = null;
|
|
107
|
+
if (this.input === undefined)
|
|
108
|
+
return inputError;
|
|
109
|
+
// required
|
|
110
|
+
if (!this.input.checkValidity() && this.input.validity.valueMissing) {
|
|
111
|
+
inputError = InputError.REQUIRED;
|
|
112
|
+
}
|
|
113
|
+
// Min & Max
|
|
114
|
+
if (this.min !== undefined && this.numericValue < this.min && this.max === undefined) {
|
|
115
|
+
// Only a min value is set
|
|
116
|
+
inputError = InputError.MIN;
|
|
117
|
+
}
|
|
118
|
+
else if (this.max !== undefined && this.numericValue > this.max && this.min === undefined) {
|
|
119
|
+
// Only a max value is set
|
|
120
|
+
inputError = InputError.MAX;
|
|
121
|
+
}
|
|
122
|
+
else if ((this.min !== undefined && this.numericValue < this.min) || (this.max !== undefined && this.numericValue > this.max)) {
|
|
123
|
+
// both min and max values are set
|
|
124
|
+
inputError = InputError.MINMAX;
|
|
125
|
+
}
|
|
126
|
+
return inputError;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Format value based on type
|
|
130
|
+
* @param value {number}
|
|
131
|
+
* @returns {string} formated local value
|
|
132
|
+
*/
|
|
133
|
+
this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value) : localeNumber(value));
|
|
134
|
+
}
|
|
135
|
+
validateValue(newValue) {
|
|
136
|
+
if (newValue !== undefined && newValue !== null) {
|
|
137
|
+
// Split number and decimal
|
|
138
|
+
const [integer, decimal = ''] = newValue.replace('-', '').split(/[\.,]/);
|
|
139
|
+
// Regex
|
|
140
|
+
const regex = this.type === 'integer' ? /^[\-]?\d+$/ : /^[\-]?\d+[.,]?\d*$/;
|
|
141
|
+
// Filter input
|
|
142
|
+
if (newValue === '' || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
143
|
+
this.storedValue = newValue;
|
|
144
|
+
}
|
|
145
|
+
else if (this.storedValue !== undefined) {
|
|
146
|
+
newValue = this.storedValue;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
newValue = null;
|
|
150
|
+
}
|
|
151
|
+
// Set value and input value
|
|
152
|
+
this.value = newValue;
|
|
153
|
+
if (this.input !== undefined)
|
|
154
|
+
this.input.value = this.value;
|
|
155
|
+
// emit numeric value
|
|
156
|
+
this.numericValue = this.value !== '' && this.value !== null ? parseFloat(this.value.replace(',', '.')) : null;
|
|
157
|
+
this.valueChange.emit(this.numericValue);
|
|
158
|
+
// Set readOnlyValue
|
|
159
|
+
this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
validateType(newValue) {
|
|
163
|
+
if (!types.includes(newValue)) {
|
|
164
|
+
throw new Error(`<mg-input-numeric> prop "type" must be one of : ${types.join(', ')}`);
|
|
165
|
+
}
|
|
166
|
+
this.classList.add(`mg-input--numeric--${this.type}`);
|
|
167
|
+
}
|
|
168
|
+
validateIntegerLength(newValue) {
|
|
169
|
+
if (newValue < 1) {
|
|
170
|
+
throw new Error(`<mg-input-numeric> prop "integer-length" must be a positive number.`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
validateDecimalLength(newValue) {
|
|
174
|
+
if (newValue < 1) {
|
|
175
|
+
throw new Error(`<mg-input-numeric> prop "decimal-length" must be a positive number, consider using prop "type" to "integer" instead.`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Check if input is valid
|
|
180
|
+
*/
|
|
181
|
+
checkValidity() {
|
|
182
|
+
if (!this.readonly) {
|
|
183
|
+
const validity = this.getInputError() === null;
|
|
184
|
+
// Set validity
|
|
185
|
+
this.valid = validity;
|
|
186
|
+
this.invalid = !validity;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Set error message
|
|
191
|
+
*/
|
|
192
|
+
setErrorMessage() {
|
|
193
|
+
const inputError = this.getInputError();
|
|
194
|
+
if (inputError === InputError.REQUIRED) {
|
|
195
|
+
this.errorMessage = messages.errors[inputError];
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
this.errorMessage = messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Check input errors
|
|
203
|
+
*/
|
|
204
|
+
checkError() {
|
|
205
|
+
// Set error message
|
|
206
|
+
this.errorMessage = undefined;
|
|
207
|
+
// Update class
|
|
208
|
+
if (!this.valid) {
|
|
209
|
+
this.setErrorMessage();
|
|
210
|
+
this.classList.add(this.classError);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
this.classList.delete(this.classError);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Validate append slot
|
|
218
|
+
*/
|
|
219
|
+
validateAppendSlot() {
|
|
220
|
+
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
221
|
+
if (slotAppendInput !== null && slotAppendInput.querySelector('.mg-button') !== null) {
|
|
222
|
+
this.classList.add('mg-input--is-input-group-append');
|
|
223
|
+
this.classList = new ClassList(this.classList.classes);
|
|
224
|
+
}
|
|
225
|
+
else if (slotAppendInput !== null) {
|
|
226
|
+
this.classList.add('mg-input--is-append-input-slot-content');
|
|
227
|
+
this.classList = new ClassList(this.classList.classes);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/*************
|
|
231
|
+
* Lifecycle *
|
|
232
|
+
*************/
|
|
233
|
+
componentWillLoad() {
|
|
234
|
+
this.validateValue(this.value);
|
|
235
|
+
// Set displayed value
|
|
236
|
+
this.displayValue = this.readonlyValue;
|
|
237
|
+
this.validateType(this.type);
|
|
238
|
+
this.validateIntegerLength(this.integerLength);
|
|
239
|
+
this.validateDecimalLength(this.decimalLength);
|
|
240
|
+
// return a promise to process action only in the FIRST render().
|
|
241
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
242
|
+
return setTimeout(() => this.checkValidity(), 0);
|
|
243
|
+
}
|
|
244
|
+
componentDidLoad() {
|
|
245
|
+
this.validateAppendSlot();
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Check if component props are well configured on init
|
|
249
|
+
*/
|
|
250
|
+
render() {
|
|
251
|
+
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: this.readonlyValue, tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-input__box", value: this.displayValue, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), h("slot", { name: "append-input" })));
|
|
252
|
+
}
|
|
253
|
+
get element() { return this; }
|
|
254
|
+
static get watchers() { return {
|
|
255
|
+
"value": ["validateValue"],
|
|
256
|
+
"type": ["validateType"],
|
|
257
|
+
"integerLength": ["validateIntegerLength"],
|
|
258
|
+
"decimalLength": ["validateDecimalLength"]
|
|
259
|
+
}; }
|
|
260
|
+
static get style() { return mgInputNumericCss; }
|
|
261
|
+
}, [1, "mg-input-numeric", {
|
|
262
|
+
"value": [1537],
|
|
263
|
+
"identifier": [1],
|
|
264
|
+
"name": [1],
|
|
265
|
+
"label": [1],
|
|
266
|
+
"labelOnTop": [4, "label-on-top"],
|
|
267
|
+
"labelHide": [4, "label-hide"],
|
|
268
|
+
"placeholder": [1],
|
|
269
|
+
"required": [4],
|
|
270
|
+
"readonly": [4],
|
|
271
|
+
"disabled": [4],
|
|
272
|
+
"width": [8],
|
|
273
|
+
"tooltip": [1],
|
|
274
|
+
"helpText": [1, "help-text"],
|
|
275
|
+
"type": [1],
|
|
276
|
+
"max": [2],
|
|
277
|
+
"min": [2],
|
|
278
|
+
"integerLength": [2, "integer-length"],
|
|
279
|
+
"decimalLength": [2, "decimal-length"],
|
|
280
|
+
"valid": [1028],
|
|
281
|
+
"invalid": [1028],
|
|
282
|
+
"classList": [32],
|
|
283
|
+
"errorMessage": [32],
|
|
284
|
+
"displayValue": [32]
|
|
285
|
+
}]);
|
|
286
|
+
function defineCustomElement$1() {
|
|
287
|
+
if (typeof customElements === "undefined") {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const components = ["mg-input-numeric", "mg-character-left", "mg-icon", "mg-input-title", "mg-tooltip"];
|
|
291
|
+
components.forEach(tagName => { switch (tagName) {
|
|
292
|
+
case "mg-input-numeric":
|
|
293
|
+
if (!customElements.get(tagName)) {
|
|
294
|
+
customElements.define(tagName, MgInputNumeric$1);
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
case "mg-character-left":
|
|
298
|
+
if (!customElements.get(tagName)) {
|
|
299
|
+
defineCustomElement$5();
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
case "mg-icon":
|
|
303
|
+
if (!customElements.get(tagName)) {
|
|
304
|
+
defineCustomElement$4();
|
|
305
|
+
}
|
|
306
|
+
break;
|
|
307
|
+
case "mg-input-title":
|
|
308
|
+
if (!customElements.get(tagName)) {
|
|
309
|
+
defineCustomElement$3();
|
|
310
|
+
}
|
|
311
|
+
break;
|
|
312
|
+
case "mg-tooltip":
|
|
313
|
+
if (!customElements.get(tagName)) {
|
|
314
|
+
defineCustomElement$2();
|
|
315
|
+
}
|
|
316
|
+
break;
|
|
317
|
+
} });
|
|
318
|
+
}
|
|
319
|
+
defineCustomElement$1();
|
|
320
|
+
|
|
321
|
+
const MgInputNumeric = MgInputNumeric$1;
|
|
322
|
+
const defineCustomElement = defineCustomElement$1;
|
|
323
|
+
|
|
324
|
+
export { MgInputNumeric, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface MgInputPassword extends Components.MgInputPassword, HTMLElement {}
|
|
4
|
+
export const MgInputPassword: {
|
|
5
|
+
prototype: MgInputPassword;
|
|
6
|
+
new (): MgInputPassword;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
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 mgInputPasswordCss = ":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}.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}";
|
|
11
|
+
|
|
12
|
+
const MgInputPassword$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.classError = InputClass.ERROR;
|
|
23
|
+
/**
|
|
24
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
25
|
+
* If not set, it will be created.
|
|
26
|
+
*/
|
|
27
|
+
this.identifier = createID('mg-input-password');
|
|
28
|
+
/**
|
|
29
|
+
* Input name
|
|
30
|
+
* If not set the value equals the identifier
|
|
31
|
+
*/
|
|
32
|
+
this.name = this.identifier;
|
|
33
|
+
/**
|
|
34
|
+
* Define if label is visible
|
|
35
|
+
*/
|
|
36
|
+
this.labelHide = false;
|
|
37
|
+
/**
|
|
38
|
+
* Define if input is required
|
|
39
|
+
*/
|
|
40
|
+
this.required = false;
|
|
41
|
+
/**
|
|
42
|
+
* Define if input is readonly
|
|
43
|
+
*/
|
|
44
|
+
this.readonly = false;
|
|
45
|
+
/**
|
|
46
|
+
* Define if input is disabled
|
|
47
|
+
*/
|
|
48
|
+
this.disabled = false;
|
|
49
|
+
/**
|
|
50
|
+
* Define input width
|
|
51
|
+
*/
|
|
52
|
+
this.width = 'full';
|
|
53
|
+
/**
|
|
54
|
+
* Component classes
|
|
55
|
+
*/
|
|
56
|
+
this.classList = new ClassList(['mg-input--password']);
|
|
57
|
+
/**
|
|
58
|
+
* Handle input event
|
|
59
|
+
*/
|
|
60
|
+
this.handleInput = () => {
|
|
61
|
+
this.checkValidity();
|
|
62
|
+
this.value = this.input.value;
|
|
63
|
+
this.valueChange.emit(this.value);
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Handle blur event
|
|
67
|
+
*/
|
|
68
|
+
this.handleBlur = () => {
|
|
69
|
+
this.checkValidity();
|
|
70
|
+
this.checkError();
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if input is valid
|
|
75
|
+
*/
|
|
76
|
+
checkValidity() {
|
|
77
|
+
if (!this.readonly && this.input !== undefined) {
|
|
78
|
+
const validity = this.input.checkValidity();
|
|
79
|
+
// Set validity
|
|
80
|
+
this.valid = validity;
|
|
81
|
+
this.invalid = !validity;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Check input errors
|
|
86
|
+
*/
|
|
87
|
+
checkError() {
|
|
88
|
+
// Set error message
|
|
89
|
+
this.errorMessage = undefined;
|
|
90
|
+
// required
|
|
91
|
+
if (!this.valid && this.input.validity.valueMissing) {
|
|
92
|
+
this.errorMessage = messages.errors.required;
|
|
93
|
+
}
|
|
94
|
+
// Update class
|
|
95
|
+
if (this.valid) {
|
|
96
|
+
this.classList.delete(this.classError);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
this.classList.add(this.classError);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/*************
|
|
103
|
+
* Lifecycle *
|
|
104
|
+
*************/
|
|
105
|
+
componentWillLoad() {
|
|
106
|
+
// return a promise to process action only in the FIRST render().
|
|
107
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
108
|
+
return setTimeout(() => this.checkValidity(), 0);
|
|
109
|
+
}
|
|
110
|
+
render() {
|
|
111
|
+
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: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, displayCharacterLeft: false, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) })));
|
|
112
|
+
}
|
|
113
|
+
static get style() { return mgInputPasswordCss; }
|
|
114
|
+
}, [1, "mg-input-password", {
|
|
115
|
+
"value": [1537],
|
|
116
|
+
"identifier": [1],
|
|
117
|
+
"name": [1],
|
|
118
|
+
"label": [1],
|
|
119
|
+
"labelOnTop": [4, "label-on-top"],
|
|
120
|
+
"labelHide": [4, "label-hide"],
|
|
121
|
+
"placeholder": [1],
|
|
122
|
+
"required": [4],
|
|
123
|
+
"readonly": [4],
|
|
124
|
+
"disabled": [4],
|
|
125
|
+
"width": [8],
|
|
126
|
+
"tooltip": [1],
|
|
127
|
+
"helpText": [1, "help-text"],
|
|
128
|
+
"valid": [1028],
|
|
129
|
+
"invalid": [1028],
|
|
130
|
+
"classList": [32],
|
|
131
|
+
"errorMessage": [32]
|
|
132
|
+
}]);
|
|
133
|
+
function defineCustomElement$1() {
|
|
134
|
+
if (typeof customElements === "undefined") {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const components = ["mg-input-password", "mg-character-left", "mg-icon", "mg-input-title", "mg-tooltip"];
|
|
138
|
+
components.forEach(tagName => { switch (tagName) {
|
|
139
|
+
case "mg-input-password":
|
|
140
|
+
if (!customElements.get(tagName)) {
|
|
141
|
+
customElements.define(tagName, MgInputPassword$1);
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case "mg-character-left":
|
|
145
|
+
if (!customElements.get(tagName)) {
|
|
146
|
+
defineCustomElement$5();
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
case "mg-icon":
|
|
150
|
+
if (!customElements.get(tagName)) {
|
|
151
|
+
defineCustomElement$4();
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
case "mg-input-title":
|
|
155
|
+
if (!customElements.get(tagName)) {
|
|
156
|
+
defineCustomElement$3();
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
case "mg-tooltip":
|
|
160
|
+
if (!customElements.get(tagName)) {
|
|
161
|
+
defineCustomElement$2();
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
} });
|
|
165
|
+
}
|
|
166
|
+
defineCustomElement$1();
|
|
167
|
+
|
|
168
|
+
const MgInputPassword = MgInputPassword$1;
|
|
169
|
+
const defineCustomElement = defineCustomElement$1;
|
|
170
|
+
|
|
171
|
+
export { MgInputPassword, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface MgInputRadio extends Components.MgInputRadio, HTMLElement {}
|
|
4
|
+
export const MgInputRadio: {
|
|
5
|
+
prototype: MgInputRadio;
|
|
6
|
+
new (): MgInputRadio;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|