@mgdis/mg-components 6.20.0 → 6.22.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-TUElr4Wv.js → index-BxB20_Vw.js} +54 -0
- package/dist/cjs/{index-Bp6wZzau.js → index-C2viYwrR.js} +1761 -80
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_37.cjs.entry.js +761 -371
- package/dist/cjs/mg-alert.cjs.entry.js +17 -9
- package/dist/cjs/mg-breadcrumb.cjs.entry.js +63 -0
- 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 +49 -19
- package/dist/cjs/mg-input-file.cjs.entry.js +384 -0
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +40096 -15821
- 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/assets/icons/index.js +1 -1
- package/dist/collection/collection-manifest.json +5 -3
- package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js +1 -1
- package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +2 -2
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.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/mg-input.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +1 -1
- 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 +2 -2
- 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/editor/custom-properties.scss +212 -0
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/index.js +300 -94
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.conf.js +29 -0
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +163 -53
- 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 +1 -1
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +3 -36
- package/dist/collection/components/molecules/menus/mg-menu/mg-menu.conf.js +0 -4
- package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +21 -43
- package/dist/collection/components/molecules/menus/mg-menu-item/mg-menu-item.js +65 -38
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -2
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
- package/dist/collection/components/molecules/mg-breadcrumb/mg-breadcrumb.conf.js +1 -0
- package/dist/collection/components/molecules/mg-breadcrumb/mg-breadcrumb.js +92 -0
- 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-table/mg-table.js +37 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +0 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +13 -33
- package/dist/collection/locales/en/messages.json +14 -0
- package/dist/collection/locales/fr/messages.json +14 -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-breadcrumb.d.ts +11 -0
- package/dist/components/mg-breadcrumb.js +1 -0
- 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 -940
- 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 +1663 -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 -371
- 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-BluNKQ3L.js → index-DFwaH2hS.js} +1761 -80
- package/dist/esm/{index-CNX6lq0x.js → index-DSEloqPn.js} +54 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_37.entry.js +761 -371
- package/dist/esm/mg-alert.entry.js +17 -9
- package/dist/esm/mg-breadcrumb.entry.js +61 -0
- 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 +49 -19
- package/dist/esm/mg-input-file.entry.js +382 -0
- package/dist/esm/mg-input-rich-text-editor.entry.js +40083 -15808
- 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 +14 -0
- package/dist/mg-components/locales/fr/messages.json +14 -0
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-0482eb9f.entry.js +1 -0
- package/dist/mg-components/{p-7132bca1.entry.js → p-2ee92f38.entry.js} +1 -1
- package/dist/mg-components/{p-916dfb6d.entry.js → p-3b653226.entry.js} +1 -1
- package/dist/mg-components/p-5745fbea.entry.js +1 -0
- package/dist/mg-components/p-C9rmNQIL.js +1 -0
- package/dist/mg-components/p-DFwaH2hS.js +2 -0
- package/dist/mg-components/p-DSEloqPn.js +1 -0
- package/dist/mg-components/p-adec7fcc.entry.js +1 -0
- package/dist/mg-components/p-c63f97f0.entry.js +1658 -0
- package/dist/mg-components/p-c8c8cfc1.entry.js +1 -0
- package/dist/mg-components/p-cc793586.entry.js +1 -0
- package/dist/mg-components/p-d5e69c95.entry.js +1 -0
- package/dist/types/assets/icons/index.d.ts +2 -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/editor/editor.conf.d.ts +17 -0
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/editor/index.d.ts +27 -19
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.conf.d.ts +3 -0
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +50 -16
- package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.conf.d.ts +0 -5
- package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.d.ts +1 -6
- package/dist/types/components/molecules/menus/mg-menu/mg-menu.conf.d.ts +2 -10
- package/dist/types/components/molecules/menus/mg-menu/mg-menu.d.ts +7 -7
- package/dist/types/components/molecules/menus/mg-menu-item/mg-menu-item.d.ts +12 -8
- package/dist/types/components/molecules/mg-breadcrumb/mg-breadcrumb.conf.d.ts +18 -0
- package/dist/types/components/molecules/mg-breadcrumb/mg-breadcrumb.d.ts +34 -0
- package/dist/types/components/molecules/mg-table/mg-table.d.ts +6 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +1 -9
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +4 -4
- package/dist/types/components.d.ts +302 -46
- package/dist/types/stencil-public-runtime.d.ts +76 -12
- package/ide/intellij/web-types.json +483 -51
- package/ide/vscode/css-custom-data.json +10 -2
- package/ide/vscode/html-custom-data.json +445 -104
- package/package.json +24 -23
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.scss +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-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-cd061b38.entry.js +0 -1
- package/dist/mg-components/p-d2c72f09.entry.js +0 -1
- package/dist/mg-components/p-d5a276eb.entry.js +0 -1
- package/ide/vscode/custom.css-data.json +0 -425
|
@@ -1,463 +1 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { C as ClassList, i as isValidString, o as dateRegExp, p as dateToString, t as toString } from './index2.js';
|
|
3
|
-
import { l as localeDate, a as localeDatePattern, i as initLocales } from './index3.js';
|
|
4
|
-
import { d as defineCustomElement$5, c as classReadonly, a as classDisabled } from './mg-input2.js';
|
|
5
|
-
import { d as defineCustomElement$6 } from './mg-icon2.js';
|
|
6
|
-
import { d as defineCustomElement$4 } from './mg-input-title2.js';
|
|
7
|
-
import { d as defineCustomElement$3 } from './mg-tooltip2.js';
|
|
8
|
-
import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
|
|
9
|
-
|
|
10
|
-
const DEFAULT_MAX_DATE = '9999-12-31';
|
|
11
|
-
|
|
12
|
-
const mgInputDateCss = ".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__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-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}";
|
|
13
|
-
|
|
14
|
-
const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends HTMLElement {
|
|
15
|
-
constructor(registerHost) {
|
|
16
|
-
super();
|
|
17
|
-
if (registerHost !== false) {
|
|
18
|
-
this.__registerHost();
|
|
19
|
-
}
|
|
20
|
-
this.__attachShadow();
|
|
21
|
-
this.valueChange = createEvent(this, "value-change", 7);
|
|
22
|
-
this.inputValid = createEvent(this, "input-valid", 7);
|
|
23
|
-
// hasDisplayedError (triggered by blur event)
|
|
24
|
-
this.hasDisplayedError = false;
|
|
25
|
-
this.customErrorMessage = { lock: false };
|
|
26
|
-
/**
|
|
27
|
-
* Input name
|
|
28
|
-
* If not set the value equals the identifier
|
|
29
|
-
*/
|
|
30
|
-
this.name = this.identifier;
|
|
31
|
-
/**
|
|
32
|
-
* Define if label is displayed on top
|
|
33
|
-
*/
|
|
34
|
-
this.labelOnTop = false;
|
|
35
|
-
/**
|
|
36
|
-
* Define if label is visible
|
|
37
|
-
*/
|
|
38
|
-
this.labelHide = false;
|
|
39
|
-
/**
|
|
40
|
-
* Define if input is required
|
|
41
|
-
*/
|
|
42
|
-
this.required = false;
|
|
43
|
-
/**
|
|
44
|
-
* Define if input is readonly
|
|
45
|
-
*/
|
|
46
|
-
this.readonly = false;
|
|
47
|
-
/**
|
|
48
|
-
* Define input maximum date
|
|
49
|
-
* format: yyyy-mm-dd
|
|
50
|
-
*/
|
|
51
|
-
this.max = '9999-12-31'; // Hardcoded value matching DEFAULT_MAX_DATE for documentation
|
|
52
|
-
/**
|
|
53
|
-
* Define if input is disabled
|
|
54
|
-
*/
|
|
55
|
-
this.disabled = false;
|
|
56
|
-
/**
|
|
57
|
-
* Define tooltip position
|
|
58
|
-
*/
|
|
59
|
-
this.tooltipPosition = 'input';
|
|
60
|
-
/**
|
|
61
|
-
* Component classes
|
|
62
|
-
*/
|
|
63
|
-
this.classCollection = new ClassList(['mg-c-input--date']);
|
|
64
|
-
/**
|
|
65
|
-
* Method to validate date pattern string
|
|
66
|
-
* @param value - value to test
|
|
67
|
-
* @returns truthy when value match the pattern
|
|
68
|
-
*/
|
|
69
|
-
this.isValidPattern = (value) => isValidString(value) && dateRegExp.test(value);
|
|
70
|
-
/**
|
|
71
|
-
* Format help text to display
|
|
72
|
-
* @param helpText - help text format
|
|
73
|
-
* @returns formated pattern help text. Ex: Format attendu : jj/mm/aaaa (ex : 20/12/2020)
|
|
74
|
-
*/
|
|
75
|
-
this.formatHelpText = (helpText) => {
|
|
76
|
-
// If the component is in readonly mode, return directly because the message will not be rendered
|
|
77
|
-
if (this.readonly) {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
const defaultHelpTextVariable = '{defaultHelpText}';
|
|
81
|
-
// If a custom helpText is provided, store it but don't return it directly
|
|
82
|
-
let text = isValidString(helpText) ? helpText : this.messages.input.date.helpText.expectedFormat;
|
|
83
|
-
// Handle defaultHelpText
|
|
84
|
-
if (text.includes(defaultHelpTextVariable)) {
|
|
85
|
-
text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText.expectedFormat));
|
|
86
|
-
}
|
|
87
|
-
// Replace pattern and date variables
|
|
88
|
-
return text.replace('{pattern}', this.renderPattern()).replace('{date}', localeDate(dateToString(new Date('2025-12-24')), this.systemLocale));
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Handle input event
|
|
92
|
-
*/
|
|
93
|
-
this.handleInput = () => {
|
|
94
|
-
this.checkValidity();
|
|
95
|
-
if (this.hasDisplayedError) {
|
|
96
|
-
this.setErrorMessage();
|
|
97
|
-
}
|
|
98
|
-
this.value = this.input.value;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Handle blur event
|
|
102
|
-
*/
|
|
103
|
-
this.handleBlur = () => {
|
|
104
|
-
this.handlerInProgress = 'blur';
|
|
105
|
-
this.displayError().finally(() => {
|
|
106
|
-
// reset guard
|
|
107
|
-
this.handlerInProgress = undefined;
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Handle keydown event
|
|
112
|
-
* @param event - input keydown event
|
|
113
|
-
*/
|
|
114
|
-
this.handleKeyDown = (event) => {
|
|
115
|
-
// bypass the native "Delete" action wich trigger an "input" event with "checkValidty() => false" with a falsy badInput = true,
|
|
116
|
-
// when we reset the field we need to test a blank value.
|
|
117
|
-
if (['Delete', 'Backspace'].includes(event.key)) {
|
|
118
|
-
event.preventDefault();
|
|
119
|
-
this.value = null;
|
|
120
|
-
this.checkValidity();
|
|
121
|
-
if (this.hasDisplayedError) {
|
|
122
|
-
this.setErrorMessage();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* Check if input is valid
|
|
128
|
-
*/
|
|
129
|
-
this.checkValidity = () => {
|
|
130
|
-
this.setValidity(this.readonly || this.disabled || (this.input.checkValidity() && (this.value === null || this.isValidPattern(this.value))));
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* get input error code
|
|
134
|
-
* @returns error code
|
|
135
|
-
*/
|
|
136
|
-
this.getInputError = () => {
|
|
137
|
-
var _a;
|
|
138
|
-
let error;
|
|
139
|
-
// bad input or pattern
|
|
140
|
-
if (this.input.validity.badInput || (this.value && !this.isValidPattern(this.value))) {
|
|
141
|
-
error = 'badInput';
|
|
142
|
-
}
|
|
143
|
-
// required
|
|
144
|
-
else if (this.input.validity.valueMissing) {
|
|
145
|
-
error = 'required';
|
|
146
|
-
}
|
|
147
|
-
// min & max
|
|
148
|
-
else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
|
|
149
|
-
error = 'minMax';
|
|
150
|
-
}
|
|
151
|
-
// min
|
|
152
|
-
else if (this.input.validity.rangeUnderflow) {
|
|
153
|
-
error = 'min';
|
|
154
|
-
}
|
|
155
|
-
// max
|
|
156
|
-
else if (this.input.validity.rangeOverflow) {
|
|
157
|
-
error = 'max';
|
|
158
|
-
}
|
|
159
|
-
return error;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Check input errors
|
|
163
|
-
* @param fromSetErrorContext - context come from `setError` method
|
|
164
|
-
*/
|
|
165
|
-
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
166
|
-
// Set error message
|
|
167
|
-
this.errorMessage = undefined;
|
|
168
|
-
if (!this.valid) {
|
|
169
|
-
const inputError = this.getInputError();
|
|
170
|
-
// Does have a new custom error message OR does have a custom error message locked
|
|
171
|
-
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
172
|
-
this.errorMessage = this.customErrorMessage.message;
|
|
173
|
-
}
|
|
174
|
-
// required
|
|
175
|
-
else if (inputError === 'required') {
|
|
176
|
-
this.errorMessage = this.messages.errors[inputError];
|
|
177
|
-
}
|
|
178
|
-
// min, max & minMax
|
|
179
|
-
else if (['min', 'max', 'minMax'].includes(inputError)) {
|
|
180
|
-
this.errorMessage = this.messages.input.date.error[inputError]
|
|
181
|
-
.replace('{min}', localeDate(this.min, this.systemLocale))
|
|
182
|
-
.replace('{max}', localeDate(this.max, this.systemLocale));
|
|
183
|
-
}
|
|
184
|
-
// wrong date format
|
|
185
|
-
// element.validity.badInput is default error message
|
|
186
|
-
else {
|
|
187
|
-
this.errorMessage = this.messages.input.date.error.badInput
|
|
188
|
-
.replace('{pattern}', this.renderPattern())
|
|
189
|
-
.replace('{date}', localeDate(dateToString(new Date('2025-12-24')), this.systemLocale));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* Render pattern
|
|
195
|
-
* @returns translated html pattern
|
|
196
|
-
*/
|
|
197
|
-
this.renderPattern = () => {
|
|
198
|
-
let patternLocal = localeDatePattern(this.systemLocale);
|
|
199
|
-
for (const key in this.messages.input.date.pattern) {
|
|
200
|
-
patternLocal = patternLocal.replace(key, this.messages.input.date.pattern[key]);
|
|
201
|
-
}
|
|
202
|
-
return `<span aria-hidden="true">${patternLocal}</span><span class="mg-u-visually-hidden">${[...patternLocal].join(' ')}</span>`;
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
validateValue(newValue) {
|
|
206
|
-
// When the input is not fully completed or has been cleared, the value becomes an empty string.
|
|
207
|
-
if (['', undefined].includes(newValue)) {
|
|
208
|
-
// need to force value update to `null` to prevent extra render
|
|
209
|
-
// - `''` is not a valide value
|
|
210
|
-
// - `undefined` is not allowed in CustomEvent['detail']
|
|
211
|
-
this.value = null;
|
|
212
|
-
}
|
|
213
|
-
else if (newValue && !isValidString(newValue)) {
|
|
214
|
-
// check value validity
|
|
215
|
-
throw new Error(`<mg-input-date> props 'value' must be a valid string. Passed value: ${toString(newValue)}.`);
|
|
216
|
-
}
|
|
217
|
-
else if (newValue === null || this.isValidPattern(newValue)) {
|
|
218
|
-
this.valueChange.emit(newValue);
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
console.error("<mg-input-date> props 'value' doesn't match pattern: 'yyyy-mm-dd'.");
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
watchReadonly(newValue) {
|
|
225
|
-
if (newValue)
|
|
226
|
-
this.classCollection.add(classReadonly);
|
|
227
|
-
else
|
|
228
|
-
this.classCollection.delete(classReadonly);
|
|
229
|
-
}
|
|
230
|
-
validateMinMax(newValue) {
|
|
231
|
-
if (newValue && !this.isValidPattern(newValue)) {
|
|
232
|
-
throw new Error(`<mg-input-date> props 'min/max' doesn't match pattern: 'yyyy-mm-dd'. Passed value: ${toString(newValue)}.`);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
handleValidityChange(newValue, _oldValue, prop) {
|
|
236
|
-
if (this.input !== undefined) {
|
|
237
|
-
this.input[prop] = newValue;
|
|
238
|
-
this.checkValidity();
|
|
239
|
-
if (this.hasDisplayedError) {
|
|
240
|
-
this.setErrorMessage();
|
|
241
|
-
this.hasDisplayedError = false;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
watchDisabled(newValue) {
|
|
246
|
-
if (newValue)
|
|
247
|
-
this.classCollection.add(classDisabled);
|
|
248
|
-
else
|
|
249
|
-
this.classCollection.delete(classDisabled);
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Set focus on input.
|
|
253
|
-
*/
|
|
254
|
-
async setFocus() {
|
|
255
|
-
var _a;
|
|
256
|
-
(_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Display input error if it exists.
|
|
260
|
-
*/
|
|
261
|
-
displayError() {
|
|
262
|
-
// Use `Promise` as requested for stencil method
|
|
263
|
-
// Use `requestAnimationFrame` to ensure:
|
|
264
|
-
// - DOM is fully updated before validation
|
|
265
|
-
// - Async operations are completed
|
|
266
|
-
// - No timing issues with Stencil's render cycle
|
|
267
|
-
// - Keep everything in sync both inside and outside the component
|
|
268
|
-
return new Promise(resolve => {
|
|
269
|
-
requestAnimationFrame(() => {
|
|
270
|
-
this.checkValidity();
|
|
271
|
-
this.setErrorMessage();
|
|
272
|
-
this.hasDisplayedError = this.invalid;
|
|
273
|
-
resolve();
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Set an error and display a custom error message.
|
|
279
|
-
* This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.
|
|
280
|
-
* It must be paired with an error message to display for the given context.
|
|
281
|
-
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
282
|
-
* @param valid - value indicating the validity
|
|
283
|
-
* @param errorMessage - the error message to display
|
|
284
|
-
* @param errorMessageLock - lock the error message and validity state
|
|
285
|
-
*/
|
|
286
|
-
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
287
|
-
if (typeof valid !== 'boolean') {
|
|
288
|
-
throw new Error('<mg-input-date> method "setError()" param "valid" must be a boolean.');
|
|
289
|
-
}
|
|
290
|
-
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
291
|
-
throw new Error('<mg-input-date> method "setError()" param "errorMessage" must be a string.');
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
this.customErrorMessage = {
|
|
295
|
-
lock: valid ? false : errorMessageLock,
|
|
296
|
-
message: valid ? undefined : errorMessage,
|
|
297
|
-
};
|
|
298
|
-
this.setValidity(valid);
|
|
299
|
-
this.setErrorMessage(true);
|
|
300
|
-
this.hasDisplayedError = this.invalid;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Reset value, validity and error state
|
|
305
|
-
*/
|
|
306
|
-
async reset() {
|
|
307
|
-
if (!this.readonly) {
|
|
308
|
-
this.value = null;
|
|
309
|
-
// Use `Promise` as requested for stencil method
|
|
310
|
-
// Use `requestAnimationFrame` to ensure:
|
|
311
|
-
// - DOM is fully updated before validation
|
|
312
|
-
// - Async operations are completed
|
|
313
|
-
// - No timing issues with Stencil's render cycle
|
|
314
|
-
// - Keep everything in sync both inside and outside the component
|
|
315
|
-
return new Promise(resolve => {
|
|
316
|
-
requestAnimationFrame(() => {
|
|
317
|
-
// unlock validity check by reseting customErrorMessage
|
|
318
|
-
this.customErrorMessage = { lock: false };
|
|
319
|
-
this.checkValidity();
|
|
320
|
-
this.errorMessage = undefined;
|
|
321
|
-
this.hasDisplayedError = false;
|
|
322
|
-
resolve();
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Method to set validity values
|
|
329
|
-
* @param newValue - valid new value
|
|
330
|
-
*/
|
|
331
|
-
setValidity(newValue) {
|
|
332
|
-
const oldValue = this.valid;
|
|
333
|
-
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
334
|
-
this.valid = newValue;
|
|
335
|
-
}
|
|
336
|
-
this.invalid = !this.valid;
|
|
337
|
-
// We need to send valid event even if it is the same value
|
|
338
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
339
|
-
this.inputValid.emit(this.valid);
|
|
340
|
-
}
|
|
341
|
-
/*************
|
|
342
|
-
* Lifecycle *
|
|
343
|
-
*************/
|
|
344
|
-
/**
|
|
345
|
-
* Check if component props are well configured on init
|
|
346
|
-
* @returns timeout
|
|
347
|
-
*/
|
|
348
|
-
componentWillLoad() {
|
|
349
|
-
// Get locales
|
|
350
|
-
const locales = initLocales(this.element);
|
|
351
|
-
this.locale = locales.locale;
|
|
352
|
-
this.messages = locales.messages;
|
|
353
|
-
// as a native input use the OS locale to define the date pattern
|
|
354
|
-
// we need to get this locale to define the displayed pattern
|
|
355
|
-
this.systemLocale = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
356
|
-
// Validate
|
|
357
|
-
this.validateValue(this.value);
|
|
358
|
-
this.validateMinMax(this.min);
|
|
359
|
-
this.validateMinMax(this.max);
|
|
360
|
-
this.watchReadonly(this.readonly);
|
|
361
|
-
this.watchDisabled(this.disabled);
|
|
362
|
-
// Check validity when component is ready
|
|
363
|
-
// return a promise to process action only in the FIRST render().
|
|
364
|
-
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
365
|
-
return setTimeout(() => {
|
|
366
|
-
this.checkValidity();
|
|
367
|
-
}, 0);
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Render
|
|
371
|
-
* @returns HTML Element
|
|
372
|
-
*/
|
|
373
|
-
render() {
|
|
374
|
-
return (h("mg-input", { key: '1428f0f9f11d829ec8d3ed507c8690d63839ff17', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === null ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly ? (this.value && h("b", { class: "mg-c-input__readonly-value" }, localeDate(this.value, this.locale))) : (h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
|
|
375
|
-
if (el !== null)
|
|
376
|
-
this.input = el;
|
|
377
|
-
} }))));
|
|
378
|
-
}
|
|
379
|
-
get element() { return this; }
|
|
380
|
-
static get watchers() { return {
|
|
381
|
-
"value": ["validateValue"],
|
|
382
|
-
"readonly": ["watchReadonly", "handleValidityChange"],
|
|
383
|
-
"min": ["validateMinMax", "handleValidityChange"],
|
|
384
|
-
"max": ["validateMinMax", "handleValidityChange"],
|
|
385
|
-
"required": ["handleValidityChange"],
|
|
386
|
-
"disabled": ["handleValidityChange", "watchDisabled"]
|
|
387
|
-
}; }
|
|
388
|
-
static get style() { return mgInputDateCss; }
|
|
389
|
-
}, [257, "mg-input-date", {
|
|
390
|
-
"value": [1537],
|
|
391
|
-
"identifier": [1],
|
|
392
|
-
"name": [1],
|
|
393
|
-
"label": [1],
|
|
394
|
-
"labelOnTop": [4, "label-on-top"],
|
|
395
|
-
"labelHide": [4, "label-hide"],
|
|
396
|
-
"required": [4],
|
|
397
|
-
"readonly": [4],
|
|
398
|
-
"min": [1],
|
|
399
|
-
"max": [1],
|
|
400
|
-
"disabled": [4],
|
|
401
|
-
"tooltip": [1],
|
|
402
|
-
"tooltipPosition": [1, "tooltip-position"],
|
|
403
|
-
"helpText": [1, "help-text"],
|
|
404
|
-
"valid": [1028],
|
|
405
|
-
"invalid": [1028],
|
|
406
|
-
"classCollection": [32],
|
|
407
|
-
"errorMessage": [32],
|
|
408
|
-
"setFocus": [64],
|
|
409
|
-
"displayError": [64],
|
|
410
|
-
"setError": [64],
|
|
411
|
-
"reset": [64]
|
|
412
|
-
}, undefined, {
|
|
413
|
-
"value": ["validateValue"],
|
|
414
|
-
"readonly": ["watchReadonly", "handleValidityChange"],
|
|
415
|
-
"min": ["validateMinMax", "handleValidityChange"],
|
|
416
|
-
"max": ["validateMinMax", "handleValidityChange"],
|
|
417
|
-
"required": ["handleValidityChange"],
|
|
418
|
-
"disabled": ["handleValidityChange", "watchDisabled"]
|
|
419
|
-
}]);
|
|
420
|
-
function defineCustomElement$1() {
|
|
421
|
-
if (typeof customElements === "undefined") {
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
const components = ["mg-input-date", "mg-icon", "mg-input", "mg-input-title", "mg-tooltip", "mg-tooltip-content"];
|
|
425
|
-
components.forEach(tagName => { switch (tagName) {
|
|
426
|
-
case "mg-input-date":
|
|
427
|
-
if (!customElements.get(tagName)) {
|
|
428
|
-
customElements.define(tagName, MgInputDate$1);
|
|
429
|
-
}
|
|
430
|
-
break;
|
|
431
|
-
case "mg-icon":
|
|
432
|
-
if (!customElements.get(tagName)) {
|
|
433
|
-
defineCustomElement$6();
|
|
434
|
-
}
|
|
435
|
-
break;
|
|
436
|
-
case "mg-input":
|
|
437
|
-
if (!customElements.get(tagName)) {
|
|
438
|
-
defineCustomElement$5();
|
|
439
|
-
}
|
|
440
|
-
break;
|
|
441
|
-
case "mg-input-title":
|
|
442
|
-
if (!customElements.get(tagName)) {
|
|
443
|
-
defineCustomElement$4();
|
|
444
|
-
}
|
|
445
|
-
break;
|
|
446
|
-
case "mg-tooltip":
|
|
447
|
-
if (!customElements.get(tagName)) {
|
|
448
|
-
defineCustomElement$3();
|
|
449
|
-
}
|
|
450
|
-
break;
|
|
451
|
-
case "mg-tooltip-content":
|
|
452
|
-
if (!customElements.get(tagName)) {
|
|
453
|
-
defineCustomElement$2();
|
|
454
|
-
}
|
|
455
|
-
break;
|
|
456
|
-
} });
|
|
457
|
-
}
|
|
458
|
-
defineCustomElement$1();
|
|
459
|
-
|
|
460
|
-
const MgInputDate = MgInputDate$1;
|
|
461
|
-
const defineCustomElement = defineCustomElement$1;
|
|
462
|
-
|
|
463
|
-
export { MgInputDate, defineCustomElement };
|
|
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 o,o as r,p as h,t as l}from"./index2.js";import{a as m,b as d,i as p}from"./index3.js";import{c as u,b as c}from"./mg-input.conf.js";import{d as g}from"./mg-icon2.js";import{d as b}from"./mg-input2.js";import{d as v}from"./mg-input-title2.js";import{d as f}from"./mg-tooltip2.js";import{d as y}from"./mg-tooltip-content2.js";const x=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.hasDisplayedError=!1,this.customErrorMessage={lock:!1},this.name=this.identifier,this.labelOnTop=!1,this.labelHide=!1,this.required=!1,this.readonly=!1,this.max="9999-12-31",this.disabled=!1,this.tooltipPosition="input",this.classCollection=new n(["mg-c-input--date"]),this.isValidPattern=t=>o(t)&&r.test(t),this.formatHelpText=t=>{if(this.readonly)return;const i="{defaultHelpText}";let e=o(t)?t:this.messages.input.date.helpText.expectedFormat;return e.includes(i)&&(e=e.replace(i,this.formatHelpText(this.messages.input.date.helpText.expectedFormat))),e.replace("{pattern}",this.renderPattern()).replace("{date}",m(h(new Date("2025-12-24")),this.systemLocale))},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.handleKeyDown=t=>{["Delete","Backspace"].includes(t.key)&&(t.preventDefault(),this.value=null,this.checkValidity(),this.hasDisplayedError&&this.setErrorMessage())},this.checkValidity=()=>{this.setValidity(this.readonly||this.disabled||this.input.checkValidity()&&(null===this.value||this.isValidPattern(this.value)))},this.getInputError=()=>{var t;let i;return this.input.validity.badInput||this.value&&!this.isValidPattern(this.value)?i="badInput":this.input.validity.valueMissing?i="required":(this.input.validity.rangeUnderflow||this.input.validity.rangeOverflow)&&(null===(t=this.min)||void 0===t?void 0:t.length)>0&&"9999-12-31"!==this.max?i="minMax":this.input.validity.rangeUnderflow?i="min":this.input.validity.rangeOverflow&&(i="max"),i},this.setErrorMessage=(t=!1)=>{if(this.errorMessage=void 0,!this.valid){const i=this.getInputError();this.errorMessage=t||this.customErrorMessage.lock&&void 0!==this.customErrorMessage.message?this.customErrorMessage.message:"required"===i?this.messages.errors[i]:["min","max","minMax"].includes(i)?this.messages.input.date.error[i].replace("{min}",m(this.min,this.systemLocale)).replace("{max}",m(this.max,this.systemLocale)):this.messages.input.date.error.badInput.replace("{pattern}",this.renderPattern()).replace("{date}",m(h(new Date("2025-12-24")),this.systemLocale))}},this.renderPattern=()=>{let t=d(this.systemLocale);for(const i in this.messages.input.date.pattern)t=t.replace(i,this.messages.input.date.pattern[i]);return`<span aria-hidden="true">${t}</span><span class="mg-u-visually-hidden">${[...t].join(" ")}</span>`}}validateValue(t){if(["",void 0].includes(t))this.value=null;else{if(t&&!o(t))throw Error(`<mg-input-date> props 'value' must be a valid string. Passed value: ${l(t)}.`);null===t||this.isValidPattern(t)?this.valueChange.emit(t):console.error("<mg-input-date> props 'value' doesn't match pattern: 'yyyy-mm-dd'.")}}watchReadonly(t){t?this.classCollection.add(u):this.classCollection.delete(u)}validateMinMax(t){if(t&&!this.isValidPattern(t))throw Error(`<mg-input-date> props 'min/max' doesn't match pattern: 'yyyy-mm-dd'. Passed value: ${l(t)}.`)}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)}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 Error('<mg-input-date> method "setError()" param "valid" must be a boolean.');if(void 0!==i&&!o(i))throw Error('<mg-input-date> 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=null,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(){const t=p(this.element);return this.locale=t.locale,this.messages=t.messages,this.systemLocale=Intl.DateTimeFormat().resolvedOptions().locale,this.validateValue(this.value),this.validateMinMax(this.min),this.validateMinMax(this.max),this.watchReadonly(this.readonly),this.watchDisabled(this.disabled),setTimeout((()=>{this.checkValidity()}),0)}render(){return a("mg-input",{key:"53d23a27355884d3b3ac996188f619ad325d58b6",label:this.label,identifier:this.identifier,class:this.classCollection.join(),labelOnTop:this.labelOnTop,labelHide:this.labelHide,required:this.required,tooltip:this.tooltip,tooltipPosition:this.readonly&&null===this.value?"label":this.tooltipPosition,helpText:this.formatHelpText(this.helpText),errorMessage:this.errorMessage},this.readonly?this.value&&a("b",{class:"mg-c-input__readonly-value"},m(this.value,this.locale)):a("input",{type:"date",class:"mg-c-input__box",min:this.min,max:this.max,value:this.value,id:this.identifier,name:this.name,disabled:this.disabled,required:this.required,"aria-invalid":""+(!0===this.invalid),onInput:this.handleInput,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,ref:t=>{null!==t&&(this.input=t)}}))}get element(){return this}static get watchers(){return{value:[{validateValue:0}],readonly:[{watchReadonly:0},{handleValidityChange:0}],min:[{validateMinMax:0},{handleValidityChange:0}],max:[{validateMinMax:0},{handleValidityChange:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}]}}static get style(){return".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__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-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}"}},[1,"mg-input-date",{value:[1537],identifier:[1],name:[1],label:[1],labelOnTop:[4,"label-on-top"],labelHide:[4,"label-hide"],required:[4],readonly:[4],min:[1],max:[1],disabled:[4],tooltip:[1],tooltipPosition:[1,"tooltip-position"],helpText:[1,"help-text"],valid:[1028],invalid:[1028],classCollection:[32],errorMessage:[32],setFocus:[64],displayError:[64],setError:[64],reset:[64]},void 0,{value:[{validateValue:0}],readonly:[{watchReadonly:0},{handleValidityChange:0}],min:[{validateMinMax:0},{handleValidityChange:0}],max:[{validateMinMax:0},{handleValidityChange:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}]}]);function w(){"undefined"!=typeof customElements&&["mg-input-date","mg-icon","mg-input","mg-input-title","mg-tooltip","mg-tooltip-content"].forEach((i=>{switch(i){case"mg-input-date":customElements.get(t(i))||customElements.define(t(i),x);break;case"mg-icon":customElements.get(t(i))||g();break;case"mg-input":customElements.get(t(i))||b();break;case"mg-input-title":customElements.get(t(i))||v();break;case"mg-tooltip":customElements.get(t(i))||f();break;case"mg-tooltip-content":customElements.get(t(i))||y()}}))}w();const _=x,E=w;export{_ as MgInputDate,E as defineCustomElement}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface MgInputFile extends Components.MgInputFile, HTMLElement {}
|
|
4
|
+
export const MgInputFile: {
|
|
5
|
+
prototype: MgInputFile;
|
|
6
|
+
new (): MgInputFile;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{transformTag as t,proxyCustomElement as i,HTMLElement as e,createEvent as s,h as o}from"@stencil/core/internal/client";import{C as a,d as r,t as n,i as l,k as h}from"./index2.js";import{l as m,i as c}from"./index3.js";import{b as p}from"./mg-input.conf.js";import{d as u}from"./mg-button2.js";import{d as g}from"./mg-icon2.js";import{d}from"./mg-input2.js";import{d as b}from"./mg-input-title2.js";import{d as f}from"./mg-tooltip2.js";import{d as v}from"./mg-tooltip-content2.js";const _=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.hasDisplayedError=!1,this.customErrorMessage={lock:!1},this.name=this.identifier,this.labelOnTop=!1,this.labelHide=!1,this.multiple=!1,this.required=!1,this.disabled=!1,this.tooltipPosition="input",this.classCollection=new a(["mg-c-input--file"]),this.files=[],this.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)},this.handleInputChange=t=>{this.checkValidity(),this.hasDisplayedError&&this.setErrorMessage(),this.files=Array.from(t.target.files),this.fileButtonElement.focus()},this.handleInputFocus=()=>{this.fileButtonElement.dataset.focusVisible=""},this.handleInputBlur=()=>{this.handlerInProgress="blur",this.displayError().finally((()=>{this.handlerInProgress=void 0})),delete this.fileButtonElement.dataset.focusVisible},this.handleButtonBlur=()=>{this.inputElement.blur()},this.handleButtonClick=()=>{this.inputElement.click()},this.checkValidity=()=>{this.setValidity(this.disabled||!this.isMaxSizeExceeded()&&this.inputElement.checkValidity())},this.handleDeleteFileClick=()=>{this.files=[],this.fileButtonElement.focus()},this.setErrorMessage=(t=!1)=>{this.errorMessage=void 0,this.valid||(t||this.customErrorMessage.lock&&void 0!==this.customErrorMessage.message?this.errorMessage=this.customErrorMessage.message:this.isMaxSizeExceeded()?this.errorMessage=this.messages.input.file.errors.maxSize.replace("{{maxSize}}",m(this.maxSize,this.locale)):this.inputElement.validity.valueMissing&&(this.errorMessage=this.messages.errors.required))},this.isMaxSizeExceeded=()=>this.maxSize>=0&&this.files.some((t=>t.size>this.maxSize)),this.renderFiles=()=>{const t=this.identifier+"-file-list",i=t=>o("span",{class:"mg-c-input__file-item-name"},t.name,t.size>0?o("span",{class:"mg-c-input__file-item-size"}," "+m(t.size,this.locale)):void 0),e=()=>o("mg-button",{variant:"flat",class:"mg-c-input__file-delete-button","is-icon":!0,label:this.messages.input.file.deleteButton,type:"button",disabled:this.disabled,"aria-controls":[this.identifier,t].join(" "),onClick:this.handleDeleteFileClick},o("mg-icon",{icon:"cross"}));return 0===this.files.length?null:1===this.files.length?o("div",{class:"mg-c-input__file-item"},i(this.files[0]),e()):o("div",{class:"mg-c-input__file-list-container"},o("ul",{role:"list",class:"mg-c-input__file-list",id:t},Array.from(this.files).map(((t,e)=>o("li",{class:"mg-c-input__file-item",key:`${t.name}-${e}`},i(t))))),e())}}watchValue(t){if(r(t))this.files=this.value.map((t=>new File([],t)));else if((t=>Array.isArray(t)&&t.every((t=>h(t)&&"string"==typeof t.name&&"number"==typeof t.size)))(t))this.files=this.value;else{if(void 0!==t)throw Error(`<mg-input-file> prop "value" must be an array of strings or File objects. Passed value: ${n(t)}.`);this.files=[]}this.valueChange.emit(t)}watchMultiple(){if(!1===this.multiple&&this.files.length>1)throw Error('<mg-input-file> prop "value" must be a single file when prop "multiple" is set to false.')}watchAccept(t){if(void 0!==t&&!l(t))throw Error('<mg-input-file> prop "accept" must be a valid string.')}handleValidityChange(t,i,e){void 0!==this.inputElement&&(this.inputElement[e]=t,this.checkValidity(),this.hasDisplayedError&&(this.setErrorMessage(),this.hasDisplayedError=!1))}watchDisabled(t){t?this.classCollection.add(p):this.classCollection.delete(p)}watchHelpText(){if(!l(this.helpText)){const t=[];void 0!==this.maxSize&&t.push(this.messages.input.file.helpText.maxSize.replace("{{maxSize}}",m(this.maxSize,this.locale))),void 0!==this.accept&&t.push(this.messages.input.file.helpText.accept.replace("{{accept}}",this.accept)),this.helpText=t.join(". ")}}watchFiles(t,i){n(t)!==n(i)&&(this.value=t.length>0?t:void 0)}async setFocus(){this.fileButtonElement.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 Error('<mg-input-file> method "setError()" param "valid" must be a boolean.');if(void 0!==i&&!l(i))throw Error('<mg-input-file> 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(){return this.files=[],new Promise((t=>{requestAnimationFrame((()=>{this.customErrorMessage={lock:!1},this.checkValidity(),this.errorMessage=void 0,this.hasDisplayedError=!1,t()}))}))}componentWillLoad(){const t=c(this.element);return this.locale=t.locale,this.messages=t.messages,this.watchValue(this.value),this.watchDisabled(this.disabled),this.watchHelpText(),this.watchAccept(this.accept),this.watchMultiple(),setTimeout((()=>{this.checkValidity()}),0)}render(){return o("mg-input",{key:"48337d8e0a059dbea60c4bfa152468429b37b897",label:this.label,identifier:this.identifier,class:this.classCollection.join(),labelOnTop:this.labelOnTop,labelHide:this.labelHide,required:this.required,tooltip:this.tooltip,tooltipPosition:this.tooltipPosition,helpText:this.helpText,errorMessage:this.errorMessage},o("div",{key:"b0a67412ce2a054ce84f001efe01156bfce001a1",class:"mg-c-input__file-container"},o("input",{key:"0585b37ac4da8e5b29b94c04a298cfd8451016c9",name:this.name,id:this.identifier,class:"mg-u-visually-hidden",type:"file",multiple:!0===this.multiple,capture:this.capture,accept:this.accept,disabled:this.disabled,required:0===this.files.length&&this.required,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur,onChange:this.handleInputChange,"aria-invalid":""+(!0===this.invalid),ref:t=>{this.inputElement=t}}),o("mg-button",{key:"0c71ea34375f60a357ad2aa38353c7acafc1091a",variant:"secondary",class:"mg-c-input__file-button",type:"button",disabled:this.disabled,onClick:this.handleButtonClick,onBlur:this.handleButtonBlur,tabindex:"-1",ref:t=>{this.fileButtonElement=t}},this.messages.input.file.browse),this.renderFiles()))}get element(){return this}static get watchers(){return{value:[{watchValue:0},{watchMultiple:0}],multiple:[{watchMultiple:0}],accept:[{watchAccept:0},{watchHelpText:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}],helpText:[{watchHelpText:0}],maxSize:[{watchHelpText:0}],files:[{watchFiles:0}]}}static get style(){return".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__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-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}}.mg-c-input__file-container{display:flex;flex-direction:column;gap:var(--mg-b-size-8)}.mg-c-input__file-item{display:inline-flex;min-height:var(--mg-b-size-min-height);align-items:center;padding-left:var(--mg-b-size-8);background-color:var(--mg-b-color-neutral-10);font-weight:600;gap:var(--mg-b-size-8)}.mg-c-input__file-item-name{word-break:break-all}.mg-c-input__file-item-size{color:var(--mg-b-color-neutral-90);font-weight:400;word-break:normal}.mg-c-input__file-delete-button{align-self:flex-start}.mg-c-input__file-list{display:flex;flex-direction:column;padding:0;margin:0;gap:var(--mg-b-size-4);list-style:none}.mg-c-input__file-list .mg-c-input__file-item{min-height:unset;padding:var(--mg-b-size-8)}.mg-c-input__file-list-container{position:relative;padding:var(--mg-b-size-8) calc(var(--mg-b-size-8) + var(--mg-b-size-min-height)) var(--mg-b-size-8) var(--mg-b-size-8);border:var(--mg-b-size-border) solid var(--mg-b-color-neutral-30);border-radius:var(--mg-b-size-4)}.mg-c-input__file-list-container .mg-c-input__file-delete-button{position:absolute;top:0;right:0}"}},[1,"mg-input-file",{value:[1032],identifier:[1],name:[1],label:[1],labelOnTop:[4,"label-on-top"],labelHide:[4,"label-hide"],multiple:[4],accept:[1],maxSize:[2,"max-size"],capture:[1],required:[4],disabled:[4],tooltip:[1],tooltipPosition:[1,"tooltip-position"],helpText:[1025,"help-text"],valid:[1028],invalid:[1028],classCollection:[32],errorMessage:[32],files:[32],setFocus:[64],displayError:[64],setError:[64],reset:[64]},void 0,{value:[{watchValue:0},{watchMultiple:0}],multiple:[{watchMultiple:0}],accept:[{watchAccept:0},{watchHelpText:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}],helpText:[{watchHelpText:0}],maxSize:[{watchHelpText:0}],files:[{watchFiles:0}]}]);function w(){"undefined"!=typeof customElements&&["mg-input-file","mg-button","mg-icon","mg-input","mg-input-title","mg-tooltip","mg-tooltip-content"].forEach((i=>{switch(i){case"mg-input-file":customElements.get(t(i))||customElements.define(t(i),_);break;case"mg-button":customElements.get(t(i))||u();break;case"mg-icon":customElements.get(t(i))||g();break;case"mg-input":customElements.get(t(i))||d();break;case"mg-input-title":customElements.get(t(i))||b();break;case"mg-tooltip":customElements.get(t(i))||f();break;case"mg-tooltip-content":customElements.get(t(i))||v()}}))}w();const y=_,x=w;export{y as MgInputFile,x as defineCustomElement}
|