@mgdis/mg-components 6.17.0 → 6.19.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-DCZEYvlH.js → index-Bp6wZzau.js} +5 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_37.cjs.entry.js +438 -212
- package/dist/cjs/mg-alert.cjs.entry.js +2 -2
- package/dist/cjs/mg-components.cjs.js +2 -2
- package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
- package/dist/cjs/mg-input-combobox.cjs.entry.js +93 -80
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +35 -26
- package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-D7jmj_lh.js} +7 -0
- package/dist/cjs/mg-loader.cjs.entry.js +2 -2
- package/dist/cjs/mg-progress.cjs.entry.js +2 -2
- package/dist/collection/assets/icons/index.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +5 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +178 -18
- 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-checkbox/mg-input-checkbox.js +36 -16
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +98 -78
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +41 -22
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +32 -12
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +30 -12
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +31 -12
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +41 -25
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +31 -12
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +60 -40
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +35 -33
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +36 -11
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +1 -1
- package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +5 -1
- 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-details/mg-details.js +1 -1
- package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +404 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +13 -4
- 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 +40 -9
- 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/components/mg-action-more.js +1 -1
- package/dist/components/mg-alert.js +1 -1
- package/dist/components/mg-details.js +1 -1
- package/dist/components/mg-fieldset.d.ts +11 -0
- package/dist/components/mg-fieldset.js +209 -0
- package/dist/components/mg-form.js +4 -3
- package/dist/components/mg-icon2.js +1 -1
- package/dist/components/mg-illustrated-message.js +2 -2
- package/dist/components/mg-input-checkbox-paginated2.js +1 -1
- package/dist/components/mg-input-checkbox.js +29 -16
- package/dist/components/mg-input-combobox.js +92 -79
- package/dist/components/mg-input-date.js +34 -22
- package/dist/components/mg-input-numeric.js +25 -12
- package/dist/components/mg-input-password.js +23 -12
- package/dist/components/mg-input-radio.js +23 -11
- package/dist/components/mg-input-rich-text-editor.js +33 -24
- package/dist/components/mg-input-select2.js +24 -12
- package/dist/components/mg-input-text2.js +51 -39
- package/dist/components/mg-input-textarea.js +28 -33
- package/dist/components/mg-input-toggle.js +35 -10
- package/dist/components/mg-input2.js +119 -19
- package/dist/components/mg-item-more2.js +5 -1
- package/dist/components/mg-loader2.js +1 -1
- package/dist/components/mg-message2.js +2 -2
- package/dist/components/mg-modal.js +3 -3
- package/dist/components/mg-panel.js +37 -8
- package/dist/components/mg-popover-content2.js +2 -2
- package/dist/components/mg-popover2.js +2 -2
- package/dist/components/mg-progress.js +1 -1
- package/dist/components/mg-skip-links.js +1 -1
- package/dist/components/mg-tabs2.js +1 -1
- package/dist/esm/{index-T6kOJXP1.js → index-BluNKQ3L.js} +5 -1
- package/dist/esm/{index-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_37.entry.js +439 -213
- package/dist/esm/mg-alert.entry.js +3 -3
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-fieldset.entry.js +139 -0
- package/dist/esm/mg-input-combobox.entry.js +94 -81
- package/dist/esm/mg-input-rich-text-editor.entry.js +36 -27
- package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-DDnrE1hD.js} +6 -1
- package/dist/esm/mg-loader.entry.js +3 -3
- package/dist/esm/mg-progress.entry.js +3 -3
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-016bd291.entry.js +1 -0
- package/dist/mg-components/{p-397bf67b.entry.js → p-186a6139.entry.js} +1 -1
- package/dist/mg-components/p-66a1cb83.entry.js +1 -0
- package/dist/mg-components/p-6efd819f.entry.js +1 -0
- package/dist/mg-components/{p-c5da335e.entry.js → p-916dfb6d.entry.js} +1 -1
- package/dist/mg-components/p-BluNKQ3L.js +2 -0
- package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
- package/dist/mg-components/p-DDnrE1hD.js +1 -0
- package/dist/mg-components/{p-0e6b40d6.entry.js → p-d2c72f09.entry.js} +1 -1
- package/dist/mg-components/{p-5dc3a1fb.entry.js → p-d5a276eb.entry.js} +1 -1
- package/dist/types/assets/icons/index.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +32 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +8 -7
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -7
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -8
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -2
- package/dist/types/components/molecules/mg-fieldset/mg-fieldset.d.ts +105 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +8 -1
- package/dist/types/components.d.ts +168 -18
- package/ide/intellij/web-types.json +289 -22
- package/ide/vscode/css-custom-data.json +7 -3
- package/ide/vscode/html-custom-data.json +300 -8
- package/package.json +18 -18
- package/dist/mg-components/p-8a69175b.entry.js +0 -1
- package/dist/mg-components/p-CNgv8hc5.js +0 -1
- package/dist/mg-components/p-T6kOJXP1.js +0 -2
- package/dist/mg-components/p-d84d87ea.entry.js +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Bp6wZzau.js');
|
|
4
4
|
var index$1 = require('./index-CpENFzEo.js');
|
|
5
|
-
var mgInput_conf = require('./mg-input.conf-
|
|
5
|
+
var mgInput_conf = require('./mg-input.conf-D7jmj_lh.js');
|
|
6
6
|
var index$2 = require('./index-TUElr4Wv.js');
|
|
7
7
|
var events_utils = require('./events.utils-D5SAtkpQ.js');
|
|
8
8
|
|
|
9
|
-
const mgInputComboboxCss = ".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-
|
|
9
|
+
const mgInputComboboxCss = ".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__popover-info{padding:var(--mg-b-size-8);margin:0;color:var(--mg-b-color-neutral-90);text-align:center}.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-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--combobox mg-popover{--mg-c-card-overflow:hidden;--mg-c-popover-padding-vertical:0;--mg-c-popover-padding-horizontal:0}.mg-c-input.mg-c-input--combobox .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--combobox .mg-c-input__box{cursor:pointer}.mg-c-input.mg-c-input--combobox .mg-c-input__popover-container{display:flex;min-width:var(--mg-c-input-list-width);max-height:calc(50*var(--mg-b-size-8) - var(--mg-b-size-32));flex-direction:column;gap:var(--mg-b-size-4);overflow-y:scroll}.mg-c-input.mg-c-input--combobox .mg-c-input__load-more{padding:0 var(--mg-b-size-8) var(--mg-b-size-4)}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list{padding:0;margin:0;cursor:pointer;list-style:none}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item{display:flex;padding:var(--mg-b-size-8)}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item:hover,.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item.mg-c-input__input-list-item--focus-visible{background-color:var(--mg-b-color-neutral-20)}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item.mg-c-input__input-list-item--selected{font-weight:700}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item.mg-c-input__input-list-item--selected mg-icon{margin-left:auto}.mg-c-input.mg-c-input--combobox.mg-c-input--width-2 .mg-c-input__box{width:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2 + var(--mg-b-size-24) + var(--mg-b-size-min-height) + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-4 .mg-c-input__box{width:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2 + var(--mg-b-size-48) + var(--mg-b-size-min-height) + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-16 .mg-c-input__box{width:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2 + calc(23 * var(--mg-b-size-8)) + var(--mg-b-size-min-height) + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-full mg-popover{--mg-c-popover-max-width:var(--mg-c-input-list-width, var(--mg-c-popover-max-width))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-full .mg-c-input__input-group-container{display:flex;width:100%}.mg-c-input.mg-c-input--combobox.mg-c-input--width-full .mg-c-input__box{flex:1}.mg-c-input.mg-c-input--combobox.mg-c-input--input-append .mg-c-input__box{padding-right:calc(var(--mg-b-size-min-height) + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--input-append .mg-c-input__box-append{position:absolute;top:0;right:0}";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Check if object is an item
|
|
@@ -31,7 +31,7 @@ const isFetchmappings = (value) => {
|
|
|
31
31
|
const { request, response } = value;
|
|
32
32
|
if ([request, response].some(property => !index$1.isObject(property)))
|
|
33
33
|
return false;
|
|
34
|
-
const isValidRequest = typeof request.filter === 'string';
|
|
34
|
+
const isValidRequest = typeof request.filter === 'string' && (request.filterTransform === undefined || typeof request.filterTransform === 'function');
|
|
35
35
|
const isValidResponse = typeof response === 'object' &&
|
|
36
36
|
typeof response.total === 'string' &&
|
|
37
37
|
typeof response.items === 'string' &&
|
|
@@ -52,13 +52,9 @@ const MgInputCombobox = class {
|
|
|
52
52
|
this.showMore = index.createEvent(this, "load-more", 7);
|
|
53
53
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
54
54
|
this.fetchError = index.createEvent(this, "fetch-error", 7);
|
|
55
|
-
/************
|
|
56
|
-
* Internal *
|
|
57
|
-
************/
|
|
58
|
-
// Classes
|
|
59
|
-
this.classFocus = 'mg-u-is-focused';
|
|
60
55
|
// hasDisplayedError (triggered by blur event)
|
|
61
56
|
this.hasDisplayedError = false;
|
|
57
|
+
this.customErrorMessage = { lock: false };
|
|
62
58
|
/**
|
|
63
59
|
* Input name
|
|
64
60
|
* If not set the value equals the identifier
|
|
@@ -113,7 +109,7 @@ const MgInputCombobox = class {
|
|
|
113
109
|
* @param event - option element click event
|
|
114
110
|
*/
|
|
115
111
|
this.handleOptionClick = (event) => {
|
|
116
|
-
this.setValue(this.options.items.find(option => index$1.
|
|
112
|
+
this.setValue(this.options.items.find(option => index$1.toString(option.value) === event.target.dataset.value));
|
|
117
113
|
this.popoverDisplay = false;
|
|
118
114
|
};
|
|
119
115
|
/**
|
|
@@ -193,7 +189,7 @@ const MgInputCombobox = class {
|
|
|
193
189
|
// override keys actions
|
|
194
190
|
switch (event.key) {
|
|
195
191
|
case events_utils.Keys.TAB:
|
|
196
|
-
case events_utils.Keys.ENTER:
|
|
192
|
+
case events_utils.Keys.ENTER: {
|
|
197
193
|
guard = event.key === events_utils.Keys.ENTER;
|
|
198
194
|
const option = (_a = this.option) !== null && _a !== void 0 ? _a : this.options.items.find(this.isCurrentOption);
|
|
199
195
|
// Sets the value to the content of the focused option in the listbox.
|
|
@@ -203,12 +199,13 @@ const MgInputCombobox = class {
|
|
|
203
199
|
// Closes the popover.
|
|
204
200
|
this.popoverDisplay = false;
|
|
205
201
|
break;
|
|
202
|
+
}
|
|
206
203
|
case events_utils.Keys.DOWN:
|
|
207
204
|
case events_utils.Keys.ARROWDOWN:
|
|
208
205
|
case events_utils.Keys.UP:
|
|
209
|
-
case events_utils.Keys.ARROWUP:
|
|
206
|
+
case events_utils.Keys.ARROWUP: {
|
|
210
207
|
guard = true;
|
|
211
|
-
if (this.isLoading ||
|
|
208
|
+
if (this.isLoading || this.page.total === 0) {
|
|
212
209
|
this.popoverDisplay = true;
|
|
213
210
|
break;
|
|
214
211
|
}
|
|
@@ -239,12 +236,13 @@ const MgInputCombobox = class {
|
|
|
239
236
|
// open popover
|
|
240
237
|
this.popoverDisplay = true;
|
|
241
238
|
break;
|
|
239
|
+
}
|
|
242
240
|
case events_utils.Keys.LEFT:
|
|
243
241
|
case events_utils.Keys.ARROWLEFT:
|
|
244
242
|
case events_utils.Keys.HOME:
|
|
245
243
|
case events_utils.Keys.RIGHT:
|
|
246
244
|
case events_utils.Keys.ARROWRIGHT:
|
|
247
|
-
case events_utils.Keys.END:
|
|
245
|
+
case events_utils.Keys.END: {
|
|
248
246
|
// skip process if visual focus is not in popover
|
|
249
247
|
if (!isItem(this.option))
|
|
250
248
|
break;
|
|
@@ -264,8 +262,9 @@ const MgInputCombobox = class {
|
|
|
264
262
|
this.input.setSelectionRange(index, index);
|
|
265
263
|
}
|
|
266
264
|
break;
|
|
265
|
+
}
|
|
267
266
|
case events_utils.Keys.ESC:
|
|
268
|
-
case events_utils.Keys.ESCAPE:
|
|
267
|
+
case events_utils.Keys.ESCAPE: {
|
|
269
268
|
guard = true;
|
|
270
269
|
if (this.popoverDisplay) {
|
|
271
270
|
// If the popover is displayed, closes it.
|
|
@@ -279,10 +278,12 @@ const MgInputCombobox = class {
|
|
|
279
278
|
this.option = null;
|
|
280
279
|
}
|
|
281
280
|
break;
|
|
282
|
-
|
|
281
|
+
}
|
|
282
|
+
default: {
|
|
283
283
|
// Remove visual focus from popover options
|
|
284
284
|
this.option = null;
|
|
285
285
|
break;
|
|
286
|
+
}
|
|
286
287
|
}
|
|
287
288
|
if (guard) {
|
|
288
289
|
event.stopPropagation();
|
|
@@ -328,40 +329,41 @@ const MgInputCombobox = class {
|
|
|
328
329
|
};
|
|
329
330
|
/**
|
|
330
331
|
* Set input error message
|
|
331
|
-
* @param
|
|
332
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
332
333
|
*/
|
|
333
|
-
this.setErrorMessage = (
|
|
334
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
334
335
|
// Set error message
|
|
335
336
|
this.errorMessage = undefined;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
this.
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
337
|
+
if (!this.valid) {
|
|
338
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
339
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
340
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
341
|
+
}
|
|
342
|
+
// required
|
|
343
|
+
else if (this.input.validity.valueMissing) {
|
|
344
|
+
this.errorMessage = this.messages.errors.required;
|
|
345
|
+
}
|
|
343
346
|
}
|
|
344
347
|
};
|
|
345
348
|
/**
|
|
346
|
-
* Get
|
|
347
|
-
* @returns
|
|
349
|
+
* Get first page with filter applied
|
|
350
|
+
* @returns first page with filter applied
|
|
348
351
|
*/
|
|
349
|
-
this.
|
|
352
|
+
this.getFirstPage = () => this.options.getPage(0, option => this.filter === '' || option.title.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase()));
|
|
350
353
|
/**
|
|
351
354
|
* Loading wrapper with a given action
|
|
352
355
|
* @param action - wrapped loading action
|
|
353
356
|
* @returns promisified action
|
|
354
357
|
*/
|
|
355
358
|
this.loadingWrapper = (action) => {
|
|
359
|
+
var _a;
|
|
356
360
|
let promise;
|
|
357
361
|
let index;
|
|
358
362
|
// cache initial loading action if not defined
|
|
359
|
-
|
|
360
|
-
this.loadingAction = action.name;
|
|
361
|
-
}
|
|
363
|
+
(_a = this.loadingAction) !== null && _a !== void 0 ? _a : (this.loadingAction = action.name);
|
|
362
364
|
// update index
|
|
363
365
|
if (Boolean(this.option) && this.loadingAction !== 'load-more') {
|
|
364
|
-
index = this.page.items.findIndex(option => option.value
|
|
366
|
+
index = this.page.items.findIndex(option => index$1.toString(option.value) === index$1.toString(this.option.value));
|
|
365
367
|
}
|
|
366
368
|
else if (this.loadingAction === 'load-more') {
|
|
367
369
|
index = this.page.items.length - this.page.baseIndex;
|
|
@@ -391,7 +393,7 @@ const MgInputCombobox = class {
|
|
|
391
393
|
return promise()
|
|
392
394
|
.then(() => {
|
|
393
395
|
// parse full items list from options
|
|
394
|
-
const options = this.options.items.filter(this.
|
|
396
|
+
const options = this.filter === '' ? this.options.items : this.options.items.filter(option => option.title.includes(this.filter));
|
|
395
397
|
// update visual focus
|
|
396
398
|
if (action.name !== 'load-data') {
|
|
397
399
|
index = this.page.getIndexFromCursor(action.cursor, this.loadingAction === 'load-more' && index >= 0 ? options[index] : this.option);
|
|
@@ -414,14 +416,14 @@ const MgInputCombobox = class {
|
|
|
414
416
|
*/
|
|
415
417
|
this.goToNextPage = () => {
|
|
416
418
|
this.showMore.emit();
|
|
417
|
-
if (
|
|
419
|
+
if (this.fetchurl !== undefined) {
|
|
418
420
|
return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then(nextPage => {
|
|
419
|
-
if (
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
421
|
+
if (nextPage !== undefined) {
|
|
422
|
+
// merge items from current page and next page
|
|
423
|
+
const items = [...this.page.items, ...nextPage.items];
|
|
424
|
+
// create new options pagination withe merged items
|
|
425
|
+
this.options = new index$1.Paginate(items, { total: nextPage.total, next: nextPage.next, top: items.length });
|
|
426
|
+
}
|
|
425
427
|
});
|
|
426
428
|
}
|
|
427
429
|
else {
|
|
@@ -438,16 +440,16 @@ const MgInputCombobox = class {
|
|
|
438
440
|
* @returns promise
|
|
439
441
|
*/
|
|
440
442
|
this.updatePage = async () => {
|
|
441
|
-
if (
|
|
443
|
+
if (this.fetchurl !== undefined) {
|
|
442
444
|
return this.getOptions().then(page => {
|
|
443
|
-
if (
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
445
|
+
if (page !== undefined) {
|
|
446
|
+
// reset current options pagination from API response
|
|
447
|
+
this.options = new index$1.Paginate(page.items, { total: page.total, next: page.next, top: page.top });
|
|
448
|
+
}
|
|
447
449
|
});
|
|
448
450
|
}
|
|
449
451
|
else {
|
|
450
|
-
this.page = this.
|
|
452
|
+
this.page = this.getFirstPage();
|
|
451
453
|
}
|
|
452
454
|
};
|
|
453
455
|
/**
|
|
@@ -456,8 +458,9 @@ const MgInputCombobox = class {
|
|
|
456
458
|
* @returns new page from url
|
|
457
459
|
*/
|
|
458
460
|
this.getOptions = async (url = this.fetchurl) => {
|
|
459
|
-
// add text filter
|
|
460
|
-
const
|
|
461
|
+
// add text filter to url
|
|
462
|
+
const filter = typeof this.fetchmappings.request.filterTransform === 'function' ? this.fetchmappings.request.filterTransform(this.filter) : this.filter;
|
|
463
|
+
const updateUrl = (typeof url === 'string' ? url : url.toString()).replaceAll(this.fetchmappings.request.filter, encodeURIComponent(filter));
|
|
461
464
|
try {
|
|
462
465
|
const response = await fetch(updateUrl, this.fetchoptions);
|
|
463
466
|
if (!response.ok) {
|
|
@@ -465,10 +468,13 @@ const MgInputCombobox = class {
|
|
|
465
468
|
return;
|
|
466
469
|
}
|
|
467
470
|
const json = await response.json();
|
|
468
|
-
const items = index$1.getObjectValueFromKey(json, this.fetchmappings.response.items).map((item) =>
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
471
|
+
const items = index$1.getObjectValueFromKey(json, this.fetchmappings.response.items).map((item) => {
|
|
472
|
+
var _a;
|
|
473
|
+
return ({
|
|
474
|
+
title: index$1.getObjectValueFromKey(item, this.fetchmappings.response.itemTitle),
|
|
475
|
+
value: (_a = index$1.getObjectValueFromKey(item, this.fetchmappings.response.itemValue)) !== null && _a !== void 0 ? _a : item,
|
|
476
|
+
});
|
|
477
|
+
});
|
|
472
478
|
const total = Number(index$1.getObjectValueFromKey(json, this.fetchmappings.response.total, 0));
|
|
473
479
|
let next = index$1.getObjectValueFromKey(json, this.fetchmappings.response.next);
|
|
474
480
|
if (URL.canParse(updateUrl) && Boolean(next) && !URL.canParse(next)) {
|
|
@@ -489,11 +495,11 @@ const MgInputCombobox = class {
|
|
|
489
495
|
this.valueChange.emit(newValue);
|
|
490
496
|
}
|
|
491
497
|
watchItems(newValue) {
|
|
492
|
-
if (
|
|
498
|
+
if (this.fetchurl !== undefined && newValue === undefined) {
|
|
493
499
|
// skip newValue check
|
|
494
500
|
return;
|
|
495
501
|
}
|
|
496
|
-
else if (
|
|
502
|
+
else if (this.fetchurl !== undefined && newValue !== undefined) {
|
|
497
503
|
throw new Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${index$1.toString(newValue)}.`);
|
|
498
504
|
}
|
|
499
505
|
// Empty options
|
|
@@ -513,7 +519,7 @@ const MgInputCombobox = class {
|
|
|
513
519
|
}
|
|
514
520
|
}
|
|
515
521
|
watchIdentifier(newValue) {
|
|
516
|
-
if (
|
|
522
|
+
if (index$1.isValidString(newValue)) {
|
|
517
523
|
this.popoverId = `${newValue}-popover`;
|
|
518
524
|
this.element.dataset.mgPopoverGuard = this.popoverId;
|
|
519
525
|
}
|
|
@@ -553,7 +559,7 @@ const MgInputCombobox = class {
|
|
|
553
559
|
this.classCollection = new index$1.ClassList(this.classCollection.classes);
|
|
554
560
|
}
|
|
555
561
|
watchFetchUrl(newValue) {
|
|
556
|
-
if (
|
|
562
|
+
if (newValue !== undefined) {
|
|
557
563
|
this.loadingWrapper({ name: 'load-data' });
|
|
558
564
|
}
|
|
559
565
|
}
|
|
@@ -561,20 +567,17 @@ const MgInputCombobox = class {
|
|
|
561
567
|
if (this.fetchurl && newValue && !index$1.isObject(newValue)) {
|
|
562
568
|
throw new Error(`<mg-input-combobox> prop "fetchoptions" value must be a valid RequestInit. Passed value: ${index$1.toString(newValue)}.`);
|
|
563
569
|
}
|
|
564
|
-
else {
|
|
565
|
-
new Request(this.fetchurl, newValue);
|
|
566
|
-
}
|
|
567
570
|
}
|
|
568
571
|
watchFetchMappings(newValue) {
|
|
569
|
-
if (
|
|
572
|
+
if (this.fetchurl !== undefined && !index$1.isObject(newValue)) {
|
|
570
573
|
throw new Error(`<mg-input-combobox> prop "fetchmappings" is required with "fetchurl" prop.`);
|
|
571
574
|
}
|
|
572
|
-
else if (
|
|
575
|
+
else if (newValue !== undefined && !isFetchmappings(newValue)) {
|
|
573
576
|
throw new Error(`<mg-input-combobox> prop "fetchmappings" value must be { request: RequestMappingType, response: ResponseMappingType }. Passed value: ${index$1.toString(newValue)}.`);
|
|
574
577
|
}
|
|
575
578
|
}
|
|
576
|
-
watchOptions(
|
|
577
|
-
this.page =
|
|
579
|
+
watchOptions() {
|
|
580
|
+
this.page = this.getFirstPage();
|
|
578
581
|
}
|
|
579
582
|
watchFilter(newValue) {
|
|
580
583
|
this.loadingWrapper({ name: 'load-data' });
|
|
@@ -582,7 +585,6 @@ const MgInputCombobox = class {
|
|
|
582
585
|
}
|
|
583
586
|
watchPopoverDisplay(newValue) {
|
|
584
587
|
if (newValue) {
|
|
585
|
-
this.classCollection.add(this.classFocus);
|
|
586
588
|
this.input.focus();
|
|
587
589
|
}
|
|
588
590
|
else {
|
|
@@ -590,7 +592,6 @@ const MgInputCombobox = class {
|
|
|
590
592
|
this.option = null;
|
|
591
593
|
// reset filter with value
|
|
592
594
|
this.filter = this.getValueTitle();
|
|
593
|
-
this.classCollection.delete(this.classFocus);
|
|
594
595
|
this.handlerInProgress = 'blur';
|
|
595
596
|
this.displayError().finally(() => {
|
|
596
597
|
// reset guard
|
|
@@ -631,17 +632,22 @@ const MgInputCombobox = class {
|
|
|
631
632
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
632
633
|
* @param valid - value indicating the validity
|
|
633
634
|
* @param errorMessage - the error message to display
|
|
635
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
634
636
|
*/
|
|
635
|
-
async setError(valid, errorMessage) {
|
|
637
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
636
638
|
if (typeof valid !== 'boolean') {
|
|
637
639
|
throw new Error('<mg-input-combobox> method "setError()" param "valid" must be a boolean.');
|
|
638
640
|
}
|
|
639
|
-
else if (!index$1.isValidString(errorMessage)) {
|
|
641
|
+
else if (errorMessage !== undefined && !index$1.isValidString(errorMessage)) {
|
|
640
642
|
throw new Error('<mg-input-combobox> method "setError()" param "errorMessage" must be a string.');
|
|
641
643
|
}
|
|
642
644
|
else {
|
|
645
|
+
this.customErrorMessage = {
|
|
646
|
+
lock: valid ? false : errorMessageLock,
|
|
647
|
+
message: valid ? undefined : errorMessage,
|
|
648
|
+
};
|
|
643
649
|
this.setValidity(valid);
|
|
644
|
-
this.setErrorMessage(
|
|
650
|
+
this.setErrorMessage(true);
|
|
645
651
|
this.hasDisplayedError = this.invalid;
|
|
646
652
|
}
|
|
647
653
|
}
|
|
@@ -661,6 +667,8 @@ const MgInputCombobox = class {
|
|
|
661
667
|
// - Keep everything in sync both inside and outside the component
|
|
662
668
|
return new Promise(resolve => {
|
|
663
669
|
requestAnimationFrame(() => {
|
|
670
|
+
// unlock validity check by reseting customErrorMessage
|
|
671
|
+
this.customErrorMessage = { lock: false };
|
|
664
672
|
this.checkValidity();
|
|
665
673
|
this.errorMessage = undefined;
|
|
666
674
|
this.hasDisplayedError = false;
|
|
@@ -689,11 +697,13 @@ const MgInputCombobox = class {
|
|
|
689
697
|
* @param newValue - valid new value
|
|
690
698
|
*/
|
|
691
699
|
setValidity(newValue) {
|
|
692
|
-
const
|
|
693
|
-
this.
|
|
700
|
+
const oldValue = this.valid;
|
|
701
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
702
|
+
this.valid = newValue;
|
|
703
|
+
}
|
|
694
704
|
this.invalid = !this.valid;
|
|
695
705
|
// We need to send valid event even if it is the same value
|
|
696
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
706
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
697
707
|
this.inputValid.emit(this.valid);
|
|
698
708
|
}
|
|
699
709
|
/*************
|
|
@@ -709,13 +719,13 @@ const MgInputCombobox = class {
|
|
|
709
719
|
// Validate
|
|
710
720
|
this.watchIdentifier(this.identifier);
|
|
711
721
|
this.watchItems(this.items);
|
|
712
|
-
if (
|
|
722
|
+
if (this.fetchurl !== undefined) {
|
|
713
723
|
this.watchFetchOptions(this.fetchoptions);
|
|
714
724
|
this.watchFetchMappings(this.fetchmappings);
|
|
715
725
|
this.loadingWrapper({ name: 'load-data' });
|
|
716
726
|
}
|
|
717
727
|
this.watchValue(this.value);
|
|
718
|
-
this.watchOptions(
|
|
728
|
+
this.watchOptions();
|
|
719
729
|
this.watchMgWidth(this.mgWidth);
|
|
720
730
|
this.watchReadonly(this.readonly);
|
|
721
731
|
this.watchDisabled(this.disabled);
|
|
@@ -736,14 +746,17 @@ const MgInputCombobox = class {
|
|
|
736
746
|
const readonlyValue = this.getValueTitle();
|
|
737
747
|
const withResetButton = this.value && !this.disabled;
|
|
738
748
|
let popoverContent;
|
|
739
|
-
if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0)
|
|
749
|
+
if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0) {
|
|
740
750
|
popoverContent = 'list';
|
|
741
|
-
|
|
751
|
+
}
|
|
752
|
+
else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && this.filter.length > 0) {
|
|
742
753
|
popoverContent = 'notfound';
|
|
743
|
-
|
|
754
|
+
}
|
|
755
|
+
else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0) {
|
|
744
756
|
popoverContent = 'notavailable';
|
|
757
|
+
}
|
|
745
758
|
let activeDescendant;
|
|
746
|
-
if (
|
|
759
|
+
if (((_d = this.option) === null || _d === void 0 ? void 0 : _d.value) !== undefined) {
|
|
747
760
|
activeDescendant = this.option.value;
|
|
748
761
|
}
|
|
749
762
|
else if (typeof this.value === 'string') {
|
|
@@ -752,8 +765,8 @@ const MgInputCombobox = class {
|
|
|
752
765
|
else {
|
|
753
766
|
activeDescendant = (_e = this.value) === null || _e === void 0 ? void 0 : _e.value;
|
|
754
767
|
}
|
|
755
|
-
return (index.h("mg-input", { key: '
|
|
756
|
-
'--mg-c-input-list-width':
|
|
768
|
+
return (index.h("mg-input", { key: 'fd5a59f1e0bf31342a3bf935a60a2877e5df1772', label: this.label, identifier: this.identifier, class: this.classCollection.classes.join(' '), ariaDescribedbyIDs: popoverContent && popoverContent !== 'list' ? popoverContent : undefined, 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 ? (readonlyValue && index.h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (index.h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
|
|
769
|
+
'--mg-c-input-list-width': ((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) > 0 ? `${this.input.offsetWidth}px` : undefined,
|
|
757
770
|
}, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, index.h("div", { class: "mg-c-input__input-group-container" }, index.h("mg-icon", { icon: "magnifying-glass" }), index.h("input", { type: "text", role: "combobox", class: "mg-c-input__box mg-c-input__box--width", value: this.filter, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-autocomplete": "list", "aria-expanded": this.popoverDisplay.toString(), "aria-controls": listId, "aria-invalid": (this.invalid === true).toString(), "aria-activedescendant": index$1.formatID(activeDescendant), onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
|
|
758
771
|
if (el !== null)
|
|
759
772
|
this.input = el;
|
|
@@ -767,7 +780,7 @@ const MgInputCombobox = class {
|
|
|
767
780
|
'mg-c-input__input-list-item': true,
|
|
768
781
|
'mg-c-input__input-list-item--focus-visible': JSON.stringify((_a = this.option) === null || _a === void 0 ? void 0 : _a.value) === JSON.stringify(option.value),
|
|
769
782
|
'mg-c-input__input-list-item--selected': this.isCurrentOption(option),
|
|
770
|
-
}, key: option.title, id: index$1.formatID(option.value), "aria-selected": this.isCurrentOption(option).toString(), onClick: this.handleOptionClick }, option.title, this.isCurrentOption(option) && index.h("mg-icon", { icon: "check" })));
|
|
783
|
+
}, key: option.title, id: index$1.formatID(option.value), "aria-selected": this.isCurrentOption(option).toString(), "data-value": index$1.toString(option.value), onClick: this.handleOptionClick }, option.title, this.isCurrentOption(option) && index.h("mg-icon", { icon: "check" })));
|
|
771
784
|
})),
|
|
772
785
|
this.isLoading && index.h("mg-loader", { key: "loader", message: this.messages.input.combobox.search, class: { 'mg-u-visually-hidden': Boolean(this.page.next) } }),
|
|
773
786
|
this.page.next && (index.h("mg-button", { key: "load-more", variant: "flat", class: "mg-c-input__load-more", tabIndex: -1, disabled: this.isLoading, "full-width": true, "disable-on-click": true, onClick: this.handleLoadMoreButton, "aria-controls": listId, ref: (el) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index$1 = require('./index-
|
|
3
|
+
var index$1 = require('./index-Bp6wZzau.js');
|
|
4
4
|
var index = require('./index-CpENFzEo.js');
|
|
5
|
-
var mgInput_conf = require('./mg-input.conf-
|
|
5
|
+
var mgInput_conf = require('./mg-input.conf-D7jmj_lh.js');
|
|
6
6
|
var index$2 = require('./index-TUElr4Wv.js');
|
|
7
7
|
|
|
8
8
|
/** Detect free variable `global` from Node.js. */
|
|
@@ -16389,8 +16389,7 @@ const MgInputRichTextEditor = class {
|
|
|
16389
16389
|
this.valueChange = index$1.createEvent(this, "value-change", 7);
|
|
16390
16390
|
// hasDisplayedError (triggered by blur event)
|
|
16391
16391
|
this.hasDisplayedError = false;
|
|
16392
|
-
|
|
16393
|
-
this.classFocus = 'mg-u-is-focused';
|
|
16392
|
+
this.customErrorMessage = { lock: false };
|
|
16394
16393
|
/**
|
|
16395
16394
|
* Define the value of the editor
|
|
16396
16395
|
* Can be either HTML string or plain text
|
|
@@ -16454,27 +16453,29 @@ const MgInputRichTextEditor = class {
|
|
|
16454
16453
|
};
|
|
16455
16454
|
/**
|
|
16456
16455
|
* Set input error message
|
|
16457
|
-
* @param
|
|
16456
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
16458
16457
|
*/
|
|
16459
|
-
this.setErrorMessage = (
|
|
16458
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
16459
|
+
// Set error message
|
|
16460
16460
|
this.errorMessage = undefined;
|
|
16461
|
-
|
|
16462
|
-
|
|
16463
|
-
|
|
16464
|
-
this.
|
|
16465
|
-
|
|
16466
|
-
|
|
16467
|
-
this.
|
|
16468
|
-
|
|
16469
|
-
|
|
16470
|
-
|
|
16461
|
+
// Does have a new custom error message
|
|
16462
|
+
if (!this.valid) {
|
|
16463
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
16464
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
16465
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
16466
|
+
}
|
|
16467
|
+
else if (this.required && this.isEmpty()) {
|
|
16468
|
+
this.errorMessage = this.messages.errors.required;
|
|
16469
|
+
}
|
|
16470
|
+
else if (!this.getPatternValidity()) {
|
|
16471
|
+
this.errorMessage = this.patternErrorMessage;
|
|
16472
|
+
}
|
|
16471
16473
|
}
|
|
16472
16474
|
};
|
|
16473
16475
|
/**
|
|
16474
16476
|
* Handle focus event
|
|
16475
16477
|
*/
|
|
16476
16478
|
this.handleFocus = () => {
|
|
16477
|
-
this.classCollection.add(this.classFocus);
|
|
16478
16479
|
this.classCollection = new index.ClassList(this.classCollection.classes);
|
|
16479
16480
|
};
|
|
16480
16481
|
/**
|
|
@@ -16483,7 +16484,6 @@ const MgInputRichTextEditor = class {
|
|
|
16483
16484
|
*/
|
|
16484
16485
|
this.handleBlur = () => {
|
|
16485
16486
|
// Manage focus
|
|
16486
|
-
this.classCollection.delete(this.classFocus);
|
|
16487
16487
|
this.classCollection = new index.ClassList(this.classCollection.classes);
|
|
16488
16488
|
if (!this.readonly) {
|
|
16489
16489
|
this.checkValidity();
|
|
@@ -16551,7 +16551,7 @@ const MgInputRichTextEditor = class {
|
|
|
16551
16551
|
* Get editor content as HTML
|
|
16552
16552
|
* @returns HTML content of the editor
|
|
16553
16553
|
*/
|
|
16554
|
-
|
|
16554
|
+
getHTML() {
|
|
16555
16555
|
return new Promise(resolve => {
|
|
16556
16556
|
requestAnimationFrame(() => {
|
|
16557
16557
|
resolve(this.editor.getSemanticHTML());
|
|
@@ -16595,17 +16595,22 @@ const MgInputRichTextEditor = class {
|
|
|
16595
16595
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
16596
16596
|
* @param valid - value indicating the validity
|
|
16597
16597
|
* @param errorMessage - the error message to display
|
|
16598
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
16598
16599
|
*/
|
|
16599
|
-
async setError(valid, errorMessage) {
|
|
16600
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
16600
16601
|
if (typeof valid !== 'boolean') {
|
|
16601
16602
|
throw new Error('<mg-input-rich-text-editor> method "setError()" param "valid" must be a boolean.');
|
|
16602
16603
|
}
|
|
16603
|
-
else if (!index.isValidString(errorMessage)) {
|
|
16604
|
+
else if (errorMessage !== undefined && !index.isValidString(errorMessage)) {
|
|
16604
16605
|
throw new Error('<mg-input-rich-text-editor> method "setError()" param "errorMessage" must be a string.');
|
|
16605
16606
|
}
|
|
16606
16607
|
else {
|
|
16608
|
+
this.customErrorMessage = {
|
|
16609
|
+
lock: valid ? false : errorMessageLock,
|
|
16610
|
+
message: valid ? undefined : errorMessage,
|
|
16611
|
+
};
|
|
16607
16612
|
this.setValidity(valid);
|
|
16608
|
-
this.setErrorMessage(
|
|
16613
|
+
this.setErrorMessage(true);
|
|
16609
16614
|
this.hasDisplayedError = this.invalid;
|
|
16610
16615
|
}
|
|
16611
16616
|
}
|
|
@@ -16624,6 +16629,8 @@ const MgInputRichTextEditor = class {
|
|
|
16624
16629
|
// - Keep everything in sync both inside and outside the component
|
|
16625
16630
|
return new Promise(resolve => {
|
|
16626
16631
|
requestAnimationFrame(() => {
|
|
16632
|
+
// unlock validity check by reseting customErrorMessage
|
|
16633
|
+
this.customErrorMessage = { lock: false };
|
|
16627
16634
|
this.checkValidity();
|
|
16628
16635
|
this.errorMessage = undefined;
|
|
16629
16636
|
this.hasDisplayedError = false;
|
|
@@ -16637,10 +16644,12 @@ const MgInputRichTextEditor = class {
|
|
|
16637
16644
|
* @param newValue - valid new value
|
|
16638
16645
|
*/
|
|
16639
16646
|
setValidity(newValue) {
|
|
16640
|
-
const
|
|
16641
|
-
this.
|
|
16647
|
+
const oldValue = this.valid;
|
|
16648
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
16649
|
+
this.valid = newValue;
|
|
16650
|
+
}
|
|
16642
16651
|
this.invalid = !this.valid;
|
|
16643
|
-
if (this.valid !==
|
|
16652
|
+
if (this.valid !== oldValue) {
|
|
16644
16653
|
this.inputValid.emit(this.valid);
|
|
16645
16654
|
}
|
|
16646
16655
|
}
|
|
@@ -16689,7 +16698,7 @@ const MgInputRichTextEditor = class {
|
|
|
16689
16698
|
* @returns HTML mg-input Element
|
|
16690
16699
|
*/
|
|
16691
16700
|
render() {
|
|
16692
|
-
return (index$1.h("mg-input", { key: '
|
|
16701
|
+
return (index$1.h("mg-input", { key: '5e807e1059704a6624a1fda63ab56a6f9a51230f', identifier: this.identifier, class: this.classCollection.join(), label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, helpText: this.helpText, errorMessage: this.hasDisplayedError ? this.errorMessage : undefined }, this.readonly ? (index$1.h("div", { class: "mg-c-input__readonly-value", innerHTML: this.value })) : (index$1.h("div", { ref: el => {
|
|
16693
16702
|
this.wrapperElement = el;
|
|
16694
16703
|
}, id: this.identifier, class: "mg-c-input__wrapper" }, index$1.h("div", null)))));
|
|
16695
16704
|
}
|
|
@@ -8,14 +8,21 @@ const widths = [2, 4, 16, 'full'];
|
|
|
8
8
|
* Possible tootltip postions
|
|
9
9
|
*/
|
|
10
10
|
const tooltipPositions = ['input', 'label'];
|
|
11
|
+
/**
|
|
12
|
+
* Possible label headings
|
|
13
|
+
*/
|
|
14
|
+
const labelHeadings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
11
15
|
const classFieldset = 'mg-c-input--fieldset';
|
|
12
16
|
const classDisabled = 'mg-c-input--disabled';
|
|
13
17
|
const classReadonly = 'mg-c-input--readonly';
|
|
14
18
|
const classVerticalList = 'mg-c-input--vertical-list';
|
|
19
|
+
const classDisplayCharacterLeft = 'mg-c-input--display-character-left';
|
|
15
20
|
|
|
16
21
|
exports.classDisabled = classDisabled;
|
|
22
|
+
exports.classDisplayCharacterLeft = classDisplayCharacterLeft;
|
|
17
23
|
exports.classFieldset = classFieldset;
|
|
18
24
|
exports.classReadonly = classReadonly;
|
|
19
25
|
exports.classVerticalList = classVerticalList;
|
|
26
|
+
exports.labelHeadings = labelHeadings;
|
|
20
27
|
exports.tooltipPositions = tooltipPositions;
|
|
21
28
|
exports.widths = widths;
|