@mgdis/mg-components 6.19.0 → 6.21.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-Bp6wZzau.js → index-C2viYwrR.js} +1757 -80
- package/dist/cjs/{index-TUElr4Wv.js → index-CCsGMNyq.js} +46 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_37.cjs.entry.js +735 -337
- package/dist/cjs/mg-alert.cjs.entry.js +17 -9
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-fieldset.cjs.entry.js +24 -7
- package/dist/cjs/mg-input-combobox.cjs.entry.js +63 -29
- package/dist/cjs/mg-input-file.cjs.entry.js +384 -0
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +30 -18
- package/dist/cjs/{mg-input.conf-D7jmj_lh.js → mg-input.conf-BNpeATnq.js} +7 -0
- package/dist/cjs/mg-loader.cjs.entry.js +8 -6
- package/dist/cjs/mg-progress.cjs.entry.js +19 -9
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +6 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +15 -11
- package/dist/collection/components/molecules/inputs/mg-input-file/mg-input-file.js +877 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +12 -12
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +72 -84
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
- package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +12 -3
- package/dist/collection/components/molecules/mg-form/mg-form.js +12 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/collection/locales/en/messages.json +11 -0
- package/dist/collection/locales/fr/messages.json +11 -0
- package/dist/components/events.utils.js +1 -23
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -1
- package/dist/components/index2.js +1 -408
- package/dist/components/index3.js +1 -476
- package/dist/components/mg-action-more.js +1 -254
- package/dist/components/mg-alert.js +1 -224
- package/dist/components/mg-badge.js +1 -6
- package/dist/components/mg-badge2.js +1 -113
- package/dist/components/mg-button.js +1 -6
- package/dist/components/mg-button2.js +1 -275
- package/dist/components/mg-card.js +1 -6
- package/dist/components/mg-card2.js +1 -92
- package/dist/components/mg-character-left.js +1 -6
- package/dist/components/mg-character-left2.js +1 -75
- package/dist/components/mg-details.js +1 -104
- package/dist/components/mg-divider.js +1 -6
- package/dist/components/mg-divider2.js +1 -49
- package/dist/components/mg-fieldset.js +1 -209
- package/dist/components/mg-form.js +1 -302
- package/dist/components/mg-icon.js +1 -6
- package/dist/components/mg-icon2.js +1 -188
- package/dist/components/mg-illustrated-message.js +1 -129
- package/dist/components/mg-input-checkbox-paginated.js +1 -6
- package/dist/components/mg-input-checkbox-paginated2.js +1 -135
- package/dist/components/mg-input-checkbox.js +1 -762
- package/dist/components/mg-input-combobox.js +1 -936
- package/dist/components/mg-input-date.js +1 -463
- package/dist/components/mg-input-file.d.ts +11 -0
- package/dist/components/mg-input-file.js +1 -0
- package/dist/components/mg-input-numeric.js +1 -592
- package/dist/components/mg-input-password.js +1 -360
- package/dist/components/mg-input-radio.js +1 -392
- package/dist/components/mg-input-rich-text-editor.js +1 -16797
- package/dist/components/mg-input-select.js +1 -6
- package/dist/components/mg-input-select2.js +1 -481
- package/dist/components/mg-input-text.js +1 -6
- package/dist/components/mg-input-text2.js +1 -514
- package/dist/components/mg-input-textarea.js +1 -412
- package/dist/components/mg-input-title.js +1 -6
- package/dist/components/mg-input-title2.js +1 -81
- package/dist/components/mg-input-toggle.js +1 -386
- package/dist/components/mg-input.conf.js +1 -0
- package/dist/components/mg-input.js +1 -6
- package/dist/components/mg-input2.js +1 -459
- package/dist/components/mg-item-more.js +1 -6
- package/dist/components/mg-item-more2.js +1 -505
- package/dist/components/mg-loader.js +1 -6
- package/dist/components/mg-loader2.js +1 -74
- package/dist/components/mg-menu-item.js +1 -6
- package/dist/components/mg-menu-item2.js +1 -485
- package/dist/components/mg-menu.js +1 -6
- package/dist/components/mg-message.js +1 -6
- package/dist/components/mg-message2.js +1 -146
- package/dist/components/mg-modal.js +1 -184
- package/dist/components/mg-pagination.js +1 -234
- package/dist/components/mg-panel.js +1 -350
- package/dist/components/mg-popover-content.js +1 -6
- package/dist/components/mg-popover-content2.js +1 -96
- package/dist/components/mg-popover.js +1 -6
- package/dist/components/mg-popover2.js +1 -312
- package/dist/components/mg-progress.js +1 -123
- package/dist/components/mg-skip-links.js +1 -78
- package/dist/components/mg-table.js +1 -319
- package/dist/components/mg-tabs.js +1 -6
- package/dist/components/mg-tabs2.js +1 -315
- package/dist/components/mg-tag.js +1 -133
- package/dist/components/mg-tooltip-content.js +1 -6
- package/dist/components/mg-tooltip-content2.js +1 -42
- package/dist/components/mg-tooltip.js +1 -6
- package/dist/components/mg-tooltip2.js +1 -421
- package/dist/components/popper.js +1 -1790
- package/dist/esm/{index-CNX6lq0x.js → index-D-uaxCxH.js} +46 -1
- package/dist/esm/{index-BluNKQ3L.js → index-DFwaH2hS.js} +1757 -80
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_37.entry.js +735 -337
- package/dist/esm/mg-alert.entry.js +17 -9
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-fieldset.entry.js +24 -7
- package/dist/esm/mg-input-combobox.entry.js +63 -29
- package/dist/esm/mg-input-file.entry.js +382 -0
- package/dist/esm/mg-input-rich-text-editor.entry.js +30 -18
- package/dist/esm/{mg-input.conf-DDnrE1hD.js → mg-input.conf-C9rmNQIL.js} +7 -1
- package/dist/esm/mg-loader.entry.js +8 -6
- package/dist/esm/mg-progress.entry.js +19 -9
- package/dist/mg-components/locales/en/messages.json +11 -0
- package/dist/mg-components/locales/fr/messages.json +11 -0
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-d5a276eb.entry.js → p-08fa327b.entry.js} +1 -1
- package/dist/mg-components/p-4175dcbe.entry.js +1 -0
- package/dist/mg-components/p-6b57f249.entry.js +1 -0
- package/dist/mg-components/p-6b655830.entry.js +1 -0
- package/dist/mg-components/p-988c282e.entry.js +1 -0
- package/dist/mg-components/p-C9rmNQIL.js +1 -0
- package/dist/mg-components/p-D-uaxCxH.js +1 -0
- package/dist/mg-components/p-DFwaH2hS.js +2 -0
- package/dist/mg-components/p-a79b1f19.entry.js +1 -0
- package/dist/mg-components/{p-916dfb6d.entry.js → p-c3d116b9.entry.js} +1 -1
- package/dist/mg-components/p-dd1934f4.entry.js +1 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +7 -1
- package/dist/types/components/molecules/inputs/mg-input-file/mg-input-file.d.ts +210 -0
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -4
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +13 -16
- package/dist/types/components.d.ts +217 -18
- package/dist/types/stencil-public-runtime.d.ts +76 -12
- package/ide/intellij/web-types.json +373 -26
- package/ide/vscode/css-custom-data.json +12 -0
- package/ide/vscode/html-custom-data.json +341 -79
- package/package.json +22 -22
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.scss +0 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +0 -1
- package/dist/mg-components/p-016bd291.entry.js +0 -1
- package/dist/mg-components/p-186a6139.entry.js +0 -1
- package/dist/mg-components/p-66a1cb83.entry.js +0 -1
- package/dist/mg-components/p-6efd819f.entry.js +0 -1
- package/dist/mg-components/p-BluNKQ3L.js +0 -2
- package/dist/mg-components/p-CNX6lq0x.js +0 -1
- package/dist/mg-components/p-DDnrE1hD.js +0 -1
- package/dist/mg-components/p-d2c72f09.entry.js +0 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +0 -8
|
@@ -1,514 +1 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { C as ClassList, i as isValidString, d as allItemsAreString, t as toString } from './index2.js';
|
|
3
|
-
import { d as defineCustomElement$4, c as classReadonly, a as classDisabled, w as widths, e as classDisplayCharacterLeft } from './mg-input2.js';
|
|
4
|
-
import { i as initLocales } from './index3.js';
|
|
5
|
-
import { d as defineCustomElement$6 } from './mg-character-left2.js';
|
|
6
|
-
import { d as defineCustomElement$5 } 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
|
-
import { d as defineCustomElement$1 } from './mg-tooltip-content2.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* TextType from text types
|
|
13
|
-
*/
|
|
14
|
-
// Define possible text types with help text
|
|
15
|
-
const helpTextTypes = ['email', 'emails', 'url'];
|
|
16
|
-
// Define possible text types
|
|
17
|
-
const textTypes = ['text', 'search', 'tel', ...helpTextTypes];
|
|
18
|
-
|
|
19
|
-
const mgInputTextCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-full .mg-c-input__input-group-container{width:100%;flex-grow:1}.mg-c-input.mg-c-input--width-2.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-4.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-16.mg-c-input--display-character-left .mg-c-input__input-group-container{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input.mg-c-input--display-character-left mg-character-left{position:absolute;display:none}.mg-c-input.mg-c-input--display-character-left mg-character-left>span{font-size:var(--mg-b-font-size-small);opacity:.6}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__help-text ::slotted(*),.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__error ::slotted(*){margin-top:0}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--display-character-left input:focus~mg-character-left,.mg-c-input.mg-c-input--display-character-left textarea:focus~mg-character-left{display:block}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input.mg-c-input--display-character-left mg-character-left{top:50%;right:var(--mg-b-size-8);font-size:var(--mg-b-font-size-small);transform:translateY(-50%)}.mg-c-input.mg-c-input--display-character-left .mg-c-input__box:focus{padding-right:max(var(--mg-c-character-left-message-length)*(.35ch + .3rem) + var(--mg-b-size-16)*clamp(0,var(--mg-c-character-left-message-length),1),var(--mg-b-size-8))}";
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Check if object is an option
|
|
23
|
-
* @param option - object to validate
|
|
24
|
-
* @returns true id object is an option
|
|
25
|
-
*/
|
|
26
|
-
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Check if datalist options are well structured.
|
|
29
|
-
* @param options - Datalist options to check.
|
|
30
|
-
* @returns True if datalist is well structured.
|
|
31
|
-
*/
|
|
32
|
-
const isDatalistOptions = (options) => allItemsAreString(options) || (Array.isArray(options) && options.every(isOption));
|
|
33
|
-
const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends HTMLElement {
|
|
34
|
-
constructor(registerHost) {
|
|
35
|
-
super();
|
|
36
|
-
if (registerHost !== false) {
|
|
37
|
-
this.__registerHost();
|
|
38
|
-
}
|
|
39
|
-
this.__attachShadow();
|
|
40
|
-
this.valueChange = createEvent(this, "value-change", 7);
|
|
41
|
-
this.inputValid = createEvent(this, "input-valid", 7);
|
|
42
|
-
/************
|
|
43
|
-
* Internal *
|
|
44
|
-
************/
|
|
45
|
-
// Classes
|
|
46
|
-
this.classIsInputGroupAppend = 'mg-c-input--is-input-group-append';
|
|
47
|
-
this.classHasIcon = 'mg-c-input--has-icon';
|
|
48
|
-
this.classHasButtonsGroupAppend = 'mg-c-input--has-buttons-group-append';
|
|
49
|
-
this.classIsAppendInputSlotContent = 'mg-c-input--is-append-input-slot-content';
|
|
50
|
-
// hasDisplayedError (triggered by blur event)
|
|
51
|
-
this.hasDisplayedError = false;
|
|
52
|
-
this.customErrorMessage = { lock: false };
|
|
53
|
-
/**
|
|
54
|
-
* Input name
|
|
55
|
-
* If not set the value equals the identifier
|
|
56
|
-
*/
|
|
57
|
-
this.name = this.identifier;
|
|
58
|
-
/**
|
|
59
|
-
* Define if label is displayed on top
|
|
60
|
-
*/
|
|
61
|
-
this.labelOnTop = false;
|
|
62
|
-
/**
|
|
63
|
-
* Define if label is visible
|
|
64
|
-
*/
|
|
65
|
-
this.labelHide = false;
|
|
66
|
-
/**
|
|
67
|
-
* Input type
|
|
68
|
-
*/
|
|
69
|
-
this.type = 'text';
|
|
70
|
-
/**
|
|
71
|
-
* Input max length
|
|
72
|
-
*/
|
|
73
|
-
this.maxlength = 400;
|
|
74
|
-
/**
|
|
75
|
-
* Define if input is required
|
|
76
|
-
*/
|
|
77
|
-
this.required = false;
|
|
78
|
-
/**
|
|
79
|
-
* Define if input is readonly
|
|
80
|
-
*/
|
|
81
|
-
this.readonly = false;
|
|
82
|
-
/**
|
|
83
|
-
* Define if input is disabled
|
|
84
|
-
*/
|
|
85
|
-
this.disabled = false;
|
|
86
|
-
/**
|
|
87
|
-
* Define input width
|
|
88
|
-
*/
|
|
89
|
-
this.mgWidth = 'full';
|
|
90
|
-
/**
|
|
91
|
-
* Define tooltip position
|
|
92
|
-
*/
|
|
93
|
-
this.tooltipPosition = 'input';
|
|
94
|
-
/**
|
|
95
|
-
* Define if component should display character left
|
|
96
|
-
*/
|
|
97
|
-
this.characterLeftHide = false;
|
|
98
|
-
/**
|
|
99
|
-
* Component classes
|
|
100
|
-
*/
|
|
101
|
-
this.classCollection = new ClassList(['mg-c-input--text']);
|
|
102
|
-
/**
|
|
103
|
-
* Validate pattern configuration
|
|
104
|
-
*/
|
|
105
|
-
this.validatePattern = () => {
|
|
106
|
-
if ((this.pattern !== undefined || this.patternErrorMessage !== undefined) && // At least one is defined
|
|
107
|
-
(!isValidString(this.pattern) || (!helpTextTypes.includes(this.type) && !isValidString(this.patternErrorMessage))) // Both must be defined
|
|
108
|
-
) {
|
|
109
|
-
throw new Error(`<mg-input-text> props "pattern" and "patternErrorMessage" must be non-empty string and paired. Passed value: "pattern='${this.pattern}'" and "patternErrorMessage='${this.patternErrorMessage}'".`);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Handle input event
|
|
114
|
-
*/
|
|
115
|
-
this.handleInput = () => {
|
|
116
|
-
this.checkValidity();
|
|
117
|
-
if (this.hasDisplayedError) {
|
|
118
|
-
this.setErrorMessage();
|
|
119
|
-
}
|
|
120
|
-
this.value = this.input.value;
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Handle blur event
|
|
124
|
-
*/
|
|
125
|
-
this.handleBlur = () => {
|
|
126
|
-
// Display Error
|
|
127
|
-
this.handlerInProgress = 'blur';
|
|
128
|
-
this.displayError().finally(() => {
|
|
129
|
-
// reset guard
|
|
130
|
-
this.handlerInProgress = undefined;
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Check if input is valid
|
|
135
|
-
*/
|
|
136
|
-
this.checkValidity = () => {
|
|
137
|
-
this.setValidity(this.readonly || this.disabled || this.input.checkValidity());
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Set input error message
|
|
141
|
-
* @param fromSetErrorContext - context come from `setError` method
|
|
142
|
-
*/
|
|
143
|
-
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
144
|
-
var _a;
|
|
145
|
-
// Set error message
|
|
146
|
-
this.errorMessage = undefined;
|
|
147
|
-
if (!this.valid) {
|
|
148
|
-
// Does have a new custom error message OR does have a custom error message locked
|
|
149
|
-
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
150
|
-
this.errorMessage = this.customErrorMessage.message;
|
|
151
|
-
}
|
|
152
|
-
// Does not match type (email, emails, tel, url, etc.)
|
|
153
|
-
else if (this.input.validity.typeMismatch) {
|
|
154
|
-
this.errorMessage = this.messages.input.text.errors.typeMismatch[this.type];
|
|
155
|
-
}
|
|
156
|
-
// Does not match pattern
|
|
157
|
-
else if (this.input.validity.patternMismatch) {
|
|
158
|
-
this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : this.messages.input.text.errors.typeMismatch[this.type];
|
|
159
|
-
}
|
|
160
|
-
// required
|
|
161
|
-
else if (this.input.validity.valueMissing) {
|
|
162
|
-
this.errorMessage = this.messages.errors.required;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
/**
|
|
167
|
-
* Validate append slot
|
|
168
|
-
*/
|
|
169
|
-
this.validateAppendSlot = () => {
|
|
170
|
-
const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
|
|
171
|
-
if (slotAppendInput.length === 1) {
|
|
172
|
-
if (slotAppendInput[0].nodeName === 'MG-BUTTON') {
|
|
173
|
-
this.classCollection.add(this.classIsInputGroupAppend);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
this.classCollection.add(this.classIsAppendInputSlotContent);
|
|
177
|
-
this.slotContent = slotAppendInput[0].textContent;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
|
|
181
|
-
this.classCollection.add(this.classIsInputGroupAppend);
|
|
182
|
-
this.classCollection.add(this.classHasButtonsGroupAppend);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* Method to control datalist display condition
|
|
187
|
-
* @returns true if display condition success
|
|
188
|
-
*/
|
|
189
|
-
this.hasDatalist = () => isDatalistOptions(this.datalistoptions) && this.datalistoptions.length > 0;
|
|
190
|
-
/**
|
|
191
|
-
* Renders the readonly content of the input component.
|
|
192
|
-
* @returns The readonly content element.
|
|
193
|
-
*/
|
|
194
|
-
this.renderReadonly = () => {
|
|
195
|
-
return this.slotContent !== undefined ? (h("span", { class: "mg-c-input__readonly-value" }, h("b", null, this.value), this.slotContent)) : (h("b", { class: "mg-c-input__readonly-value" }, this.value));
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
handleValue(newValue) {
|
|
199
|
-
var _a, _b;
|
|
200
|
-
if ((_a = this.datalistoptions) === null || _a === void 0 ? void 0 : _a.every(isOption)) {
|
|
201
|
-
this.valueChange.emit(((_b = this.datalistoptions.find(option => option.title === newValue)) === null || _b === void 0 ? void 0 : _b.value) || newValue);
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
this.valueChange.emit(newValue);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
validateType(newValue) {
|
|
208
|
-
if (!textTypes.includes(newValue)) {
|
|
209
|
-
throw new Error(`<mg-input-text> prop "type" must be one of the following values: ${textTypes.join(', ')}. Passed value: ${newValue}.`);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
validateIcon(newValue) {
|
|
213
|
-
if (newValue !== undefined) {
|
|
214
|
-
this.classCollection.add(this.classHasIcon);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
this.classCollection.delete(this.classHasIcon);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
validateDatalistoptions(newValue) {
|
|
221
|
-
if (Boolean(newValue) && !isDatalistOptions(newValue)) {
|
|
222
|
-
throw new Error(`<mg-input-text> prop "datalistoptions" values must be the same type, string or OptionType. Passed value: ${toString(newValue)}.`);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
watchReadonly(newValue) {
|
|
226
|
-
if (newValue)
|
|
227
|
-
this.classCollection.add(classReadonly);
|
|
228
|
-
else
|
|
229
|
-
this.classCollection.delete(classReadonly);
|
|
230
|
-
}
|
|
231
|
-
handleValidityChange(newValue, _oldValue, prop) {
|
|
232
|
-
if (this.input !== undefined) {
|
|
233
|
-
this.input[prop] = newValue;
|
|
234
|
-
this.checkValidity();
|
|
235
|
-
if (this.hasDisplayedError) {
|
|
236
|
-
this.setErrorMessage();
|
|
237
|
-
this.hasDisplayedError = false;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
watchDisabled(newValue) {
|
|
242
|
-
if (newValue)
|
|
243
|
-
this.classCollection.add(classDisabled);
|
|
244
|
-
else
|
|
245
|
-
this.classCollection.delete(classDisabled);
|
|
246
|
-
}
|
|
247
|
-
watchMgWidth(newValue) {
|
|
248
|
-
// reset width class
|
|
249
|
-
widths.forEach(width => {
|
|
250
|
-
this.classCollection.delete(`mg-c-input--width-${width}`);
|
|
251
|
-
});
|
|
252
|
-
// apply new width
|
|
253
|
-
if (newValue !== undefined)
|
|
254
|
-
this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
|
|
255
|
-
}
|
|
256
|
-
watchPattern() {
|
|
257
|
-
this.validatePattern();
|
|
258
|
-
}
|
|
259
|
-
validateCharacterLeftHide(newValue) {
|
|
260
|
-
if (newValue) {
|
|
261
|
-
this.classCollection.delete(classDisplayCharacterLeft);
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
this.classCollection.add(classDisplayCharacterLeft);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
watchHelpText(newValue) {
|
|
268
|
-
if (!isValidString(newValue) && helpTextTypes.includes(this.type)) {
|
|
269
|
-
this.helpText = this.messages.input.text.helpText[this.type];
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Set focus on input.
|
|
274
|
-
*/
|
|
275
|
-
async setFocus() {
|
|
276
|
-
var _a;
|
|
277
|
-
(_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Display input error if it exists.
|
|
281
|
-
*/
|
|
282
|
-
displayError() {
|
|
283
|
-
// Use `Promise` as requested for stencil method
|
|
284
|
-
// Use `requestAnimationFrame` to ensure:
|
|
285
|
-
// - DOM is fully updated before validation
|
|
286
|
-
// - Async operations are completed
|
|
287
|
-
// - No timing issues with Stencil's render cycle
|
|
288
|
-
// - Keep everything in sync both inside and outside the component
|
|
289
|
-
return new Promise(resolve => {
|
|
290
|
-
requestAnimationFrame(() => {
|
|
291
|
-
this.checkValidity();
|
|
292
|
-
this.setErrorMessage();
|
|
293
|
-
this.hasDisplayedError = this.invalid;
|
|
294
|
-
resolve();
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Set an error and display a custom error message.
|
|
300
|
-
* This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.
|
|
301
|
-
* It must be paired with an error message to display for the given context.
|
|
302
|
-
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
303
|
-
* @param valid - value indicating the validity
|
|
304
|
-
* @param errorMessage - the error message to display
|
|
305
|
-
* @param errorMessageLock - lock the error message and validity state
|
|
306
|
-
*/
|
|
307
|
-
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
308
|
-
if (typeof valid !== 'boolean') {
|
|
309
|
-
throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean.');
|
|
310
|
-
}
|
|
311
|
-
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
312
|
-
throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string.');
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
this.customErrorMessage = {
|
|
316
|
-
lock: valid ? false : errorMessageLock,
|
|
317
|
-
message: valid ? undefined : errorMessage,
|
|
318
|
-
};
|
|
319
|
-
this.setValidity(valid);
|
|
320
|
-
this.setErrorMessage(true);
|
|
321
|
-
this.hasDisplayedError = this.invalid;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Reset value, validity and error state
|
|
326
|
-
*/
|
|
327
|
-
async reset() {
|
|
328
|
-
if (!this.readonly) {
|
|
329
|
-
this.value = '';
|
|
330
|
-
// Use `Promise` as requested for stencil method
|
|
331
|
-
// Use `requestAnimationFrame` to ensure:
|
|
332
|
-
// - DOM is fully updated before validation
|
|
333
|
-
// - Async operations are completed
|
|
334
|
-
// - No timing issues with Stencil's render cycle
|
|
335
|
-
// - Keep everything in sync both inside and outside the component
|
|
336
|
-
return new Promise(resolve => {
|
|
337
|
-
requestAnimationFrame(() => {
|
|
338
|
-
// unlock validity check by reseting customErrorMessage
|
|
339
|
-
this.customErrorMessage = { lock: false };
|
|
340
|
-
this.checkValidity();
|
|
341
|
-
this.errorMessage = undefined;
|
|
342
|
-
this.hasDisplayedError = false;
|
|
343
|
-
resolve();
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Method to set validity values
|
|
350
|
-
* @param newValue - valid new value
|
|
351
|
-
*/
|
|
352
|
-
setValidity(newValue) {
|
|
353
|
-
const oldValue = this.valid;
|
|
354
|
-
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
355
|
-
this.valid = newValue;
|
|
356
|
-
}
|
|
357
|
-
this.invalid = !this.valid;
|
|
358
|
-
// We need to send valid event even if it is the same value
|
|
359
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
360
|
-
this.inputValid.emit(this.valid);
|
|
361
|
-
}
|
|
362
|
-
/*************
|
|
363
|
-
* Lifecycle *
|
|
364
|
-
*************/
|
|
365
|
-
/**
|
|
366
|
-
* Check if component props are well configured on init
|
|
367
|
-
* @returns timeout
|
|
368
|
-
*/
|
|
369
|
-
componentWillLoad() {
|
|
370
|
-
// Get locales
|
|
371
|
-
this.messages = initLocales(this.element).messages;
|
|
372
|
-
this.characterLeftId = `${this.identifier}-character-left`;
|
|
373
|
-
this.datalistId = `${this.identifier}-datalist`;
|
|
374
|
-
// Validate
|
|
375
|
-
this.validateIcon(this.icon);
|
|
376
|
-
this.validateDatalistoptions(this.datalistoptions);
|
|
377
|
-
this.watchPattern();
|
|
378
|
-
this.validateAppendSlot();
|
|
379
|
-
this.watchMgWidth(this.mgWidth);
|
|
380
|
-
this.watchReadonly(this.readonly);
|
|
381
|
-
this.watchDisabled(this.disabled);
|
|
382
|
-
this.validateCharacterLeftHide(this.characterLeftHide);
|
|
383
|
-
this.validateType(this.type);
|
|
384
|
-
this.watchHelpText(this.helpText);
|
|
385
|
-
// Check validity when component is ready
|
|
386
|
-
// return a promise to process action only in the FIRST render().
|
|
387
|
-
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
388
|
-
return setTimeout(() => {
|
|
389
|
-
this.checkValidity();
|
|
390
|
-
}, 0);
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Render
|
|
394
|
-
* @returns HTML Element
|
|
395
|
-
*/
|
|
396
|
-
render() {
|
|
397
|
-
return (h("mg-input", { key: 'b6360c95530daf744ae5c3eb5cc41d6c81c3e35c', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: this.characterLeftId, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly
|
|
398
|
-
? this.value && this.renderReadonly()
|
|
399
|
-
: [
|
|
400
|
-
h("div", { key: "input", class: "mg-c-input__input-group-container", style: {
|
|
401
|
-
'--mg-c-character-left-message-length': (!this.characterLeftHide ? this.maxlength.toString().length * 2 + 1 : 0).toString(),
|
|
402
|
-
} }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type === 'emails' ? 'email' : this.type, multiple: this.type === 'emails', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, list: this.hasDatalist() ? this.datalistId : undefined, autocomplete: this.hasDatalist() ? 'off' : undefined, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), pattern: this.pattern, onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
403
|
-
if (el !== null)
|
|
404
|
-
this.input = el;
|
|
405
|
-
} }), this.hasDatalist() && (h("datalist", { id: this.datalistId }, this.datalistoptions.map(option => (h("option", { value: isOption(option) ? option.title : option, key: option }))))), !this.characterLeftHide && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))),
|
|
406
|
-
h("slot", { key: "slot", name: "append-input" }),
|
|
407
|
-
]));
|
|
408
|
-
}
|
|
409
|
-
get element() { return this; }
|
|
410
|
-
static get watchers() { return {
|
|
411
|
-
"value": ["handleValue"],
|
|
412
|
-
"type": ["validateType"],
|
|
413
|
-
"icon": ["validateIcon"],
|
|
414
|
-
"datalistoptions": ["validateDatalistoptions"],
|
|
415
|
-
"readonly": ["watchReadonly", "handleValidityChange"],
|
|
416
|
-
"required": ["handleValidityChange"],
|
|
417
|
-
"disabled": ["handleValidityChange", "watchDisabled"],
|
|
418
|
-
"mgWidth": ["watchMgWidth"],
|
|
419
|
-
"pattern": ["watchPattern"],
|
|
420
|
-
"patternErrorMessage": ["watchPattern"],
|
|
421
|
-
"characterLeftHide": ["validateCharacterLeftHide"],
|
|
422
|
-
"helpText": ["watchHelpText"]
|
|
423
|
-
}; }
|
|
424
|
-
static get style() { return mgInputTextCss; }
|
|
425
|
-
}, [257, "mg-input-text", {
|
|
426
|
-
"value": [1544],
|
|
427
|
-
"identifier": [1],
|
|
428
|
-
"name": [1],
|
|
429
|
-
"label": [1],
|
|
430
|
-
"labelOnTop": [4, "label-on-top"],
|
|
431
|
-
"labelHide": [4, "label-hide"],
|
|
432
|
-
"type": [1],
|
|
433
|
-
"icon": [1],
|
|
434
|
-
"placeholder": [1],
|
|
435
|
-
"datalistoptions": [16],
|
|
436
|
-
"maxlength": [2],
|
|
437
|
-
"required": [4],
|
|
438
|
-
"readonly": [4],
|
|
439
|
-
"disabled": [4],
|
|
440
|
-
"mgWidth": [8, "mg-width"],
|
|
441
|
-
"pattern": [1],
|
|
442
|
-
"patternErrorMessage": [1, "pattern-error-message"],
|
|
443
|
-
"tooltip": [1],
|
|
444
|
-
"tooltipPosition": [1, "tooltip-position"],
|
|
445
|
-
"characterLeftHide": [4, "character-left-hide"],
|
|
446
|
-
"helpText": [1025, "help-text"],
|
|
447
|
-
"valid": [1028],
|
|
448
|
-
"invalid": [1028],
|
|
449
|
-
"classCollection": [32],
|
|
450
|
-
"errorMessage": [32],
|
|
451
|
-
"setFocus": [64],
|
|
452
|
-
"displayError": [64],
|
|
453
|
-
"setError": [64],
|
|
454
|
-
"reset": [64]
|
|
455
|
-
}, undefined, {
|
|
456
|
-
"value": ["handleValue"],
|
|
457
|
-
"type": ["validateType"],
|
|
458
|
-
"icon": ["validateIcon"],
|
|
459
|
-
"datalistoptions": ["validateDatalistoptions"],
|
|
460
|
-
"readonly": ["watchReadonly", "handleValidityChange"],
|
|
461
|
-
"required": ["handleValidityChange"],
|
|
462
|
-
"disabled": ["handleValidityChange", "watchDisabled"],
|
|
463
|
-
"mgWidth": ["watchMgWidth"],
|
|
464
|
-
"pattern": ["watchPattern"],
|
|
465
|
-
"patternErrorMessage": ["watchPattern"],
|
|
466
|
-
"characterLeftHide": ["validateCharacterLeftHide"],
|
|
467
|
-
"helpText": ["watchHelpText"]
|
|
468
|
-
}]);
|
|
469
|
-
function defineCustomElement() {
|
|
470
|
-
if (typeof customElements === "undefined") {
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
const components = ["mg-input-text", "mg-character-left", "mg-icon", "mg-input", "mg-input-title", "mg-tooltip", "mg-tooltip-content"];
|
|
474
|
-
components.forEach(tagName => { switch (tagName) {
|
|
475
|
-
case "mg-input-text":
|
|
476
|
-
if (!customElements.get(tagName)) {
|
|
477
|
-
customElements.define(tagName, MgInputText);
|
|
478
|
-
}
|
|
479
|
-
break;
|
|
480
|
-
case "mg-character-left":
|
|
481
|
-
if (!customElements.get(tagName)) {
|
|
482
|
-
defineCustomElement$6();
|
|
483
|
-
}
|
|
484
|
-
break;
|
|
485
|
-
case "mg-icon":
|
|
486
|
-
if (!customElements.get(tagName)) {
|
|
487
|
-
defineCustomElement$5();
|
|
488
|
-
}
|
|
489
|
-
break;
|
|
490
|
-
case "mg-input":
|
|
491
|
-
if (!customElements.get(tagName)) {
|
|
492
|
-
defineCustomElement$4();
|
|
493
|
-
}
|
|
494
|
-
break;
|
|
495
|
-
case "mg-input-title":
|
|
496
|
-
if (!customElements.get(tagName)) {
|
|
497
|
-
defineCustomElement$3();
|
|
498
|
-
}
|
|
499
|
-
break;
|
|
500
|
-
case "mg-tooltip":
|
|
501
|
-
if (!customElements.get(tagName)) {
|
|
502
|
-
defineCustomElement$2();
|
|
503
|
-
}
|
|
504
|
-
break;
|
|
505
|
-
case "mg-tooltip-content":
|
|
506
|
-
if (!customElements.get(tagName)) {
|
|
507
|
-
defineCustomElement$1();
|
|
508
|
-
}
|
|
509
|
-
break;
|
|
510
|
-
} });
|
|
511
|
-
}
|
|
512
|
-
defineCustomElement();
|
|
513
|
-
|
|
514
|
-
export { MgInputText as M, defineCustomElement as d };
|
|
1
|
+
import{transformTag as t,proxyCustomElement as i,HTMLElement as e,createEvent as s,h as a}from"@stencil/core/internal/client";import{C as n,i as r,d as o,t as h}from"./index2.js";import{c as p,b as c,w as l,e as m}from"./mg-input.conf.js";import{i as g}from"./index3.js";import{d as u}from"./mg-character-left2.js";import{d}from"./mg-icon2.js";import{d as b}from"./mg-input2.js";import{d as f}from"./mg-input-title2.js";import{d as v}from"./mg-tooltip2.js";import{d as w}from"./mg-tooltip-content2.js";const y=["email","emails","url"],_=["text","search","tel",...y],x=t=>"object"==typeof t&&"string"==typeof t.title&&void 0!==t.value,z=t=>o(t)||Array.isArray(t)&&t.every(x),E=i(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.valueChange=s(this,"value-change",7),this.inputValid=s(this,"input-valid",7),this.classIsInputGroupAppend="mg-c-input--is-input-group-append",this.classHasIcon="mg-c-input--has-icon",this.classHasButtonsGroupAppend="mg-c-input--has-buttons-group-append",this.classIsAppendInputSlotContent="mg-c-input--is-append-input-slot-content",this.hasDisplayedError=!1,this.customErrorMessage={lock:!1},this.name=this.identifier,this.labelOnTop=!1,this.labelHide=!1,this.type="text",this.maxlength=400,this.required=!1,this.readonly=!1,this.disabled=!1,this.mgWidth="full",this.tooltipPosition="input",this.characterLeftHide=!1,this.classCollection=new n(["mg-c-input--text"]),this.validatePattern=()=>{if(!(void 0===this.pattern&&void 0===this.patternErrorMessage||r(this.pattern)&&(y.includes(this.type)||r(this.patternErrorMessage))))throw new Error(`<mg-input-text> props "pattern" and "patternErrorMessage" must be non-empty string and paired. Passed value: "pattern='${this.pattern}'" and "patternErrorMessage='${this.patternErrorMessage}'".`)},this.handleInput=()=>{this.checkValidity(),this.hasDisplayedError&&this.setErrorMessage(),this.value=this.input.value},this.handleBlur=()=>{this.handlerInProgress="blur",this.displayError().finally((()=>{this.handlerInProgress=void 0}))},this.checkValidity=()=>{this.setValidity(this.readonly||this.disabled||this.input.checkValidity())},this.setErrorMessage=(t=!1)=>{var i;this.errorMessage=void 0,this.valid||(t||this.customErrorMessage.lock&&void 0!==this.customErrorMessage.message?this.errorMessage=this.customErrorMessage.message:this.input.validity.typeMismatch?this.errorMessage=this.messages.input.text.errors.typeMismatch[this.type]:this.input.validity.patternMismatch?this.errorMessage=null!==(i=this.patternErrorMessage)&&void 0!==i?i:this.messages.input.text.errors.typeMismatch[this.type]:this.input.validity.valueMissing&&(this.errorMessage=this.messages.errors.required))},this.validateAppendSlot=()=>{const t=Array.from(this.element.querySelectorAll('[slot="append-input"]'));1===t.length?"MG-BUTTON"===t[0].nodeName?this.classCollection.add(this.classIsInputGroupAppend):(this.classCollection.add(this.classIsAppendInputSlotContent),this.slotContent=t[0].textContent):t.filter((t=>"MG-BUTTON"===t.nodeName)).length>1&&(this.classCollection.add(this.classIsInputGroupAppend),this.classCollection.add(this.classHasButtonsGroupAppend))},this.hasDatalist=()=>z(this.datalistoptions)&&this.datalistoptions.length>0,this.renderReadonly=()=>void 0!==this.slotContent?a("span",{class:"mg-c-input__readonly-value"},a("b",null,this.value),this.slotContent):a("b",{class:"mg-c-input__readonly-value"},this.value)}handleValue(t){var i,e;(null===(i=this.datalistoptions)||void 0===i?void 0:i.every(x))?this.valueChange.emit((null===(e=this.datalistoptions.find((i=>i.title===t)))||void 0===e?void 0:e.value)||t):this.valueChange.emit(t)}validateType(t){if(!_.includes(t))throw new Error(`<mg-input-text> prop "type" must be one of the following values: ${_.join(", ")}. Passed value: ${t}.`)}validateIcon(t){void 0!==t?this.classCollection.add(this.classHasIcon):this.classCollection.delete(this.classHasIcon)}validateDatalistoptions(t){if(Boolean(t)&&!z(t))throw new Error(`<mg-input-text> prop "datalistoptions" values must be the same type, string or OptionType. Passed value: ${h(t)}.`)}watchReadonly(t){t?this.classCollection.add(p):this.classCollection.delete(p)}handleValidityChange(t,i,e){void 0!==this.input&&(this.input[e]=t,this.checkValidity(),this.hasDisplayedError&&(this.setErrorMessage(),this.hasDisplayedError=!1))}watchDisabled(t){t?this.classCollection.add(c):this.classCollection.delete(c)}watchMgWidth(t){l.forEach((t=>{this.classCollection.delete(`mg-c-input--width-${t}`)})),void 0!==t&&this.classCollection.add(`mg-c-input--width-${this.mgWidth}`)}watchPattern(){this.validatePattern()}validateCharacterLeftHide(t){t?this.classCollection.delete(m):this.classCollection.add(m)}watchHelpText(t){!r(t)&&y.includes(this.type)&&(this.helpText=this.messages.input.text.helpText[this.type])}async setFocus(){var t;null===(t=this.input)||void 0===t||t.focus()}displayError(){return new Promise((t=>{requestAnimationFrame((()=>{this.checkValidity(),this.setErrorMessage(),this.hasDisplayedError=this.invalid,t()}))}))}async setError(t,i,e=!1){if("boolean"!=typeof t)throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean.');if(void 0!==i&&!r(i))throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string.');this.customErrorMessage={lock:!t&&e,message:t?void 0:i},this.setValidity(t),this.setErrorMessage(!0),this.hasDisplayedError=this.invalid}async reset(){if(!this.readonly)return this.value="",new Promise((t=>{requestAnimationFrame((()=>{this.customErrorMessage={lock:!1},this.checkValidity(),this.errorMessage=void 0,this.hasDisplayedError=!1,t()}))}))}setValidity(t){const i=this.valid;this.customErrorMessage.lock&&(void 0===this.customErrorMessage.message||t)||(this.valid=t),this.invalid=!this.valid,(void 0===this.handlerInProgress||"blur"===this.handlerInProgress&&this.valid!==i)&&this.inputValid.emit(this.valid)}componentWillLoad(){return this.messages=g(this.element).messages,this.characterLeftId=`${this.identifier}-character-left`,this.datalistId=`${this.identifier}-datalist`,this.validateIcon(this.icon),this.validateDatalistoptions(this.datalistoptions),this.watchPattern(),this.validateAppendSlot(),this.watchMgWidth(this.mgWidth),this.watchReadonly(this.readonly),this.watchDisabled(this.disabled),this.validateCharacterLeftHide(this.characterLeftHide),this.validateType(this.type),this.watchHelpText(this.helpText),setTimeout((()=>{this.checkValidity()}),0)}render(){return a("mg-input",{key:"cefd22e81ad535ff0ffd99d274c5eb616110ddd6",label:this.label,identifier:this.identifier,class:this.classCollection.join(),ariaDescribedbyIDs:this.characterLeftId,labelOnTop:this.labelOnTop,labelHide:this.labelHide,required:this.required,tooltip:this.tooltip,tooltipPosition:this.readonly&&void 0===this.value?"label":this.tooltipPosition,helpText:this.helpText,errorMessage:this.errorMessage},this.readonly?this.value&&this.renderReadonly():[a("div",{key:"input",class:"mg-c-input__input-group-container",style:{"--mg-c-character-left-message-length":(this.characterLeftHide?0:2*this.maxlength.toString().length+1).toString()}},void 0!==this.icon&&a("mg-icon",{icon:this.icon}),a("input",{type:"emails"===this.type?"email":this.type,multiple:"emails"===this.type,class:"mg-c-input__box mg-c-input__box--width",value:this.value,id:this.identifier,list:this.hasDatalist()?this.datalistId:void 0,autocomplete:this.hasDatalist()?"off":void 0,name:this.name,placeholder:this.placeholder,title:this.placeholder,maxlength:this.maxlength,disabled:this.disabled,required:this.required,"aria-invalid":(!0===this.invalid).toString(),pattern:this.pattern,onInput:this.handleInput,onBlur:this.handleBlur,ref:t=>{null!==t&&(this.input=t)}}),this.hasDatalist()&&a("datalist",{id:this.datalistId},this.datalistoptions.map((t=>a("option",{value:x(t)?t.title:t,key:t})))),!this.characterLeftHide&&this.maxlength>0&&a("mg-character-left",{identifier:this.characterLeftId,characters:this.value,maxlength:this.maxlength})),a("slot",{key:"slot",name:"append-input"})])}get element(){return this}static get watchers(){return{value:[{handleValue:0}],type:[{validateType:0}],icon:[{validateIcon:0}],datalistoptions:[{validateDatalistoptions:0}],readonly:[{watchReadonly:0},{handleValidityChange:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}],mgWidth:[{watchMgWidth:0}],pattern:[{watchPattern:0}],patternErrorMessage:[{watchPattern:0}],characterLeftHide:[{validateCharacterLeftHide:0}],helpText:[{watchHelpText:0}]}}static get style(){return".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-full .mg-c-input__input-group-container{width:100%;flex-grow:1}.mg-c-input.mg-c-input--width-2.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-4.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-16.mg-c-input--display-character-left .mg-c-input__input-group-container{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input.mg-c-input--display-character-left mg-character-left{position:absolute;display:none}.mg-c-input.mg-c-input--display-character-left mg-character-left>span{font-size:var(--mg-b-font-size-small);opacity:.6}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__help-text ::slotted(*),.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__error ::slotted(*){margin-top:0}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--display-character-left input:focus~mg-character-left,.mg-c-input.mg-c-input--display-character-left textarea:focus~mg-character-left{display:block}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input.mg-c-input--display-character-left mg-character-left{top:50%;right:var(--mg-b-size-8);font-size:var(--mg-b-font-size-small);transform:translateY(-50%)}.mg-c-input.mg-c-input--display-character-left .mg-c-input__box:focus{padding-right:max(var(--mg-c-character-left-message-length)*(.35ch + .3rem) + var(--mg-b-size-16)*clamp(0,var(--mg-c-character-left-message-length),1),var(--mg-b-size-8))}"}},[257,"mg-input-text",{value:[1544],identifier:[1],name:[1],label:[1],labelOnTop:[4,"label-on-top"],labelHide:[4,"label-hide"],type:[1],icon:[1],placeholder:[1],datalistoptions:[16],maxlength:[2],required:[4],readonly:[4],disabled:[4],mgWidth:[8,"mg-width"],pattern:[1],patternErrorMessage:[1,"pattern-error-message"],tooltip:[1],tooltipPosition:[1,"tooltip-position"],characterLeftHide:[4,"character-left-hide"],helpText:[1025,"help-text"],valid:[1028],invalid:[1028],classCollection:[32],errorMessage:[32],setFocus:[64],displayError:[64],setError:[64],reset:[64]},void 0,{value:[{handleValue:0}],type:[{validateType:0}],icon:[{validateIcon:0}],datalistoptions:[{validateDatalistoptions:0}],readonly:[{watchReadonly:0},{handleValidityChange:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}],mgWidth:[{watchMgWidth:0}],pattern:[{watchPattern:0}],patternErrorMessage:[{watchPattern:0}],characterLeftHide:[{validateCharacterLeftHide:0}],helpText:[{watchHelpText:0}]}]);function T(){"undefined"!=typeof customElements&&["mg-input-text","mg-character-left","mg-icon","mg-input","mg-input-title","mg-tooltip","mg-tooltip-content"].forEach((i=>{switch(i){case"mg-input-text":customElements.get(t(i))||customElements.define(t(i),E);break;case"mg-character-left":customElements.get(t(i))||u();break;case"mg-icon":customElements.get(t(i))||d();break;case"mg-input":customElements.get(t(i))||b();break;case"mg-input-title":customElements.get(t(i))||f();break;case"mg-tooltip":customElements.get(t(i))||v();break;case"mg-tooltip-content":customElements.get(t(i))||w()}}))}T();export{E as M,T as d}
|