@streamline-pulse/formkrafter-wc 0.38.1 → 0.38.2
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/components/fk-address-search.js +1 -1
- package/dist/components/fk-brick-actions.js +1 -1
- package/dist/components/fk-brick-list.js +1 -1
- package/dist/components/fk-brick-mold-item.js +1 -1
- package/dist/components/fk-brick-render.js +1 -1
- package/dist/components/fk-data-grid.js +1 -1
- package/dist/components/fk-document-reader.js +1 -1
- package/dist/components/fk-drop-area.js +1 -1
- package/dist/components/fk-empty-form.js +1 -1
- package/dist/components/fk-file-input.js +1 -1
- package/dist/components/fk-form-builder.js +1 -1
- package/dist/components/fk-form-render.js +1 -1
- package/dist/components/fk-form-review.js +1 -1
- package/dist/components/fk-geo-map.js +1 -1
- package/dist/components/fk-key-value.js +1 -1
- package/dist/components/fk-property-panel.js +1 -1
- package/dist/components/fk-rules-editor.js +1 -1
- package/dist/components/fk-select-input.js +1 -1
- package/dist/components/fk-signature-input.js +1 -1
- package/dist/components/fk-slot-picker.js +1 -1
- package/dist/components/fk-stepper.js +1 -1
- package/dist/components/fk-tabs.js +1 -1
- package/dist/components/fk-variable-picker.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/{p-Doa3hlEQ.js → p-B2WjEBTj.js} +1 -1
- package/dist/components/{p-DUuYfn0a.js → p-BB8xmjGJ.js} +1 -1
- package/dist/components/{p-irwwRRFn.js → p-BNiJAnkH.js} +1 -1
- package/dist/components/{p-C6A-ONnV.js → p-BYs5bgI7.js} +1 -1
- package/dist/components/{p-CUli9A8K.js → p-BctcvQo_.js} +1 -1
- package/dist/components/{p-CT6E7MdF.js → p-BfAyKjRN.js} +1 -1
- package/dist/components/{p-C3lh3RIu.js → p-BnJTALSz.js} +1 -1
- package/dist/components/{p-BgkVuGfo.js → p-BoKyVDo8.js} +1 -1
- package/dist/components/{p-B1GlI_Hr.js → p-C0mb7E87.js} +1 -1
- package/dist/components/{p-B22Z6Vu_.js → p-C9JdgAhz.js} +1 -1
- package/dist/components/{p-DrbcL_4W.js → p-CDxk9vDA.js} +1 -1
- package/dist/components/{p-CR5WtUWs.js → p-CLWABZ2R.js} +1 -1
- package/dist/components/{p-BjjJ9dQ-.js → p-CTLL7UBX.js} +1 -1
- package/dist/components/{p-BpwtxhSr.js → p-CpKgFpVg.js} +1 -1
- package/dist/components/{p-CBuIUYeI.js → p-D_ALB6XV.js} +1 -1
- package/dist/components/{p-Ca7Vz8hh.js → p-D_JbLnpV.js} +1 -1
- package/dist/components/{p-D1rC6paR.js → p-DrJ8gU-f.js} +1 -1
- package/dist/components/{p-Ddnb-hw4.js → p-OQ_nVt0C.js} +1 -1
- package/dist/components/{p-CRKfZc8F.js → p-O_ioA0Jo.js} +1 -1
- package/dist/components/{p-DfCT35Th.js → p-X4fDptw9.js} +1 -1
- package/dist/components/{p-DxH4cD0Z.js → p-an8X72Cc.js} +1 -1
- package/dist/components/{p-C_3Cb1pX.js → p-aoxwgnh3.js} +1 -1
- package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -1
- package/dist/formkrafter-wc/index.esm.js +1 -1
- package/dist/formkrafter-wc/{p-291bbeac.entry.js → p-317f9751.entry.js} +1 -1
- package/dist/formkrafter-wc/{p-XJo4Hw4r.js → p-CJDS5Un0.js} +1 -1
- package/dist/formkrafter-wc/{p-9be743e6.entry.js → p-e9b0facd.entry.js} +1 -1
- package/dist/formkrafter-wc/{p-af66a199.entry.js → p-fb215b73.entry.js} +1 -1
- package/dist/formkrafter-wc/{p-AEhPr5oS.js → p-u-PoTtC0.js} +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,p as e,H as s,c as i,h as o}from"./p-8ICOcloT.js";import{k as r,l as a,p as c,s as l,n,m as h,b as f}from"./p-irwwRRFn.js";import{f as d}from"./p-Csjvp5q8.js";let p=0;const u=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.selectValueChange=i(this,"selectValueChange"),this.disabled=!1,this.multiple=!1,this.invalid=!1,this.required=!1,this.open=!1,this.query="",this.activeIndex=0,this.instanceId="fk-select-"+ ++p,this.remoteOptions=[],this.catalogOptions=[],this.outsideClick=t=>{this.host.contains(t.target)||this.close()},this.onTriggerKeyDown=t=>{if(!this.disabled){if(this.open){const{options:e}=this.resolve();if(!this.isSearchable(e))return void this.onListKeyDown(t,e)}["Enter"," ","ArrowDown","ArrowUp"].includes(t.key)?(t.preventDefault(),this.openDropdown()):"Escape"===t.key&&this.open&&(t.preventDefault(),this.close())}}}componentWillLoad(){return Promise.all([this.resolveRemote(),this.resolveCatalog()])}disconnectedCallback(){this.unbindOutsideClick()}onConfigsChange(){this.resolveRemote(),this.resolveCatalog()}onDataMapChange(){this.resolveRemote(),this.resolveCatalog()}searchParam(){var t;return(null===(t=this.configs)||void 0===t?void 0:t.searchParam)||void 0}remoteUrl(){var t;const e=null===(t=this.configs)||void 0===t?void 0:t.optionsUrl;if(!e)return;let s=r(e,this.dataMap);const i=this.searchParam();return i&&(s=a(s,i,this.query.trim())),s}bindOutsideClick(){document.addEventListener("mousedown",this.outsideClick)}unbindOutsideClick(){document.removeEventListener("mousedown",this.outsideClick)}toggleOpen(){this.disabled||(this.open?this.close():this.openDropdown())}openDropdown(){if(this.disabled||this.open)return;this.open=!0,this.query="";const{options:t}=this.resolve(),e=this.selectedValues(),s=t.findIndex((t=>e.includes(t.value)));this.activeIndex=s>=0?s:0,this.bindOutsideClick()}close(t=!1){var e;this.open=!1,this.unbindOutsideClick(),t&&(null===(e=this.triggerEl)||void 0===e||e.focus())}moveActive(t,e){e&&(this.activeIndex=(this.activeIndex+t+e)%e,this.scrollActiveIntoView())}scrollActiveIntoView(){requestAnimationFrame((()=>{var t;const e=this.host.querySelector(`#${this.instanceId}-opt-${this.activeIndex}`);null===(t=null==e?void 0:e.scrollIntoView)||void 0===t||t.call(e,{block:"nearest"})}))}isSearchable(t){var e;const s=null===(e=this.configs)||void 0===e?void 0:e.searchable;return!0===s||"true"===s||!1!==s&&"false"!==s&&(!("remote"!==this.source()||!this.searchParam())||t.length>7)}isClearable(){var t;const e=null===(t=this.configs)||void 0===t?void 0:t.clearable;return!0===e||"true"===e||!1!==e&&"false"!==e&&!this.required}onListKeyDown(t,e){if(" "!==t.key)if(1!==t.key.length||t.ctrlKey||t.metaKey||t.altKey)this.onSearchKeyDown(t,e);else{const s=t.key.toLowerCase(),i=e.length;for(let t=1;t<=i;t++){const o=(this.activeIndex+t)%i;if(e[o].label.toLowerCase().startsWith(s)){this.activeIndex=o,this.scrollActiveIntoView();break}}}else{t.preventDefault();const s=e[this.activeIndex];s&&this.pick(s)}}onSearchKeyDown(t,e){var s;switch(t.key){case"ArrowDown":t.preventDefault(),this.moveActive(1,e.length);break;case"ArrowUp":t.preventDefault(),this.moveActive(-1,e.length);break;case"Home":t.preventDefault(),this.activeIndex=0,this.scrollActiveIntoView();break;case"End":t.preventDefault(),this.activeIndex=Math.max(e.length-1,0),this.scrollActiveIntoView();break;case"Enter":{t.preventDefault();const i=null!==(s=e[this.activeIndex])&&void 0!==s?s:e[0];i&&this.pick(i);break}case"Escape":t.preventDefault(),this.close(!0);break;case"Tab":this.close()}}source(){var t,e;return null!==(e=null===(t=this.configs)||void 0===t?void 0:t.optionsSource)&&void 0!==e?e:"static"}async resolveRemote(t=!1){var e,s;if("remote"!==this.source())return;const i=this.remoteUrl();if(!i)return void(this.remoteOptions=[]);const o=c(null===(e=this.configs)||void 0===e?void 0:e.optionsHeaders,this.dataMap),r=`${i}|${JSON.stringify(null!=o?o:{})}`;if(t||r!==this.lastRemoteSignature){this.lastRemoteSignature=r;try{this.remoteError=void 0;const t=null===(s=this.configs)||void 0===s?void 0:s.optionsPath;this.remoteOptions=await l.dataSourceService.fetchOptions(i,o||t?Object.assign(Object.assign({},o?{headers:o}:{}),t?{path:t}:{}):void 0)}catch(t){this.remoteOptions=[],this.remoteError=t instanceof Error?t.message:String(t)}}}async resolveCatalog(t=!1){var e;if("catalog"!==this.source())return;const s=(null===(e=this.configs)||void 0===e?void 0:e.optionsRef)||"",i=s?r(s,this.dataMap):"";if(i){if(t||i!==this.lastCatalogRef){this.lastCatalogRef=i;try{this.catalogError=void 0,this.catalogOptions=await l.optionSourceService.fetchOptions(i)}catch(t){this.catalogOptions=[],this.catalogError=t instanceof Error?t.message:String(t)}}}else this.catalogOptions=[]}onSearchInput(t){this.query=t,"remote"===this.source()&&this.searchParam()&&(this.searchTimer&&clearTimeout(this.searchTimer),this.searchTimer=setTimeout((()=>this.resolveRemote()),250))}resolve(){var t,e,s,i,o,r;const a=(null===(t=this.configs)||void 0===t?void 0:t.labelKey)||void 0,c=(null===(e=this.configs)||void 0===e?void 0:e.valueKey)||void 0;switch(this.source()){case"remote":return{options:n(this.remoteOptions,a,c),error:this.remoteError};case"catalog":return{options:n(this.catalogOptions,a,c),error:this.catalogError};case"dataMap":{const t=null===(s=this.configs)||void 0===s?void 0:s.optionsPath;return{options:n(t?null===(i=this.dataMap)||void 0===i?void 0:i[t]:[],a,c)}}case"js":{const t=null===(o=this.configs)||void 0===o?void 0:o.optionsCode;if(!t)return{options:[]};const e=h(t,this.dataMap);return e instanceof Error?{options:[],error:e.message}:{options:n(e,a,c)}}default:return{options:n(null===(r=this.configs)||void 0===r?void 0:r.options,a,c)}}}selectedValues(){return this.multiple?Array.isArray(this.value)?this.value:[]:"string"==typeof this.value&&""!==this.value?[this.value]:[]}labelOf(t,e){var s,i;return null!==(i=null===(s=e.find((e=>e.value===t)))||void 0===s?void 0:s.label)&&void 0!==i?i:t}pick(t){if(this.multiple){const e=this.selectedValues(),s=e.includes(t.value)?e.filter((e=>e!==t.value)):[...e,t.value];this.selectValueChange.emit(s.length?s:void 0)}else this.selectValueChange.emit(t.value),this.close(!0)}unpick(t){const e=this.selectedValues().filter((e=>e!==t));this.selectValueChange.emit(e.length?e:void 0)}filteredOptions(t){if("remote"===this.source()&&this.searchParam())return t;const e=this.query.trim().toLowerCase();return e?t.filter((t=>t.label.toLowerCase().includes(e))):t}render(){var t,e;const{options:s,error:i}=this.resolve(),r=this.selectedValues(),a=this.isSearchable(s),c=a?this.filteredOptions(s):s,l=this.open&&c.length?`${this.instanceId}-opt-${Math.min(this.activeIndex,c.length-1)}`:void 0;return o("div",{key:"88b50f8a452e8de6c1e9a1c021f7b9ff214a493e",class:{"fk-select":!0,"fk-select--disabled":this.disabled}},o("div",{key:"d9453b1153e933415fda1849333da545e078ce92",class:{"fk-select__trigger":!0,"fk-select__trigger--open":this.open},role:"combobox",tabIndex:this.disabled?void 0:0,"aria-label":this.accessibleLabel,"aria-expanded":this.open?"true":"false","aria-haspopup":"listbox","aria-controls":`${this.instanceId}-listbox`,"aria-disabled":this.disabled?"true":void 0,"aria-invalid":this.invalid?"true":void 0,"aria-required":this.required?"true":void 0,"aria-activedescendant":a?void 0:l,ref:t=>this.triggerEl=t,onKeyDown:this.onTriggerKeyDown,onClick:t=>{t.preventDefault(),this.toggleOpen()}},o("div",{key:"268cdac3437c442646ae3f56f7f41661285a598d",class:"fk-select__values"},0===r.length?o("span",{class:"fk-select__placeholder"},String(null!==(e=null===(t=this.configs)||void 0===t?void 0:t.placeholder)&&void 0!==e?e:"")):this.multiple?r.map((t=>o("span",{class:"fk-select__chip",key:t},this.labelOf(t,s),o("button",{type:"button",class:"fk-select__chip-remove","aria-label":`${f("select.clear")} — ${this.labelOf(t,s)}`,disabled:this.disabled,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.unpick(t)}},"✕")))):o("span",{class:"fk-select__value",title:this.labelOf(r[0],s)},this.labelOf(r[0],s))),!this.multiple&&r.length>0&&!this.disabled&&this.isClearable()?o("button",{type:"button",class:"fk-select__clear",title:f("select.clear"),"aria-label":f("select.clear"),onClick:t=>{t.preventDefault(),t.stopPropagation(),this.selectValueChange.emit(void 0)}},"✕"):null,o("span",{key:"7c1074b0fdcc30c61d1a082aec5cc50a0484f920",class:"fk-select__caret","aria-hidden":"true"},d("chevronDown"))),this.open?o("div",{class:"fk-select__dropdown"},a?o("input",{class:"fk-select__search",type:"text",placeholder:f("select.search"),value:this.query,role:"combobox","aria-label":this.accessibleLabel,"aria-expanded":"true","aria-autocomplete":"list","aria-controls":`${this.instanceId}-listbox`,"aria-activedescendant":l,ref:t=>setTimeout((()=>null==t?void 0:t.focus()),0),onInput:t=>{this.activeIndex=0,this.onSearchInput(t.target.value)},onKeyDown:t=>this.onSearchKeyDown(t,c)}):null,o("div",{class:"fk-select__options",role:"listbox",id:`${this.instanceId}-listbox`,"aria-multiselectable":this.multiple?"true":void 0},c.map(((t,e)=>{const s=r.includes(t.value),i=e===Math.min(this.activeIndex,c.length-1);return o("div",{key:t.value,id:`${this.instanceId}-opt-${e}`,role:"option","aria-selected":s?"true":"false",class:{"fk-select__option":!0,"fk-select__option--selected":s,"fk-select__option--active":i},onMouseEnter:()=>this.activeIndex=e,onClick:e=>{e.preventDefault(),this.pick(t)}},o("span",{class:"fk-select__option-label"},t.label),s?o("span",{class:"fk-select__check"},"✓"):null)})),0===c.length?o("p",{class:"fk-select__empty"},f("select.empty")):null)):null,i?o("span",{class:"fk-field__error"},i):null)}get host(){return this}static get watchers(){return{configs:[{onConfigsChange:0}],dataMap:[{onDataMapChange:0}]}}static get style(){return".sc-fk-select-input-h{display:block}.fk-select.sc-fk-select-input{position:relative;font-family:var(--fk-font)}.fk-select__trigger.sc-fk-select-input{display:flex;align-items:center;gap:calc(var(--fk-spacing) / 2);box-sizing:border-box;min-height:var(--fk-control-height, 2.375rem);padding:calc(var(--fk-spacing) / 2) var(--fk-spacing) calc(var(--fk-spacing) / 2) calc(var(--fk-spacing) * 1.5);font-size:0.9rem;line-height:1.25;border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface);color:var(--fk-color-text);cursor:pointer}.fk-select--disabled.sc-fk-select-input .fk-select__trigger.sc-fk-select-input{cursor:not-allowed;opacity:0.6}.fk-select__trigger--open.sc-fk-select-input{border-color:var(--fk-color-primary)}.fk-select__values.sc-fk-select-input{display:flex;flex:1 1 0;width:0;flex-wrap:wrap;align-items:center;gap:4px;min-width:0}.fk-select__value.sc-fk-select-input{min-width:0;max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.fk-select__placeholder.sc-fk-select-input{color:var(--fk-color-muted)}.fk-select__chip.sc-fk-select-input{display:inline-flex;align-items:center;gap:4px;padding:1px 8px;border-radius:999px;background:color-mix(in srgb, var(--fk-color-primary) 14%, transparent);color:var(--fk-color-primary);font-size:0.8rem;font-weight:600}.fk-select__chip-remove.sc-fk-select-input,.fk-select__clear.sc-fk-select-input{border:none;background:transparent;color:inherit;font-size:0.7rem;cursor:pointer;padding:0 2px}.fk-select__clear.sc-fk-select-input{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:1rem;height:1.5rem;padding:0;border-radius:calc(var(--fk-radius) / 2);color:var(--fk-color-muted);font-size:0.75rem}.fk-select__clear.sc-fk-select-input:hover{color:var(--fk-color-danger)}.fk-select__caret.sc-fk-select-input{display:inline-flex;flex-shrink:0;width:1rem;height:1rem;color:var(--fk-color-muted);transition:transform 120ms ease}.fk-select__caret.sc-fk-select-input svg.sc-fk-select-input{width:100%;height:100%}.fk-select__trigger--open.sc-fk-select-input .fk-select__caret.sc-fk-select-input{transform:rotate(180deg)}.fk-select__dropdown.sc-fk-select-input{position:absolute;top:calc(100% + 4px);inset-inline:0;z-index:20;display:flex;flex-direction:column;border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface);box-shadow:0 8px 24px var(--fk-color-shadow);overflow:hidden}.fk-select__search.sc-fk-select-input{font:inherit;font-size:0.85rem;padding:var(--fk-spacing) calc(var(--fk-spacing) * 1.5);border:none;border-bottom:1px solid var(--fk-color-border);background:transparent;color:var(--fk-color-text)}.fk-select__search.sc-fk-select-input:focus{outline:none}.fk-select__options.sc-fk-select-input{max-height:220px;overflow-y:auto}.fk-select__option.sc-fk-select-input{display:flex;align-items:center;justify-content:space-between;gap:var(--fk-spacing);padding:var(--fk-spacing) calc(var(--fk-spacing) * 1.5);font-size:0.9rem;color:var(--fk-color-text);cursor:pointer}.fk-select__option.sc-fk-select-input:hover{background:color-mix(in srgb, var(--fk-color-primary) 8%, transparent)}.fk-select__option--selected.sc-fk-select-input{color:var(--fk-color-primary);font-weight:600}.fk-select__check.sc-fk-select-input{font-size:0.8rem}.fk-select__empty.sc-fk-select-input{margin:0;padding:var(--fk-spacing);font-size:0.85rem;color:var(--fk-color-muted)}.fk-select__trigger.sc-fk-select-input:focus-visible{outline:2px solid color-mix(in srgb, var(--fk-color-primary) 55%, transparent);outline-offset:1px}.fk-select__option--active.sc-fk-select-input{background:color-mix(in srgb, var(--fk-color-primary) 12%, transparent)}"}},[2,"fk-select-input",{configs:[16],value:[1],disabled:[4],multiple:[4],invalid:[4],required:[4],dataMap:[16],accessibleLabel:[1,"accessible-label"],open:[32],query:[32],activeIndex:[32],remoteOptions:[32],remoteError:[32],catalogOptions:[32],catalogError:[32]},void 0,{configs:[{onConfigsChange:0}],dataMap:[{onDataMapChange:0}]}]);function k(){"undefined"!=typeof customElements&&["fk-select-input"].forEach((e=>{"fk-select-input"===e&&(customElements.get(t(e))||customElements.define(t(e),u))}))}k();export{u as F,k as d}
|
|
1
|
+
import{t,p as e,H as s,c as i,h as o}from"./p-8ICOcloT.js";import{k as r,l as a,p as c,s as l,n,m as h,b as f}from"./p-BNiJAnkH.js";import{f as d}from"./p-Csjvp5q8.js";let p=0;const u=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.selectValueChange=i(this,"selectValueChange"),this.disabled=!1,this.multiple=!1,this.invalid=!1,this.required=!1,this.open=!1,this.query="",this.activeIndex=0,this.instanceId="fk-select-"+ ++p,this.remoteOptions=[],this.catalogOptions=[],this.outsideClick=t=>{this.host.contains(t.target)||this.close()},this.onTriggerKeyDown=t=>{if(!this.disabled){if(this.open){const{options:e}=this.resolve();if(!this.isSearchable(e))return void this.onListKeyDown(t,e)}["Enter"," ","ArrowDown","ArrowUp"].includes(t.key)?(t.preventDefault(),this.openDropdown()):"Escape"===t.key&&this.open&&(t.preventDefault(),this.close())}}}componentWillLoad(){return Promise.all([this.resolveRemote(),this.resolveCatalog()])}disconnectedCallback(){this.unbindOutsideClick()}onConfigsChange(){this.resolveRemote(),this.resolveCatalog()}onDataMapChange(){this.resolveRemote(),this.resolveCatalog()}searchParam(){var t;return(null===(t=this.configs)||void 0===t?void 0:t.searchParam)||void 0}remoteUrl(){var t;const e=null===(t=this.configs)||void 0===t?void 0:t.optionsUrl;if(!e)return;let s=r(e,this.dataMap);const i=this.searchParam();return i&&(s=a(s,i,this.query.trim())),s}bindOutsideClick(){document.addEventListener("mousedown",this.outsideClick)}unbindOutsideClick(){document.removeEventListener("mousedown",this.outsideClick)}toggleOpen(){this.disabled||(this.open?this.close():this.openDropdown())}openDropdown(){if(this.disabled||this.open)return;this.open=!0,this.query="";const{options:t}=this.resolve(),e=this.selectedValues(),s=t.findIndex((t=>e.includes(t.value)));this.activeIndex=s>=0?s:0,this.bindOutsideClick()}close(t=!1){var e;this.open=!1,this.unbindOutsideClick(),t&&(null===(e=this.triggerEl)||void 0===e||e.focus())}moveActive(t,e){e&&(this.activeIndex=(this.activeIndex+t+e)%e,this.scrollActiveIntoView())}scrollActiveIntoView(){requestAnimationFrame((()=>{var t;const e=this.host.querySelector(`#${this.instanceId}-opt-${this.activeIndex}`);null===(t=null==e?void 0:e.scrollIntoView)||void 0===t||t.call(e,{block:"nearest"})}))}isSearchable(t){var e;const s=null===(e=this.configs)||void 0===e?void 0:e.searchable;return!0===s||"true"===s||!1!==s&&"false"!==s&&(!("remote"!==this.source()||!this.searchParam())||t.length>7)}isClearable(){var t;const e=null===(t=this.configs)||void 0===t?void 0:t.clearable;return!0===e||"true"===e||!1!==e&&"false"!==e&&!this.required}onListKeyDown(t,e){if(" "!==t.key)if(1!==t.key.length||t.ctrlKey||t.metaKey||t.altKey)this.onSearchKeyDown(t,e);else{const s=t.key.toLowerCase(),i=e.length;for(let t=1;t<=i;t++){const o=(this.activeIndex+t)%i;if(e[o].label.toLowerCase().startsWith(s)){this.activeIndex=o,this.scrollActiveIntoView();break}}}else{t.preventDefault();const s=e[this.activeIndex];s&&this.pick(s)}}onSearchKeyDown(t,e){var s;switch(t.key){case"ArrowDown":t.preventDefault(),this.moveActive(1,e.length);break;case"ArrowUp":t.preventDefault(),this.moveActive(-1,e.length);break;case"Home":t.preventDefault(),this.activeIndex=0,this.scrollActiveIntoView();break;case"End":t.preventDefault(),this.activeIndex=Math.max(e.length-1,0),this.scrollActiveIntoView();break;case"Enter":{t.preventDefault();const i=null!==(s=e[this.activeIndex])&&void 0!==s?s:e[0];i&&this.pick(i);break}case"Escape":t.preventDefault(),this.close(!0);break;case"Tab":this.close()}}source(){var t,e;return null!==(e=null===(t=this.configs)||void 0===t?void 0:t.optionsSource)&&void 0!==e?e:"static"}async resolveRemote(t=!1){var e,s;if("remote"!==this.source())return;const i=this.remoteUrl();if(!i)return void(this.remoteOptions=[]);const o=c(null===(e=this.configs)||void 0===e?void 0:e.optionsHeaders,this.dataMap),r=`${i}|${JSON.stringify(null!=o?o:{})}`;if(t||r!==this.lastRemoteSignature){this.lastRemoteSignature=r;try{this.remoteError=void 0;const t=null===(s=this.configs)||void 0===s?void 0:s.optionsPath;this.remoteOptions=await l.dataSourceService.fetchOptions(i,o||t?Object.assign(Object.assign({},o?{headers:o}:{}),t?{path:t}:{}):void 0)}catch(t){this.remoteOptions=[],this.remoteError=t instanceof Error?t.message:String(t)}}}async resolveCatalog(t=!1){var e;if("catalog"!==this.source())return;const s=(null===(e=this.configs)||void 0===e?void 0:e.optionsRef)||"",i=s?r(s,this.dataMap):"";if(i){if(t||i!==this.lastCatalogRef){this.lastCatalogRef=i;try{this.catalogError=void 0,this.catalogOptions=await l.optionSourceService.fetchOptions(i)}catch(t){this.catalogOptions=[],this.catalogError=t instanceof Error?t.message:String(t)}}}else this.catalogOptions=[]}onSearchInput(t){this.query=t,"remote"===this.source()&&this.searchParam()&&(this.searchTimer&&clearTimeout(this.searchTimer),this.searchTimer=setTimeout((()=>this.resolveRemote()),250))}resolve(){var t,e,s,i,o,r;const a=(null===(t=this.configs)||void 0===t?void 0:t.labelKey)||void 0,c=(null===(e=this.configs)||void 0===e?void 0:e.valueKey)||void 0;switch(this.source()){case"remote":return{options:n(this.remoteOptions,a,c),error:this.remoteError};case"catalog":return{options:n(this.catalogOptions,a,c),error:this.catalogError};case"dataMap":{const t=null===(s=this.configs)||void 0===s?void 0:s.optionsPath;return{options:n(t?null===(i=this.dataMap)||void 0===i?void 0:i[t]:[],a,c)}}case"js":{const t=null===(o=this.configs)||void 0===o?void 0:o.optionsCode;if(!t)return{options:[]};const e=h(t,this.dataMap);return e instanceof Error?{options:[],error:e.message}:{options:n(e,a,c)}}default:return{options:n(null===(r=this.configs)||void 0===r?void 0:r.options,a,c)}}}selectedValues(){return this.multiple?Array.isArray(this.value)?this.value:[]:"string"==typeof this.value&&""!==this.value?[this.value]:[]}labelOf(t,e){var s,i;return null!==(i=null===(s=e.find((e=>e.value===t)))||void 0===s?void 0:s.label)&&void 0!==i?i:t}pick(t){if(this.multiple){const e=this.selectedValues(),s=e.includes(t.value)?e.filter((e=>e!==t.value)):[...e,t.value];this.selectValueChange.emit(s.length?s:void 0)}else this.selectValueChange.emit(t.value),this.close(!0)}unpick(t){const e=this.selectedValues().filter((e=>e!==t));this.selectValueChange.emit(e.length?e:void 0)}filteredOptions(t){if("remote"===this.source()&&this.searchParam())return t;const e=this.query.trim().toLowerCase();return e?t.filter((t=>t.label.toLowerCase().includes(e))):t}render(){var t,e;const{options:s,error:i}=this.resolve(),r=this.selectedValues(),a=this.isSearchable(s),c=a?this.filteredOptions(s):s,l=this.open&&c.length?`${this.instanceId}-opt-${Math.min(this.activeIndex,c.length-1)}`:void 0;return o("div",{key:"88b50f8a452e8de6c1e9a1c021f7b9ff214a493e",class:{"fk-select":!0,"fk-select--disabled":this.disabled}},o("div",{key:"d9453b1153e933415fda1849333da545e078ce92",class:{"fk-select__trigger":!0,"fk-select__trigger--open":this.open},role:"combobox",tabIndex:this.disabled?void 0:0,"aria-label":this.accessibleLabel,"aria-expanded":this.open?"true":"false","aria-haspopup":"listbox","aria-controls":`${this.instanceId}-listbox`,"aria-disabled":this.disabled?"true":void 0,"aria-invalid":this.invalid?"true":void 0,"aria-required":this.required?"true":void 0,"aria-activedescendant":a?void 0:l,ref:t=>this.triggerEl=t,onKeyDown:this.onTriggerKeyDown,onClick:t=>{t.preventDefault(),this.toggleOpen()}},o("div",{key:"268cdac3437c442646ae3f56f7f41661285a598d",class:"fk-select__values"},0===r.length?o("span",{class:"fk-select__placeholder"},String(null!==(e=null===(t=this.configs)||void 0===t?void 0:t.placeholder)&&void 0!==e?e:"")):this.multiple?r.map((t=>o("span",{class:"fk-select__chip",key:t},this.labelOf(t,s),o("button",{type:"button",class:"fk-select__chip-remove","aria-label":`${f("select.clear")} — ${this.labelOf(t,s)}`,disabled:this.disabled,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.unpick(t)}},"✕")))):o("span",{class:"fk-select__value",title:this.labelOf(r[0],s)},this.labelOf(r[0],s))),!this.multiple&&r.length>0&&!this.disabled&&this.isClearable()?o("button",{type:"button",class:"fk-select__clear",title:f("select.clear"),"aria-label":f("select.clear"),onClick:t=>{t.preventDefault(),t.stopPropagation(),this.selectValueChange.emit(void 0)}},"✕"):null,o("span",{key:"7c1074b0fdcc30c61d1a082aec5cc50a0484f920",class:"fk-select__caret","aria-hidden":"true"},d("chevronDown"))),this.open?o("div",{class:"fk-select__dropdown"},a?o("input",{class:"fk-select__search",type:"text",placeholder:f("select.search"),value:this.query,role:"combobox","aria-label":this.accessibleLabel,"aria-expanded":"true","aria-autocomplete":"list","aria-controls":`${this.instanceId}-listbox`,"aria-activedescendant":l,ref:t=>setTimeout((()=>null==t?void 0:t.focus()),0),onInput:t=>{this.activeIndex=0,this.onSearchInput(t.target.value)},onKeyDown:t=>this.onSearchKeyDown(t,c)}):null,o("div",{class:"fk-select__options",role:"listbox",id:`${this.instanceId}-listbox`,"aria-multiselectable":this.multiple?"true":void 0},c.map(((t,e)=>{const s=r.includes(t.value),i=e===Math.min(this.activeIndex,c.length-1);return o("div",{key:t.value,id:`${this.instanceId}-opt-${e}`,role:"option","aria-selected":s?"true":"false",class:{"fk-select__option":!0,"fk-select__option--selected":s,"fk-select__option--active":i},onMouseEnter:()=>this.activeIndex=e,onClick:e=>{e.preventDefault(),this.pick(t)}},o("span",{class:"fk-select__option-label"},t.label),s?o("span",{class:"fk-select__check"},"✓"):null)})),0===c.length?o("p",{class:"fk-select__empty"},f("select.empty")):null)):null,i?o("span",{class:"fk-field__error"},i):null)}get host(){return this}static get watchers(){return{configs:[{onConfigsChange:0}],dataMap:[{onDataMapChange:0}]}}static get style(){return".sc-fk-select-input-h{display:block}.fk-select.sc-fk-select-input{position:relative;font-family:var(--fk-font)}.fk-select__trigger.sc-fk-select-input{display:flex;align-items:center;gap:calc(var(--fk-spacing) / 2);box-sizing:border-box;min-height:var(--fk-control-height, 2.375rem);padding:calc(var(--fk-spacing) / 2) var(--fk-spacing) calc(var(--fk-spacing) / 2) calc(var(--fk-spacing) * 1.5);font-size:0.9rem;line-height:1.25;border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface);color:var(--fk-color-text);cursor:pointer}.fk-select--disabled.sc-fk-select-input .fk-select__trigger.sc-fk-select-input{cursor:not-allowed;opacity:0.6}.fk-select__trigger--open.sc-fk-select-input{border-color:var(--fk-color-primary)}.fk-select__values.sc-fk-select-input{display:flex;flex:1 1 0;width:0;flex-wrap:wrap;align-items:center;gap:4px;min-width:0}.fk-select__value.sc-fk-select-input{min-width:0;max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.fk-select__placeholder.sc-fk-select-input{color:var(--fk-color-muted)}.fk-select__chip.sc-fk-select-input{display:inline-flex;align-items:center;gap:4px;padding:1px 8px;border-radius:999px;background:color-mix(in srgb, var(--fk-color-primary) 14%, transparent);color:var(--fk-color-primary);font-size:0.8rem;font-weight:600}.fk-select__chip-remove.sc-fk-select-input,.fk-select__clear.sc-fk-select-input{border:none;background:transparent;color:inherit;font-size:0.7rem;cursor:pointer;padding:0 2px}.fk-select__clear.sc-fk-select-input{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:1rem;height:1.5rem;padding:0;border-radius:calc(var(--fk-radius) / 2);color:var(--fk-color-muted);font-size:0.75rem}.fk-select__clear.sc-fk-select-input:hover{color:var(--fk-color-danger)}.fk-select__caret.sc-fk-select-input{display:inline-flex;flex-shrink:0;width:1rem;height:1rem;color:var(--fk-color-muted);transition:transform 120ms ease}.fk-select__caret.sc-fk-select-input svg.sc-fk-select-input{width:100%;height:100%}.fk-select__trigger--open.sc-fk-select-input .fk-select__caret.sc-fk-select-input{transform:rotate(180deg)}.fk-select__dropdown.sc-fk-select-input{position:absolute;top:calc(100% + 4px);inset-inline:0;z-index:20;display:flex;flex-direction:column;border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface);box-shadow:0 8px 24px var(--fk-color-shadow);overflow:hidden}.fk-select__search.sc-fk-select-input{font:inherit;font-size:0.85rem;padding:var(--fk-spacing) calc(var(--fk-spacing) * 1.5);border:none;border-bottom:1px solid var(--fk-color-border);background:transparent;color:var(--fk-color-text)}.fk-select__search.sc-fk-select-input:focus{outline:none}.fk-select__options.sc-fk-select-input{max-height:220px;overflow-y:auto}.fk-select__option.sc-fk-select-input{display:flex;align-items:center;justify-content:space-between;gap:var(--fk-spacing);padding:var(--fk-spacing) calc(var(--fk-spacing) * 1.5);font-size:0.9rem;color:var(--fk-color-text);cursor:pointer}.fk-select__option.sc-fk-select-input:hover{background:color-mix(in srgb, var(--fk-color-primary) 8%, transparent)}.fk-select__option--selected.sc-fk-select-input{color:var(--fk-color-primary);font-weight:600}.fk-select__check.sc-fk-select-input{font-size:0.8rem}.fk-select__empty.sc-fk-select-input{margin:0;padding:var(--fk-spacing);font-size:0.85rem;color:var(--fk-color-muted)}.fk-select__trigger.sc-fk-select-input:focus-visible{outline:2px solid color-mix(in srgb, var(--fk-color-primary) 55%, transparent);outline-offset:1px}.fk-select__option--active.sc-fk-select-input{background:color-mix(in srgb, var(--fk-color-primary) 12%, transparent)}"}},[2,"fk-select-input",{configs:[16],value:[1],disabled:[4],multiple:[4],invalid:[4],required:[4],dataMap:[16],accessibleLabel:[1,"accessible-label"],open:[32],query:[32],activeIndex:[32],remoteOptions:[32],remoteError:[32],catalogOptions:[32],catalogError:[32]},void 0,{configs:[{onConfigsChange:0}],dataMap:[{onDataMapChange:0}]}]);function k(){"undefined"!=typeof customElements&&["fk-select-input"].forEach((e=>{"fk-select-input"===e&&(customElements.get(t(e))||customElements.define(t(e),u))}))}k();export{u as F,k as d}
|