@mgdis/mg-components 6.26.0 → 6.28.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/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_36.cjs.entry.js +506 -161
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-illustration.cjs.entry.js +1 -1
- package/dist/cjs/mg-input-combobox.cjs.entry.js +60 -8
- package/dist/cjs/mg-input-file.cjs.entry.js +26 -3
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +2304 -1131
- package/dist/cjs/mg-loader.cjs.entry.js +1 -1
- package/dist/cjs/mg-progress.cjs.entry.js +1 -1
- package/dist/collection/assets/illustrations/index.js +1 -1
- package/dist/collection/assets/jodit/jodit.css +14 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +86 -13
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +103 -55
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +25 -4
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +59 -7
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +25 -9
- package/dist/collection/components/molecules/inputs/mg-input-file/mg-input-file.js +25 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +24 -6
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +24 -5
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +64 -16
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +32 -10
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +24 -5
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +24 -6
- package/dist/collection/components/molecules/mg-details/mg-details.js +5 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +83 -9
- 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 +3 -3
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/components/mg-button2.js +1 -1
- package/dist/components/mg-details.js +1 -1
- package/dist/components/mg-form.js +1 -1
- package/dist/components/mg-illustrated-message.js +1 -1
- package/dist/components/mg-illustration.js +1 -1
- package/dist/components/mg-input-checkbox.js +1 -1
- package/dist/components/mg-input-combobox.js +1 -1
- package/dist/components/mg-input-date.js +1 -1
- package/dist/components/mg-input-file.js +1 -1
- package/dist/components/mg-input-numeric.js +1 -1
- package/dist/components/mg-input-password.js +1 -1
- package/dist/components/mg-input-radio.js +1 -1
- package/dist/components/mg-input-rich-text-editor.js +285 -285
- package/dist/components/mg-input-select2.js +1 -1
- package/dist/components/mg-input-text2.js +1 -1
- package/dist/components/mg-input-textarea.js +1 -1
- package/dist/components/mg-input-toggle.js +1 -1
- package/dist/components/mg-input2.js +1 -1
- package/dist/components/mg-loader2.js +1 -1
- package/dist/components/mg-menu-item2.js +1 -1
- package/dist/components/mg-message2.js +1 -1
- package/dist/components/mg-modal.js +1 -1
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover-content2.js +1 -1
- package/dist/components/mg-popover2.js +1 -1
- 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/components/mg-tooltip2.js +1 -1
- package/dist/custom-elements.json +12 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_36.entry.js +507 -162
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-illustration.entry.js +1 -1
- package/dist/esm/mg-input-combobox.entry.js +60 -8
- package/dist/esm/mg-input-file.entry.js +26 -3
- package/dist/esm/mg-input-rich-text-editor.entry.js +2304 -1131
- package/dist/esm/mg-loader.entry.js +1 -1
- package/dist/esm/mg-progress.entry.js +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-2198f145.entry.js +1 -0
- package/dist/mg-components/p-85ebacd6.entry.js +1 -0
- package/dist/mg-components/{p-96fc508e.entry.js → p-c2beff2c.entry.js} +1 -1
- package/dist/mg-components/p-d4a4eb78.entry.js +1 -0
- package/dist/mg-components/p-e8b5e8d8.entry.js +1667 -0
- package/dist/mg-components/p-f308e2e4.entry.js +1 -0
- package/dist/mg-components/p-fdcce8d5.entry.js +1 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +41 -2
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +33 -6
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +21 -1
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-file/mg-input-file.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +29 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +10 -1
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +9 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +22 -0
- package/dist/types/components.d.ts +10 -2
- package/ide/intellij/web-types.json +4 -4
- package/ide/vscode/html-custom-data.json +3 -3
- package/package.json +19 -19
- package/dist/mg-components/p-206505b5.entry.js +0 -1667
- package/dist/mg-components/p-3ad7441c.entry.js +0 -1
- package/dist/mg-components/p-5dff879a.entry.js +0 -1
- package/dist/mg-components/p-b20f3698.entry.js +0 -1
- package/dist/mg-components/p-bf2252c9.entry.js +0 -1
- package/dist/mg-components/p-f8e58181.entry.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as i,c as t,h as e,a as s}from"./p-D4bO_UCn.js";import{C as r,b as o,t as n,i as a,c as h}from"./p-91BOpzAB.js";import{a as l,n as c}from"./p-DOi9lJXy.js";import{l as p,i as m}from"./p-BfblyCaJ.js";const g=class{constructor(s){i(this,s),this.valueChange=t(this,"value-change",7),this.inputValid=t(this,"input-valid",7),this.hasDisplayedError=!1,this.customErrorMessage={lock:!1},this.name=this.identifier,this.labelOnTop=!1,this.labelHide=!1,this.multiple=!1,this.required=!1,this.disabled=!1,this.tooltipPosition="input",this.classCollection=new r(["mg-c-input--file"]),this.files=[],this.setValidity=i=>{const t=this.valid;this.customErrorMessage.lock&&(void 0===this.customErrorMessage.message||i)||(this.valid=i),this.invalid=!this.valid,(void 0===this.handlerInProgress||"blur"===this.handlerInProgress&&this.valid!==t)&&this.inputValid.emit(this.valid)},this.handleInputChange=i=>{this.checkValidity(),this.hasDisplayedError&&this.setErrorMessage(),this.files=Array.from(i.target.files),this.fileButtonElement.focus()},this.handleInputFocus=()=>{this.fileButtonElement.dataset.focusVisible=""},this.handleInputBlur=()=>{this.handlerInProgress="blur",this.displayError().finally((()=>{this.handlerInProgress=void 0})),delete this.fileButtonElement.dataset.focusVisible},this.handleButtonBlur=()=>{this.inputElement.blur()},this.handleButtonClick=()=>{this.inputElement.click()},this.checkValidity=()=>{this.setValidity(this.disabled||!this.isMaxSizeExceeded()&&this.inputElement.checkValidity())},this.handleDeleteFileClick=()=>{this.files=[],this.fileButtonElement.focus()},this.setErrorMessage=(i=!1)=>{this.errorMessage=void 0,this.valid||(i||this.customErrorMessage.lock&&void 0!==this.customErrorMessage.message?this.errorMessage=this.customErrorMessage.message:this.isMaxSizeExceeded()?this.errorMessage=this.messages.input.file.errors.maxSize.replace("{{maxSize}}",p(this.maxSize,this.locale)):this.inputElement.validity.valueMissing&&(this.errorMessage=this.messages.errors.required))},this.isMaxSizeExceeded=()=>this.maxSize>=0&&this.files.some((i=>i.size>this.maxSize)),this.renderFiles=()=>{const i=`${this.identifier}-file-list`,t=i=>e("span",{class:"mg-c-input__file-item-name"},i.name,i.size>0?e("span",{class:"mg-c-input__file-item-size"},` ${p(i.size,this.locale)}`):void 0),s=()=>e("mg-button",{variant:"flat",class:"mg-c-input__file-delete-button","is-icon":!0,label:this.messages.input.file.deleteButton,type:"button",disabled:this.disabled,"aria-controls":[this.identifier,i].join(" "),onClick:this.handleDeleteFileClick},e("mg-icon",{icon:"cross"}));return 0===this.files.length?null:1===this.files.length?e("div",{class:"mg-c-input__file-item"},t(this.files[0]),s()):e("div",{class:"mg-c-input__file-list-container"},e("ul",{role:"list",class:"mg-c-input__file-list",id:i},Array.from(this.files).map(((i,s)=>e("li",{class:"mg-c-input__file-item",key:`${i.name}-${s}`},t(i))))),s())}}watchValue(i){if(o(i))this.files=this.value.map((i=>new File([],i)));else if(t=i,Array.isArray(t)&&t.every((i=>h(i)&&"string"==typeof i.name&&"number"==typeof i.size)))this.files=this.value;else{if(void 0!==i)throw new Error(`<mg-input-file> prop "value" must be an array of strings or File objects. Passed value: ${n(i)}.`);this.files=[]}var t;this.valueChange.emit(i)}watchMultiple(){if(!1===this.multiple&&this.files.length>1)throw new Error('<mg-input-file> prop "value" must be a single file when prop "multiple" is set to false.')}watchAccept(i){if(void 0!==i&&!a(i))throw new Error('<mg-input-file> prop "accept" must be a valid string.')}handleValidityChange(i,t,e){void 0!==this.inputElement&&(this.inputElement[e]=i,this.checkValidity(),this.hasDisplayedError&&(this.setErrorMessage(),this.hasDisplayedError=!1))}watchDisabled(i){i?this.classCollection.add(l):this.classCollection.delete(l)}watchHelpText(){if(!a(this.helpText)){const i=[];void 0!==this.maxSize&&i.push(this.messages.input.file.helpText.maxSize.replace("{{maxSize}}",p(this.maxSize,this.locale))),void 0!==this.accept&&i.push(this.messages.input.file.helpText.accept.replace("{{accept}}",this.accept)),this.helpText=i.join(". ")}}watchFiles(i,t){n(i)!==n(t)&&(this.value=i.length>0?i:void 0)}async setFocus(){this.fileButtonElement.focus()}displayError(){return new Promise((i=>{requestAnimationFrame((()=>{this.checkValidity(),this.setErrorMessage(),this.hasDisplayedError=this.invalid,i()}))}))}async setError(i,t,e=!1){if("boolean"!=typeof i)throw new Error('<mg-input-file> method "setError()" param "valid" must be a boolean.');if(void 0!==t&&!a(t))throw new Error('<mg-input-file> method "setError()" param "errorMessage" must be a string.');this.customErrorMessage={lock:!i&&e,message:i?void 0:t},this.setValidity(i),this.setErrorMessage(!0),this.hasDisplayedError=this.invalid}async reset(){return this.files=[],new Promise((i=>{requestAnimationFrame((()=>{this.customErrorMessage={lock:!1},this.checkValidity(),this.errorMessage=void 0,this.hasDisplayedError=!1,i()}))}))}componentWillLoad(){const i=m(this.element);return this.locale=i.locale,this.messages=i.messages,c(this),this.watchValue(this.value),this.watchDisabled(this.disabled),this.watchHelpText(),this.watchAccept(this.accept),this.watchMultiple(),setTimeout((()=>{this.checkValidity()}),0)}render(){return e("mg-input",{key:"3c4c0ebdd1661e381f0002b2ae68dcf454097913",label:this.label,identifier:this.identifier,class:this.classCollection.join(),labelOnTop:this.labelOnTop,labelHide:this.labelHide,required:this.required,tooltip:this.tooltip,tooltipPosition:this.tooltipPosition,helpText:this.helpText,errorMessage:this.errorMessage},e("div",{key:"bd7665fe8c6e01ec4e04fbbbf9cc21ccc4128b17",class:"mg-c-input__file-container"},e("input",{key:"f27d10160115ec1ff5163a1c55aa2658779c6fd7",name:this.name,id:this.identifier,class:"mg-u-visually-hidden",type:"file",multiple:!0===this.multiple,capture:this.capture,accept:this.accept,disabled:this.disabled,required:0===this.files.length&&this.required,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur,onChange:this.handleInputChange,"aria-invalid":(!0===this.invalid).toString(),ref:i=>{this.inputElement=i}}),e("mg-button",{key:"d16c4cbd95d676bcddb895659aab37f0f9c396eb",variant:"secondary",class:"mg-c-input__file-button",type:"button",disabled:this.disabled,onClick:this.handleButtonClick,onBlur:this.handleButtonBlur,tabindex:"-1",ref:i=>{this.fileButtonElement=i}},this.messages.input.file.browse),this.renderFiles()))}get element(){return s(this)}static get watchers(){return{value:[{watchValue:0},{watchMultiple:0}],multiple:[{watchMultiple:0}],accept:[{watchAccept:0},{watchHelpText:0}],required:[{handleValidityChange:0}],disabled:[{handleValidityChange:0},{watchDisabled:0}],helpText:[{watchHelpText:0}],maxSize:[{watchHelpText:0}],files:[{watchFiles:0}]}}};g.style=".mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:calc(-1*var(--mg-b-size-2));outline-style:solid;outline-width:var(--mg-b-size-2)}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip-path:inset(50%) !important;white-space:nowrap !important}.mg-u-visually-hidden *{overflow:hidden !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}.mg-c-input__file-container{display:flex;flex-direction:column;gap:var(--mg-b-size-8)}.mg-c-input__file-item{display:inline-flex;min-height:var(--mg-b-size-min-height);align-items:center;padding-left:var(--mg-b-size-8);background-color:var(--mg-b-color-neutral-10);font-weight:600;gap:var(--mg-b-size-8)}.mg-c-input__file-item-name{word-break:break-all}.mg-c-input__file-item-size{color:var(--mg-b-color-neutral-90);font-weight:400;word-break:normal}.mg-c-input__file-delete-button{align-self:flex-start}.mg-c-input__file-list{display:flex;flex-direction:column;padding:0;margin:0;gap:var(--mg-b-size-4);list-style:none}.mg-c-input__file-list .mg-c-input__file-item{min-height:unset;padding:var(--mg-b-size-8)}.mg-c-input__file-list-container{position:relative;padding:var(--mg-b-size-8) calc(var(--mg-b-size-8) + var(--mg-b-size-min-height)) var(--mg-b-size-8) var(--mg-b-size-8);border:var(--mg-b-size-border) solid var(--mg-b-color-neutral-30);border-radius:var(--mg-b-size-4)}.mg-c-input__file-list-container .mg-c-input__file-delete-button{position:absolute;top:0;right:0}";export{g as mg_input_file}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as i,h as s,a as o}from"./p-D4bO_UCn.js";import{P as e,C as n,t as a,a as h,n as r,g as c,b as p,i as m,c as u,f as l,d as g}from"./p-91BOpzAB.js";import{c as d,a as b,w as v,n as f}from"./p-DOi9lJXy.js";import{i as w}from"./p-BfblyCaJ.js";import{K as _}from"./p-yMGqY8YG.js";const x=t=>t&&"object"==typeof t&&"string"==typeof t.title&&void 0!==t.value,y=class{constructor(s){t(this,s),this.valueChange=i(this,"value-change",7),this.filterChange=i(this,"filter-change",7),this.showMore=i(this,"load-more",7),this.inputValid=i(this,"input-valid",7),this.fetchError=i(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.popoverPlacement="bottom-start",this.tooltipPosition="input",this.options=new e([]),this.filter="",this.classCollection=new n(["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=>a(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:h.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(Boolean(t.altKey)&&[_.DOWN,_.ARROWDOWN].includes(t.key)){this.popoverDisplay=!0;break}let i;const o=this.popoverDisplay&&x(this.option);[_.DOWN,_.ARROWDOWN].includes(t.key)?i=o?h.NEXT:h.FIRST:[_.UP,_.ARROWUP].includes(t.key)&&(i=o?h.PREVIOUS:h.LAST),this.loadingWrapper({name:"scroll",cursor:i}),this.popoverDisplay=!0;break}case _.LEFT:case _.ARROWLEFT:case _.HOME:case _.RIGHT:case _.ARROWRIGHT:case _.END:{if(!x(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=>(x(this.value)?this.value.value:this.value)===t.value,this.getValueTitle=()=>this.value&&x(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),Boolean(this.option)&&"load-more"!==this.loadingAction?o=this.page.items.findIndex((t=>a(t.value)===a(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===h.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?r: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 e(i,{total:t.total,next:t.next,top:i.length})}})):r((()=>{if("function"==typeof this.page.next){const t=this.page.next();this.page=new g(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 e(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.toString()).replaceAll(this.fetchmappings.request.filter,encodeURIComponent(i));try{const t=await fetch(s,this.fetchoptions);if(!t.ok)return void this.fetchError.emit(new Error(`${t.status} - ${t.statusText}`));const i=await t.json(),o=c(i,this.fetchmappings.response.items).map((t=>{var i;return{title:c(t,this.fetchmappings.response.itemTitle),value:null!==(i=c(t,this.fetchmappings.response.itemValue))&&void 0!==i?i:t}})),e=Number(c(i,this.fetchmappings.response.total,0));let n=c(i,this.fetchmappings.response.next);if(Boolean(n)&&!URL.canParse(n)){const t=new URL(s,this.element.ownerDocument.baseURI);n=new URL(n,t).toString()}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 new Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${a(t)}.`);if(Array.isArray(t)&&0===t.length)this.options=new e([]);else if(p(t))this.options=new e(t.map((t=>({title:t,value:t}))),{total:t.length});else{if(i=t,!Array.isArray(i)||!i.every(x))throw new Error(`<mg-input-combobox> prop "items" values must be the same type, string or Option. Passed value: ${a(t)}.`);this.options=new e(t,{total:t.length})}var i}}watchIdentifier(t){m(t)&&(this.popoverId=`${t}-popover`,this.element.dataset.mgPopoverGuard=this.popoverId)}watchReadonly(t){t?this.classCollection.add(d):this.classCollection.delete(d)}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(b):this.classCollection.delete(b)}watchMgWidth(t){v.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 n(this.classCollection.classes)}watchFetchUrl(t){void 0!==t&&this.loadingWrapper({name:"load-data"})}watchFetchOptions(t){if(this.fetchurl&&t&&!u(t))throw new Error(`<mg-input-combobox> prop "fetchoptions" value must be a valid RequestInit. Passed value: ${a(t)}.`)}watchFetchMappings(t){if(void 0!==this.fetchurl&&!u(t))throw new Error('<mg-input-combobox> prop "fetchmappings" is required with "fetchurl" prop.');if(void 0!==t&&!(t=>{const i=u(t)&&Object.hasOwn(t,"request")&&Object.hasOwn(t,"response");if(i){const{request:i,response:s}=t;return![i,s].some((t=>!u(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 new Error(`<mg-input-combobox> prop "fetchmappings" value must be { request: RequestMappingType, response: ResponseMappingType }. Passed value: ${a(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 new Error('<mg-input-combobox> method "setError()" param "valid" must be a boolean.');if(void 0!==i&&!m(i))throw new 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=x(t)?p(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,f(this),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,o,e,n,h;const r=`${this.identifier}-list`,c=this.getValueTitle(),p=this.value&&!this.disabled;let m,u;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===(o=this.page)||void 0===o?void 0:o.items.length)&&(m="notavailable"),u=void 0!==(null===(e=this.option)||void 0===e?void 0:e.value)?this.option.value:"string"==typeof this.value?this.value:null===(n=this.value)||void 0===n?void 0:n.value,s("mg-input",{key:"c8cff9468c9bfdcc6dd5c96c1452ad81620e050c",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?c&&s("b",{class:"mg-c-input__readonly-value"},c):s("mg-popover",{identifier:this.popoverId,placement:this.popoverPlacement,display:this.popoverDisplay,style:{"--mg-c-input-list-width":(null===(h=this.input)||void 0===h?void 0:h.offsetWidth)>0?`${this.input.offsetWidth}px`:void 0},"data-fallback-placement":"bottom-end","onDisplay-change":this.handlePopoverDisplay},s("div",{class:"mg-c-input__input-group-container"},s("mg-icon",{icon:"magnifying-glass"}),s("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":r,"aria-invalid":(!0===this.invalid).toString(),"aria-activedescendant":l(u),onInput:this.handleFilterInput,onBlur:this.handleFilterBlur,onFocus:this.handleFilterFocus,onKeyDown:this.handleFilterKeydown,ref:t=>{null!==t&&(this.input=t)}}),p?s("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},s("mg-icon",{icon:"cross"})):s("mg-button",{class:"mg-c-input__box-append",variant:"flat","is-icon":!0,label:this.itemsLabel,tabindex:"-1",disabled:this.disabled},s("mg-icon",{icon:"chevron-"+(this.popoverDisplay?"up":"down")}))),s("div",{slot:"content",class:"mg-c-input__popover-container"},"list"===m&&[s("ul",{key:"list",class:"mg-c-input__input-list",role:"listbox",id:r,"aria-label":this.itemsLabel,"aria-setsize":this.page.total},this.page.items.map((t=>{var i;return s("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:l(t.value),"aria-selected":this.isCurrentOption(t).toString(),"data-value":a(t.value),onClick:this.handleOptionClick},t.title,this.isCurrentOption(t)&&s("mg-icon",{icon:"check"}))}))),this.isLoading&&s("mg-loader",{key:"loader",message:this.messages.input.combobox.search,class:{"mg-u-visually-hidden":Boolean(this.page.next)}}),this.page.next&&s("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":r,ref:t=>{null!==t&&(this.loadMoreElement=t)}},s("mg-icon",{icon:"chevron-down"}),this.messages.input.showMore)],"notfound"===m&&s("p",{id:m,class:"mg-c-input__popover-info"},this.messages.input.combobox.notFound),"notavailable"===m&&s("p",{id:m,class:"mg-c-input__popover-info"},this.messages.input.combobox.notAvailable))))}get element(){return o(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}]}}};y.style=".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:calc(-1*var(--mg-b-size-2));outline-style:solid;outline-width:var(--mg-b-size-2)}.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-path:inset(50%) !important;white-space:nowrap !important}.mg-u-visually-hidden *{overflow:hidden !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:has(mg-icon){display:inline-flex;align-items:center;gap:var(--mg-b-size-4)}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}";export{y as mg_input_combobox}
|