@formkit/pro 0.126.9 → 0.126.10

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.
Files changed (3) hide show
  1. package/index.cjs +1 -1
  2. package/index.mjs +1 -1
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -16,7 +16,7 @@
16
16
  /* #__PURE__ */o.defaultIcon("remove","trash"),
17
17
  /* #__PURE__ */o.defaultIcon("add","add"),
18
18
  /* #__PURE__ */o.defaultIcon("moveUp","arrowUp"),
19
- /* #__PURE__ */o.defaultIcon("moveDown","arrowDown")]},Xo=new WeakMap;function Jo(e,t){const o={onItems:[],offItems:[]},n=t||Number(e.value||0);for(let t=0;t<e.props.max;t++)if(t<n&&t+1>=n){const r=e.props.rightToLeft?100-100*(n-t):100*(n-t);o.onItems.push(r+"%"),o.offItems.push(100-r+"%")}else t<n?(o.offItems.push("0%"),o.onItems.push("100%")):t>=n&&(o.offItems.push("100%"),o.onItems.push("0%"));e.props.itemsToPercentages=o}function Qo(e,t){var o;null===(o=e.context)||void 0===o||o.handlers.blur(t)}function en(e,t){const{x:o,y:n}=dn(t);let r=document.elementFromPoint(o,n);const s=Array.from(document.querySelectorAll(`#${e.props.id}_items_wrapper > .formkit-ratingItem`));let a=!0;for(;r&&a;){if(s.includes(r)){a=!1;break}r=r.parentNode}if(!a){const t=s.indexOf(r);if(1===e.props.step)return void e.input(t+1,!1)}}function tn(e,t,o){e.props.disabled||(o.preventDefault(),e.props.hoverHighlight=!0,e.props.touchStarted=!0,1!==e.props.step?cn(e,t,o):e.input(t+1,!1))}function on(e,t){if(!e.props.dragStarted)return;t.preventDefault(),e.props.hoverHighlight=!1,e.props.dragStarted=!1,Jo(e);const o=Xo.get(e);o&&(o.abort(),Xo.delete(e))}function nn(e,t,o){if(e.props.hoverHighlight||e.props.disabled)return;o.preventDefault(),e.props.hoverHighlight=!0,e.props.dragStarted=!0;const n=new AbortController;document.addEventListener("mouseup",(t=>on(e,t)),{signal:n.signal}),Xo.set(e,n),1===e.props.step?e.input(t+1,!1):cn(e,t,o)}function rn(e,t){var o,n;if(document.activeElement===t.currentTarget)if("ArrowRight"===t.key||"ArrowDown"===t.key){e.props.arrow=1;const t=e.value?un(e.value+1*e.props.step,e.props.step):e.props.min+1*e.props.step,n=null===(o=e.props.__root)||void 0===o?void 0:o.querySelector(e.value?`#${e.props.id}_inner input[value="${t}"]`:"#"+(e.props.id+"_0_0"));e.props.preventFocus=!0,n&&n instanceof HTMLInputElement&&n.focus(),e.props.preventFocus=!1,e.input(Number(t))}else if("ArrowLeft"===t.key||"ArrowUp"===t.key){e.props.arrow=-1;const t=e.value?un(e.value-1*e.props.step,e.props.step):e.props.max,o=null===(n=e.props.__root)||void 0===n?void 0:n.querySelector(`#${e.props.id}_inner input[value="${t}"]`);e.props.preventFocus=!0,o&&o instanceof HTMLInputElement&&o.focus(),e.props.preventFocus=!0,e.input(Number(t)),e.props.preventFocus=!1}}function sn(e,t){if(!e.props.preventFocus)if(e.props.preventFocus=!0,setTimeout((()=>{e.props.preventFocus=!1}),50),t.relatedTarget instanceof HTMLElement&&t.relatedTarget.id===e.props.id+"_items_wrapper")e.props.arrow>0?setTimeout((()=>{var t,o;null===(o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(e.props.id+"_0_0"))||void 0===o||o.focus()})):e.props.arrow<0&&setTimeout((()=>{var t,o;null===(o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(e.props.id+`_${e.props.max-1}_${e.props.stepsPerValue-1}`))||void 0===o||o.focus()}));else if(t.target instanceof HTMLInputElement){if(Number(t.target.value)===e.props.step&&e.value===e.props.max||Number(t.target.value)===e.props.max&&e.value===e.props.step){const t=document.getElementById(e.props.id+"_items_wrapper");return null==t||t.focus(),void e.input(0)}e.input(Number(t.target.value))}}function an(e,t,o){e.props.hoverHighlight&&(e.props.disabled||(1===e.props.step?(Jo(e,t+1),e.props.dragStarted&&e.input(t+1,!1)):cn(e,t,o,!!e.props.dragStarted)))}function ln(e){Jo(e)}function pn(e,t,o){if(!e.props.disabled&&"touchstart"!==o.type&&(o.preventDefault(),(0!==o.clientX||0!==o.clientY)&&o.currentTarget instanceof HTMLElement))return 1===e.props.step?e.props.deselect&&Number(e.value)===t+1?void e.input(0):void e.input(t+1):void cn(e,t,o)}function dn(e){return e instanceof MouseEvent?{x:e.clientX,y:e.clientY}:{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY}}function cn(e,t,o,n=!0){if(!(o.currentTarget instanceof HTMLElement))return;const{x:r,y:s}=dn(o),a=o.currentTarget.getBoundingClientRect();let l=un((r-a.x)/a.width+t,e.props.step);l=l>e.props.min?l:e.props.min,l=l<e.props.max?l:e.props.max,!e.props.deselect||l!==Number(e.value)||e.props.dragStarted?n?e.input(l,!1):Jo(e,l):e.input(0)}function un(e,t){t||(t=1);const o=1/t;return Math.ceil(e*o)/o}const fn=/* #__PURE__ */q("rt"),{outer:vn,wrapper:hn,inner:mn,label:gn,prefix:$n,suffix:bn,help:yn,messages:xn,message:wn,icon:_n}=/* #__PURE__ */z(fn),kn=fn("itemsWrapper",(()=>({$el:"span",attrs:{style:{"flex-direction":'$rightToLeft && "row-reverse" || undefined'},tabindex:"$value !== undefined && $value !== 0 && '-1' || '0'",id:"$id + _items_wrapper",onKeydown:"$handlers.handleWrapperKeydown","data-disabled":"$disabled",onBlur:"$handlers.handleWrapperBlur",onMouseleave:"$hoverHighlight && $handlers.handleMouseleave"}}))),Sn=fn("ratingItem",(()=>({for:["item","index","$max"],$el:"span",attrs:{id:'$id + "_item_" + $index',onClick:"$handlers.handleItemClick($item)",draggable:"$hoverHighlight !== true && && $disabled !== true && true",onMousemove:"$handlers.handleMousemove($item)",onDragstart:"$handlers.handleDragstart($item)",onDragend:"$handlers.handleDragend",onTouchstart:"$handlers.handleTouchstart($item)",onTouchmove:"$handlers.handleTouchmove"}}))),Ln=fn("template",(()=>({for:["increment","stepIndex","$stepsPerValue"],$el:null}))),An=fn("itemLabel",(()=>({$el:"label",attrs:{id:'$id + "_label_" + $index + "_" + $stepIndex',for:'$id + "_" + $index + "_" + $stepIndex',"data-checked":'$value === $fns.getValue($item, $increment) && "true" || "false"',style:{width:'$fns.showLabel($fns.getValue($item, $increment), $stepIndex, $item) && "100%" || "0%"'}}}))),In=fn("itemLabelInner",(()=>({$el:"span",children:"$fns.getValue($item, $increment)"}))),Dn=fn("input",(()=>({$el:"input",attrs:{type:"radio",value:"$fns.getValue($item, $increment)",id:'$id + "_" + $index + "_" + $stepIndex',onFocus:"$handlers.handleFocus",tabindex:'$value === $fns.getValue($item, $increment) && "0" || "-1"',disabled:"$disabled",name:"$id","data-value":"$fns.getValue($item, $increment)",checked:"$value === $fns.getValue($item, $increment) && true",onKeydown:"$handlers.handleKeydown($fns.getValue($item, $increment))"}}))),Cn=fn("onItemRow",(()=>({$el:"span",attrs:{style:{width:"$fns.getPercentage($itemsToPercentages, $item)",display:"flex",position:"relative",overflow:"hidden",top:"0",left:"0",bottom:"0"}}}))),Tn=fn("offItemRow",(()=>({$el:"span",attrs:{style:{width:"$fns.getPercentage($itemsToPercentages, $item, false)",display:"flex","flex-direction":"row-reverse",position:"absolute",zIndex:"$offItemStyles && 100",overflow:"hidden",top:"0",right:"0"}}}))),En=fn("onItemWrapper",(()=>({$el:"div",attrs:{style:{color:"$onColor"}}}))),On=fn("offItemWrapper",(()=>({$el:"div",attrs:{style:{color:"$offColor"}}}))),Mn=()=>U("$slots.onItem",(()=>()=>"$slots.onItem"),U("$slots.default",(()=>()=>"$slots.default"),_n("rating"))),Vn=()=>U("$slots.offItem",(()=>()=>"$slots.offItem"),U("$slots.default",(()=>()=>"$slots.default"),_n("rating"))),Fn={schema:/* #__PURE__ */vn(/* #__PURE__ */hn(/* #__PURE__ */gn("$label"),/* #__PURE__ */mn(/* #__PURE__ */_n("prefix"),/* #__PURE__ */$n(),/* #__PURE__ */kn(/* #__PURE__ */Sn(/* #__PURE__ */Ln(/* #__PURE__ */An(/* #__PURE__ */Cn(/* #__PURE__ */En(/* #__PURE__ */Mn())),/* #__PURE__ */Tn(/* #__PURE__ */On(/* #__PURE__ */Vn())),/* #__PURE__ */In()),/* #__PURE__ */Dn()))),/* #__PURE__ */bn(),/* #__PURE__ */_n("suffix"))),/* #__PURE__ */yn("$help"),/* #__PURE__ */xn(/* #__PURE__ */wn("$message.value"))),type:"input",props:[],features:[function(t){function o(e){setTimeout((()=>{const t=Array.from(document.querySelectorAll(`#${e.props.id}_items_wrapper > .formkit-ratingItem`));for(let e=0;e<t.length;e++){const o=t[e].querySelectorAll(".formkit-onItemWrapper"),n=t[e].querySelectorAll(".formkit-offItemWrapper");for(let n=0;n<o.length;n++)o[n].style.flex=`0 0 ${t[e].getBoundingClientRect().width}px`;for(let o=0;o<n.length;o++)n[o].style.flex=`0 0 ${t[e].getBoundingClientRect().width}px`}}))}t.addProps(["max","step","stepsPerValue","itemsToPercentages","rightToLeft","onItemStyles","offItemStyles","hoverHighlight","deselect","disabled","wrapperWidth","onColor","offColor"]),!1!==t.props.hoverHighlight&&"false"!==t.props.hoverHighlight&&(t.props.hoverHighlight=!0),t.props.deselect=e.undefine(t.props.deselect),t.props.max=Number(t.props.max)||5,t.props.min=Number(t.props.min)||0,t.props.step=Number(t.props.step)||1,t.props.numberOfSteps=t.props.max/t.props.step,t.props.lastIndex=1/t.props.step-1,t.props.itemsToPercentages={},"disabled"in t.props&&(t.props.disabled=e.undefine(t.props.disabled)),t.props.rightToLeft?(t.props.onItemStyles=void 0,t.props.offItemStyles={position:"absolute",top:"0",left:"0",overflow:"hidden",height:"100%",zIndex:100}):t.props.onItemStyles={position:"absolute",top:"0",left:"0",overflow:"hidden",height:"100%"},t.props.stepsPerValue=1/t.props.step,t.hook.input(((e,o)=>{if(null===e||""===e||isNaN(e))return o(e);const n=Number(e),r=Number(t.props.min),s=Number(t.props.max);return n>s?o(s):t.props.min&&n<=r?o(r):o(n)})),t.on("commit",(({payload:e})=>{const o=Number(e||0);Jo(t,o)})),t.on("created",(()=>{t.context&&(e.whenAvailable(`${t.props.id}_items_wrapper`,(()=>{o(t),function(e){var t;const n=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}_items_wrapper`);if(!n)return;new ResizeObserver((()=>{o(e)})).observe(n)}(t),setTimeout((()=>o(t)),100)}),t.props.__root),t.context.fns.getPercentage=(e,t,o=!0)=>(o?e.onItems:e.offItems)[t],t.context.fns.getValue=(e,o)=>e+Number((o*t.props.step+t.props.step).toFixed(1)),t.context.fns.showLabel=(e,o)=>{const n=Number(t.value||0);return 0===n&&0===o||n&&e===n||e>n&&0===o||n>e&&o===t.props.lastIndex},t.context.handlers.handleFocus=e=>sn.call(null,t,e),t.context.handlers.handleWrapperKeydown=e=>rn.call(null,t,e),t.context.handlers.handleWrapperBlur=e=>Qo.call(null,t,e),t.context.handlers.handleItemClick=e=>o=>pn.call(null,t,e,o),t.context.handlers.handleMousemove=e=>o=>an.call(null,t,e,o),t.context.handlers.handleMouseleave=()=>ln.call(null,t),t.context.handlers.handleDragstart=e=>o=>nn.call(null,t,e,o),t.context.handlers.handleMouseup=e=>on.call(null,t,e),t.context.handlers.handleTouchstart=e=>o=>tn.call(null,t,e,o),t.context.handlers.handleTouchmove=e=>en.call(null,t,e),t.context.handlers.handleKeydown=e=>o=>function(e,t,o){const n=Number(e.value);e.props.deselect&&" "===o.key&&n===t?e.input(0):" "===o.key&&e.input(t)}(t,e,o))}))},/* #__PURE__ */o.defaultIcon("rating","star")]},Bn=/* #__PURE__ */q("ac"),{outer:Pn,wrapper:Hn,inner:Rn,icon:Kn,label:Nn,prefix:Wn,suffix:qn,help:zn,messages:Yn,message:Un}=/* #__PURE__ */z(Bn),jn=Bn("input",(()=>({$el:"input",bind:"$attrs",attrs:{id:"$id",type:"text",onClick:"$handlers.click",onBlur:"$handlers.blur",onKeydown:"$handlers.keydown",onInput:"$handlers.input",onFocus:"$handlers.focus",value:"$inputText || undefined",name:"$node.name",placeholder:"$state.loading && $ui.isLoading.value || $placeholder || undefined",tabindex:'$disabled && "-1" || 0',role:"combobox",autocomplete:'$attrs.autocomplete || "off"',autocapitalize:"none",readonly:"$attrs.readonly || $state.loading || $multiple && $max && $value && $value.length >= $max && $hasHighlightedRange !== true || undefined","data-selection-appearance":"$selectionAppearance",disabled:"$disabled || $disabledInternally || undefined",onTouchmove:"$handlers.touchmove",onTouchstart:"$handlers.touchmove",onTouchend:"$handlers.touchend","aria-autocomplete":"list","aria-expanded":"$expanded","aria-controls":'$expanded && $id + "_listbox" || undefined',"aria-describedBy":"$describedBy","aria-activedescendant":"$expanded && $activeDescendant || undefined"}}))),Zn=Bn("listboxButton",(()=>({$el:"div",attrs:{style:"$visibilityStyles",id:'$id + "_listbox_button"',role:"button","aria-label":"$expanded && $ui.close.value || $ui.open.value",onClick:"$handlers.toggleListbox",onKeydown:"$handlers.toggleListboxKeydown",tabindex:'$disabled && "-1" || 0',"aria-haspopup":"true","aria-expanded":"$expanded","aria-controls":'$expanded && $id + "_listbox" || undefined',"aria-disabled":"$disabled || $state.loading || undefined","data-disabled":"$disabled || $disabledInternally || undefined"}}))),Gn=Bn("selectionWrapper",(()=>({for:["option","index","$selections"],$el:"div",attrs:{id:'$id + "_selection_wrapper_" + $index',key:"$option.value","data-value":"$option.value",tabindex:'$disabled && "-1" || 0',onKeydown:"$handlers.selectionKeydown && $handlers.selectionKeydown($multiple && $option || undefined)",onClick:"$handlers.selectionClick && $handlers.selectionClick($multiple && $option || undefined)",onFocus:"$handlers.selectionFocus && $handlers.selectionFocus($multiple && $option || undefined)",onBlur:"$handlers.selectionBlur && $handlers.selectionBlur($multiple && $option || undefined)","data-is-selection":"true","data-active-selection":"$fns.isActiveSelection && $fns.isActiveSelection($activeSelectionValue, $option)"}}))),Xn=Bn("selection",(()=>({$el:"div",attrs:{id:'$id + "_selection_" + $index'}}))),Jn=Bn("selections",(()=>({$el:"div",attrs:{"aria-live":"polite",id:'$id + "_selections"'}}))),Qn=Bn("removeSelection",(()=>({$el:"button",attrs:{id:'$selectionAppearance === "option" && $multiple && $id + "_remove_selection_" + $index || $id + "_remove_selection"',tabindex:"0",title:"$ui.remove.value",type:"button","aria-label":"$ui.remove.value",onClick:"$handlers.removeSelection && $handlers.removeSelection($multiple && $option || undefined)",onTouchend:"$handlers.removeSelection && $handlers.removeSelection($multiple && $option || undefined)","aria-controls":"$id"}}))),er=Bn("optionLoading","span"),tr=Bn("option",(()=>({$el:"div",if:"$value !== undefined"}))),or=/* #__PURE__ */j(Bn);function nr(t){"option"!==t.props.selectionAppearance||t.props.multiple||!1===t.props.selectionRemovable||"false"===t.props.selectionRemovable||(t.props.selectionRemovable=!0),t.props.multiple||(t.props.clearSearchOnOpen=e.undefine(t.props.clearSearchOnOpen)),t.props.selectionRemovable=e.undefine(t.props.selectionRemovable),t.props.openOnClick=e.undefine(t.props.openOnClick),"option"!==t.props.selectionAppearance||t.props.multiple||(t.props.isSingleOption=!0),void 0===t.props.closeOnSelect&&(t.props.closeOnSelect=!0),void 0===t.props.selectionAppearance&&(t.props.selectionAppearance="text-input"),void 0===t.props.closeOnSelect&&(t.props.closeOnSelect=!0),t.props.closeOnSelect?t.props.resetSearchOnCommit=!1:void 0===t.props.resetSearchOnCommit&&(t.props.resetSearchOnCommit=t.props.multiple),t.props.allowNewValues=e.undefine(t.props.allowNewValues)}function rr(t){t.addProps(["inputText","selectionAppearance","searchValue","openOnClick","filteredOptions","search","debounce","showInput","visibilityStyles","selectionStyles","multiple","filter","hasHighlightedRange","clearOnClick","debounce"]),void 0===t.props.debounce?t.props.debounce=200:t.props.debounce=parseInt(t.props.debounce),t.props.nonceKey="searchValue",t.props.searchValue="",t.props.inputText="",t.props.filterOptions=Ce.bind(null,t),t.props.reloadOnCommit=e.undefine(t.props.reloadOnCommit),void 0===t.props.alwaysLoadOnOpen?t.props.alwaysLoadOnOpen=!0:t.props.alwaysLoadOnOpen=e.undefine(t.props.alwaysLoadOnOpen),"function"!=typeof t.props.filter&&(t.props.filter=(e,t)=>e.label.toLowerCase().includes(t.toLowerCase())),t.on("created",(()=>{t.context&&u&&(t.context.handlers.focus=lr.bind(null,t),t.context.handlers.input=sr.bind(null,t),t.context.handlers.focus=lr.bind(null,t),t.context.handlers.click=ar.bind(null,t),t.context.handlers.toggleListbox=ir.bind(null,t),t.context.handlers.toggleListboxKeydown=pr.bind(null,t),t.context.handlers.keydown=At.bind(null,t),t.context.handlers.selectionKeydown=e=>o=>St(t,e,o),t.context.handlers.searchInputTagKeydown=e=>o=>function(e,t,o){if(o.stopPropagation(),e.props.disabled)return;switch(o.key){case"ArrowDown":bt(e);break;case"ArrowRight":case"ArrowLeft":yt(e,t,o);break;case"Delete":case"Backspace":xt(e,t,o)}}(t,e,o),t.on("prop:options",(({payload:e})=>{if((0===t.props.initialOptions.length&&"function"!=typeof t.props.optionsLoader||!t.props.searchValue&&e.length)&&(t.props.initialOptions=[...e]),t.props.selections&&t.props.selections.length&&e.length)for(let o=0;o<t.props.selections.length;o++){const n=t.props.selections[o],r=e.find((e=>Ae(e)===n.value));r&&(t.props.selections[o]=r)}})))})),t.on("prop:expanded",(({payload:e})=>{e||Ie.delete(t)}))}function sr(e,t){if(e.props.disabled)return;const o=t.target;e.props.inputText=o.value,e.emit("handleSearchInput",o.value),e.props.searchValue&&Ce(e,e.props.searchValue,!0)}function ar(e,t){t.stopPropagation(),e.props.disabled||e.props.disabledInternally||(e.props.attrs.onClick&&e.props.attrs.onClick(t),(!e.props.expanded&&e.props.openOnClick||e.props.openOnFocus)&&(e.props.expanded=!0))}function lr(e){e.props.disabled||e.props.disabledInternally||(e.props.attrs.onFocus&&e.props.attrs.onFocus(),e.props.activeSelectionValue=void 0,e.props.skipOpen?e.props.skipOpen=!1:e.props.openOnFocus&&(e.props.expanded=!0))}function ir(e){var t,o,n;e.props.disabled||e.props.disabledInternally||(null===(t=e.context)||void 0===t?void 0:t.state.loading)||(e.props.expanded=!e.props.expanded,e.props.openOnFocus||null===(n=null===(o=e.props.__root)||void 0===o?void 0:o.getElementById(`${e.props.id}`))||void 0===n||n.focus())}function pr(e,t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),ir(e))}const dr=new WeakMap,cr="undefined"!=typeof window,ur=new WeakMap;let fr=!1;function vr(t){t.props.searchValue=null,t.on("commit",(()=>{t.props.searchValue=null,t.props.highlightedRange||hr(t)})),t.on("created",(()=>{if(!t.context||!cr)return;t.on("handleSearchInput",(({payload:e})=>{""===e?(t.props.searchValue=null,t.input([])):e&&0===t.props.inputStd.length?t.props.searchValue=e:e&&t.props.inputStd.length>0&&(t.props.searchValue=function(e){var t;const o=gr(e);if(e.props.highlightedRange){const[t,n]=mr(e,o);return e.props.inputText.slice(t,n)}return e.props.inputText.slice((null===(t=o[o.length-1])||void 0===t?void 0:t.end)+2)}(t)),!t.props.expanded&&e?t.props.expanded=!0:!e&&t.props.expanded&&(t.props.expanded=!1)})),function(t){e.whenAvailable(`${t.props.id}`,(e=>{e instanceof HTMLInputElement&&ur.set(e,t)}),t.props.__root),cr&&!fr&&(fr=!0,document.addEventListener("selectionchange",(()=>{const e=Le();if(e instanceof HTMLInputElement&&ur.has(e)){const t=ur.get(e);t&&function(e){clearTimeout(dr.get(e)),dr.set(e,setTimeout((()=>{var t,o,n,r;const s=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}`);if(s instanceof HTMLInputElement){const t=gr(e),a=t.findIndex((e=>null!==s.selectionStart?s.selectionStart>=e.start&&s.selectionStart<=e.end:null!==s.selectionEnd&&(s.selectionEnd>=e.start&&s.selectionEnd<=e.end))),l=null===(o=t[t.length-1])||void 0===o?void 0:o.end;if(0===s.selectionStart&&s.selectionEnd===(null===(n=e.props.inputText)||void 0===n?void 0:n.length))return;if("string"==typeof e.props.searchValue&&e.props.highlightedRange){if(t.length){const o=e.props.highlightedRange,[n,r]=mr(e,t);if(null!==s.selectionEnd&&(s.selectionEnd<n||s.selectionEnd>r)){const t=o.end-o.start-(r-n),a=s.selectionEnd;e.props.inputText=e.props.option.label,e.props.highlightedRange=void 0,e.props.searchValue=null,s.value=e.props.inputText,s.selectionStart=s.selectionEnd=a+(a>n?t:0)}}}else if(a>=0&&null!==s.selectionStart&&(l!==(null===(r=e.props.inputText)||void 0===r?void 0:r.length)||s.selectionStart<l)){const o=t[a],n=e.props.inputText.substr(0,l),r=o.start+(o.index>0?1:0),i=o.end+(t.length-1>o.index?-1:0);n!==e.props.inputText&&(e.props.inputText=n,s.value=n),e.props.highlightedRange=o,s.selectionStart=r,s.selectionEnd=i}else e.props.highlightedRange=void 0,hr(e);if(null!==s.selectionStart&&s.selectionStart>=l&&", "!==e.props.inputText.substring(l,l+2)){let t=e.props.inputText.substring(0,l);t=e.props.multiple&&e.props.max&&Array.isArray(e.props.inputStd)&&e.props.inputStd.length>=e.props.max?t:`${t},`,e.props.inputText=`${t} ${e.props.inputText.substring(l).replace(/^[,\s]{1,2}/,"")}`}}}),5))}(t)}})))}(t);const n=t.context.handlers.keydown;t.context.handlers.keydown=e=>{n(e),function(e,t){var n,r,s,a;if(["ArrowRight","ArrowLeft"].includes(t.key)&&t.target instanceof HTMLInputElement&&null!==t.target.selectionEnd&&null!==t.target.selectionStart){if(0===t.target.selectionStart&&t.target.selectionEnd===(null===(n=e.props.inputText)||void 0===n?void 0:n.length))"ArrowLeft"===t.key?o(0):o(-1);else if(!e.props.searchValue){e.props.searchValue=null;const o=gr(e),n=null===(r=o[o.length-1])||void 0===r?void 0:r.end;t.target.selectionStart<n&&(t.target.selectionStart=Math.max(0,"ArrowLeft"===t.key?t.target.selectionStart-2:t.target.selectionEnd+2))}}else if(["Delete","Backspace"].includes(t.key))e.props.highlightedRange&&!e.props.searchValue?(Ke(e,e.props.highlightedRange.option),0===e.props.inputStd.length&&(e.props.highlightedRange=void 0)):t.target instanceof HTMLInputElement&&(e.props.searchValue=null,o(-1,!0)&&t.preventDefault());else if(t.target instanceof HTMLInputElement&&0===t.target.selectionStart&&t.target.selectionEnd===(null===(s=e.props.inputText)||void 0===s?void 0:s.length)&&(null===(a=e.props.inputText)||void 0===a?void 0:a.length)&&0===e.props.selections.length)t.preventDefault();else if("Tab"===t.key)return;"ArrowLeft"===t.key&&o(-1,!0)&&t.preventDefault()}(t,e)};const r=t.context.handlers.focus;t.context.handlers.focus=e=>{r(t,e);const o=new Event("selectionchange");document.dispatchEvent(o)},t.on("blur",(()=>{t.props.selections.length?(t.props.inputText=t.props.selections.map((e=>e.label)).join(", "),t.props.searchValue=null):t.props.selections.length||(t.props.inputText="",t.props.searchValue="")}))})),t.on("prop:expanded",(({payload:e})=>{e||t.props.inputStd.length?e&&(t.props.options.length&&!t.props.alwaysLoadOnOpen||(t.props.options=[],Ce(t,t.props.searchValue))):(t.props.searchValue="",t.props.inputText="")})),t.on("prop:selections",(()=>{var e;const o=[...t.props.selections].map((e=>e.label)).join(", ");let n="";if(cr&&t.isCreated){const o=null===(e=t.props.__root)||void 0===e?void 0:e.getElementById(`${t.props.id}`);if(null==o||o.focus(),Le()===o&&Array.isArray(t._value)&&t._value.length){if(t.props.max&&t._value.length>=Number(t.props.max))return;n=", "}}t.props.inputText=`${o}${n}`,t.props.reloadOnCommit&&(t.props.searchValue="",Ce(t,t.props.searchValue))}));const o=(e,o=!1)=>{var n,r;const s=null===(n=t.props.__root)||void 0===n?void 0:n.getElementById(`${t.props.id}`);if(!(s instanceof HTMLInputElement))return!1;const a=gr(t),l=e>=0?e:a.length-1;if(void 0===a[l])return!1;const i=null===(r=a[l])||void 0===r?void 0:r.end;return null!==s.selectionStart&&(!o||s.selectionStart>=i&&s.selectionStart<=i+2)&&(s.selectionStart=a[l].start+(l>0?1:0),s.selectionEnd=a[l].end+(l<a.length-1?-1:0),!0)};let n;t.on("selectRange",(({payload:e})=>o(...e))),t.on("prop:highlightedRange",(({payload:e})=>{t.props.hasHighlightedRange=!!e,e&&t.props.expanded&&n!==e.option&&(n=e.option,We(t))}))}function hr(e){var t;if(!cr)return;const o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}`);o&&o.scrollTo({left:o.scrollWidth,behavior:"smooth"})}function mr(e,t){var o;const n=e.props.highlightedRange,r=n.index,s=n.start+(r?1:0),a=t.length-1>r?t[t.length-1].end-t[r+1].start:0;return[s,(null===(o=e.props.inputText)||void 0===o?void 0:o.length)-a+(t.length-1>n.index?-1:0)]}function gr(e){const t=Re(e);return Array.isArray(t)&&t.length?t.reduce(((e,o,n)=>{var r;const s=(null===(r=e[n-1])||void 0===r?void 0:r.end)||0;let a=0;return t.length-1!==n&&a++,0!==n&&a++,e.push({option:o,index:n,start:s,end:s+o.label.length+a}),e}),[]):[]}function $r(e){!function(e){e.on("prop:expanded",(({payload:t})=>{t?(e.props.searchValue="",e.props.options.length&&!e.props.alwaysLoadOnOpen||(e.props.options=[],Ce(e,e.props.searchValue,!0))):(e.props.searchValue="",e.props.inputText="")}))}(e),function(e){e.on("handleSearchInput",(({payload:t})=>{t&&!e.props.expanded?(e.props.searchExpand=!0,e.props.expanded=!0):!t&&e.props.expanded&&(e.props.expanded=!1),e.props.searchValue=e.props.inputText}))}(e),function(e){e.on("prop:selections",(()=>{e.isCreated&&(e.props.inputText="",e.props.searchValue="",e.props.optionRemoved||e.props.reloadOnCommit&&Ce(e,e.props.searchValue,!0))}))}(e)}function br(e){!function(e){function t(e){0===e.props.inputStd.length?(e.props.inputText="",e.props.searchValue=""):(e.props.inputText=e.props.selections[0].label,e.props.searchValue=e.props.selections[0].label)}function o(e){e.props.clearSearchOnOpen&&!e.props.searchExpand&&(e.props.inputText="",e.props.searchValue=""),e.props.searchValue=e.props.inputText,e.props.options.length&&!e.props.alwaysLoadOnOpen||e.props.searchExpand||(e.props.options=[],Ce(e,e.props.searchValue,!0)),e.props.searchExpand&&(e.props.searchExpand=!1)}e.on("prop:expanded",(({payload:n})=>{n?o(e):t(e)}))}(e),function(e){e.on("handleSearchInput",(({payload:t})=>{""===t?(0===e.props.inputStd.length&&(e.props.expanded=!1),e.input(void 0)):t&&!e.props.expanded&&(e.props.searchExpand=!0,e.props.expanded=!0),e.props.searchValue=e.props.inputText}))}(e),function(e){e.on("prop:selections",(({payload:t})=>{e.props.inputText=t.length?t[0].label:"",e.props.searchValue=t.length?t[0].label:"",e.isCreated&&e.props.expanded&&0===t.length&&Ce(e,e.props.searchValue,!0)}))}(e)}function yr(t){if(t.props.multiple)if(t.props.multiple&&"option"===t.props.selectionAppearance){function o(){return Array.isArray(t.value)?t.value:[]}function r(e){t.input(e)}$r(t),t.on("created",(()=>{t.props.disabled&&(t.props.draggable=!1),e.whenAvailable(`${t.props.id}_selections`,(e=>{if(e instanceof HTMLElement&&t.context){const s={draggingClass:t.context.classes.dragging,dropZoneClass:t.context.classes.dropZone,root:t.props.__root,disabled:!t.props.draggable,plugins:[n.animations()],touchDraggingClass:t.context.classes.touchDragging,touchDropZoneClass:t.context.classes.touchDropZone,draggable:e=>e.hasAttribute("data-is-selection")};n.dragAndDrop({parent:e,getValues:o,setValues:r,config:s}),t.on("prop:disabled",(({payload:t})=>{s.disabled=t,n.dragAndDrop({parent:e,getValues:o,setValues:r,config:s})})),t.on("prop:draggable",(({payload:t})=>{s.disabled=!t,n.dragAndDrop({parent:e,getValues:o,setValues:r,config:s})}))}}),t.props.__root)}))}else t.props.multiple&&"text-input"===t.props.selectionAppearance&&vr(t);else br(t)}const xr={schema:/* #__PURE__ */Pn(/* #__PURE__ */Hn(/* #__PURE__ */Nn("$label"),/* #__PURE__ */Rn(/* #__PURE__ */Kn("prefix"),/* #__PURE__ */Wn(),/* #__PURE__ */jn(),/* #__PURE__ */U("$multiple !== true && $selectionAppearance === option && $expanded === false",/* #__PURE__ */Jn(/* #__PURE__ */Gn(/* #__PURE__ */Xn(/* #__PURE__ */tr(/* #__PURE__ */U("$state.loading",/* #__PURE__ */er("$ui.isLoading.value"),"$option.label"))),/* #__PURE__ */U("$state.loading && $isSingleOption !== true && $optionLoaderValues.includes($option.value)",/* #__PURE__ */Kn("loader")),/* #__PURE__ */U("$selectionRemovable && $isSingleOption",/* #__PURE__ */Qn(/* #__PURE__ */Kn("close")))))),/* #__PURE__ */U("$state.loading && ($isSingleOption !== true || $selections.length === 0)",/* #__PURE__ */Kn("loader")),/* #__PURE__ */U('$selectionRemovable && $selectionAppearance === "text-input" && $selections.length > 0',/* #__PURE__ */Qn(/* #__PURE__ */Kn("close")),/* #__PURE__ */U('$selectionAppearance === "text-input" || ($selectionAppearance === "option" && $multiple)',/* #__PURE__ */Zn(/* #__PURE__ */Kn("select")))),/* #__PURE__ */U("$isSingleOption && ($inputStd.length === 0 || $selectionRemovable === undefined || ($expanded) || $state.loading || $optionLoaderValues.length > 0)",/* #__PURE__ */Zn(/* #__PURE__ */Kn("select"))),/* #__PURE__ */or(),/* #__PURE__ */qn(),/* #__PURE__ */Kn("suffix")),/* #__PURE__ */U("$multiple && $selectionAppearance === option",/* #__PURE__ */Jn(/* #__PURE__ */Gn(/* #__PURE__ */Xn(/* #__PURE__ */tr(/* #__PURE__ */U("$state.loading && $isLoadingOption",/* #__PURE__ */er("$ui.isLoading.value"),"$option.label"))),/* #__PURE__ */Qn(/* #__PURE__ */Kn("close")))))),/* #__PURE__ */zn("$help"),/* #__PURE__ */Yn(/* #__PURE__ */Un("$message.value"))),type:"input",family:"dropdown",props:[],features:[
19
+ /* #__PURE__ */o.defaultIcon("moveDown","arrowDown")]},Xo=new WeakMap;function Jo(e,t){const o={onItems:[],offItems:[]},n=t||Number(e.value||0);for(let t=0;t<e.props.max;t++)if(t<n&&t+1>=n){const r=e.props.rightToLeft?100-100*(n-t):100*(n-t);o.onItems.push(r+"%"),o.offItems.push(100-r+"%")}else t<n?(o.offItems.push("0%"),o.onItems.push("100%")):t>=n&&(o.offItems.push("100%"),o.onItems.push("0%"));e.props.itemsToPercentages=o}function Qo(e,t){var o;null===(o=e.context)||void 0===o||o.handlers.blur(t)}function en(e,t){const{x:o,y:n}=dn(t);let r=document.elementFromPoint(o,n);const s=Array.from(document.querySelectorAll(`#${e.props.id}_items_wrapper > .formkit-ratingItem`));let a=!0;for(;r&&a;){if(s.includes(r)){a=!1;break}r=r.parentNode}if(!a){const t=s.indexOf(r);if(1===e.props.step)return void e.input(t+1,!1)}}function tn(e,t,o){e.props.disabled||(o.preventDefault(),e.props.hoverHighlight=!0,e.props.touchStarted=!0,1!==e.props.step?cn(e,t,o):e.input(t+1,!1))}function on(e,t){if(!e.props.dragStarted)return;t.preventDefault(),e.props.hoverHighlight=!1,e.props.dragStarted=!1,Jo(e);const o=Xo.get(e);o&&(o.abort(),Xo.delete(e))}function nn(e,t,o){if(e.props.hoverHighlight||e.props.disabled)return;o.preventDefault(),e.props.hoverHighlight=!0,e.props.dragStarted=!0;const n=new AbortController;document.addEventListener("mouseup",(t=>on(e,t)),{signal:n.signal}),Xo.set(e,n),1===e.props.step?e.input(t+1,!1):cn(e,t,o)}function rn(e,t){var o,n;if(document.activeElement===t.currentTarget)if("ArrowRight"===t.key||"ArrowDown"===t.key){e.props.arrow=1;const t=e.value?un(e.value+1*e.props.step,e.props.step):e.props.min+1*e.props.step,n=null===(o=e.props.__root)||void 0===o?void 0:o.querySelector(e.value?`#${e.props.id}_inner input[value="${t}"]`:"#"+(e.props.id+"_0_0"));e.props.preventFocus=!0,n&&n instanceof HTMLInputElement&&n.focus(),e.props.preventFocus=!1,e.input(Number(t))}else if("ArrowLeft"===t.key||"ArrowUp"===t.key){e.props.arrow=-1;const t=e.value?un(e.value-1*e.props.step,e.props.step):e.props.max,o=null===(n=e.props.__root)||void 0===n?void 0:n.querySelector(`#${e.props.id}_inner input[value="${t}"]`);e.props.preventFocus=!0,o&&o instanceof HTMLInputElement&&o.focus(),e.props.preventFocus=!0,e.input(Number(t)),e.props.preventFocus=!1}}function sn(e,t){if(!e.props.preventFocus)if(e.props.preventFocus=!0,setTimeout((()=>{e.props.preventFocus=!1}),50),t.relatedTarget instanceof HTMLElement&&t.relatedTarget.id===e.props.id+"_items_wrapper")e.props.arrow>0?setTimeout((()=>{var t,o;null===(o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(e.props.id+"_0_0"))||void 0===o||o.focus()})):e.props.arrow<0&&setTimeout((()=>{var t,o;null===(o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(e.props.id+`_${e.props.max-1}_${e.props.stepsPerValue-1}`))||void 0===o||o.focus()}));else if(t.target instanceof HTMLInputElement){if(Number(t.target.value)===e.props.step&&e.value===e.props.max||Number(t.target.value)===e.props.max&&e.value===e.props.step){const t=document.getElementById(e.props.id+"_items_wrapper");return null==t||t.focus(),void e.input(0)}e.input(Number(t.target.value))}}function an(e,t,o){e.props.hoverHighlight&&(e.props.disabled||(1===e.props.step?(Jo(e,t+1),e.props.dragStarted&&e.input(t+1,!1)):cn(e,t,o,!!e.props.dragStarted)))}function ln(e){Jo(e)}function pn(e,t,o){if(!e.props.disabled&&"touchstart"!==o.type&&(o.preventDefault(),(0!==o.clientX||0!==o.clientY)&&o.currentTarget instanceof HTMLElement))return 1===e.props.step?e.props.deselect&&Number(e.value)===t+1?void e.input(0):void e.input(t+1):void cn(e,t,o)}function dn(e){return e instanceof MouseEvent?{x:e.clientX,y:e.clientY}:{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY}}function cn(e,t,o,n=!0){if(!(o.currentTarget instanceof HTMLElement))return;const{x:r,y:s}=dn(o),a=o.currentTarget.getBoundingClientRect();let l=un((r-a.x)/a.width+t,e.props.step);l=l>e.props.min?l:e.props.min,l=l<e.props.max?l:e.props.max,!e.props.deselect||l!==Number(e.value)||e.props.dragStarted?n?e.input(l,!1):Jo(e,l):e.input(0)}function un(e,t){t||(t=1);const o=1/t;return Math.ceil(e*o)/o}const fn=/* #__PURE__ */q("rt"),{outer:vn,wrapper:hn,inner:mn,label:gn,prefix:$n,suffix:bn,help:yn,messages:xn,message:wn,icon:_n}=/* #__PURE__ */z(fn),kn=fn("itemsWrapper",(()=>({$el:"span",attrs:{style:{"flex-direction":'$rightToLeft && "row-reverse" || undefined'},tabindex:"$value !== undefined && $value !== 0 && '-1' || '0'",id:"$id + _items_wrapper",onKeydown:"$handlers.handleWrapperKeydown","data-disabled":"$disabled",onBlur:"$handlers.handleWrapperBlur",onMouseleave:"$hoverHighlight && $handlers.handleMouseleave"}}))),Sn=fn("ratingItem",(()=>({for:["item","index","$max"],$el:"span",attrs:{id:'$id + "_item_" + $index',onClick:"$handlers.handleItemClick($item)",draggable:"$hoverHighlight !== true && && $disabled !== true && true",onMousemove:"$handlers.handleMousemove($item)",onDragstart:"$handlers.handleDragstart($item)",onDragend:"$handlers.handleDragend",onTouchstart:"$handlers.handleTouchstart($item)",onTouchmove:"$handlers.handleTouchmove"}}))),Ln=fn("template",(()=>({for:["increment","stepIndex","$stepsPerValue"],$el:null}))),An=fn("itemLabel",(()=>({$el:"label",attrs:{id:'$id + "_label_" + $index + "_" + $stepIndex',for:'$id + "_" + $index + "_" + $stepIndex',"data-checked":'$value === $fns.getValue($item, $increment) && "true" || "false"',style:{width:'$fns.showLabel($fns.getValue($item, $increment), $stepIndex, $item) && "100%" || "0%"'}}}))),In=fn("itemLabelInner",(()=>({$el:"span",children:"$fns.getValue($item, $increment)"}))),Dn=fn("input",(()=>({$el:"input",attrs:{type:"radio",value:"$fns.getValue($item, $increment)",id:'$id + "_" + $index + "_" + $stepIndex',onFocus:"$handlers.handleFocus",tabindex:'$value === $fns.getValue($item, $increment) && "0" || "-1"',disabled:"$disabled",name:"$id","data-value":"$fns.getValue($item, $increment)",checked:"$value === $fns.getValue($item, $increment) && true",onKeydown:"$handlers.handleKeydown($fns.getValue($item, $increment))"}}))),Cn=fn("onItemRow",(()=>({$el:"span",attrs:{style:{width:"$fns.getPercentage($itemsToPercentages, $item)",display:"flex",position:"relative",overflow:"hidden",top:"0",left:"0",bottom:"0"}}}))),Tn=fn("offItemRow",(()=>({$el:"span",attrs:{style:{width:"$fns.getPercentage($itemsToPercentages, $item, false)",display:"flex","flex-direction":"row-reverse",position:"absolute",zIndex:"$offItemStyles && 100",overflow:"hidden",top:"0",right:"0"}}}))),En=fn("onItemWrapper",(()=>({$el:"div",attrs:{style:{color:"$onColor"}}}))),On=fn("offItemWrapper",(()=>({$el:"div",attrs:{style:{color:"$offColor"}}}))),Mn=()=>U("$slots.onItem",(()=>()=>"$slots.onItem"),U("$slots.default",(()=>()=>"$slots.default"),_n("rating"))),Vn=()=>U("$slots.offItem",(()=>()=>"$slots.offItem"),U("$slots.default",(()=>()=>"$slots.default"),_n("rating"))),Fn={schema:/* #__PURE__ */vn(/* #__PURE__ */hn(/* #__PURE__ */gn("$label"),/* #__PURE__ */mn(/* #__PURE__ */_n("prefix"),/* #__PURE__ */$n(),/* #__PURE__ */kn(/* #__PURE__ */Sn(/* #__PURE__ */Ln(/* #__PURE__ */An(/* #__PURE__ */Cn(/* #__PURE__ */En(/* #__PURE__ */Mn())),/* #__PURE__ */Tn(/* #__PURE__ */On(/* #__PURE__ */Vn())),/* #__PURE__ */In()),/* #__PURE__ */Dn()))),/* #__PURE__ */bn(),/* #__PURE__ */_n("suffix"))),/* #__PURE__ */yn("$help"),/* #__PURE__ */xn(/* #__PURE__ */wn("$message.value"))),type:"input",props:[],features:[function(t){function o(e){setTimeout((()=>{const t=Array.from(document.querySelectorAll(`#${e.props.id}_items_wrapper > .formkit-ratingItem`));for(let e=0;e<t.length;e++){const o=t[e].querySelectorAll(".formkit-onItemWrapper"),n=t[e].querySelectorAll(".formkit-offItemWrapper");for(let n=0;n<o.length;n++)o[n].style.flex=`0 0 ${t[e].getBoundingClientRect().width}px`;for(let o=0;o<n.length;o++)n[o].style.flex=`0 0 ${t[e].getBoundingClientRect().width}px`}}))}t.addProps(["max","step","stepsPerValue","itemsToPercentages","rightToLeft","onItemStyles","offItemStyles","hoverHighlight","deselect","disabled","wrapperWidth","onColor","offColor"]),!1!==t.props.hoverHighlight&&"false"!==t.props.hoverHighlight&&(t.props.hoverHighlight=!0),t.props.deselect=e.undefine(t.props.deselect),t.props.max=Number(t.props.max)||5,t.props.min=Number(t.props.min)||0,t.props.step=Number(t.props.step)||1,t.props.numberOfSteps=t.props.max/t.props.step,t.props.lastIndex=1/t.props.step-1,t.props.itemsToPercentages={},"disabled"in t.props&&(t.props.disabled=e.undefine(t.props.disabled)),t.props.rightToLeft?(t.props.onItemStyles=void 0,t.props.offItemStyles={position:"absolute",top:"0",left:"0",overflow:"hidden",height:"100%",zIndex:100}):t.props.onItemStyles={position:"absolute",top:"0",left:"0",overflow:"hidden",height:"100%"},t.props.stepsPerValue=1/t.props.step,t.hook.input(((e,o)=>{if(null===e||""===e||isNaN(e))return o(e);const n=Number(e),r=Number(t.props.min),s=Number(t.props.max);return n>s?o(s):t.props.min&&n<=r?o(r):o(n)})),t.on("commit",(({payload:e})=>{const o=Number(e||0);Jo(t,o)})),t.on("created",(()=>{t.context&&(e.whenAvailable(`${t.props.id}_items_wrapper`,(()=>{o(t),function(e){var t;const n=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}_items_wrapper`);if(!n)return;new ResizeObserver((()=>{o(e)})).observe(n)}(t),setTimeout((()=>o(t)),100)}),t.props.__root),t.context.fns.getPercentage=(e,t,o=!0)=>(o?e.onItems:e.offItems)[t],t.context.fns.getValue=(e,o)=>e+Number((o*t.props.step+t.props.step).toFixed(1)),t.context.fns.showLabel=(e,o)=>{const n=Number(t.value||0);return 0===n&&0===o||n&&e===n||e>n&&0===o||n>e&&o===t.props.lastIndex},t.context.handlers.handleFocus=e=>sn.call(null,t,e),t.context.handlers.handleWrapperKeydown=e=>rn.call(null,t,e),t.context.handlers.handleWrapperBlur=e=>Qo.call(null,t,e),t.context.handlers.handleItemClick=e=>o=>pn.call(null,t,e,o),t.context.handlers.handleMousemove=e=>o=>an.call(null,t,e,o),t.context.handlers.handleMouseleave=()=>ln.call(null,t),t.context.handlers.handleDragstart=e=>o=>nn.call(null,t,e,o),t.context.handlers.handleMouseup=e=>on.call(null,t,e),t.context.handlers.handleTouchstart=e=>o=>tn.call(null,t,e,o),t.context.handlers.handleTouchmove=e=>en.call(null,t,e),t.context.handlers.handleKeydown=e=>o=>function(e,t,o){const n=Number(e.value);e.props.deselect&&" "===o.key&&n===t?e.input(0):" "===o.key&&e.input(t)}(t,e,o))}))},/* #__PURE__ */o.defaultIcon("rating","star")]},Bn=/* #__PURE__ */q("ac"),{outer:Pn,wrapper:Hn,inner:Rn,icon:Kn,label:Nn,prefix:Wn,suffix:qn,help:zn,messages:Yn,message:Un}=/* #__PURE__ */z(Bn),jn=Bn("input",(()=>({$el:"input",bind:"$attrs",attrs:{id:"$id",type:"text",onClick:"$handlers.click",onBlur:"$handlers.blur",onKeydown:"$handlers.keydown",onInput:"$handlers.input",onFocus:"$handlers.focus",value:"$inputText || undefined",name:"$node.name",placeholder:"$state.loading && $ui.isLoading.value || $placeholder || undefined",tabindex:'$disabled && "-1" || 0',role:"combobox",autocomplete:'$attrs.autocomplete || "off"',autocapitalize:"none",readonly:"$attrs.readonly || $state.loading || $multiple && $max && $value && $value.length >= $max && $hasHighlightedRange !== true || undefined","data-selection-appearance":"$selectionAppearance",disabled:"$disabled || $disabledInternally || undefined",onTouchmove:"$handlers.touchmove",onTouchstart:"$handlers.touchmove",onTouchend:"$handlers.touchend","aria-autocomplete":"list","aria-expanded":"$expanded","aria-controls":'$expanded && $id + "_listbox" || undefined',"aria-describedBy":"$describedBy","aria-activedescendant":"$expanded && $activeDescendant || undefined"}}))),Zn=Bn("listboxButton",(()=>({$el:"div",attrs:{style:"$visibilityStyles",id:'$id + "_listbox_button"',role:"button","aria-label":"$expanded && $ui.close.value || $ui.open.value",onClick:"$handlers.toggleListbox",onKeydown:"$handlers.toggleListboxKeydown",tabindex:'$disabled && "-1" || 0',"aria-haspopup":"true","aria-expanded":"$expanded","aria-controls":'$expanded && $id + "_listbox" || undefined',"aria-disabled":"$disabled || $state.loading || undefined","data-disabled":"$disabled || $disabledInternally || undefined"}}))),Gn=Bn("selectionWrapper",(()=>({for:["option","index","$selections"],$el:"div",attrs:{id:'$id + "_selection_wrapper_" + $index',key:"$option.value","data-value":"$option.value",tabindex:'$disabled && "-1" || 0',onKeydown:"$handlers.selectionKeydown && $handlers.selectionKeydown($multiple && $option || undefined)",onClick:"$handlers.selectionClick && $handlers.selectionClick($multiple && $option || undefined)",onFocus:"$handlers.selectionFocus && $handlers.selectionFocus($multiple && $option || undefined)",onBlur:"$handlers.selectionBlur && $handlers.selectionBlur($multiple && $option || undefined)","data-is-selection":"true","data-active-selection":"$fns.isActiveSelection && $fns.isActiveSelection($activeSelectionValue, $option)"}}))),Xn=Bn("selection",(()=>({$el:"div",attrs:{id:'$id + "_selection_" + $index'}}))),Jn=Bn("selections",(()=>({$el:"div",attrs:{"aria-live":"polite",id:'$id + "_selections"'}}))),Qn=Bn("removeSelection",(()=>({$el:"button",attrs:{id:'$selectionAppearance === "option" && $multiple && $id + "_remove_selection_" + $index || $id + "_remove_selection"',tabindex:"0",title:"$ui.remove.value",type:"button","aria-label":"$ui.remove.value",onClick:"$handlers.removeSelection && $handlers.removeSelection($multiple && $option || undefined)",onTouchend:"$handlers.removeSelection && $handlers.removeSelection($multiple && $option || undefined)","aria-controls":"$id"}}))),er=Bn("optionLoading","span"),tr=Bn("option",(()=>({$el:"div",if:"$value !== undefined"}))),or=/* #__PURE__ */j(Bn);function nr(t){"option"!==t.props.selectionAppearance||t.props.multiple||!1===t.props.selectionRemovable||"false"===t.props.selectionRemovable||(t.props.selectionRemovable=!0),t.props.multiple||(t.props.clearSearchOnOpen=e.undefine(t.props.clearSearchOnOpen)),t.props.selectionRemovable=e.undefine(t.props.selectionRemovable),t.props.openOnClick=e.undefine(t.props.openOnClick),"option"!==t.props.selectionAppearance||t.props.multiple||(t.props.isSingleOption=!0),void 0===t.props.closeOnSelect&&(t.props.closeOnSelect=!0),void 0===t.props.selectionAppearance&&(t.props.selectionAppearance="text-input"),void 0===t.props.closeOnSelect&&(t.props.closeOnSelect=!0),t.props.closeOnSelect?t.props.resetSearchOnCommit=!1:void 0===t.props.resetSearchOnCommit&&(t.props.resetSearchOnCommit=t.props.multiple),t.props.allowNewValues=e.undefine(t.props.allowNewValues)}function rr(t){t.addProps(["inputText","selectionAppearance","searchValue","openOnClick","filteredOptions","search","debounce","showInput","visibilityStyles","selectionStyles","multiple","filter","hasHighlightedRange","clearOnClick","debounce"]),void 0===t.props.debounce?t.props.debounce=200:t.props.debounce=parseInt(t.props.debounce),t.props.nonceKey="searchValue",t.props.searchValue="",t.props.inputText="",t.props.filterOptions=Ce.bind(null,t),t.props.reloadOnCommit=e.undefine(t.props.reloadOnCommit),void 0===t.props.alwaysLoadOnOpen?t.props.alwaysLoadOnOpen=!0:t.props.alwaysLoadOnOpen=e.undefine(t.props.alwaysLoadOnOpen),"function"!=typeof t.props.filter&&(t.props.filter=(e,t)=>e.label.toLowerCase().includes(t.toLowerCase())),t.on("created",(()=>{t.context&&u&&(t.context.handlers.focus=lr.bind(null,t),t.context.handlers.input=sr.bind(null,t),t.context.handlers.focus=lr.bind(null,t),t.context.handlers.click=ar.bind(null,t),t.context.handlers.toggleListbox=ir.bind(null,t),t.context.handlers.toggleListboxKeydown=pr.bind(null,t),t.context.handlers.keydown=At.bind(null,t),t.context.handlers.selectionKeydown=e=>o=>St(t,e,o),t.context.handlers.searchInputTagKeydown=e=>o=>function(e,t,o){if(o.stopPropagation(),e.props.disabled)return;switch(o.key){case"ArrowDown":bt(e);break;case"ArrowRight":case"ArrowLeft":yt(e,t,o);break;case"Delete":case"Backspace":xt(e,t,o)}}(t,e,o),t.on("prop:options",(({payload:e})=>{if((0===t.props.initialOptions.length&&"function"!=typeof t.props.optionsLoader||!t.props.searchValue&&e.length)&&(t.props.initialOptions=[...e]),t.props.selections&&t.props.selections.length&&e.length)for(let o=0;o<t.props.selections.length;o++){const n=t.props.selections[o],r=e.find((e=>Ae(e)===n.value));r&&(t.props.selections[o]=r)}})))})),t.on("prop:expanded",(({payload:e})=>{e||Ie.delete(t)}))}function sr(e,t){if(e.props.disabled)return;const o=t.target;e.props.inputText=o.value,e.emit("handleSearchInput",o.value),e.props.searchValue&&Ce(e,e.props.searchValue,!0)}function ar(e,t){t.stopPropagation(),e.props.disabled||e.props.disabledInternally||(e.props.attrs.onClick&&e.props.attrs.onClick(t),(!e.props.expanded&&e.props.openOnClick||e.props.openOnFocus)&&(e.props.expanded=!0))}function lr(e){e.props.disabled||e.props.disabledInternally||(e.props.attrs.onFocus&&e.props.attrs.onFocus(),e.props.activeSelectionValue=void 0,e.props.skipOpen?e.props.skipOpen=!1:e.props.openOnFocus&&(e.props.expanded=!0))}function ir(e){var t,o,n;e.props.disabled||e.props.disabledInternally||(null===(t=e.context)||void 0===t?void 0:t.state.loading)||(e.props.expanded=!e.props.expanded,e.props.openOnFocus||null===(n=null===(o=e.props.__root)||void 0===o?void 0:o.getElementById(`${e.props.id}`))||void 0===n||n.focus())}function pr(e,t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),ir(e))}const dr=new WeakMap,cr="undefined"!=typeof window,ur=new WeakMap;let fr=!1;function vr(t){t.props.searchValue=null,t.on("commit",(()=>{t.props.searchValue=null,t.props.highlightedRange||hr(t)})),t.on("created",(()=>{if(!t.context||!cr)return;t.on("handleSearchInput",(({payload:e})=>{""===e?(t.props.searchValue=null,t.input([])):e&&0===t.props.inputStd.length?t.props.searchValue=e:e&&t.props.inputStd.length>0&&(t.props.searchValue=function(e){var t;const o=gr(e);if(e.props.highlightedRange){const[t,n]=mr(e,o);return e.props.inputText.slice(t,n)}return e.props.inputText.slice((null===(t=o[o.length-1])||void 0===t?void 0:t.end)+2)}(t)),!t.props.expanded&&e?t.props.expanded=!0:!e&&t.props.expanded&&(t.props.expanded=!1)})),function(t){e.whenAvailable(`${t.props.id}`,(e=>{e instanceof HTMLInputElement&&ur.set(e,t)}),t.props.__root),cr&&!fr&&(fr=!0,document.addEventListener("selectionchange",(()=>{const e=Le();if(e instanceof HTMLInputElement&&ur.has(e)){const t=ur.get(e);t&&function(e){clearTimeout(dr.get(e)),dr.set(e,setTimeout((()=>{var t,o,n,r;const s=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}`);if(s instanceof HTMLInputElement){const t=gr(e),a=t.findIndex((e=>null!==s.selectionStart?s.selectionStart>=e.start&&s.selectionStart<=e.end:null!==s.selectionEnd&&(s.selectionEnd>=e.start&&s.selectionEnd<=e.end))),l=null===(o=t[t.length-1])||void 0===o?void 0:o.end;if(0===s.selectionStart&&s.selectionEnd===(null===(n=e.props.inputText)||void 0===n?void 0:n.length))return;if("string"==typeof e.props.searchValue&&e.props.highlightedRange){if(t.length){const o=e.props.highlightedRange,[n,r]=mr(e,t);if(null!==s.selectionEnd&&(s.selectionEnd<n||s.selectionEnd>r)){const t=o.end-o.start-(r-n),a=s.selectionEnd;e.props.inputText=e.props.option.label,e.props.highlightedRange=void 0,e.props.searchValue=null,s.value=e.props.inputText,s.selectionStart=s.selectionEnd=a+(a>n?t:0)}}}else if(a>=0&&null!==s.selectionStart&&(l!==(null===(r=e.props.inputText)||void 0===r?void 0:r.length)||s.selectionStart<l)){const o=t[a],n=e.props.inputText.substr(0,l),r=o.start+(o.index>0?1:0),i=o.end+(t.length-1>o.index?-1:0);n!==e.props.inputText&&(e.props.inputText=n,s.value=n),e.props.highlightedRange=o,s.selectionStart=r,s.selectionEnd=i}else e.props.highlightedRange=void 0,hr(e);if(null!==s.selectionStart&&s.selectionStart>=l&&", "!==e.props.inputText.substring(l,l+2)){let t=e.props.inputText.substring(0,l);t=e.props.multiple&&e.props.max&&Array.isArray(e.props.inputStd)&&e.props.inputStd.length>=e.props.max?t:`${t},`,e.props.inputText=`${t} ${e.props.inputText.substring(l).replace(/^[,\s]{1,2}/,"")}`}}}),5))}(t)}})))}(t);const n=t.context.handlers.keydown;t.context.handlers.keydown=e=>{n(e),function(e,t){var n,r,s,a;if(["ArrowRight","ArrowLeft"].includes(t.key)&&t.target instanceof HTMLInputElement&&null!==t.target.selectionEnd&&null!==t.target.selectionStart){if(0===t.target.selectionStart&&t.target.selectionEnd===(null===(n=e.props.inputText)||void 0===n?void 0:n.length))"ArrowLeft"===t.key?o(0):o(-1);else if(!e.props.searchValue){e.props.searchValue=null;const o=gr(e),n=null===(r=o[o.length-1])||void 0===r?void 0:r.end;t.target.selectionStart<n&&(t.target.selectionStart=Math.max(0,"ArrowLeft"===t.key?t.target.selectionStart-2:t.target.selectionEnd+2))}}else if(["Delete","Backspace"].includes(t.key))e.props.highlightedRange&&!e.props.searchValue?(Ke(e,e.props.highlightedRange.option),0===e.props.inputStd.length&&(e.props.highlightedRange=void 0)):t.target instanceof HTMLInputElement&&(e.props.searchValue=null,o(-1,!0)&&t.preventDefault());else if(t.target instanceof HTMLInputElement&&0===t.target.selectionStart&&t.target.selectionEnd===(null===(s=e.props.inputText)||void 0===s?void 0:s.length)&&(null===(a=e.props.inputText)||void 0===a?void 0:a.length)&&0===e.props.selections.length)t.preventDefault();else if("Tab"===t.key)return;"ArrowLeft"===t.key&&o(-1,!0)&&t.preventDefault()}(t,e)};const r=t.context.handlers.focus;t.context.handlers.focus=e=>{r(t,e);const o=new Event("selectionchange");document.dispatchEvent(o)},t.on("blur",(()=>{t.props.selections.length?(t.props.inputText=t.props.selections.map((e=>e.label)).join(", "),t.props.searchValue=null):t.props.selections.length||(t.props.inputText="",t.props.searchValue="")}))})),t.on("prop:expanded",(({payload:e})=>{e||t.props.inputStd.length?e&&(t.props.options.length&&!t.props.alwaysLoadOnOpen||(t.props.options=[],Ce(t,t.props.searchValue))):(t.props.searchValue="",t.props.inputText="")})),t.on("prop:selections",(()=>{var e;const o=[...t.props.selections].map((e=>e.label)).join(", ");let n="";if(cr&&t.isCreated){const o=null===(e=t.props.__root)||void 0===e?void 0:e.getElementById(`${t.props.id}`);if(Le()===o&&Array.isArray(t._value)&&t._value.length){if(t.props.max&&t._value.length>=Number(t.props.max))return;n=", "}}t.props.inputText=`${o}${n}`,t.props.reloadOnCommit&&(t.props.searchValue="",Ce(t,t.props.searchValue))}));const o=(e,o=!1)=>{var n,r;const s=null===(n=t.props.__root)||void 0===n?void 0:n.getElementById(`${t.props.id}`);if(!(s instanceof HTMLInputElement))return!1;const a=gr(t),l=e>=0?e:a.length-1;if(void 0===a[l])return!1;const i=null===(r=a[l])||void 0===r?void 0:r.end;return null!==s.selectionStart&&(!o||s.selectionStart>=i&&s.selectionStart<=i+2)&&(s.selectionStart=a[l].start+(l>0?1:0),s.selectionEnd=a[l].end+(l<a.length-1?-1:0),!0)};let n;t.on("selectRange",(({payload:e})=>o(...e))),t.on("prop:highlightedRange",(({payload:e})=>{t.props.hasHighlightedRange=!!e,e&&t.props.expanded&&n!==e.option&&(n=e.option,We(t))}))}function hr(e){var t;if(!cr)return;const o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}`);o&&o.scrollTo({left:o.scrollWidth,behavior:"smooth"})}function mr(e,t){var o;const n=e.props.highlightedRange,r=n.index,s=n.start+(r?1:0),a=t.length-1>r?t[t.length-1].end-t[r+1].start:0;return[s,(null===(o=e.props.inputText)||void 0===o?void 0:o.length)-a+(t.length-1>n.index?-1:0)]}function gr(e){const t=Re(e);return Array.isArray(t)&&t.length?t.reduce(((e,o,n)=>{var r;const s=(null===(r=e[n-1])||void 0===r?void 0:r.end)||0;let a=0;return t.length-1!==n&&a++,0!==n&&a++,e.push({option:o,index:n,start:s,end:s+o.label.length+a}),e}),[]):[]}function $r(e){!function(e){e.on("prop:expanded",(({payload:t})=>{t?(e.props.searchValue="",e.props.options.length&&!e.props.alwaysLoadOnOpen||(e.props.options=[],Ce(e,e.props.searchValue,!0))):(e.props.searchValue="",e.props.inputText="")}))}(e),function(e){e.on("handleSearchInput",(({payload:t})=>{t&&!e.props.expanded?(e.props.searchExpand=!0,e.props.expanded=!0):!t&&e.props.expanded&&(e.props.expanded=!1),e.props.searchValue=e.props.inputText}))}(e),function(e){e.on("prop:selections",(()=>{e.isCreated&&(e.props.inputText="",e.props.searchValue="",e.props.optionRemoved||e.props.reloadOnCommit&&Ce(e,e.props.searchValue,!0))}))}(e)}function br(e){!function(e){function t(e){0===e.props.inputStd.length?(e.props.inputText="",e.props.searchValue=""):(e.props.inputText=e.props.selections[0].label,e.props.searchValue=e.props.selections[0].label)}function o(e){e.props.clearSearchOnOpen&&!e.props.searchExpand&&(e.props.inputText="",e.props.searchValue=""),e.props.searchValue=e.props.inputText,e.props.options.length&&!e.props.alwaysLoadOnOpen||e.props.searchExpand||(e.props.options=[],Ce(e,e.props.searchValue,!0)),e.props.searchExpand&&(e.props.searchExpand=!1)}e.on("prop:expanded",(({payload:n})=>{n?o(e):t(e)}))}(e),function(e){e.on("handleSearchInput",(({payload:t})=>{""===t?(0===e.props.inputStd.length&&(e.props.expanded=!1),e.input(void 0)):t&&!e.props.expanded&&(e.props.searchExpand=!0,e.props.expanded=!0),e.props.searchValue=e.props.inputText}))}(e),function(e){e.on("prop:selections",(({payload:t})=>{e.props.inputText=t.length?t[0].label:"",e.props.searchValue=t.length?t[0].label:"",e.isCreated&&e.props.expanded&&0===t.length&&Ce(e,e.props.searchValue,!0)}))}(e)}function yr(t){if(t.props.multiple)if(t.props.multiple&&"option"===t.props.selectionAppearance){function o(){return Array.isArray(t.value)?t.value:[]}function r(e){t.input(e)}$r(t),t.on("created",(()=>{t.props.disabled&&(t.props.draggable=!1),e.whenAvailable(`${t.props.id}_selections`,(e=>{if(e instanceof HTMLElement&&t.context){const s={draggingClass:t.context.classes.dragging,dropZoneClass:t.context.classes.dropZone,root:t.props.__root,disabled:!t.props.draggable,plugins:[n.animations()],touchDraggingClass:t.context.classes.touchDragging,touchDropZoneClass:t.context.classes.touchDropZone,draggable:e=>e.hasAttribute("data-is-selection")};n.dragAndDrop({parent:e,getValues:o,setValues:r,config:s}),t.on("prop:disabled",(({payload:t})=>{s.disabled=t,n.dragAndDrop({parent:e,getValues:o,setValues:r,config:s})})),t.on("prop:draggable",(({payload:t})=>{s.disabled=!t,n.dragAndDrop({parent:e,getValues:o,setValues:r,config:s})}))}}),t.props.__root)}))}else t.props.multiple&&"text-input"===t.props.selectionAppearance&&vr(t);else br(t)}const xr={schema:/* #__PURE__ */Pn(/* #__PURE__ */Hn(/* #__PURE__ */Nn("$label"),/* #__PURE__ */Rn(/* #__PURE__ */Kn("prefix"),/* #__PURE__ */Wn(),/* #__PURE__ */jn(),/* #__PURE__ */U("$multiple !== true && $selectionAppearance === option && $expanded === false",/* #__PURE__ */Jn(/* #__PURE__ */Gn(/* #__PURE__ */Xn(/* #__PURE__ */tr(/* #__PURE__ */U("$state.loading",/* #__PURE__ */er("$ui.isLoading.value"),"$option.label"))),/* #__PURE__ */U("$state.loading && $isSingleOption !== true && $optionLoaderValues.includes($option.value)",/* #__PURE__ */Kn("loader")),/* #__PURE__ */U("$selectionRemovable && $isSingleOption",/* #__PURE__ */Qn(/* #__PURE__ */Kn("close")))))),/* #__PURE__ */U("$state.loading && ($isSingleOption !== true || $selections.length === 0)",/* #__PURE__ */Kn("loader")),/* #__PURE__ */U('$selectionRemovable && $selectionAppearance === "text-input" && $selections.length > 0',/* #__PURE__ */Qn(/* #__PURE__ */Kn("close")),/* #__PURE__ */U('$selectionAppearance === "text-input" || ($selectionAppearance === "option" && $multiple)',/* #__PURE__ */Zn(/* #__PURE__ */Kn("select")))),/* #__PURE__ */U("$isSingleOption && ($inputStd.length === 0 || $selectionRemovable === undefined || ($expanded) || $state.loading || $optionLoaderValues.length > 0)",/* #__PURE__ */Zn(/* #__PURE__ */Kn("select"))),/* #__PURE__ */or(),/* #__PURE__ */qn(),/* #__PURE__ */Kn("suffix")),/* #__PURE__ */U("$multiple && $selectionAppearance === option",/* #__PURE__ */Jn(/* #__PURE__ */Gn(/* #__PURE__ */Xn(/* #__PURE__ */tr(/* #__PURE__ */U("$state.loading && $isLoadingOption",/* #__PURE__ */er("$ui.isLoading.value"),"$option.label"))),/* #__PURE__ */Qn(/* #__PURE__ */Kn("close")))))),/* #__PURE__ */zn("$help"),/* #__PURE__ */Yn(/* #__PURE__ */Un("$message.value"))),type:"input",family:"dropdown",props:[],features:[
20
20
  /* #__PURE__ */o.defaultIcon("select","select"),
21
21
  /* #__PURE__ */o.defaultIcon("close","close"),
22
22
  /* #__PURE__ */o.defaultIcon("selected","check"),
package/index.mjs CHANGED
@@ -16,7 +16,7 @@ import{isRecord as e,isObject as t,isPojo as o,eq as n,undefine as r,whenAvailab
16
16
  /* #__PURE__ */$("remove","trash"),
17
17
  /* #__PURE__ */$("add","add"),
18
18
  /* #__PURE__ */$("moveUp","arrowUp"),
19
- /* #__PURE__ */$("moveDown","arrowDown")]},Un=new WeakMap;function Yn(e,t){const o={onItems:[],offItems:[]},n=t||Number(e.value||0);for(let t=0;t<e.props.max;t++)if(t<n&&t+1>=n){const r=e.props.rightToLeft?100-100*(n-t):100*(n-t);o.onItems.push(r+"%"),o.offItems.push(100-r+"%")}else t<n?(o.offItems.push("0%"),o.onItems.push("100%")):t>=n&&(o.offItems.push("100%"),o.onItems.push("0%"));e.props.itemsToPercentages=o}function jn(e,t){var o;null===(o=e.context)||void 0===o||o.handlers.blur(t)}function zn(e,t){const{x:o,y:n}=or(t);let r=document.elementFromPoint(o,n);const s=Array.from(document.querySelectorAll(`#${e.props.id}_items_wrapper > .formkit-ratingItem`));let a=!0;for(;r&&a;){if(s.includes(r)){a=!1;break}r=r.parentNode}if(!a){const t=s.indexOf(r);if(1===e.props.step)return void e.input(t+1,!1)}}function Zn(e,t,o){e.props.disabled||(o.preventDefault(),e.props.hoverHighlight=!0,e.props.touchStarted=!0,1!==e.props.step?nr(e,t,o):e.input(t+1,!1))}function qn(e,t){if(!e.props.dragStarted)return;t.preventDefault(),e.props.hoverHighlight=!1,e.props.dragStarted=!1,Yn(e);const o=Un.get(e);o&&(o.abort(),Un.delete(e))}function Gn(e,t,o){if(e.props.hoverHighlight||e.props.disabled)return;o.preventDefault(),e.props.hoverHighlight=!0,e.props.dragStarted=!0;const n=new AbortController;document.addEventListener("mouseup",(t=>qn(e,t)),{signal:n.signal}),Un.set(e,n),1===e.props.step?e.input(t+1,!1):nr(e,t,o)}function Xn(e,t){var o,n;if(document.activeElement===t.currentTarget)if("ArrowRight"===t.key||"ArrowDown"===t.key){e.props.arrow=1;const t=e.value?rr(e.value+1*e.props.step,e.props.step):e.props.min+1*e.props.step,n=null===(o=e.props.__root)||void 0===o?void 0:o.querySelector(e.value?`#${e.props.id}_inner input[value="${t}"]`:"#"+(e.props.id+"_0_0"));e.props.preventFocus=!0,n&&n instanceof HTMLInputElement&&n.focus(),e.props.preventFocus=!1,e.input(Number(t))}else if("ArrowLeft"===t.key||"ArrowUp"===t.key){e.props.arrow=-1;const t=e.value?rr(e.value-1*e.props.step,e.props.step):e.props.max,o=null===(n=e.props.__root)||void 0===n?void 0:n.querySelector(`#${e.props.id}_inner input[value="${t}"]`);e.props.preventFocus=!0,o&&o instanceof HTMLInputElement&&o.focus(),e.props.preventFocus=!0,e.input(Number(t)),e.props.preventFocus=!1}}function Jn(e,t){if(!e.props.preventFocus)if(e.props.preventFocus=!0,setTimeout((()=>{e.props.preventFocus=!1}),50),t.relatedTarget instanceof HTMLElement&&t.relatedTarget.id===e.props.id+"_items_wrapper")e.props.arrow>0?setTimeout((()=>{var t,o;null===(o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(e.props.id+"_0_0"))||void 0===o||o.focus()})):e.props.arrow<0&&setTimeout((()=>{var t,o;null===(o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(e.props.id+`_${e.props.max-1}_${e.props.stepsPerValue-1}`))||void 0===o||o.focus()}));else if(t.target instanceof HTMLInputElement){if(Number(t.target.value)===e.props.step&&e.value===e.props.max||Number(t.target.value)===e.props.max&&e.value===e.props.step){const t=document.getElementById(e.props.id+"_items_wrapper");return null==t||t.focus(),void e.input(0)}e.input(Number(t.target.value))}}function Qn(e,t,o){e.props.hoverHighlight&&(e.props.disabled||(1===e.props.step?(Yn(e,t+1),e.props.dragStarted&&e.input(t+1,!1)):nr(e,t,o,!!e.props.dragStarted)))}function er(e){Yn(e)}function tr(e,t,o){if(!e.props.disabled&&"touchstart"!==o.type&&(o.preventDefault(),(0!==o.clientX||0!==o.clientY)&&o.currentTarget instanceof HTMLElement))return 1===e.props.step?e.props.deselect&&Number(e.value)===t+1?void e.input(0):void e.input(t+1):void nr(e,t,o)}function or(e){return e instanceof MouseEvent?{x:e.clientX,y:e.clientY}:{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY}}function nr(e,t,o,n=!0){if(!(o.currentTarget instanceof HTMLElement))return;const{x:r,y:s}=or(o),a=o.currentTarget.getBoundingClientRect();let l=rr((r-a.x)/a.width+t,e.props.step);l=l>e.props.min?l:e.props.min,l=l<e.props.max?l:e.props.max,!e.props.deselect||l!==Number(e.value)||e.props.dragStarted?n?e.input(l,!1):Yn(e,l):e.input(0)}function rr(e,t){t||(t=1);const o=1/t;return Math.ceil(e*o)/o}const sr=/* #__PURE__ */Fe("rt"),{outer:ar,wrapper:lr,inner:pr,label:ir,prefix:dr,suffix:cr,help:ur,messages:fr,message:vr,icon:hr}=/* #__PURE__ */Be(sr),mr=sr("itemsWrapper",(()=>({$el:"span",attrs:{style:{"flex-direction":'$rightToLeft && "row-reverse" || undefined'},tabindex:"$value !== undefined && $value !== 0 && '-1' || '0'",id:"$id + _items_wrapper",onKeydown:"$handlers.handleWrapperKeydown","data-disabled":"$disabled",onBlur:"$handlers.handleWrapperBlur",onMouseleave:"$hoverHighlight && $handlers.handleMouseleave"}}))),$r=sr("ratingItem",(()=>({for:["item","index","$max"],$el:"span",attrs:{id:'$id + "_item_" + $index',onClick:"$handlers.handleItemClick($item)",draggable:"$hoverHighlight !== true && && $disabled !== true && true",onMousemove:"$handlers.handleMousemove($item)",onDragstart:"$handlers.handleDragstart($item)",onDragend:"$handlers.handleDragend",onTouchstart:"$handlers.handleTouchstart($item)",onTouchmove:"$handlers.handleTouchmove"}}))),gr=sr("template",(()=>({for:["increment","stepIndex","$stepsPerValue"],$el:null}))),br=sr("itemLabel",(()=>({$el:"label",attrs:{id:'$id + "_label_" + $index + "_" + $stepIndex',for:'$id + "_" + $index + "_" + $stepIndex',"data-checked":'$value === $fns.getValue($item, $increment) && "true" || "false"',style:{width:'$fns.showLabel($fns.getValue($item, $increment), $stepIndex, $item) && "100%" || "0%"'}}}))),yr=sr("itemLabelInner",(()=>({$el:"span",children:"$fns.getValue($item, $increment)"}))),xr=sr("input",(()=>({$el:"input",attrs:{type:"radio",value:"$fns.getValue($item, $increment)",id:'$id + "_" + $index + "_" + $stepIndex',onFocus:"$handlers.handleFocus",tabindex:'$value === $fns.getValue($item, $increment) && "0" || "-1"',disabled:"$disabled",name:"$id","data-value":"$fns.getValue($item, $increment)",checked:"$value === $fns.getValue($item, $increment) && true",onKeydown:"$handlers.handleKeydown($fns.getValue($item, $increment))"}}))),wr=sr("onItemRow",(()=>({$el:"span",attrs:{style:{width:"$fns.getPercentage($itemsToPercentages, $item)",display:"flex",position:"relative",overflow:"hidden",top:"0",left:"0",bottom:"0"}}}))),_r=sr("offItemRow",(()=>({$el:"span",attrs:{style:{width:"$fns.getPercentage($itemsToPercentages, $item, false)",display:"flex","flex-direction":"row-reverse",position:"absolute",zIndex:"$offItemStyles && 100",overflow:"hidden",top:"0",right:"0"}}}))),kr=sr("onItemWrapper",(()=>({$el:"div",attrs:{style:{color:"$onColor"}}}))),Sr=sr("offItemWrapper",(()=>({$el:"div",attrs:{style:{color:"$offColor"}}}))),Lr=()=>He("$slots.onItem",(()=>()=>"$slots.onItem"),He("$slots.default",(()=>()=>"$slots.default"),hr("rating"))),Ir=()=>He("$slots.offItem",(()=>()=>"$slots.offItem"),He("$slots.default",(()=>()=>"$slots.default"),hr("rating"))),Ar={schema:/* #__PURE__ */ar(/* #__PURE__ */lr(/* #__PURE__ */ir("$label"),/* #__PURE__ */pr(/* #__PURE__ */hr("prefix"),/* #__PURE__ */dr(),/* #__PURE__ */mr(/* #__PURE__ */$r(/* #__PURE__ */gr(/* #__PURE__ */br(/* #__PURE__ */wr(/* #__PURE__ */kr(/* #__PURE__ */Lr())),/* #__PURE__ */_r(/* #__PURE__ */Sr(/* #__PURE__ */Ir())),/* #__PURE__ */yr()),/* #__PURE__ */xr()))),/* #__PURE__ */cr(),/* #__PURE__ */hr("suffix"))),/* #__PURE__ */ur("$help"),/* #__PURE__ */fr(/* #__PURE__ */vr("$message.value"))),type:"input",props:[],features:[function(e){function t(e){setTimeout((()=>{const t=Array.from(document.querySelectorAll(`#${e.props.id}_items_wrapper > .formkit-ratingItem`));for(let e=0;e<t.length;e++){const o=t[e].querySelectorAll(".formkit-onItemWrapper"),n=t[e].querySelectorAll(".formkit-offItemWrapper");for(let n=0;n<o.length;n++)o[n].style.flex=`0 0 ${t[e].getBoundingClientRect().width}px`;for(let o=0;o<n.length;o++)n[o].style.flex=`0 0 ${t[e].getBoundingClientRect().width}px`}}))}e.addProps(["max","step","stepsPerValue","itemsToPercentages","rightToLeft","onItemStyles","offItemStyles","hoverHighlight","deselect","disabled","wrapperWidth","onColor","offColor"]),!1!==e.props.hoverHighlight&&"false"!==e.props.hoverHighlight&&(e.props.hoverHighlight=!0),e.props.deselect=r(e.props.deselect),e.props.max=Number(e.props.max)||5,e.props.min=Number(e.props.min)||0,e.props.step=Number(e.props.step)||1,e.props.numberOfSteps=e.props.max/e.props.step,e.props.lastIndex=1/e.props.step-1,e.props.itemsToPercentages={},"disabled"in e.props&&(e.props.disabled=r(e.props.disabled)),e.props.rightToLeft?(e.props.onItemStyles=void 0,e.props.offItemStyles={position:"absolute",top:"0",left:"0",overflow:"hidden",height:"100%",zIndex:100}):e.props.onItemStyles={position:"absolute",top:"0",left:"0",overflow:"hidden",height:"100%"},e.props.stepsPerValue=1/e.props.step,e.hook.input(((t,o)=>{if(null===t||""===t||isNaN(t))return o(t);const n=Number(t),r=Number(e.props.min),s=Number(e.props.max);return n>s?o(s):e.props.min&&n<=r?o(r):o(n)})),e.on("commit",(({payload:t})=>{const o=Number(t||0);Yn(e,o)})),e.on("created",(()=>{e.context&&(s(`${e.props.id}_items_wrapper`,(()=>{t(e),function(e){var o;const n=null===(o=e.props.__root)||void 0===o?void 0:o.getElementById(`${e.props.id}_items_wrapper`);if(!n)return;new ResizeObserver((()=>{t(e)})).observe(n)}(e),setTimeout((()=>t(e)),100)}),e.props.__root),e.context.fns.getPercentage=(e,t,o=!0)=>(o?e.onItems:e.offItems)[t],e.context.fns.getValue=(t,o)=>t+Number((o*e.props.step+e.props.step).toFixed(1)),e.context.fns.showLabel=(t,o)=>{const n=Number(e.value||0);return 0===n&&0===o||n&&t===n||t>n&&0===o||n>t&&o===e.props.lastIndex},e.context.handlers.handleFocus=t=>Jn.call(null,e,t),e.context.handlers.handleWrapperKeydown=t=>Xn.call(null,e,t),e.context.handlers.handleWrapperBlur=t=>jn.call(null,e,t),e.context.handlers.handleItemClick=t=>o=>tr.call(null,e,t,o),e.context.handlers.handleMousemove=t=>o=>Qn.call(null,e,t,o),e.context.handlers.handleMouseleave=()=>er.call(null,e),e.context.handlers.handleDragstart=t=>o=>Gn.call(null,e,t,o),e.context.handlers.handleMouseup=t=>qn.call(null,e,t),e.context.handlers.handleTouchstart=t=>o=>Zn.call(null,e,t,o),e.context.handlers.handleTouchmove=t=>zn.call(null,e,t),e.context.handlers.handleKeydown=t=>o=>function(e,t,o){const n=Number(e.value);e.props.deselect&&" "===o.key&&n===t?e.input(0):" "===o.key&&e.input(t)}(e,t,o))}))},/* #__PURE__ */$("rating","star")]},Cr=/* #__PURE__ */Fe("ac"),{outer:Dr,wrapper:Tr,inner:Er,icon:Or,label:Mr,prefix:Vr,suffix:Fr,help:Br,messages:Pr,message:Hr}=/* #__PURE__ */Be(Cr),Rr=Cr("input",(()=>({$el:"input",bind:"$attrs",attrs:{id:"$id",type:"text",onClick:"$handlers.click",onBlur:"$handlers.blur",onKeydown:"$handlers.keydown",onInput:"$handlers.input",onFocus:"$handlers.focus",value:"$inputText || undefined",name:"$node.name",placeholder:"$state.loading && $ui.isLoading.value || $placeholder || undefined",tabindex:'$disabled && "-1" || 0',role:"combobox",autocomplete:'$attrs.autocomplete || "off"',autocapitalize:"none",readonly:"$attrs.readonly || $state.loading || $multiple && $max && $value && $value.length >= $max && $hasHighlightedRange !== true || undefined","data-selection-appearance":"$selectionAppearance",disabled:"$disabled || $disabledInternally || undefined",onTouchmove:"$handlers.touchmove",onTouchstart:"$handlers.touchmove",onTouchend:"$handlers.touchend","aria-autocomplete":"list","aria-expanded":"$expanded","aria-controls":'$expanded && $id + "_listbox" || undefined',"aria-describedBy":"$describedBy","aria-activedescendant":"$expanded && $activeDescendant || undefined"}}))),Kr=Cr("listboxButton",(()=>({$el:"div",attrs:{style:"$visibilityStyles",id:'$id + "_listbox_button"',role:"button","aria-label":"$expanded && $ui.close.value || $ui.open.value",onClick:"$handlers.toggleListbox",onKeydown:"$handlers.toggleListboxKeydown",tabindex:'$disabled && "-1" || 0',"aria-haspopup":"true","aria-expanded":"$expanded","aria-controls":'$expanded && $id + "_listbox" || undefined',"aria-disabled":"$disabled || $state.loading || undefined","data-disabled":"$disabled || $disabledInternally || undefined"}}))),Nr=Cr("selectionWrapper",(()=>({for:["option","index","$selections"],$el:"div",attrs:{id:'$id + "_selection_wrapper_" + $index',key:"$option.value","data-value":"$option.value",tabindex:'$disabled && "-1" || 0',onKeydown:"$handlers.selectionKeydown && $handlers.selectionKeydown($multiple && $option || undefined)",onClick:"$handlers.selectionClick && $handlers.selectionClick($multiple && $option || undefined)",onFocus:"$handlers.selectionFocus && $handlers.selectionFocus($multiple && $option || undefined)",onBlur:"$handlers.selectionBlur && $handlers.selectionBlur($multiple && $option || undefined)","data-is-selection":"true","data-active-selection":"$fns.isActiveSelection && $fns.isActiveSelection($activeSelectionValue, $option)"}}))),Wr=Cr("selection",(()=>({$el:"div",attrs:{id:'$id + "_selection_" + $index'}}))),Ur=Cr("selections",(()=>({$el:"div",attrs:{"aria-live":"polite",id:'$id + "_selections"'}}))),Yr=Cr("removeSelection",(()=>({$el:"button",attrs:{id:'$selectionAppearance === "option" && $multiple && $id + "_remove_selection_" + $index || $id + "_remove_selection"',tabindex:"0",title:"$ui.remove.value",type:"button","aria-label":"$ui.remove.value",onClick:"$handlers.removeSelection && $handlers.removeSelection($multiple && $option || undefined)",onTouchend:"$handlers.removeSelection && $handlers.removeSelection($multiple && $option || undefined)","aria-controls":"$id"}}))),jr=Cr("optionLoading","span"),zr=Cr("option",(()=>({$el:"div",if:"$value !== undefined"}))),Zr=/* #__PURE__ */Re(Cr);function qr(e){"option"!==e.props.selectionAppearance||e.props.multiple||!1===e.props.selectionRemovable||"false"===e.props.selectionRemovable||(e.props.selectionRemovable=!0),e.props.multiple||(e.props.clearSearchOnOpen=r(e.props.clearSearchOnOpen)),e.props.selectionRemovable=r(e.props.selectionRemovable),e.props.openOnClick=r(e.props.openOnClick),"option"!==e.props.selectionAppearance||e.props.multiple||(e.props.isSingleOption=!0),void 0===e.props.closeOnSelect&&(e.props.closeOnSelect=!0),void 0===e.props.selectionAppearance&&(e.props.selectionAppearance="text-input"),void 0===e.props.closeOnSelect&&(e.props.closeOnSelect=!0),e.props.closeOnSelect?e.props.resetSearchOnCommit=!1:void 0===e.props.resetSearchOnCommit&&(e.props.resetSearchOnCommit=e.props.multiple),e.props.allowNewValues=r(e.props.allowNewValues)}function Gr(e){e.addProps(["inputText","selectionAppearance","searchValue","openOnClick","filteredOptions","search","debounce","showInput","visibilityStyles","selectionStyles","multiple","filter","hasHighlightedRange","clearOnClick","debounce"]),void 0===e.props.debounce?e.props.debounce=200:e.props.debounce=parseInt(e.props.debounce),e.props.nonceKey="searchValue",e.props.searchValue="",e.props.inputText="",e.props.filterOptions=wt.bind(null,e),e.props.reloadOnCommit=r(e.props.reloadOnCommit),void 0===e.props.alwaysLoadOnOpen?e.props.alwaysLoadOnOpen=!0:e.props.alwaysLoadOnOpen=r(e.props.alwaysLoadOnOpen),"function"!=typeof e.props.filter&&(e.props.filter=(e,t)=>e.label.toLowerCase().includes(t.toLowerCase())),e.on("created",(()=>{e.context&&re&&(e.context.handlers.focus=Qr.bind(null,e),e.context.handlers.input=Xr.bind(null,e),e.context.handlers.focus=Qr.bind(null,e),e.context.handlers.click=Jr.bind(null,e),e.context.handlers.toggleListbox=es.bind(null,e),e.context.handlers.toggleListboxKeydown=ts.bind(null,e),e.context.handlers.keydown=yo.bind(null,e),e.context.handlers.selectionKeydown=t=>o=>go(e,t,o),e.context.handlers.searchInputTagKeydown=t=>o=>function(e,t,o){if(o.stopPropagation(),e.props.disabled)return;switch(o.key){case"ArrowDown":uo(e);break;case"ArrowRight":case"ArrowLeft":fo(e,t,o);break;case"Delete":case"Backspace":vo(e,t,o)}}(e,t,o),e.on("prop:options",(({payload:t})=>{if((0===e.props.initialOptions.length&&"function"!=typeof e.props.optionsLoader||!e.props.searchValue&&t.length)&&(e.props.initialOptions=[...t]),e.props.selections&&e.props.selections.length&&t.length)for(let o=0;o<e.props.selections.length;o++){const n=e.props.selections[o],r=t.find((e=>bt(e)===n.value));r&&(e.props.selections[o]=r)}})))})),e.on("prop:expanded",(({payload:t})=>{t||yt.delete(e)}))}function Xr(e,t){if(e.props.disabled)return;const o=t.target;e.props.inputText=o.value,e.emit("handleSearchInput",o.value),e.props.searchValue&&wt(e,e.props.searchValue,!0)}function Jr(e,t){t.stopPropagation(),e.props.disabled||e.props.disabledInternally||(e.props.attrs.onClick&&e.props.attrs.onClick(t),(!e.props.expanded&&e.props.openOnClick||e.props.openOnFocus)&&(e.props.expanded=!0))}function Qr(e){e.props.disabled||e.props.disabledInternally||(e.props.attrs.onFocus&&e.props.attrs.onFocus(),e.props.activeSelectionValue=void 0,e.props.skipOpen?e.props.skipOpen=!1:e.props.openOnFocus&&(e.props.expanded=!0))}function es(e){var t,o,n;e.props.disabled||e.props.disabledInternally||(null===(t=e.context)||void 0===t?void 0:t.state.loading)||(e.props.expanded=!e.props.expanded,e.props.openOnFocus||null===(n=null===(o=e.props.__root)||void 0===o?void 0:o.getElementById(`${e.props.id}`))||void 0===n||n.focus())}function ts(e,t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),es(e))}const os=new WeakMap,ns="undefined"!=typeof window,rs=new WeakMap;let ss=!1;function as(e){e.props.searchValue=null,e.on("commit",(()=>{e.props.searchValue=null,e.props.highlightedRange||ls(e)})),e.on("created",(()=>{if(!e.context||!ns)return;e.on("handleSearchInput",(({payload:t})=>{""===t?(e.props.searchValue=null,e.input([])):t&&0===e.props.inputStd.length?e.props.searchValue=t:t&&e.props.inputStd.length>0&&(e.props.searchValue=function(e){var t;const o=is(e);if(e.props.highlightedRange){const[t,n]=ps(e,o);return e.props.inputText.slice(t,n)}return e.props.inputText.slice((null===(t=o[o.length-1])||void 0===t?void 0:t.end)+2)}(e)),!e.props.expanded&&t?e.props.expanded=!0:!t&&e.props.expanded&&(e.props.expanded=!1)})),function(e){s(`${e.props.id}`,(t=>{t instanceof HTMLInputElement&&rs.set(t,e)}),e.props.__root),ns&&!ss&&(ss=!0,document.addEventListener("selectionchange",(()=>{const e=gt();if(e instanceof HTMLInputElement&&rs.has(e)){const t=rs.get(e);t&&function(e){clearTimeout(os.get(e)),os.set(e,setTimeout((()=>{var t,o,n,r;const s=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}`);if(s instanceof HTMLInputElement){const t=is(e),a=t.findIndex((e=>null!==s.selectionStart?s.selectionStart>=e.start&&s.selectionStart<=e.end:null!==s.selectionEnd&&(s.selectionEnd>=e.start&&s.selectionEnd<=e.end))),l=null===(o=t[t.length-1])||void 0===o?void 0:o.end;if(0===s.selectionStart&&s.selectionEnd===(null===(n=e.props.inputText)||void 0===n?void 0:n.length))return;if("string"==typeof e.props.searchValue&&e.props.highlightedRange){if(t.length){const o=e.props.highlightedRange,[n,r]=ps(e,t);if(null!==s.selectionEnd&&(s.selectionEnd<n||s.selectionEnd>r)){const t=o.end-o.start-(r-n),a=s.selectionEnd;e.props.inputText=e.props.option.label,e.props.highlightedRange=void 0,e.props.searchValue=null,s.value=e.props.inputText,s.selectionStart=s.selectionEnd=a+(a>n?t:0)}}}else if(a>=0&&null!==s.selectionStart&&(l!==(null===(r=e.props.inputText)||void 0===r?void 0:r.length)||s.selectionStart<l)){const o=t[a],n=e.props.inputText.substr(0,l),r=o.start+(o.index>0?1:0),p=o.end+(t.length-1>o.index?-1:0);n!==e.props.inputText&&(e.props.inputText=n,s.value=n),e.props.highlightedRange=o,s.selectionStart=r,s.selectionEnd=p}else e.props.highlightedRange=void 0,ls(e);if(null!==s.selectionStart&&s.selectionStart>=l&&", "!==e.props.inputText.substring(l,l+2)){let t=e.props.inputText.substring(0,l);t=e.props.multiple&&e.props.max&&Array.isArray(e.props.inputStd)&&e.props.inputStd.length>=e.props.max?t:`${t},`,e.props.inputText=`${t} ${e.props.inputText.substring(l).replace(/^[,\s]{1,2}/,"")}`}}}),5))}(t)}})))}(e);const o=e.context.handlers.keydown;e.context.handlers.keydown=n=>{o(n),function(e,o){var n,r,s,a;if(["ArrowRight","ArrowLeft"].includes(o.key)&&o.target instanceof HTMLInputElement&&null!==o.target.selectionEnd&&null!==o.target.selectionStart){if(0===o.target.selectionStart&&o.target.selectionEnd===(null===(n=e.props.inputText)||void 0===n?void 0:n.length))"ArrowLeft"===o.key?t(0):t(-1);else if(!e.props.searchValue){e.props.searchValue=null;const t=is(e),n=null===(r=t[t.length-1])||void 0===r?void 0:r.end;o.target.selectionStart<n&&(o.target.selectionStart=Math.max(0,"ArrowLeft"===o.key?o.target.selectionStart-2:o.target.selectionEnd+2))}}else if(["Delete","Backspace"].includes(o.key))e.props.highlightedRange&&!e.props.searchValue?(Ot(e,e.props.highlightedRange.option),0===e.props.inputStd.length&&(e.props.highlightedRange=void 0)):o.target instanceof HTMLInputElement&&(e.props.searchValue=null,t(-1,!0)&&o.preventDefault());else if(o.target instanceof HTMLInputElement&&0===o.target.selectionStart&&o.target.selectionEnd===(null===(s=e.props.inputText)||void 0===s?void 0:s.length)&&(null===(a=e.props.inputText)||void 0===a?void 0:a.length)&&0===e.props.selections.length)o.preventDefault();else if("Tab"===o.key)return;"ArrowLeft"===o.key&&t(-1,!0)&&o.preventDefault()}(e,n)};const n=e.context.handlers.focus;e.context.handlers.focus=t=>{n(e,t);const o=new Event("selectionchange");document.dispatchEvent(o)},e.on("blur",(()=>{e.props.selections.length?(e.props.inputText=e.props.selections.map((e=>e.label)).join(", "),e.props.searchValue=null):e.props.selections.length||(e.props.inputText="",e.props.searchValue="")}))})),e.on("prop:expanded",(({payload:t})=>{t||e.props.inputStd.length?t&&(e.props.options.length&&!e.props.alwaysLoadOnOpen||(e.props.options=[],wt(e,e.props.searchValue))):(e.props.searchValue="",e.props.inputText="")})),e.on("prop:selections",(()=>{var t;const o=[...e.props.selections].map((e=>e.label)).join(", ");let n="";if(ns&&e.isCreated){const o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}`);if(null==o||o.focus(),gt()===o&&Array.isArray(e._value)&&e._value.length){if(e.props.max&&e._value.length>=Number(e.props.max))return;n=", "}}e.props.inputText=`${o}${n}`,e.props.reloadOnCommit&&(e.props.searchValue="",wt(e,e.props.searchValue))}));const t=(t,o=!1)=>{var n,r;const s=null===(n=e.props.__root)||void 0===n?void 0:n.getElementById(`${e.props.id}`);if(!(s instanceof HTMLInputElement))return!1;const a=is(e),l=t>=0?t:a.length-1;if(void 0===a[l])return!1;const p=null===(r=a[l])||void 0===r?void 0:r.end;return null!==s.selectionStart&&(!o||s.selectionStart>=p&&s.selectionStart<=p+2)&&(s.selectionStart=a[l].start+(l>0?1:0),s.selectionEnd=a[l].end+(l<a.length-1?-1:0),!0)};let o;e.on("selectRange",(({payload:e})=>t(...e))),e.on("prop:highlightedRange",(({payload:t})=>{e.props.hasHighlightedRange=!!t,t&&e.props.expanded&&o!==t.option&&(o=t.option,Vt(e))}))}function ls(e){var t;if(!ns)return;const o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}`);o&&o.scrollTo({left:o.scrollWidth,behavior:"smooth"})}function ps(e,t){var o;const n=e.props.highlightedRange,r=n.index,s=n.start+(r?1:0),a=t.length-1>r?t[t.length-1].end-t[r+1].start:0;return[s,(null===(o=e.props.inputText)||void 0===o?void 0:o.length)-a+(t.length-1>n.index?-1:0)]}function is(e){const t=Et(e);return Array.isArray(t)&&t.length?t.reduce(((e,o,n)=>{var r;const s=(null===(r=e[n-1])||void 0===r?void 0:r.end)||0;let a=0;return t.length-1!==n&&a++,0!==n&&a++,e.push({option:o,index:n,start:s,end:s+o.label.length+a}),e}),[]):[]}function ds(e){!function(e){e.on("prop:expanded",(({payload:t})=>{t?(e.props.searchValue="",e.props.options.length&&!e.props.alwaysLoadOnOpen||(e.props.options=[],wt(e,e.props.searchValue,!0))):(e.props.searchValue="",e.props.inputText="")}))}(e),function(e){e.on("handleSearchInput",(({payload:t})=>{t&&!e.props.expanded?(e.props.searchExpand=!0,e.props.expanded=!0):!t&&e.props.expanded&&(e.props.expanded=!1),e.props.searchValue=e.props.inputText}))}(e),function(e){e.on("prop:selections",(()=>{e.isCreated&&(e.props.inputText="",e.props.searchValue="",e.props.optionRemoved||e.props.reloadOnCommit&&wt(e,e.props.searchValue,!0))}))}(e)}function cs(e){!function(e){function t(e){0===e.props.inputStd.length?(e.props.inputText="",e.props.searchValue=""):(e.props.inputText=e.props.selections[0].label,e.props.searchValue=e.props.selections[0].label)}function o(e){e.props.clearSearchOnOpen&&!e.props.searchExpand&&(e.props.inputText="",e.props.searchValue=""),e.props.searchValue=e.props.inputText,e.props.options.length&&!e.props.alwaysLoadOnOpen||e.props.searchExpand||(e.props.options=[],wt(e,e.props.searchValue,!0)),e.props.searchExpand&&(e.props.searchExpand=!1)}e.on("prop:expanded",(({payload:n})=>{n?o(e):t(e)}))}(e),function(e){e.on("handleSearchInput",(({payload:t})=>{""===t?(0===e.props.inputStd.length&&(e.props.expanded=!1),e.input(void 0)):t&&!e.props.expanded&&(e.props.searchExpand=!0,e.props.expanded=!0),e.props.searchValue=e.props.inputText}))}(e),function(e){e.on("prop:selections",(({payload:t})=>{e.props.inputText=t.length?t[0].label:"",e.props.searchValue=t.length?t[0].label:"",e.isCreated&&e.props.expanded&&0===t.length&&wt(e,e.props.searchValue,!0)}))}(e)}function us(e){if(e.props.multiple)if(e.props.multiple&&"option"===e.props.selectionAppearance){function t(){return Array.isArray(e.value)?e.value:[]}function o(t){e.input(t)}ds(e),e.on("created",(()=>{e.props.disabled&&(e.props.draggable=!1),s(`${e.props.id}_selections`,(n=>{if(n instanceof HTMLElement&&e.context){const r={draggingClass:e.context.classes.dragging,dropZoneClass:e.context.classes.dropZone,root:e.props.__root,disabled:!e.props.draggable,plugins:[x()],touchDraggingClass:e.context.classes.touchDragging,touchDropZoneClass:e.context.classes.touchDropZone,draggable:e=>e.hasAttribute("data-is-selection")};w({parent:n,getValues:t,setValues:o,config:r}),e.on("prop:disabled",(({payload:e})=>{r.disabled=e,w({parent:n,getValues:t,setValues:o,config:r})})),e.on("prop:draggable",(({payload:e})=>{r.disabled=!e,w({parent:n,getValues:t,setValues:o,config:r})}))}}),e.props.__root)}))}else e.props.multiple&&"text-input"===e.props.selectionAppearance&&as(e);else cs(e)}const fs={schema:/* #__PURE__ */Dr(/* #__PURE__ */Tr(/* #__PURE__ */Mr("$label"),/* #__PURE__ */Er(/* #__PURE__ */Or("prefix"),/* #__PURE__ */Vr(),/* #__PURE__ */Rr(),/* #__PURE__ */He("$multiple !== true && $selectionAppearance === option && $expanded === false",/* #__PURE__ */Ur(/* #__PURE__ */Nr(/* #__PURE__ */Wr(/* #__PURE__ */zr(/* #__PURE__ */He("$state.loading",/* #__PURE__ */jr("$ui.isLoading.value"),"$option.label"))),/* #__PURE__ */He("$state.loading && $isSingleOption !== true && $optionLoaderValues.includes($option.value)",/* #__PURE__ */Or("loader")),/* #__PURE__ */He("$selectionRemovable && $isSingleOption",/* #__PURE__ */Yr(/* #__PURE__ */Or("close")))))),/* #__PURE__ */He("$state.loading && ($isSingleOption !== true || $selections.length === 0)",/* #__PURE__ */Or("loader")),/* #__PURE__ */He('$selectionRemovable && $selectionAppearance === "text-input" && $selections.length > 0',/* #__PURE__ */Yr(/* #__PURE__ */Or("close")),/* #__PURE__ */He('$selectionAppearance === "text-input" || ($selectionAppearance === "option" && $multiple)',/* #__PURE__ */Kr(/* #__PURE__ */Or("select")))),/* #__PURE__ */He("$isSingleOption && ($inputStd.length === 0 || $selectionRemovable === undefined || ($expanded) || $state.loading || $optionLoaderValues.length > 0)",/* #__PURE__ */Kr(/* #__PURE__ */Or("select"))),/* #__PURE__ */Zr(),/* #__PURE__ */Fr(),/* #__PURE__ */Or("suffix")),/* #__PURE__ */He("$multiple && $selectionAppearance === option",/* #__PURE__ */Ur(/* #__PURE__ */Nr(/* #__PURE__ */Wr(/* #__PURE__ */zr(/* #__PURE__ */He("$state.loading && $isLoadingOption",/* #__PURE__ */jr("$ui.isLoading.value"),"$option.label"))),/* #__PURE__ */Yr(/* #__PURE__ */Or("close")))))),/* #__PURE__ */Br("$help"),/* #__PURE__ */Pr(/* #__PURE__ */Hr("$message.value"))),type:"input",family:"dropdown",props:[],features:[
19
+ /* #__PURE__ */$("moveDown","arrowDown")]},Un=new WeakMap;function Yn(e,t){const o={onItems:[],offItems:[]},n=t||Number(e.value||0);for(let t=0;t<e.props.max;t++)if(t<n&&t+1>=n){const r=e.props.rightToLeft?100-100*(n-t):100*(n-t);o.onItems.push(r+"%"),o.offItems.push(100-r+"%")}else t<n?(o.offItems.push("0%"),o.onItems.push("100%")):t>=n&&(o.offItems.push("100%"),o.onItems.push("0%"));e.props.itemsToPercentages=o}function jn(e,t){var o;null===(o=e.context)||void 0===o||o.handlers.blur(t)}function zn(e,t){const{x:o,y:n}=or(t);let r=document.elementFromPoint(o,n);const s=Array.from(document.querySelectorAll(`#${e.props.id}_items_wrapper > .formkit-ratingItem`));let a=!0;for(;r&&a;){if(s.includes(r)){a=!1;break}r=r.parentNode}if(!a){const t=s.indexOf(r);if(1===e.props.step)return void e.input(t+1,!1)}}function Zn(e,t,o){e.props.disabled||(o.preventDefault(),e.props.hoverHighlight=!0,e.props.touchStarted=!0,1!==e.props.step?nr(e,t,o):e.input(t+1,!1))}function qn(e,t){if(!e.props.dragStarted)return;t.preventDefault(),e.props.hoverHighlight=!1,e.props.dragStarted=!1,Yn(e);const o=Un.get(e);o&&(o.abort(),Un.delete(e))}function Gn(e,t,o){if(e.props.hoverHighlight||e.props.disabled)return;o.preventDefault(),e.props.hoverHighlight=!0,e.props.dragStarted=!0;const n=new AbortController;document.addEventListener("mouseup",(t=>qn(e,t)),{signal:n.signal}),Un.set(e,n),1===e.props.step?e.input(t+1,!1):nr(e,t,o)}function Xn(e,t){var o,n;if(document.activeElement===t.currentTarget)if("ArrowRight"===t.key||"ArrowDown"===t.key){e.props.arrow=1;const t=e.value?rr(e.value+1*e.props.step,e.props.step):e.props.min+1*e.props.step,n=null===(o=e.props.__root)||void 0===o?void 0:o.querySelector(e.value?`#${e.props.id}_inner input[value="${t}"]`:"#"+(e.props.id+"_0_0"));e.props.preventFocus=!0,n&&n instanceof HTMLInputElement&&n.focus(),e.props.preventFocus=!1,e.input(Number(t))}else if("ArrowLeft"===t.key||"ArrowUp"===t.key){e.props.arrow=-1;const t=e.value?rr(e.value-1*e.props.step,e.props.step):e.props.max,o=null===(n=e.props.__root)||void 0===n?void 0:n.querySelector(`#${e.props.id}_inner input[value="${t}"]`);e.props.preventFocus=!0,o&&o instanceof HTMLInputElement&&o.focus(),e.props.preventFocus=!0,e.input(Number(t)),e.props.preventFocus=!1}}function Jn(e,t){if(!e.props.preventFocus)if(e.props.preventFocus=!0,setTimeout((()=>{e.props.preventFocus=!1}),50),t.relatedTarget instanceof HTMLElement&&t.relatedTarget.id===e.props.id+"_items_wrapper")e.props.arrow>0?setTimeout((()=>{var t,o;null===(o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(e.props.id+"_0_0"))||void 0===o||o.focus()})):e.props.arrow<0&&setTimeout((()=>{var t,o;null===(o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(e.props.id+`_${e.props.max-1}_${e.props.stepsPerValue-1}`))||void 0===o||o.focus()}));else if(t.target instanceof HTMLInputElement){if(Number(t.target.value)===e.props.step&&e.value===e.props.max||Number(t.target.value)===e.props.max&&e.value===e.props.step){const t=document.getElementById(e.props.id+"_items_wrapper");return null==t||t.focus(),void e.input(0)}e.input(Number(t.target.value))}}function Qn(e,t,o){e.props.hoverHighlight&&(e.props.disabled||(1===e.props.step?(Yn(e,t+1),e.props.dragStarted&&e.input(t+1,!1)):nr(e,t,o,!!e.props.dragStarted)))}function er(e){Yn(e)}function tr(e,t,o){if(!e.props.disabled&&"touchstart"!==o.type&&(o.preventDefault(),(0!==o.clientX||0!==o.clientY)&&o.currentTarget instanceof HTMLElement))return 1===e.props.step?e.props.deselect&&Number(e.value)===t+1?void e.input(0):void e.input(t+1):void nr(e,t,o)}function or(e){return e instanceof MouseEvent?{x:e.clientX,y:e.clientY}:{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY}}function nr(e,t,o,n=!0){if(!(o.currentTarget instanceof HTMLElement))return;const{x:r,y:s}=or(o),a=o.currentTarget.getBoundingClientRect();let l=rr((r-a.x)/a.width+t,e.props.step);l=l>e.props.min?l:e.props.min,l=l<e.props.max?l:e.props.max,!e.props.deselect||l!==Number(e.value)||e.props.dragStarted?n?e.input(l,!1):Yn(e,l):e.input(0)}function rr(e,t){t||(t=1);const o=1/t;return Math.ceil(e*o)/o}const sr=/* #__PURE__ */Fe("rt"),{outer:ar,wrapper:lr,inner:pr,label:ir,prefix:dr,suffix:cr,help:ur,messages:fr,message:vr,icon:hr}=/* #__PURE__ */Be(sr),mr=sr("itemsWrapper",(()=>({$el:"span",attrs:{style:{"flex-direction":'$rightToLeft && "row-reverse" || undefined'},tabindex:"$value !== undefined && $value !== 0 && '-1' || '0'",id:"$id + _items_wrapper",onKeydown:"$handlers.handleWrapperKeydown","data-disabled":"$disabled",onBlur:"$handlers.handleWrapperBlur",onMouseleave:"$hoverHighlight && $handlers.handleMouseleave"}}))),$r=sr("ratingItem",(()=>({for:["item","index","$max"],$el:"span",attrs:{id:'$id + "_item_" + $index',onClick:"$handlers.handleItemClick($item)",draggable:"$hoverHighlight !== true && && $disabled !== true && true",onMousemove:"$handlers.handleMousemove($item)",onDragstart:"$handlers.handleDragstart($item)",onDragend:"$handlers.handleDragend",onTouchstart:"$handlers.handleTouchstart($item)",onTouchmove:"$handlers.handleTouchmove"}}))),gr=sr("template",(()=>({for:["increment","stepIndex","$stepsPerValue"],$el:null}))),br=sr("itemLabel",(()=>({$el:"label",attrs:{id:'$id + "_label_" + $index + "_" + $stepIndex',for:'$id + "_" + $index + "_" + $stepIndex',"data-checked":'$value === $fns.getValue($item, $increment) && "true" || "false"',style:{width:'$fns.showLabel($fns.getValue($item, $increment), $stepIndex, $item) && "100%" || "0%"'}}}))),yr=sr("itemLabelInner",(()=>({$el:"span",children:"$fns.getValue($item, $increment)"}))),xr=sr("input",(()=>({$el:"input",attrs:{type:"radio",value:"$fns.getValue($item, $increment)",id:'$id + "_" + $index + "_" + $stepIndex',onFocus:"$handlers.handleFocus",tabindex:'$value === $fns.getValue($item, $increment) && "0" || "-1"',disabled:"$disabled",name:"$id","data-value":"$fns.getValue($item, $increment)",checked:"$value === $fns.getValue($item, $increment) && true",onKeydown:"$handlers.handleKeydown($fns.getValue($item, $increment))"}}))),wr=sr("onItemRow",(()=>({$el:"span",attrs:{style:{width:"$fns.getPercentage($itemsToPercentages, $item)",display:"flex",position:"relative",overflow:"hidden",top:"0",left:"0",bottom:"0"}}}))),_r=sr("offItemRow",(()=>({$el:"span",attrs:{style:{width:"$fns.getPercentage($itemsToPercentages, $item, false)",display:"flex","flex-direction":"row-reverse",position:"absolute",zIndex:"$offItemStyles && 100",overflow:"hidden",top:"0",right:"0"}}}))),kr=sr("onItemWrapper",(()=>({$el:"div",attrs:{style:{color:"$onColor"}}}))),Sr=sr("offItemWrapper",(()=>({$el:"div",attrs:{style:{color:"$offColor"}}}))),Lr=()=>He("$slots.onItem",(()=>()=>"$slots.onItem"),He("$slots.default",(()=>()=>"$slots.default"),hr("rating"))),Ir=()=>He("$slots.offItem",(()=>()=>"$slots.offItem"),He("$slots.default",(()=>()=>"$slots.default"),hr("rating"))),Ar={schema:/* #__PURE__ */ar(/* #__PURE__ */lr(/* #__PURE__ */ir("$label"),/* #__PURE__ */pr(/* #__PURE__ */hr("prefix"),/* #__PURE__ */dr(),/* #__PURE__ */mr(/* #__PURE__ */$r(/* #__PURE__ */gr(/* #__PURE__ */br(/* #__PURE__ */wr(/* #__PURE__ */kr(/* #__PURE__ */Lr())),/* #__PURE__ */_r(/* #__PURE__ */Sr(/* #__PURE__ */Ir())),/* #__PURE__ */yr()),/* #__PURE__ */xr()))),/* #__PURE__ */cr(),/* #__PURE__ */hr("suffix"))),/* #__PURE__ */ur("$help"),/* #__PURE__ */fr(/* #__PURE__ */vr("$message.value"))),type:"input",props:[],features:[function(e){function t(e){setTimeout((()=>{const t=Array.from(document.querySelectorAll(`#${e.props.id}_items_wrapper > .formkit-ratingItem`));for(let e=0;e<t.length;e++){const o=t[e].querySelectorAll(".formkit-onItemWrapper"),n=t[e].querySelectorAll(".formkit-offItemWrapper");for(let n=0;n<o.length;n++)o[n].style.flex=`0 0 ${t[e].getBoundingClientRect().width}px`;for(let o=0;o<n.length;o++)n[o].style.flex=`0 0 ${t[e].getBoundingClientRect().width}px`}}))}e.addProps(["max","step","stepsPerValue","itemsToPercentages","rightToLeft","onItemStyles","offItemStyles","hoverHighlight","deselect","disabled","wrapperWidth","onColor","offColor"]),!1!==e.props.hoverHighlight&&"false"!==e.props.hoverHighlight&&(e.props.hoverHighlight=!0),e.props.deselect=r(e.props.deselect),e.props.max=Number(e.props.max)||5,e.props.min=Number(e.props.min)||0,e.props.step=Number(e.props.step)||1,e.props.numberOfSteps=e.props.max/e.props.step,e.props.lastIndex=1/e.props.step-1,e.props.itemsToPercentages={},"disabled"in e.props&&(e.props.disabled=r(e.props.disabled)),e.props.rightToLeft?(e.props.onItemStyles=void 0,e.props.offItemStyles={position:"absolute",top:"0",left:"0",overflow:"hidden",height:"100%",zIndex:100}):e.props.onItemStyles={position:"absolute",top:"0",left:"0",overflow:"hidden",height:"100%"},e.props.stepsPerValue=1/e.props.step,e.hook.input(((t,o)=>{if(null===t||""===t||isNaN(t))return o(t);const n=Number(t),r=Number(e.props.min),s=Number(e.props.max);return n>s?o(s):e.props.min&&n<=r?o(r):o(n)})),e.on("commit",(({payload:t})=>{const o=Number(t||0);Yn(e,o)})),e.on("created",(()=>{e.context&&(s(`${e.props.id}_items_wrapper`,(()=>{t(e),function(e){var o;const n=null===(o=e.props.__root)||void 0===o?void 0:o.getElementById(`${e.props.id}_items_wrapper`);if(!n)return;new ResizeObserver((()=>{t(e)})).observe(n)}(e),setTimeout((()=>t(e)),100)}),e.props.__root),e.context.fns.getPercentage=(e,t,o=!0)=>(o?e.onItems:e.offItems)[t],e.context.fns.getValue=(t,o)=>t+Number((o*e.props.step+e.props.step).toFixed(1)),e.context.fns.showLabel=(t,o)=>{const n=Number(e.value||0);return 0===n&&0===o||n&&t===n||t>n&&0===o||n>t&&o===e.props.lastIndex},e.context.handlers.handleFocus=t=>Jn.call(null,e,t),e.context.handlers.handleWrapperKeydown=t=>Xn.call(null,e,t),e.context.handlers.handleWrapperBlur=t=>jn.call(null,e,t),e.context.handlers.handleItemClick=t=>o=>tr.call(null,e,t,o),e.context.handlers.handleMousemove=t=>o=>Qn.call(null,e,t,o),e.context.handlers.handleMouseleave=()=>er.call(null,e),e.context.handlers.handleDragstart=t=>o=>Gn.call(null,e,t,o),e.context.handlers.handleMouseup=t=>qn.call(null,e,t),e.context.handlers.handleTouchstart=t=>o=>Zn.call(null,e,t,o),e.context.handlers.handleTouchmove=t=>zn.call(null,e,t),e.context.handlers.handleKeydown=t=>o=>function(e,t,o){const n=Number(e.value);e.props.deselect&&" "===o.key&&n===t?e.input(0):" "===o.key&&e.input(t)}(e,t,o))}))},/* #__PURE__ */$("rating","star")]},Cr=/* #__PURE__ */Fe("ac"),{outer:Dr,wrapper:Tr,inner:Er,icon:Or,label:Mr,prefix:Vr,suffix:Fr,help:Br,messages:Pr,message:Hr}=/* #__PURE__ */Be(Cr),Rr=Cr("input",(()=>({$el:"input",bind:"$attrs",attrs:{id:"$id",type:"text",onClick:"$handlers.click",onBlur:"$handlers.blur",onKeydown:"$handlers.keydown",onInput:"$handlers.input",onFocus:"$handlers.focus",value:"$inputText || undefined",name:"$node.name",placeholder:"$state.loading && $ui.isLoading.value || $placeholder || undefined",tabindex:'$disabled && "-1" || 0',role:"combobox",autocomplete:'$attrs.autocomplete || "off"',autocapitalize:"none",readonly:"$attrs.readonly || $state.loading || $multiple && $max && $value && $value.length >= $max && $hasHighlightedRange !== true || undefined","data-selection-appearance":"$selectionAppearance",disabled:"$disabled || $disabledInternally || undefined",onTouchmove:"$handlers.touchmove",onTouchstart:"$handlers.touchmove",onTouchend:"$handlers.touchend","aria-autocomplete":"list","aria-expanded":"$expanded","aria-controls":'$expanded && $id + "_listbox" || undefined',"aria-describedBy":"$describedBy","aria-activedescendant":"$expanded && $activeDescendant || undefined"}}))),Kr=Cr("listboxButton",(()=>({$el:"div",attrs:{style:"$visibilityStyles",id:'$id + "_listbox_button"',role:"button","aria-label":"$expanded && $ui.close.value || $ui.open.value",onClick:"$handlers.toggleListbox",onKeydown:"$handlers.toggleListboxKeydown",tabindex:'$disabled && "-1" || 0',"aria-haspopup":"true","aria-expanded":"$expanded","aria-controls":'$expanded && $id + "_listbox" || undefined',"aria-disabled":"$disabled || $state.loading || undefined","data-disabled":"$disabled || $disabledInternally || undefined"}}))),Nr=Cr("selectionWrapper",(()=>({for:["option","index","$selections"],$el:"div",attrs:{id:'$id + "_selection_wrapper_" + $index',key:"$option.value","data-value":"$option.value",tabindex:'$disabled && "-1" || 0',onKeydown:"$handlers.selectionKeydown && $handlers.selectionKeydown($multiple && $option || undefined)",onClick:"$handlers.selectionClick && $handlers.selectionClick($multiple && $option || undefined)",onFocus:"$handlers.selectionFocus && $handlers.selectionFocus($multiple && $option || undefined)",onBlur:"$handlers.selectionBlur && $handlers.selectionBlur($multiple && $option || undefined)","data-is-selection":"true","data-active-selection":"$fns.isActiveSelection && $fns.isActiveSelection($activeSelectionValue, $option)"}}))),Wr=Cr("selection",(()=>({$el:"div",attrs:{id:'$id + "_selection_" + $index'}}))),Ur=Cr("selections",(()=>({$el:"div",attrs:{"aria-live":"polite",id:'$id + "_selections"'}}))),Yr=Cr("removeSelection",(()=>({$el:"button",attrs:{id:'$selectionAppearance === "option" && $multiple && $id + "_remove_selection_" + $index || $id + "_remove_selection"',tabindex:"0",title:"$ui.remove.value",type:"button","aria-label":"$ui.remove.value",onClick:"$handlers.removeSelection && $handlers.removeSelection($multiple && $option || undefined)",onTouchend:"$handlers.removeSelection && $handlers.removeSelection($multiple && $option || undefined)","aria-controls":"$id"}}))),jr=Cr("optionLoading","span"),zr=Cr("option",(()=>({$el:"div",if:"$value !== undefined"}))),Zr=/* #__PURE__ */Re(Cr);function qr(e){"option"!==e.props.selectionAppearance||e.props.multiple||!1===e.props.selectionRemovable||"false"===e.props.selectionRemovable||(e.props.selectionRemovable=!0),e.props.multiple||(e.props.clearSearchOnOpen=r(e.props.clearSearchOnOpen)),e.props.selectionRemovable=r(e.props.selectionRemovable),e.props.openOnClick=r(e.props.openOnClick),"option"!==e.props.selectionAppearance||e.props.multiple||(e.props.isSingleOption=!0),void 0===e.props.closeOnSelect&&(e.props.closeOnSelect=!0),void 0===e.props.selectionAppearance&&(e.props.selectionAppearance="text-input"),void 0===e.props.closeOnSelect&&(e.props.closeOnSelect=!0),e.props.closeOnSelect?e.props.resetSearchOnCommit=!1:void 0===e.props.resetSearchOnCommit&&(e.props.resetSearchOnCommit=e.props.multiple),e.props.allowNewValues=r(e.props.allowNewValues)}function Gr(e){e.addProps(["inputText","selectionAppearance","searchValue","openOnClick","filteredOptions","search","debounce","showInput","visibilityStyles","selectionStyles","multiple","filter","hasHighlightedRange","clearOnClick","debounce"]),void 0===e.props.debounce?e.props.debounce=200:e.props.debounce=parseInt(e.props.debounce),e.props.nonceKey="searchValue",e.props.searchValue="",e.props.inputText="",e.props.filterOptions=wt.bind(null,e),e.props.reloadOnCommit=r(e.props.reloadOnCommit),void 0===e.props.alwaysLoadOnOpen?e.props.alwaysLoadOnOpen=!0:e.props.alwaysLoadOnOpen=r(e.props.alwaysLoadOnOpen),"function"!=typeof e.props.filter&&(e.props.filter=(e,t)=>e.label.toLowerCase().includes(t.toLowerCase())),e.on("created",(()=>{e.context&&re&&(e.context.handlers.focus=Qr.bind(null,e),e.context.handlers.input=Xr.bind(null,e),e.context.handlers.focus=Qr.bind(null,e),e.context.handlers.click=Jr.bind(null,e),e.context.handlers.toggleListbox=es.bind(null,e),e.context.handlers.toggleListboxKeydown=ts.bind(null,e),e.context.handlers.keydown=yo.bind(null,e),e.context.handlers.selectionKeydown=t=>o=>go(e,t,o),e.context.handlers.searchInputTagKeydown=t=>o=>function(e,t,o){if(o.stopPropagation(),e.props.disabled)return;switch(o.key){case"ArrowDown":uo(e);break;case"ArrowRight":case"ArrowLeft":fo(e,t,o);break;case"Delete":case"Backspace":vo(e,t,o)}}(e,t,o),e.on("prop:options",(({payload:t})=>{if((0===e.props.initialOptions.length&&"function"!=typeof e.props.optionsLoader||!e.props.searchValue&&t.length)&&(e.props.initialOptions=[...t]),e.props.selections&&e.props.selections.length&&t.length)for(let o=0;o<e.props.selections.length;o++){const n=e.props.selections[o],r=t.find((e=>bt(e)===n.value));r&&(e.props.selections[o]=r)}})))})),e.on("prop:expanded",(({payload:t})=>{t||yt.delete(e)}))}function Xr(e,t){if(e.props.disabled)return;const o=t.target;e.props.inputText=o.value,e.emit("handleSearchInput",o.value),e.props.searchValue&&wt(e,e.props.searchValue,!0)}function Jr(e,t){t.stopPropagation(),e.props.disabled||e.props.disabledInternally||(e.props.attrs.onClick&&e.props.attrs.onClick(t),(!e.props.expanded&&e.props.openOnClick||e.props.openOnFocus)&&(e.props.expanded=!0))}function Qr(e){e.props.disabled||e.props.disabledInternally||(e.props.attrs.onFocus&&e.props.attrs.onFocus(),e.props.activeSelectionValue=void 0,e.props.skipOpen?e.props.skipOpen=!1:e.props.openOnFocus&&(e.props.expanded=!0))}function es(e){var t,o,n;e.props.disabled||e.props.disabledInternally||(null===(t=e.context)||void 0===t?void 0:t.state.loading)||(e.props.expanded=!e.props.expanded,e.props.openOnFocus||null===(n=null===(o=e.props.__root)||void 0===o?void 0:o.getElementById(`${e.props.id}`))||void 0===n||n.focus())}function ts(e,t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),es(e))}const os=new WeakMap,ns="undefined"!=typeof window,rs=new WeakMap;let ss=!1;function as(e){e.props.searchValue=null,e.on("commit",(()=>{e.props.searchValue=null,e.props.highlightedRange||ls(e)})),e.on("created",(()=>{if(!e.context||!ns)return;e.on("handleSearchInput",(({payload:t})=>{""===t?(e.props.searchValue=null,e.input([])):t&&0===e.props.inputStd.length?e.props.searchValue=t:t&&e.props.inputStd.length>0&&(e.props.searchValue=function(e){var t;const o=is(e);if(e.props.highlightedRange){const[t,n]=ps(e,o);return e.props.inputText.slice(t,n)}return e.props.inputText.slice((null===(t=o[o.length-1])||void 0===t?void 0:t.end)+2)}(e)),!e.props.expanded&&t?e.props.expanded=!0:!t&&e.props.expanded&&(e.props.expanded=!1)})),function(e){s(`${e.props.id}`,(t=>{t instanceof HTMLInputElement&&rs.set(t,e)}),e.props.__root),ns&&!ss&&(ss=!0,document.addEventListener("selectionchange",(()=>{const e=gt();if(e instanceof HTMLInputElement&&rs.has(e)){const t=rs.get(e);t&&function(e){clearTimeout(os.get(e)),os.set(e,setTimeout((()=>{var t,o,n,r;const s=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}`);if(s instanceof HTMLInputElement){const t=is(e),a=t.findIndex((e=>null!==s.selectionStart?s.selectionStart>=e.start&&s.selectionStart<=e.end:null!==s.selectionEnd&&(s.selectionEnd>=e.start&&s.selectionEnd<=e.end))),l=null===(o=t[t.length-1])||void 0===o?void 0:o.end;if(0===s.selectionStart&&s.selectionEnd===(null===(n=e.props.inputText)||void 0===n?void 0:n.length))return;if("string"==typeof e.props.searchValue&&e.props.highlightedRange){if(t.length){const o=e.props.highlightedRange,[n,r]=ps(e,t);if(null!==s.selectionEnd&&(s.selectionEnd<n||s.selectionEnd>r)){const t=o.end-o.start-(r-n),a=s.selectionEnd;e.props.inputText=e.props.option.label,e.props.highlightedRange=void 0,e.props.searchValue=null,s.value=e.props.inputText,s.selectionStart=s.selectionEnd=a+(a>n?t:0)}}}else if(a>=0&&null!==s.selectionStart&&(l!==(null===(r=e.props.inputText)||void 0===r?void 0:r.length)||s.selectionStart<l)){const o=t[a],n=e.props.inputText.substr(0,l),r=o.start+(o.index>0?1:0),p=o.end+(t.length-1>o.index?-1:0);n!==e.props.inputText&&(e.props.inputText=n,s.value=n),e.props.highlightedRange=o,s.selectionStart=r,s.selectionEnd=p}else e.props.highlightedRange=void 0,ls(e);if(null!==s.selectionStart&&s.selectionStart>=l&&", "!==e.props.inputText.substring(l,l+2)){let t=e.props.inputText.substring(0,l);t=e.props.multiple&&e.props.max&&Array.isArray(e.props.inputStd)&&e.props.inputStd.length>=e.props.max?t:`${t},`,e.props.inputText=`${t} ${e.props.inputText.substring(l).replace(/^[,\s]{1,2}/,"")}`}}}),5))}(t)}})))}(e);const o=e.context.handlers.keydown;e.context.handlers.keydown=n=>{o(n),function(e,o){var n,r,s,a;if(["ArrowRight","ArrowLeft"].includes(o.key)&&o.target instanceof HTMLInputElement&&null!==o.target.selectionEnd&&null!==o.target.selectionStart){if(0===o.target.selectionStart&&o.target.selectionEnd===(null===(n=e.props.inputText)||void 0===n?void 0:n.length))"ArrowLeft"===o.key?t(0):t(-1);else if(!e.props.searchValue){e.props.searchValue=null;const t=is(e),n=null===(r=t[t.length-1])||void 0===r?void 0:r.end;o.target.selectionStart<n&&(o.target.selectionStart=Math.max(0,"ArrowLeft"===o.key?o.target.selectionStart-2:o.target.selectionEnd+2))}}else if(["Delete","Backspace"].includes(o.key))e.props.highlightedRange&&!e.props.searchValue?(Ot(e,e.props.highlightedRange.option),0===e.props.inputStd.length&&(e.props.highlightedRange=void 0)):o.target instanceof HTMLInputElement&&(e.props.searchValue=null,t(-1,!0)&&o.preventDefault());else if(o.target instanceof HTMLInputElement&&0===o.target.selectionStart&&o.target.selectionEnd===(null===(s=e.props.inputText)||void 0===s?void 0:s.length)&&(null===(a=e.props.inputText)||void 0===a?void 0:a.length)&&0===e.props.selections.length)o.preventDefault();else if("Tab"===o.key)return;"ArrowLeft"===o.key&&t(-1,!0)&&o.preventDefault()}(e,n)};const n=e.context.handlers.focus;e.context.handlers.focus=t=>{n(e,t);const o=new Event("selectionchange");document.dispatchEvent(o)},e.on("blur",(()=>{e.props.selections.length?(e.props.inputText=e.props.selections.map((e=>e.label)).join(", "),e.props.searchValue=null):e.props.selections.length||(e.props.inputText="",e.props.searchValue="")}))})),e.on("prop:expanded",(({payload:t})=>{t||e.props.inputStd.length?t&&(e.props.options.length&&!e.props.alwaysLoadOnOpen||(e.props.options=[],wt(e,e.props.searchValue))):(e.props.searchValue="",e.props.inputText="")})),e.on("prop:selections",(()=>{var t;const o=[...e.props.selections].map((e=>e.label)).join(", ");let n="";if(ns&&e.isCreated){const o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}`);if(gt()===o&&Array.isArray(e._value)&&e._value.length){if(e.props.max&&e._value.length>=Number(e.props.max))return;n=", "}}e.props.inputText=`${o}${n}`,e.props.reloadOnCommit&&(e.props.searchValue="",wt(e,e.props.searchValue))}));const t=(t,o=!1)=>{var n,r;const s=null===(n=e.props.__root)||void 0===n?void 0:n.getElementById(`${e.props.id}`);if(!(s instanceof HTMLInputElement))return!1;const a=is(e),l=t>=0?t:a.length-1;if(void 0===a[l])return!1;const p=null===(r=a[l])||void 0===r?void 0:r.end;return null!==s.selectionStart&&(!o||s.selectionStart>=p&&s.selectionStart<=p+2)&&(s.selectionStart=a[l].start+(l>0?1:0),s.selectionEnd=a[l].end+(l<a.length-1?-1:0),!0)};let o;e.on("selectRange",(({payload:e})=>t(...e))),e.on("prop:highlightedRange",(({payload:t})=>{e.props.hasHighlightedRange=!!t,t&&e.props.expanded&&o!==t.option&&(o=t.option,Vt(e))}))}function ls(e){var t;if(!ns)return;const o=null===(t=e.props.__root)||void 0===t?void 0:t.getElementById(`${e.props.id}`);o&&o.scrollTo({left:o.scrollWidth,behavior:"smooth"})}function ps(e,t){var o;const n=e.props.highlightedRange,r=n.index,s=n.start+(r?1:0),a=t.length-1>r?t[t.length-1].end-t[r+1].start:0;return[s,(null===(o=e.props.inputText)||void 0===o?void 0:o.length)-a+(t.length-1>n.index?-1:0)]}function is(e){const t=Et(e);return Array.isArray(t)&&t.length?t.reduce(((e,o,n)=>{var r;const s=(null===(r=e[n-1])||void 0===r?void 0:r.end)||0;let a=0;return t.length-1!==n&&a++,0!==n&&a++,e.push({option:o,index:n,start:s,end:s+o.label.length+a}),e}),[]):[]}function ds(e){!function(e){e.on("prop:expanded",(({payload:t})=>{t?(e.props.searchValue="",e.props.options.length&&!e.props.alwaysLoadOnOpen||(e.props.options=[],wt(e,e.props.searchValue,!0))):(e.props.searchValue="",e.props.inputText="")}))}(e),function(e){e.on("handleSearchInput",(({payload:t})=>{t&&!e.props.expanded?(e.props.searchExpand=!0,e.props.expanded=!0):!t&&e.props.expanded&&(e.props.expanded=!1),e.props.searchValue=e.props.inputText}))}(e),function(e){e.on("prop:selections",(()=>{e.isCreated&&(e.props.inputText="",e.props.searchValue="",e.props.optionRemoved||e.props.reloadOnCommit&&wt(e,e.props.searchValue,!0))}))}(e)}function cs(e){!function(e){function t(e){0===e.props.inputStd.length?(e.props.inputText="",e.props.searchValue=""):(e.props.inputText=e.props.selections[0].label,e.props.searchValue=e.props.selections[0].label)}function o(e){e.props.clearSearchOnOpen&&!e.props.searchExpand&&(e.props.inputText="",e.props.searchValue=""),e.props.searchValue=e.props.inputText,e.props.options.length&&!e.props.alwaysLoadOnOpen||e.props.searchExpand||(e.props.options=[],wt(e,e.props.searchValue,!0)),e.props.searchExpand&&(e.props.searchExpand=!1)}e.on("prop:expanded",(({payload:n})=>{n?o(e):t(e)}))}(e),function(e){e.on("handleSearchInput",(({payload:t})=>{""===t?(0===e.props.inputStd.length&&(e.props.expanded=!1),e.input(void 0)):t&&!e.props.expanded&&(e.props.searchExpand=!0,e.props.expanded=!0),e.props.searchValue=e.props.inputText}))}(e),function(e){e.on("prop:selections",(({payload:t})=>{e.props.inputText=t.length?t[0].label:"",e.props.searchValue=t.length?t[0].label:"",e.isCreated&&e.props.expanded&&0===t.length&&wt(e,e.props.searchValue,!0)}))}(e)}function us(e){if(e.props.multiple)if(e.props.multiple&&"option"===e.props.selectionAppearance){function t(){return Array.isArray(e.value)?e.value:[]}function o(t){e.input(t)}ds(e),e.on("created",(()=>{e.props.disabled&&(e.props.draggable=!1),s(`${e.props.id}_selections`,(n=>{if(n instanceof HTMLElement&&e.context){const r={draggingClass:e.context.classes.dragging,dropZoneClass:e.context.classes.dropZone,root:e.props.__root,disabled:!e.props.draggable,plugins:[x()],touchDraggingClass:e.context.classes.touchDragging,touchDropZoneClass:e.context.classes.touchDropZone,draggable:e=>e.hasAttribute("data-is-selection")};w({parent:n,getValues:t,setValues:o,config:r}),e.on("prop:disabled",(({payload:e})=>{r.disabled=e,w({parent:n,getValues:t,setValues:o,config:r})})),e.on("prop:draggable",(({payload:e})=>{r.disabled=!e,w({parent:n,getValues:t,setValues:o,config:r})}))}}),e.props.__root)}))}else e.props.multiple&&"text-input"===e.props.selectionAppearance&&as(e);else cs(e)}const fs={schema:/* #__PURE__ */Dr(/* #__PURE__ */Tr(/* #__PURE__ */Mr("$label"),/* #__PURE__ */Er(/* #__PURE__ */Or("prefix"),/* #__PURE__ */Vr(),/* #__PURE__ */Rr(),/* #__PURE__ */He("$multiple !== true && $selectionAppearance === option && $expanded === false",/* #__PURE__ */Ur(/* #__PURE__ */Nr(/* #__PURE__ */Wr(/* #__PURE__ */zr(/* #__PURE__ */He("$state.loading",/* #__PURE__ */jr("$ui.isLoading.value"),"$option.label"))),/* #__PURE__ */He("$state.loading && $isSingleOption !== true && $optionLoaderValues.includes($option.value)",/* #__PURE__ */Or("loader")),/* #__PURE__ */He("$selectionRemovable && $isSingleOption",/* #__PURE__ */Yr(/* #__PURE__ */Or("close")))))),/* #__PURE__ */He("$state.loading && ($isSingleOption !== true || $selections.length === 0)",/* #__PURE__ */Or("loader")),/* #__PURE__ */He('$selectionRemovable && $selectionAppearance === "text-input" && $selections.length > 0',/* #__PURE__ */Yr(/* #__PURE__ */Or("close")),/* #__PURE__ */He('$selectionAppearance === "text-input" || ($selectionAppearance === "option" && $multiple)',/* #__PURE__ */Kr(/* #__PURE__ */Or("select")))),/* #__PURE__ */He("$isSingleOption && ($inputStd.length === 0 || $selectionRemovable === undefined || ($expanded) || $state.loading || $optionLoaderValues.length > 0)",/* #__PURE__ */Kr(/* #__PURE__ */Or("select"))),/* #__PURE__ */Zr(),/* #__PURE__ */Fr(),/* #__PURE__ */Or("suffix")),/* #__PURE__ */He("$multiple && $selectionAppearance === option",/* #__PURE__ */Ur(/* #__PURE__ */Nr(/* #__PURE__ */Wr(/* #__PURE__ */zr(/* #__PURE__ */He("$state.loading && $isLoadingOption",/* #__PURE__ */jr("$ui.isLoading.value"),"$option.label"))),/* #__PURE__ */Yr(/* #__PURE__ */Or("close")))))),/* #__PURE__ */Br("$help"),/* #__PURE__ */Pr(/* #__PURE__ */Hr("$message.value"))),type:"input",family:"dropdown",props:[],features:[
20
20
  /* #__PURE__ */$("select","select"),
21
21
  /* #__PURE__ */$("close","close"),
22
22
  /* #__PURE__ */$("selected","check"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formkit/pro",
3
- "version": "0.126.9",
3
+ "version": "0.126.10",
4
4
  "description": "FormKit Pro — Form inputs and tools for high quality forms.",
5
5
  "main": "index.cjs",
6
6
  "module": "index.mjs",