@featherk/composables 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(_,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vueuse/integrations/useFocusTrap")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/integrations/useFocusTrap"],t):(_=typeof globalThis<"u"?globalThis:_||self,t(_.FeatherKComposables={},_.Vue,_.useFocusTrap))})(this,(function(_,t,Ve){"use strict";const $e=(e,n)=>{const l=t.ref(null);let V=!1,I=null,T=null;const k=[],w=".k-table-row[data-grid-row-index] [tabindex]",x=()=>{const i=e?.value?.$el;return i?i.closest(".k-grid"):null},M=i=>{const g=x();if(!g)return!1;const u=i.closest(".k-grid-aria-root");if(u)return g.contains(u);const d=i.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return d?g.contains(d):!1},E=i=>i.key==="Enter"||i.code==="Enter"||i.code==="NumpadEnter",F=()=>e?.value?.columns,b=i=>{const g=i.key||i.code;([" ","Spacebar","Space"].includes(g)||E(i))&&(i.preventDefault(),i.stopPropagation(),l.value=i.target,i.target.click())},y=i=>{if(!l.value)return;if(i.code==="Escape"){i.stopPropagation(),l.value&&l.value.focus();return}const g=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),u=document.querySelector(".k-animation-container .k-popup .k-column-menu .k-filter-menu-container");if(u){if(i.code==="Tab"){const d=[".k-dropdownlist[tabindex='0']","input.k-input-inner:not([tabindex='-1']):not([disabled])","button:not([tabindex='-1']):not([disabled])",".k-checkbox"],A=n?.focusableMenuSelectors??d,m=Array.from(u.querySelectorAll(A.join(",")));if(m.length===0)return;const D=m.findIndex(Z=>Z===document.activeElement);let q;D===-1?q=0:i.shiftKey?q=(D-1+m.length)%m.length:q=(D+1)%m.length,i.preventDefault(),i.stopPropagation(),m[q]?.focus()}}else if(i.code==="ArrowUp"||i.code==="ArrowDown"){i.preventDefault(),i.stopPropagation();const d=g.findIndex(m=>m===document.activeElement);let A=d;i.code==="ArrowUp"?A=d>0?d-1:g.length-1:i.code==="ArrowDown"&&(A=d<g.length-1?d+1:0),g[A]?.focus();return}if(i.code==="Tab"){i.preventDefault(),i.stopPropagation();const d=l.value?.parentElement;(i.shiftKey?d?.previousElementSibling:d?.nextElementSibling)?.querySelector("button, [role='button'], .k-link")?.focus()}},C=()=>{I=new MutationObserver(i=>{i.forEach(g=>{g.addedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;if(d.classList.contains("k-animation-container")){const m=l.value;m&&(m.dataset.featherKSortable==="true"||t.nextTick(()=>{d.querySelectorAll(".k-columnmenu-item-wrapper").forEach(Z=>{Z.textContent?.toLowerCase().includes("sort")&&Z.remove()})})),d.addEventListener("keydown",y),t.nextTick(()=>{const D=()=>{const q=Array.from(d.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"));if(q.length===1)q[0].focus(),q[0].click(),D.attempts=0;else if(q.length>1){D.attempts=0;return}else D.attempts===void 0&&(D.attempts=0),D.attempts++<3&&setTimeout(D,200)};D()})}d.querySelectorAll(".k-animation-container").forEach(m=>{m.addEventListener("keydown",y)})}}),g.removedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;d.classList.contains("k-animation-container")&&d.removeEventListener("keydown",y),d.querySelectorAll(".k-animation-container").forEach(m=>{m.removeEventListener("keydown",y)})}})})}),I.observe(document.body,{childList:!0,subtree:!0})},R=i=>{const g=i.tagName.toLowerCase();return!!(["input","textarea","select","button"].includes(g)||i.closest('.k-picker-wrap, .k-input-inner, .k-textbox, [role="combobox"]'))},f=i=>{if(!i.type||!i)return;const g=i.target;if(!g)return;const u=g.closest(".k-table-row[data-grid-row-index]");if(!M(g))return;const d=["ArrowLeft","ArrowRight"].includes(i.code);if(!(R(g)&&!(u&&d))){if(i.code==="Escape"){const A=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(A){i.preventDefault(),i.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(D=>D.setAttribute("tabindex","-1"))}catch{}A.setAttribute("tabindex","0"),A.focus();return}}if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter","NumpadEnter","Space"].includes(i.code)){if(g.classList.contains("k-grid-header-menu")&&g.classList.contains("k-grid-column-menu")){l.value=g;return}if(u){if(["ArrowDown","ArrowUp"].includes(i.code)){i.preventDefault(),i.stopPropagation();const A=(D,q)=>{let Z=q==="next"?D.nextElementSibling:D.previousElementSibling;for(;Z;){const o=Z;try{if(o.classList.contains("k-table-row"))return o}catch{}Z=q==="next"?Z.nextElementSibling:Z.previousElementSibling}return null},m=i.code==="ArrowDown"?A(u,"next"):A(u,"previous");m&&(u.setAttribute("tabindex","-1"),m.setAttribute("tabindex","0"),m.focus());return}if(["ArrowLeft","ArrowRight"].includes(i.code)){i.preventDefault(),i.stopPropagation();const A=u.querySelectorAll(w);if(A.length===0)return;let m=Array.from(A).findIndex(D=>D===document.activeElement);if(m===-1&&document.activeElement===u){A[0].focus();return}i.code==="ArrowRight"?m=m===A.length-1?0:m+1:i.code==="ArrowLeft"&&(m=m===0?A.length-1:m-1),A[m].focus();return}}}}},v=()=>{t.nextTick(()=>{const i=e.value?.$el;if(!i||typeof i.closest!="function")return;const g=i.closest(".k-grid");g&&g.classList.add("fk-grid")})},L=()=>{if(!T)try{const i=()=>{try{const d=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!d||d.length===0||d.filter(D=>D.getAttribute("tabindex")==="0").length===1)return;const m=d.find(D=>D===document.activeElement||D.contains(document.activeElement));if(d.forEach(D=>D.setAttribute("tabindex","-1")),m){m.setAttribute("tabindex","0");return}d[0].setAttribute("tabindex","0")}catch(d){console.error("ensureSingleTabindex error:",d)}},g=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));g.length>0&&g.forEach((d,A)=>{d.setAttribute("tabindex",A===0?"0":"-1")});const u=e.value.$el.querySelector(".k-table-tbody");u&&(T=new MutationObserver(()=>{i()}),T.observe(u,{childList:!0,subtree:!0}))}catch(i){console.error("Error setting up row navigation:",i)}},H=()=>{t.nextTick(()=>{const g=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");g&&g.forEach(u=>{u.setAttribute("role","button"),u.addEventListener("keydown",b)}),C(),J()})},Y=()=>{const g=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");g&&g.forEach(u=>{u.removeEventListener("keydown",b)}),I&&(I.disconnect(),I=null),T&&(T.disconnect(),T=null),k.forEach(u=>u()),k.length=0},J=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((u,d)=>{if(u.dataset.featherKHeaderBound==="true")return;const A=u.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!A)return;const m=F();if(m&&m[d]){const h=m[d].field??"";u.setAttribute("data-feather-k-field",h),u.setAttribute("data-feather-k-filterable",m[d].filterable===!1?"false":"true"),u.setAttribute("data-feather-k-sortable",m[d].sortable===!1?"false":"true")}const D=u.dataset.featherKFilterable!=="false",q=u.dataset.featherKSortable!=="false";A.setAttribute("tabindex","-1"),D||q?u.style.cursor="pointer":u.style.cursor="default",D?(u.setAttribute("tabindex","0"),u.setAttribute("role","button"),u.setAttribute("aria-haspopup","menu")):(u.setAttribute("tabindex","0"),u.setAttribute("role","columnheader"),u.removeAttribute("aria-haspopup"));const Z=h=>{h.target?.closest(".k-column-resizer")||(l.value=u,A.click())},o=h=>{if(D)l.value=u,h.preventDefault(),h.stopPropagation(),Z(h);else if(q){l.value=u;const U=u.querySelector(".k-link");U&&U.click()}};u.addEventListener("click",o),k.push(()=>{u.removeEventListener("click",o)});const p=h=>{if((E(h)||h.code==="Space")&&(D||q)){if(h.preventDefault(),h.stopPropagation(),l.value=u,l.value.focus(),D)Z(h);else if(q){const U=u.querySelector(".k-link");U&&U.click()}}};u.addEventListener("keydown",p,!0),k.push(()=>{u.removeEventListener("keydown",p,!0)}),u.dataset.featherKHeaderBound="true"});const g=document.querySelector(".k-grid-header .k-table-thead");if(g&&g.dataset.featherKHeaderBound!=="true"){const u=d=>{const A=d.target.closest("th");A&&(E(d)||d.code==="Space")&&A.dataset.featherKFilterable==="false"&&A.dataset.featherKSortable==="false"&&(d.preventDefault(),d.stopImmediatePropagation())};g.addEventListener("keydown",u,!0),k.push(()=>{g.removeEventListener("keydown",u,!0)}),g.dataset.featherKHeaderBound="true"}},X=function(i,g){const u=i?.event?.event.target,d=F();if(!u||!d)return;const A=u.classList.contains("k-grid-header-menu"),m=u.classList.contains("k-columnmenu-item"),D=d.find(q=>q.field===i?.event?.field)?.sortable&&!0;if(!A){if(m&&!D){i?.event?.sort?.filter(Z=>Z.field!==i?.event?.field);return}typeof g=="function"&&t.nextTick(()=>{l.value&&l.value.focus(),g(i),t.nextTick(()=>{J()})})}},re=()=>{if(!V)try{v(),L(),H(),V=!0}catch(i){console.error("initA11y failed:",i),Y()}};return t.onBeforeUnmount(()=>{Y()}),{activeFilterButton:l,handleGridKeyDown:f,handleSortChange:X,initA11y:re}},Fe=e=>!!e&&typeof e=="object"&&"filters"in e&&Array.isArray(e.filters),Pe=e=>!!e&&typeof e=="object"&&"field"in e,Ae=(e,n)=>!e||typeof e!="object"?!1:Fe(e)?e.filters.some(l=>Ae(l,n)):Pe(e)?e.field===n:!1,Re=e=>n=>e.value?.filters&&e.value.filters.some(l=>Ae(l,n))?"active":"",Le="Enter a valid ZIP code with exactly 5 or 9 digits.",De=e=>{const n=e.replace(/\D/g,"").slice(0,9);return n.length>5?`${n.slice(0,5)}-${n.slice(5)}`:n},qe=(e,n)=>e.slice(0,Math.max(0,n)).replace(/\D/g,"").length,Oe=e=>e<=5?e:Math.min(e+1,10),xe=e=>{const n=t.ref(De(e.initialValue??"")),l=t.ref(!1),V=t.ref(e.errorMessage?.trim()||Le),I=t.computed(()=>n.value.replace(/\D/g,"")),T=t.computed(()=>{const y=I.value.length;return y===5||y===9}),k=t.computed(()=>l.value&&!T.value),w=t.computed(()=>!l.value||T.value),x=t.computed(()=>l.value),M=(y,C)=>{const R=Oe(C);t.nextTick(()=>{y.isConnected&&y.setSelectionRange(R,R)})};return{zipDisplay:n,submitted:l,errorMessage:V,wrapperClass:"fk-zip-textbox",zipRaw:I,isZipValid:T,showZipError:k,textBoxValid:w,textBoxValidate:x,handleZipInput:(...y)=>{const C=y[0],f=C?.event?.target,v=C?.value,L=Array.isArray(v)?v.join(""):String(v??""),H=f?.selectionStart!==void 0&&f.selectionStart!==null?qe(f.value,f.selectionStart):L.replace(/\D/g,"").length;n.value=De(L),f&&M(f,H)},submitAndValidate:y=>{l.value=!0;const C=T.value;return!C&&y?.focus&&t.nextTick(()=>{document.getElementById(e.id)?.focus()}),C},buildPayload:()=>({zip:I.value})}};function Ee(e,n){const l=t.ref(!1);t.watchEffect(()=>{e.value?.setAttribute("aria-invalid",String(!n.isValid()))});function V(T){const k=e.value??T.currentTarget,w=T.relatedTarget;(!k||!k.contains(w))&&(l.value=!0)}function I(){l.value=!1}return{touched:l,onFocusout:V,reset:I}}function Me(e,n){const l=t.ref(!1),V=t.ref(!1),I=t.computed(()=>t.toValue(n.submitted)||l.value),T=t.computed(()=>!I.value||n.isValid()),k=Ee(e,{isValid:()=>T.value});function w(b){return t.computed(()=>!I.value||t.toValue(b))}function x(b){return Object.fromEntries(Object.entries(b).map(([y,C])=>[y,w(C)]))}function M(b){const y=t.toValue(b);if(!y)return;y.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function E(b){if(V.value){V.value=!1;return}k.onFocusout(b),k.touched.value&&(l.value=!0)}function F(){l.value=!1,V.value=!0,k.reset()}return{touched:l,fieldsetValidate:I,onFocusout:E,reset:F,createFieldValidity:w,createFieldValidationsMap:x,focusFirstInvalidField:M}}const Ue=[{label:"Alabama",value:"AL"},{label:"Alaska",value:"AK"},{label:"Arizona",value:"AZ"},{label:"Arkansas",value:"AR"},{label:"California",value:"CA"},{label:"Colorado",value:"CO"},{label:"Connecticut",value:"CT"},{label:"Delaware",value:"DE"},{label:"Florida",value:"FL"},{label:"Georgia",value:"GA"},{label:"Hawaii",value:"HI"},{label:"Idaho",value:"ID"},{label:"Illinois",value:"IL"},{label:"Indiana",value:"IN"},{label:"Iowa",value:"IA"},{label:"Kansas",value:"KS"},{label:"Kentucky",value:"KY"},{label:"Louisiana",value:"LA"},{label:"Maine",value:"ME"},{label:"Maryland",value:"MD"},{label:"Massachusetts",value:"MA"},{label:"Michigan",value:"MI"},{label:"Minnesota",value:"MN"},{label:"Mississippi",value:"MS"},{label:"Missouri",value:"MO"},{label:"Montana",value:"MT"},{label:"Nebraska",value:"NE"},{label:"Nevada",value:"NV"},{label:"New Hampshire",value:"NH"},{label:"New Jersey",value:"NJ"},{label:"New Mexico",value:"NM"},{label:"New York",value:"NY"},{label:"North Carolina",value:"NC"},{label:"North Dakota",value:"ND"},{label:"Ohio",value:"OH"},{label:"Oklahoma",value:"OK"},{label:"Oregon",value:"OR"},{label:"Pennsylvania",value:"PA"},{label:"Rhode Island",value:"RI"},{label:"South Carolina",value:"SC"},{label:"South Dakota",value:"SD"},{label:"Tennessee",value:"TN"},{label:"Texas",value:"TX"},{label:"Utah",value:"UT"},{label:"Vermont",value:"VT"},{label:"Virginia",value:"VA"},{label:"Washington",value:"WA"},{label:"West Virginia",value:"WV"},{label:"Wisconsin",value:"WI"},{label:"Wyoming",value:"WY"}];function ve(e){if(e&&typeof e=="object"&&"value"in e){const n=e.value;return typeof n=="string"?n:String(n??"")}return""}function Ke(){const e=t.reactive({address1:"",address2:"",city:"",state:null,zip:""});return{formData:e,onAddress1Input:(...k)=>{e.address1=ve(k[0])},onAddress2Input:(...k)=>{e.address2=ve(k[0])},onCityInput:(...k)=>{e.city=ve(k[0])},onStateChange:k=>{k.value===null&&e.state!==null||(e.state=k.value)},resetFormData:()=>{e.address1="",e.address2="",e.city="",e.state=null,e.zip=""}}}function Ne(e){const n=xe({id:"zip"}),{zipDisplay:l,zipRaw:V,isZipValid:I,wrapperClass:T,handleZipInput:k}=n;return t.watch(V,x=>{e.zip=x}),{zipDisplay:l,isZipValid:I,zipWrapperClass:T,onZipInput:k,resetZip:()=>{l.value="",e.zip=""}}}function Be(e){const n=t.computed(()=>e.formData.address1.trim()!==""),l=t.computed(()=>e.formData.city.trim()!==""),V=t.computed(()=>!!e.formData.state),I=t.computed(()=>t.toValue(e.isZipValid)),T=t.computed(()=>n.value&&l.value&&V.value&&I.value);return{strictAddress1Valid:n,strictCityValid:l,strictStateValid:V,strictZipValid:I,strictAddressValid:T}}function ze(e){if(!e)return;e.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function He(e){const n=t.ref(!1),{formData:l,onAddress1Input:V,onAddress2Input:I,onCityInput:T,onStateChange:k,resetFormData:w}=Ke(),{zipDisplay:x,isZipValid:M,zipWrapperClass:E,onZipInput:F,resetZip:b}=Ne(l),{strictAddress1Valid:y,strictCityValid:C,strictStateValid:R,strictZipValid:f,strictAddressValid:v}=Be({formData:l,isZipValid:M}),L=Me(e.fieldsetRef,{submitted:n,isValid:()=>v.value}),{touched:H,fieldsetValidate:Y,onFocusout:J,reset:X}=L,re=L.createFieldValidationsMap({address1:y,city:C,state:R,zip:f,address:v}),{address1:i,city:g,state:u,zip:d,address:A}=re,m={value:null,label:"Select state"},D=Ue.map(({label:p,value:h})=>({label:p,value:h})),q=t.computed(()=>({address1:l.address1.trim(),address2:l.address2.trim(),city:l.city.trim(),state:(l.state??"").trim().toUpperCase(),zip:l.zip.replace(/\D/g,"")}));return{formData:l,submitted:n,touched:H,addressValidate:Y,address1Valid:i,cityValid:g,stateValid:u,zipValid:d,addressValid:A,stateDefaultItem:m,stateOptions:D,zipDisplay:x,zipWrapperClass:E,onAddress1Input:V,onAddress2Input:I,onCityInput:T,onStateChange:k,onZipInput:F,onFieldsetFocusout:J,normalizedPayload:q,submit:async()=>(n.value=!0,v.value?{isValid:!0,payload:q.value}:(await t.nextTick(),ze(e.formRef.value),{isValid:!1,payload:null})),reset:()=>{n.value=!1,X(),w(),b()}}}function Ze(e){const n=t.ref(""),l=t.ref(void 0),V=t.ref(!!e.debug),I=t.ref(e.dateFormat??"mm/dd/yyyy"),T=t.computed(()=>!!e.required),k=t.ref(!1),w=["ArrowUp","ArrowDown"],x=["ArrowLeft","ArrowRight"],M=t.computed(()=>(n.value??"").replace(/\D/g,"")),E=o=>o<=2?"mm":o<=5?"dd":M.value.length<=10?"yyyy":"mm",F=t.computed(()=>{const o=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),b=t.computed(()=>{const o=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),y=t.computed(()=>{const o=n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(4,"0")}),C=o=>{if(M.value.length===0){e.onChange({value:null,event:o});return}if(M.value.length<8){e.onChange({value:null,event:o});return}if((n.value??"").length===10&&M.value.length===8){const[p,h,U]=n.value.split("/"),N=parseInt(p),B=parseInt(h),Q=parseInt(U);if(H(Q,N,B)){const oe=new Date(Q,N-1,B);R(oe)?e.onChange({value:oe,event:o}):e.onChange({value:null,event:o})}else e.onChange({value:null,event:o})}},R=o=>{const p=e.min??void 0,h=e.max??void 0;return!(p&&o<p||h&&o>h)},f=t.computed(()=>{if((n.value??"").length===10&&M.value.length===8){const[o,p,h]=(n.value??"").split("/"),U=parseInt(o),N=parseInt(p),B=parseInt(h);if(H(B,U,N))return new Date(B,U-1,N)}return null}),v=t.computed(()=>(n.value??"").length===10&&M.value.length===8),L=(o,p)=>new Date(o,p,0).getDate(),H=(o,p,h)=>p>=1&&p<=12&&o>=1900&&h>=1&&h<=L(o,p),Y=o=>{n.value=o.value;const p=o.event?.target;l.value=p?.selectionStart??0,C(o)},J=o=>{l.value=o.target.selectionStart??0},X=(o,p,h)=>{const U=p?.selectionStart??l.value??0;l.value=U;let N=parseInt(F.value),B=parseInt(b.value),Q=parseInt(y.value);if(!(M.value.length>=8)||!H(Q,N,B)){const j=e.defaultValue??new Date;N=j.getMonth()+1,B=j.getDate(),Q=j.getFullYear(),n.value=`${String(N).padStart(2,"0")}/${String(B).padStart(2,"0")}/${String(Q)}`;const K=new Date(Q,N-1,B);e.onChange({value:R(K)?K:null,event:h}),d({useRAF:!0});return}const r=E(U);if(r==="mm")N=o==="ArrowUp"?N<12?N+1:1:N>1?N-1:12;else if(r==="dd"){const j=new Date(Q,N,0).getDate();B=o==="ArrowUp"?B<j?B+1:1:B>1?B-1:j}else r==="yyyy"&&(Q=o==="ArrowUp"?Q+1:Math.max(1,Q-1));n.value=`${String(N).padStart(2,"0")}/${String(B).padStart(2,"0")}/${String(Q)}`;const[s,P,O]=n.value.split("/"),z=new Date(parseInt(O),parseInt(s)-1,parseInt(P));z.toString()!=="Invalid Date"&&parseInt(O)>=1e3?e.onChange({value:R(z)?z:null,event:h}):e.onChange({value:null,event:h}),d({useRAF:!0})},re=o=>{if(o.code==="Space"||o.key===" "){o.preventDefault(),o.stopPropagation(),e.onShowCalendar(o);return}if(o.key==="ArrowDown"&&o.altKey){o.preventDefault(),o.stopPropagation(),e.onShowCalendar(o);return}if(w.includes(o.key)){if(o.altKey)return;o.preventDefault(),o.stopPropagation();const p=o.target;X(o.key,p,o);return}},i=o=>{o.preventDefault();const p=o.deltaY<0?"ArrowUp":"ArrowDown";X(p,o.target,o)},g=o=>{const p=o.target;if(x.includes(o.key)){l.value=p?.selectionStart??0;return}if(w.includes(o.key)){if(o.altKey)return;l.value=p?.selectionStart??0}},u=o=>{k.value=!0,T.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&M.value.length===0&&(e.externalValue.value="");const p=o.target;p&&(l.value=p.selectionStart??0)},d=o=>{const p=()=>{const h=document.getElementById(e.id);if(!h)return;const U=o?.pos??l.value??h.value.length;try{h.focus(),h.setSelectionRange(U,U)}catch{}};t.nextTick(()=>{if(o?.delay&&o.delay>0){setTimeout(p,o.delay);return}if(o?.useRAF){requestAnimationFrame(p);return}p()})};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const p=new Date(o);if(p.toString()!=="Invalid Date"){const h=(p.getMonth()+1).toString().padStart(2,"0"),U=p.getDate().toString().padStart(2,"0"),N=p.getFullYear().toString();n.value=`${h}/${U}/${N}`,d({delay:50});return}}},{immediate:!0});const A=t.computed(()=>[["Date",`${F.value} / ${b.value} / ${y.value}`],["Digits only",M.value],["min",e.min?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null],["max",e.max?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null]]),m=t.computed(()=>{if(!T.value){if(!v.value)return!0;const p=f.value;return p?R(p):!1}if(!k.value)return!0;const o=f.value;return!v.value||!o?!1:R(o)}),D=t.computed(()=>{if(!T.value){if(!v.value)return;const p=f.value;return p?R(p)?"valid":"out-of-bounds":"invalid-date"}if(!k.value)return;if(M.value.length===0||!v.value)return"incomplete";const o=f.value;return o?R(o)?"valid":"out-of-bounds":"invalid-date"}),q=t.computed(()=>{const o=D.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-date")return`Must be in ${I.value} format.`;const p=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,h=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(o==="out-of-bounds"){if(p&&h)return`Must be between ${p} and ${h}.`;if(p)return`Must be on or after ${p}.`;if(h)return`Must be on or before ${h}.`}return""}),Z=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`ID (#${e.id}) not found for styling.`);return}const p=o.closest(".k-datepicker");if(!p){console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}const h=p.parentElement;if(h){if(h.classList.contains("fk-datepicker"))return;h.classList.add("fk-datepicker")}else console.warn(`Parent of .k-datepicker not found for #${e.id} styling.`)})};return t.onMounted(()=>{Z()}),{raw:n,cursorPos:l,debugEnabled:V,debugLines:A,placeholder:I,isValid:m,reason:t.readonly(D),validationMessage:q,digitsOnly:M,month:t.readonly(F),day:t.readonly(b),year:t.readonly(y),datePart:E,handleChange:Y,handleKeyDown:re,handleWheel:i,handleKeyUp:g,handleClick:J,handleBlur:u,initStyling:Z}}function We(e){const n=t.ref(""),l=t.ref(void 0),V=t.ref(!!e.debug),I=t.ref(!1),T=1440*60*1e3,k=365*T,w=new Date,x=new Date(w.getTime()-k),M=new Date(w.getTime()+k);e.min=e.min??x,e.max=e.max??M;const E=t.computed(()=>(n.value??"").replace(/\D/g,"")),F=(a,c)=>new Date(a,c,0).getDate(),b=(a,c,S)=>c>=1&&c<=12&&a>=1e3&&S>=1&&S<=F(a,c),y=a=>Date.UTC(a.getFullYear(),a.getMonth(),a.getDate()),C=a=>{if(!a)return null;const c=e.min??new Date(Date.now()-90*T),S=e.max??new Date,$=y(a);return $<y(c)||$>y(S)?null:a},R=(a,c)=>e.allowReverse??!1?!0:a<=c,f=t.computed(()=>(n.value?.length??0)>=23&&E.value.length>=16),v=a=>{if((a??"").length<23||E.value.length<16)return{start:null,end:null};const c=a.substring(0,10),S=a.substring(13,23),[$,ee,te]=c.split("/").map(se=>parseInt(se||"0",10)),[ie,ce,de]=S.split("/").map(se=>parseInt(se||"0",10)),fe=new Date(te,$-1,ee),ye=new Date(de,ie-1,ce),Se=b(te,$,ee)&&fe.toString()!=="Invalid Date",ke=b(de,ie,ce)&&ye.toString()!=="Invalid Date";return{start:Se?fe:null,end:ke?ye:null}},L=e.externalValid??t.ref(!0),H=t.computed(()=>v(n.value)),Y=t.computed(()=>{const a=C(H.value.start),c=C(H.value.end);return{start:a,end:c}}),J=t.computed(()=>{if(!f.value)return;const a=Y.value.start,c=Y.value.end;if(!a||!c)return;const S=Math.abs(y(c)-y(a));return Math.round(S/864e5+1)}),X=t.computed(()=>{if(!f.value)return!1;const{start:a,end:c}=H.value;if(!a||!c||!Y.value.start||!Y.value.end)return!1;const S=Y.value.start,$=Y.value.end;return!(!R(S,$)||typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays)}),re=t.computed(()=>{const{start:a,end:c}=H.value;if(!f.value)return"incomplete";if(!a||!c)return"invalid-date";if(!Y.value.start||!Y.value.end)return"out-of-bounds";const S=Y.value.start,$=Y.value.end;return R(S,$)?typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),i=t.ref(void 0),g=t.computed(()=>{if(L.value!==!1)return"";const{min:a,max:c}=e,S=i.value;if(!S)return"";switch(S){case"incomplete":return"Required";case"invalid-date":return"One or both dates invalid.";case"reversed-range":return"End Date must be on or after Start Date.";case"out-of-bounds":return a&&c?`Dates must be between ${m(a)} and ${m(c)}.`:"Dates must be within the allowed range.";case"span-exceeds-limit":return typeof e.maxSpanDays=="number"?`Date range exceeds ${e.maxSpanDays} days.`:"Date range exceeds maximum allowed span.";default:return""}}),u=["ArrowUp","ArrowDown"],d=["ArrowLeft","ArrowRight"],A=(a,c)=>String(a).padStart(c,"0"),m=a=>`${A(a.getMonth()+1,2)}/${A(a.getDate(),2)}/${A(a.getFullYear(),4)}`,D=a=>a<=2?{side:"start",part:"mm"}:a<=5?{side:"start",part:(a<=3,"dd")}:a<=11?{side:"start",part:"yyyy"}:a<=15?{side:"end",part:"mm"}:a<=18?{side:"end",part:"dd"}:{side:"end",part:"yyyy"},q=(a,c,S)=>{const $=c?.selectionStart??l.value??0;l.value=$;const{start:ee,end:te}=v(n.value);if(!ee&&!te){const W=new Date,le=m(W);n.value=`${le} - ${le}`,e.onChange({value:{start:W,end:W},event:S}),t.nextTick(()=>{requestAnimationFrame(()=>{const ne=document.getElementById(e.id),ae=l.value??0;ne&&(ne.focus(),ne.setSelectionRange(ae,ae))})});return}const ie=new Date,ce=D($);let de=ee?new Date(ee):new Date(ie),fe=te?new Date(te):new Date(ie);const ye=(W,le)=>{if(le==="mm"){const ne=W.getMonth()+1,ae=a==="ArrowUp"?ne<12?ne+1:1:ne>1?ne-1:12;W.setMonth(ae-1);const ge=F(W.getFullYear(),ae);W.getDate()>ge&&W.setDate(ge)}else if(le==="dd"){const ne=F(W.getFullYear(),W.getMonth()+1),ae=W.getDate(),ge=a==="ArrowUp"?ae<ne?ae+1:1:ae>1?ae-1:ne;W.setDate(ge)}else if(le==="yyyy"){const ne=W.getFullYear();W.setFullYear(a==="ArrowUp"?ne+1:Math.max(1,ne-1));const ae=F(W.getFullYear(),W.getMonth()+1);W.getDate()>ae&&W.setDate(ae)}};ce.side==="start"?ye(de,ce.part):ye(fe,ce.part);const Se=m(de),ke=m(fe);n.value=`${Se} - ${ke}`;const se=C(de),we=C(fe);se&&we&&R(se,we)?e.onChange({value:{start:se,end:we},event:S}):e.onChange({value:null,event:S}),t.nextTick(()=>{requestAnimationFrame(()=>{const W=document.getElementById(e.id),le=l.value??0;W&&(W.focus(),W.setSelectionRange(le,le))})})},Z=a=>{const{start:c,end:S}=v(n.value);if(!c||!S){e.onChange({value:null,event:a});return}const $=C(c),ee=C(S);if(!$||!ee){e.onChange({value:null,event:a});return}if(!R($,ee)){e.onChange({value:null,event:a});return}e.onChange({value:{start:$,end:ee},event:a})},o=a=>{const c=a.value??"",S=a.event;if(!c&&S&&S.type==="click"){oe(S);return}n.value=c;const $=S?.target;l.value=$?.selectionStart??0,Z(a)},p=a=>{l.value=a.target.selectionStart??0},h=a=>{if(a.code==="Space"||a.key===" "){a.preventDefault(),a.stopPropagation(),e.onShowCalendar(a);return}if(a.key==="ArrowDown"&&a.altKey){a.preventDefault(),a.stopPropagation(),e.onShowCalendar(a);return}if(u.includes(a.key)){a.preventDefault(),a.stopPropagation();const c=a.target;q(a.key,c,a);return}},U=a=>{a.preventDefault();const c=a.deltaY<0?"ArrowUp":"ArrowDown";q(c,a.target,a)},N=a=>{if(d.includes(a.key)||u.includes(a.key)){const c=a.target;l.value=c?.selectionStart??0}},B=()=>{i.value=re.value,(e.manageValid??!0)&&(L.value=X.value)},Q=a=>{B()},oe=a=>{console.log("Clear event:",a),n.value="",l.value=0,e.onChange({value:null,event:a}),B(),t.nextTick(()=>{const c=document.getElementById(e.id);c&&(c.focus(),c.setSelectionRange(0,0))})};e.externalValue&&t.watch(e.externalValue,a=>{const c=a?.start??null,S=a?.end??null;if(c&&S){if(n.value=`${m(c)} - ${m(S)}`,e.isOpen?.value&&I.value&&e.onRequestClose){const $=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),I.value=!1,B()},$)}return}},{immediate:!0});const r=t.computed(()=>n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0"),s=t.computed(()=>n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0"),P=t.computed(()=>n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0"),O=t.computed(()=>n.value&&n.value.substring(13,15).replace(/\D/g,"0")||"0"),z=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),j=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),K=t.computed(()=>{const{start:a,end:c}=v(n.value);return[{label:"Raw",value:n.value},{label:"Min Date",value:`${e.min?e.min.toDateString():"-"}`},{label:"Max Date",value:`${e.max?e.max.toDateString():"-"}`},{label:"Start",value:`${String(r.value).padStart(2,"0")} / ${String(s.value).padStart(2,"0")} / ${String(P.value).padStart(4,"0")}`},{label:"End",value:`${String(O.value).padStart(2,"0")} / ${String(z.value).padStart(2,"0")} / ${String(j.value).padStart(4,"0")}`},{label:"Digits only",value:E.value},{label:"Mask complete",value:`${f.value}`},{label:"Parsed",value:`${a?a.toDateString():"-"} | ${c?c.toDateString():"-"}`},{label:"Valid (managed)",value:`${L.value??"-"}`},{label:"Span (days)",value:`${J.value??"-"}`},{label:"Reason",value:`${re.value??"-"}`},{label:"Cursor in",value:`${l.value??"-"} (${(()=>{const S=l.value??0,$=D(S);return`${$.side}.${$.part}`})()})`}]}),G=()=>{t.nextTick(()=>{const a=document.getElementById(e.id);if(!a){console.warn(`#${e.id} not found for styling.`);return}const c=a.closest("div");if(!c){console.warn(`Parent div of #${e.id} not found for styling.`);return}c.classList.contains("fk-daterangepicker")||c.classList.add("fk-daterangepicker")})};t.onMounted(()=>{G()});const me=()=>{t.nextTick(()=>{try{const a=Array.from(document.querySelectorAll(".k-animation-container"));if(!a.length)return;const S=[...a].reverse().find(te=>te.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!S)return;const $=S.querySelectorAll(".k-calendar-table");let ee=!1;$.forEach(te=>{te.tabIndex===0&&(ee?te.tabIndex=-1:ee=!0)})}catch(a){console.warn(a)}})};return e.isOpen&&t.watch(e.isOpen,a=>{a&&setTimeout(()=>me(),0)},{immediate:!1}),{raw:n,cursorPos:l,debugEnabled:V,debugLines:K,digitsOnly:E,valid:L,validComputed:t.readonly(X),reason:t.readonly(re),validationMessage:t.readonly(g),spanDays:t.readonly(J),month1:t.readonly(r),day1:t.readonly(s),year1:t.readonly(P),month2:t.readonly(O),day2:t.readonly(z),year2:t.readonly(j),handleChange:o,handleKeyDown:h,handleWheel:U,handleKeyUp:N,handleClick:p,handleBlur:Q,handleClear:oe,onCalendarChange:()=>{I.value=!0},initStyling:G}}function Ye(e){const n=t.ref(""),l=t.ref(void 0),V=t.ref(!!e.debug),I=t.ref(e.timeFormat??"hh:mm AM"),T=t.computed(()=>!!e.required),k=t.ref(!1),w=["ArrowUp","ArrowDown"],x=["ArrowLeft","ArrowRight"],M=t.computed(()=>(n.value??"").replace(/\D/g,"")),E={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},F=r=>r<=2?"hh":r<=5?"mm":"ampm",b=t.computed(()=>{const r=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0",s=parseInt(r);return Math.min(Math.max(s,0),23)}),y=t.computed(()=>{const r=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0",s=parseInt(r);return Math.min(Math.max(s,0),59)}),C=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),R=t.computed(()=>{const r=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),s=C.value;return r===12?s==="AM"?0:12:s==="PM"?r+12:r}),f=t.computed(()=>v.value?`${String(R.value).padStart(2,"0")}:${String(y.value).padStart(2,"0")}:00`:null),v=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),L=(r,s,P)=>{let O=r%12;return O===0&&(O=12),`${String(O).padStart(2,"0")}:${String(s).padStart(2,"0")} ${P}`},H=r=>{const s=r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!s)return null;const P=parseInt(s[1]),O=parseInt(s[2]),z=s[3].toUpperCase();if(P<1||P>12||O<0||O>59)return null;let j=P%12;z==="PM"&&(j+=12);const K=new Date;return K.setSeconds(0,0),K.setHours(j),K.setMinutes(O),K},Y=r=>{if(M.value.length===0){e.onChange({value:null,event:r});return}if(!v.value){e.onChange({value:null,event:r});return}const s=H(n.value);s&&X(s)?e.onChange({value:s,event:r}):e.onChange({value:null,event:r})},J=r=>r.getHours()*60+r.getMinutes(),X=r=>{const s=e.min??void 0,P=e.max??void 0,O=J(r);if(s){const z=J(s);if(O<z)return!1}if(P){const z=J(P);if(O>z)return!1}return!0},re=r=>{const s=r.getHours(),P=s>=12?"PM":"AM";n.value=L(s,r.getMinutes(),P)},i=(r,s)=>{e.onChange({value:r,event:s})},g=()=>{t.nextTick(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const r=document.getElementById(e.id);if(r){r.focus();const s=(r.value??"").length;r.setSelectionRange(s,s)}})})})},u=r=>{const s=r?.event?.target;return s?s.closest(".k-time-now")?"now":s.closest(".k-time-accept")?"set":null:null},d=(r,s)=>{r&&X(r)?i(r,s):i(null,s)},A=(...r)=>{const s=r[0];if(!s)return;const P=u(s);if(P==="now"){const z=new Date;re(z),d(z,s),g();return}if(s?.value instanceof Date){const z=new Date(s.value);re(z),d(z,s),P==="set"&&g();return}if(s?.value===null){n.value="",i(null,s);return}n.value=s.value;const O=s.event?.target;l.value=O?.selectionStart??0;try{const z=l.value??0;if(F(z)==="ampm"&&(n.value??"").length>=8){const j=n.value.charAt(6);/[Aa]/.test(j)?(n.value=`${n.value.slice(0,6)}AM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const K=document.getElementById(e.id);K&&(K.focus(),K.setSelectionRange(8,8))})})):/[Pp]/.test(j)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const K=document.getElementById(e.id);K&&(K.focus(),K.setSelectionRange(8,8))})}))}}catch{}Y(s)},m=r=>{l.value=r.target.selectionStart??0},D=(r,s,P)=>{const O=s?.selectionStart??l.value??0;l.value=O;const z=F(O),j=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!j){if((n.value??"").length===0||M.value.length===0){const c=new Date,S=c.getHours(),$=S>=12?"PM":"AM";n.value=L(S,c.getMinutes(),$);const ee=H(n.value);d(ee,P),t.nextTick(()=>{requestAnimationFrame(()=>{const te=document.getElementById(e.id),ie=l.value??0;te&&(te.focus(),te.setSelectionRange(ie,ie))})})}return}let K=parseInt(j[1]),G=parseInt(j[2]),me=j[3].toUpperCase();if(z==="hh")r==="ArrowUp"?K=K<12?K+1:1:K=K>1?K-1:12;else if(z==="mm"){const c=e.minuteStepRef?.value??e.minuteStep??1;if(c===1)r==="ArrowUp"?G=G<59?G+1:0:G=G>0?G-1:59;else if(r==="ArrowUp"){const S=G%c;let $=S===0?G+c:G+(c-S);$>=60&&($=0),G=$}else{const S=G%c;let $=S===0?G-c:G-S;$<0&&($=60-c),G=$}}else z==="ampm"&&(me=me==="AM"?"PM":"AM");n.value=`${String(K).padStart(2,"0")}:${String(G).padStart(2,"0")} ${me}`;const a=H(n.value);d(a,P),t.nextTick(()=>{requestAnimationFrame(()=>{const c=document.getElementById(e.id),S=l.value??0;c&&(c.focus(),c.setSelectionRange(S,S))})})},q=r=>{if(r.code==="Space"||r.key===" "){r.preventDefault(),r.stopPropagation(),e.onShowPicker(r);return}if(r.key==="ArrowDown"&&r.altKey){r.preventDefault(),r.stopPropagation(),e.onShowPicker(r);return}if(w.includes(r.key)){if(r.altKey)return;r.preventDefault(),r.stopPropagation();const s=r.target;D(r.key,s,r);return}},Z=r=>{r.preventDefault();const s=r.deltaY<0?"ArrowUp":"ArrowDown";D(s,r.target,r)},o=r=>{const s=r.target;if(x.includes(r.key)){l.value=s?.selectionStart??0;return}if(w.includes(r.key)){if(r.altKey)return;l.value=s?.selectionStart??0}},p=r=>{k.value=!0,T.value&&e.externalValue&&e.externalValue.value===void 0&&M.value.length===0&&(e.externalValue.value="");const s=r.target;s&&(l.value=s.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,r=>{if(r){const s=new Date(r);if(s.toString()!=="Invalid Date"){const P=s.getHours(),O=P>=12?"PM":"AM";n.value=L(P,s.getMinutes(),O);return}}},{immediate:!0});const h=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",b.value],["Hour (24h)",R.value],["Minute",y.value],["Period",C.value],["Time (24h)",f.value??"--:--:--"],["Digits only",M.value],["Parsed Date",U.value?.toLocaleDateString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["min",e.min?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["max",e.max?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["valid",N.value],["reason",B.value],["validationMessage",Q.value]]),U=t.computed(()=>H(n.value)??null),N=t.computed(()=>{if(!T.value){if(!v.value)return!0;const s=U.value;return s?X(s):!1}if(!k.value)return!0;const r=U.value;return!v.value||!r?!1:X(r)}),B=t.computed(()=>{if(!T.value){if(!v.value)return;const s=U.value;return s?X(s)?"valid":"out-of-bounds":"invalid-time"}if(!k.value)return;if(M.value.length===0||!v.value)return"incomplete";const r=U.value;return r?X(r)?"valid":"out-of-bounds":"invalid-time"}),Q=t.computed(()=>{const r=B.value;if(!r||r==="valid")return"";if(r==="incomplete")return"Required";if(r==="invalid-time")return`Must be in ${I.value} format.`;const s={hour:"2-digit",minute:"2-digit"},P=e.min?e.min.toLocaleTimeString("en-US",s):null,O=e.max?e.max.toLocaleTimeString("en-US",s):null;if(r==="out-of-bounds"){if(P&&O)return`Must be between ${P} and ${O}.`;if(P)return`Must be ${P} or later.`;if(O)return`Must be ${O} or earlier.`}return""}),oe=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`#${e.id} not found for styling.`);return}const s=r.closest(".k-timepicker");if(!s){console.warn(`.k-timepicker parent of #${e.id} not found for styling.`);return}const P=s.parentElement;if(!P){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}P.classList.contains("fk-timepicker")||P.classList.add("fk-timepicker")})};return t.onMounted(()=>{oe()}),{raw:n,rules:E,debugEnabled:V,debugLines:h,placeholder:I,isValid:N,reason:t.readonly(B),validationMessage:Q,isComplete:v,inRangeTime:X,cursorPos:l,hour:t.readonly(b),hour24:t.readonly(R),minute:t.readonly(y),period:t.readonly(C),time24:t.readonly(f),parsedRawTime:t.readonly(U),handleChange:A,handleKeyDown:q,handleKeyUp:o,handleClick:m,handleWheel:Z,handleBlur:p,initStyling:oe}}function je(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}const Ie=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ge=Object.prototype.toString,_e=e=>Ge.call(e)==="[object Object]",ue=()=>{},Je=Xe();function Xe(){var e,n;return Ie&&((e=window?.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((n=window?.navigator)==null?void 0:n.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function he(e){return Array.isArray(e)?e:[e]}function Qe(e,n,l){return t.watch(e,n,{...l,immediate:!0})}const Te=Ie?window:void 0;function pe(e){var n;const l=t.toValue(e);return(n=l?.$el)!=null?n:l}function be(...e){const n=[],l=()=>{n.forEach(w=>w()),n.length=0},V=(w,x,M,E)=>(w.addEventListener(x,M,E),()=>w.removeEventListener(x,M,E)),I=t.computed(()=>{const w=he(t.toValue(e[0])).filter(x=>x!=null);return w.every(x=>typeof x!="string")?w:void 0}),T=Qe(()=>{var w,x;return[(x=(w=I.value)==null?void 0:w.map(M=>pe(M)))!=null?x:[Te].filter(M=>M!=null),he(t.toValue(I.value?e[1]:e[0])),he(t.unref(I.value?e[2]:e[1])),t.toValue(I.value?e[3]:e[2])]},([w,x,M,E])=>{if(l(),!w?.length||!x?.length||!M?.length)return;const F=_e(E)?{...E}:E;n.push(...w.flatMap(b=>x.flatMap(y=>M.map(C=>V(b,y,C,F)))))},{flush:"post"}),k=()=>{T(),l()};return je(l),k}let Ce=!1;function et(e,n,l={}){const{window:V=Te,ignore:I=[],capture:T=!0,detectIframe:k=!1,controls:w=!1}=l;if(!V)return w?{stop:ue,cancel:ue,trigger:ue}:ue;if(Je&&!Ce){Ce=!0;const f={passive:!0};Array.from(V.document.body.children).forEach(v=>v.addEventListener("click",ue,f)),V.document.documentElement.addEventListener("click",ue,f)}let x=!0;const M=f=>t.toValue(I).some(v=>{if(typeof v=="string")return Array.from(V.document.querySelectorAll(v)).some(L=>L===f.target||f.composedPath().includes(L));{const L=pe(v);return L&&(f.target===L||f.composedPath().includes(L))}});function E(f){const v=t.toValue(f);return v&&v.$.subTree.shapeFlag===16}function F(f,v){const L=t.toValue(f),H=L.$.subTree&&L.$.subTree.children;return H==null||!Array.isArray(H)?!1:H.some(Y=>Y.el===v.target||v.composedPath().includes(Y.el))}const b=f=>{const v=pe(e);if(f.target!=null&&!(!(v instanceof Element)&&E(e)&&F(e,f))&&!(!v||v===f.target||f.composedPath().includes(v))){if("detail"in f&&f.detail===0&&(x=!M(f)),!x){x=!0;return}n(f)}};let y=!1;const C=[be(V,"click",f=>{y||(y=!0,setTimeout(()=>{y=!1},0),b(f))},{passive:!0,capture:T}),be(V,"pointerdown",f=>{const v=pe(e);x=!M(f)&&!!(v&&!f.composedPath().includes(v))},{passive:!0}),k&&be(V,"blur",f=>{setTimeout(()=>{var v;const L=pe(e);((v=V.document.activeElement)==null?void 0:v.tagName)==="IFRAME"&&!L?.contains(V.document.activeElement)&&n(f)},0)},{passive:!0})].filter(Boolean),R=()=>C.forEach(f=>f());return w?{stop:R,cancel:()=>{x=!1},trigger:f=>{x=!0,b(f),x=!1}}:R}function tt(e){const n=t.shallowRef(null),l=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],V=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??l].flat(),I=E=>E?typeof e.initialFocus=="string"?E.querySelector(e.initialFocus)??E:typeof e.initialFocus=="function"?e.initialFocus(E)??E:E.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??E:null,{activate:T,deactivate:k}=Ve.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>I(n.value),...e.focusTrapOptions??{}});let w=null,x=t.ref(null);const M=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const E=(b,y)=>{const C=Array.from(b.querySelectorAll(y));if(!C.length)return null;const R=C.filter(f=>f.offsetParent!==null||f.getClientRects().length>0);return R[R.length-1]??C[C.length-1]??null},F=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const b of V){const y=E(F,b);if(y)return y}for(const b of V){const y=E(document,b);if(y)return y}return null};return et(n,E=>{x.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",E)}),t.watch(()=>e.isOpen.value,E=>{E?(x.value=null,t.nextTick(()=>{const F=M();F&&(n.value=F,setTimeout(()=>T(),0),w||(w=b=>{b.key==="Escape"&&(x.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",b))},document.addEventListener("keydown",w,!0)))})):(k(),w&&(document.removeEventListener("keydown",w,!0),w=null),n.value=null,x.value==="outside"&&t.nextTick(()=>{const F=()=>{const b=e.triggerEl?.value,y=b?.querySelector("input"),C=document.activeElement;C&&(C===y||b&&b.contains(C))&&(y??b)?.blur?.()};requestAnimationFrame(()=>setTimeout(F,0))}),e.returnFocusToTrigger!==!1&&x.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const F=()=>{const b=e.triggerEl?.value;if(!b)return;(b.querySelector("input")??b)?.focus?.()};requestAnimationFrame(()=>setTimeout(F,0))})))}),{popupRef:n,activate:T,deactivate:k,lastCloseReason:t.readonly(x),setPopupEl:E=>n.value=E}}_.useFieldsetTouchTracker=Ee,_.useFieldsetValidationKit=Me,_.useGridA11y=$e,_.useGridActiveFilter=Re,_.useMaskedDateInput=Ze,_.useMaskedDateRangeInput=We,_.useMaskedTimeInput=Ye,_.usePopupTrap=tt,_.useUSAddress=He,_.useZipTextBox=xe,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(_,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vueuse/integrations/useFocusTrap")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/integrations/useFocusTrap"],t):(_=typeof globalThis<"u"?globalThis:_||self,t(_.FeatherKComposables={},_.Vue,_.useFocusTrap))})(this,(function(_,t,Ve){"use strict";const Fe=(e,n)=>{const l=t.ref(null);let b=!1,T=null,C=null;const A=[],w=".k-table-row[data-grid-row-index] [tabindex]",I=()=>{const i=e?.value?.$el;return i?i.closest(".k-grid"):null},D=i=>{const g=I();if(!g)return!1;const u=i.closest(".k-grid-aria-root");if(u)return g.contains(u);const d=i.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return d?g.contains(d):!1},M=i=>i.key==="Enter"||i.code==="Enter"||i.code==="NumpadEnter",$=()=>e?.value?.columns,S=i=>{const g=i.key||i.code;([" ","Spacebar","Space"].includes(g)||M(i))&&(i.preventDefault(),i.stopPropagation(),l.value=i.target,i.target.click())},y=i=>{if(!l.value)return;if(i.code==="Escape"){i.stopPropagation(),l.value&&l.value.focus();return}const g=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),u=document.querySelector(".k-animation-container .k-popup .k-column-menu .k-filter-menu-container");if(u){if(i.code==="Tab"){const d=[".k-dropdownlist[tabindex='0']","input.k-input-inner:not([tabindex='-1']):not([disabled])","button:not([tabindex='-1']):not([disabled])",".k-checkbox"],x=n?.focusableMenuSelectors??d,m=Array.from(u.querySelectorAll(x.join(",")));if(m.length===0)return;const E=m.findIndex(z=>z===document.activeElement);let q;E===-1?q=0:i.shiftKey?q=(E-1+m.length)%m.length:q=(E+1)%m.length,i.preventDefault(),i.stopPropagation(),m[q]?.focus()}}else if(i.code==="ArrowUp"||i.code==="ArrowDown"){i.preventDefault(),i.stopPropagation();const d=g.findIndex(m=>m===document.activeElement);let x=d;i.code==="ArrowUp"?x=d>0?d-1:g.length-1:i.code==="ArrowDown"&&(x=d<g.length-1?d+1:0),g[x]?.focus();return}if(i.code==="Tab"){i.preventDefault(),i.stopPropagation();const d=l.value?.parentElement;(i.shiftKey?d?.previousElementSibling:d?.nextElementSibling)?.querySelector("button, [role='button'], .k-link")?.focus()}},V=()=>{T=new MutationObserver(i=>{i.forEach(g=>{g.addedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;if(d.classList.contains("k-animation-container")){const m=l.value;m&&(m.dataset.featherKSortable==="true"||t.nextTick(()=>{d.querySelectorAll(".k-columnmenu-item-wrapper").forEach(z=>{z.textContent?.toLowerCase().includes("sort")&&z.remove()})})),d.addEventListener("keydown",y),t.nextTick(()=>{const E=()=>{const q=Array.from(d.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"));if(q.length===1)q[0].focus(),q[0].click(),E.attempts=0;else if(q.length>1){E.attempts=0;return}else E.attempts===void 0&&(E.attempts=0),E.attempts++<3&&setTimeout(E,200)};E()})}d.querySelectorAll(".k-animation-container").forEach(m=>{m.addEventListener("keydown",y)})}}),g.removedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;d.classList.contains("k-animation-container")&&d.removeEventListener("keydown",y),d.querySelectorAll(".k-animation-container").forEach(m=>{m.removeEventListener("keydown",y)})}})})}),T.observe(document.body,{childList:!0,subtree:!0})},R=i=>{const g=i.tagName.toLowerCase();return!!(["input","textarea","select","button"].includes(g)||i.closest('.k-picker-wrap, .k-input-inner, .k-textbox, [role="combobox"]'))},f=i=>{if(!i.type||!i)return;const g=i.target;if(!g)return;const u=g.closest(".k-table-row[data-grid-row-index]");if(!D(g))return;const d=["ArrowLeft","ArrowRight"].includes(i.code);if(!(R(g)&&!(u&&d))){if(i.code==="Escape"){const x=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(x){i.preventDefault(),i.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(E=>E.setAttribute("tabindex","-1"))}catch{}x.setAttribute("tabindex","0"),x.focus();return}}if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter","NumpadEnter","Space"].includes(i.code)){if(g.classList.contains("k-grid-header-menu")&&g.classList.contains("k-grid-column-menu")){l.value=g;return}if(u){if(["ArrowDown","ArrowUp"].includes(i.code)){i.preventDefault(),i.stopPropagation();const x=(E,q)=>{let z=q==="next"?E.nextElementSibling:E.previousElementSibling;for(;z;){const o=z;try{if(o.classList.contains("k-table-row"))return o}catch{}z=q==="next"?z.nextElementSibling:z.previousElementSibling}return null},m=i.code==="ArrowDown"?x(u,"next"):x(u,"previous");m&&(u.setAttribute("tabindex","-1"),m.setAttribute("tabindex","0"),m.focus());return}if(["ArrowLeft","ArrowRight"].includes(i.code)){i.preventDefault(),i.stopPropagation();const x=u.querySelectorAll(w);if(x.length===0)return;let m=Array.from(x).findIndex(E=>E===document.activeElement);if(m===-1&&document.activeElement===u){x[0].focus();return}i.code==="ArrowRight"?m=m===x.length-1?0:m+1:i.code==="ArrowLeft"&&(m=m===0?x.length-1:m-1),x[m].focus();return}}}}},v=()=>{t.nextTick(()=>{const i=e.value?.$el;if(!i||typeof i.closest!="function")return;const g=i.closest(".k-grid");g&&g.classList.add("fk-grid")})},L=()=>{if(!C)try{const i=()=>{try{const d=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!d||d.length===0||d.filter(E=>E.getAttribute("tabindex")==="0").length===1)return;const m=d.find(E=>E===document.activeElement||E.contains(document.activeElement));if(d.forEach(E=>E.setAttribute("tabindex","-1")),m){m.setAttribute("tabindex","0");return}d[0].setAttribute("tabindex","0")}catch(d){console.error("ensureSingleTabindex error:",d)}},g=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));g.length>0&&g.forEach((d,x)=>{d.setAttribute("tabindex",x===0?"0":"-1")});const u=e.value.$el.querySelector(".k-table-tbody");u&&(C=new MutationObserver(()=>{i()}),C.observe(u,{childList:!0,subtree:!0}))}catch(i){console.error("Error setting up row navigation:",i)}},N=()=>{t.nextTick(()=>{const g=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");g&&g.forEach(u=>{u.setAttribute("role","button"),u.addEventListener("keydown",S)}),V(),J()})},W=()=>{const g=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");g&&g.forEach(u=>{u.removeEventListener("keydown",S)}),T&&(T.disconnect(),T=null),C&&(C.disconnect(),C=null),A.forEach(u=>u()),A.length=0},J=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((u,d)=>{if(u.dataset.featherKHeaderBound==="true")return;const x=u.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!x)return;const m=$();if(m&&m[d]){const h=m[d].field??"";u.setAttribute("data-feather-k-field",h),u.setAttribute("data-feather-k-filterable",m[d].filterable===!1?"false":"true"),u.setAttribute("data-feather-k-sortable",m[d].sortable===!1?"false":"true")}const E=u.dataset.featherKFilterable!=="false",q=u.dataset.featherKSortable!=="false";x.setAttribute("tabindex","-1"),E||q?u.style.cursor="pointer":u.style.cursor="default",E?(u.setAttribute("tabindex","0"),u.setAttribute("role","button"),u.setAttribute("aria-haspopup","menu")):(u.setAttribute("tabindex","0"),u.setAttribute("role","columnheader"),u.removeAttribute("aria-haspopup"));const z=h=>{h.target?.closest(".k-column-resizer")||(l.value=u,x.click())},o=h=>{if(E)l.value=u,h.preventDefault(),h.stopPropagation(),z(h);else if(q){l.value=u;const O=u.querySelector(".k-link");O&&O.click()}};u.addEventListener("click",o),A.push(()=>{u.removeEventListener("click",o)});const p=h=>{if((M(h)||h.code==="Space")&&(E||q)){if(h.preventDefault(),h.stopPropagation(),l.value=u,l.value.focus(),E)z(h);else if(q){const O=u.querySelector(".k-link");O&&O.click()}}};u.addEventListener("keydown",p,!0),A.push(()=>{u.removeEventListener("keydown",p,!0)}),u.dataset.featherKHeaderBound="true"});const g=document.querySelector(".k-grid-header .k-table-thead");if(g&&g.dataset.featherKHeaderBound!=="true"){const u=d=>{const x=d.target.closest("th");x&&(M(d)||d.code==="Space")&&x.dataset.featherKFilterable==="false"&&x.dataset.featherKSortable==="false"&&(d.preventDefault(),d.stopImmediatePropagation())};g.addEventListener("keydown",u,!0),A.push(()=>{g.removeEventListener("keydown",u,!0)}),g.dataset.featherKHeaderBound="true"}},X=function(i,g){const u=i?.event?.event.target,d=$();if(!u||!d)return;const x=u.classList.contains("k-grid-header-menu"),m=u.classList.contains("k-columnmenu-item"),E=d.find(q=>q.field===i?.event?.field)?.sortable&&!0;if(!x){if(m&&!E){i?.event?.sort?.filter(z=>z.field!==i?.event?.field);return}typeof g=="function"&&t.nextTick(()=>{l.value&&l.value.focus(),g(i),t.nextTick(()=>{J()})})}},re=()=>{if(!b)try{v(),L(),N(),b=!0}catch(i){console.error("initA11y failed:",i),W()}};return t.onBeforeUnmount(()=>{W()}),{activeFilterButton:l,handleGridKeyDown:f,handleSortChange:X,initA11y:re}},$e=e=>!!e&&typeof e=="object"&&"filters"in e&&Array.isArray(e.filters),Pe=e=>!!e&&typeof e=="object"&&"field"in e,Ae=(e,n)=>!e||typeof e!="object"?!1:$e(e)?e.filters.some(l=>Ae(l,n)):Pe(e)?e.field===n:!1,Re=e=>n=>e.value?.filters&&e.value.filters.some(l=>Ae(l,n))?"active":"",Le="Enter a valid ZIP code with exactly 5 or 9 digits.",De=e=>{const n=e.replace(/\D/g,"").slice(0,9);return n.length>5?`${n.slice(0,5)}-${n.slice(5)}`:n},qe=(e,n)=>e.slice(0,Math.max(0,n)).replace(/\D/g,"").length,Oe=e=>e<=5?e:Math.min(e+1,10),xe=e=>{const n=t.ref(De(e.initialValue??"")),l=t.ref(!1),b=t.ref(e.errorMessage?.trim()||Le),T=t.computed(()=>n.value.replace(/\D/g,"")),C=t.computed(()=>{const y=T.value.length;return y===5||y===9}),A=t.computed(()=>l.value&&!C.value),w=t.computed(()=>!l.value||C.value),I=t.computed(()=>l.value),D=(y,V)=>{const R=Oe(V);t.nextTick(()=>{y.isConnected&&y.setSelectionRange(R,R)})};return{zipDisplay:n,submitted:l,errorMessage:b,wrapperClass:"fk-zip-textbox",zipRaw:T,isZipValid:C,showZipError:A,textBoxValid:w,textBoxValidate:I,handleZipInput:(...y)=>{const V=y[0],f=V?.event?.target,v=V?.value,L=Array.isArray(v)?v.join(""):String(v??""),N=f?.selectionStart!==void 0&&f.selectionStart!==null?qe(f.value,f.selectionStart):L.replace(/\D/g,"").length;n.value=De(L),f&&D(f,N)},submitAndValidate:y=>{l.value=!0;const V=C.value;return!V&&y?.focus&&t.nextTick(()=>{document.getElementById(e.id)?.focus()}),V},buildPayload:()=>({zip:T.value})}};function Ee(e,n){const l=t.ref(!1);t.watchEffect(()=>{e.value?.setAttribute("aria-invalid",String(!n.isValid()))});function b(C){const A=e.value??C.currentTarget,w=C.relatedTarget;(!A||!A.contains(w))&&(l.value=!0)}function T(){l.value=!1}return{touched:l,onFocusout:b,reset:T}}function Me(e,n){const l=t.ref(!1),b=t.ref(!1),T=t.computed(()=>t.toValue(n.submitted)||l.value),C=t.computed(()=>!T.value||n.isValid()),A=Ee(e,{isValid:()=>C.value});function w(S){return t.computed(()=>!T.value||t.toValue(S))}function I(S){return Object.fromEntries(Object.entries(S).map(([y,V])=>[y,w(V)]))}function D(S){const y=t.toValue(S);if(!y)return;y.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function M(S){if(b.value){b.value=!1;return}A.onFocusout(S),A.touched.value&&(l.value=!0)}function $(){l.value=!1,b.value=!0,A.reset()}return{touched:l,fieldsetValidate:T,onFocusout:M,reset:$,createFieldValidity:w,createFieldValidationsMap:I,focusFirstInvalidField:D}}const Ue=[{label:"Alabama",value:"AL"},{label:"Alaska",value:"AK"},{label:"Arizona",value:"AZ"},{label:"Arkansas",value:"AR"},{label:"California",value:"CA"},{label:"Colorado",value:"CO"},{label:"Connecticut",value:"CT"},{label:"Delaware",value:"DE"},{label:"Florida",value:"FL"},{label:"Georgia",value:"GA"},{label:"Hawaii",value:"HI"},{label:"Idaho",value:"ID"},{label:"Illinois",value:"IL"},{label:"Indiana",value:"IN"},{label:"Iowa",value:"IA"},{label:"Kansas",value:"KS"},{label:"Kentucky",value:"KY"},{label:"Louisiana",value:"LA"},{label:"Maine",value:"ME"},{label:"Maryland",value:"MD"},{label:"Massachusetts",value:"MA"},{label:"Michigan",value:"MI"},{label:"Minnesota",value:"MN"},{label:"Mississippi",value:"MS"},{label:"Missouri",value:"MO"},{label:"Montana",value:"MT"},{label:"Nebraska",value:"NE"},{label:"Nevada",value:"NV"},{label:"New Hampshire",value:"NH"},{label:"New Jersey",value:"NJ"},{label:"New Mexico",value:"NM"},{label:"New York",value:"NY"},{label:"North Carolina",value:"NC"},{label:"North Dakota",value:"ND"},{label:"Ohio",value:"OH"},{label:"Oklahoma",value:"OK"},{label:"Oregon",value:"OR"},{label:"Pennsylvania",value:"PA"},{label:"Rhode Island",value:"RI"},{label:"South Carolina",value:"SC"},{label:"South Dakota",value:"SD"},{label:"Tennessee",value:"TN"},{label:"Texas",value:"TX"},{label:"Utah",value:"UT"},{label:"Vermont",value:"VT"},{label:"Virginia",value:"VA"},{label:"Washington",value:"WA"},{label:"West Virginia",value:"WV"},{label:"Wisconsin",value:"WI"},{label:"Wyoming",value:"WY"}];function ve(e){if(e&&typeof e=="object"&&"value"in e){const n=e.value;return typeof n=="string"?n:String(n??"")}return""}function Ke(){const e=t.reactive({address1:"",address2:"",city:"",state:null,zip:""});return{formData:e,onAddress1Input:(...A)=>{e.address1=ve(A[0])},onAddress2Input:(...A)=>{e.address2=ve(A[0])},onCityInput:(...A)=>{e.city=ve(A[0])},onStateChange:A=>{A.value===null&&e.state!==null||(e.state=A.value)},resetFormData:()=>{e.address1="",e.address2="",e.city="",e.state=null,e.zip=""}}}function Ne(e,n="zip"){const l=xe({id:n}),{zipDisplay:b,zipRaw:T,isZipValid:C,wrapperClass:A,handleZipInput:w}=l;return t.watch(T,D=>{e.zip=D}),{zipDisplay:b,isZipValid:C,zipWrapperClass:A,onZipInput:w,resetZip:()=>{b.value="",e.zip=""}}}function Be(e){const n=t.computed(()=>e.formData.address1.trim()!==""),l=t.computed(()=>e.formData.city.trim()!==""),b=t.computed(()=>!!e.formData.state),T=t.computed(()=>t.toValue(e.isZipValid)),C=t.computed(()=>n.value&&l.value&&b.value&&T.value);return{strictAddress1Valid:n,strictCityValid:l,strictStateValid:b,strictZipValid:T,strictAddressValid:C}}function ze(e){if(!e)return;e.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function He(e){const n=t.ref(t.toValue(e.fieldsetRef));t.watchEffect(()=>{n.value=t.toValue(e.fieldsetRef)});const l=t.ref(!1),{formData:b,onAddress1Input:T,onAddress2Input:C,onCityInput:A,onStateChange:w,resetFormData:I}=Ke(),D=`${e.addressId}-zip`,{zipDisplay:M,isZipValid:$,zipWrapperClass:S,onZipInput:y,resetZip:V}=Ne(b,D),{strictAddress1Valid:R,strictCityValid:f,strictStateValid:v,strictZipValid:L,strictAddressValid:N}=Be({formData:b,isZipValid:$}),W=Me(n,{submitted:l,isValid:()=>N.value}),{touched:J,fieldsetValidate:X,onFocusout:re,reset:i}=W,g=W.createFieldValidationsMap({address1:R,city:f,state:v,zip:L,address:N}),{address1:u,city:d,state:x,zip:m,address:E}=g,q={value:null,label:"Select state"},z=Ue.map(({label:O,value:K})=>({label:O,value:K})),o=t.computed(()=>({address1:b.address1.trim(),address2:b.address2.trim(),city:b.city.trim(),state:(b.state??"").trim().toUpperCase(),zip:b.zip.replace(/\D/g,"")}));return{formData:b,submitted:l,touched:J,addressValidate:X,address1Valid:u,cityValid:d,stateValid:x,zipValid:m,addressValid:E,stateDefaultItem:q,stateOptions:z,zipDisplay:M,zipWrapperClass:S,onAddress1Input:T,onAddress2Input:C,onCityInput:A,onStateChange:w,onZipInput:y,onFieldsetFocusout:re,normalizedPayload:o,validateForSubmit:async()=>(l.value=!0,N.value?{isValid:!0,payload:o.value}:(await t.nextTick(),ze(n.value),{isValid:!1,payload:null})),reset:()=>{l.value=!1,i(),I(),V()}}}function Ze(e){const n=t.ref(""),l=t.ref(void 0),b=t.ref(!!e.debug),T=t.ref(e.dateFormat??"mm/dd/yyyy"),C=t.computed(()=>!!e.required),A=t.ref(!1),w=["ArrowUp","ArrowDown"],I=["ArrowLeft","ArrowRight"],D=t.computed(()=>(n.value??"").replace(/\D/g,"")),M=o=>o<=2?"mm":o<=5?"dd":D.value.length<=10?"yyyy":"mm",$=t.computed(()=>{const o=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),S=t.computed(()=>{const o=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),y=t.computed(()=>{const o=n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(4,"0")}),V=o=>{if(D.value.length===0){e.onChange({value:null,event:o});return}if(D.value.length<8){e.onChange({value:null,event:o});return}if((n.value??"").length===10&&D.value.length===8){const[p,h,O]=n.value.split("/"),K=parseInt(p),H=parseInt(h),Q=parseInt(O);if(N(Q,K,H)){const oe=new Date(Q,K-1,H);R(oe)?e.onChange({value:oe,event:o}):e.onChange({value:null,event:o})}else e.onChange({value:null,event:o})}},R=o=>{const p=e.min??void 0,h=e.max??void 0;return!(p&&o<p||h&&o>h)},f=t.computed(()=>{if((n.value??"").length===10&&D.value.length===8){const[o,p,h]=(n.value??"").split("/"),O=parseInt(o),K=parseInt(p),H=parseInt(h);if(N(H,O,K))return new Date(H,O-1,K)}return null}),v=t.computed(()=>(n.value??"").length===10&&D.value.length===8),L=(o,p)=>new Date(o,p,0).getDate(),N=(o,p,h)=>p>=1&&p<=12&&o>=1900&&h>=1&&h<=L(o,p),W=o=>{n.value=o.value;const p=o.event?.target;l.value=p?.selectionStart??0,V(o)},J=o=>{l.value=o.target.selectionStart??0},X=(o,p,h)=>{const O=p?.selectionStart??l.value??0;l.value=O;let K=parseInt($.value),H=parseInt(S.value),Q=parseInt(y.value);if(!(D.value.length>=8)||!N(Q,K,H)){const j=e.defaultValue??new Date;K=j.getMonth()+1,H=j.getDate(),Q=j.getFullYear(),n.value=`${String(K).padStart(2,"0")}/${String(H).padStart(2,"0")}/${String(Q)}`;const B=new Date(Q,K-1,H);e.onChange({value:R(B)?B:null,event:h}),d({useRAF:!0});return}const r=M(O);if(r==="mm")K=o==="ArrowUp"?K<12?K+1:1:K>1?K-1:12;else if(r==="dd"){const j=new Date(Q,K,0).getDate();H=o==="ArrowUp"?H<j?H+1:1:H>1?H-1:j}else r==="yyyy"&&(Q=o==="ArrowUp"?Q+1:Math.max(1,Q-1));n.value=`${String(K).padStart(2,"0")}/${String(H).padStart(2,"0")}/${String(Q)}`;const[s,P,U]=n.value.split("/"),Z=new Date(parseInt(U),parseInt(s)-1,parseInt(P));Z.toString()!=="Invalid Date"&&parseInt(U)>=1e3?e.onChange({value:R(Z)?Z:null,event:h}):e.onChange({value:null,event:h}),d({useRAF:!0})},re=o=>{if(o.code==="Space"||o.key===" "){o.preventDefault(),o.stopPropagation(),e.onShowCalendar(o);return}if(o.key==="ArrowDown"&&o.altKey){o.preventDefault(),o.stopPropagation(),e.onShowCalendar(o);return}if(w.includes(o.key)){if(o.altKey)return;o.preventDefault(),o.stopPropagation();const p=o.target;X(o.key,p,o);return}},i=o=>{o.preventDefault();const p=o.deltaY<0?"ArrowUp":"ArrowDown";X(p,o.target,o)},g=o=>{const p=o.target;if(I.includes(o.key)){l.value=p?.selectionStart??0;return}if(w.includes(o.key)){if(o.altKey)return;l.value=p?.selectionStart??0}},u=o=>{A.value=!0,C.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&D.value.length===0&&(e.externalValue.value="");const p=o.target;p&&(l.value=p.selectionStart??0)},d=o=>{const p=()=>{const h=document.getElementById(e.id);if(!h)return;const O=o?.pos??l.value??h.value.length;try{h.focus(),h.setSelectionRange(O,O)}catch{}};t.nextTick(()=>{if(o?.delay&&o.delay>0){setTimeout(p,o.delay);return}if(o?.useRAF){requestAnimationFrame(p);return}p()})};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const p=new Date(o);if(p.toString()!=="Invalid Date"){const h=(p.getMonth()+1).toString().padStart(2,"0"),O=p.getDate().toString().padStart(2,"0"),K=p.getFullYear().toString();n.value=`${h}/${O}/${K}`,d({delay:50});return}}},{immediate:!0});const x=t.computed(()=>[["Date",`${$.value} / ${S.value} / ${y.value}`],["Digits only",D.value],["min",e.min?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null],["max",e.max?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null]]),m=t.computed(()=>{if(!C.value){if(!v.value)return!0;const p=f.value;return p?R(p):!1}if(!A.value)return!0;const o=f.value;return!v.value||!o?!1:R(o)}),E=t.computed(()=>{if(!C.value){if(!v.value)return;const p=f.value;return p?R(p)?"valid":"out-of-bounds":"invalid-date"}if(!A.value)return;if(D.value.length===0||!v.value)return"incomplete";const o=f.value;return o?R(o)?"valid":"out-of-bounds":"invalid-date"}),q=t.computed(()=>{const o=E.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-date")return`Must be in ${T.value} format.`;const p=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,h=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(o==="out-of-bounds"){if(p&&h)return`Must be between ${p} and ${h}.`;if(p)return`Must be on or after ${p}.`;if(h)return`Must be on or before ${h}.`}return""}),z=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`ID (#${e.id}) not found for styling.`);return}const p=o.closest(".k-datepicker");if(!p){console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}const h=p.parentElement;if(h){if(h.classList.contains("fk-datepicker"))return;h.classList.add("fk-datepicker")}else console.warn(`Parent of .k-datepicker not found for #${e.id} styling.`)})};return t.onMounted(()=>{z()}),{raw:n,cursorPos:l,debugEnabled:b,debugLines:x,placeholder:T,isValid:m,reason:t.readonly(E),validationMessage:q,digitsOnly:D,month:t.readonly($),day:t.readonly(S),year:t.readonly(y),datePart:M,handleChange:W,handleKeyDown:re,handleWheel:i,handleKeyUp:g,handleClick:J,handleBlur:u,initStyling:z}}function We(e){const n=t.ref(""),l=t.ref(void 0),b=t.ref(!!e.debug),T=t.ref(!1),C=1440*60*1e3,A=365*C,w=new Date,I=new Date(w.getTime()-A),D=new Date(w.getTime()+A);e.min=e.min??I,e.max=e.max??D;const M=t.computed(()=>(n.value??"").replace(/\D/g,"")),$=(a,c)=>new Date(a,c,0).getDate(),S=(a,c,k)=>c>=1&&c<=12&&a>=1e3&&k>=1&&k<=$(a,c),y=a=>Date.UTC(a.getFullYear(),a.getMonth(),a.getDate()),V=a=>{if(!a)return null;const c=e.min??new Date(Date.now()-90*C),k=e.max??new Date,F=y(a);return F<y(c)||F>y(k)?null:a},R=(a,c)=>e.allowReverse??!1?!0:a<=c,f=t.computed(()=>(n.value?.length??0)>=23&&M.value.length>=16),v=a=>{if((a??"").length<23||M.value.length<16)return{start:null,end:null};const c=a.substring(0,10),k=a.substring(13,23),[F,ee,te]=c.split("/").map(se=>parseInt(se||"0",10)),[ie,ce,de]=k.split("/").map(se=>parseInt(se||"0",10)),fe=new Date(te,F-1,ee),ye=new Date(de,ie-1,ce),Se=S(te,F,ee)&&fe.toString()!=="Invalid Date",ke=S(de,ie,ce)&&ye.toString()!=="Invalid Date";return{start:Se?fe:null,end:ke?ye:null}},L=e.externalValid??t.ref(!0),N=t.computed(()=>v(n.value)),W=t.computed(()=>{const a=V(N.value.start),c=V(N.value.end);return{start:a,end:c}}),J=t.computed(()=>{if(!f.value)return;const a=W.value.start,c=W.value.end;if(!a||!c)return;const k=Math.abs(y(c)-y(a));return Math.round(k/864e5+1)}),X=t.computed(()=>{if(!f.value)return!1;const{start:a,end:c}=N.value;if(!a||!c||!W.value.start||!W.value.end)return!1;const k=W.value.start,F=W.value.end;return!(!R(k,F)||typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays)}),re=t.computed(()=>{const{start:a,end:c}=N.value;if(!f.value)return"incomplete";if(!a||!c)return"invalid-date";if(!W.value.start||!W.value.end)return"out-of-bounds";const k=W.value.start,F=W.value.end;return R(k,F)?typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),i=t.ref(void 0),g=t.computed(()=>{if(L.value!==!1)return"";const{min:a,max:c}=e,k=i.value;if(!k)return"";switch(k){case"incomplete":return"Required";case"invalid-date":return"One or both dates invalid.";case"reversed-range":return"End Date must be on or after Start Date.";case"out-of-bounds":return a&&c?`Dates must be between ${m(a)} and ${m(c)}.`:"Dates must be within the allowed range.";case"span-exceeds-limit":return typeof e.maxSpanDays=="number"?`Date range exceeds ${e.maxSpanDays} days.`:"Date range exceeds maximum allowed span.";default:return""}}),u=["ArrowUp","ArrowDown"],d=["ArrowLeft","ArrowRight"],x=(a,c)=>String(a).padStart(c,"0"),m=a=>`${x(a.getMonth()+1,2)}/${x(a.getDate(),2)}/${x(a.getFullYear(),4)}`,E=a=>a<=2?{side:"start",part:"mm"}:a<=5?{side:"start",part:(a<=3,"dd")}:a<=11?{side:"start",part:"yyyy"}:a<=15?{side:"end",part:"mm"}:a<=18?{side:"end",part:"dd"}:{side:"end",part:"yyyy"},q=(a,c,k)=>{const F=c?.selectionStart??l.value??0;l.value=F;const{start:ee,end:te}=v(n.value);if(!ee&&!te){const Y=new Date,le=m(Y);n.value=`${le} - ${le}`,e.onChange({value:{start:Y,end:Y},event:k}),t.nextTick(()=>{requestAnimationFrame(()=>{const ne=document.getElementById(e.id),ae=l.value??0;ne&&(ne.focus(),ne.setSelectionRange(ae,ae))})});return}const ie=new Date,ce=E(F);let de=ee?new Date(ee):new Date(ie),fe=te?new Date(te):new Date(ie);const ye=(Y,le)=>{if(le==="mm"){const ne=Y.getMonth()+1,ae=a==="ArrowUp"?ne<12?ne+1:1:ne>1?ne-1:12;Y.setMonth(ae-1);const ge=$(Y.getFullYear(),ae);Y.getDate()>ge&&Y.setDate(ge)}else if(le==="dd"){const ne=$(Y.getFullYear(),Y.getMonth()+1),ae=Y.getDate(),ge=a==="ArrowUp"?ae<ne?ae+1:1:ae>1?ae-1:ne;Y.setDate(ge)}else if(le==="yyyy"){const ne=Y.getFullYear();Y.setFullYear(a==="ArrowUp"?ne+1:Math.max(1,ne-1));const ae=$(Y.getFullYear(),Y.getMonth()+1);Y.getDate()>ae&&Y.setDate(ae)}};ce.side==="start"?ye(de,ce.part):ye(fe,ce.part);const Se=m(de),ke=m(fe);n.value=`${Se} - ${ke}`;const se=V(de),we=V(fe);se&&we&&R(se,we)?e.onChange({value:{start:se,end:we},event:k}):e.onChange({value:null,event:k}),t.nextTick(()=>{requestAnimationFrame(()=>{const Y=document.getElementById(e.id),le=l.value??0;Y&&(Y.focus(),Y.setSelectionRange(le,le))})})},z=a=>{const{start:c,end:k}=v(n.value);if(!c||!k){e.onChange({value:null,event:a});return}const F=V(c),ee=V(k);if(!F||!ee){e.onChange({value:null,event:a});return}if(!R(F,ee)){e.onChange({value:null,event:a});return}e.onChange({value:{start:F,end:ee},event:a})},o=a=>{const c=a.value??"",k=a.event;if(!c&&k&&k.type==="click"){oe(k);return}n.value=c;const F=k?.target;l.value=F?.selectionStart??0,z(a)},p=a=>{l.value=a.target.selectionStart??0},h=a=>{if(a.code==="Space"||a.key===" "){a.preventDefault(),a.stopPropagation(),e.onShowCalendar(a);return}if(a.key==="ArrowDown"&&a.altKey){a.preventDefault(),a.stopPropagation(),e.onShowCalendar(a);return}if(u.includes(a.key)){a.preventDefault(),a.stopPropagation();const c=a.target;q(a.key,c,a);return}},O=a=>{a.preventDefault();const c=a.deltaY<0?"ArrowUp":"ArrowDown";q(c,a.target,a)},K=a=>{if(d.includes(a.key)||u.includes(a.key)){const c=a.target;l.value=c?.selectionStart??0}},H=()=>{i.value=re.value,(e.manageValid??!0)&&(L.value=X.value)},Q=a=>{H()},oe=a=>{console.log("Clear event:",a),n.value="",l.value=0,e.onChange({value:null,event:a}),H(),t.nextTick(()=>{const c=document.getElementById(e.id);c&&(c.focus(),c.setSelectionRange(0,0))})};e.externalValue&&t.watch(e.externalValue,a=>{const c=a?.start??null,k=a?.end??null;if(c&&k){if(n.value=`${m(c)} - ${m(k)}`,e.isOpen?.value&&T.value&&e.onRequestClose){const F=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),T.value=!1,H()},F)}return}},{immediate:!0});const r=t.computed(()=>n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0"),s=t.computed(()=>n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0"),P=t.computed(()=>n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0"),U=t.computed(()=>n.value&&n.value.substring(13,15).replace(/\D/g,"0")||"0"),Z=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),j=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),B=t.computed(()=>{const{start:a,end:c}=v(n.value);return[{label:"Raw",value:n.value},{label:"Min Date",value:`${e.min?e.min.toDateString():"-"}`},{label:"Max Date",value:`${e.max?e.max.toDateString():"-"}`},{label:"Start",value:`${String(r.value).padStart(2,"0")} / ${String(s.value).padStart(2,"0")} / ${String(P.value).padStart(4,"0")}`},{label:"End",value:`${String(U.value).padStart(2,"0")} / ${String(Z.value).padStart(2,"0")} / ${String(j.value).padStart(4,"0")}`},{label:"Digits only",value:M.value},{label:"Mask complete",value:`${f.value}`},{label:"Parsed",value:`${a?a.toDateString():"-"} | ${c?c.toDateString():"-"}`},{label:"Valid (managed)",value:`${L.value??"-"}`},{label:"Span (days)",value:`${J.value??"-"}`},{label:"Reason",value:`${re.value??"-"}`},{label:"Cursor in",value:`${l.value??"-"} (${(()=>{const k=l.value??0,F=E(k);return`${F.side}.${F.part}`})()})`}]}),G=()=>{t.nextTick(()=>{const a=document.getElementById(e.id);if(!a){console.warn(`#${e.id} not found for styling.`);return}const c=a.closest("div");if(!c){console.warn(`Parent div of #${e.id} not found for styling.`);return}c.classList.contains("fk-daterangepicker")||c.classList.add("fk-daterangepicker")})};t.onMounted(()=>{G()});const me=()=>{t.nextTick(()=>{try{const a=Array.from(document.querySelectorAll(".k-animation-container"));if(!a.length)return;const k=[...a].reverse().find(te=>te.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!k)return;const F=k.querySelectorAll(".k-calendar-table");let ee=!1;F.forEach(te=>{te.tabIndex===0&&(ee?te.tabIndex=-1:ee=!0)})}catch(a){console.warn(a)}})};return e.isOpen&&t.watch(e.isOpen,a=>{a&&setTimeout(()=>me(),0)},{immediate:!1}),{raw:n,cursorPos:l,debugEnabled:b,debugLines:B,digitsOnly:M,valid:L,validComputed:t.readonly(X),reason:t.readonly(re),validationMessage:t.readonly(g),spanDays:t.readonly(J),month1:t.readonly(r),day1:t.readonly(s),year1:t.readonly(P),month2:t.readonly(U),day2:t.readonly(Z),year2:t.readonly(j),handleChange:o,handleKeyDown:h,handleWheel:O,handleKeyUp:K,handleClick:p,handleBlur:Q,handleClear:oe,onCalendarChange:()=>{T.value=!0},initStyling:G}}function Ye(e){const n=t.ref(""),l=t.ref(void 0),b=t.ref(!!e.debug),T=t.ref(e.timeFormat??"hh:mm AM"),C=t.computed(()=>!!e.required),A=t.ref(!1),w=["ArrowUp","ArrowDown"],I=["ArrowLeft","ArrowRight"],D=t.computed(()=>(n.value??"").replace(/\D/g,"")),M={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},$=r=>r<=2?"hh":r<=5?"mm":"ampm",S=t.computed(()=>{const r=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0",s=parseInt(r);return Math.min(Math.max(s,0),23)}),y=t.computed(()=>{const r=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0",s=parseInt(r);return Math.min(Math.max(s,0),59)}),V=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),R=t.computed(()=>{const r=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),s=V.value;return r===12?s==="AM"?0:12:s==="PM"?r+12:r}),f=t.computed(()=>v.value?`${String(R.value).padStart(2,"0")}:${String(y.value).padStart(2,"0")}:00`:null),v=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),L=(r,s,P)=>{let U=r%12;return U===0&&(U=12),`${String(U).padStart(2,"0")}:${String(s).padStart(2,"0")} ${P}`},N=r=>{const s=r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!s)return null;const P=parseInt(s[1]),U=parseInt(s[2]),Z=s[3].toUpperCase();if(P<1||P>12||U<0||U>59)return null;let j=P%12;Z==="PM"&&(j+=12);const B=new Date;return B.setSeconds(0,0),B.setHours(j),B.setMinutes(U),B},W=r=>{if(D.value.length===0){e.onChange({value:null,event:r});return}if(!v.value){e.onChange({value:null,event:r});return}const s=N(n.value);s&&X(s)?e.onChange({value:s,event:r}):e.onChange({value:null,event:r})},J=r=>r.getHours()*60+r.getMinutes(),X=r=>{const s=e.min??void 0,P=e.max??void 0,U=J(r);if(s){const Z=J(s);if(U<Z)return!1}if(P){const Z=J(P);if(U>Z)return!1}return!0},re=r=>{const s=r.getHours(),P=s>=12?"PM":"AM";n.value=L(s,r.getMinutes(),P)},i=(r,s)=>{e.onChange({value:r,event:s})},g=()=>{t.nextTick(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const r=document.getElementById(e.id);if(r){r.focus();const s=(r.value??"").length;r.setSelectionRange(s,s)}})})})},u=r=>{const s=r?.event?.target;return s?s.closest(".k-time-now")?"now":s.closest(".k-time-accept")?"set":null:null},d=(r,s)=>{r&&X(r)?i(r,s):i(null,s)},x=(...r)=>{const s=r[0];if(!s)return;const P=u(s);if(P==="now"){const Z=new Date;re(Z),d(Z,s),g();return}if(s?.value instanceof Date){const Z=new Date(s.value);re(Z),d(Z,s),P==="set"&&g();return}if(s?.value===null){n.value="",i(null,s);return}n.value=s.value;const U=s.event?.target;l.value=U?.selectionStart??0;try{const Z=l.value??0;if($(Z)==="ampm"&&(n.value??"").length>=8){const j=n.value.charAt(6);/[Aa]/.test(j)?(n.value=`${n.value.slice(0,6)}AM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const B=document.getElementById(e.id);B&&(B.focus(),B.setSelectionRange(8,8))})})):/[Pp]/.test(j)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const B=document.getElementById(e.id);B&&(B.focus(),B.setSelectionRange(8,8))})}))}}catch{}W(s)},m=r=>{l.value=r.target.selectionStart??0},E=(r,s,P)=>{const U=s?.selectionStart??l.value??0;l.value=U;const Z=$(U),j=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!j){if((n.value??"").length===0||D.value.length===0){const c=new Date,k=c.getHours(),F=k>=12?"PM":"AM";n.value=L(k,c.getMinutes(),F);const ee=N(n.value);d(ee,P),t.nextTick(()=>{requestAnimationFrame(()=>{const te=document.getElementById(e.id),ie=l.value??0;te&&(te.focus(),te.setSelectionRange(ie,ie))})})}return}let B=parseInt(j[1]),G=parseInt(j[2]),me=j[3].toUpperCase();if(Z==="hh")r==="ArrowUp"?B=B<12?B+1:1:B=B>1?B-1:12;else if(Z==="mm"){const c=e.minuteStepRef?.value??e.minuteStep??1;if(c===1)r==="ArrowUp"?G=G<59?G+1:0:G=G>0?G-1:59;else if(r==="ArrowUp"){const k=G%c;let F=k===0?G+c:G+(c-k);F>=60&&(F=0),G=F}else{const k=G%c;let F=k===0?G-c:G-k;F<0&&(F=60-c),G=F}}else Z==="ampm"&&(me=me==="AM"?"PM":"AM");n.value=`${String(B).padStart(2,"0")}:${String(G).padStart(2,"0")} ${me}`;const a=N(n.value);d(a,P),t.nextTick(()=>{requestAnimationFrame(()=>{const c=document.getElementById(e.id),k=l.value??0;c&&(c.focus(),c.setSelectionRange(k,k))})})},q=r=>{if(r.code==="Space"||r.key===" "){r.preventDefault(),r.stopPropagation(),e.onShowPicker(r);return}if(r.key==="ArrowDown"&&r.altKey){r.preventDefault(),r.stopPropagation(),e.onShowPicker(r);return}if(w.includes(r.key)){if(r.altKey)return;r.preventDefault(),r.stopPropagation();const s=r.target;E(r.key,s,r);return}},z=r=>{r.preventDefault();const s=r.deltaY<0?"ArrowUp":"ArrowDown";E(s,r.target,r)},o=r=>{const s=r.target;if(I.includes(r.key)){l.value=s?.selectionStart??0;return}if(w.includes(r.key)){if(r.altKey)return;l.value=s?.selectionStart??0}},p=r=>{A.value=!0,C.value&&e.externalValue&&e.externalValue.value===void 0&&D.value.length===0&&(e.externalValue.value="");const s=r.target;s&&(l.value=s.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,r=>{if(r){const s=new Date(r);if(s.toString()!=="Invalid Date"){const P=s.getHours(),U=P>=12?"PM":"AM";n.value=L(P,s.getMinutes(),U);return}}},{immediate:!0});const h=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",S.value],["Hour (24h)",R.value],["Minute",y.value],["Period",V.value],["Time (24h)",f.value??"--:--:--"],["Digits only",D.value],["Parsed Date",O.value?.toLocaleDateString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["min",e.min?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["max",e.max?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["valid",K.value],["reason",H.value],["validationMessage",Q.value]]),O=t.computed(()=>N(n.value)??null),K=t.computed(()=>{if(!C.value){if(!v.value)return!0;const s=O.value;return s?X(s):!1}if(!A.value)return!0;const r=O.value;return!v.value||!r?!1:X(r)}),H=t.computed(()=>{if(!C.value){if(!v.value)return;const s=O.value;return s?X(s)?"valid":"out-of-bounds":"invalid-time"}if(!A.value)return;if(D.value.length===0||!v.value)return"incomplete";const r=O.value;return r?X(r)?"valid":"out-of-bounds":"invalid-time"}),Q=t.computed(()=>{const r=H.value;if(!r||r==="valid")return"";if(r==="incomplete")return"Required";if(r==="invalid-time")return`Must be in ${T.value} format.`;const s={hour:"2-digit",minute:"2-digit"},P=e.min?e.min.toLocaleTimeString("en-US",s):null,U=e.max?e.max.toLocaleTimeString("en-US",s):null;if(r==="out-of-bounds"){if(P&&U)return`Must be between ${P} and ${U}.`;if(P)return`Must be ${P} or later.`;if(U)return`Must be ${U} or earlier.`}return""}),oe=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`#${e.id} not found for styling.`);return}const s=r.closest(".k-timepicker");if(!s){console.warn(`.k-timepicker parent of #${e.id} not found for styling.`);return}const P=s.parentElement;if(!P){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}P.classList.contains("fk-timepicker")||P.classList.add("fk-timepicker")})};return t.onMounted(()=>{oe()}),{raw:n,rules:M,debugEnabled:b,debugLines:h,placeholder:T,isValid:K,reason:t.readonly(H),validationMessage:Q,isComplete:v,inRangeTime:X,cursorPos:l,hour:t.readonly(S),hour24:t.readonly(R),minute:t.readonly(y),period:t.readonly(V),time24:t.readonly(f),parsedRawTime:t.readonly(O),handleChange:x,handleKeyDown:q,handleKeyUp:o,handleClick:m,handleWheel:z,handleBlur:p,initStyling:oe}}function je(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}const Ie=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ge=Object.prototype.toString,_e=e=>Ge.call(e)==="[object Object]",ue=()=>{},Je=Xe();function Xe(){var e,n;return Ie&&((e=window?.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((n=window?.navigator)==null?void 0:n.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function he(e){return Array.isArray(e)?e:[e]}function Qe(e,n,l){return t.watch(e,n,{...l,immediate:!0})}const Te=Ie?window:void 0;function pe(e){var n;const l=t.toValue(e);return(n=l?.$el)!=null?n:l}function be(...e){const n=[],l=()=>{n.forEach(w=>w()),n.length=0},b=(w,I,D,M)=>(w.addEventListener(I,D,M),()=>w.removeEventListener(I,D,M)),T=t.computed(()=>{const w=he(t.toValue(e[0])).filter(I=>I!=null);return w.every(I=>typeof I!="string")?w:void 0}),C=Qe(()=>{var w,I;return[(I=(w=T.value)==null?void 0:w.map(D=>pe(D)))!=null?I:[Te].filter(D=>D!=null),he(t.toValue(T.value?e[1]:e[0])),he(t.unref(T.value?e[2]:e[1])),t.toValue(T.value?e[3]:e[2])]},([w,I,D,M])=>{if(l(),!w?.length||!I?.length||!D?.length)return;const $=_e(M)?{...M}:M;n.push(...w.flatMap(S=>I.flatMap(y=>D.map(V=>b(S,y,V,$)))))},{flush:"post"}),A=()=>{C(),l()};return je(l),A}let Ce=!1;function et(e,n,l={}){const{window:b=Te,ignore:T=[],capture:C=!0,detectIframe:A=!1,controls:w=!1}=l;if(!b)return w?{stop:ue,cancel:ue,trigger:ue}:ue;if(Je&&!Ce){Ce=!0;const f={passive:!0};Array.from(b.document.body.children).forEach(v=>v.addEventListener("click",ue,f)),b.document.documentElement.addEventListener("click",ue,f)}let I=!0;const D=f=>t.toValue(T).some(v=>{if(typeof v=="string")return Array.from(b.document.querySelectorAll(v)).some(L=>L===f.target||f.composedPath().includes(L));{const L=pe(v);return L&&(f.target===L||f.composedPath().includes(L))}});function M(f){const v=t.toValue(f);return v&&v.$.subTree.shapeFlag===16}function $(f,v){const L=t.toValue(f),N=L.$.subTree&&L.$.subTree.children;return N==null||!Array.isArray(N)?!1:N.some(W=>W.el===v.target||v.composedPath().includes(W.el))}const S=f=>{const v=pe(e);if(f.target!=null&&!(!(v instanceof Element)&&M(e)&&$(e,f))&&!(!v||v===f.target||f.composedPath().includes(v))){if("detail"in f&&f.detail===0&&(I=!D(f)),!I){I=!0;return}n(f)}};let y=!1;const V=[be(b,"click",f=>{y||(y=!0,setTimeout(()=>{y=!1},0),S(f))},{passive:!0,capture:C}),be(b,"pointerdown",f=>{const v=pe(e);I=!D(f)&&!!(v&&!f.composedPath().includes(v))},{passive:!0}),A&&be(b,"blur",f=>{setTimeout(()=>{var v;const L=pe(e);((v=b.document.activeElement)==null?void 0:v.tagName)==="IFRAME"&&!L?.contains(b.document.activeElement)&&n(f)},0)},{passive:!0})].filter(Boolean),R=()=>V.forEach(f=>f());return w?{stop:R,cancel:()=>{I=!1},trigger:f=>{I=!0,S(f),I=!1}}:R}function tt(e){const n=t.shallowRef(null),l=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],b=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??l].flat(),T=M=>M?typeof e.initialFocus=="string"?M.querySelector(e.initialFocus)??M:typeof e.initialFocus=="function"?e.initialFocus(M)??M:M.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??M:null,{activate:C,deactivate:A}=Ve.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>T(n.value),...e.focusTrapOptions??{}});let w=null,I=t.ref(null);const D=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const M=(S,y)=>{const V=Array.from(S.querySelectorAll(y));if(!V.length)return null;const R=V.filter(f=>f.offsetParent!==null||f.getClientRects().length>0);return R[R.length-1]??V[V.length-1]??null},$=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const S of b){const y=M($,S);if(y)return y}for(const S of b){const y=M(document,S);if(y)return y}return null};return et(n,M=>{I.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",M)}),t.watch(()=>e.isOpen.value,M=>{M?(I.value=null,t.nextTick(()=>{const $=D();$&&(n.value=$,setTimeout(()=>C(),0),w||(w=S=>{S.key==="Escape"&&(I.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",S))},document.addEventListener("keydown",w,!0)))})):(A(),w&&(document.removeEventListener("keydown",w,!0),w=null),n.value=null,I.value==="outside"&&t.nextTick(()=>{const $=()=>{const S=e.triggerEl?.value,y=S?.querySelector("input"),V=document.activeElement;V&&(V===y||S&&S.contains(V))&&(y??S)?.blur?.()};requestAnimationFrame(()=>setTimeout($,0))}),e.returnFocusToTrigger!==!1&&I.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const $=()=>{const S=e.triggerEl?.value;if(!S)return;(S.querySelector("input")??S)?.focus?.()};requestAnimationFrame(()=>setTimeout($,0))})))}),{popupRef:n,activate:C,deactivate:A,lastCloseReason:t.readonly(I),setPopupEl:M=>n.value=M}}_.useFieldsetTouchTracker=Ee,_.useFieldsetValidationKit=Me,_.useGridA11y=Fe,_.useGridActiveFilter=Re,_.useMaskedDateInput=Ze,_.useMaskedDateRangeInput=We,_.useMaskedTimeInput=Ye,_.usePopupTrap=tt,_.useUSAddress=He,_.useZipTextBox=xe,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -10,7 +10,7 @@ Composable that orchestrates a full US address form experience for Kendo Vue inp
|
|
|
10
10
|
- `useZipTextBox` for dynamic ZIP/ZIP+4 formatting and validity
|
|
11
11
|
- internal field/state handlers for address lines, city, and state
|
|
12
12
|
|
|
13
|
-
It returns field bindings, delayed validity refs,
|
|
13
|
+
It returns field bindings, delayed validity refs, validation/reset actions, and a normalized payload.
|
|
14
14
|
|
|
15
15
|
## Prerequisites
|
|
16
16
|
|
|
@@ -23,16 +23,15 @@ It returns field bindings, delayed validity refs, submit/reset actions, and a no
|
|
|
23
23
|
import { ref } from "vue";
|
|
24
24
|
import { useUSAddress } from "@featherk/composables/address";
|
|
25
25
|
|
|
26
|
-
const formRef = ref<HTMLFormElement | null>(null);
|
|
27
26
|
const fieldsetRef = ref<HTMLFieldSetElement | null>(null);
|
|
28
27
|
|
|
29
28
|
const address = useUSAddress({
|
|
30
|
-
formRef,
|
|
31
29
|
fieldsetRef,
|
|
30
|
+
addressId: "shipping-address",
|
|
32
31
|
});
|
|
33
32
|
|
|
34
33
|
async function onSubmit() {
|
|
35
|
-
const result = await address.
|
|
34
|
+
const result = await address.validateForSubmit();
|
|
36
35
|
|
|
37
36
|
if (!result.isValid) {
|
|
38
37
|
return;
|
|
@@ -49,7 +48,7 @@ function onReset() {
|
|
|
49
48
|
|
|
50
49
|
## Payload
|
|
51
50
|
|
|
52
|
-
`
|
|
51
|
+
`validateForSubmit()` returns a normalized payload when valid:
|
|
53
52
|
|
|
54
53
|
```ts
|
|
55
54
|
export interface USAddressSubmitPayload {
|
|
@@ -90,12 +89,12 @@ Handlers:
|
|
|
90
89
|
|
|
91
90
|
Actions:
|
|
92
91
|
|
|
93
|
-
- `
|
|
92
|
+
- `validateForSubmit()`
|
|
94
93
|
- `reset()`
|
|
95
94
|
|
|
96
95
|
## Behavior Notes
|
|
97
96
|
|
|
98
97
|
- Delayed validation is inactive until submit or fieldset touch.
|
|
99
|
-
- Invalid submit focuses the first invalid Kendo control in the
|
|
98
|
+
- Invalid submit focuses the first invalid Kendo control in the fieldset.
|
|
100
99
|
- Reset clears submit/touch state and field values.
|
|
101
100
|
- ZIP behavior remains delegated to `useZipTextBox`.
|