@featherk/composables 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/address/_useUSAddressFormData.d.ts +29 -0
- package/dist/address/_useUSAddressFormData.test.d.ts +1 -0
- package/dist/address/_useUSAddressValidation.d.ts +19 -0
- package/dist/address/_useUSAddressValidation.test.d.ts +1 -0
- package/dist/address/_useUSAddressZip.d.ts +13 -0
- package/dist/address/_useUSAddressZip.test.d.ts +1 -0
- package/dist/address/index.d.ts +2 -0
- package/dist/address/usStates.d.ts +5 -0
- package/dist/address/useUSAddress.d.ts +62 -0
- package/dist/address/useUSAddress.test.d.ts +1 -0
- package/dist/featherk-composables.es.js +1171 -905
- package/dist/featherk-composables.umd.js +1 -1
- package/dist/form/index.d.ts +4 -0
- package/dist/form/useFieldsetTouchTracker.d.ts +13 -0
- package/dist/form/useFieldsetTouchTracker.test.d.ts +1 -0
- package/dist/form/useFieldsetValidationKit.d.ts +62 -0
- package/dist/form/useFieldsetValidationKit.test.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/docs/address/useUSAddress.md +101 -0
- package/docs/address/useZipTextBox.md +5 -1
- package/docs/form/useFieldsetTouchTracker.md +74 -0
- package/docs/form/useFieldsetValidationKit.md +150 -0
- package/package.json +7 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(te,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):(te=typeof globalThis<"u"?globalThis:te||self,t(te.FeatherKComposables={},te.Vue,te.useFocusTrap))})(this,(function(te,t,Me){"use strict";const Te=(e,n)=>{const s=t.ref(null);let U=!1,L=null,C=null;const O=[],x=".k-table-row[data-grid-row-index] [tabindex]",A=()=>{const l=e?.value?.$el;return l?l.closest(".k-grid"):null},D=l=>{const y=A();if(!y)return!1;const u=l.closest(".k-grid-aria-root");if(u)return y.contains(u);const d=l.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return d?y.contains(d):!1},w=l=>l.key==="Enter"||l.code==="Enter"||l.code==="NumpadEnter",I=()=>e?.value?.columns,E=l=>{const y=l.key||l.code;([" ","Spacebar","Space"].includes(y)||w(l))&&(l.preventDefault(),l.stopPropagation(),s.value=l.target,l.target.click())},v=l=>{if(!s.value)return;if(l.code==="Escape"){l.stopPropagation(),s.value&&s.value.focus();return}const y=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(l.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"],b=n?.focusableMenuSelectors??d,m=Array.from(u.querySelectorAll(b.join(",")));if(m.length===0)return;const k=m.findIndex(G=>G===document.activeElement);let F;k===-1?F=0:l.shiftKey?F=(k-1+m.length)%m.length:F=(k+1)%m.length,l.preventDefault(),l.stopPropagation(),m[F]?.focus()}}else if(l.code==="ArrowUp"||l.code==="ArrowDown"){l.preventDefault(),l.stopPropagation();const d=y.findIndex(m=>m===document.activeElement);let b=d;l.code==="ArrowUp"?b=d>0?d-1:y.length-1:l.code==="ArrowDown"&&(b=d<y.length-1?d+1:0),y[b]?.focus();return}if(l.code==="Tab"){l.preventDefault(),l.stopPropagation();const d=s.value?.parentElement;(l.shiftKey?d?.previousElementSibling:d?.nextElementSibling)?.querySelector("button, [role='button'], .k-link")?.focus()}},M=()=>{L=new MutationObserver(l=>{l.forEach(y=>{y.addedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;if(d.classList.contains("k-animation-container")){const m=s.value;m&&(m.dataset.featherKSortable==="true"||t.nextTick(()=>{d.querySelectorAll(".k-columnmenu-item-wrapper").forEach(G=>{G.textContent?.toLowerCase().includes("sort")&&G.remove()})})),d.addEventListener("keydown",v),t.nextTick(()=>{const k=()=>{const F=Array.from(d.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"));if(F.length===1)F[0].focus(),F[0].click(),k.attempts=0;else if(F.length>1){k.attempts=0;return}else k.attempts===void 0&&(k.attempts=0),k.attempts++<3&&setTimeout(k,200)};k()})}d.querySelectorAll(".k-animation-container").forEach(m=>{m.addEventListener("keydown",v)})}}),y.removedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;d.classList.contains("k-animation-container")&&d.removeEventListener("keydown",v),d.querySelectorAll(".k-animation-container").forEach(m=>{m.removeEventListener("keydown",v)})}})})}),L.observe(document.body,{childList:!0,subtree:!0})},P=l=>{const y=l.tagName.toLowerCase();return!!(["input","textarea","select","button"].includes(y)||l.closest('.k-picker-wrap, .k-input-inner, .k-textbox, [role="combobox"]'))},f=l=>{if(!l.type||!l)return;const y=l.target;if(!y)return;const u=y.closest(".k-table-row[data-grid-row-index]");if(!D(y))return;const d=["ArrowLeft","ArrowRight"].includes(l.code);if(!(P(y)&&!(u&&d))){if(l.code==="Escape"){const b=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(b){l.preventDefault(),l.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(k=>k.setAttribute("tabindex","-1"))}catch{}b.setAttribute("tabindex","0"),b.focus();return}}if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter","NumpadEnter","Space"].includes(l.code)){if(y.classList.contains("k-grid-header-menu")&&y.classList.contains("k-grid-column-menu")){s.value=y;return}if(u){if(["ArrowDown","ArrowUp"].includes(l.code)){l.preventDefault(),l.stopPropagation();const b=(k,F)=>{let G=F==="next"?k.nextElementSibling:k.previousElementSibling;for(;G;){const a=G;try{if(a.classList.contains("k-table-row"))return a}catch{}G=F==="next"?G.nextElementSibling:G.previousElementSibling}return null},m=l.code==="ArrowDown"?b(u,"next"):b(u,"previous");m&&(u.setAttribute("tabindex","-1"),m.setAttribute("tabindex","0"),m.focus());return}if(["ArrowLeft","ArrowRight"].includes(l.code)){l.preventDefault(),l.stopPropagation();const b=u.querySelectorAll(x);if(b.length===0)return;let m=Array.from(b).findIndex(k=>k===document.activeElement);if(m===-1&&document.activeElement===u){b[0].focus();return}l.code==="ArrowRight"?m=m===b.length-1?0:m+1:l.code==="ArrowLeft"&&(m=m===0?b.length-1:m-1),b[m].focus();return}}}}},S=()=>{t.nextTick(()=>{const l=e.value.$el.closest(".k-grid");l&&l.classList.add("fk-grid")})},R=()=>{if(!C)try{const l=()=>{try{const d=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!d||d.length===0||d.filter(k=>k.getAttribute("tabindex")==="0").length===1)return;const m=d.find(k=>k===document.activeElement||k.contains(document.activeElement));if(d.forEach(k=>k.setAttribute("tabindex","-1")),m){m.setAttribute("tabindex","0");return}d[0].setAttribute("tabindex","0")}catch(d){console.error("ensureSingleTabindex error:",d)}},y=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));y.length>0&&y.forEach((d,b)=>{d.setAttribute("tabindex",b===0?"0":"-1")});const u=e.value.$el.querySelector(".k-table-tbody");u&&(C=new MutationObserver(()=>{l()}),C.observe(u,{childList:!0,subtree:!0}))}catch(l){console.error("Error setting up row navigation:",l)}},j=()=>{t.nextTick(()=>{const y=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");y&&y.forEach(u=>{u.setAttribute("role","button"),u.addEventListener("keydown",E)}),M(),X()})},W=()=>{const y=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");y&&y.forEach(u=>{u.removeEventListener("keydown",E)}),L&&(L.disconnect(),L=null),C&&(C.disconnect(),C=null),O.forEach(u=>u()),O.length=0},X=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((u,d)=>{if(u.dataset.featherKHeaderBound==="true")return;const b=u.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!b)return;const m=I();if(m&&m[d]){const g=m[d].field??"";u.setAttribute("data-feather-k-field",g),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 k=u.dataset.featherKFilterable!=="false",F=u.dataset.featherKSortable!=="false";b.setAttribute("tabindex","-1"),k||F?u.style.cursor="pointer":u.style.cursor="default",k?(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 G=g=>{g.target?.closest(".k-column-resizer")||(s.value=u,b.click())},a=g=>{if(k)s.value=u,g.preventDefault(),g.stopPropagation(),G(g);else if(F){s.value=u;const V=u.querySelector(".k-link");V&&V.click()}};u.addEventListener("click",a),O.push(()=>{u.removeEventListener("click",a)});const p=g=>{if((w(g)||g.code==="Space")&&(k||F)){if(g.preventDefault(),g.stopPropagation(),s.value=u,s.value.focus(),k)G(g);else if(F){const V=u.querySelector(".k-link");V&&V.click()}}};u.addEventListener("keydown",p,!0),O.push(()=>{u.removeEventListener("keydown",p,!0)}),u.dataset.featherKHeaderBound="true"});const y=document.querySelector(".k-grid-header .k-table-thead");if(y&&y.dataset.featherKHeaderBound!=="true"){const u=d=>{const b=d.target.closest("th");b&&(w(d)||d.code==="Space")&&b.dataset.featherKFilterable==="false"&&b.dataset.featherKSortable==="false"&&(d.preventDefault(),d.stopImmediatePropagation())};y.addEventListener("keydown",u,!0),O.push(()=>{y.removeEventListener("keydown",u,!0)}),y.dataset.featherKHeaderBound="true"}},J=function(l,y){const u=l?.event?.event.target,d=I();if(!u||!d)return;const b=u.classList.contains("k-grid-header-menu"),m=u.classList.contains("k-columnmenu-item"),k=d.find(F=>F.field===l?.event?.field)?.sortable&&!0;if(!b){if(m&&!k){l?.event?.sort?.filter(G=>G.field!==l?.event?.field);return}typeof y=="function"&&t.nextTick(()=>{s.value&&s.value.focus(),y(l),t.nextTick(()=>{X()})})}},oe=()=>{if(!U)try{S(),R(),j(),U=!0}catch(l){console.error("initA11y failed:",l),W()}};return t.onBeforeUnmount(()=>{W()}),{activeFilterButton:s,handleGridKeyDown:f,handleSortChange:J,initA11y:oe}},$e=e=>!!e&&typeof e=="object"&&"filters"in e&&Array.isArray(e.filters),Ce=e=>!!e&&typeof e=="object"&&"field"in e,we=(e,n)=>!e||typeof e!="object"?!1:$e(e)?e.filters.some(s=>we(s,n)):Ce(e)?e.field===n:!1,Ie=e=>n=>e.value?.filters&&e.value.filters.some(s=>we(s,n))?"active":"",Pe="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},Le=(e,n)=>e.slice(0,Math.max(0,n)).replace(/\D/g,"").length,Re=e=>e<=5?e:Math.min(e+1,10),Fe=e=>{const n=t.ref(De(e.initialValue??"")),s=t.ref(!1),U=t.ref(e.errorMessage?.trim()||Pe),L=t.computed(()=>n.value.replace(/\D/g,"")),C=t.computed(()=>{const v=L.value.length;return v===5||v===9}),O=t.computed(()=>s.value&&!C.value),x=t.computed(()=>!s.value||C.value),A=t.computed(()=>s.value),D=(v,M)=>{const P=Re(M);t.nextTick(()=>{v.isConnected&&v.setSelectionRange(P,P)})};return{zipDisplay:n,submitted:s,errorMessage:U,wrapperClass:"fk-zip-textbox",zipRaw:L,isZipValid:C,showZipError:O,textBoxValid:x,textBoxValidate:A,handleZipInput:(...v)=>{const M=v[0],f=M?.event?.target,S=M?.value,R=Array.isArray(S)?S.join(""):String(S??""),j=f?.selectionStart!==void 0&&f.selectionStart!==null?Le(f.value,f.selectionStart):R.replace(/\D/g,"").length;n.value=De(R),f&&D(f,j)},submitAndValidate:v=>{s.value=!0;const M=C.value;return!M&&v?.focus&&t.nextTick(()=>{document.getElementById(e.id)?.focus()}),M},buildPayload:()=>({zip:L.value})}};function qe(e){const n=t.ref(""),s=t.ref(void 0),U=t.ref(!!e.debug),L=t.ref(e.dateFormat??"mm/dd/yyyy"),C=t.computed(()=>!!e.required),O=t.ref(!1),x=["ArrowUp","ArrowDown"],A=["ArrowLeft","ArrowRight"],D=t.computed(()=>(n.value??"").replace(/\D/g,"")),w=a=>a<=2?"mm":a<=5?"dd":D.value.length<=10?"yyyy":"mm",I=t.computed(()=>{const a=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(2,"0")}),E=t.computed(()=>{const a=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(2,"0")}),v=t.computed(()=>{const a=n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(4,"0")}),M=a=>{if(D.value.length===0){e.onChange({value:null,event:a});return}if(D.value.length<8){e.onChange({value:null,event:a});return}if((n.value??"").length===10&&D.value.length===8){const[p,g,V]=n.value.split("/"),K=parseInt(p),N=parseInt(g),_=parseInt(V);if(j(_,K,N)){const ae=new Date(_,K-1,N);P(ae)?e.onChange({value:ae,event:a}):e.onChange({value:null,event:a})}else e.onChange({value:null,event:a})}},P=a=>{const p=e.min??void 0,g=e.max??void 0;return!(p&&a<p||g&&a>g)},f=t.computed(()=>{if((n.value??"").length===10&&D.value.length===8){const[a,p,g]=(n.value??"").split("/"),V=parseInt(a),K=parseInt(p),N=parseInt(g);if(j(N,V,K))return new Date(N,V-1,K)}return null}),S=t.computed(()=>(n.value??"").length===10&&D.value.length===8),R=(a,p)=>new Date(a,p,0).getDate(),j=(a,p,g)=>p>=1&&p<=12&&a>=1900&&g>=1&&g<=R(a,p),W=a=>{n.value=a.value;const p=a.event?.target;s.value=p?.selectionStart??0,M(a)},X=a=>{s.value=a.target.selectionStart??0},J=(a,p,g)=>{const V=p?.selectionStart??s.value??0;s.value=V;let K=parseInt(I.value),N=parseInt(E.value),_=parseInt(v.value);if(!(D.value.length>=8)||!j(_,K,N)){const z=e.defaultValue??new Date;K=z.getMonth()+1,N=z.getDate(),_=z.getFullYear(),n.value=`${String(K).padStart(2,"0")}/${String(N).padStart(2,"0")}/${String(_)}`;const B=new Date(_,K-1,N);e.onChange({value:P(B)?B:null,event:g}),d({useRAF:!0});return}const o=w(V);if(o==="mm")K=a==="ArrowUp"?K<12?K+1:1:K>1?K-1:12;else if(o==="dd"){const z=new Date(_,K,0).getDate();N=a==="ArrowUp"?N<z?N+1:1:N>1?N-1:z}else o==="yyyy"&&(_=a==="ArrowUp"?_+1:Math.max(1,_-1));n.value=`${String(K).padStart(2,"0")}/${String(N).padStart(2,"0")}/${String(_)}`;const[i,$,q]=n.value.split("/"),H=new Date(parseInt(q),parseInt(i)-1,parseInt($));H.toString()!=="Invalid Date"&&parseInt(q)>=1e3?e.onChange({value:P(H)?H:null,event:g}):e.onChange({value:null,event:g}),d({useRAF:!0})},oe=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(x.includes(a.key)){if(a.altKey)return;a.preventDefault(),a.stopPropagation();const p=a.target;J(a.key,p,a);return}},l=a=>{a.preventDefault();const p=a.deltaY<0?"ArrowUp":"ArrowDown";J(p,a.target,a)},y=a=>{const p=a.target;if(A.includes(a.key)){s.value=p?.selectionStart??0;return}if(x.includes(a.key)){if(a.altKey)return;s.value=p?.selectionStart??0}},u=a=>{O.value=!0,C.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&D.value.length===0&&(e.externalValue.value="");const p=a.target;p&&(s.value=p.selectionStart??0)},d=a=>{const p=()=>{const g=document.getElementById(e.id);if(!g)return;const V=a?.pos??s.value??g.value.length;try{g.focus(),g.setSelectionRange(V,V)}catch{}};t.nextTick(()=>{if(a?.delay&&a.delay>0){setTimeout(p,a.delay);return}if(a?.useRAF){requestAnimationFrame(p);return}p()})};e.externalValue&&t.watch(e.externalValue,a=>{if(a){const p=new Date(a);if(p.toString()!=="Invalid Date"){const g=(p.getMonth()+1).toString().padStart(2,"0"),V=p.getDate().toString().padStart(2,"0"),K=p.getFullYear().toString();n.value=`${g}/${V}/${K}`,d({delay:50});return}}},{immediate:!0});const b=t.computed(()=>[["Date",`${I.value} / ${E.value} / ${v.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(!S.value)return!0;const p=f.value;return p?P(p):!1}if(!O.value)return!0;const a=f.value;return!S.value||!a?!1:P(a)}),k=t.computed(()=>{if(!C.value){if(!S.value)return;const p=f.value;return p?P(p)?"valid":"out-of-bounds":"invalid-date"}if(!O.value)return;if(D.value.length===0||!S.value)return"incomplete";const a=f.value;return a?P(a)?"valid":"out-of-bounds":"invalid-date"}),F=t.computed(()=>{const a=k.value;if(!a||a==="valid")return"";if(a==="incomplete")return"Required";if(a==="invalid-date")return`Must be in ${L.value} format.`;const p=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,g=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(a==="out-of-bounds"){if(p&&g)return`Must be between ${p} and ${g}.`;if(p)return`Must be on or after ${p}.`;if(g)return`Must be on or before ${g}.`}return""}),G=()=>{t.nextTick(()=>{const a=document.getElementById(e.id);if(!a){console.warn(`ID (#${e.id}) not found for styling.`);return}const p=a.closest(".k-datepicker");if(!p){console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}const g=p.parentElement;if(g){if(g.classList.contains("fk-datepicker"))return;g.classList.add("fk-datepicker")}else console.warn(`Parent of .k-datepicker not found for #${e.id} styling.`)})};return t.onMounted(()=>{G()}),{raw:n,cursorPos:s,debugEnabled:U,debugLines:b,placeholder:L,isValid:m,reason:t.readonly(k),validationMessage:F,digitsOnly:D,month:t.readonly(I),day:t.readonly(E),year:t.readonly(v),datePart:w,handleChange:W,handleKeyDown:oe,handleWheel:l,handleKeyUp:y,handleClick:X,handleBlur:u,initStyling:G}}function Ve(e){const n=t.ref(""),s=t.ref(void 0),U=t.ref(!!e.debug),L=t.ref(!1),C=1440*60*1e3,O=365*C,x=new Date,A=new Date(x.getTime()-O),D=new Date(x.getTime()+O);e.min=e.min??A,e.max=e.max??D;const w=t.computed(()=>(n.value??"").replace(/\D/g,"")),I=(r,c)=>new Date(r,c,0).getDate(),E=(r,c,h)=>c>=1&&c<=12&&r>=1e3&&h>=1&&h<=I(r,c),v=r=>Date.UTC(r.getFullYear(),r.getMonth(),r.getDate()),M=r=>{if(!r)return null;const c=e.min??new Date(Date.now()-90*C),h=e.max??new Date,T=v(r);return T<v(c)||T>v(h)?null:r},P=(r,c)=>e.allowReverse??!1?!0:r<=c,f=t.computed(()=>(n.value?.length??0)>=23&&w.value.length>=16),S=r=>{if((r??"").length<23||w.value.length<16)return{start:null,end:null};const c=r.substring(0,10),h=r.substring(13,23),[T,Q,ee]=c.split("/").map(se=>parseInt(se||"0",10)),[ie,ce,de]=h.split("/").map(se=>parseInt(se||"0",10)),fe=new Date(ee,T-1,Q),ye=new Date(de,ie-1,ce),Se=E(ee,T,Q)&&fe.toString()!=="Invalid Date",be=E(de,ie,ce)&&ye.toString()!=="Invalid Date";return{start:Se?fe:null,end:be?ye:null}},R=e.externalValid??t.ref(!0),j=t.computed(()=>S(n.value)),W=t.computed(()=>{const r=M(j.value.start),c=M(j.value.end);return{start:r,end:c}}),X=t.computed(()=>{if(!f.value)return;const r=W.value.start,c=W.value.end;if(!r||!c)return;const h=Math.abs(v(c)-v(r));return Math.round(h/864e5+1)}),J=t.computed(()=>{if(!f.value)return!1;const{start:r,end:c}=j.value;if(!r||!c||!W.value.start||!W.value.end)return!1;const h=W.value.start,T=W.value.end;return!(!P(h,T)||typeof e.maxSpanDays=="number"&&X.value!==void 0&&X.value>e.maxSpanDays)}),oe=t.computed(()=>{const{start:r,end:c}=j.value;if(!f.value)return"incomplete";if(!r||!c)return"invalid-date";if(!W.value.start||!W.value.end)return"out-of-bounds";const h=W.value.start,T=W.value.end;return P(h,T)?typeof e.maxSpanDays=="number"&&X.value!==void 0&&X.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),l=t.ref(void 0),y=t.computed(()=>{if(R.value!==!1)return"";const{min:r,max:c}=e,h=l.value;if(!h)return"";switch(h){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 r&&c?`Dates must be between ${m(r)} 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"],b=(r,c)=>String(r).padStart(c,"0"),m=r=>`${b(r.getMonth()+1,2)}/${b(r.getDate(),2)}/${b(r.getFullYear(),4)}`,k=r=>r<=2?{side:"start",part:"mm"}:r<=5?{side:"start",part:(r<=3,"dd")}:r<=11?{side:"start",part:"yyyy"}:r<=15?{side:"end",part:"mm"}:r<=18?{side:"end",part:"dd"}:{side:"end",part:"yyyy"},F=(r,c,h)=>{const T=c?.selectionStart??s.value??0;s.value=T;const{start:Q,end:ee}=S(n.value);if(!Q&&!ee){const Y=new Date,le=m(Y);n.value=`${le} - ${le}`,e.onChange({value:{start:Y,end:Y},event:h}),t.nextTick(()=>{requestAnimationFrame(()=>{const ne=document.getElementById(e.id),re=s.value??0;ne&&(ne.focus(),ne.setSelectionRange(re,re))})});return}const ie=new Date,ce=k(T);let de=Q?new Date(Q):new Date(ie),fe=ee?new Date(ee):new Date(ie);const ye=(Y,le)=>{if(le==="mm"){const ne=Y.getMonth()+1,re=r==="ArrowUp"?ne<12?ne+1:1:ne>1?ne-1:12;Y.setMonth(re-1);const ge=I(Y.getFullYear(),re);Y.getDate()>ge&&Y.setDate(ge)}else if(le==="dd"){const ne=I(Y.getFullYear(),Y.getMonth()+1),re=Y.getDate(),ge=r==="ArrowUp"?re<ne?re+1:1:re>1?re-1:ne;Y.setDate(ge)}else if(le==="yyyy"){const ne=Y.getFullYear();Y.setFullYear(r==="ArrowUp"?ne+1:Math.max(1,ne-1));const re=I(Y.getFullYear(),Y.getMonth()+1);Y.getDate()>re&&Y.setDate(re)}};ce.side==="start"?ye(de,ce.part):ye(fe,ce.part);const Se=m(de),be=m(fe);n.value=`${Se} - ${be}`;const se=M(de),ke=M(fe);se&&ke&&P(se,ke)?e.onChange({value:{start:se,end:ke},event:h}):e.onChange({value:null,event:h}),t.nextTick(()=>{requestAnimationFrame(()=>{const Y=document.getElementById(e.id),le=s.value??0;Y&&(Y.focus(),Y.setSelectionRange(le,le))})})},G=r=>{const{start:c,end:h}=S(n.value);if(!c||!h){e.onChange({value:null,event:r});return}const T=M(c),Q=M(h);if(!T||!Q){e.onChange({value:null,event:r});return}if(!P(T,Q)){e.onChange({value:null,event:r});return}e.onChange({value:{start:T,end:Q},event:r})},a=r=>{const c=r.value??"",h=r.event;if(!c&&h&&h.type==="click"){ae(h);return}n.value=c;const T=h?.target;s.value=T?.selectionStart??0,G(r)},p=r=>{s.value=r.target.selectionStart??0},g=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(u.includes(r.key)){r.preventDefault(),r.stopPropagation();const c=r.target;F(r.key,c,r);return}},V=r=>{r.preventDefault();const c=r.deltaY<0?"ArrowUp":"ArrowDown";F(c,r.target,r)},K=r=>{if(d.includes(r.key)||u.includes(r.key)){const c=r.target;s.value=c?.selectionStart??0}},N=()=>{l.value=oe.value,(e.manageValid??!0)&&(R.value=J.value)},_=r=>{N()},ae=r=>{console.log("Clear event:",r),n.value="",s.value=0,e.onChange({value:null,event:r}),N(),t.nextTick(()=>{const c=document.getElementById(e.id);c&&(c.focus(),c.setSelectionRange(0,0))})};e.externalValue&&t.watch(e.externalValue,r=>{const c=r?.start??null,h=r?.end??null;if(c&&h){if(n.value=`${m(c)} - ${m(h)}`,e.isOpen?.value&&L.value&&e.onRequestClose){const T=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),L.value=!1,N()},T)}return}},{immediate:!0});const o=t.computed(()=>n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0"),i=t.computed(()=>n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0"),$=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"),H=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),z=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),B=t.computed(()=>{const{start:r,end:c}=S(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(o.value).padStart(2,"0")} / ${String(i.value).padStart(2,"0")} / ${String($.value).padStart(4,"0")}`},{label:"End",value:`${String(q.value).padStart(2,"0")} / ${String(H.value).padStart(2,"0")} / ${String(z.value).padStart(4,"0")}`},{label:"Digits only",value:w.value},{label:"Mask complete",value:`${f.value}`},{label:"Parsed",value:`${r?r.toDateString():"-"} | ${c?c.toDateString():"-"}`},{label:"Valid (managed)",value:`${R.value??"-"}`},{label:"Span (days)",value:`${X.value??"-"}`},{label:"Reason",value:`${oe.value??"-"}`},{label:"Cursor in",value:`${s.value??"-"} (${(()=>{const h=s.value??0,T=k(h);return`${T.side}.${T.part}`})()})`}]}),Z=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`#${e.id} not found for styling.`);return}const c=r.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(()=>{Z()});const me=()=>{t.nextTick(()=>{try{const r=Array.from(document.querySelectorAll(".k-animation-container"));if(!r.length)return;const h=[...r].reverse().find(ee=>ee.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!h)return;const T=h.querySelectorAll(".k-calendar-table");let Q=!1;T.forEach(ee=>{ee.tabIndex===0&&(Q?ee.tabIndex=-1:Q=!0)})}catch(r){console.warn(r)}})};return e.isOpen&&t.watch(e.isOpen,r=>{r&&setTimeout(()=>me(),0)},{immediate:!1}),{raw:n,cursorPos:s,debugEnabled:U,debugLines:B,digitsOnly:w,valid:R,validComputed:t.readonly(J),reason:t.readonly(oe),validationMessage:t.readonly(y),spanDays:t.readonly(X),month1:t.readonly(o),day1:t.readonly(i),year1:t.readonly($),month2:t.readonly(q),day2:t.readonly(H),year2:t.readonly(z),handleChange:a,handleKeyDown:g,handleWheel:V,handleKeyUp:K,handleClick:p,handleBlur:_,handleClear:ae,onCalendarChange:()=>{L.value=!0},initStyling:Z}}function Ue(e){const n=t.ref(""),s=t.ref(void 0),U=t.ref(!!e.debug),L=t.ref(e.timeFormat??"hh:mm AM"),C=t.computed(()=>!!e.required),O=t.ref(!1),x=["ArrowUp","ArrowDown"],A=["ArrowLeft","ArrowRight"],D=t.computed(()=>(n.value??"").replace(/\D/g,"")),w={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},I=o=>o<=2?"hh":o<=5?"mm":"ampm",E=t.computed(()=>{const o=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0",i=parseInt(o);return Math.min(Math.max(i,0),23)}),v=t.computed(()=>{const o=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0",i=parseInt(o);return Math.min(Math.max(i,0),59)}),M=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),P=t.computed(()=>{const o=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),i=M.value;return o===12?i==="AM"?0:12:i==="PM"?o+12:o}),f=t.computed(()=>S.value?`${String(P.value).padStart(2,"0")}:${String(v.value).padStart(2,"0")}:00`:null),S=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),R=(o,i,$)=>{let q=o%12;return q===0&&(q=12),`${String(q).padStart(2,"0")}:${String(i).padStart(2,"0")} ${$}`},j=o=>{const i=o.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!i)return null;const $=parseInt(i[1]),q=parseInt(i[2]),H=i[3].toUpperCase();if($<1||$>12||q<0||q>59)return null;let z=$%12;H==="PM"&&(z+=12);const B=new Date;return B.setSeconds(0,0),B.setHours(z),B.setMinutes(q),B},W=o=>{if(D.value.length===0){e.onChange({value:null,event:o});return}if(!S.value){e.onChange({value:null,event:o});return}const i=j(n.value);i&&J(i)?e.onChange({value:i,event:o}):e.onChange({value:null,event:o})},X=o=>o.getHours()*60+o.getMinutes(),J=o=>{const i=e.min??void 0,$=e.max??void 0,q=X(o);if(i){const H=X(i);if(q<H)return!1}if($){const H=X($);if(q>H)return!1}return!0},oe=o=>{const i=o.getHours(),$=i>=12?"PM":"AM";n.value=R(i,o.getMinutes(),$)},l=(o,i)=>{e.onChange({value:o,event:i})},y=()=>{t.nextTick(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const o=document.getElementById(e.id);if(o){o.focus();const i=(o.value??"").length;o.setSelectionRange(i,i)}})})})},u=o=>{const i=o?.event?.target;return i?i.closest(".k-time-now")?"now":i.closest(".k-time-accept")?"set":null:null},d=(o,i)=>{o&&J(o)?l(o,i):l(null,i)},b=(...o)=>{const i=o[0];if(!i)return;const $=u(i);if($==="now"){const H=new Date;oe(H),d(H,i),y();return}if(i?.value instanceof Date){const H=new Date(i.value);oe(H),d(H,i),$==="set"&&y();return}if(i?.value===null){n.value="",l(null,i);return}n.value=i.value;const q=i.event?.target;s.value=q?.selectionStart??0;try{const H=s.value??0;if(I(H)==="ampm"&&(n.value??"").length>=8){const z=n.value.charAt(6);/[Aa]/.test(z)?(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(z)&&(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(i)},m=o=>{s.value=o.target.selectionStart??0},k=(o,i,$)=>{const q=i?.selectionStart??s.value??0;s.value=q;const H=I(q),z=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!z){if((n.value??"").length===0||D.value.length===0){const c=new Date,h=c.getHours(),T=h>=12?"PM":"AM";n.value=R(h,c.getMinutes(),T);const Q=j(n.value);d(Q,$),t.nextTick(()=>{requestAnimationFrame(()=>{const ee=document.getElementById(e.id),ie=s.value??0;ee&&(ee.focus(),ee.setSelectionRange(ie,ie))})})}return}let B=parseInt(z[1]),Z=parseInt(z[2]),me=z[3].toUpperCase();if(H==="hh")o==="ArrowUp"?B=B<12?B+1:1:B=B>1?B-1:12;else if(H==="mm"){const c=e.minuteStepRef?.value??e.minuteStep??1;if(c===1)o==="ArrowUp"?Z=Z<59?Z+1:0:Z=Z>0?Z-1:59;else if(o==="ArrowUp"){const h=Z%c;let T=h===0?Z+c:Z+(c-h);T>=60&&(T=0),Z=T}else{const h=Z%c;let T=h===0?Z-c:Z-h;T<0&&(T=60-c),Z=T}}else H==="ampm"&&(me=me==="AM"?"PM":"AM");n.value=`${String(B).padStart(2,"0")}:${String(Z).padStart(2,"0")} ${me}`;const r=j(n.value);d(r,$),t.nextTick(()=>{requestAnimationFrame(()=>{const c=document.getElementById(e.id),h=s.value??0;c&&(c.focus(),c.setSelectionRange(h,h))})})},F=o=>{if(o.code==="Space"||o.key===" "){o.preventDefault(),o.stopPropagation(),e.onShowPicker(o);return}if(o.key==="ArrowDown"&&o.altKey){o.preventDefault(),o.stopPropagation(),e.onShowPicker(o);return}if(x.includes(o.key)){if(o.altKey)return;o.preventDefault(),o.stopPropagation();const i=o.target;k(o.key,i,o);return}},G=o=>{o.preventDefault();const i=o.deltaY<0?"ArrowUp":"ArrowDown";k(i,o.target,o)},a=o=>{const i=o.target;if(A.includes(o.key)){s.value=i?.selectionStart??0;return}if(x.includes(o.key)){if(o.altKey)return;s.value=i?.selectionStart??0}},p=o=>{O.value=!0,C.value&&e.externalValue&&e.externalValue.value===void 0&&D.value.length===0&&(e.externalValue.value="");const i=o.target;i&&(s.value=i.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const i=new Date(o);if(i.toString()!=="Invalid Date"){const $=i.getHours(),q=$>=12?"PM":"AM";n.value=R($,i.getMinutes(),q);return}}},{immediate:!0});const g=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",E.value],["Hour (24h)",P.value],["Minute",v.value],["Period",M.value],["Time (24h)",f.value??"--:--:--"],["Digits only",D.value],["Parsed Date",V.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",N.value],["validationMessage",_.value]]),V=t.computed(()=>j(n.value)??null),K=t.computed(()=>{if(!C.value){if(!S.value)return!0;const i=V.value;return i?J(i):!1}if(!O.value)return!0;const o=V.value;return!S.value||!o?!1:J(o)}),N=t.computed(()=>{if(!C.value){if(!S.value)return;const i=V.value;return i?J(i)?"valid":"out-of-bounds":"invalid-time"}if(!O.value)return;if(D.value.length===0||!S.value)return"incomplete";const o=V.value;return o?J(o)?"valid":"out-of-bounds":"invalid-time"}),_=t.computed(()=>{const o=N.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-time")return`Must be in ${L.value} format.`;const i={hour:"2-digit",minute:"2-digit"},$=e.min?e.min.toLocaleTimeString("en-US",i):null,q=e.max?e.max.toLocaleTimeString("en-US",i):null;if(o==="out-of-bounds"){if($&&q)return`Must be between ${$} and ${q}.`;if($)return`Must be ${$} or later.`;if(q)return`Must be ${q} or earlier.`}return""}),ae=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`#${e.id} not found for styling.`);return}const i=o.closest(".k-timepicker");if(!i){console.warn(`.k-timepicker parent of #${e.id} not found for styling.`);return}const $=i.parentElement;if(!$){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}$.classList.contains("fk-timepicker")||$.classList.add("fk-timepicker")})};return t.onMounted(()=>{ae()}),{raw:n,rules:w,debugEnabled:U,debugLines:g,placeholder:L,isValid:K,reason:t.readonly(N),validationMessage:_,isComplete:S,inRangeTime:J,cursorPos:s,hour:t.readonly(E),hour24:t.readonly(P),minute:t.readonly(v),period:t.readonly(M),time24:t.readonly(f),parsedRawTime:t.readonly(V),handleChange:b,handleKeyDown:F,handleKeyUp:a,handleClick:m,handleWheel:G,handleBlur:p,initStyling:ae}}function Oe(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}const Ae=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Be=Object.prototype.toString,Ke=e=>Be.call(e)==="[object Object]",ue=()=>{},Ne=He();function He(){var e,n;return Ae&&((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 Ye(e,n,s){return t.watch(e,n,{...s,immediate:!0})}const xe=Ae?window:void 0;function pe(e){var n;const s=t.toValue(e);return(n=s?.$el)!=null?n:s}function ve(...e){const n=[],s=()=>{n.forEach(x=>x()),n.length=0},U=(x,A,D,w)=>(x.addEventListener(A,D,w),()=>x.removeEventListener(A,D,w)),L=t.computed(()=>{const x=he(t.toValue(e[0])).filter(A=>A!=null);return x.every(A=>typeof A!="string")?x:void 0}),C=Ye(()=>{var x,A;return[(A=(x=L.value)==null?void 0:x.map(D=>pe(D)))!=null?A:[xe].filter(D=>D!=null),he(t.toValue(L.value?e[1]:e[0])),he(t.unref(L.value?e[2]:e[1])),t.toValue(L.value?e[3]:e[2])]},([x,A,D,w])=>{if(s(),!x?.length||!A?.length||!D?.length)return;const I=Ke(w)?{...w}:w;n.push(...x.flatMap(E=>A.flatMap(v=>D.map(M=>U(E,v,M,I)))))},{flush:"post"}),O=()=>{C(),s()};return Oe(s),O}let Ee=!1;function Ge(e,n,s={}){const{window:U=xe,ignore:L=[],capture:C=!0,detectIframe:O=!1,controls:x=!1}=s;if(!U)return x?{stop:ue,cancel:ue,trigger:ue}:ue;if(Ne&&!Ee){Ee=!0;const f={passive:!0};Array.from(U.document.body.children).forEach(S=>S.addEventListener("click",ue,f)),U.document.documentElement.addEventListener("click",ue,f)}let A=!0;const D=f=>t.toValue(L).some(S=>{if(typeof S=="string")return Array.from(U.document.querySelectorAll(S)).some(R=>R===f.target||f.composedPath().includes(R));{const R=pe(S);return R&&(f.target===R||f.composedPath().includes(R))}});function w(f){const S=t.toValue(f);return S&&S.$.subTree.shapeFlag===16}function I(f,S){const R=t.toValue(f),j=R.$.subTree&&R.$.subTree.children;return j==null||!Array.isArray(j)?!1:j.some(W=>W.el===S.target||S.composedPath().includes(W.el))}const E=f=>{const S=pe(e);if(f.target!=null&&!(!(S instanceof Element)&&w(e)&&I(e,f))&&!(!S||S===f.target||f.composedPath().includes(S))){if("detail"in f&&f.detail===0&&(A=!D(f)),!A){A=!0;return}n(f)}};let v=!1;const M=[ve(U,"click",f=>{v||(v=!0,setTimeout(()=>{v=!1},0),E(f))},{passive:!0,capture:C}),ve(U,"pointerdown",f=>{const S=pe(e);A=!D(f)&&!!(S&&!f.composedPath().includes(S))},{passive:!0}),O&&ve(U,"blur",f=>{setTimeout(()=>{var S;const R=pe(e);((S=U.document.activeElement)==null?void 0:S.tagName)==="IFRAME"&&!R?.contains(U.document.activeElement)&&n(f)},0)},{passive:!0})].filter(Boolean),P=()=>M.forEach(f=>f());return x?{stop:P,cancel:()=>{A=!1},trigger:f=>{A=!0,E(f),A=!1}}:P}function je(e){const n=t.shallowRef(null),s=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],U=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??s].flat(),L=w=>w?typeof e.initialFocus=="string"?w.querySelector(e.initialFocus)??w:typeof e.initialFocus=="function"?e.initialFocus(w)??w:w.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??w:null,{activate:C,deactivate:O}=Me.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>L(n.value),...e.focusTrapOptions??{}});let x=null,A=t.ref(null);const D=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const w=(E,v)=>{const M=Array.from(E.querySelectorAll(v));if(!M.length)return null;const P=M.filter(f=>f.offsetParent!==null||f.getClientRects().length>0);return P[P.length-1]??M[M.length-1]??null},I=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const E of U){const v=w(I,E);if(v)return v}for(const E of U){const v=w(document,E);if(v)return v}return null};return Ge(n,w=>{A.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",w)}),t.watch(()=>e.isOpen.value,w=>{w?(A.value=null,t.nextTick(()=>{const I=D();I&&(n.value=I,setTimeout(()=>C(),0),x||(x=E=>{E.key==="Escape"&&(A.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",E))},document.addEventListener("keydown",x,!0)))})):(O(),x&&(document.removeEventListener("keydown",x,!0),x=null),n.value=null,A.value==="outside"&&t.nextTick(()=>{const I=()=>{const E=e.triggerEl?.value,v=E?.querySelector("input"),M=document.activeElement;M&&(M===v||E&&E.contains(M))&&(v??E)?.blur?.()};requestAnimationFrame(()=>setTimeout(I,0))}),e.returnFocusToTrigger!==!1&&A.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const I=()=>{const E=e.triggerEl?.value;if(!E)return;(E.querySelector("input")??E)?.focus?.()};requestAnimationFrame(()=>setTimeout(I,0))})))}),{popupRef:n,activate:C,deactivate:O,lastCloseReason:t.readonly(A),setPopupEl:w=>n.value=w}}te.useGridA11y=Te,te.useGridActiveFilter=Ie,te.useMaskedDateInput=qe,te.useMaskedDateRangeInput=Ve,te.useMaskedTimeInput=Ue,te.usePopupTrap=je,te.useZipTextBox=Fe,Object.defineProperty(te,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 $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"})}));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useFieldsetTouchTracker } from "./useFieldsetTouchTracker";
|
|
2
|
+
export type { UseFieldsetTouchTrackerOptions, UseFieldsetTouchTrackerApi, } from "./useFieldsetTouchTracker";
|
|
3
|
+
export { useFieldsetValidationKit } from "./useFieldsetValidationKit";
|
|
4
|
+
export type { UseFieldsetValidationKitOptions, UseFieldsetValidationKitApi, } from "./useFieldsetValidationKit";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
export interface UseFieldsetTouchTrackerOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Function that returns whether the fieldset is valid.
|
|
5
|
+
*/
|
|
6
|
+
isValid: () => boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface UseFieldsetTouchTrackerApi {
|
|
9
|
+
touched: Ref<boolean>;
|
|
10
|
+
onFocusout: (event: FocusEvent) => void;
|
|
11
|
+
reset: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function useFieldsetTouchTracker(fieldsetRef: Ref<HTMLFieldSetElement | null>, options: UseFieldsetTouchTrackerOptions): UseFieldsetTouchTrackerApi;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type ComputedRef, type MaybeRefOrGetter, type Ref } from "vue";
|
|
2
|
+
export interface UseFieldsetValidationKitOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Consumer-owned submit state. The kit reads this value but never mutates it.
|
|
5
|
+
*/
|
|
6
|
+
submitted: MaybeRefOrGetter<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the real validity of the fieldset when validation is active.
|
|
9
|
+
*/
|
|
10
|
+
isValid: () => boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* API returned by {@link useFieldsetValidationKit}.
|
|
14
|
+
*/
|
|
15
|
+
export interface UseFieldsetValidationKitApi {
|
|
16
|
+
/**
|
|
17
|
+
* Becomes true after the first focus transition that leaves the fieldset.
|
|
18
|
+
*/
|
|
19
|
+
touched: Ref<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Delayed validation gate. True when either submitted or touched is true.
|
|
22
|
+
*/
|
|
23
|
+
fieldsetValidate: ComputedRef<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Forwards fieldset focusout events to the internal touch tracker.
|
|
26
|
+
*/
|
|
27
|
+
onFocusout: (event: FocusEvent) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Clears touched state and suppresses one immediate post-reset focusout.
|
|
30
|
+
*
|
|
31
|
+
* This avoids re-activating delayed validation from reset-related focus
|
|
32
|
+
* transitions (for example, clicking Reset while an input is focused).
|
|
33
|
+
*/
|
|
34
|
+
reset: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Wraps a field-level validity source with delayed validation behavior.
|
|
37
|
+
*/
|
|
38
|
+
createFieldValidity: (isValid: MaybeRefOrGetter<boolean>) => ComputedRef<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Builds a named map of delayed field validity refs for ergonomic form setup.
|
|
41
|
+
*/
|
|
42
|
+
createFieldValidationsMap: <T extends Record<string, MaybeRefOrGetter<boolean>>>(isValidMap: T) => {
|
|
43
|
+
[K in keyof T]: ComputedRef<boolean>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Moves focus to the first invalid Kendo control found within the provided form.
|
|
47
|
+
*/
|
|
48
|
+
focusFirstInvalidField: (formRef: MaybeRefOrGetter<HTMLFormElement | null>) => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Orchestrates delayed fieldset validation using submit state and touch state.
|
|
52
|
+
*
|
|
53
|
+
* Intended as the primary form-level API for gated validity UX:
|
|
54
|
+
* - validation displays after submit or first fieldset exit
|
|
55
|
+
* - field-level validity can be composed through helper factories
|
|
56
|
+
* - invalid focus and reset behavior are handled consistently
|
|
57
|
+
*
|
|
58
|
+
* @param fieldsetRef Reference to the fieldset whose focus transitions are tracked.
|
|
59
|
+
* @param options Consumer-provided submit state and base validity function.
|
|
60
|
+
* @returns Validation kit API for wiring fieldset-level and field-level behavior.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useFieldsetValidationKit(fieldsetRef: Ref<HTMLFieldSetElement | null>, options: UseFieldsetValidationKitOptions): UseFieldsetValidationKitApi;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# useUSAddress
|
|
2
|
+
|
|
3
|
+
[← Back to Composables README](https://github.com/NantHealth/featherk/blob/integration/packages/composables/README.md)
|
|
4
|
+
|
|
5
|
+
Composable that orchestrates a full US address form experience for Kendo Vue inputs.
|
|
6
|
+
|
|
7
|
+
`useUSAddress` composes:
|
|
8
|
+
|
|
9
|
+
- `useFieldsetValidationKit` for delayed validation (`submitted || touched`)
|
|
10
|
+
- `useZipTextBox` for dynamic ZIP/ZIP+4 formatting and validity
|
|
11
|
+
- internal field/state handlers for address lines, city, and state
|
|
12
|
+
|
|
13
|
+
It returns field bindings, delayed validity refs, submit/reset actions, and a normalized payload.
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
- Vue 3 Composition API
|
|
18
|
+
- Kendo Vue form inputs (`TextBox`, `DropDownList`)
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { ref } from "vue";
|
|
24
|
+
import { useUSAddress } from "@featherk/composables/address";
|
|
25
|
+
|
|
26
|
+
const formRef = ref<HTMLFormElement | null>(null);
|
|
27
|
+
const fieldsetRef = ref<HTMLFieldSetElement | null>(null);
|
|
28
|
+
|
|
29
|
+
const address = useUSAddress({
|
|
30
|
+
formRef,
|
|
31
|
+
fieldsetRef,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
async function onSubmit() {
|
|
35
|
+
const result = await address.submit();
|
|
36
|
+
|
|
37
|
+
if (!result.isValid) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Normalized payload safe for transport
|
|
42
|
+
console.log(result.payload);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function onReset() {
|
|
46
|
+
address.reset();
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Payload
|
|
51
|
+
|
|
52
|
+
`submit()` returns a normalized payload when valid:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
export interface USAddressSubmitPayload {
|
|
56
|
+
address1: string;
|
|
57
|
+
address2: string;
|
|
58
|
+
city: string;
|
|
59
|
+
state: string; // upper-cased
|
|
60
|
+
zip: string; // digits only
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Normalization rules:
|
|
65
|
+
|
|
66
|
+
- trims whitespace for `address1`, `address2`, and `city`
|
|
67
|
+
- upper-cases `state`
|
|
68
|
+
- strips non-digits from `zip`
|
|
69
|
+
|
|
70
|
+
## Returned API (high level)
|
|
71
|
+
|
|
72
|
+
State and bindings:
|
|
73
|
+
|
|
74
|
+
- `formData`
|
|
75
|
+
- `zipDisplay`
|
|
76
|
+
- `zipWrapperClass`
|
|
77
|
+
- `stateOptions`
|
|
78
|
+
- `stateDefaultItem`
|
|
79
|
+
|
|
80
|
+
Validation:
|
|
81
|
+
|
|
82
|
+
- `addressValidate`
|
|
83
|
+
- `address1Valid`, `cityValid`, `stateValid`, `zipValid`, `addressValid`
|
|
84
|
+
- `touched`
|
|
85
|
+
|
|
86
|
+
Handlers:
|
|
87
|
+
|
|
88
|
+
- `onAddress1Input`, `onAddress2Input`, `onCityInput`, `onStateChange`, `onZipInput`
|
|
89
|
+
- `onFieldsetFocusout`
|
|
90
|
+
|
|
91
|
+
Actions:
|
|
92
|
+
|
|
93
|
+
- `submit()`
|
|
94
|
+
- `reset()`
|
|
95
|
+
|
|
96
|
+
## Behavior Notes
|
|
97
|
+
|
|
98
|
+
- Delayed validation is inactive until submit or fieldset touch.
|
|
99
|
+
- Invalid submit focuses the first invalid Kendo control in the form.
|
|
100
|
+
- Reset clears submit/touch state and field values.
|
|
101
|
+
- ZIP behavior remains delegated to `useZipTextBox`.
|
|
@@ -6,6 +6,10 @@ Composable for a multi-mask ZIP code input that pairs with the Kendo Vue `TextBo
|
|
|
6
6
|
|
|
7
7
|
Kendo Vue's `MaskedTextBox` does not handle dynamic mask switching between a 5-digit and 9-digit ZIP format gracefully. This composable solves that by managing formatting, validation state, and payload construction explicitly — leaving the `TextBox` as a simple controlled input.
|
|
8
8
|
|
|
9
|
+
## Related
|
|
10
|
+
|
|
11
|
+
- Looking for a full address form orchestration composable? See [`useUSAddress`](https://github.com/NantHealth/featherk/blob/integration/packages/composables/docs/address/useUSAddress.md).
|
|
12
|
+
|
|
9
13
|
## Prerequisites
|
|
10
14
|
|
|
11
15
|
- Vue 3 Composition API
|
|
@@ -152,4 +156,4 @@ When the user types into the middle of the value, `handleZipInput` captures the
|
|
|
152
156
|
## Notes
|
|
153
157
|
|
|
154
158
|
- The composable does **not** emit intermediate states. `buildPayload()` always returns raw digits regardless of validity; you control whether to use it by checking the return value of `submitAndValidate()`.
|
|
155
|
-
- This composable is a building block for
|
|
159
|
+
- This composable is a building block for `useUSAddress`, which composes `useZipTextBox` alongside address line, city, and state field handlers.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# useFieldsetTouchTracker
|
|
2
|
+
|
|
3
|
+
[← Back to Composables README](https://github.com/NantHealth/featherk/blob/integration/packages/composables/README.md)
|
|
4
|
+
|
|
5
|
+
Low-level composable that tracks when focus leaves a fieldset and synchronizes the fieldset `aria-invalid` attribute from a provided validity function.
|
|
6
|
+
|
|
7
|
+
This is a primitive used by `useFieldsetValidationKit`. Most app-level form workflows should use the kit first and only use this composable directly for custom orchestration.
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
- Vue 3 Composition API
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { ref } from "vue";
|
|
18
|
+
import { useFieldsetTouchTracker } from "@featherk/composables/form";
|
|
19
|
+
|
|
20
|
+
const fieldsetRef = ref<HTMLFieldSetElement | null>(null);
|
|
21
|
+
const isValid = ref(false);
|
|
22
|
+
|
|
23
|
+
const { touched, onFocusout, reset } = useFieldsetTouchTracker(fieldsetRef, {
|
|
24
|
+
isValid: () => isValid.value,
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<fieldset ref="fieldsetRef" @focusout="onFocusout">
|
|
30
|
+
<!-- fields -->
|
|
31
|
+
</fieldset>
|
|
32
|
+
|
|
33
|
+
<button type="button" @click="reset">Reset Touch State</button>
|
|
34
|
+
<p>Touched: {{ touched }}</p>
|
|
35
|
+
</template>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
### useFieldsetTouchTracker(fieldsetRef, options)
|
|
41
|
+
|
|
42
|
+
Tracks focus transitions for one fieldset.
|
|
43
|
+
|
|
44
|
+
#### Parameters
|
|
45
|
+
|
|
46
|
+
| Parameter | Type | Description |
|
|
47
|
+
|----------|------|-------------|
|
|
48
|
+
| `fieldsetRef` | `Ref<HTMLFieldSetElement \| null>` | Ref for the target fieldset. |
|
|
49
|
+
| `options.isValid` | `() => boolean` | Current validity function used to set `aria-invalid`. |
|
|
50
|
+
|
|
51
|
+
#### Returns
|
|
52
|
+
|
|
53
|
+
| Property | Type | Description |
|
|
54
|
+
|----------|------|-------------|
|
|
55
|
+
| `touched` | `Ref<boolean>` | Becomes `true` after a focus transition that leaves the fieldset. |
|
|
56
|
+
| `onFocusout` | `(event: FocusEvent) => void` | Focusout handler to bind on the fieldset. |
|
|
57
|
+
| `reset` | `() => void` | Sets `touched` back to `false`. |
|
|
58
|
+
|
|
59
|
+
## Behavior Notes
|
|
60
|
+
|
|
61
|
+
- `aria-invalid` is kept in sync with `!options.isValid()` via `watchEffect`.
|
|
62
|
+
- A focusout counts as "leaving" when the next focused element (`event.relatedTarget`) is not inside the fieldset.
|
|
63
|
+
- If `fieldsetRef.value` is `null`, the handler falls back to `event.currentTarget`.
|
|
64
|
+
|
|
65
|
+
## When to Use vs Validation Kit
|
|
66
|
+
|
|
67
|
+
Use `useFieldsetTouchTracker` when you want full control over delayed validation behavior.
|
|
68
|
+
|
|
69
|
+
Use `useFieldsetValidationKit` when you want:
|
|
70
|
+
|
|
71
|
+
- submit-or-touch gating (`submitted || touched`)
|
|
72
|
+
- delayed field-validity helpers
|
|
73
|
+
- focus-first-invalid helper
|
|
74
|
+
- reset handling for post-reset focus churn
|