@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,940 +1 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { P as Paginate, C as ClassList, t as toString, e as Cursor, n as nextTick, h as Page, j as getObjectValueFromKey, d as allItemsAreString, i as isValidString, k as isObject, f as formatID } from './index2.js';
|
|
3
|
-
import { d as defineCustomElement$8, c as classReadonly, a as classDisabled, w as widths } from './mg-input2.js';
|
|
4
|
-
import { i as initLocales } from './index3.js';
|
|
5
|
-
import { K as Keys } from './events.utils.js';
|
|
6
|
-
import { d as defineCustomElement$b } from './mg-button2.js';
|
|
7
|
-
import { d as defineCustomElement$a } from './mg-card2.js';
|
|
8
|
-
import { d as defineCustomElement$9 } from './mg-icon2.js';
|
|
9
|
-
import { d as defineCustomElement$7 } from './mg-input-title2.js';
|
|
10
|
-
import { d as defineCustomElement$6 } from './mg-loader2.js';
|
|
11
|
-
import { d as defineCustomElement$5 } from './mg-popover2.js';
|
|
12
|
-
import { d as defineCustomElement$4 } from './mg-popover-content2.js';
|
|
13
|
-
import { d as defineCustomElement$3 } from './mg-tooltip2.js';
|
|
14
|
-
import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
|
|
15
|
-
|
|
16
|
-
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-popover-overflow:auto;--mg-c-popover-padding-vertical:0;--mg-c-popover-padding-horizontal:0;--mg-c-popover-min-width:var(--mg-c-input-list-width);--mg-c-popover-max-height:calc(50 * var(--mg-b-size-8) - var(--mg-b-size-32))}.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;flex-direction:column;gap:var(--mg-b-size-4)}.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}";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Check if object is an item
|
|
20
|
-
* @param item - object to check
|
|
21
|
-
* @returns True if object is an item
|
|
22
|
-
*/
|
|
23
|
-
const isItem = (item) => item && typeof item === 'object' && typeof item.title === 'string' && item.value !== undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Check if objects are items
|
|
26
|
-
* @param items - items to check
|
|
27
|
-
* @returns True if objects are items
|
|
28
|
-
*/
|
|
29
|
-
const isItems = (items) => Array.isArray(items) && items.every(isItem);
|
|
30
|
-
/**
|
|
31
|
-
* Check if object is valid combobox fetchmappings
|
|
32
|
-
* @param value - to validate
|
|
33
|
-
* @returns truthy if mapping is valid
|
|
34
|
-
*/
|
|
35
|
-
const isFetchmappings = (value) => {
|
|
36
|
-
const isValidRoot = isObject(value) && Object.hasOwn(value, 'request') && Object.hasOwn(value, 'response');
|
|
37
|
-
if (isValidRoot) {
|
|
38
|
-
const { request, response } = value;
|
|
39
|
-
if ([request, response].some(property => !isObject(property)))
|
|
40
|
-
return false;
|
|
41
|
-
const isValidRequest = typeof request.filter === 'string' && (request.filterTransform === undefined || typeof request.filterTransform === 'function');
|
|
42
|
-
const isValidResponse = typeof response === 'object' &&
|
|
43
|
-
typeof response.total === 'string' &&
|
|
44
|
-
typeof response.items === 'string' &&
|
|
45
|
-
typeof response.next === 'string' &&
|
|
46
|
-
typeof response.itemTitle === 'string' &&
|
|
47
|
-
(typeof response.itemValue === 'string' || response.itemValue === undefined);
|
|
48
|
-
return isValidRequest && isValidResponse;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return isValidRoot;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox extends HTMLElement {
|
|
55
|
-
constructor(registerHost) {
|
|
56
|
-
super();
|
|
57
|
-
if (registerHost !== false) {
|
|
58
|
-
this.__registerHost();
|
|
59
|
-
}
|
|
60
|
-
this.__attachShadow();
|
|
61
|
-
this.valueChange = createEvent(this, "value-change", 7);
|
|
62
|
-
this.filterChange = createEvent(this, "filter-change", 7);
|
|
63
|
-
this.showMore = createEvent(this, "load-more", 7);
|
|
64
|
-
this.inputValid = createEvent(this, "input-valid", 7);
|
|
65
|
-
this.fetchError = createEvent(this, "fetch-error", 7);
|
|
66
|
-
// hasDisplayedError (triggered by blur event)
|
|
67
|
-
this.hasDisplayedError = false;
|
|
68
|
-
this.customErrorMessage = { lock: false };
|
|
69
|
-
/**
|
|
70
|
-
* Input name
|
|
71
|
-
* If not set the value equals the identifier
|
|
72
|
-
*/
|
|
73
|
-
this.name = this.identifier;
|
|
74
|
-
/**
|
|
75
|
-
* Define if label is displayed on top
|
|
76
|
-
*/
|
|
77
|
-
this.labelOnTop = false;
|
|
78
|
-
/**
|
|
79
|
-
* Define if label is visible
|
|
80
|
-
*/
|
|
81
|
-
this.labelHide = false;
|
|
82
|
-
/**
|
|
83
|
-
* Define if input is required
|
|
84
|
-
*/
|
|
85
|
-
this.required = false;
|
|
86
|
-
/**
|
|
87
|
-
* Define if input is readonly
|
|
88
|
-
*/
|
|
89
|
-
this.readonly = false;
|
|
90
|
-
/**
|
|
91
|
-
* Define if input is disabled
|
|
92
|
-
*/
|
|
93
|
-
this.disabled = false;
|
|
94
|
-
/**
|
|
95
|
-
* Define input width
|
|
96
|
-
*/
|
|
97
|
-
this.mgWidth = 'full';
|
|
98
|
-
/**
|
|
99
|
-
* Define tooltip position
|
|
100
|
-
*/
|
|
101
|
-
this.tooltipPosition = 'input';
|
|
102
|
-
/**
|
|
103
|
-
* Formated items for display
|
|
104
|
-
*/
|
|
105
|
-
this.options = new Paginate([]);
|
|
106
|
-
/**
|
|
107
|
-
* Option filter
|
|
108
|
-
*/
|
|
109
|
-
this.filter = '';
|
|
110
|
-
/**
|
|
111
|
-
* Component classes
|
|
112
|
-
*/
|
|
113
|
-
this.classCollection = new ClassList(['mg-c-input--combobox', 'mg-c-input--has-icon', 'mg-c-input--input-append']);
|
|
114
|
-
/**
|
|
115
|
-
* Popover display state
|
|
116
|
-
*/
|
|
117
|
-
this.popoverDisplay = false;
|
|
118
|
-
/**
|
|
119
|
-
* Handle `click` event on option
|
|
120
|
-
* @param event - option element click event
|
|
121
|
-
*/
|
|
122
|
-
this.handleOptionClick = (event) => {
|
|
123
|
-
this.setValue(this.options.items.find(option => toString(option.value) === event.target.dataset.value));
|
|
124
|
-
this.popoverDisplay = false;
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* Handle `click` event on reset button
|
|
128
|
-
* @param event - click event
|
|
129
|
-
*/
|
|
130
|
-
this.handleResetButton = (event) => {
|
|
131
|
-
event.stopPropagation();
|
|
132
|
-
this.reset().then(() => {
|
|
133
|
-
this.input.focus();
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Handle `display-change` event on mg-popover
|
|
138
|
-
*/
|
|
139
|
-
this.handlePopoverDisplay = (event) => {
|
|
140
|
-
this.popoverDisplay = event.detail;
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* Handle input event
|
|
144
|
-
*/
|
|
145
|
-
this.handleFilterInput = () => {
|
|
146
|
-
this.checkValidity();
|
|
147
|
-
if (this.hasDisplayedError)
|
|
148
|
-
this.setErrorMessage();
|
|
149
|
-
if (!this.popoverDisplay)
|
|
150
|
-
this.popoverDisplay = true;
|
|
151
|
-
// update filter with debounce to prevent filter update overload
|
|
152
|
-
if (!this.debounce) {
|
|
153
|
-
this.debounce = true;
|
|
154
|
-
setTimeout(() => {
|
|
155
|
-
this.filter = this.input.value;
|
|
156
|
-
this.debounce = false;
|
|
157
|
-
}, 250);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* Handle `blur` event
|
|
162
|
-
*/
|
|
163
|
-
this.handleFilterBlur = (event) => {
|
|
164
|
-
if (this.popoverDisplay) {
|
|
165
|
-
// prevent blur event to bubble up and reset input focus process when popover is open
|
|
166
|
-
event.stopImmediatePropagation();
|
|
167
|
-
this.input.focus();
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
// Display Error
|
|
171
|
-
this.handlerInProgress = 'blur';
|
|
172
|
-
this.displayError().finally(() => {
|
|
173
|
-
// reset guard
|
|
174
|
-
this.handlerInProgress = undefined;
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* Handle `focus` event
|
|
180
|
-
*/
|
|
181
|
-
this.handleFilterFocus = () => {
|
|
182
|
-
// ensure visual focus is always clear on focus when component isn't in loading state
|
|
183
|
-
if (!this.isLoading) {
|
|
184
|
-
this.option = null;
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* Handle load-more <mg-button> `click`
|
|
189
|
-
*/
|
|
190
|
-
this.handleLoadMoreButton = () => {
|
|
191
|
-
this.loadingWrapper({ name: 'load-more', cursor: Cursor.NEXT }).then(() => {
|
|
192
|
-
this.input.focus();
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* Handle `keypress` event
|
|
197
|
-
* @param event - keyboard event
|
|
198
|
-
*/
|
|
199
|
-
this.handleFilterKeydown = (event) => {
|
|
200
|
-
var _a;
|
|
201
|
-
if (this.disabled || event.ctrlKey || event.shiftKey)
|
|
202
|
-
return;
|
|
203
|
-
let guard = false;
|
|
204
|
-
// override keys actions
|
|
205
|
-
switch (event.key) {
|
|
206
|
-
case Keys.TAB:
|
|
207
|
-
case Keys.ENTER: {
|
|
208
|
-
guard = event.key === Keys.ENTER;
|
|
209
|
-
const option = (_a = this.option) !== null && _a !== void 0 ? _a : this.options.items.find(this.isCurrentOption);
|
|
210
|
-
// Sets the value to the content of the focused option in the listbox.
|
|
211
|
-
if (this.popoverDisplay) {
|
|
212
|
-
this.setValue(option);
|
|
213
|
-
}
|
|
214
|
-
// Closes the popover.
|
|
215
|
-
this.popoverDisplay = false;
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
case Keys.DOWN:
|
|
219
|
-
case Keys.ARROWDOWN:
|
|
220
|
-
case Keys.UP:
|
|
221
|
-
case Keys.ARROWUP: {
|
|
222
|
-
guard = true;
|
|
223
|
-
if (this.isLoading || this.page.total === 0) {
|
|
224
|
-
this.popoverDisplay = true;
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
if (Boolean(event.altKey) && [Keys.DOWN, Keys.ARROWDOWN].includes(event.key)) {
|
|
228
|
-
// Opens the popover without moving focus or changing selection.
|
|
229
|
-
this.popoverDisplay = true;
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
// define cursor
|
|
233
|
-
let cursor;
|
|
234
|
-
const isNavigationStart = this.popoverDisplay && isItem(this.option);
|
|
235
|
-
if ([Keys.DOWN, Keys.ARROWDOWN].includes(event.key)) {
|
|
236
|
-
// If the filter is not empty and the popover is displayed, moves visual focus to the first suggested value.
|
|
237
|
-
// If the filter is empty and the popover is not displayed, opens the popover and moves visual focus to the first option.
|
|
238
|
-
// Moves visual focus to the next option.
|
|
239
|
-
// If visual focus is on the last option, moves visual focus to the first option.
|
|
240
|
-
cursor = isNavigationStart ? Cursor.NEXT : Cursor.FIRST;
|
|
241
|
-
}
|
|
242
|
-
else if ([Keys.UP, Keys.ARROWUP].includes(event.key)) {
|
|
243
|
-
// If the filter is not empty and the popover is displayed, moves visual focus to the last suggested value.
|
|
244
|
-
// If the filter is empty, first opens the popover if it is not already displayed and then moves visual focus to the last option.
|
|
245
|
-
// Moves visual focus to the previous option.
|
|
246
|
-
// If visual focus is on the first option, moves visual focus to the last option.
|
|
247
|
-
cursor = isNavigationStart ? Cursor.PREVIOUS : Cursor.LAST;
|
|
248
|
-
}
|
|
249
|
-
// update scroll and visual focused option in wrapper
|
|
250
|
-
this.loadingWrapper({ name: 'scroll', cursor });
|
|
251
|
-
// open popover
|
|
252
|
-
this.popoverDisplay = true;
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
case Keys.LEFT:
|
|
256
|
-
case Keys.ARROWLEFT:
|
|
257
|
-
case Keys.HOME:
|
|
258
|
-
case Keys.RIGHT:
|
|
259
|
-
case Keys.ARROWRIGHT:
|
|
260
|
-
case Keys.END: {
|
|
261
|
-
// skip process if visual focus is not in popover
|
|
262
|
-
if (!isItem(this.option))
|
|
263
|
-
break;
|
|
264
|
-
guard = true;
|
|
265
|
-
// Remove visual focus from popover options
|
|
266
|
-
this.option = null;
|
|
267
|
-
let index;
|
|
268
|
-
if (Keys.HOME === event.key) {
|
|
269
|
-
// Moves visual focus to the textbox and places the editing cursor at the beginning of the field.
|
|
270
|
-
index = 0;
|
|
271
|
-
}
|
|
272
|
-
else if (Keys.END === event.key) {
|
|
273
|
-
// Moves visual focus to the textbox and places the editing cursor at the end of the field.
|
|
274
|
-
index = this.filter.length;
|
|
275
|
-
}
|
|
276
|
-
if (typeof index === 'number') {
|
|
277
|
-
this.input.setSelectionRange(index, index);
|
|
278
|
-
}
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
case Keys.ESC:
|
|
282
|
-
case Keys.ESCAPE: {
|
|
283
|
-
guard = true;
|
|
284
|
-
if (this.popoverDisplay) {
|
|
285
|
-
// If the popover is displayed, closes it.
|
|
286
|
-
this.popoverDisplay = false;
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
// If the popover is not displayed, clears the filter.
|
|
290
|
-
this.setValue(null);
|
|
291
|
-
this.filter = '';
|
|
292
|
-
// Sets visual focus on the textbox.
|
|
293
|
-
this.option = null;
|
|
294
|
-
}
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
default: {
|
|
298
|
-
// Remove visual focus from popover options
|
|
299
|
-
this.option = null;
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (guard) {
|
|
304
|
-
event.stopPropagation();
|
|
305
|
-
event.preventDefault();
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
/**
|
|
309
|
-
* Scroll to next option from cursor
|
|
310
|
-
* @param index - targeted option index to scroll into
|
|
311
|
-
*/
|
|
312
|
-
this.scrollToIndex = (index) => {
|
|
313
|
-
// ensure we have an opened popover element on screen when the scrollIntiView is called
|
|
314
|
-
requestAnimationFrame(() => {
|
|
315
|
-
var _a;
|
|
316
|
-
if (!this.popoverDisplay)
|
|
317
|
-
return;
|
|
318
|
-
(_a = this.element.shadowRoot.querySelector(`li:nth-of-type(${(index || 0) + this.page.baseIndex})`)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: 'nearest' });
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
/**
|
|
322
|
-
* Is option the current value
|
|
323
|
-
* @param option - option to match with
|
|
324
|
-
* @returns true if option is the current value
|
|
325
|
-
*/
|
|
326
|
-
this.isCurrentOption = (option) => (isItem(this.value) ? this.value.value : this.value) === option.value;
|
|
327
|
-
/**
|
|
328
|
-
* get value prop title
|
|
329
|
-
* @returns value title
|
|
330
|
-
*/
|
|
331
|
-
this.getValueTitle = () => {
|
|
332
|
-
if (this.value && isItem(this.value))
|
|
333
|
-
return this.value.title;
|
|
334
|
-
else if (typeof this.value === 'string')
|
|
335
|
-
return this.value;
|
|
336
|
-
else
|
|
337
|
-
return '';
|
|
338
|
-
};
|
|
339
|
-
/**
|
|
340
|
-
* Check if input is valid
|
|
341
|
-
*/
|
|
342
|
-
this.checkValidity = () => {
|
|
343
|
-
this.setValidity(this.readonly || this.disabled || this.input.checkValidity());
|
|
344
|
-
};
|
|
345
|
-
/**
|
|
346
|
-
* Set input error message
|
|
347
|
-
* @param fromSetErrorContext - context come from `setError` method
|
|
348
|
-
*/
|
|
349
|
-
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
350
|
-
// Set error message
|
|
351
|
-
this.errorMessage = undefined;
|
|
352
|
-
if (!this.valid) {
|
|
353
|
-
// Does have a new custom error message OR does have a custom error message locked
|
|
354
|
-
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
355
|
-
this.errorMessage = this.customErrorMessage.message;
|
|
356
|
-
}
|
|
357
|
-
// required
|
|
358
|
-
else if (this.input.validity.valueMissing) {
|
|
359
|
-
this.errorMessage = this.messages.errors.required;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
/**
|
|
364
|
-
* Get first page with filter applied
|
|
365
|
-
* @returns first page with filter applied
|
|
366
|
-
*/
|
|
367
|
-
this.getFirstPage = () => this.options.getPage(0, option => this.filter === '' || option.title.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase()));
|
|
368
|
-
/**
|
|
369
|
-
* Loading wrapper with a given action
|
|
370
|
-
* @param action - wrapped loading action
|
|
371
|
-
* @returns promisified action
|
|
372
|
-
*/
|
|
373
|
-
this.loadingWrapper = (action) => {
|
|
374
|
-
var _a;
|
|
375
|
-
let promise;
|
|
376
|
-
let index;
|
|
377
|
-
// cache initial loading action if not defined
|
|
378
|
-
(_a = this.loadingAction) !== null && _a !== void 0 ? _a : (this.loadingAction = action.name);
|
|
379
|
-
// update index
|
|
380
|
-
if (Boolean(this.option) && this.loadingAction !== 'load-more') {
|
|
381
|
-
index = this.page.items.findIndex(option => toString(option.value) === toString(this.option.value));
|
|
382
|
-
}
|
|
383
|
-
else if (this.loadingAction === 'load-more') {
|
|
384
|
-
index = this.page.items.length - this.page.baseIndex;
|
|
385
|
-
}
|
|
386
|
-
// when action require a showMore we fetch the API else we report action to next tick
|
|
387
|
-
// Set "Show more" if action match OR if next item not available in the current page
|
|
388
|
-
if (action.name === 'load-more') {
|
|
389
|
-
// wait for new element render and update scroll position
|
|
390
|
-
// set component loading
|
|
391
|
-
this.isLoading = true;
|
|
392
|
-
promise = this.goToNextPage;
|
|
393
|
-
}
|
|
394
|
-
else if (action.cursor === Cursor.NEXT &&
|
|
395
|
-
this.page.items.length <= this.page.total &&
|
|
396
|
-
index + this.page.baseIndex === this.page.items.length &&
|
|
397
|
-
index + this.page.baseIndex < this.page.total) {
|
|
398
|
-
// trigger load-more from button to benefit from `disabled-on-click`
|
|
399
|
-
this.loadMoreElement.click();
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
else if (action.name === 'scroll') {
|
|
403
|
-
promise = nextTick;
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
promise = this.updatePage;
|
|
407
|
-
}
|
|
408
|
-
return promise()
|
|
409
|
-
.then(() => {
|
|
410
|
-
// parse full items list from options
|
|
411
|
-
const options = this.filter === '' ? this.options.items : this.options.items.filter(option => option.title.includes(this.filter));
|
|
412
|
-
// update visual focus
|
|
413
|
-
if (action.name !== 'load-data') {
|
|
414
|
-
index = this.page.getIndexFromCursor(action.cursor, this.loadingAction === 'load-more' && index >= 0 ? options[index] : this.option);
|
|
415
|
-
}
|
|
416
|
-
this.option = options[index];
|
|
417
|
-
// update scroll position
|
|
418
|
-
this.scrollToIndex(index);
|
|
419
|
-
})
|
|
420
|
-
.finally(() => {
|
|
421
|
-
// reset loading after next render
|
|
422
|
-
requestAnimationFrame(() => {
|
|
423
|
-
this.isLoading = false;
|
|
424
|
-
this.loadingAction = undefined;
|
|
425
|
-
});
|
|
426
|
-
});
|
|
427
|
-
};
|
|
428
|
-
/**
|
|
429
|
-
* Go to next page
|
|
430
|
-
* @returns promise
|
|
431
|
-
*/
|
|
432
|
-
this.goToNextPage = () => {
|
|
433
|
-
this.showMore.emit();
|
|
434
|
-
if (this.fetchurl !== undefined) {
|
|
435
|
-
return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then(nextPage => {
|
|
436
|
-
if (nextPage !== undefined) {
|
|
437
|
-
// merge items from current page and next page
|
|
438
|
-
const items = [...this.page.items, ...nextPage.items];
|
|
439
|
-
// create new options pagination withe merged items
|
|
440
|
-
this.options = new Paginate(items, { total: nextPage.total, next: nextPage.next, top: items.length });
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
return nextTick(() => {
|
|
446
|
-
if (typeof this.page.next === 'function') {
|
|
447
|
-
const nextPage = this.page.next();
|
|
448
|
-
this.page = new Page(Object.assign(Object.assign({}, nextPage), { items: [...this.page.items, ...nextPage.items] }));
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
/**
|
|
454
|
-
* Go to next page
|
|
455
|
-
* @returns promise
|
|
456
|
-
*/
|
|
457
|
-
this.updatePage = async () => {
|
|
458
|
-
if (this.fetchurl !== undefined) {
|
|
459
|
-
return this.getOptions().then(page => {
|
|
460
|
-
if (page !== undefined) {
|
|
461
|
-
// reset current options pagination from API response
|
|
462
|
-
this.options = new Paginate(page.items, { total: page.total, next: page.next, top: page.top });
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
else {
|
|
467
|
-
this.page = this.getFirstPage();
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
/**
|
|
471
|
-
* Fetch request
|
|
472
|
-
* @param url - to fetch
|
|
473
|
-
* @returns new page from url
|
|
474
|
-
*/
|
|
475
|
-
this.getOptions = async (url = this.fetchurl) => {
|
|
476
|
-
// add text filter to url
|
|
477
|
-
const filter = typeof this.fetchmappings.request.filterTransform === 'function' ? this.fetchmappings.request.filterTransform(this.filter) : this.filter;
|
|
478
|
-
const updateUrl = (typeof url === 'string' ? url : url.toString()).replaceAll(this.fetchmappings.request.filter, encodeURIComponent(filter));
|
|
479
|
-
try {
|
|
480
|
-
const response = await fetch(updateUrl, this.fetchoptions);
|
|
481
|
-
if (!response.ok) {
|
|
482
|
-
this.fetchError.emit(new Error(`${response.status} - ${response.statusText}`));
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
const json = await response.json();
|
|
486
|
-
const items = getObjectValueFromKey(json, this.fetchmappings.response.items).map((item) => {
|
|
487
|
-
var _a;
|
|
488
|
-
return ({
|
|
489
|
-
title: getObjectValueFromKey(item, this.fetchmappings.response.itemTitle),
|
|
490
|
-
value: (_a = getObjectValueFromKey(item, this.fetchmappings.response.itemValue)) !== null && _a !== void 0 ? _a : item,
|
|
491
|
-
});
|
|
492
|
-
});
|
|
493
|
-
const total = Number(getObjectValueFromKey(json, this.fetchmappings.response.total, 0));
|
|
494
|
-
let next = getObjectValueFromKey(json, this.fetchmappings.response.next);
|
|
495
|
-
if (URL.canParse(updateUrl) && Boolean(next) && !URL.canParse(next)) {
|
|
496
|
-
const previousUrl = new URL(updateUrl);
|
|
497
|
-
if (previousUrl.pathname.endsWith(next.split('?')[0])) {
|
|
498
|
-
next = new URL(next, previousUrl).toString();
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return { items, total, next, top: items.length };
|
|
502
|
-
}
|
|
503
|
-
catch (error) {
|
|
504
|
-
this.fetchError.emit(error);
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
}
|
|
508
|
-
watchValue(newValue) {
|
|
509
|
-
this.filter = this.getValueTitle();
|
|
510
|
-
this.valueChange.emit(newValue);
|
|
511
|
-
}
|
|
512
|
-
watchItems(newValue) {
|
|
513
|
-
if (this.fetchurl !== undefined && newValue === undefined) {
|
|
514
|
-
// skip newValue check
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
else if (this.fetchurl !== undefined && newValue !== undefined) {
|
|
518
|
-
throw new Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${toString(newValue)}.`);
|
|
519
|
-
}
|
|
520
|
-
// Empty options
|
|
521
|
-
else if (Array.isArray(newValue) && newValue.length === 0) {
|
|
522
|
-
this.options = new Paginate([]);
|
|
523
|
-
}
|
|
524
|
-
// String array
|
|
525
|
-
else if (allItemsAreString(newValue)) {
|
|
526
|
-
this.options = new Paginate(newValue.map(item => ({ title: item, value: item })), { total: newValue.length });
|
|
527
|
-
}
|
|
528
|
-
// Object array
|
|
529
|
-
else if (isItems(newValue)) {
|
|
530
|
-
this.options = new Paginate(newValue, { total: newValue.length });
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
throw new Error(`<mg-input-combobox> prop "items" values must be the same type, string or Option. Passed value: ${toString(newValue)}.`);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
watchIdentifier(newValue) {
|
|
537
|
-
if (isValidString(newValue)) {
|
|
538
|
-
this.popoverId = `${newValue}-popover`;
|
|
539
|
-
this.element.dataset.mgPopoverGuard = this.popoverId;
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
watchReadonly(newValue) {
|
|
543
|
-
if (newValue)
|
|
544
|
-
this.classCollection.add(classReadonly);
|
|
545
|
-
else
|
|
546
|
-
this.classCollection.delete(classReadonly);
|
|
547
|
-
}
|
|
548
|
-
watchValidityChange(newValue, _oldValue, prop) {
|
|
549
|
-
if (this.input === undefined)
|
|
550
|
-
return;
|
|
551
|
-
this.input[prop] = newValue;
|
|
552
|
-
this.checkValidity();
|
|
553
|
-
if (this.hasDisplayedError) {
|
|
554
|
-
this.setErrorMessage();
|
|
555
|
-
this.hasDisplayedError = false;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
watchDisabled(newValue) {
|
|
559
|
-
if (newValue) {
|
|
560
|
-
this.classCollection.add(classDisabled);
|
|
561
|
-
}
|
|
562
|
-
else {
|
|
563
|
-
this.classCollection.delete(classDisabled);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
watchMgWidth(newValue) {
|
|
567
|
-
// reset width class
|
|
568
|
-
widths.forEach(width => {
|
|
569
|
-
this.classCollection.delete(`mg-c-input--width-${width}`);
|
|
570
|
-
});
|
|
571
|
-
// apply new width
|
|
572
|
-
if (newValue !== undefined)
|
|
573
|
-
this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
|
|
574
|
-
this.classCollection = new ClassList(this.classCollection.classes);
|
|
575
|
-
}
|
|
576
|
-
watchFetchUrl(newValue) {
|
|
577
|
-
if (newValue !== undefined) {
|
|
578
|
-
this.loadingWrapper({ name: 'load-data' });
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
watchFetchOptions(newValue) {
|
|
582
|
-
if (this.fetchurl && newValue && !isObject(newValue)) {
|
|
583
|
-
throw new Error(`<mg-input-combobox> prop "fetchoptions" value must be a valid RequestInit. Passed value: ${toString(newValue)}.`);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
watchFetchMappings(newValue) {
|
|
587
|
-
if (this.fetchurl !== undefined && !isObject(newValue)) {
|
|
588
|
-
throw new Error(`<mg-input-combobox> prop "fetchmappings" is required with "fetchurl" prop.`);
|
|
589
|
-
}
|
|
590
|
-
else if (newValue !== undefined && !isFetchmappings(newValue)) {
|
|
591
|
-
throw new Error(`<mg-input-combobox> prop "fetchmappings" value must be { request: RequestMappingType, response: ResponseMappingType }. Passed value: ${toString(newValue)}.`);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
watchOptions() {
|
|
595
|
-
this.page = this.getFirstPage();
|
|
596
|
-
}
|
|
597
|
-
watchFilter(newValue) {
|
|
598
|
-
this.loadingWrapper({ name: 'load-data' });
|
|
599
|
-
this.filterChange.emit(newValue);
|
|
600
|
-
}
|
|
601
|
-
watchPopoverDisplay(newValue) {
|
|
602
|
-
if (newValue) {
|
|
603
|
-
this.input.focus();
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
// remove visual focus
|
|
607
|
-
this.option = null;
|
|
608
|
-
// reset filter with value
|
|
609
|
-
this.filter = this.getValueTitle();
|
|
610
|
-
this.handlerInProgress = 'blur';
|
|
611
|
-
this.displayError().finally(() => {
|
|
612
|
-
// reset guard
|
|
613
|
-
this.handlerInProgress = undefined;
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Set focus on input.
|
|
619
|
-
*/
|
|
620
|
-
async setFocus() {
|
|
621
|
-
var _a;
|
|
622
|
-
(_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Display input error if it exists.
|
|
626
|
-
*/
|
|
627
|
-
displayError() {
|
|
628
|
-
// Use `Promise` as requested for stencil method
|
|
629
|
-
// Use `requestAnimationFrame` to ensure:
|
|
630
|
-
// - DOM is fully updated before validation
|
|
631
|
-
// - Async operations are completed
|
|
632
|
-
// - No timing issues with Stencil's render cycle
|
|
633
|
-
// - Keep everything in sync both inside and outside the component
|
|
634
|
-
return new Promise(resolve => {
|
|
635
|
-
requestAnimationFrame(() => {
|
|
636
|
-
this.checkValidity();
|
|
637
|
-
this.setErrorMessage();
|
|
638
|
-
this.hasDisplayedError = this.invalid;
|
|
639
|
-
resolve();
|
|
640
|
-
});
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
/**
|
|
644
|
-
* Set an error and display a custom error message.
|
|
645
|
-
* This method can be used to set the component's error state from its concombobox by passing a boolean value to the `valid` parameter.
|
|
646
|
-
* It must be paired with an error message to display for the given concombobox.
|
|
647
|
-
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
648
|
-
* @param valid - value indicating the validity
|
|
649
|
-
* @param errorMessage - the error message to display
|
|
650
|
-
* @param errorMessageLock - lock the error message and validity state
|
|
651
|
-
*/
|
|
652
|
-
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
653
|
-
if (typeof valid !== 'boolean') {
|
|
654
|
-
throw new Error('<mg-input-combobox> method "setError()" param "valid" must be a boolean.');
|
|
655
|
-
}
|
|
656
|
-
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
657
|
-
throw new Error('<mg-input-combobox> method "setError()" param "errorMessage" must be a string.');
|
|
658
|
-
}
|
|
659
|
-
else {
|
|
660
|
-
this.customErrorMessage = {
|
|
661
|
-
lock: valid ? false : errorMessageLock,
|
|
662
|
-
message: valid ? undefined : errorMessage,
|
|
663
|
-
};
|
|
664
|
-
this.setValidity(valid);
|
|
665
|
-
this.setErrorMessage(true);
|
|
666
|
-
this.hasDisplayedError = this.invalid;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
/**
|
|
670
|
-
* Reset value, validity and error state
|
|
671
|
-
*/
|
|
672
|
-
async reset() {
|
|
673
|
-
if (!this.readonly) {
|
|
674
|
-
this.setValue(null);
|
|
675
|
-
this.option = null;
|
|
676
|
-
this.filter = '';
|
|
677
|
-
// Use `Promise` as requested for stencil method
|
|
678
|
-
// Use `requestAnimationFrame` to ensure:
|
|
679
|
-
// - DOM is fully updated before validation
|
|
680
|
-
// - Async operations are completed
|
|
681
|
-
// - No timing issues with Stencil's render cycle
|
|
682
|
-
// - Keep everything in sync both inside and outside the component
|
|
683
|
-
return new Promise(resolve => {
|
|
684
|
-
requestAnimationFrame(() => {
|
|
685
|
-
// unlock validity check by reseting customErrorMessage
|
|
686
|
-
this.customErrorMessage = { lock: false };
|
|
687
|
-
this.checkValidity();
|
|
688
|
-
this.errorMessage = undefined;
|
|
689
|
-
this.hasDisplayedError = false;
|
|
690
|
-
resolve();
|
|
691
|
-
});
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* Set value prop
|
|
697
|
-
* @param newValue - slected option item
|
|
698
|
-
*/
|
|
699
|
-
setValue(newValue) {
|
|
700
|
-
if (!isItem(newValue)) {
|
|
701
|
-
this.value = '';
|
|
702
|
-
}
|
|
703
|
-
else if (allItemsAreString(this.items || this.options.items)) {
|
|
704
|
-
this.value = newValue.title;
|
|
705
|
-
}
|
|
706
|
-
else {
|
|
707
|
-
this.value = Object.assign({}, newValue);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* Method to set validity values
|
|
712
|
-
* @param newValue - valid new value
|
|
713
|
-
*/
|
|
714
|
-
setValidity(newValue) {
|
|
715
|
-
const oldValue = this.valid;
|
|
716
|
-
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
717
|
-
this.valid = newValue;
|
|
718
|
-
}
|
|
719
|
-
this.invalid = !this.valid;
|
|
720
|
-
// We need to send valid event even if it is the same value
|
|
721
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
722
|
-
this.inputValid.emit(this.valid);
|
|
723
|
-
}
|
|
724
|
-
/*************
|
|
725
|
-
* Lifecycle *
|
|
726
|
-
*************/
|
|
727
|
-
/**
|
|
728
|
-
* Check if component props are well configured on init
|
|
729
|
-
* @returns timeout
|
|
730
|
-
*/
|
|
731
|
-
componentWillLoad() {
|
|
732
|
-
// Get locales
|
|
733
|
-
this.messages = initLocales(this.element).messages;
|
|
734
|
-
// Validate
|
|
735
|
-
this.watchIdentifier(this.identifier);
|
|
736
|
-
this.watchItems(this.items);
|
|
737
|
-
if (this.fetchurl !== undefined) {
|
|
738
|
-
this.watchFetchOptions(this.fetchoptions);
|
|
739
|
-
this.watchFetchMappings(this.fetchmappings);
|
|
740
|
-
this.loadingWrapper({ name: 'load-data' });
|
|
741
|
-
}
|
|
742
|
-
this.watchValue(this.value);
|
|
743
|
-
this.watchOptions();
|
|
744
|
-
this.watchMgWidth(this.mgWidth);
|
|
745
|
-
this.watchReadonly(this.readonly);
|
|
746
|
-
this.watchDisabled(this.disabled);
|
|
747
|
-
// Check validity when component is ready
|
|
748
|
-
// return a promise to process action only in the FIRST render().
|
|
749
|
-
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
750
|
-
return setTimeout(() => {
|
|
751
|
-
this.checkValidity();
|
|
752
|
-
}, 0);
|
|
753
|
-
}
|
|
754
|
-
/**
|
|
755
|
-
* Render
|
|
756
|
-
* @returns HTML Element
|
|
757
|
-
*/
|
|
758
|
-
render() {
|
|
759
|
-
var _a, _b, _c, _d, _e, _f;
|
|
760
|
-
const listId = `${this.identifier}-list`;
|
|
761
|
-
const readonlyValue = this.getValueTitle();
|
|
762
|
-
const withResetButton = this.value && !this.disabled;
|
|
763
|
-
let popoverContent;
|
|
764
|
-
if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0) {
|
|
765
|
-
popoverContent = 'list';
|
|
766
|
-
}
|
|
767
|
-
else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && this.filter.length > 0) {
|
|
768
|
-
popoverContent = 'notfound';
|
|
769
|
-
}
|
|
770
|
-
else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0) {
|
|
771
|
-
popoverContent = 'notavailable';
|
|
772
|
-
}
|
|
773
|
-
let activeDescendant;
|
|
774
|
-
if (((_d = this.option) === null || _d === void 0 ? void 0 : _d.value) !== undefined) {
|
|
775
|
-
activeDescendant = this.option.value;
|
|
776
|
-
}
|
|
777
|
-
else if (typeof this.value === 'string') {
|
|
778
|
-
activeDescendant = this.value;
|
|
779
|
-
}
|
|
780
|
-
else {
|
|
781
|
-
activeDescendant = (_e = this.value) === null || _e === void 0 ? void 0 : _e.value;
|
|
782
|
-
}
|
|
783
|
-
return (h("mg-input", { key: 'ee8222484fa6546a422eb724fdea67402644c0cc', 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 && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
|
|
784
|
-
'--mg-c-input-list-width': ((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) > 0 ? `${this.input.offsetWidth}px` : undefined,
|
|
785
|
-
}, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, h("div", { class: "mg-c-input__input-group-container" }, h("mg-icon", { icon: "magnifying-glass" }), 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": formatID(activeDescendant), onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
|
|
786
|
-
if (el !== null)
|
|
787
|
-
this.input = el;
|
|
788
|
-
} }), withResetButton ? (h("mg-button", { class: "mg-c-input__box-append mg-c-input__reset", variant: "flat", "is-icon": true, label: this.messages.general.reset, "aria-controls": this.identifier, tabindex: "-1", onClick: this.handleResetButton }, h("mg-icon", { icon: "cross" }))) : (h("mg-button", { class: "mg-c-input__box-append", variant: "flat", "is-icon": true, label: this.itemsLabel, tabindex: "-1", disabled: this.disabled }, h("mg-icon", { icon: `chevron-${this.popoverDisplay ? 'up' : 'down'}` })))), h("div", { slot: "content", class: "mg-c-input__popover-container" }, popoverContent === 'list' && [
|
|
789
|
-
// eslint-disable-next-line jsx-a11y/role-supports-aria-props
|
|
790
|
-
h("ul", { key: "list", class: "mg-c-input__input-list", role: "listbox", id: listId, "aria-label": this.itemsLabel, "aria-setsize": this.page.total }, this.page.items.map(option => {
|
|
791
|
-
var _a;
|
|
792
|
-
return (
|
|
793
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
794
|
-
h("li", { role: "option", class: {
|
|
795
|
-
'mg-c-input__input-list-item': true,
|
|
796
|
-
'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),
|
|
797
|
-
'mg-c-input__input-list-item--selected': this.isCurrentOption(option),
|
|
798
|
-
}, key: option.title, id: formatID(option.value), "aria-selected": this.isCurrentOption(option).toString(), "data-value": toString(option.value), onClick: this.handleOptionClick }, option.title, this.isCurrentOption(option) && h("mg-icon", { icon: "check" })));
|
|
799
|
-
})),
|
|
800
|
-
this.isLoading && h("mg-loader", { key: "loader", message: this.messages.input.combobox.search, class: { 'mg-u-visually-hidden': Boolean(this.page.next) } }),
|
|
801
|
-
this.page.next && (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) => {
|
|
802
|
-
if (el !== null)
|
|
803
|
-
this.loadMoreElement = el;
|
|
804
|
-
} }, h("mg-icon", { icon: "chevron-down" }), this.messages.input.showMore)),
|
|
805
|
-
], popoverContent === 'notfound' && (h("p", { id: popoverContent, class: "mg-c-input__popover-info" }, this.messages.input.combobox.notFound)), popoverContent === 'notavailable' && (h("p", { id: popoverContent, class: "mg-c-input__popover-info" }, this.messages.input.combobox.notAvailable)))))));
|
|
806
|
-
}
|
|
807
|
-
get element() { return this; }
|
|
808
|
-
static get watchers() { return {
|
|
809
|
-
"value": ["watchValue"],
|
|
810
|
-
"items": ["watchItems"],
|
|
811
|
-
"identifier": ["watchIdentifier"],
|
|
812
|
-
"readonly": ["watchReadonly", "watchValidityChange"],
|
|
813
|
-
"required": ["watchValidityChange"],
|
|
814
|
-
"disabled": ["watchValidityChange", "watchDisabled"],
|
|
815
|
-
"mgWidth": ["watchMgWidth"],
|
|
816
|
-
"fetchurl": ["watchFetchUrl"],
|
|
817
|
-
"fetchoptions": ["watchFetchOptions"],
|
|
818
|
-
"fetchmappings": ["watchFetchMappings"],
|
|
819
|
-
"options": ["watchOptions"],
|
|
820
|
-
"filter": ["watchFilter"],
|
|
821
|
-
"popoverDisplay": ["watchPopoverDisplay"]
|
|
822
|
-
}; }
|
|
823
|
-
static get style() { return mgInputComboboxCss; }
|
|
824
|
-
}, [257, "mg-input-combobox", {
|
|
825
|
-
"value": [1537],
|
|
826
|
-
"items": [16],
|
|
827
|
-
"itemsLabel": [1, "items-label"],
|
|
828
|
-
"identifier": [1],
|
|
829
|
-
"name": [1],
|
|
830
|
-
"label": [1],
|
|
831
|
-
"labelOnTop": [4, "label-on-top"],
|
|
832
|
-
"labelHide": [4, "label-hide"],
|
|
833
|
-
"placeholder": [1],
|
|
834
|
-
"required": [4],
|
|
835
|
-
"readonly": [4],
|
|
836
|
-
"disabled": [4],
|
|
837
|
-
"mgWidth": [8, "mg-width"],
|
|
838
|
-
"tooltip": [1],
|
|
839
|
-
"tooltipPosition": [1, "tooltip-position"],
|
|
840
|
-
"helpText": [1, "help-text"],
|
|
841
|
-
"fetchurl": [1],
|
|
842
|
-
"fetchoptions": [16],
|
|
843
|
-
"fetchmappings": [16],
|
|
844
|
-
"valid": [1028],
|
|
845
|
-
"invalid": [1028],
|
|
846
|
-
"isLoading": [32],
|
|
847
|
-
"options": [32],
|
|
848
|
-
"option": [32],
|
|
849
|
-
"filter": [32],
|
|
850
|
-
"classCollection": [32],
|
|
851
|
-
"errorMessage": [32],
|
|
852
|
-
"popoverDisplay": [32],
|
|
853
|
-
"setFocus": [64],
|
|
854
|
-
"displayError": [64],
|
|
855
|
-
"setError": [64],
|
|
856
|
-
"reset": [64]
|
|
857
|
-
}, undefined, {
|
|
858
|
-
"value": ["watchValue"],
|
|
859
|
-
"items": ["watchItems"],
|
|
860
|
-
"identifier": ["watchIdentifier"],
|
|
861
|
-
"readonly": ["watchReadonly", "watchValidityChange"],
|
|
862
|
-
"required": ["watchValidityChange"],
|
|
863
|
-
"disabled": ["watchValidityChange", "watchDisabled"],
|
|
864
|
-
"mgWidth": ["watchMgWidth"],
|
|
865
|
-
"fetchurl": ["watchFetchUrl"],
|
|
866
|
-
"fetchoptions": ["watchFetchOptions"],
|
|
867
|
-
"fetchmappings": ["watchFetchMappings"],
|
|
868
|
-
"options": ["watchOptions"],
|
|
869
|
-
"filter": ["watchFilter"],
|
|
870
|
-
"popoverDisplay": ["watchPopoverDisplay"]
|
|
871
|
-
}]);
|
|
872
|
-
function defineCustomElement$1() {
|
|
873
|
-
if (typeof customElements === "undefined") {
|
|
874
|
-
return;
|
|
875
|
-
}
|
|
876
|
-
const components = ["mg-input-combobox", "mg-button", "mg-card", "mg-icon", "mg-input", "mg-input-title", "mg-loader", "mg-popover", "mg-popover-content", "mg-tooltip", "mg-tooltip-content"];
|
|
877
|
-
components.forEach(tagName => { switch (tagName) {
|
|
878
|
-
case "mg-input-combobox":
|
|
879
|
-
if (!customElements.get(tagName)) {
|
|
880
|
-
customElements.define(tagName, MgInputCombobox$1);
|
|
881
|
-
}
|
|
882
|
-
break;
|
|
883
|
-
case "mg-button":
|
|
884
|
-
if (!customElements.get(tagName)) {
|
|
885
|
-
defineCustomElement$b();
|
|
886
|
-
}
|
|
887
|
-
break;
|
|
888
|
-
case "mg-card":
|
|
889
|
-
if (!customElements.get(tagName)) {
|
|
890
|
-
defineCustomElement$a();
|
|
891
|
-
}
|
|
892
|
-
break;
|
|
893
|
-
case "mg-icon":
|
|
894
|
-
if (!customElements.get(tagName)) {
|
|
895
|
-
defineCustomElement$9();
|
|
896
|
-
}
|
|
897
|
-
break;
|
|
898
|
-
case "mg-input":
|
|
899
|
-
if (!customElements.get(tagName)) {
|
|
900
|
-
defineCustomElement$8();
|
|
901
|
-
}
|
|
902
|
-
break;
|
|
903
|
-
case "mg-input-title":
|
|
904
|
-
if (!customElements.get(tagName)) {
|
|
905
|
-
defineCustomElement$7();
|
|
906
|
-
}
|
|
907
|
-
break;
|
|
908
|
-
case "mg-loader":
|
|
909
|
-
if (!customElements.get(tagName)) {
|
|
910
|
-
defineCustomElement$6();
|
|
911
|
-
}
|
|
912
|
-
break;
|
|
913
|
-
case "mg-popover":
|
|
914
|
-
if (!customElements.get(tagName)) {
|
|
915
|
-
defineCustomElement$5();
|
|
916
|
-
}
|
|
917
|
-
break;
|
|
918
|
-
case "mg-popover-content":
|
|
919
|
-
if (!customElements.get(tagName)) {
|
|
920
|
-
defineCustomElement$4();
|
|
921
|
-
}
|
|
922
|
-
break;
|
|
923
|
-
case "mg-tooltip":
|
|
924
|
-
if (!customElements.get(tagName)) {
|
|
925
|
-
defineCustomElement$3();
|
|
926
|
-
}
|
|
927
|
-
break;
|
|
928
|
-
case "mg-tooltip-content":
|
|
929
|
-
if (!customElements.get(tagName)) {
|
|
930
|
-
defineCustomElement$2();
|
|
931
|
-
}
|
|
932
|
-
break;
|
|
933
|
-
} });
|
|
934
|
-
}
|
|
935
|
-
defineCustomElement$1();
|
|
936
|
-
|
|
937
|
-
const MgInputCombobox = MgInputCombobox$1;
|
|
938
|
-
const defineCustomElement = defineCustomElement$1;
|
|
939
|
-
|
|
940
|
-
export { MgInputCombobox, defineCustomElement };
|
|
1
|
+
import{transformTag as t,proxyCustomElement as i,HTMLElement as s,createEvent as o,h as e}from"@stencil/core/internal/client";import{P as n,C as a,t as r,e as c,n as h,h as p,j as m,d as l,i as u,k as g,f as d}from"./index2.js";import{c as b,b as v,w as f}from"./mg-input.conf.js";import{i as w}from"./index3.js";import{K as _}from"./events.utils.js";import{d as x}from"./mg-button2.js";import{d as y}from"./mg-card2.js";import{d as z}from"./mg-icon2.js";import{d as k}from"./mg-input2.js";import{d as E}from"./mg-input-title2.js";import{d as j}from"./mg-loader2.js";import{d as F}from"./mg-popover2.js";import{d as O}from"./mg-popover-content2.js";import{d as q}from"./mg-tooltip2.js";import{d as C}from"./mg-tooltip-content2.js";const D=t=>t&&"object"==typeof t&&"string"==typeof t.title&&void 0!==t.value,P=i(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.valueChange=o(this,"value-change",7),this.filterChange=o(this,"filter-change",7),this.showMore=o(this,"load-more",7),this.inputValid=o(this,"input-valid",7),this.fetchError=o(this,"fetch-error",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.disabled=!1,this.mgWidth="full",this.tooltipPosition="input",this.options=new n([]),this.filter="",this.classCollection=new a(["mg-c-input--combobox","mg-c-input--has-icon","mg-c-input--input-append"]),this.popoverDisplay=!1,this.handleOptionClick=t=>{this.setValue(this.options.items.find((i=>r(i.value)===t.target.dataset.value))),this.popoverDisplay=!1},this.handleResetButton=t=>{t.stopPropagation(),this.reset().then((()=>{this.input.focus()}))},this.handlePopoverDisplay=t=>{this.popoverDisplay=t.detail},this.handleFilterInput=()=>{this.checkValidity(),this.hasDisplayedError&&this.setErrorMessage(),this.popoverDisplay||(this.popoverDisplay=!0),this.debounce||(this.debounce=!0,setTimeout((()=>{this.filter=this.input.value,this.debounce=!1}),250))},this.handleFilterBlur=t=>{this.popoverDisplay?(t.stopImmediatePropagation(),this.input.focus()):(this.handlerInProgress="blur",this.displayError().finally((()=>{this.handlerInProgress=void 0})))},this.handleFilterFocus=()=>{this.isLoading||(this.option=null)},this.handleLoadMoreButton=()=>{this.loadingWrapper({name:"load-more",cursor:c.NEXT}).then((()=>{this.input.focus()}))},this.handleFilterKeydown=t=>{var i;if(this.disabled||t.ctrlKey||t.shiftKey)return;let s=!1;switch(t.key){case _.TAB:case _.ENTER:{s=t.key===_.ENTER;const o=null!==(i=this.option)&&void 0!==i?i:this.options.items.find(this.isCurrentOption);this.popoverDisplay&&this.setValue(o),this.popoverDisplay=!1;break}case _.DOWN:case _.ARROWDOWN:case _.UP:case _.ARROWUP:{if(s=!0,this.isLoading||0===this.page.total){this.popoverDisplay=!0;break}if(t.altKey&&[_.DOWN,_.ARROWDOWN].includes(t.key)){this.popoverDisplay=!0;break}let i;const o=this.popoverDisplay&&D(this.option);[_.DOWN,_.ARROWDOWN].includes(t.key)?i=o?c.NEXT:c.FIRST:[_.UP,_.ARROWUP].includes(t.key)&&(i=o?c.PREVIOUS:c.LAST),this.loadingWrapper({name:"scroll",cursor:i}),this.popoverDisplay=!0;break}case _.LEFT:case _.ARROWLEFT:case _.HOME:case _.RIGHT:case _.ARROWRIGHT:case _.END:{if(!D(this.option))break;let i;s=!0,this.option=null,_.HOME===t.key?i=0:_.END===t.key&&(i=this.filter.length),"number"==typeof i&&this.input.setSelectionRange(i,i);break}case _.ESC:case _.ESCAPE:s=!0,this.popoverDisplay?this.popoverDisplay=!1:(this.setValue(null),this.filter="",this.option=null);break;default:this.option=null}s&&(t.stopPropagation(),t.preventDefault())},this.scrollToIndex=t=>{requestAnimationFrame((()=>{var i;this.popoverDisplay&&(null===(i=this.element.shadowRoot.querySelector(`li:nth-of-type(${(t||0)+this.page.baseIndex})`))||void 0===i||i.scrollIntoView({block:"nearest"}))}))},this.isCurrentOption=t=>(D(this.value)?this.value.value:this.value)===t.value,this.getValueTitle=()=>this.value&&D(this.value)?this.value.title:"string"==typeof this.value?this.value:"",this.checkValidity=()=>{this.setValidity(this.readonly||this.disabled||this.input.checkValidity())},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.input.validity.valueMissing&&(this.errorMessage=this.messages.errors.required))},this.getFirstPage=()=>this.options.getPage(0,(t=>""===this.filter||t.title.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase()))),this.loadingWrapper=t=>{var i;let s,o;if(null!==(i=this.loadingAction)&&void 0!==i||(this.loadingAction=t.name),this.option&&"load-more"!==this.loadingAction?o=this.page.items.findIndex((t=>r(t.value)===r(this.option.value))):"load-more"===this.loadingAction&&(o=this.page.items.length-this.page.baseIndex),"load-more"===t.name)this.isLoading=!0,s=this.goToNextPage;else{if(t.cursor===c.NEXT&&this.page.items.length<=this.page.total&&o+this.page.baseIndex===this.page.items.length&&o+this.page.baseIndex<this.page.total)return void this.loadMoreElement.click();s="scroll"===t.name?h:this.updatePage}return s().then((()=>{const i=""===this.filter?this.options.items:this.options.items.filter((t=>t.title.includes(this.filter)));"load-data"!==t.name&&(o=this.page.getIndexFromCursor(t.cursor,"load-more"===this.loadingAction&&o>=0?i[o]:this.option)),this.option=i[o],this.scrollToIndex(o)})).finally((()=>{requestAnimationFrame((()=>{this.isLoading=!1,this.loadingAction=void 0}))}))},this.goToNextPage=()=>(this.showMore.emit(),void 0!==this.fetchurl?this.getOptions("string"==typeof this.page.next?this.page.next:void 0).then((t=>{if(void 0!==t){const i=[...this.page.items,...t.items];this.options=new n(i,{total:t.total,next:t.next,top:i.length})}})):h((()=>{if("function"==typeof this.page.next){const t=this.page.next();this.page=new p(Object.assign(Object.assign({},t),{items:[...this.page.items,...t.items]}))}}))),this.updatePage=async()=>{if(void 0!==this.fetchurl)return this.getOptions().then((t=>{void 0!==t&&(this.options=new n(t.items,{total:t.total,next:t.next,top:t.top}))}));this.page=this.getFirstPage()},this.getOptions=async(t=this.fetchurl)=>{const i="function"==typeof this.fetchmappings.request.filterTransform?this.fetchmappings.request.filterTransform(this.filter):this.filter,s=("string"==typeof t?t:""+t).replaceAll(this.fetchmappings.request.filter,encodeURIComponent(i));try{const t=await fetch(s,this.fetchoptions);if(!t.ok)return void this.fetchError.emit(Error(`${t.status} - ${t.statusText}`));const i=await t.json(),o=m(i,this.fetchmappings.response.items).map((t=>{var i;return{title:m(t,this.fetchmappings.response.itemTitle),value:null!==(i=m(t,this.fetchmappings.response.itemValue))&&void 0!==i?i:t}})),e=Number(m(i,this.fetchmappings.response.total,0));let n=m(i,this.fetchmappings.response.next);if(URL.canParse(s)&&n&&!URL.canParse(n)){const t=new URL(s);t.pathname.endsWith(n.split("?")[0])&&(n=""+new URL(n,t))}return{items:o,total:e,next:n,top:o.length}}catch(t){this.fetchError.emit(t)}}}watchValue(t){this.filter=this.getValueTitle(),this.valueChange.emit(t)}watchItems(t){if(void 0===this.fetchurl||void 0!==t){if(void 0!==this.fetchurl&&void 0!==t)throw Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${r(t)}.`);if(Array.isArray(t)&&0===t.length)this.options=new n([]);else if(l(t))this.options=new n(t.map((t=>({title:t,value:t}))),{total:t.length});else{if(!(t=>Array.isArray(t)&&t.every(D))(t))throw Error(`<mg-input-combobox> prop "items" values must be the same type, string or Option. Passed value: ${r(t)}.`);this.options=new n(t,{total:t.length})}}}watchIdentifier(t){u(t)&&(this.popoverId=t+"-popover",this.element.dataset.mgPopoverGuard=this.popoverId)}watchReadonly(t){t?this.classCollection.add(b):this.classCollection.delete(b)}watchValidityChange(t,i,s){void 0!==this.input&&(this.input[s]=t,this.checkValidity(),this.hasDisplayedError&&(this.setErrorMessage(),this.hasDisplayedError=!1))}watchDisabled(t){t?this.classCollection.add(v):this.classCollection.delete(v)}watchMgWidth(t){f.forEach((t=>{this.classCollection.delete("mg-c-input--width-"+t)})),void 0!==t&&this.classCollection.add("mg-c-input--width-"+this.mgWidth),this.classCollection=new a(this.classCollection.classes)}watchFetchUrl(t){void 0!==t&&this.loadingWrapper({name:"load-data"})}watchFetchOptions(t){if(this.fetchurl&&t&&!g(t))throw Error(`<mg-input-combobox> prop "fetchoptions" value must be a valid RequestInit. Passed value: ${r(t)}.`)}watchFetchMappings(t){if(void 0!==this.fetchurl&&!g(t))throw Error('<mg-input-combobox> prop "fetchmappings" is required with "fetchurl" prop.');if(void 0!==t&&!(t=>{const i=g(t)&&Object.hasOwn(t,"request")&&Object.hasOwn(t,"response");if(i){const{request:i,response:s}=t;return![i,s].some((t=>!g(t)))&&!("string"!=typeof i.filter||void 0!==i.filterTransform&&"function"!=typeof i.filterTransform||"object"!=typeof s||"string"!=typeof s.total||"string"!=typeof s.items||"string"!=typeof s.next||"string"!=typeof s.itemTitle||"string"!=typeof s.itemValue&&void 0!==s.itemValue)}return i})(t))throw Error(`<mg-input-combobox> prop "fetchmappings" value must be { request: RequestMappingType, response: ResponseMappingType }. Passed value: ${r(t)}.`)}watchOptions(){this.page=this.getFirstPage()}watchFilter(t){this.loadingWrapper({name:"load-data"}),this.filterChange.emit(t)}watchPopoverDisplay(t){t?this.input.focus():(this.option=null,this.filter=this.getValueTitle(),this.handlerInProgress="blur",this.displayError().finally((()=>{this.handlerInProgress=void 0})))}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,s=!1){if("boolean"!=typeof t)throw Error('<mg-input-combobox> method "setError()" param "valid" must be a boolean.');if(void 0!==i&&!u(i))throw Error('<mg-input-combobox> method "setError()" param "errorMessage" must be a string.');this.customErrorMessage={lock:!t&&s,message:t?void 0:i},this.setValidity(t),this.setErrorMessage(!0),this.hasDisplayedError=this.invalid}async reset(){if(!this.readonly)return this.setValue(null),this.option=null,this.filter="",new Promise((t=>{requestAnimationFrame((()=>{this.customErrorMessage={lock:!1},this.checkValidity(),this.errorMessage=void 0,this.hasDisplayedError=!1,t()}))}))}setValue(t){this.value=D(t)?l(this.items||this.options.items)?t.title:Object.assign({},t):""}setValidity(t){const i=this.valid;this.customErrorMessage.lock&&(void 0===this.customErrorMessage.message||t)||(this.valid=t),this.invalid=!this.valid,(void 0===this.handlerInProgress||"blur"===this.handlerInProgress&&this.valid!==i)&&this.inputValid.emit(this.valid)}componentWillLoad(){return this.messages=w(this.element).messages,this.watchIdentifier(this.identifier),this.watchItems(this.items),void 0!==this.fetchurl&&(this.watchFetchOptions(this.fetchoptions),this.watchFetchMappings(this.fetchmappings),this.loadingWrapper({name:"load-data"})),this.watchValue(this.value),this.watchOptions(),this.watchMgWidth(this.mgWidth),this.watchReadonly(this.readonly),this.watchDisabled(this.disabled),setTimeout((()=>{this.checkValidity()}),0)}render(){var t,i,s,o,n,a;const c=this.identifier+"-list",h=this.getValueTitle(),p=this.value&&!this.disabled;let m,l;return(null===(t=this.page)||void 0===t?void 0:t.items.length)>0?m="list":0===(null===(i=this.page)||void 0===i?void 0:i.items.length)&&this.filter.length>0?m="notfound":0===(null===(s=this.page)||void 0===s?void 0:s.items.length)&&(m="notavailable"),l=void 0!==(null===(o=this.option)||void 0===o?void 0:o.value)?this.option.value:"string"==typeof this.value?this.value:null===(n=this.value)||void 0===n?void 0:n.value,e("mg-input",{key:"d16350f2e21e492932e7264c076454a249e1f5f2",label:this.label,identifier:this.identifier,class:this.classCollection.classes.join(" "),ariaDescribedbyIDs:m&&"list"!==m?m:void 0,labelOnTop:this.labelOnTop,labelHide:this.labelHide,required:this.required,tooltip:this.tooltip,tooltipPosition:this.readonly&&void 0===this.value?"label":this.tooltipPosition,helpText:this.helpText,errorMessage:this.errorMessage},this.readonly?h&&e("b",{class:"mg-c-input__readonly-value"},h):e("mg-popover",{identifier:this.popoverId,placement:"bottom-start",display:this.popoverDisplay,"arrow-hide":!0,style:{"--mg-c-input-list-width":(null===(a=this.input)||void 0===a?void 0:a.offsetWidth)>0?this.input.offsetWidth+"px":void 0},"data-fallback-placement":"bottom-end","onDisplay-change":this.handlePopoverDisplay},e("div",{class:"mg-c-input__input-group-container"},e("mg-icon",{icon:"magnifying-glass"}),e("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,"aria-controls":c,"aria-invalid":""+(!0===this.invalid),"aria-activedescendant":d(l),onInput:this.handleFilterInput,onBlur:this.handleFilterBlur,onFocus:this.handleFilterFocus,onKeyDown:this.handleFilterKeydown,ref:t=>{null!==t&&(this.input=t)}}),p?e("mg-button",{class:"mg-c-input__box-append mg-c-input__reset",variant:"flat","is-icon":!0,label:this.messages.general.reset,"aria-controls":this.identifier,tabindex:"-1",onClick:this.handleResetButton},e("mg-icon",{icon:"cross"})):e("mg-button",{class:"mg-c-input__box-append",variant:"flat","is-icon":!0,label:this.itemsLabel,tabindex:"-1",disabled:this.disabled},e("mg-icon",{icon:"chevron-"+(this.popoverDisplay?"up":"down")}))),e("div",{slot:"content",class:"mg-c-input__popover-container"},"list"===m&&[e("ul",{key:"list",class:"mg-c-input__input-list",role:"listbox",id:c,"aria-label":this.itemsLabel,"aria-setsize":this.page.total},this.page.items.map((t=>{var i;return e("li",{role:"option",class:{"mg-c-input__input-list-item":!0,"mg-c-input__input-list-item--focus-visible":JSON.stringify(null===(i=this.option)||void 0===i?void 0:i.value)===JSON.stringify(t.value),"mg-c-input__input-list-item--selected":this.isCurrentOption(t)},key:t.title,id:d(t.value),"aria-selected":""+this.isCurrentOption(t),"data-value":r(t.value),onClick:this.handleOptionClick},t.title,this.isCurrentOption(t)&&e("mg-icon",{icon:"check"}))}))),this.isLoading&&e("mg-loader",{key:"loader",message:this.messages.input.combobox.search,class:{"mg-u-visually-hidden":!!this.page.next}}),this.page.next&&e("mg-button",{key:"load-more",variant:"flat",class:"mg-c-input__load-more",tabIndex:-1,disabled:this.isLoading,"full-width":!0,"disable-on-click":!0,onClick:this.handleLoadMoreButton,"aria-controls":c,ref:t=>{null!==t&&(this.loadMoreElement=t)}},e("mg-icon",{icon:"chevron-down"}),this.messages.input.showMore)],"notfound"===m&&e("p",{id:m,class:"mg-c-input__popover-info"},this.messages.input.combobox.notFound),"notavailable"===m&&e("p",{id:m,class:"mg-c-input__popover-info"},this.messages.input.combobox.notAvailable))))}get element(){return this}static get watchers(){return{value:[{watchValue:0}],items:[{watchItems:0}],identifier:[{watchIdentifier:0}],readonly:[{watchReadonly:0},{watchValidityChange:0}],required:[{watchValidityChange:0}],disabled:[{watchValidityChange:0},{watchDisabled:0}],mgWidth:[{watchMgWidth:0}],fetchurl:[{watchFetchUrl:0}],fetchoptions:[{watchFetchOptions:0}],fetchmappings:[{watchFetchMappings:0}],options:[{watchOptions:0}],filter:[{watchFilter:0}],popoverDisplay:[{watchPopoverDisplay:0}]}}static get style(){return".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__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-popover-overflow:auto;--mg-c-popover-spacing-vertical:0;--mg-c-popover-spacing-horizontal:0;--mg-c-popover-min-width:var(--mg-c-input-list-width);--mg-c-popover-max-height:calc(50 * var(--mg-b-size-8) - var(--mg-b-size-32))}.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;flex-direction:column;gap:var(--mg-b-size-4)}.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}"}},[1,"mg-input-combobox",{value:[1537],items:[16],itemsLabel:[1,"items-label"],identifier:[1],name:[1],label:[1],labelOnTop:[4,"label-on-top"],labelHide:[4,"label-hide"],placeholder:[1],required:[4],readonly:[4],disabled:[4],mgWidth:[8,"mg-width"],tooltip:[1],tooltipPosition:[1,"tooltip-position"],helpText:[1,"help-text"],fetchurl:[1],fetchoptions:[16],fetchmappings:[16],valid:[1028],invalid:[1028],isLoading:[32],options:[32],option:[32],filter:[32],classCollection:[32],errorMessage:[32],popoverDisplay:[32],setFocus:[64],displayError:[64],setError:[64],reset:[64]},void 0,{value:[{watchValue:0}],items:[{watchItems:0}],identifier:[{watchIdentifier:0}],readonly:[{watchReadonly:0},{watchValidityChange:0}],required:[{watchValidityChange:0}],disabled:[{watchValidityChange:0},{watchDisabled:0}],mgWidth:[{watchMgWidth:0}],fetchurl:[{watchFetchUrl:0}],fetchoptions:[{watchFetchOptions:0}],fetchmappings:[{watchFetchMappings:0}],options:[{watchOptions:0}],filter:[{watchFilter:0}],popoverDisplay:[{watchPopoverDisplay:0}]}]);function V(){"undefined"!=typeof customElements&&["mg-input-combobox","mg-button","mg-card","mg-icon","mg-input","mg-input-title","mg-loader","mg-popover","mg-popover-content","mg-tooltip","mg-tooltip-content"].forEach((i=>{switch(i){case"mg-input-combobox":customElements.get(t(i))||customElements.define(t(i),P);break;case"mg-button":customElements.get(t(i))||x();break;case"mg-card":customElements.get(t(i))||y();break;case"mg-icon":customElements.get(t(i))||z();break;case"mg-input":customElements.get(t(i))||k();break;case"mg-input-title":customElements.get(t(i))||E();break;case"mg-loader":customElements.get(t(i))||j();break;case"mg-popover":customElements.get(t(i))||F();break;case"mg-popover-content":customElements.get(t(i))||O();break;case"mg-tooltip":customElements.get(t(i))||q();break;case"mg-tooltip-content":customElements.get(t(i))||C()}}))}V();const I=P,M=V;export{I as MgInputCombobox,M as defineCustomElement}
|