@featherk/composables 0.9.6 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/featherk-composables.es.js +1053 -1043
- package/dist/featherk-composables.es.js.map +1 -1
- package/dist/featherk-composables.umd.js +1 -1
- package/dist/featherk-composables.umd.js.map +1 -1
- package/docs/address/useUSAddress.md +8 -1
- package/docs/date/useMaskedDateInput.md +2 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(Q,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):(Q=typeof globalThis<"u"?globalThis:Q||self,t(Q.FeatherKComposables={},Q.Vue,Q.useFocusTrap))})(this,(function(Q,t,Ve){"use strict";const Fe=(e,n)=>{const l=t.ref(null);let h=!1,m=null,C=null;const M=[],A=".k-table-row[data-grid-row-index] [tabindex]",T=()=>{const i=e?.value?.$el;return i?i.closest(".k-grid"):null},D=i=>{const v=T();if(!v)return!1;const u=i.closest(".k-grid-aria-root");if(u)return v.contains(u);const d=i.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return d?v.contains(d):!1},I=i=>i.key==="Enter"||i.code==="Enter"||i.code==="NumpadEnter",P=()=>e?.value?.columns,w=i=>{const v=i.key||i.code;([" ","Spacebar","Space"].includes(v)||I(i))&&(i.preventDefault(),i.stopPropagation(),l.value=i.target,i.target.click())},g=i=>{if(!l.value)return;if(i.code==="Escape"){i.stopPropagation(),l.value&&l.value.focus();return}const v=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,y=Array.from(u.querySelectorAll(x.join(",")));if(y.length===0)return;const E=y.findIndex(Z=>Z===document.activeElement);let q;E===-1?q=0:i.shiftKey?q=(E-1+y.length)%y.length:q=(E+1)%y.length,i.preventDefault(),i.stopPropagation(),y[q]?.focus()}}else if(i.code==="ArrowUp"||i.code==="ArrowDown"){i.preventDefault(),i.stopPropagation();const d=v.findIndex(y=>y===document.activeElement);let x=d;i.code==="ArrowUp"?x=d>0?d-1:v.length-1:i.code==="ArrowDown"&&(x=d<v.length-1?d+1:0),v[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=()=>{m=new MutationObserver(i=>{i.forEach(v=>{v.addedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;if(d.classList.contains("k-animation-container")){const y=l.value;y&&(y.dataset.featherKSortable==="true"||t.nextTick(()=>{d.querySelectorAll(".k-columnmenu-item-wrapper").forEach(Z=>{Z.textContent?.toLowerCase().includes("sort")&&Z.remove()})})),d.addEventListener("keydown",g),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(y=>{y.addEventListener("keydown",g)})}}),v.removedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;d.classList.contains("k-animation-container")&&d.removeEventListener("keydown",g),d.querySelectorAll(".k-animation-container").forEach(y=>{y.removeEventListener("keydown",g)})}})})}),m.observe(document.body,{childList:!0,subtree:!0})},R=i=>{const v=i.tagName.toLowerCase();return!!(["input","textarea","select","button"].includes(v)||i.closest('.k-picker-wrap, .k-input-inner, .k-textbox, [role="combobox"]'))},f=i=>{if(!i.type||!i)return;const v=i.target;if(!v)return;const u=v.closest(".k-table-row[data-grid-row-index]");if(!D(v))return;const d=["ArrowLeft","ArrowRight"].includes(i.code);if(!(R(v)&&!(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(v.classList.contains("k-grid-header-menu")&&v.classList.contains("k-grid-column-menu")){l.value=v;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},y=i.code==="ArrowDown"?x(u,"next"):x(u,"previous");y&&(u.setAttribute("tabindex","-1"),y.setAttribute("tabindex","0"),y.focus());return}if(["ArrowLeft","ArrowRight"].includes(i.code)){i.preventDefault(),i.stopPropagation();const x=u.querySelectorAll(A);if(x.length===0)return;let y=Array.from(x).findIndex(E=>E===document.activeElement);if(y===-1&&document.activeElement===u){x[0].focus();return}i.code==="ArrowRight"?y=y===x.length-1?0:y+1:i.code==="ArrowLeft"&&(y=y===0?x.length-1:y-1),x[y].focus();return}}}}},b=()=>{t.nextTick(()=>{const i=e.value?.$el;if(!i||typeof i.closest!="function")return;const v=i.closest(".k-grid");v&&v.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 y=d.find(E=>E===document.activeElement||E.contains(document.activeElement));if(d.forEach(E=>E.setAttribute("tabindex","-1")),y){y.setAttribute("tabindex","0");return}d[0].setAttribute("tabindex","0")}catch(d){console.error("ensureSingleTabindex error:",d)}},v=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));v.length>0&&v.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)}},W=()=>{t.nextTick(()=>{const v=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");v&&v.forEach(u=>{u.setAttribute("role","button"),u.addEventListener("keydown",w)}),V(),J()})},N=()=>{const v=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");v&&v.forEach(u=>{u.removeEventListener("keydown",w)}),m&&(m.disconnect(),m=null),C&&(C.disconnect(),C=null),M.forEach(u=>u()),M.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 y=P();if(y&&y[d]){const S=y[d].field??"";u.setAttribute("data-feather-k-field",S),u.setAttribute("data-feather-k-filterable",y[d].filterable===!1?"false":"true"),u.setAttribute("data-feather-k-sortable",y[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=S=>{S.target?.closest(".k-column-resizer")||(l.value=u,x.click())},o=S=>{if(E)l.value=u,S.preventDefault(),S.stopPropagation(),Z(S);else if(q){l.value=u;const U=u.querySelector(".k-link");U&&U.click()}};u.addEventListener("click",o),M.push(()=>{u.removeEventListener("click",o)});const p=S=>{if((I(S)||S.code==="Space")&&(E||q)){if(S.preventDefault(),S.stopPropagation(),l.value=u,l.value.focus(),E)Z(S);else if(q){const U=u.querySelector(".k-link");U&&U.click()}}};u.addEventListener("keydown",p,!0),M.push(()=>{u.removeEventListener("keydown",p,!0)}),u.dataset.featherKHeaderBound="true"});const v=document.querySelector(".k-grid-header .k-table-thead");if(v&&v.dataset.featherKHeaderBound!=="true"){const u=d=>{const x=d.target.closest("th");x&&(I(d)||d.code==="Space")&&x.dataset.featherKFilterable==="false"&&x.dataset.featherKSortable==="false"&&(d.preventDefault(),d.stopImmediatePropagation())};v.addEventListener("keydown",u,!0),M.push(()=>{v.removeEventListener("keydown",u,!0)}),v.dataset.featherKHeaderBound="true"}},X=function(i,v){const u=i?.event?.event.target,d=P();if(!u||!d)return;const x=u.classList.contains("k-grid-header-menu"),y=u.classList.contains("k-columnmenu-item"),E=d.find(q=>q.field===i?.event?.field)?.sortable&&!0;if(!x){if(y&&!E){i?.event?.sort?.filter(Z=>Z.field!==i?.event?.field);return}typeof v=="function"&&t.nextTick(()=>{l.value&&l.value.focus(),v(i),t.nextTick(()=>{J()})})}},oe=()=>{if(!h)try{b(),L(),W(),h=!0}catch(i){console.error("initA11y failed:",i),N()}};return t.onBeforeUnmount(()=>{N()}),{activeFilterButton:l,handleGridKeyDown:f,handleSortChange:X,initA11y:oe}},$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),h=t.ref(e.errorMessage?.trim()||Le),m=t.computed(()=>n.value.replace(/\D/g,"")),C=t.computed(()=>{const g=m.value.length;return g===5||g===9}),M=t.computed(()=>l.value&&!C.value),A=t.computed(()=>!l.value||C.value),T=t.computed(()=>l.value),D=(g,V)=>{const R=Oe(V);t.nextTick(()=>{g.isConnected&&g.setSelectionRange(R,R)})};return{zipDisplay:n,submitted:l,errorMessage:h,wrapperClass:"fk-zip-textbox",zipRaw:m,isZipValid:C,showZipError:M,textBoxValid:A,textBoxValidate:T,handleZipInput:(...g)=>{const V=g[0],f=V?.event?.target,b=V?.value,L=Array.isArray(b)?b.join(""):String(b??""),W=f?.selectionStart!==void 0&&f.selectionStart!==null?qe(f.value,f.selectionStart):L.replace(/\D/g,"").length;n.value=De(L),f&&D(f,W)},submitAndValidate:g=>{l.value=!0;const V=C.value;return!V&&g?.focus&&t.nextTick(()=>{document.getElementById(e.id)?.focus()}),V},buildPayload:()=>({zip:m.value})}};function Ee(e,n){const l=t.ref(!1);t.watchEffect(()=>{e.value?.setAttribute("aria-invalid",String(!n.isValid()))});function h(C){const M=e.value??C.currentTarget,A=C.relatedTarget;(!M||!M.contains(A))&&(l.value=!0)}function m(){l.value=!1}return{touched:l,onFocusout:h,reset:m}}function Me(e,n){const l=t.ref(!1),h=t.ref(!1),m=t.computed(()=>t.toValue(n.submitted)||l.value),C=t.computed(()=>!m.value||n.isValid()),M=Ee(e,{isValid:()=>C.value});function A(w){return t.computed(()=>!m.value||t.toValue(w))}function T(w){return Object.fromEntries(Object.entries(w).map(([g,V])=>[g,A(V)]))}function D(w){const g=t.toValue(w);if(!g)return;g.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function I(w){if(h.value){h.value=!1;return}M.onFocusout(w),M.touched.value&&(l.value=!0)}function P(){l.value=!1,h.value=!0,M.reset()}return{touched:l,fieldsetValidate:m,onFocusout:I,reset:P,createFieldValidity:A,createFieldValidationsMap:T,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 ge(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:(...M)=>{e.address1=ge(M[0])},onAddress2Input:(...M)=>{e.address2=ge(M[0])},onCityInput:(...M)=>{e.city=ge(M[0])},onStateChange:M=>{e.state=M.value},resetFormData:()=>{e.address1="",e.address2="",e.city="",e.state=null,e.zip=""}}}function Ne(e,n="zip"){const l=xe({id:n}),{zipDisplay:h,zipRaw:m,isZipValid:C,wrapperClass:M,handleZipInput:A}=l;return t.watch(m,D=>{e.zip=D}),{zipDisplay:h,isZipValid:C,zipWrapperClass:M,onZipInput:A,resetZip:()=>{h.value="",e.zip=""}}}function Be(e){const n=t.computed(()=>e.formData.address1.trim()!==""),l=t.computed(()=>e.formData.city.trim()!==""),h=t.computed(()=>!!e.formData.state),m=t.computed(()=>t.toValue(e.isZipValid)),C=t.computed(()=>n.value&&l.value&&h.value&&m.value);return{strictAddress1Valid:n,strictCityValid:l,strictStateValid:h,strictZipValid:m,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),h=t.computed(()=>t.toValue(e.required)??!0),{formData:m,onAddress1Input:C,onAddress2Input:M,onCityInput:A,onStateChange:T,resetFormData:D}=Ke(),I=`${e.addressId}-zip`,{zipDisplay:P,isZipValid:w,zipWrapperClass:g,onZipInput:V,resetZip:R}=Ne(m,I),{strictAddress1Valid:f,strictCityValid:b,strictStateValid:L,strictZipValid:W,strictAddressValid:N}=Be({formData:m,isZipValid:w}),J=Me(n,{submitted:l,isValid:()=>N.value}),{touched:X,fieldsetValidate:oe,onFocusout:i,reset:v}=J,u=J.createFieldValidationsMap({address1:f,city:b,state:L,zip:W,address:N}),{address1:d,city:x,state:y,zip:E,address:q}=u,Z=t.computed(()=>h.value?oe.value:!1),o=t.computed(()=>h.value?d.value:!0),p=t.computed(()=>h.value?x.value:!0),S=t.computed(()=>h.value?y.value:!0),U=t.computed(()=>h.value?E.value:!0),B=t.computed(()=>h.value?q.value:!0),z={value:null,label:"State"},G=Ue.map(({label:a,value:c})=>({label:a,value:c})),ae=t.computed(()=>({address1:m.address1.trim(),address2:m.address2.trim(),city:m.city.trim(),state:(m.state??"").trim().toUpperCase(),zip:m.zip.replace(/\D/g,"")})),r=t.computed(()=>m.address1.trim()===""&&m.address2.trim()===""&&m.city.trim()===""&&(m.state??"").trim()===""&&m.zip.replace(/\D/g,"")===""),s=t.computed(()=>!r.value),F=t.computed(()=>!h.value&&s.value&&(!f.value||!b.value||!L.value)),O=t.computed(()=>{const a=m.zip.replace(/\D/g,"");return!h.value&&s.value&&a.length!==5&&a.length!==9}),K=t.computed(()=>!h.value&&s.value&&!N.value),j=t.computed(()=>!h.value&&K.value&&(X.value||l.value));return t.watch(h,a=>{a||(l.value=!1,v())}),{formData:m,submitted:l,touched:X,addressValidate:Z,address1Valid:o,cityValid:p,stateValid:S,zipValid:U,addressValid:B,optionalFeedbackActive:j,optionalPartialInvalid:K,optionalMissingRequiredFields:F,optionalZipInvalid:O,stateDefaultItem:z,stateOptions:G,zipDisplay:P,zipWrapperClass:g,onAddress1Input:C,onAddress2Input:M,onCityInput:A,onStateChange:T,onZipInput:V,onFieldsetFocusout:a=>{i(a)},normalizedPayload:ae,validateForSubmit:async()=>h.value?(l.value=!0,N.value?{isValid:!0,payload:ae.value}:(await t.nextTick(),ze(n.value),{isValid:!1,payload:null})):r.value||N.value?(l.value=!1,{isValid:!0,payload:ae.value}):(l.value=!0,{isValid:!1,payload:null}),reset:()=>{l.value=!1,v(),D(),R()}}}function Ze(e){const n=t.ref(""),l=t.ref(void 0),h=t.ref(!!e.debug),m=t.ref(e.dateFormat??"mm/dd/yyyy"),C=t.computed(()=>!!e.required),M=t.ref(!1),A=["ArrowUp","ArrowDown"],T=["ArrowLeft","ArrowRight"],D=t.computed(()=>(n.value??"").replace(/\D/g,"")),I=o=>o<=2?"mm":o<=5?"dd":D.value.length<=10?"yyyy":"mm",P=t.computed(()=>{const o=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),w=t.computed(()=>{const o=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),g=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,S,U]=n.value.split("/"),B=parseInt(p),z=parseInt(S),G=parseInt(U);if(W(G,B,z)){const ae=new Date(G,B-1,z);R(ae)?e.onChange({value:ae,event:o}):e.onChange({value:null,event:o})}else e.onChange({value:null,event:o})}},R=o=>{const p=e.min??void 0,S=e.max??void 0;return!(p&&o<p||S&&o>S)},f=t.computed(()=>{if((n.value??"").length===10&&D.value.length===8){const[o,p,S]=(n.value??"").split("/"),U=parseInt(o),B=parseInt(p),z=parseInt(S);if(W(z,U,B))return new Date(z,U-1,B)}return null}),b=t.computed(()=>(n.value??"").length===10&&D.value.length===8),L=(o,p)=>new Date(o,p,0).getDate(),W=(o,p,S)=>p>=1&&p<=12&&o>=1900&&S>=1&&S<=L(o,p),N=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,S)=>{const U=p?.selectionStart??l.value??0;l.value=U;let B=parseInt(P.value),z=parseInt(w.value),G=parseInt(g.value);if(!(D.value.length>=8)||!W(G,B,z)){const j=e.defaultValue??new Date;B=j.getMonth()+1,z=j.getDate(),G=j.getFullYear(),n.value=`${String(B).padStart(2,"0")}/${String(z).padStart(2,"0")}/${String(G)}`;const H=new Date(G,B-1,z);e.onChange({value:R(H)?H:null,event:S}),d({useRAF:!0});return}const r=I(U);if(r==="mm")B=o==="ArrowUp"?B<12?B+1:1:B>1?B-1:12;else if(r==="dd"){const j=new Date(G,B,0).getDate();z=o==="ArrowUp"?z<j?z+1:1:z>1?z-1:j}else r==="yyyy"&&(G=o==="ArrowUp"?G+1:Math.max(1,G-1));n.value=`${String(B).padStart(2,"0")}/${String(z).padStart(2,"0")}/${String(G)}`;const[s,F,O]=n.value.split("/"),K=new Date(parseInt(O),parseInt(s)-1,parseInt(F));K.toString()!=="Invalid Date"&&parseInt(O)>=1e3?e.onChange({value:R(K)?K:null,event:S}):e.onChange({value:null,event:S}),d({useRAF:!0})},oe=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(A.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)},v=o=>{const p=o.target;if(T.includes(o.key)){l.value=p?.selectionStart??0;return}if(A.includes(o.key)){if(o.altKey)return;l.value=p?.selectionStart??0}},u=o=>{M.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 S=document.getElementById(e.id);if(!S)return;const U=o?.pos??l.value??S.value.length;try{S.focus(),S.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 S=(p.getMonth()+1).toString().padStart(2,"0"),U=p.getDate().toString().padStart(2,"0"),B=p.getFullYear().toString();n.value=`${S}/${U}/${B}`,d({delay:50});return}}},{immediate:!0});const x=t.computed(()=>[["Date",`${P.value} / ${w.value} / ${g.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]]),y=t.computed(()=>{if(!C.value){if(!b.value)return!0;const p=f.value;return p?R(p):!1}if(!M.value)return!0;const o=f.value;return!b.value||!o?!1:R(o)}),E=t.computed(()=>{if(!C.value){if(!b.value)return;const p=f.value;return p?R(p)?"valid":"out-of-bounds":"invalid-date"}if(!M.value)return;if(D.value.length===0||!b.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 ${m.value} format.`;const p=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,S=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(o==="out-of-bounds"){if(p&&S)return`Must be between ${p} and ${S}.`;if(p)return`Must be on or after ${p}.`;if(S)return`Must be on or before ${S}.`}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 S=p.parentElement;if(S){if(S.classList.contains("fk-datepicker"))return;S.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:h,debugLines:x,placeholder:m,isValid:y,reason:t.readonly(E),validationMessage:q,digitsOnly:D,month:t.readonly(P),day:t.readonly(w),year:t.readonly(g),datePart:I,handleChange:N,handleKeyDown:oe,handleWheel:i,handleKeyUp:v,handleClick:J,handleBlur:u,initStyling:Z}}function We(e){const n=t.ref(""),l=t.ref(void 0),h=t.ref(!!e.debug),m=t.ref(!1),C=1440*60*1e3,M=365*C,A=new Date,T=new Date(A.getTime()-M),D=new Date(A.getTime()+M);e.min=e.min??T,e.max=e.max??D;const I=t.computed(()=>(n.value??"").replace(/\D/g,"")),P=(a,c)=>new Date(a,c,0).getDate(),w=(a,c,k)=>c>=1&&c<=12&&a>=1e3&&k>=1&&k<=P(a,c),g=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,$=g(a);return $<g(c)||$>g(k)?null:a},R=(a,c)=>e.allowReverse??!1?!0:a<=c,f=t.computed(()=>(n.value?.length??0)>=23&&I.value.length>=16),b=a=>{if((a??"").length<23||I.value.length<16)return{start:null,end:null};const c=a.substring(0,10),k=a.substring(13,23),[$,ee,te]=c.split("/").map(se=>parseInt(se||"0",10)),[ie,de,fe]=k.split("/").map(se=>parseInt(se||"0",10)),pe=new Date(te,$-1,ee),ye=new Date(fe,ie-1,de),Se=w(te,$,ee)&&pe.toString()!=="Invalid Date",we=w(fe,ie,de)&&ye.toString()!=="Invalid Date";return{start:Se?pe:null,end:we?ye:null}},L=e.externalValid??t.ref(!0),W=t.computed(()=>b(n.value)),N=t.computed(()=>{const a=V(W.value.start),c=V(W.value.end);return{start:a,end:c}}),J=t.computed(()=>{if(!f.value)return;const a=N.value.start,c=N.value.end;if(!a||!c)return;const k=Math.abs(g(c)-g(a));return Math.round(k/864e5+1)}),X=t.computed(()=>{if(!f.value)return!1;const{start:a,end:c}=W.value;if(!a||!c||!N.value.start||!N.value.end)return!1;const k=N.value.start,$=N.value.end;return!(!R(k,$)||typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays)}),oe=t.computed(()=>{const{start:a,end:c}=W.value;if(!f.value)return"incomplete";if(!a||!c)return"invalid-date";if(!N.value.start||!N.value.end)return"out-of-bounds";const k=N.value.start,$=N.value.end;return R(k,$)?typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),i=t.ref(void 0),v=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 ${y(a)} and ${y(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"),y=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 $=c?.selectionStart??l.value??0;l.value=$;const{start:ee,end:te}=b(n.value);if(!ee&&!te){const Y=new Date,le=y(Y);n.value=`${le} - ${le}`,e.onChange({value:{start:Y,end:Y},event:k}),t.nextTick(()=>{requestAnimationFrame(()=>{const ne=document.getElementById(e.id),re=l.value??0;ne&&(ne.focus(),ne.setSelectionRange(re,re))})});return}const ie=new Date,de=E($);let fe=ee?new Date(ee):new Date(ie),pe=te?new Date(te):new Date(ie);const ye=(Y,le)=>{if(le==="mm"){const ne=Y.getMonth()+1,re=a==="ArrowUp"?ne<12?ne+1:1:ne>1?ne-1:12;Y.setMonth(re-1);const ve=P(Y.getFullYear(),re);Y.getDate()>ve&&Y.setDate(ve)}else if(le==="dd"){const ne=P(Y.getFullYear(),Y.getMonth()+1),re=Y.getDate(),ve=a==="ArrowUp"?re<ne?re+1:1:re>1?re-1:ne;Y.setDate(ve)}else if(le==="yyyy"){const ne=Y.getFullYear();Y.setFullYear(a==="ArrowUp"?ne+1:Math.max(1,ne-1));const re=P(Y.getFullYear(),Y.getMonth()+1);Y.getDate()>re&&Y.setDate(re)}};de.side==="start"?ye(fe,de.part):ye(pe,de.part);const Se=y(fe),we=y(pe);n.value=`${Se} - ${we}`;const se=V(fe),ke=V(pe);se&&ke&&R(se,ke)?e.onChange({value:{start:se,end:ke},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}=b(n.value);if(!c||!k){e.onChange({value:null,event:a});return}const $=V(c),ee=V(k);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??"",k=a.event;if(!c&&k&&k.type==="click"){ae(k);return}n.value=c;const $=k?.target;l.value=$?.selectionStart??0,Z(a)},p=a=>{l.value=a.target.selectionStart??0},S=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)},B=a=>{if(d.includes(a.key)||u.includes(a.key)){const c=a.target;l.value=c?.selectionStart??0}},z=()=>{i.value=oe.value,(e.manageValid??!0)&&(L.value=X.value)},G=a=>{z()},ae=a=>{console.log("Clear event:",a),n.value="",l.value=0,e.onChange({value:null,event:a}),z(),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=`${y(c)} - ${y(k)}`,e.isOpen?.value&&m.value&&e.onRequestClose){const $=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),m.value=!1,z()},$)}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"),F=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"),K=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"),H=t.computed(()=>{const{start:a,end:c}=b(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(F.value).padStart(4,"0")}`},{label:"End",value:`${String(O.value).padStart(2,"0")} / ${String(K.value).padStart(2,"0")} / ${String(j.value).padStart(4,"0")}`},{label:"Digits only",value:I.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:`${oe.value??"-"}`},{label:"Cursor in",value:`${l.value??"-"} (${(()=>{const k=l.value??0,$=E(k);return`${$.side}.${$.part}`})()})`}]}),_=()=>{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(()=>{_()});const ce=()=>{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 $=k.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(()=>ce(),0)},{immediate:!1}),{raw:n,cursorPos:l,debugEnabled:h,debugLines:H,digitsOnly:I,valid:L,validComputed:t.readonly(X),reason:t.readonly(oe),validationMessage:t.readonly(v),spanDays:t.readonly(J),month1:t.readonly(r),day1:t.readonly(s),year1:t.readonly(F),month2:t.readonly(O),day2:t.readonly(K),year2:t.readonly(j),handleChange:o,handleKeyDown:S,handleWheel:U,handleKeyUp:B,handleClick:p,handleBlur:G,handleClear:ae,onCalendarChange:()=>{m.value=!0},initStyling:_}}function Ye(e){const n=t.ref(""),l=t.ref(void 0),h=t.ref(!!e.debug),m=t.ref(e.timeFormat??"hh:mm AM"),C=t.computed(()=>!!e.required),M=t.ref(!1),A=["ArrowUp","ArrowDown"],T=["ArrowLeft","ArrowRight"],D=t.computed(()=>(n.value??"").replace(/\D/g,"")),I={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},P=r=>r<=2?"hh":r<=5?"mm":"ampm",w=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)}),g=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(()=>b.value?`${String(R.value).padStart(2,"0")}:${String(g.value).padStart(2,"0")}:00`:null),b=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),L=(r,s,F)=>{let O=r%12;return O===0&&(O=12),`${String(O).padStart(2,"0")}:${String(s).padStart(2,"0")} ${F}`},W=r=>{const s=r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!s)return null;const F=parseInt(s[1]),O=parseInt(s[2]),K=s[3].toUpperCase();if(F<1||F>12||O<0||O>59)return null;let j=F%12;K==="PM"&&(j+=12);const H=new Date;return H.setSeconds(0,0),H.setHours(j),H.setMinutes(O),H},N=r=>{if(D.value.length===0){e.onChange({value:null,event:r});return}if(!b.value){e.onChange({value:null,event:r});return}const s=W(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,F=e.max??void 0,O=J(r);if(s){const K=J(s);if(O<K)return!1}if(F){const K=J(F);if(O>K)return!1}return!0},oe=r=>{const s=r.getHours(),F=s>=12?"PM":"AM";n.value=L(s,r.getMinutes(),F)},i=(r,s)=>{e.onChange({value:r,event:s})},v=()=>{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 F=u(s);if(F==="now"){const K=new Date;oe(K),d(K,s),v();return}if(s?.value instanceof Date){const K=new Date(s.value);oe(K),d(K,s),F==="set"&&v();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 K=l.value??0;if(P(K)==="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 H=document.getElementById(e.id);H&&(H.focus(),H.setSelectionRange(8,8))})})):/[Pp]/.test(j)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const H=document.getElementById(e.id);H&&(H.focus(),H.setSelectionRange(8,8))})}))}}catch{}N(s)},y=r=>{l.value=r.target.selectionStart??0},E=(r,s,F)=>{const O=s?.selectionStart??l.value??0;l.value=O;const K=P(O),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(),$=k>=12?"PM":"AM";n.value=L(k,c.getMinutes(),$);const ee=W(n.value);d(ee,F),t.nextTick(()=>{requestAnimationFrame(()=>{const te=document.getElementById(e.id),ie=l.value??0;te&&(te.focus(),te.setSelectionRange(ie,ie))})})}return}let H=parseInt(j[1]),_=parseInt(j[2]),ce=j[3].toUpperCase();if(K==="hh")r==="ArrowUp"?H=H<12?H+1:1:H=H>1?H-1:12;else if(K==="mm"){const c=e.minuteStepRef?.value??e.minuteStep??1;if(c===1)r==="ArrowUp"?_=_<59?_+1:0:_=_>0?_-1:59;else if(r==="ArrowUp"){const k=_%c;let $=k===0?_+c:_+(c-k);$>=60&&($=0),_=$}else{const k=_%c;let $=k===0?_-c:_-k;$<0&&($=60-c),_=$}}else K==="ampm"&&(ce=ce==="AM"?"PM":"AM");n.value=`${String(H).padStart(2,"0")}:${String(_).padStart(2,"0")} ${ce}`;const a=W(n.value);d(a,F),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(A.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(T.includes(r.key)){l.value=s?.selectionStart??0;return}if(A.includes(r.key)){if(r.altKey)return;l.value=s?.selectionStart??0}},p=r=>{M.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 F=s.getHours(),O=F>=12?"PM":"AM";n.value=L(F,s.getMinutes(),O);return}}},{immediate:!0});const S=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",w.value],["Hour (24h)",R.value],["Minute",g.value],["Period",V.value],["Time (24h)",f.value??"--:--:--"],["Digits only",D.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",B.value],["reason",z.value],["validationMessage",G.value]]),U=t.computed(()=>W(n.value)??null),B=t.computed(()=>{if(!C.value){if(!b.value)return!0;const s=U.value;return s?X(s):!1}if(!M.value)return!0;const r=U.value;return!b.value||!r?!1:X(r)}),z=t.computed(()=>{if(!C.value){if(!b.value)return;const s=U.value;return s?X(s)?"valid":"out-of-bounds":"invalid-time"}if(!M.value)return;if(D.value.length===0||!b.value)return"incomplete";const r=U.value;return r?X(r)?"valid":"out-of-bounds":"invalid-time"}),G=t.computed(()=>{const r=z.value;if(!r||r==="valid")return"";if(r==="incomplete")return"Required";if(r==="invalid-time")return`Must be in ${m.value} format.`;const s={hour:"2-digit",minute:"2-digit"},F=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(F&&O)return`Must be between ${F} and ${O}.`;if(F)return`Must be ${F} or later.`;if(O)return`Must be ${O} or earlier.`}return""}),ae=()=>{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 F=s.parentElement;if(!F){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}F.classList.contains("fk-timepicker")||F.classList.add("fk-timepicker")})};return t.onMounted(()=>{ae()}),{raw:n,rules:I,debugEnabled:h,debugLines:S,placeholder:m,isValid:B,reason:t.readonly(z),validationMessage:G,isComplete:b,inRangeTime:X,cursorPos:l,hour:t.readonly(w),hour24:t.readonly(R),minute:t.readonly(g),period:t.readonly(V),time24:t.readonly(f),parsedRawTime:t.readonly(U),handleChange:x,handleKeyDown:q,handleKeyUp:o,handleClick:y,handleWheel:Z,handleBlur:p,initStyling:ae}}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 me(e){var n;const l=t.toValue(e);return(n=l?.$el)!=null?n:l}function be(...e){const n=[],l=()=>{n.forEach(A=>A()),n.length=0},h=(A,T,D,I)=>(A.addEventListener(T,D,I),()=>A.removeEventListener(T,D,I)),m=t.computed(()=>{const A=he(t.toValue(e[0])).filter(T=>T!=null);return A.every(T=>typeof T!="string")?A:void 0}),C=Qe(()=>{var A,T;return[(T=(A=m.value)==null?void 0:A.map(D=>me(D)))!=null?T:[Te].filter(D=>D!=null),he(t.toValue(m.value?e[1]:e[0])),he(t.unref(m.value?e[2]:e[1])),t.toValue(m.value?e[3]:e[2])]},([A,T,D,I])=>{if(l(),!A?.length||!T?.length||!D?.length)return;const P=_e(I)?{...I}:I;n.push(...A.flatMap(w=>T.flatMap(g=>D.map(V=>h(w,g,V,P)))))},{flush:"post"}),M=()=>{C(),l()};return je(l),M}let Ce=!1;function et(e,n,l={}){const{window:h=Te,ignore:m=[],capture:C=!0,detectIframe:M=!1,controls:A=!1}=l;if(!h)return A?{stop:ue,cancel:ue,trigger:ue}:ue;if(Je&&!Ce){Ce=!0;const f={passive:!0};Array.from(h.document.body.children).forEach(b=>b.addEventListener("click",ue,f)),h.document.documentElement.addEventListener("click",ue,f)}let T=!0;const D=f=>t.toValue(m).some(b=>{if(typeof b=="string")return Array.from(h.document.querySelectorAll(b)).some(L=>L===f.target||f.composedPath().includes(L));{const L=me(b);return L&&(f.target===L||f.composedPath().includes(L))}});function I(f){const b=t.toValue(f);return b&&b.$.subTree.shapeFlag===16}function P(f,b){const L=t.toValue(f),W=L.$.subTree&&L.$.subTree.children;return W==null||!Array.isArray(W)?!1:W.some(N=>N.el===b.target||b.composedPath().includes(N.el))}const w=f=>{const b=me(e);if(f.target!=null&&!(!(b instanceof Element)&&I(e)&&P(e,f))&&!(!b||b===f.target||f.composedPath().includes(b))){if("detail"in f&&f.detail===0&&(T=!D(f)),!T){T=!0;return}n(f)}};let g=!1;const V=[be(h,"click",f=>{g||(g=!0,setTimeout(()=>{g=!1},0),w(f))},{passive:!0,capture:C}),be(h,"pointerdown",f=>{const b=me(e);T=!D(f)&&!!(b&&!f.composedPath().includes(b))},{passive:!0}),M&&be(h,"blur",f=>{setTimeout(()=>{var b;const L=me(e);((b=h.document.activeElement)==null?void 0:b.tagName)==="IFRAME"&&!L?.contains(h.document.activeElement)&&n(f)},0)},{passive:!0})].filter(Boolean),R=()=>V.forEach(f=>f());return A?{stop:R,cancel:()=>{T=!1},trigger:f=>{T=!0,w(f),T=!1}}:R}function tt(e){const n=t.shallowRef(null),l=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],h=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??l].flat(),m=I=>I?typeof e.initialFocus=="string"?I.querySelector(e.initialFocus)??I:typeof e.initialFocus=="function"?e.initialFocus(I)??I:I.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??I:null,{activate:C,deactivate:M}=Ve.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>m(n.value),...e.focusTrapOptions??{}});let A=null,T=t.ref(null);const D=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const I=(w,g)=>{const V=Array.from(w.querySelectorAll(g));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},P=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const w of h){const g=I(P,w);if(g)return g}for(const w of h){const g=I(document,w);if(g)return g}return null};return et(n,I=>{T.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",I)}),t.watch(()=>e.isOpen.value,I=>{I?(T.value=null,t.nextTick(()=>{const P=D();P&&(n.value=P,setTimeout(()=>C(),0),A||(A=w=>{w.key==="Escape"&&(T.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",w))},document.addEventListener("keydown",A,!0)))})):(M(),A&&(document.removeEventListener("keydown",A,!0),A=null),n.value=null,T.value==="outside"&&t.nextTick(()=>{const P=()=>{const w=e.triggerEl?.value,g=w?.querySelector("input"),V=document.activeElement;V&&(V===g||w&&w.contains(V))&&(g??w)?.blur?.()};requestAnimationFrame(()=>setTimeout(P,0))}),e.returnFocusToTrigger!==!1&&T.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const P=()=>{const w=e.triggerEl?.value;if(!w)return;(w.querySelector("input")??w)?.focus?.()};requestAnimationFrame(()=>setTimeout(P,0))})))}),{popupRef:n,activate:C,deactivate:M,lastCloseReason:t.readonly(T),setPopupEl:I=>n.value=I}}Q.useFieldsetTouchTracker=Ee,Q.useFieldsetValidationKit=Me,Q.useGridA11y=Fe,Q.useGridActiveFilter=Re,Q.useMaskedDateInput=Ze,Q.useMaskedDateRangeInput=We,Q.useMaskedTimeInput=Ye,Q.usePopupTrap=tt,Q.useUSAddress=He,Q.useZipTextBox=xe,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(J,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):(J=typeof globalThis<"u"?globalThis:J||self,t(J.FeatherKComposables={},J.Vue,J.useFocusTrap))})(this,(function(J,t,Ve){"use strict";const Fe=(e,n)=>{const l=t.ref(null);let D=!1,y=null,v=null;const T=[],w=".k-table-row[data-grid-row-index] [tabindex]",E=()=>{const i=e?.value?.$el;return i?i.closest(".k-grid"):null},F=i=>{const b=E();if(!b)return!1;const c=i.closest(".k-grid-aria-root");if(c)return b.contains(c);const p=i.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return p?b.contains(p):!1},g=i=>i.key==="Enter"||i.code==="Enter"||i.code==="NumpadEnter",R=()=>e?.value?.columns,A=i=>{const b=i.key||i.code;([" ","Spacebar","Space"].includes(b)||g(i))&&(i.preventDefault(),i.stopPropagation(),l.value=i.target,i.target.click())},h=i=>{if(!l.value)return;if(i.code==="Escape"){i.stopPropagation(),l.value&&l.value.focus();return}const b=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),c=document.querySelector(".k-animation-container .k-popup .k-column-menu .k-filter-menu-container");if(c){if(i.code==="Tab"){const p=[".k-dropdownlist[tabindex='0']","input.k-input-inner:not([tabindex='-1']):not([disabled])","button:not([tabindex='-1']):not([disabled])",".k-checkbox"],x=n?.focusableMenuSelectors??p,m=Array.from(c.querySelectorAll(x.join(",")));if(m.length===0)return;const M=m.findIndex(H=>H===document.activeElement);let L;M===-1?L=0:i.shiftKey?L=(M-1+m.length)%m.length:L=(M+1)%m.length,i.preventDefault(),i.stopPropagation(),m[L]?.focus()}}else if(i.code==="ArrowUp"||i.code==="ArrowDown"){i.preventDefault(),i.stopPropagation();const p=b.findIndex(m=>m===document.activeElement);let x=p;i.code==="ArrowUp"?x=p>0?p-1:b.length-1:i.code==="ArrowDown"&&(x=p<b.length-1?p+1:0),b[x]?.focus();return}if(i.code==="Tab"){i.preventDefault(),i.stopPropagation();const p=l.value?.parentElement;(i.shiftKey?p?.previousElementSibling:p?.nextElementSibling)?.querySelector("button, [role='button'], .k-link")?.focus()}},I=()=>{y=new MutationObserver(i=>{i.forEach(b=>{b.addedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE){const p=c;if(p.classList.contains("k-animation-container")){const m=l.value;m&&(m.dataset.featherKSortable==="true"||t.nextTick(()=>{p.querySelectorAll(".k-columnmenu-item-wrapper").forEach(H=>{H.textContent?.toLowerCase().includes("sort")&&H.remove()})})),p.addEventListener("keydown",h),t.nextTick(()=>{const M=()=>{const L=Array.from(p.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"));if(L.length===1)L[0].focus(),L[0].click(),M.attempts=0;else if(L.length>1){M.attempts=0;return}else M.attempts===void 0&&(M.attempts=0),M.attempts++<3&&setTimeout(M,200)};M()})}p.querySelectorAll(".k-animation-container").forEach(m=>{m.addEventListener("keydown",h)})}}),b.removedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE){const p=c;p.classList.contains("k-animation-container")&&p.removeEventListener("keydown",h),p.querySelectorAll(".k-animation-container").forEach(m=>{m.removeEventListener("keydown",h)})}})})}),y.observe(document.body,{childList:!0,subtree:!0})},z=i=>{const b=i.tagName.toLowerCase();return!!(["input","textarea","select","button"].includes(b)||i.closest('.k-picker-wrap, .k-input-inner, .k-textbox, [role="combobox"]'))},f=i=>{if(!i.type||!i)return;const b=i.target;if(!b)return;const c=b.closest(".k-table-row[data-grid-row-index]");if(!F(b))return;const p=["ArrowLeft","ArrowRight"].includes(i.code);if(!(z(b)&&!(c&&p))){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(M=>M.setAttribute("tabindex","-1"))}catch{}x.setAttribute("tabindex","0"),x.focus();return}}if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter","NumpadEnter","Space"].includes(i.code)){if(b.classList.contains("k-grid-header-menu")&&b.classList.contains("k-grid-column-menu")){l.value=b;return}if(c){if(["ArrowDown","ArrowUp"].includes(i.code)){i.preventDefault(),i.stopPropagation();const x=(M,L)=>{let H=L==="next"?M.nextElementSibling:M.previousElementSibling;for(;H;){const te=H;try{if(te.classList.contains("k-table-row"))return te}catch{}H=L==="next"?H.nextElementSibling:H.previousElementSibling}return null},m=i.code==="ArrowDown"?x(c,"next"):x(c,"previous");m&&(c.setAttribute("tabindex","-1"),m.setAttribute("tabindex","0"),m.focus());return}if(["ArrowLeft","ArrowRight"].includes(i.code)){i.preventDefault(),i.stopPropagation();const x=c.querySelectorAll(w);if(x.length===0)return;let m=Array.from(x).findIndex(M=>M===document.activeElement);if(m===-1&&document.activeElement===c){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}}}}},k=()=>{t.nextTick(()=>{const i=e.value?.$el;if(!i||typeof i.closest!="function")return;const b=i.closest(".k-grid");b&&b.classList.add("fk-grid")})},P=()=>{if(!v)try{const i=()=>{try{const p=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!p||p.length===0||p.filter(M=>M.getAttribute("tabindex")==="0").length===1)return;const m=p.find(M=>M===document.activeElement||M.contains(document.activeElement));if(p.forEach(M=>M.setAttribute("tabindex","-1")),m){m.setAttribute("tabindex","0");return}p[0].setAttribute("tabindex","0")}catch(p){console.error("ensureSingleTabindex error:",p)}},b=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));b.length>0&&b.forEach((p,x)=>{p.setAttribute("tabindex",x===0?"0":"-1")});const c=e.value.$el.querySelector(".k-table-tbody");c&&(v=new MutationObserver(()=>{i()}),v.observe(c,{childList:!0,subtree:!0}))}catch(i){console.error("Error setting up row navigation:",i)}},U=()=>{t.nextTick(()=>{const b=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");b&&b.forEach(c=>{c.setAttribute("role","button"),c.addEventListener("keydown",A)}),I(),W()})},G=()=>{const b=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");b&&b.forEach(c=>{c.removeEventListener("keydown",A)}),y&&(y.disconnect(),y=null),v&&(v.disconnect(),v=null),T.forEach(c=>c()),T.length=0},W=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((c,p)=>{if(c.dataset.featherKHeaderBound==="true")return;const x=c.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!x)return;const m=R();if(m&&m[p]){const r=m[p].field??"";c.setAttribute("data-feather-k-field",r),c.setAttribute("data-feather-k-filterable",m[p].filterable===!1?"false":"true"),c.setAttribute("data-feather-k-sortable",m[p].sortable===!1?"false":"true")}const M=c.dataset.featherKFilterable!=="false",L=c.dataset.featherKSortable!=="false";x.setAttribute("tabindex","-1"),M||L?c.style.cursor="pointer":c.style.cursor="default",M?(c.setAttribute("tabindex","0"),c.setAttribute("role","button"),c.setAttribute("aria-haspopup","menu")):(c.setAttribute("tabindex","0"),c.setAttribute("role","columnheader"),c.removeAttribute("aria-haspopup"));const H=r=>{r.target?.closest(".k-column-resizer")||(l.value=c,x.click())},te=r=>{if(M)l.value=c,r.preventDefault(),r.stopPropagation(),H(r);else if(L){l.value=c;const d=c.querySelector(".k-link");d&&d.click()}};c.addEventListener("click",te),T.push(()=>{c.removeEventListener("click",te)});const oe=r=>{if((g(r)||r.code==="Space")&&(M||L)){if(r.preventDefault(),r.stopPropagation(),l.value=c,l.value.focus(),M)H(r);else if(L){const d=c.querySelector(".k-link");d&&d.click()}}};c.addEventListener("keydown",oe,!0),T.push(()=>{c.removeEventListener("keydown",oe,!0)}),c.dataset.featherKHeaderBound="true"});const b=document.querySelector(".k-grid-header .k-table-thead");if(b&&b.dataset.featherKHeaderBound!=="true"){const c=p=>{const x=p.target.closest("th");x&&(g(p)||p.code==="Space")&&x.dataset.featherKFilterable==="false"&&x.dataset.featherKSortable==="false"&&(p.preventDefault(),p.stopImmediatePropagation())};b.addEventListener("keydown",c,!0),T.push(()=>{b.removeEventListener("keydown",c,!0)}),b.dataset.featherKHeaderBound="true"}},X=function(i,b){const c=i?.event?.event.target,p=R();if(!c||!p)return;const x=c.classList.contains("k-grid-header-menu"),m=c.classList.contains("k-columnmenu-item"),M=p.find(L=>L.field===i?.event?.field)?.sortable&&!0;if(!x){if(m&&!M){i?.event?.sort?.filter(H=>H.field!==i?.event?.field);return}typeof b=="function"&&t.nextTick(()=>{l.value&&l.value.focus(),b(i),t.nextTick(()=>{W()})})}},re=()=>{if(!D)try{k(),P(),U(),D=!0}catch(i){console.error("initA11y failed:",i),G()}};return t.onBeforeUnmount(()=>{G()}),{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),D=t.ref(e.errorMessage?.trim()||Le),y=t.computed(()=>n.value.replace(/\D/g,"")),v=t.computed(()=>{const h=y.value.length;return h===5||h===9}),T=t.computed(()=>l.value&&!v.value),w=t.computed(()=>!l.value||v.value),E=t.computed(()=>l.value),F=(h,I)=>{const z=Oe(I);t.nextTick(()=>{h.isConnected&&h.setSelectionRange(z,z)})};return{zipDisplay:n,submitted:l,errorMessage:D,wrapperClass:"fk-zip-textbox",zipRaw:y,isZipValid:v,showZipError:T,textBoxValid:w,textBoxValidate:E,handleZipInput:(...h)=>{const I=h[0],f=I?.event?.target,k=I?.value,P=Array.isArray(k)?k.join(""):String(k??""),U=f?.selectionStart!==void 0&&f.selectionStart!==null?qe(f.value,f.selectionStart):P.replace(/\D/g,"").length;n.value=De(P),f&&F(f,U)},submitAndValidate:h=>{l.value=!0;const I=v.value;return!I&&h?.focus&&t.nextTick(()=>{document.getElementById(e.id)?.focus()}),I},buildPayload:()=>({zip:y.value})}};function Ee(e,n){const l=t.ref(!1);t.watchEffect(()=>{e.value?.setAttribute("aria-invalid",String(!n.isValid()))});function D(v){const T=e.value??v.currentTarget,w=v.relatedTarget;(!T||!T.contains(w))&&(l.value=!0)}function y(){l.value=!1}return{touched:l,onFocusout:D,reset:y}}function Me(e,n){const l=t.ref(!1),D=t.ref(!1),y=t.computed(()=>t.toValue(n.submitted)||l.value),v=t.computed(()=>!y.value||n.isValid()),T=Ee(e,{isValid:()=>v.value});function w(A){return t.computed(()=>!y.value||t.toValue(A))}function E(A){return Object.fromEntries(Object.entries(A).map(([h,I])=>[h,w(I)]))}function F(A){const h=t.toValue(A);if(!h)return;h.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function g(A){if(D.value){D.value=!1;return}T.onFocusout(A),T.touched.value&&(l.value=!0)}function R(){l.value=!1,D.value=!0,T.reset()}return{touched:l,fieldsetValidate:y,onFocusout:g,reset:R,createFieldValidity:w,createFieldValidationsMap:E,focusFirstInvalidField:F}}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 ge(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:(...T)=>{e.address1=ge(T[0])},onAddress2Input:(...T)=>{e.address2=ge(T[0])},onCityInput:(...T)=>{e.city=ge(T[0])},onStateChange:T=>{e.state=T.value},resetFormData:()=>{e.address1="",e.address2="",e.city="",e.state=null,e.zip=""}}}function Ne(e,n="zip"){const l=xe({id:n}),{zipDisplay:D,zipRaw:y,isZipValid:v,wrapperClass:T,handleZipInput:w}=l;return t.watch(y,F=>{e.zip=F}),{zipDisplay:D,isZipValid:v,zipWrapperClass:T,onZipInput:w,resetZip:()=>{D.value="",e.zip=""}}}function Be(e){const n=t.computed(()=>e.formData.address1.trim()!==""),l=t.computed(()=>e.formData.city.trim()!==""),D=t.computed(()=>!!e.formData.state),y=t.computed(()=>t.toValue(e.isZipValid)),v=t.computed(()=>n.value&&l.value&&D.value&&y.value);return{strictAddress1Valid:n,strictCityValid:l,strictStateValid:D,strictZipValid:y,strictAddressValid:v}}function ze(e){if(!e)return;e.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function He(e,n){const l=e??n.currentTarget,D=n.relatedTarget;return!l||!l.contains(D)}function Ze(e){const n=t.ref(t.toValue(e.fieldsetRef));t.watchEffect(()=>{n.value=t.toValue(e.fieldsetRef)});const l=t.ref(!1),D=t.ref(!1),y=t.computed(()=>t.toValue(e.required)??!0),{formData:v,onAddress1Input:T,onAddress2Input:w,onCityInput:E,onStateChange:F,resetFormData:g}=Ke(),R=`${e.addressId}-zip`,{zipDisplay:A,isZipValid:h,zipWrapperClass:I,onZipInput:z,resetZip:f}=Ne(v,R),{strictAddress1Valid:k,strictCityValid:P,strictStateValid:U,strictZipValid:G,strictAddressValid:W}=Be({formData:v,isZipValid:h}),X=Me(n,{submitted:l,isValid:()=>W.value}),{touched:re,fieldsetValidate:i,onFocusout:b,reset:c}=X,p=X.createFieldValidationsMap({address1:k,city:P,state:U,zip:G,address:W}),{address1:x,city:m,state:M,zip:L,address:H}=p,te=t.computed(()=>y.value?i.value:!1),oe=t.computed(()=>y.value?x.value:!0),r=t.computed(()=>y.value?m.value:!0),d=t.computed(()=>y.value?M.value:!0),V=t.computed(()=>y.value?L.value:!0),K=t.computed(()=>y.value?H.value:!0),N={value:null,label:"State"},Z=Ue.map(({label:u,value:S})=>({label:u,value:S})),a=t.computed(()=>({address1:v.address1.trim(),address2:v.address2.trim(),city:v.city.trim(),state:(v.state??"").trim().toUpperCase(),zip:v.zip.replace(/\D/g,"")})),s=t.computed(()=>v.address1.trim()===""&&v.address2.trim()===""&&v.city.trim()===""&&(v.state??"").trim()===""&&v.zip.replace(/\D/g,"")===""),C=t.computed(()=>!s.value),q=t.computed(()=>!y.value&&C.value&&(!k.value||!P.value||!U.value)),Y=t.computed(()=>{const u=v.zip.replace(/\D/g,"");return!y.value&&C.value&&u.length!==5&&u.length!==9}),_=t.computed(()=>!y.value&&C.value&&!W.value),O=t.computed(()=>!y.value&&_.value&&(D.value||l.value));return t.watch(a,()=>{y.value||(D.value=!1)}),t.watch(y,u=>{u||(l.value=!1,D.value=!1,c())}),{formData:v,submitted:l,touched:re,addressValidate:te,address1Valid:oe,cityValid:r,stateValid:d,zipValid:V,addressValid:K,optionalFeedbackActive:O,optionalPartialInvalid:_,optionalMissingRequiredFields:q,optionalZipInvalid:Y,stateDefaultItem:N,stateOptions:Z,zipDisplay:A,zipWrapperClass:I,onAddress1Input:T,onAddress2Input:w,onCityInput:E,onStateChange:F,onZipInput:z,onFieldsetFocusout:u=>{const S=He(n.value,u);b(u),!y.value&&S&&(D.value=!0)},normalizedPayload:a,validateForSubmit:async()=>y.value?(l.value=!0,W.value?{isValid:!0,payload:a.value}:(await t.nextTick(),ze(n.value),{isValid:!1,payload:null})):s.value||W.value?(l.value=!1,{isValid:!0,payload:a.value}):(l.value=!0,{isValid:!1,payload:null}),reset:()=>{l.value=!1,D.value=!1,c(),g(),f()}}}function Ye(e){const n=t.ref(""),l=t.ref(void 0),D=t.ref(!!e.debug),y=t.ref(e.dateFormat??"mm/dd/yyyy"),v=t.computed(()=>!!e.required),T=1e3,w=t.ref(!1),E=["ArrowUp","ArrowDown"],F=["ArrowLeft","ArrowRight"],g=t.computed(()=>(n.value??"").replace(/\D/g,"")),R=r=>r<=2?"mm":r<=5?"dd":g.value.length<=10?"yyyy":"mm",A=t.computed(()=>{const r=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(r).toString().padStart(2,"0")}),h=t.computed(()=>{const r=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(r).toString().padStart(2,"0")}),I=t.computed(()=>{const r=n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(r).toString().padStart(4,"0")}),z=r=>{if(g.value.length===0){e.onChange({value:null,event:r});return}if(g.value.length<8){e.onChange({value:null,event:r});return}if((n.value??"").length===10&&g.value.length===8){const[d,V,K]=n.value.split("/"),N=parseInt(d),Z=parseInt(V),a=parseInt(K);if(W(a,N,Z)){const s=U(a,N,Z);f(s)?e.onChange({value:s,event:r}):e.onChange({value:null,event:r})}else e.onChange({value:null,event:r})}},f=r=>{const d=e.min??void 0,V=e.max??void 0;return!(d&&r<d||V&&r>V)},k=t.computed(()=>{if((n.value??"").length===10&&g.value.length===8){const[r,d,V]=(n.value??"").split("/"),K=parseInt(r),N=parseInt(d),Z=parseInt(V);if(W(Z,K,N))return U(Z,K,N)}return null}),P=t.computed(()=>(n.value??"").length===10&&g.value.length===8),U=(r,d,V)=>{const K=new Date(0);return K.setFullYear(r,d-1,V),K.setHours(0,0,0,0),K},G=(r,d)=>U(r,d+1,0).getDate(),W=(r,d,V)=>d>=1&&d<=12&&r>=T&&V>=1&&V<=G(r,d),X=r=>{n.value=r.value;const d=r.event?.target;l.value=d?.selectionStart??0,z(r)},re=r=>{l.value=r.target.selectionStart??0},i=(r,d,V)=>{const K=d?.selectionStart??l.value??0;l.value=K;let N=parseInt(A.value),Z=parseInt(h.value),a=parseInt(I.value);if(!(g.value.length>=8)||!W(a,N,Z)){const B=e.defaultValue??new Date;N=B.getMonth()+1,Z=B.getDate(),a=B.getFullYear(),n.value=`${String(N).padStart(2,"0")}/${String(Z).padStart(2,"0")}/${String(a)}`;const le=U(a,N,Z);e.onChange({value:f(le)?le:null,event:V}),m({useRAF:!0});return}const C=R(K);if(C==="mm")N=r==="ArrowUp"?N<12?N+1:1:N>1?N-1:12;else if(C==="dd"){const B=new Date(a,N,0).getDate();Z=r==="ArrowUp"?Z<B?Z+1:1:Z>1?Z-1:B}else C==="yyyy"&&(a=r==="ArrowUp"?a+1:Math.max(1,a-1));n.value=`${String(N).padStart(2,"0")}/${String(Z).padStart(2,"0")}/${String(a)}`;const[q,Y,_]=n.value.split("/"),O=U(parseInt(_),parseInt(q),parseInt(Y));O.toString()!=="Invalid Date"&&parseInt(_)>=1e3?e.onChange({value:f(O)?O:null,event:V}):e.onChange({value:null,event:V}),m({useRAF:!0})},b=r=>{if(r.code==="Space"||r.key===" "){r.preventDefault(),r.stopPropagation(),e.onShowCalendar(r);return}if(r.key==="ArrowDown"&&r.altKey){r.preventDefault(),r.stopPropagation(),e.onShowCalendar(r);return}if(E.includes(r.key)){if(r.altKey)return;r.preventDefault(),r.stopPropagation();const d=r.target;i(r.key,d,r);return}},c=r=>{r.preventDefault();const d=r.deltaY<0?"ArrowUp":"ArrowDown";i(d,r.target,r)},p=r=>{const d=r.target;if(F.includes(r.key)){l.value=d?.selectionStart??0;return}if(E.includes(r.key)){if(r.altKey)return;l.value=d?.selectionStart??0}},x=r=>{w.value=!0,v.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&g.value.length===0&&(e.externalValue.value="");const d=r.target;d&&(l.value=d.selectionStart??0)},m=r=>{const d=()=>{const V=document.getElementById(e.id);if(!V)return;const K=r?.pos??l.value??V.value.length;try{V.focus(),V.setSelectionRange(K,K)}catch{}};t.nextTick(()=>{if(r?.delay&&r.delay>0){setTimeout(d,r.delay);return}if(r?.useRAF){requestAnimationFrame(d);return}d()})};e.externalValue&&t.watch(e.externalValue,r=>{if(r){const d=new Date(r);if(d.toString()!=="Invalid Date"){const V=(d.getMonth()+1).toString().padStart(2,"0"),K=d.getDate().toString().padStart(2,"0"),N=d.getFullYear().toString();n.value=`${V}/${K}/${N}`,m({delay:50});return}}},{immediate:!0});const M=t.computed(()=>[["Date",`${A.value} / ${h.value} / ${I.value}`],["Digits only",g.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]]),L=t.computed(()=>{if(!v.value){if(!P.value)return!0;const d=k.value;return d?f(d):!1}if(!w.value)return!0;const r=k.value;return!P.value||!r?!1:f(r)}),H=t.computed(()=>{if(!v.value){if(!P.value)return;const d=k.value;return d?f(d)?"valid":"out-of-bounds":"invalid-date"}if(!w.value)return;if(g.value.length===0||!P.value)return"incomplete";const r=k.value;return r?f(r)?"valid":"out-of-bounds":"invalid-date"}),te=t.computed(()=>{const r=H.value;if(!r||r==="valid")return"";if(r==="incomplete")return"Required";if(r==="invalid-date")return`Must be in ${y.value} format.`;const d=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,V=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(r==="out-of-bounds"){if(d&&V)return`Must be between ${d} and ${V}.`;if(d)return`Must be on or after ${d}.`;if(V)return`Must be on or before ${V}.`}return""}),oe=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`ID (#${e.id}) not found for styling.`);return}const d=r.closest(".k-datepicker");if(!d){console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}const V=d.parentElement;if(V){if(V.classList.contains("fk-datepicker"))return;V.classList.add("fk-datepicker")}else console.warn(`Parent of .k-datepicker not found for #${e.id} styling.`)})};return t.onMounted(()=>{oe()}),{raw:n,cursorPos:l,debugEnabled:D,debugLines:M,placeholder:y,isValid:L,reason:t.readonly(H),validationMessage:te,digitsOnly:g,month:t.readonly(A),day:t.readonly(h),year:t.readonly(I),datePart:R,handleChange:X,handleKeyDown:b,handleWheel:c,handleKeyUp:p,handleClick:re,handleBlur:x,initStyling:oe}}function We(e){const n=t.ref(""),l=t.ref(void 0),D=t.ref(!!e.debug),y=t.ref(!1),v=1440*60*1e3,T=365*v,w=new Date,E=new Date(w.getTime()-T),F=new Date(w.getTime()+T);e.min=e.min??E,e.max=e.max??F;const g=t.computed(()=>(n.value??"").replace(/\D/g,"")),R=(o,u)=>new Date(o,u,0).getDate(),A=(o,u,S)=>u>=1&&u<=12&&o>=1e3&&S>=1&&S<=R(o,u),h=o=>Date.UTC(o.getFullYear(),o.getMonth(),o.getDate()),I=o=>{if(!o)return null;const u=e.min??new Date(Date.now()-90*v),S=e.max??new Date,$=h(o);return $<h(u)||$>h(S)?null:o},z=(o,u)=>e.allowReverse??!1?!0:o<=u,f=t.computed(()=>(n.value?.length??0)>=23&&g.value.length>=16),k=o=>{if((o??"").length<23||g.value.length<16)return{start:null,end:null};const u=o.substring(0,10),S=o.substring(13,23),[$,Q,ee]=u.split("/").map(ue=>parseInt(ue||"0",10)),[se,de,fe]=S.split("/").map(ue=>parseInt(ue||"0",10)),pe=new Date(ee,$-1,Q),ye=new Date(fe,se-1,de),Se=A(ee,$,Q)&&pe.toString()!=="Invalid Date",ke=A(fe,se,de)&&ye.toString()!=="Invalid Date";return{start:Se?pe:null,end:ke?ye:null}},P=e.externalValid??t.ref(!0),U=t.computed(()=>k(n.value)),G=t.computed(()=>{const o=I(U.value.start),u=I(U.value.end);return{start:o,end:u}}),W=t.computed(()=>{if(!f.value)return;const o=G.value.start,u=G.value.end;if(!o||!u)return;const S=Math.abs(h(u)-h(o));return Math.round(S/864e5+1)}),X=t.computed(()=>{if(!f.value)return!1;const{start:o,end:u}=U.value;if(!o||!u||!G.value.start||!G.value.end)return!1;const S=G.value.start,$=G.value.end;return!(!z(S,$)||typeof e.maxSpanDays=="number"&&W.value!==void 0&&W.value>e.maxSpanDays)}),re=t.computed(()=>{const{start:o,end:u}=U.value;if(!f.value)return"incomplete";if(!o||!u)return"invalid-date";if(!G.value.start||!G.value.end)return"out-of-bounds";const S=G.value.start,$=G.value.end;return z(S,$)?typeof e.maxSpanDays=="number"&&W.value!==void 0&&W.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),i=t.ref(void 0),b=t.computed(()=>{if(P.value!==!1)return"";const{min:o,max:u}=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 o&&u?`Dates must be between ${m(o)} and ${m(u)}.`:"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""}}),c=["ArrowUp","ArrowDown"],p=["ArrowLeft","ArrowRight"],x=(o,u)=>String(o).padStart(u,"0"),m=o=>`${x(o.getMonth()+1,2)}/${x(o.getDate(),2)}/${x(o.getFullYear(),4)}`,M=o=>o<=2?{side:"start",part:"mm"}:o<=5?{side:"start",part:(o<=3,"dd")}:o<=11?{side:"start",part:"yyyy"}:o<=15?{side:"end",part:"mm"}:o<=18?{side:"end",part:"dd"}:{side:"end",part:"yyyy"},L=(o,u,S)=>{const $=u?.selectionStart??l.value??0;l.value=$;const{start:Q,end:ee}=k(n.value);if(!Q&&!ee){const j=new Date,ie=m(j);n.value=`${ie} - ${ie}`,e.onChange({value:{start:j,end:j},event:S}),t.nextTick(()=>{requestAnimationFrame(()=>{const ne=document.getElementById(e.id),ae=l.value??0;ne&&(ne.focus(),ne.setSelectionRange(ae,ae))})});return}const se=new Date,de=M($);let fe=Q?new Date(Q):new Date(se),pe=ee?new Date(ee):new Date(se);const ye=(j,ie)=>{if(ie==="mm"){const ne=j.getMonth()+1,ae=o==="ArrowUp"?ne<12?ne+1:1:ne>1?ne-1:12;j.setMonth(ae-1);const ve=R(j.getFullYear(),ae);j.getDate()>ve&&j.setDate(ve)}else if(ie==="dd"){const ne=R(j.getFullYear(),j.getMonth()+1),ae=j.getDate(),ve=o==="ArrowUp"?ae<ne?ae+1:1:ae>1?ae-1:ne;j.setDate(ve)}else if(ie==="yyyy"){const ne=j.getFullYear();j.setFullYear(o==="ArrowUp"?ne+1:Math.max(1,ne-1));const ae=R(j.getFullYear(),j.getMonth()+1);j.getDate()>ae&&j.setDate(ae)}};de.side==="start"?ye(fe,de.part):ye(pe,de.part);const Se=m(fe),ke=m(pe);n.value=`${Se} - ${ke}`;const ue=I(fe),we=I(pe);ue&&we&&z(ue,we)?e.onChange({value:{start:ue,end:we},event:S}):e.onChange({value:null,event:S}),t.nextTick(()=>{requestAnimationFrame(()=>{const j=document.getElementById(e.id),ie=l.value??0;j&&(j.focus(),j.setSelectionRange(ie,ie))})})},H=o=>{const{start:u,end:S}=k(n.value);if(!u||!S){e.onChange({value:null,event:o});return}const $=I(u),Q=I(S);if(!$||!Q){e.onChange({value:null,event:o});return}if(!z($,Q)){e.onChange({value:null,event:o});return}e.onChange({value:{start:$,end:Q},event:o})},te=o=>{const u=o.value??"",S=o.event;if(!u&&S&&S.type==="click"){Z(S);return}n.value=u;const $=S?.target;l.value=$?.selectionStart??0,H(o)},oe=o=>{l.value=o.target.selectionStart??0},r=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(c.includes(o.key)){o.preventDefault(),o.stopPropagation();const u=o.target;L(o.key,u,o);return}},d=o=>{o.preventDefault();const u=o.deltaY<0?"ArrowUp":"ArrowDown";L(u,o.target,o)},V=o=>{if(p.includes(o.key)||c.includes(o.key)){const u=o.target;l.value=u?.selectionStart??0}},K=()=>{i.value=re.value,(e.manageValid??!0)&&(P.value=X.value)},N=o=>{K()},Z=o=>{console.log("Clear event:",o),n.value="",l.value=0,e.onChange({value:null,event:o}),K(),t.nextTick(()=>{const u=document.getElementById(e.id);u&&(u.focus(),u.setSelectionRange(0,0))})};e.externalValue&&t.watch(e.externalValue,o=>{const u=o?.start??null,S=o?.end??null;if(u&&S){if(n.value=`${m(u)} - ${m(S)}`,e.isOpen?.value&&y.value&&e.onRequestClose){const $=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),y.value=!1,K()},$)}return}},{immediate:!0});const a=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"),C=t.computed(()=>n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0"),q=t.computed(()=>n.value&&n.value.substring(13,15).replace(/\D/g,"0")||"0"),Y=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),_=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),O=t.computed(()=>{const{start:o,end:u}=k(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(a.value).padStart(2,"0")} / ${String(s.value).padStart(2,"0")} / ${String(C.value).padStart(4,"0")}`},{label:"End",value:`${String(q.value).padStart(2,"0")} / ${String(Y.value).padStart(2,"0")} / ${String(_.value).padStart(4,"0")}`},{label:"Digits only",value:g.value},{label:"Mask complete",value:`${f.value}`},{label:"Parsed",value:`${o?o.toDateString():"-"} | ${u?u.toDateString():"-"}`},{label:"Valid (managed)",value:`${P.value??"-"}`},{label:"Span (days)",value:`${W.value??"-"}`},{label:"Reason",value:`${re.value??"-"}`},{label:"Cursor in",value:`${l.value??"-"} (${(()=>{const S=l.value??0,$=M(S);return`${$.side}.${$.part}`})()})`}]}),B=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`#${e.id} not found for styling.`);return}const u=o.closest("div");if(!u){console.warn(`Parent div of #${e.id} not found for styling.`);return}u.classList.contains("fk-daterangepicker")||u.classList.add("fk-daterangepicker")})};t.onMounted(()=>{B()});const le=()=>{t.nextTick(()=>{try{const o=Array.from(document.querySelectorAll(".k-animation-container"));if(!o.length)return;const S=[...o].reverse().find(ee=>ee.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!S)return;const $=S.querySelectorAll(".k-calendar-table");let Q=!1;$.forEach(ee=>{ee.tabIndex===0&&(Q?ee.tabIndex=-1:Q=!0)})}catch(o){console.warn(o)}})};return e.isOpen&&t.watch(e.isOpen,o=>{o&&setTimeout(()=>le(),0)},{immediate:!1}),{raw:n,cursorPos:l,debugEnabled:D,debugLines:O,digitsOnly:g,valid:P,validComputed:t.readonly(X),reason:t.readonly(re),validationMessage:t.readonly(b),spanDays:t.readonly(W),month1:t.readonly(a),day1:t.readonly(s),year1:t.readonly(C),month2:t.readonly(q),day2:t.readonly(Y),year2:t.readonly(_),handleChange:te,handleKeyDown:r,handleWheel:d,handleKeyUp:V,handleClick:oe,handleBlur:N,handleClear:Z,onCalendarChange:()=>{y.value=!0},initStyling:B}}function je(e){const n=t.ref(""),l=t.ref(void 0),D=t.ref(!!e.debug),y=t.ref(e.timeFormat??"hh:mm AM"),v=t.computed(()=>!!e.required),T=t.ref(!1),w=["ArrowUp","ArrowDown"],E=["ArrowLeft","ArrowRight"],F=t.computed(()=>(n.value??"").replace(/\D/g,"")),g={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},R=a=>a<=2?"hh":a<=5?"mm":"ampm",A=t.computed(()=>{const a=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0",s=parseInt(a);return Math.min(Math.max(s,0),23)}),h=t.computed(()=>{const a=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0",s=parseInt(a);return Math.min(Math.max(s,0),59)}),I=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),z=t.computed(()=>{const a=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),s=I.value;return a===12?s==="AM"?0:12:s==="PM"?a+12:a}),f=t.computed(()=>k.value?`${String(z.value).padStart(2,"0")}:${String(h.value).padStart(2,"0")}:00`:null),k=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),P=(a,s,C)=>{let q=a%12;return q===0&&(q=12),`${String(q).padStart(2,"0")}:${String(s).padStart(2,"0")} ${C}`},U=a=>{const s=a.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!s)return null;const C=parseInt(s[1]),q=parseInt(s[2]),Y=s[3].toUpperCase();if(C<1||C>12||q<0||q>59)return null;let _=C%12;Y==="PM"&&(_+=12);const O=new Date;return O.setSeconds(0,0),O.setHours(_),O.setMinutes(q),O},G=a=>{if(F.value.length===0){e.onChange({value:null,event:a});return}if(!k.value){e.onChange({value:null,event:a});return}const s=U(n.value);s&&X(s)?e.onChange({value:s,event:a}):e.onChange({value:null,event:a})},W=a=>a.getHours()*60+a.getMinutes(),X=a=>{const s=e.min??void 0,C=e.max??void 0,q=W(a);if(s){const Y=W(s);if(q<Y)return!1}if(C){const Y=W(C);if(q>Y)return!1}return!0},re=a=>{const s=a.getHours(),C=s>=12?"PM":"AM";n.value=P(s,a.getMinutes(),C)},i=(a,s)=>{e.onChange({value:a,event:s})},b=()=>{t.nextTick(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const a=document.getElementById(e.id);if(a){a.focus();const s=(a.value??"").length;a.setSelectionRange(s,s)}})})})},c=a=>{const s=a?.event?.target;return s?s.closest(".k-time-now")?"now":s.closest(".k-time-accept")?"set":null:null},p=(a,s)=>{a&&X(a)?i(a,s):i(null,s)},x=(...a)=>{const s=a[0];if(!s)return;const C=c(s);if(C==="now"){const Y=new Date;re(Y),p(Y,s),b();return}if(s?.value instanceof Date){const Y=new Date(s.value);re(Y),p(Y,s),C==="set"&&b();return}if(s?.value===null){n.value="",i(null,s);return}n.value=s.value;const q=s.event?.target;l.value=q?.selectionStart??0;try{const Y=l.value??0;if(R(Y)==="ampm"&&(n.value??"").length>=8){const _=n.value.charAt(6);/[Aa]/.test(_)?(n.value=`${n.value.slice(0,6)}AM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const O=document.getElementById(e.id);O&&(O.focus(),O.setSelectionRange(8,8))})})):/[Pp]/.test(_)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const O=document.getElementById(e.id);O&&(O.focus(),O.setSelectionRange(8,8))})}))}}catch{}G(s)},m=a=>{l.value=a.target.selectionStart??0},M=(a,s,C)=>{const q=s?.selectionStart??l.value??0;l.value=q;const Y=R(q),_=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!_){if((n.value??"").length===0||F.value.length===0){const u=new Date,S=u.getHours(),$=S>=12?"PM":"AM";n.value=P(S,u.getMinutes(),$);const Q=U(n.value);p(Q,C),t.nextTick(()=>{requestAnimationFrame(()=>{const ee=document.getElementById(e.id),se=l.value??0;ee&&(ee.focus(),ee.setSelectionRange(se,se))})})}return}let O=parseInt(_[1]),B=parseInt(_[2]),le=_[3].toUpperCase();if(Y==="hh")a==="ArrowUp"?O=O<12?O+1:1:O=O>1?O-1:12;else if(Y==="mm"){const u=e.minuteStepRef?.value??e.minuteStep??1;if(u===1)a==="ArrowUp"?B=B<59?B+1:0:B=B>0?B-1:59;else if(a==="ArrowUp"){const S=B%u;let $=S===0?B+u:B+(u-S);$>=60&&($=0),B=$}else{const S=B%u;let $=S===0?B-u:B-S;$<0&&($=60-u),B=$}}else Y==="ampm"&&(le=le==="AM"?"PM":"AM");n.value=`${String(O).padStart(2,"0")}:${String(B).padStart(2,"0")} ${le}`;const o=U(n.value);p(o,C),t.nextTick(()=>{requestAnimationFrame(()=>{const u=document.getElementById(e.id),S=l.value??0;u&&(u.focus(),u.setSelectionRange(S,S))})})},L=a=>{if(a.code==="Space"||a.key===" "){a.preventDefault(),a.stopPropagation(),e.onShowPicker(a);return}if(a.key==="ArrowDown"&&a.altKey){a.preventDefault(),a.stopPropagation(),e.onShowPicker(a);return}if(w.includes(a.key)){if(a.altKey)return;a.preventDefault(),a.stopPropagation();const s=a.target;M(a.key,s,a);return}},H=a=>{a.preventDefault();const s=a.deltaY<0?"ArrowUp":"ArrowDown";M(s,a.target,a)},te=a=>{const s=a.target;if(E.includes(a.key)){l.value=s?.selectionStart??0;return}if(w.includes(a.key)){if(a.altKey)return;l.value=s?.selectionStart??0}},oe=a=>{T.value=!0,v.value&&e.externalValue&&e.externalValue.value===void 0&&F.value.length===0&&(e.externalValue.value="");const s=a.target;s&&(l.value=s.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,a=>{if(a){const s=new Date(a);if(s.toString()!=="Invalid Date"){const C=s.getHours(),q=C>=12?"PM":"AM";n.value=P(C,s.getMinutes(),q);return}}},{immediate:!0});const r=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",A.value],["Hour (24h)",z.value],["Minute",h.value],["Period",I.value],["Time (24h)",f.value??"--:--:--"],["Digits only",F.value],["Parsed Date",d.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",V.value],["reason",K.value],["validationMessage",N.value]]),d=t.computed(()=>U(n.value)??null),V=t.computed(()=>{if(!v.value){if(!k.value)return!0;const s=d.value;return s?X(s):!1}if(!T.value)return!0;const a=d.value;return!k.value||!a?!1:X(a)}),K=t.computed(()=>{if(!v.value){if(!k.value)return;const s=d.value;return s?X(s)?"valid":"out-of-bounds":"invalid-time"}if(!T.value)return;if(F.value.length===0||!k.value)return"incomplete";const a=d.value;return a?X(a)?"valid":"out-of-bounds":"invalid-time"}),N=t.computed(()=>{const a=K.value;if(!a||a==="valid")return"";if(a==="incomplete")return"Required";if(a==="invalid-time")return`Must be in ${y.value} format.`;const s={hour:"2-digit",minute:"2-digit"},C=e.min?e.min.toLocaleTimeString("en-US",s):null,q=e.max?e.max.toLocaleTimeString("en-US",s):null;if(a==="out-of-bounds"){if(C&&q)return`Must be between ${C} and ${q}.`;if(C)return`Must be ${C} or later.`;if(q)return`Must be ${q} or earlier.`}return""}),Z=()=>{t.nextTick(()=>{const a=document.getElementById(e.id);if(!a){console.warn(`#${e.id} not found for styling.`);return}const s=a.closest(".k-timepicker");if(!s){console.warn(`.k-timepicker parent of #${e.id} not found for styling.`);return}const C=s.parentElement;if(!C){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}C.classList.contains("fk-timepicker")||C.classList.add("fk-timepicker")})};return t.onMounted(()=>{Z()}),{raw:n,rules:g,debugEnabled:D,debugLines:r,placeholder:y,isValid:V,reason:t.readonly(K),validationMessage:N,isComplete:k,inRangeTime:X,cursorPos:l,hour:t.readonly(A),hour24:t.readonly(z),minute:t.readonly(h),period:t.readonly(I),time24:t.readonly(f),parsedRawTime:t.readonly(d),handleChange:x,handleKeyDown:L,handleKeyUp:te,handleClick:m,handleWheel:H,handleBlur:oe,initStyling:Z}}function Ge(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}const Ie=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const _e=Object.prototype.toString,Je=e=>_e.call(e)==="[object Object]",ce=()=>{},Xe=Qe();function Qe(){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 et(e,n,l){return t.watch(e,n,{...l,immediate:!0})}const Te=Ie?window:void 0;function me(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},D=(w,E,F,g)=>(w.addEventListener(E,F,g),()=>w.removeEventListener(E,F,g)),y=t.computed(()=>{const w=he(t.toValue(e[0])).filter(E=>E!=null);return w.every(E=>typeof E!="string")?w:void 0}),v=et(()=>{var w,E;return[(E=(w=y.value)==null?void 0:w.map(F=>me(F)))!=null?E:[Te].filter(F=>F!=null),he(t.toValue(y.value?e[1]:e[0])),he(t.unref(y.value?e[2]:e[1])),t.toValue(y.value?e[3]:e[2])]},([w,E,F,g])=>{if(l(),!w?.length||!E?.length||!F?.length)return;const R=Je(g)?{...g}:g;n.push(...w.flatMap(A=>E.flatMap(h=>F.map(I=>D(A,h,I,R)))))},{flush:"post"}),T=()=>{v(),l()};return Ge(l),T}let Ce=!1;function tt(e,n,l={}){const{window:D=Te,ignore:y=[],capture:v=!0,detectIframe:T=!1,controls:w=!1}=l;if(!D)return w?{stop:ce,cancel:ce,trigger:ce}:ce;if(Xe&&!Ce){Ce=!0;const f={passive:!0};Array.from(D.document.body.children).forEach(k=>k.addEventListener("click",ce,f)),D.document.documentElement.addEventListener("click",ce,f)}let E=!0;const F=f=>t.toValue(y).some(k=>{if(typeof k=="string")return Array.from(D.document.querySelectorAll(k)).some(P=>P===f.target||f.composedPath().includes(P));{const P=me(k);return P&&(f.target===P||f.composedPath().includes(P))}});function g(f){const k=t.toValue(f);return k&&k.$.subTree.shapeFlag===16}function R(f,k){const P=t.toValue(f),U=P.$.subTree&&P.$.subTree.children;return U==null||!Array.isArray(U)?!1:U.some(G=>G.el===k.target||k.composedPath().includes(G.el))}const A=f=>{const k=me(e);if(f.target!=null&&!(!(k instanceof Element)&&g(e)&&R(e,f))&&!(!k||k===f.target||f.composedPath().includes(k))){if("detail"in f&&f.detail===0&&(E=!F(f)),!E){E=!0;return}n(f)}};let h=!1;const I=[be(D,"click",f=>{h||(h=!0,setTimeout(()=>{h=!1},0),A(f))},{passive:!0,capture:v}),be(D,"pointerdown",f=>{const k=me(e);E=!F(f)&&!!(k&&!f.composedPath().includes(k))},{passive:!0}),T&&be(D,"blur",f=>{setTimeout(()=>{var k;const P=me(e);((k=D.document.activeElement)==null?void 0:k.tagName)==="IFRAME"&&!P?.contains(D.document.activeElement)&&n(f)},0)},{passive:!0})].filter(Boolean),z=()=>I.forEach(f=>f());return w?{stop:z,cancel:()=>{E=!1},trigger:f=>{E=!0,A(f),E=!1}}:z}function nt(e){const n=t.shallowRef(null),l=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],D=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??l].flat(),y=g=>g?typeof e.initialFocus=="string"?g.querySelector(e.initialFocus)??g:typeof e.initialFocus=="function"?e.initialFocus(g)??g:g.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??g:null,{activate:v,deactivate:T}=Ve.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>y(n.value),...e.focusTrapOptions??{}});let w=null,E=t.ref(null);const F=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const g=(A,h)=>{const I=Array.from(A.querySelectorAll(h));if(!I.length)return null;const z=I.filter(f=>f.offsetParent!==null||f.getClientRects().length>0);return z[z.length-1]??I[I.length-1]??null},R=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const A of D){const h=g(R,A);if(h)return h}for(const A of D){const h=g(document,A);if(h)return h}return null};return tt(n,g=>{E.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",g)}),t.watch(()=>e.isOpen.value,g=>{g?(E.value=null,t.nextTick(()=>{const R=F();R&&(n.value=R,setTimeout(()=>v(),0),w||(w=A=>{A.key==="Escape"&&(E.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",A))},document.addEventListener("keydown",w,!0)))})):(T(),w&&(document.removeEventListener("keydown",w,!0),w=null),n.value=null,E.value==="outside"&&t.nextTick(()=>{const R=()=>{const A=e.triggerEl?.value,h=A?.querySelector("input"),I=document.activeElement;I&&(I===h||A&&A.contains(I))&&(h??A)?.blur?.()};requestAnimationFrame(()=>setTimeout(R,0))}),e.returnFocusToTrigger!==!1&&E.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const R=()=>{const A=e.triggerEl?.value;if(!A)return;(A.querySelector("input")??A)?.focus?.()};requestAnimationFrame(()=>setTimeout(R,0))})))}),{popupRef:n,activate:v,deactivate:T,lastCloseReason:t.readonly(E),setPopupEl:g=>n.value=g}}J.useFieldsetTouchTracker=Ee,J.useFieldsetValidationKit=Me,J.useGridA11y=Fe,J.useGridActiveFilter=Re,J.useMaskedDateInput=Ye,J.useMaskedDateRangeInput=We,J.useMaskedTimeInput=je,J.usePopupTrap=nt,J.useUSAddress=Ze,J.useZipTextBox=xe,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"})}));
|
|
2
2
|
//# sourceMappingURL=featherk-composables.umd.js.map
|