@featherk/composables 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(Q,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vueuse/integrations/useFocusTrap")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/integrations/useFocusTrap"],t):(Q=typeof globalThis<"u"?globalThis:Q||self,t(Q.FeatherKComposables={},Q.Vue,Q.useFocusTrap))})(this,(function(Q,t,we){"use strict";const ke=e=>{const r=t.ref(null);let f=!1,q=null,F=null;const V=[],N=".k-table-row[data-grid-row-index] [tabindex]",E=()=>e?.value?.columns,D=l=>{const d=l.key||l.code;[" ","Spacebar","Space","Enter"].includes(d)&&(l.preventDefault(),l.stopPropagation(),r.value=l.target,l.target.click())},v=l=>{if(!r.value)return;if(l.code==="Escape"){l.preventDefault(),l.stopPropagation(),r.value&&r.value.focus();return}const d=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),i=document.querySelector(".k-filter-menu-container");if(i){if(l.code==="Tab"){const s=[".k-filter-menu-container .k-dropdownlist[tabindex='0']",".k-filter-menu-container input.k-input-inner:not([tabindex='-1']):not([disabled])",".k-filter-menu-container button:not([tabindex='-1']):not([disabled])"],p=Array.from(i.querySelectorAll(s.join(",")));if(p.length===0)return;const M=p.findIndex(P=>P===document.activeElement);let k;M===-1?k=0:l.shiftKey?k=(M-1+p.length)%p.length:k=(M+1)%p.length,l.preventDefault(),l.stopPropagation(),p[k]?.focus();return}}else if(l.code==="ArrowUp"||l.code==="ArrowDown"){l.preventDefault(),l.stopPropagation();const s=d.findIndex(M=>M===document.activeElement);let p=s;l.code==="ArrowUp"?p=s>0?s-1:d.length-1:l.code==="ArrowDown"&&(p=s<d.length-1?s+1:0),d[p]?.focus();return}l.code==="Tab"&&(l.preventDefault(),l.stopPropagation(),l.shiftKey?(r.value?.previousElementSibling).focus():(r.value?.nextElementSibling).focus())},A=()=>{q=new MutationObserver(l=>{l.forEach(d=>{d.addedNodes.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const s=i;if(s.classList.contains("k-animation-container")){const M=r.value;M&&(M.dataset.featherKSortable==="true"||t.nextTick(()=>{s.querySelectorAll(".k-columnmenu-item-wrapper").forEach(H=>{H.textContent?.toLowerCase().includes("sort")&&H.remove()})})),s.addEventListener("keydown",v),t.nextTick(()=>{const k=()=>{const P=Array.from(s.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"));if(P.length===1)P[0].focus(),P[0].click(),k.attempts=0;else if(P.length>1){k.attempts=0;return}else k.attempts===void 0&&(k.attempts=0),k.attempts++<3&&setTimeout(k,200)};k()})}s.querySelectorAll(".k-animation-container").forEach(M=>{M.addEventListener("keydown",v)})}}),d.removedNodes.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const s=i;s.classList.contains("k-animation-container")&&s.removeEventListener("keydown",v),s.querySelectorAll(".k-animation-container").forEach(M=>{M.removeEventListener("keydown",v)})}})})}),q.observe(document.body,{childList:!0,subtree:!0})},$=l=>{if(!l.type||!l)return;const d=l.target;if(d){if(l.code==="Escape"){const i=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(i){l.preventDefault(),l.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(p=>p.setAttribute("tabindex","-1"))}catch{}i.setAttribute("tabindex","0"),i.focus();return}}if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter","Space"].includes(l.code)){if(l.preventDefault(),d.classList.contains("k-grid-header-menu")&&d.classList.contains("k-grid-column-menu")){r.value=d;return}const i=d.closest(".k-table-row[data-grid-row-index]");if(i){if(["ArrowDown","ArrowUp"].includes(l.code)){const s=(M,k)=>{let P=k==="next"?M.nextElementSibling:M.previousElementSibling;for(;P;){const H=P;try{if(H.hasAttribute&&H.classList.contains("k-table-row"))return H}catch{}P=k==="next"?P.nextElementSibling:P.previousElementSibling}return null},p=l.code==="ArrowDown"?s(i,"next"):s(i,"previous");p&&(i.setAttribute("tabindex","-1"),p.setAttribute("tabindex","0"),p.focus());return}if(["ArrowLeft","ArrowRight"].includes(l.code)){l.preventDefault();const s=i.querySelectorAll(N);if(s.length===0)return;let p=Array.from(s).findIndex(M=>M===document.activeElement);if(p===-1&&document.activeElement===i){s[0].focus();return}l.code==="ArrowRight"?p=p===s.length-1?0:p+1:l.code==="ArrowLeft"&&(p=p===s.length-1?p-1:s.length-1),s[p].focus();return}}}}},x=()=>{t.nextTick(()=>{const l=e.value.$el.closest(".k-grid");l&&l.classList.add("fk-grid")})},w=()=>{if(!F)try{const l=()=>{try{const s=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!s||s.length===0||s.filter(k=>k.getAttribute("tabindex")==="0").length===1)return;const M=s.find(k=>k===document.activeElement||k.contains(document.activeElement));if(s.forEach(k=>k.setAttribute("tabindex","-1")),M){M.setAttribute("tabindex","0");return}s[0].setAttribute("tabindex","0")}catch(s){console.error("ensureSingleTabindex error:",s)}},d=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));d.length>0&&d.forEach((s,p)=>{s.setAttribute("tabindex",p===0?"0":"-1")});const i=e.value.$el.querySelector(".k-table-tbody");i&&(F=new MutationObserver(()=>{l()}),F.observe(i,{childList:!0,subtree:!0}))}catch(l){console.error("Error setting up row navigation:",l)}},L=()=>{t.nextTick(()=>{const d=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");d&&d.forEach(i=>{i.setAttribute("role","button"),i.addEventListener("keydown",D)}),A(),m()})},C=()=>{const d=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");d&&d.forEach(i=>{i.removeEventListener("keydown",D)}),q&&(q.disconnect(),q=null),F&&(F.disconnect(),F=null),V.forEach(i=>i()),V.length=0},m=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((i,s)=>{const p=i.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!p)return;const M=E();if(M&&M[s]){const K=M[s].field??"";i.setAttribute("data-feather-k-field",K),i.setAttribute("data-feather-k-filterable",M[s].filterable===!1?"false":"true"),i.setAttribute("data-feather-k-sortable",M[s].sortable===!1?"false":"true")}const k=i.dataset.featherKFilterable!=="false",P=i.dataset.featherKSortable!=="false";p.setAttribute("tabindex","-1"),k||P?i.style.cursor="pointer":i.style.cursor="default",k?(i.setAttribute("tabindex","0"),i.setAttribute("role","button"),i.setAttribute("aria-haspopup","menu")):(i.setAttribute("tabindex","0"),i.setAttribute("role","columnheader"),i.removeAttribute("aria-haspopup"));const H=K=>{K.target?.closest(".k-column-resizer")||(r.value=i,p.click())},G=K=>{if(k)r.value=i,K.preventDefault(),K.stopPropagation(),H(K);else if(P){r.value=i;const Z=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0});i.dispatchEvent(Z)}};i.addEventListener("click",G),V.push(()=>{i.removeEventListener("click",G)});const X=K=>{if((K.code==="Enter"||K.code==="Space")&&(k||P)){if(r.value=i,r.value.focus(),k)K.preventDefault(),K.stopPropagation(),H(K);else if(P){const Z=i.querySelector(".k-link");Z&&Z.click()}}};i.addEventListener("keydown",X,!0),V.push(()=>{i.removeEventListener("keydown",X,!0)})});const d=document.querySelector(".k-grid-header .k-table-thead");if(d){const i=s=>{const p=s.target.closest("th");p&&(s.code==="Enter"||s.code==="Space")&&p.dataset.featherKFilterable==="false"&&p.dataset.featherKSortable==="false"&&(s.preventDefault(),s.stopImmediatePropagation())};d.addEventListener("keydown",i,!0),V.push(()=>{d.removeEventListener("keydown",i,!0)})}},S=function(l,d){const i=l?.event.event.target,s=E();if(!i||!s)return;const p=i.classList.contains("k-link"),M=i.classList.contains("k-columnmenu-item"),k=s.find(P=>P.field===l.event.field)?.sortable&&!0;if(!p){if(M&&!k){(l.event.sort&&void 0)?.filter(H=>H.field!==l.event.field);return}typeof d=="function"&&t.nextTick(()=>{r.value&&r.value.focus(),d(l)})}},O=()=>{if(!f)try{x(),w(),L(),f=!0}catch(l){console.error("initA11y failed:",l),C()}};return t.onBeforeUnmount(()=>{C()}),{activeFilterButton:r,handleGridKeyDown:$,handleSortChange:S,initA11y:O}};function De(e){const r=t.ref(""),f=t.ref(void 0),q=t.ref(!!e.debug),F=t.ref(e.dateFormat??"mm/dd/yyyy"),V=t.computed(()=>!!e.required),N=t.ref(!1),E=["ArrowUp","ArrowDown"],D=["ArrowLeft","ArrowRight"],v=t.computed(()=>(r.value??"").replace(/\D/g,"")),A=a=>a<=2?"mm":a<=5?"dd":v.value.length<=10?"yyyy":"mm",$=t.computed(()=>{const a=r.value&&r.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(2,"0")}),x=t.computed(()=>{const a=r.value&&r.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(2,"0")}),w=t.computed(()=>{const a=r.value&&r.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(4,"0")}),L=a=>{if(v.value.length===0){e.onChange({value:null,event:a});return}if(v.value.length<8){e.onChange({value:null,event:a});return}if((r.value??"").length===10&&v.value.length===8){const[y,o,u]=r.value.split("/"),g=parseInt(y),h=parseInt(o),T=parseInt(u);if(l(T,g,h)){const _=new Date(T,g-1,h);C(_)?e.onChange({value:_,event:a}):e.onChange({value:null,event:a})}else e.onChange({value:null,event:a})}},C=a=>{const y=e.min??void 0,o=e.max??void 0;return!(y&&a<y||o&&a>o)},m=t.computed(()=>{if((r.value??"").length===10&&v.value.length===8){const[a,y,o]=(r.value??"").split("/"),u=parseInt(a),g=parseInt(y),h=parseInt(o);if(l(h,u,g))return new Date(h,u-1,g)}return null}),S=t.computed(()=>(r.value??"").length===10&&v.value.length===8),O=(a,y)=>new Date(a,y,0).getDate(),l=(a,y,o)=>y>=1&&y<=12&&a>=1900&&o>=1&&o<=O(a,y),d=a=>{r.value=a.value;const y=a.event?.target;f.value=y?.selectionStart??0,L(a)},i=a=>{f.value=a.target.selectionStart??0},s=(a,y,o)=>{const u=y?.selectionStart??f.value??0;f.value=u;let g=parseInt($.value),h=parseInt(x.value),T=parseInt(w.value);if(!(v.value.length>=8)||!l(T,g,h)){const R=e.defaultValue??new Date;g=R.getMonth()+1,h=R.getDate(),T=R.getFullYear(),r.value=`${String(g).padStart(2,"0")}/${String(h).padStart(2,"0")}/${String(T)}`;const n=new Date(T,g-1,h);e.onChange({value:C(n)?n:null,event:o}),t.nextTick(()=>{requestAnimationFrame(()=>{const c=document.getElementById(e.id),b=f.value??0;c&&(c.focus(),c.setSelectionRange(b,b))})});return}const W=A(u);if(W==="mm")g=a==="ArrowUp"?g<12?g+1:1:g>1?g-1:12;else if(W==="dd"){const R=new Date(T,g,0).getDate();h=a==="ArrowUp"?h<R?h+1:1:h>1?h-1:R}else W==="yyyy"&&(T=a==="ArrowUp"?T+1:Math.max(1,T-1));r.value=`${String(g).padStart(2,"0")}/${String(h).padStart(2,"0")}/${String(T)}`;const[B,ne,re]=r.value.split("/"),Y=new Date(parseInt(re),parseInt(B)-1,parseInt(ne));Y.toString()!=="Invalid Date"&&parseInt(re)>=1e3?e.onChange({value:C(Y)?Y:null,event:o}):e.onChange({value:null,event:o}),t.nextTick(()=>{requestAnimationFrame(()=>{const R=document.getElementById(e.id),n=f.value??0;R&&(R.focus(),R.setSelectionRange(n,n))})})},p=a=>{if(a.code==="Space"||a.key===" "){e.onShowCalendar(a);return}if(E.includes(a.key)){a.preventDefault();const y=a.target;s(a.key,y,a)}},M=a=>{a.preventDefault();const y=a.deltaY<0?"ArrowUp":"ArrowDown";s(y,a.target,a)},k=a=>{const y=a.target;if(D.includes(a.key)){f.value=y?.selectionStart??0;return}E.includes(a.key)&&(a.preventDefault(),f.value=y?.selectionStart??0)},P=a=>{N.value=!0,V.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&v.value.length===0&&(e.externalValue.value="");const y=a.target;y&&(f.value=y.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,a=>{if(a){const y=new Date(a);if(y.toString()!=="Invalid Date"){const o=(y.getMonth()+1).toString().padStart(2,"0"),u=y.getDate().toString().padStart(2,"0"),g=y.getFullYear().toString();r.value=`${o}/${u}/${g}`;return}}},{immediate:!0});const H=t.computed(()=>[["Date",`${$.value} / ${x.value} / ${w.value}`],["Digits only",v.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]]),G=t.computed(()=>{if(!V.value){if(!S.value)return!0;const y=m.value;return y?C(y):!1}if(!N.value)return!0;const a=m.value;return!S.value||!a?!1:C(a)}),X=t.computed(()=>{if(!V.value){if(!S.value)return;const y=m.value;return y?C(y)?"valid":"out-of-bounds":"invalid-date"}if(!N.value)return;if(v.value.length===0||!S.value)return"incomplete";const a=m.value;return a?C(a)?"valid":"out-of-bounds":"invalid-date"}),K=t.computed(()=>{const a=X.value;if(!a||a==="valid")return"";if(a==="incomplete")return"Required";if(a==="invalid-date")return`Must be in ${F.value} format.`;const y=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,o=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(a==="out-of-bounds"){if(y&&o)return`Must be between ${y} and ${o}.`;if(y)return`Must be on or after ${y}.`;if(o)return`Must be on or before ${o}.`}return""}),Z=()=>{t.nextTick(()=>{const a=document.getElementById(e.id);if(!a){console.warn(`ID (#${e.id}) not found for styling.`);return}const y=a.closest(".k-datepicker");if(y)y.classList.add("fk-datepicker");else{console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}})};return t.onMounted(()=>{Z()}),{raw:r,cursorPos:f,debugEnabled:q,debugLines:H,placeholder:F,isValid:G,reason:t.readonly(X),validationMessage:K,digitsOnly:v,month:t.readonly($),day:t.readonly(x),year:t.readonly(w),datePart:A,handleChange:d,handleKeyDown:p,handleWheel:M,handleKeyUp:k,handleClick:i,handleBlur:P}}function Ae(e){const r=t.ref(""),f=t.ref(void 0),q=t.ref(!!e.debug),F=t.ref(!1),N=365*(1440*60*1e3),E=new Date,D=new Date(E.getTime()-N),v=new Date(E.getTime()+N);e.min=e.min??D,e.max=e.max??v;const A=t.computed(()=>(r.value??"").replace(/\D/g,"")),$=(n,c)=>new Date(n,c,0).getDate(),x=(n,c,b)=>c>=1&&c<=12&&n>=1e3&&b>=1&&b<=$(n,c),w=n=>Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()),L=n=>{if(!n)return null;const c=e.min,b=e.max,I=w(n);return I<w(c)||I>w(b)?null:n},C=(n,c)=>e.allowReverse??!1?!0:n<=c,m=t.computed(()=>(r.value?.length??0)>=23&&A.value.length>=16),S=n=>{if((n??"").length<23||A.value.length<16)return{start:null,end:null};const c=n.substring(0,10),b=n.substring(13,23),[I,j,ee]=c.split("/").map(oe=>parseInt(oe||"0",10)),[ce,le,ie]=b.split("/").map(oe=>parseInt(oe||"0",10)),se=new Date(ee,I-1,j),de=new Date(ie,ce-1,le),ye=x(ee,I,j)&&se.toString()!=="Invalid Date",ge=x(ie,ce,le)&&de.toString()!=="Invalid Date";return{start:ye?se:null,end:ge?de:null}},O=e.externalValid??t.ref(void 0),l=t.computed(()=>S(r.value)),d=t.computed(()=>{const n=L(l.value.start),c=L(l.value.end);return{start:n,end:c}}),i=t.computed(()=>{if(!m.value)return;const n=d.value.start,c=d.value.end;if(!n||!c)return;const b=j=>Date.UTC(j.getFullYear(),j.getMonth(),j.getDate()),I=Math.abs(b(c)-b(n));return Math.round(I/864e5)}),s=t.computed(()=>{const{start:n,end:c}=l.value;if(!m.value)return;if(!n||!c||!d.value.start||!d.value.end)return!1;const b=d.value.start,I=d.value.end;return!(!C(b,I)||typeof e.maxSpanDays=="number"&&i.value!==void 0&&i.value>e.maxSpanDays)}),p=t.computed(()=>{const{start:n,end:c}=l.value;if(!m.value)return"incomplete";if(!n||!c)return"invalid-date";if(!d.value.start||!d.value.end)return"out-of-bounds";const b=d.value.start,I=d.value.end;return C(b,I)?typeof e.maxSpanDays=="number"&&i.value!==void 0&&i.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),M=t.computed(()=>{const{start:n,end:c}=l.value,{min:b,max:I}=e;switch(console.table({start:n,end:c,min:b,max:I}),p.value){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 n&&c&&(w(n)<w(b)||w(c)<w(b)||w(n)>w(I)||w(c)>w(I))?`Dates must be between ${G(b)} and ${G(I)}.`:"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.";case"valid":default:return""}});t.watch(s,n=>{(e.manageValid??!0)&&(O.value=n)},{immediate:!0});const k=["ArrowUp","ArrowDown"],P=["ArrowLeft","ArrowRight"],H=(n,c)=>String(n).padStart(c,"0"),G=n=>`${H(n.getMonth()+1,2)}/${H(n.getDate(),2)}/${H(n.getFullYear(),4)}`,X=n=>n<=2?{side:"start",part:"mm"}:n<=5?{side:"start",part:(n<=3,"dd")}:n<=11?{side:"start",part:"yyyy"}:n<=15?{side:"end",part:"mm"}:n<=18?{side:"end",part:"dd"}:{side:"end",part:"yyyy"},K=(n,c,b)=>{const I=c?.selectionStart??f.value??0;f.value=I;const{start:j,end:ee}=S(r.value);if(!j&&!ee){const U=new Date,te=G(U);r.value=`${te} - ${te}`,e.onChange({value:{start:U,end:U},event:b}),t.nextTick(()=>{requestAnimationFrame(()=>{const z=document.getElementById(e.id),J=f.value??0;z&&(z.focus(),z.setSelectionRange(J,J))})});return}const ce=new Date,le=X(I);let ie=j?new Date(j):new Date(ce),se=ee?new Date(ee):new Date(ce);const de=(U,te)=>{if(te==="mm"){const z=U.getMonth()+1,J=n==="ArrowUp"?z<12?z+1:1:z>1?z-1:12;U.setMonth(J-1);const fe=$(U.getFullYear(),J);U.getDate()>fe&&U.setDate(fe)}else if(te==="dd"){const z=$(U.getFullYear(),U.getMonth()+1),J=U.getDate(),fe=n==="ArrowUp"?J<z?J+1:1:J>1?J-1:z;U.setDate(fe)}else if(te==="yyyy"){const z=U.getFullYear();U.setFullYear(n==="ArrowUp"?z+1:Math.max(1,z-1));const J=$(U.getFullYear(),U.getMonth()+1);U.getDate()>J&&U.setDate(J)}};le.side==="start"?de(ie,le.part):de(se,le.part);const ye=G(ie),ge=G(se);r.value=`${ye} - ${ge}`;const oe=L(ie),he=L(se);oe&&he&&C(oe,he)?e.onChange({value:{start:oe,end:he},event:b}):e.onChange({value:null,event:b}),t.nextTick(()=>{requestAnimationFrame(()=>{const U=document.getElementById(e.id),te=f.value??0;U&&(U.focus(),U.setSelectionRange(te,te))})})},Z=n=>{const{start:c,end:b}=S(r.value);if(!c||!b){e.onChange({value:null,event:n});return}const I=L(c),j=L(b);if(!I||!j){e.onChange({value:null,event:n});return}if(!C(I,j)){e.onChange({value:null,event:n});return}e.onChange({value:{start:I,end:j},event:n})},a=n=>{r.value=n.value;const c=n.event?.target;f.value=c?.selectionStart??0,Z(n)},y=n=>{f.value=n.target.selectionStart??0},o=n=>{if(n.code==="Space"||n.key===" "){n.preventDefault(),e.onShowCalendar(n);return}if(n.key==="ArrowDown"&&n.altKey){n.preventDefault(),e.onShowCalendar(n);return}if(k.includes(n.key)){n.preventDefault();const c=n.target;K(n.key,c,n)}},u=n=>{n.preventDefault();const c=n.deltaY<0?"ArrowUp":"ArrowDown";K(c,n.target,n)},g=n=>{if(P.includes(n.key)||k.includes(n.key)){n.preventDefault();const c=n.target;f.value=c?.selectionStart??0}};e.externalValue&&t.watch(e.externalValue,n=>{const c=n?.start??null,b=n?.end??null;if(c&&b){if(r.value=`${G(c)} - ${G(b)}`,e.isOpen?.value&&F.value&&e.onRequestClose){const I=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),F.value=!1},I)}return}},{immediate:!0});const h=t.computed(()=>r.value&&r.value.substring(0,2).replace(/\D/g,"0")||"0"),T=t.computed(()=>r.value&&r.value.substring(3,5).replace(/\D/g,"0")||"0"),_=t.computed(()=>r.value&&r.value.substring(6,10).replace(/\D/g,"0")||"0"),W=t.computed(()=>r.value&&r.value.substring(13,15).replace(/\D/g,"0")||"0"),B=t.computed(()=>r.value&&r.value.substring(16,18).replace(/\D/g,"0")||"0"),ne=t.computed(()=>r.value&&r.value.substring(19,23).replace(/\D/g,"0")||"0"),re=t.computed(()=>{const{start:n,end:c}=S(r.value);return[{label:"Raw",value:r.value},{label:"Min Date",value:`${e.min?e.min.toDateString():"-"}`},{label:"Max Date",value:`${e.max?e.max.toDateString():"-"}`},{label:"Start",value:`${String(h.value).padStart(2,"0")} / ${String(T.value).padStart(2,"0")} / ${String(_.value).padStart(4,"0")}`},{label:"End",value:`${String(W.value).padStart(2,"0")} / ${String(B.value).padStart(2,"0")} / ${String(ne.value).padStart(4,"0")}`},{label:"Digits only",value:A.value},{label:"Mask complete",value:`${m.value}`},{label:"Parsed",value:`${n?n.toDateString():"-"} | ${c?c.toDateString():"-"}`},{label:"Valid (managed)",value:`${O.value??"-"}`},{label:"Span (days)",value:`${i.value??"-"}`},{label:"Reason",value:`${p.value??"-"}`},{label:"Cursor in",value:`${f.value??"-"} (${(()=>{const b=f.value??0,I=X(b);return`${I.side}.${I.part}`})()})`}]}),Y=()=>{t.nextTick(()=>{const n=document.getElementById(e.id);if(!n){console.warn(`#${e.id} not found for styling.`);return}const c=n.closest("div");c?c.classList.add("fk-daterangepicker"):console.warn(`Parent div of #${e.id} not found for styling.`)})};t.onMounted(()=>{Y()});const R=()=>{t.nextTick(()=>{try{const n=Array.from(document.querySelectorAll(".k-animation-container"));if(!n.length)return;const b=[...n].reverse().find(ee=>ee.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!b)return;const I=b.querySelectorAll(".k-calendar-table");let j=!1;I.forEach(ee=>{ee.tabIndex===0&&(j?ee.tabIndex=-1:j=!0)})}catch(n){console.warn(n)}})};return e.isOpen&&t.watch(e.isOpen,n=>{n&&setTimeout(()=>R(),0)},{immediate:!1}),{raw:r,cursorPos:f,debugEnabled:q,debugLines:re,digitsOnly:A,valid:O,validComputed:t.readonly(s),reason:t.readonly(p),validationMessage:t.readonly(M),spanDays:t.readonly(i),month1:t.readonly(h),day1:t.readonly(T),year1:t.readonly(_),month2:t.readonly(W),day2:t.readonly(B),year2:t.readonly(ne),handleChange:a,handleKeyDown:o,handleWheel:u,handleKeyUp:g,handleClick:y,onCalendarChange:()=>{F.value=!0}}}function Ee(e){const r=t.ref(""),f=t.ref(void 0),q=t.ref(!!e.debug),F=t.ref(e.timeFormat??"hh:mm AM"),V=t.computed(()=>!!e.required),N=t.ref(!1),E=["ArrowUp","ArrowDown"],D=["ArrowLeft","ArrowRight"],v=t.computed(()=>(r.value??"").replace(/\D/g,"")),A={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},$=o=>o<=2?"hh":o<=5?"mm":"ampm",x=t.computed(()=>{const o=r.value&&r.value.substring(0,2).replace(/\D/g,"0")||"0",u=parseInt(o);return Math.min(Math.max(u,0),23)}),w=t.computed(()=>{const o=r.value&&r.value.substring(3,5).replace(/\D/g,"0")||"0",u=parseInt(o);return Math.min(Math.max(u,0),59)}),L=t.computed(()=>(r.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),C=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(r.value??"")),m=(o,u,g)=>{let h=o%12;return h===0&&(h=12),`${String(h).padStart(2,"0")}:${String(u).padStart(2,"0")} ${g}`},S=o=>{const u=o.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!u)return null;const g=parseInt(u[1]),h=parseInt(u[2]),T=u[3].toUpperCase();if(g<1||g>12||h<0||h>59)return null;let _=g%12;T==="PM"&&(_+=12);const W=new Date;return W.setSeconds(0,0),W.setHours(_),W.setMinutes(h),W},O=o=>{if(v.value.length===0){e.onChange({value:null,event:o});return}if(!C.value){e.onChange({value:null,event:o});return}const u=S(r.value);u&&d(u)?e.onChange({value:u,event:o}):e.onChange({value:null,event:o})},l=o=>o.getHours()*60+o.getMinutes(),d=o=>{const u=e.min??void 0,g=e.max??void 0,h=l(o);if(u){const T=l(u);if(h<T)return!1}if(g){const T=l(g);if(h>T)return!1}return!0},i=o=>{r.value=o.value;const u=o.event?.target;f.value=u?.selectionStart??0;try{const g=f.value??0;if($(g)==="ampm"&&(r.value??"").length>=8){const h=r.value.charAt(6);/[Aa]/.test(h)?(r.value=`${r.value.slice(0,6)}AM${r.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const T=document.getElementById(e.id);T&&(T.focus(),T.setSelectionRange(8,8))})})):/[Pp]/.test(h)&&(r.value=`${r.value.slice(0,6)}PM${r.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const T=document.getElementById(e.id);T&&(T.focus(),T.setSelectionRange(8,8))})}))}}catch{}O(o)},s=o=>{f.value=o.target.selectionStart??0},p=(o,u,g)=>{const h=u?.selectionStart??f.value??0;f.value=h;const T=$(h),_=(r.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!_){if((r.value??"").length===0||v.value.length===0){const Y=new Date,R=Y.getHours(),n=R>=12?"PM":"AM";r.value=m(R,Y.getMinutes(),n);const c=S(r.value);c&&d(c)?e.onChange({value:c,event:g}):e.onChange({value:null,event:g}),t.nextTick(()=>{requestAnimationFrame(()=>{const b=document.getElementById(e.id),I=f.value??0;b&&(b.focus(),b.setSelectionRange(I,I))})})}return}let W=parseInt(_[1]),B=parseInt(_[2]),ne=_[3].toUpperCase();if(T==="hh")o==="ArrowUp"?W=W<12?W+1:1:W=W>1?W-1:12;else if(T==="mm"){const Y=e.minuteStepRef?.value??e.minuteStep??1;if(Y===1)o==="ArrowUp"?B=B<59?B+1:0:B=B>0?B-1:59;else if(o==="ArrowUp"){const R=B%Y;let n=R===0?B+Y:B+(Y-R);n>=60&&(n=0),B=n}else{const R=B%Y;let n=R===0?B-Y:B-R;n<0&&(n=60-Y),B=n}}else T==="ampm"&&(ne=ne==="AM"?"PM":"AM");r.value=`${String(W).padStart(2,"0")}:${String(B).padStart(2,"0")} ${ne}`;const re=S(r.value);re&&d(re)?e.onChange({value:re,event:g}):e.onChange({value:null,event:g}),t.nextTick(()=>{requestAnimationFrame(()=>{const Y=document.getElementById(e.id),R=f.value??0;Y&&(Y.focus(),Y.setSelectionRange(R,R))})})},M=o=>{if(o.code==="Space"||o.key===" "){e.onShowPicker(o);return}if(E.includes(o.key)){o.preventDefault();const u=o.target;p(o.key,u,o)}},k=o=>{o.preventDefault();const u=o.deltaY<0?"ArrowUp":"ArrowDown";p(u,o.target,o)},P=o=>{const u=o.target;if(D.includes(o.key)){f.value=u?.selectionStart??0;return}E.includes(o.key)&&(o.preventDefault(),f.value=u?.selectionStart??0)},H=o=>{N.value=!0,V.value&&e.externalValue&&e.externalValue.value===void 0&&v.value.length===0&&(e.externalValue.value="");const u=o.target;u&&(f.value=u.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const u=new Date(o);if(u.toString()!=="Invalid Date"){const g=u.getHours(),h=g>=12?"PM":"AM";r.value=m(g,u.getMinutes(),h);return}}},{immediate:!0});const G=t.computed(()=>[["Time",r.value||"--:-- --"],["Hour (12h)",x.value],["Minute",w.value],["Period",L.value],["Digits only",v.value],["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",Z.value],["validationMessage",a.value]]),X=t.computed(()=>S(r.value)??null),K=t.computed(()=>{if(!V.value){if(!C.value)return!0;const u=X.value;return u?d(u):!1}if(!N.value)return!0;const o=X.value;return!C.value||!o?!1:d(o)}),Z=t.computed(()=>{if(!V.value){if(!C.value)return;const u=X.value;return u?d(u)?"valid":"out-of-bounds":"invalid-time"}if(!N.value)return;if(v.value.length===0||!C.value)return"incomplete";const o=X.value;return o?d(o)?"valid":"out-of-bounds":"invalid-time"}),a=t.computed(()=>{const o=Z.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-time")return`Must be in ${F.value} format.`;const u={hour:"2-digit",minute:"2-digit"},g=e.min?e.min.toLocaleTimeString("en-US",u):null,h=e.max?e.max.toLocaleTimeString("en-US",u):null;if(o==="out-of-bounds"){if(g&&h)return`Must be between ${g} and ${h}.`;if(g)return`Must be ${g} or later.`;if(h)return`Must be ${h} or earlier.`}return""}),y=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`#${e.id} not found for styling.`);return}const u=o.closest(".k-timepicker");u?u.classList.add("fk-timepicker"):console.warn(`.k-timepicker parent of #${e.id} not found for styling.`)})};return t.onMounted(()=>{y()}),{raw:r,rules:A,debugEnabled:q,debugLines:G,placeholder:F,isValid:K,reason:t.readonly(Z),validationMessage:a,isComplete:C,inRangeTime:d,cursorPos:f,hour:t.readonly(x),minute:t.readonly(w),period:t.readonly(L),handleChange:i,handleKeyDown:M,handleKeyUp:P,handleClick:s,handleWheel:k,handleBlur:H}}function xe(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}const ve=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Me=Object.prototype.toString,Te=e=>Me.call(e)==="[object Object]",ae=()=>{},Ie=Ce();function Ce(){var e,r;return ve&&((e=window?.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((r=window?.navigator)==null?void 0:r.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function me(e){return Array.isArray(e)?e:[e]}function $e(e,r,f){return t.watch(e,r,{...f,immediate:!0})}const be=ve?window:void 0;function ue(e){var r;const f=t.toValue(e);return(r=f?.$el)!=null?r:f}function pe(...e){const r=[],f=()=>{r.forEach(E=>E()),r.length=0},q=(E,D,v,A)=>(E.addEventListener(D,v,A),()=>E.removeEventListener(D,v,A)),F=t.computed(()=>{const E=me(t.toValue(e[0])).filter(D=>D!=null);return E.every(D=>typeof D!="string")?E:void 0}),V=$e(()=>{var E,D;return[(D=(E=F.value)==null?void 0:E.map(v=>ue(v)))!=null?D:[be].filter(v=>v!=null),me(t.toValue(F.value?e[1]:e[0])),me(t.unref(F.value?e[2]:e[1])),t.toValue(F.value?e[3]:e[2])]},([E,D,v,A])=>{if(f(),!E?.length||!D?.length||!v?.length)return;const $=Te(A)?{...A}:A;r.push(...E.flatMap(x=>D.flatMap(w=>v.map(L=>q(x,w,L,$)))))},{flush:"post"}),N=()=>{V(),f()};return xe(f),N}let Se=!1;function Le(e,r,f={}){const{window:q=be,ignore:F=[],capture:V=!0,detectIframe:N=!1,controls:E=!1}=f;if(!q)return E?{stop:ae,cancel:ae,trigger:ae}:ae;if(Ie&&!Se){Se=!0;const m={passive:!0};Array.from(q.document.body.children).forEach(S=>S.addEventListener("click",ae,m)),q.document.documentElement.addEventListener("click",ae,m)}let D=!0;const v=m=>t.toValue(F).some(S=>{if(typeof S=="string")return Array.from(q.document.querySelectorAll(S)).some(O=>O===m.target||m.composedPath().includes(O));{const O=ue(S);return O&&(m.target===O||m.composedPath().includes(O))}});function A(m){const S=t.toValue(m);return S&&S.$.subTree.shapeFlag===16}function $(m,S){const O=t.toValue(m),l=O.$.subTree&&O.$.subTree.children;return l==null||!Array.isArray(l)?!1:l.some(d=>d.el===S.target||S.composedPath().includes(d.el))}const x=m=>{const S=ue(e);if(m.target!=null&&!(!(S instanceof Element)&&A(e)&&$(e,m))&&!(!S||S===m.target||m.composedPath().includes(S))){if("detail"in m&&m.detail===0&&(D=!v(m)),!D){D=!0;return}r(m)}};let w=!1;const L=[pe(q,"click",m=>{w||(w=!0,setTimeout(()=>{w=!1},0),x(m))},{passive:!0,capture:V}),pe(q,"pointerdown",m=>{const S=ue(e);D=!v(m)&&!!(S&&!m.composedPath().includes(S))},{passive:!0}),N&&pe(q,"blur",m=>{setTimeout(()=>{var S;const O=ue(e);((S=q.document.activeElement)==null?void 0:S.tagName)==="IFRAME"&&!O?.contains(q.document.activeElement)&&r(m)},0)},{passive:!0})].filter(Boolean),C=()=>L.forEach(m=>m());return E?{stop:C,cancel:()=>{D=!1},trigger:m=>{D=!0,x(m),D=!1}}:C}function Pe(e){const r=t.shallowRef(null),f=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],q=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??f].flat(),F=A=>A?typeof e.initialFocus=="string"?A.querySelector(e.initialFocus)??A:typeof e.initialFocus=="function"?e.initialFocus(A)??A:A.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??A:null,{activate:V,deactivate:N}=we.useFocusTrap(r,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>r.value,initialFocus:()=>F(r.value),...e.focusTrapOptions??{}});let E=null,D=t.ref(null);const v=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const A=(x,w)=>{const L=Array.from(x.querySelectorAll(w));if(!L.length)return null;const C=L.filter(m=>m.offsetParent!==null||m.getClientRects().length>0);return C[C.length-1]??L[L.length-1]??null},$=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const x of q){const w=A($,x);if(w)return w}for(const x of q){const w=A(document,x);if(w)return w}return null};return Le(r,A=>{D.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",A)}),t.watch(()=>e.isOpen.value,A=>{A?(D.value=null,t.nextTick(()=>{const $=v();$&&(r.value=$,setTimeout(()=>V(),0),E||(E=x=>{x.key==="Escape"&&(D.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",x))},document.addEventListener("keydown",E,!0)))})):(N(),E&&(document.removeEventListener("keydown",E,!0),E=null),r.value=null,D.value==="outside"&&t.nextTick(()=>{const $=()=>{const x=e.triggerEl?.value,w=x?.querySelector("input"),L=document.activeElement;L&&(L===w||x&&x.contains(L))&&(w??x)?.blur?.()};requestAnimationFrame(()=>setTimeout($,0))}),e.returnFocusToTrigger!==!1&&D.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const $=()=>{const x=e.triggerEl?.value;if(!x)return;(x.querySelector("input")??x)?.focus?.()};requestAnimationFrame(()=>setTimeout($,0))})))}),{popupRef:r,activate:V,deactivate:N,lastCloseReason:t.readonly(D),setPopupEl:A=>r.value=A}}Q.useGridA11y=ke,Q.useMaskedDateInput=De,Q.useMaskedDateRangeInput=Ae,Q.useMaskedTimeInput=Ee,Q.usePopupTrap=Pe,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
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,Ee){"use strict";const xe=e=>{const n=t.ref(null);let d=!1,P=null,L=null;const B=[],N=".k-table-row[data-grid-row-index] [tabindex]",k=()=>e?.value?.columns,b=l=>{const p=l.key||l.code;[" ","Spacebar","Space","Enter"].includes(p)&&(l.preventDefault(),l.stopPropagation(),n.value=l.target,l.target.click())},v=l=>{if(!n.value)return;if(l.code==="Escape"){l.preventDefault(),l.stopPropagation(),n.value&&n.value.focus();return}const p=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),i=document.querySelector(".k-filter-menu-container");if(i){if(l.code==="Tab"){const s=[".k-filter-menu-container .k-dropdownlist[tabindex='0']",".k-filter-menu-container input.k-input-inner:not([tabindex='-1']):not([disabled])",".k-filter-menu-container button:not([tabindex='-1']):not([disabled])"],y=Array.from(i.querySelectorAll(s.join(",")));if(y.length===0)return;const A=y.findIndex($=>$===document.activeElement);let S;A===-1?S=0:l.shiftKey?S=(A-1+y.length)%y.length:S=(A+1)%y.length,l.preventDefault(),l.stopPropagation(),y[S]?.focus();return}}else if(l.code==="ArrowUp"||l.code==="ArrowDown"){l.preventDefault(),l.stopPropagation();const s=p.findIndex(A=>A===document.activeElement);let y=s;l.code==="ArrowUp"?y=s>0?s-1:p.length-1:l.code==="ArrowDown"&&(y=s<p.length-1?s+1:0),p[y]?.focus();return}l.code==="Tab"&&(l.preventDefault(),l.stopPropagation(),l.shiftKey?(n.value?.previousElementSibling).focus():(n.value?.nextElementSibling).focus())},w=()=>{P=new MutationObserver(l=>{l.forEach(p=>{p.addedNodes.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const s=i;if(s.classList.contains("k-animation-container")){const A=n.value;A&&(A.dataset.featherKSortable==="true"||t.nextTick(()=>{s.querySelectorAll(".k-columnmenu-item-wrapper").forEach(H=>{H.textContent?.toLowerCase().includes("sort")&&H.remove()})})),s.addEventListener("keydown",v),t.nextTick(()=>{const S=()=>{const $=Array.from(s.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"));if($.length===1)$[0].focus(),$[0].click(),S.attempts=0;else if($.length>1){S.attempts=0;return}else S.attempts===void 0&&(S.attempts=0),S.attempts++<3&&setTimeout(S,200)};S()})}s.querySelectorAll(".k-animation-container").forEach(A=>{A.addEventListener("keydown",v)})}}),p.removedNodes.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const s=i;s.classList.contains("k-animation-container")&&s.removeEventListener("keydown",v),s.querySelectorAll(".k-animation-container").forEach(A=>{A.removeEventListener("keydown",v)})}})})}),P.observe(document.body,{childList:!0,subtree:!0})},C=l=>{if(!l.type||!l)return;const p=l.target;if(p){if(l.code==="Escape"){const i=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(i){l.preventDefault(),l.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(y=>y.setAttribute("tabindex","-1"))}catch{}i.setAttribute("tabindex","0"),i.focus();return}}if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter","Space"].includes(l.code)){if(l.preventDefault(),p.classList.contains("k-grid-header-menu")&&p.classList.contains("k-grid-column-menu")){n.value=p;return}const i=p.closest(".k-table-row[data-grid-row-index]");if(i){if(["ArrowDown","ArrowUp"].includes(l.code)){const s=(A,S)=>{let $=S==="next"?A.nextElementSibling:A.previousElementSibling;for(;$;){const H=$;try{if(H.hasAttribute&&H.classList.contains("k-table-row"))return H}catch{}$=S==="next"?$.nextElementSibling:$.previousElementSibling}return null},y=l.code==="ArrowDown"?s(i,"next"):s(i,"previous");y&&(i.setAttribute("tabindex","-1"),y.setAttribute("tabindex","0"),y.focus());return}if(["ArrowLeft","ArrowRight"].includes(l.code)){l.preventDefault();const s=i.querySelectorAll(N);if(s.length===0)return;let y=Array.from(s).findIndex(A=>A===document.activeElement);if(y===-1&&document.activeElement===i){s[0].focus();return}l.code==="ArrowRight"?y=y===s.length-1?0:y+1:l.code==="ArrowLeft"&&(y=y===s.length-1?y-1:s.length-1),s[y].focus();return}}}}},D=()=>{t.nextTick(()=>{const l=e.value.$el.closest(".k-grid");l&&l.classList.add("fk-grid")})},x=()=>{if(!L)try{const l=()=>{try{const s=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!s||s.length===0||s.filter(S=>S.getAttribute("tabindex")==="0").length===1)return;const A=s.find(S=>S===document.activeElement||S.contains(document.activeElement));if(s.forEach(S=>S.setAttribute("tabindex","-1")),A){A.setAttribute("tabindex","0");return}s[0].setAttribute("tabindex","0")}catch(s){console.error("ensureSingleTabindex error:",s)}},p=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));p.length>0&&p.forEach((s,y)=>{s.setAttribute("tabindex",y===0?"0":"-1")});const i=e.value.$el.querySelector(".k-table-tbody");i&&(L=new MutationObserver(()=>{l()}),L.observe(i,{childList:!0,subtree:!0}))}catch(l){console.error("Error setting up row navigation:",l)}},T=()=>{t.nextTick(()=>{const p=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");p&&p.forEach(i=>{i.setAttribute("role","button"),i.addEventListener("keydown",b)}),w(),m()})},q=()=>{const p=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");p&&p.forEach(i=>{i.removeEventListener("keydown",b)}),P&&(P.disconnect(),P=null),L&&(L.disconnect(),L=null),B.forEach(i=>i()),B.length=0},m=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((i,s)=>{const y=i.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!y)return;const A=k();if(A&&A[s]){const Y=A[s].field??"";i.setAttribute("data-feather-k-field",Y),i.setAttribute("data-feather-k-filterable",A[s].filterable===!1?"false":"true"),i.setAttribute("data-feather-k-sortable",A[s].sortable===!1?"false":"true")}const S=i.dataset.featherKFilterable!=="false",$=i.dataset.featherKSortable!=="false";y.setAttribute("tabindex","-1"),S||$?i.style.cursor="pointer":i.style.cursor="default",S?(i.setAttribute("tabindex","0"),i.setAttribute("role","button"),i.setAttribute("aria-haspopup","menu")):(i.setAttribute("tabindex","0"),i.setAttribute("role","columnheader"),i.removeAttribute("aria-haspopup"));const H=Y=>{Y.target?.closest(".k-column-resizer")||(n.value=i,y.click())},re=Y=>{if(S)n.value=i,Y.preventDefault(),Y.stopPropagation(),H(Y);else if($){n.value=i;const _=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0});i.dispatchEvent(_)}};i.addEventListener("click",re),B.push(()=>{i.removeEventListener("click",re)});const z=Y=>{if((Y.code==="Enter"||Y.code==="Space")&&(S||$)){if(n.value=i,n.value.focus(),S)Y.preventDefault(),Y.stopPropagation(),H(Y);else if($){const _=i.querySelector(".k-link");_&&_.click()}}};i.addEventListener("keydown",z,!0),B.push(()=>{i.removeEventListener("keydown",z,!0)})});const p=document.querySelector(".k-grid-header .k-table-thead");if(p){const i=s=>{const y=s.target.closest("th");y&&(s.code==="Enter"||s.code==="Space")&&y.dataset.featherKFilterable==="false"&&y.dataset.featherKSortable==="false"&&(s.preventDefault(),s.stopImmediatePropagation())};p.addEventListener("keydown",i,!0),B.push(()=>{p.removeEventListener("keydown",i,!0)})}},h=function(l,p){const i=l?.event.event.target,s=k();if(!i||!s)return;const y=i.classList.contains("k-link"),A=i.classList.contains("k-columnmenu-item"),S=s.find($=>$.field===l.event.field)?.sortable&&!0;if(!y){if(A&&!S){(l.event.sort&&void 0)?.filter(H=>H.field!==l.event.field);return}typeof p=="function"&&t.nextTick(()=>{n.value&&n.value.focus(),p(l)})}},F=()=>{if(!d)try{D(),x(),T(),d=!0}catch(l){console.error("initA11y failed:",l),q()}};return t.onBeforeUnmount(()=>{q()}),{activeFilterButton:n,handleGridKeyDown:C,handleSortChange:h,initA11y:F}};function Me(e){const n=t.ref(""),d=t.ref(void 0),P=t.ref(!!e.debug),L=t.ref(e.dateFormat??"mm/dd/yyyy"),B=t.computed(()=>!!e.required),N=t.ref(!1),k=["ArrowUp","ArrowDown"],b=["ArrowLeft","ArrowRight"],v=t.computed(()=>(n.value??"").replace(/\D/g,"")),w=a=>a<=2?"mm":a<=5?"dd":v.value.length<=10?"yyyy":"mm",C=t.computed(()=>{const a=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(2,"0")}),D=t.computed(()=>{const a=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(2,"0")}),x=t.computed(()=>{const a=n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(4,"0")}),T=a=>{if(v.value.length===0){e.onChange({value:null,event:a});return}if(v.value.length<8){e.onChange({value:null,event:a});return}if((n.value??"").length===10&&v.value.length===8){const[f,I,Q]=n.value.split("/"),o=parseInt(f),u=parseInt(I),g=parseInt(Q);if(l(g,o,u)){const M=new Date(g,o-1,u);q(M)?e.onChange({value:M,event:a}):e.onChange({value:null,event:a})}else e.onChange({value:null,event:a})}},q=a=>{const f=e.min??void 0,I=e.max??void 0;return!(f&&a<f||I&&a>I)},m=t.computed(()=>{if((n.value??"").length===10&&v.value.length===8){const[a,f,I]=(n.value??"").split("/"),Q=parseInt(a),o=parseInt(f),u=parseInt(I);if(l(u,Q,o))return new Date(u,Q-1,o)}return null}),h=t.computed(()=>(n.value??"").length===10&&v.value.length===8),F=(a,f)=>new Date(a,f,0).getDate(),l=(a,f,I)=>f>=1&&f<=12&&a>=1900&&I>=1&&I<=F(a,f),p=a=>{n.value=a.value;const f=a.event?.target;d.value=f?.selectionStart??0,T(a)},i=a=>{d.value=a.target.selectionStart??0},s=(a,f,I)=>{const Q=f?.selectionStart??d.value??0;d.value=Q;let o=parseInt(C.value),u=parseInt(D.value),g=parseInt(x.value);if(!(v.value.length>=8)||!l(g,o,u)){const j=e.defaultValue??new Date;o=j.getMonth()+1,u=j.getDate(),g=j.getFullYear(),n.value=`${String(o).padStart(2,"0")}/${String(u).padStart(2,"0")}/${String(g)}`;const U=new Date(g,o-1,u);e.onChange({value:q(U)?U:null,event:I}),t.nextTick(()=>{requestAnimationFrame(()=>{const G=document.getElementById(e.id),X=d.value??0;G&&(G.focus(),G.setSelectionRange(X,X))})});return}const O=w(Q);if(O==="mm")o=a==="ArrowUp"?o<12?o+1:1:o>1?o-1:12;else if(O==="dd"){const j=new Date(g,o,0).getDate();u=a==="ArrowUp"?u<j?u+1:1:u>1?u-1:j}else O==="yyyy"&&(g=a==="ArrowUp"?g+1:Math.max(1,g-1));n.value=`${String(o).padStart(2,"0")}/${String(u).padStart(2,"0")}/${String(g)}`;const[ne,W,K]=n.value.split("/"),ae=new Date(parseInt(K),parseInt(ne)-1,parseInt(W));ae.toString()!=="Invalid Date"&&parseInt(K)>=1e3?e.onChange({value:q(ae)?ae:null,event:I}):e.onChange({value:null,event:I}),t.nextTick(()=>{requestAnimationFrame(()=>{const j=document.getElementById(e.id),U=d.value??0;j&&(j.focus(),j.setSelectionRange(U,U))})})},y=a=>{if(a.code==="Space"||a.key===" "){e.onShowCalendar(a);return}if(k.includes(a.key)){a.preventDefault();const f=a.target;s(a.key,f,a)}},A=a=>{a.preventDefault();const f=a.deltaY<0?"ArrowUp":"ArrowDown";s(f,a.target,a)},S=a=>{const f=a.target;if(b.includes(a.key)){d.value=f?.selectionStart??0;return}k.includes(a.key)&&(a.preventDefault(),d.value=f?.selectionStart??0)},$=a=>{N.value=!0,B.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&v.value.length===0&&(e.externalValue.value="");const f=a.target;f&&(d.value=f.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,a=>{if(a){const f=new Date(a);if(f.toString()!=="Invalid Date"){const I=(f.getMonth()+1).toString().padStart(2,"0"),Q=f.getDate().toString().padStart(2,"0"),o=f.getFullYear().toString();n.value=`${I}/${Q}/${o}`;return}}},{immediate:!0});const H=t.computed(()=>[["Date",`${C.value} / ${D.value} / ${x.value}`],["Digits only",v.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]]),re=t.computed(()=>{if(!B.value){if(!h.value)return!0;const f=m.value;return f?q(f):!1}if(!N.value)return!0;const a=m.value;return!h.value||!a?!1:q(a)}),z=t.computed(()=>{if(!B.value){if(!h.value)return;const f=m.value;return f?q(f)?"valid":"out-of-bounds":"invalid-date"}if(!N.value)return;if(v.value.length===0||!h.value)return"incomplete";const a=m.value;return a?q(a)?"valid":"out-of-bounds":"invalid-date"}),Y=t.computed(()=>{const a=z.value;if(!a||a==="valid")return"";if(a==="incomplete")return"Required";if(a==="invalid-date")return`Must be in ${L.value} format.`;const f=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,I=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(a==="out-of-bounds"){if(f&&I)return`Must be between ${f} and ${I}.`;if(f)return`Must be on or after ${f}.`;if(I)return`Must be on or before ${I}.`}return""}),_=()=>{t.nextTick(()=>{const a=document.getElementById(e.id);if(!a){console.warn(`ID (#${e.id}) not found for styling.`);return}const f=a.closest(".k-datepicker");if(f){const I=f.parentElement;I?I.classList.add("fk-datepicker"):console.warn(`Parent of .k-datepicker not found for #${e.id} styling.`)}else{console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}})};return t.onMounted(()=>{_()}),{raw:n,cursorPos:d,debugEnabled:P,debugLines:H,placeholder:L,isValid:re,reason:t.readonly(z),validationMessage:Y,digitsOnly:v,month:t.readonly(C),day:t.readonly(D),year:t.readonly(x),datePart:w,handleChange:p,handleKeyDown:y,handleWheel:A,handleKeyUp:S,handleClick:i,handleBlur:$}}function Te(e){const n=t.ref(""),d=t.ref(void 0),P=t.ref(!!e.debug),L=t.ref(!1),N=365*(1440*60*1e3),k=new Date,b=new Date(k.getTime()-N),v=new Date(k.getTime()+N);e.min=e.min??b,e.max=e.max??v;const w=t.computed(()=>(n.value??"").replace(/\D/g,"")),C=(r,c)=>new Date(r,c,0).getDate(),D=(r,c,E)=>c>=1&&c<=12&&r>=1e3&&E>=1&&E<=C(r,c),x=r=>Date.UTC(r.getFullYear(),r.getMonth(),r.getDate()),T=r=>{if(!r)return null;const c=e.min,E=e.max,R=x(r);return R<x(c)||R>x(E)?null:r},q=(r,c)=>e.allowReverse??!1?!0:r<=c,m=t.computed(()=>(n.value?.length??0)>=23&&w.value.length>=16),h=r=>{if((r??"").length<23||w.value.length<16)return{start:null,end:null};const c=r.substring(0,10),E=r.substring(13,23),[R,Z,oe]=c.split("/").map(ie=>parseInt(ie||"0",10)),[pe,ue,ce]=E.split("/").map(ie=>parseInt(ie||"0",10)),de=new Date(oe,R-1,Z),ye=new Date(ce,pe-1,ue),Se=D(oe,R,Z)&&de.toString()!=="Invalid Date",be=D(ce,pe,ue)&&ye.toString()!=="Invalid Date";return{start:Se?de:null,end:be?ye:null}},F=e.externalValid??t.ref(!0),l=t.computed(()=>h(n.value)),p=t.computed(()=>{const r=T(l.value.start),c=T(l.value.end);return{start:r,end:c}}),i=t.computed(()=>{if(!m.value)return;const r=p.value.start,c=p.value.end;if(!r||!c)return;const E=Math.abs(x(c)-x(r));return Math.round(E/864e5+1)}),s=t.computed(()=>{if(!m.value)return!1;const{start:r,end:c}=l.value;if(!r||!c||!p.value.start||!p.value.end)return!1;const E=p.value.start,R=p.value.end;return!(!q(E,R)||typeof e.maxSpanDays=="number"&&i.value!==void 0&&i.value>e.maxSpanDays)}),y=t.computed(()=>{const{start:r,end:c}=l.value;if(!m.value)return"incomplete";if(!r||!c)return"invalid-date";if(!p.value.start||!p.value.end)return"out-of-bounds";const E=p.value.start,R=p.value.end;return q(E,R)?typeof e.maxSpanDays=="number"&&i.value!==void 0&&i.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),A=t.ref(void 0),S=t.computed(()=>{if(F.value!==!1)return"";const{min:r,max:c}=e,E=A.value;if(!E)return"";switch(E){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 ${z(r)} and ${z(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.";case"valid":default:return""}}),$=["ArrowUp","ArrowDown"],H=["ArrowLeft","ArrowRight"],re=(r,c)=>String(r).padStart(c,"0"),z=r=>`${re(r.getMonth()+1,2)}/${re(r.getDate(),2)}/${re(r.getFullYear(),4)}`,Y=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"},_=(r,c,E)=>{const R=c?.selectionStart??d.value??0;d.value=R;const{start:Z,end:oe}=h(n.value);if(!Z&&!oe){const V=new Date,le=z(V);n.value=`${le} - ${le}`,e.onChange({value:{start:V,end:V},event:E}),t.nextTick(()=>{requestAnimationFrame(()=>{const J=document.getElementById(e.id),ee=d.value??0;J&&(J.focus(),J.setSelectionRange(ee,ee))})});return}const pe=new Date,ue=Y(R);let ce=Z?new Date(Z):new Date(pe),de=oe?new Date(oe):new Date(pe);const ye=(V,le)=>{if(le==="mm"){const J=V.getMonth()+1,ee=r==="ArrowUp"?J<12?J+1:1:J>1?J-1:12;V.setMonth(ee-1);const ge=C(V.getFullYear(),ee);V.getDate()>ge&&V.setDate(ge)}else if(le==="dd"){const J=C(V.getFullYear(),V.getMonth()+1),ee=V.getDate(),ge=r==="ArrowUp"?ee<J?ee+1:1:ee>1?ee-1:J;V.setDate(ge)}else if(le==="yyyy"){const J=V.getFullYear();V.setFullYear(r==="ArrowUp"?J+1:Math.max(1,J-1));const ee=C(V.getFullYear(),V.getMonth()+1);V.getDate()>ee&&V.setDate(ee)}};ue.side==="start"?ye(ce,ue.part):ye(de,ue.part);const Se=z(ce),be=z(de);n.value=`${Se} - ${be}`;const ie=T(ce),we=T(de);ie&&we&&q(ie,we)?e.onChange({value:{start:ie,end:we},event:E}):e.onChange({value:null,event:E}),t.nextTick(()=>{requestAnimationFrame(()=>{const V=document.getElementById(e.id),le=d.value??0;V&&(V.focus(),V.setSelectionRange(le,le))})})},a=r=>{const{start:c,end:E}=h(n.value);if(!c||!E){e.onChange({value:null,event:r});return}const R=T(c),Z=T(E);if(!R||!Z){e.onChange({value:null,event:r});return}if(!q(R,Z)){e.onChange({value:null,event:r});return}e.onChange({value:{start:R,end:Z},event:r})},f=r=>{const c=r.value??"",E=r.event;if(!c&&E&&E.type==="click"){O(E);return}n.value=c;const R=E?.target;d.value=R?.selectionStart??0,a(r)},I=r=>{d.value=r.target.selectionStart??0},Q=r=>{if(r.code==="Space"||r.key===" "){r.preventDefault(),e.onShowCalendar(r);return}if(r.key==="ArrowDown"&&r.altKey){r.preventDefault(),e.onShowCalendar(r);return}if($.includes(r.key)){r.preventDefault();const c=r.target;_(r.key,c,r)}},o=r=>{r.preventDefault();const c=r.deltaY<0?"ArrowUp":"ArrowDown";_(c,r.target,r)},u=r=>{if(H.includes(r.key)||$.includes(r.key)){r.preventDefault();const c=r.target;d.value=c?.selectionStart??0}},g=()=>{A.value=y.value,(e.manageValid??!0)&&(F.value=s.value)},M=r=>{g()},O=r=>{console.log("Clear event:",r),n.value="",d.value=0,e.onChange({value:null,event:r}),g(),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,E=r?.end??null;if(c&&E){if(n.value=`${z(c)} - ${z(E)}`,e.isOpen?.value&&L.value&&e.onRequestClose){const R=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),L.value=!1,g()},R)}return}},{immediate:!0});const ne=t.computed(()=>n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0"),W=t.computed(()=>n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0"),K=t.computed(()=>n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0"),ae=t.computed(()=>n.value&&n.value.substring(13,15).replace(/\D/g,"0")||"0"),j=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),U=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),G=t.computed(()=>{const{start:r,end:c}=h(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(ne.value).padStart(2,"0")} / ${String(W.value).padStart(2,"0")} / ${String(K.value).padStart(4,"0")}`},{label:"End",value:`${String(ae.value).padStart(2,"0")} / ${String(j.value).padStart(2,"0")} / ${String(U.value).padStart(4,"0")}`},{label:"Digits only",value:w.value},{label:"Mask complete",value:`${m.value}`},{label:"Parsed",value:`${r?r.toDateString():"-"} | ${c?c.toDateString():"-"}`},{label:"Valid (managed)",value:`${F.value??"-"}`},{label:"Span (days)",value:`${i.value??"-"}`},{label:"Reason",value:`${y.value??"-"}`},{label:"Cursor in",value:`${d.value??"-"} (${(()=>{const E=d.value??0,R=Y(E);return`${R.side}.${R.part}`})()})`}]}),X=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`#${e.id} not found for styling.`);return}const c=r.closest("div");c?c.classList.add("fk-daterangepicker"):console.warn(`Parent div of #${e.id} not found for styling.`)})};t.onMounted(()=>{X()});const me=()=>{t.nextTick(()=>{try{const r=Array.from(document.querySelectorAll(".k-animation-container"));if(!r.length)return;const E=[...r].reverse().find(oe=>oe.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!E)return;const R=E.querySelectorAll(".k-calendar-table");let Z=!1;R.forEach(oe=>{oe.tabIndex===0&&(Z?oe.tabIndex=-1:Z=!0)})}catch(r){console.warn(r)}})};return e.isOpen&&t.watch(e.isOpen,r=>{r&&setTimeout(()=>me(),0)},{immediate:!1}),{raw:n,cursorPos:d,debugEnabled:P,debugLines:G,digitsOnly:w,valid:F,validComputed:t.readonly(s),reason:t.readonly(y),validationMessage:t.readonly(S),spanDays:t.readonly(i),month1:t.readonly(ne),day1:t.readonly(W),year1:t.readonly(K),month2:t.readonly(ae),day2:t.readonly(j),year2:t.readonly(U),handleChange:f,handleKeyDown:Q,handleWheel:o,handleKeyUp:u,handleClick:I,handleBlur:M,handleClear:O,onCalendarChange:()=>{L.value=!0}}}function $e(e){const n=t.ref(""),d=t.ref(void 0),P=t.ref(!!e.debug),L=t.ref(e.timeFormat??"hh:mm AM"),B=t.computed(()=>!!e.required),N=t.ref(!1),k=["ArrowUp","ArrowDown"],b=["ArrowLeft","ArrowRight"],v=t.computed(()=>(n.value??"").replace(/\D/g,"")),w={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},C=o=>o<=2?"hh":o<=5?"mm":"ampm",D=t.computed(()=>{const o=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0",u=parseInt(o);return Math.min(Math.max(u,0),23)}),x=t.computed(()=>{const o=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0",u=parseInt(o);return Math.min(Math.max(u,0),59)}),T=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),q=t.computed(()=>{const o=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),u=T.value;return o===12?u==="AM"?0:12:u==="PM"?o+12:o}),m=t.computed(()=>h.value?`${String(q.value).padStart(2,"0")}:${String(x.value).padStart(2,"0")}:00`:null),h=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),F=(o,u,g)=>{let M=o%12;return M===0&&(M=12),`${String(M).padStart(2,"0")}:${String(u).padStart(2,"0")} ${g}`},l=o=>{const u=o.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!u)return null;const g=parseInt(u[1]),M=parseInt(u[2]),O=u[3].toUpperCase();if(g<1||g>12||M<0||M>59)return null;let ne=g%12;O==="PM"&&(ne+=12);const W=new Date;return W.setSeconds(0,0),W.setHours(ne),W.setMinutes(M),W},p=o=>{if(v.value.length===0){e.onChange({value:null,event:o});return}if(!h.value){e.onChange({value:null,event:o});return}const u=l(n.value);u&&s(u)?e.onChange({value:u,event:o}):e.onChange({value:null,event:o})},i=o=>o.getHours()*60+o.getMinutes(),s=o=>{const u=e.min??void 0,g=e.max??void 0,M=i(o);if(u){const O=i(u);if(M<O)return!1}if(g){const O=i(g);if(M>O)return!1}return!0},y=o=>{n.value=o.value;const u=o.event?.target;d.value=u?.selectionStart??0;try{const g=d.value??0;if(C(g)==="ampm"&&(n.value??"").length>=8){const M=n.value.charAt(6);/[Aa]/.test(M)?(n.value=`${n.value.slice(0,6)}AM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const O=document.getElementById(e.id);O&&(O.focus(),O.setSelectionRange(8,8))})})):/[Pp]/.test(M)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const O=document.getElementById(e.id);O&&(O.focus(),O.setSelectionRange(8,8))})}))}}catch{}p(o)},A=o=>{d.value=o.target.selectionStart??0},S=(o,u,g)=>{const M=u?.selectionStart??d.value??0;d.value=M;const O=C(M),ne=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!ne){if((n.value??"").length===0||v.value.length===0){const U=new Date,G=U.getHours(),X=G>=12?"PM":"AM";n.value=F(G,U.getMinutes(),X);const me=l(n.value);me&&s(me)?e.onChange({value:me,event:g}):e.onChange({value:null,event:g}),t.nextTick(()=>{requestAnimationFrame(()=>{const r=document.getElementById(e.id),c=d.value??0;r&&(r.focus(),r.setSelectionRange(c,c))})})}return}let W=parseInt(ne[1]),K=parseInt(ne[2]),ae=ne[3].toUpperCase();if(O==="hh")o==="ArrowUp"?W=W<12?W+1:1:W=W>1?W-1:12;else if(O==="mm"){const U=e.minuteStepRef?.value??e.minuteStep??1;if(U===1)o==="ArrowUp"?K=K<59?K+1:0:K=K>0?K-1:59;else if(o==="ArrowUp"){const G=K%U;let X=G===0?K+U:K+(U-G);X>=60&&(X=0),K=X}else{const G=K%U;let X=G===0?K-U:K-G;X<0&&(X=60-U),K=X}}else O==="ampm"&&(ae=ae==="AM"?"PM":"AM");n.value=`${String(W).padStart(2,"0")}:${String(K).padStart(2,"0")} ${ae}`;const j=l(n.value);j&&s(j)?e.onChange({value:j,event:g}):e.onChange({value:null,event:g}),t.nextTick(()=>{requestAnimationFrame(()=>{const U=document.getElementById(e.id),G=d.value??0;U&&(U.focus(),U.setSelectionRange(G,G))})})},$=o=>{if(o.code==="Space"||o.key===" "){e.onShowPicker(o);return}if(k.includes(o.key)){o.preventDefault();const u=o.target;S(o.key,u,o)}},H=o=>{o.preventDefault();const u=o.deltaY<0?"ArrowUp":"ArrowDown";S(u,o.target,o)},re=o=>{const u=o.target;if(b.includes(o.key)){d.value=u?.selectionStart??0;return}k.includes(o.key)&&(o.preventDefault(),d.value=u?.selectionStart??0)},z=o=>{N.value=!0,B.value&&e.externalValue&&e.externalValue.value===void 0&&v.value.length===0&&(e.externalValue.value="");const u=o.target;u&&(d.value=u.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const u=new Date(o);if(u.toString()!=="Invalid Date"){const g=u.getHours(),M=g>=12?"PM":"AM";n.value=F(g,u.getMinutes(),M);return}}},{immediate:!0});const Y=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",D.value],["Hour (24h)",q.value],["Minute",x.value],["Period",T.value],["Time (24h)",m.value??"--:--:--"],["Digits only",v.value],["Parsed Date",_.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",a.value],["reason",f.value],["validationMessage",I.value]]),_=t.computed(()=>l(n.value)??null),a=t.computed(()=>{if(!B.value){if(!h.value)return!0;const u=_.value;return u?s(u):!1}if(!N.value)return!0;const o=_.value;return!h.value||!o?!1:s(o)}),f=t.computed(()=>{if(!B.value){if(!h.value)return;const u=_.value;return u?s(u)?"valid":"out-of-bounds":"invalid-time"}if(!N.value)return;if(v.value.length===0||!h.value)return"incomplete";const o=_.value;return o?s(o)?"valid":"out-of-bounds":"invalid-time"}),I=t.computed(()=>{const o=f.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-time")return`Must be in ${L.value} format.`;const u={hour:"2-digit",minute:"2-digit"},g=e.min?e.min.toLocaleTimeString("en-US",u):null,M=e.max?e.max.toLocaleTimeString("en-US",u):null;if(o==="out-of-bounds"){if(g&&M)return`Must be between ${g} and ${M}.`;if(g)return`Must be ${g} or later.`;if(M)return`Must be ${M} or earlier.`}return""}),Q=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`#${e.id} not found for styling.`);return}const u=o.closest(".k-timepicker");if(!u)console.warn(`.k-timepicker parent of #${e.id} not found for styling.`);else{const g=u.parentElement;g?g.classList.add("fk-timepicker"):console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`)}})};return t.onMounted(()=>{Q()}),{raw:n,rules:w,debugEnabled:P,debugLines:Y,placeholder:L,isValid:a,reason:t.readonly(f),validationMessage:I,isComplete:h,inRangeTime:s,cursorPos:d,hour:t.readonly(D),hour24:t.readonly(q),minute:t.readonly(x),period:t.readonly(T),time24:t.readonly(m),parsedRawTime:t.readonly(_),handleChange:y,handleKeyDown:$,handleKeyUp:re,handleClick:A,handleWheel:H,handleBlur:z}}function Ie(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}const ke=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ce=Object.prototype.toString,Pe=e=>Ce.call(e)==="[object Object]",se=()=>{},Le=qe();function qe(){var e,n;return ke&&((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 Re(e,n,d){return t.watch(e,n,{...d,immediate:!0})}const De=ke?window:void 0;function fe(e){var n;const d=t.toValue(e);return(n=d?.$el)!=null?n:d}function ve(...e){const n=[],d=()=>{n.forEach(k=>k()),n.length=0},P=(k,b,v,w)=>(k.addEventListener(b,v,w),()=>k.removeEventListener(b,v,w)),L=t.computed(()=>{const k=he(t.toValue(e[0])).filter(b=>b!=null);return k.every(b=>typeof b!="string")?k:void 0}),B=Re(()=>{var k,b;return[(b=(k=L.value)==null?void 0:k.map(v=>fe(v)))!=null?b:[De].filter(v=>v!=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])]},([k,b,v,w])=>{if(d(),!k?.length||!b?.length||!v?.length)return;const C=Pe(w)?{...w}:w;n.push(...k.flatMap(D=>b.flatMap(x=>v.map(T=>P(D,x,T,C)))))},{flush:"post"}),N=()=>{B(),d()};return Ie(d),N}let Ae=!1;function Fe(e,n,d={}){const{window:P=De,ignore:L=[],capture:B=!0,detectIframe:N=!1,controls:k=!1}=d;if(!P)return k?{stop:se,cancel:se,trigger:se}:se;if(Le&&!Ae){Ae=!0;const m={passive:!0};Array.from(P.document.body.children).forEach(h=>h.addEventListener("click",se,m)),P.document.documentElement.addEventListener("click",se,m)}let b=!0;const v=m=>t.toValue(L).some(h=>{if(typeof h=="string")return Array.from(P.document.querySelectorAll(h)).some(F=>F===m.target||m.composedPath().includes(F));{const F=fe(h);return F&&(m.target===F||m.composedPath().includes(F))}});function w(m){const h=t.toValue(m);return h&&h.$.subTree.shapeFlag===16}function C(m,h){const F=t.toValue(m),l=F.$.subTree&&F.$.subTree.children;return l==null||!Array.isArray(l)?!1:l.some(p=>p.el===h.target||h.composedPath().includes(p.el))}const D=m=>{const h=fe(e);if(m.target!=null&&!(!(h instanceof Element)&&w(e)&&C(e,m))&&!(!h||h===m.target||m.composedPath().includes(h))){if("detail"in m&&m.detail===0&&(b=!v(m)),!b){b=!0;return}n(m)}};let x=!1;const T=[ve(P,"click",m=>{x||(x=!0,setTimeout(()=>{x=!1},0),D(m))},{passive:!0,capture:B}),ve(P,"pointerdown",m=>{const h=fe(e);b=!v(m)&&!!(h&&!m.composedPath().includes(h))},{passive:!0}),N&&ve(P,"blur",m=>{setTimeout(()=>{var h;const F=fe(e);((h=P.document.activeElement)==null?void 0:h.tagName)==="IFRAME"&&!F?.contains(P.document.activeElement)&&n(m)},0)},{passive:!0})].filter(Boolean),q=()=>T.forEach(m=>m());return k?{stop:q,cancel:()=>{b=!1},trigger:m=>{b=!0,D(m),b=!1}}:q}function Oe(e){const n=t.shallowRef(null),d=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],P=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??d].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:B,deactivate:N}=Ee.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>L(n.value),...e.focusTrapOptions??{}});let k=null,b=t.ref(null);const v=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const w=(D,x)=>{const T=Array.from(D.querySelectorAll(x));if(!T.length)return null;const q=T.filter(m=>m.offsetParent!==null||m.getClientRects().length>0);return q[q.length-1]??T[T.length-1]??null},C=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const D of P){const x=w(C,D);if(x)return x}for(const D of P){const x=w(document,D);if(x)return x}return null};return Fe(n,w=>{b.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",w)}),t.watch(()=>e.isOpen.value,w=>{w?(b.value=null,t.nextTick(()=>{const C=v();C&&(n.value=C,setTimeout(()=>B(),0),k||(k=D=>{D.key==="Escape"&&(b.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",D))},document.addEventListener("keydown",k,!0)))})):(N(),k&&(document.removeEventListener("keydown",k,!0),k=null),n.value=null,b.value==="outside"&&t.nextTick(()=>{const C=()=>{const D=e.triggerEl?.value,x=D?.querySelector("input"),T=document.activeElement;T&&(T===x||D&&D.contains(T))&&(x??D)?.blur?.()};requestAnimationFrame(()=>setTimeout(C,0))}),e.returnFocusToTrigger!==!1&&b.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const C=()=>{const D=e.triggerEl?.value;if(!D)return;(D.querySelector("input")??D)?.focus?.()};requestAnimationFrame(()=>setTimeout(C,0))})))}),{popupRef:n,activate:B,deactivate:N,lastCloseReason:t.readonly(b),setPopupEl:w=>n.value=w}}te.useGridA11y=xe,te.useMaskedDateInput=Me,te.useMaskedDateRangeInput=Te,te.useMaskedTimeInput=$e,te.usePopupTrap=Oe,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})}));
@@ -44,5 +44,7 @@ export declare function useMaskedDateRangeInput(args: {
44
44
  handleWheel: (event: WheelEvent) => void;
45
45
  handleKeyUp: (event: KeyboardEvent) => void;
46
46
  handleClick: (event: MouseEvent) => void;
47
+ handleBlur: (_event: FocusEvent) => void;
48
+ handleClear: (event?: Event) => void;
47
49
  onCalendarChange: () => void;
48
50
  };
@@ -36,8 +36,11 @@ export declare function useMaskedTimeInput(args: {
36
36
  inRangeTime: (d: Date) => boolean;
37
37
  cursorPos: Ref<number, number>;
38
38
  hour: Readonly<Ref<number, number>>;
39
+ hour24: Readonly<Ref<number, number>>;
39
40
  minute: Readonly<Ref<number, number>>;
40
41
  period: Readonly<Ref<"AM" | "PM", "AM" | "PM">>;
42
+ time24: Readonly<Ref<string, string>>;
43
+ parsedRawTime: Readonly<Ref<Date, Date>>;
41
44
  handleChange: (event: any) => void;
42
45
  handleKeyDown: (event: KeyboardEvent) => void;
43
46
  handleKeyUp: (event: KeyboardEvent) => void;
@@ -154,7 +154,7 @@ Creates a controller for a masked single-date input.
154
154
  - **Caret persistence**: After programmatic updates (including steppers), the caret is restored to the prior position to preserve typing flow.
155
155
  - **Space key**: The input consumes Space and calls `onShowCalendar` to open the DatePicker popup without inserting a space into `raw`.
156
156
  - **External sync**: When `externalValue` is set to a valid date, `raw` mirrors it (e.g., from a calendar selection). If external becomes null/invalid, `raw` is preserved to avoid clobbering in-progress text.
157
- - **Styling hook**: On mount, adds `fk-datepicker` class to the closest `.k-datepicker` parent for theming.
157
+ - **Styling hook**: On mount, adds `fk-datepicker` class to the parent of the closest `.k-datepicker` element for theming.
158
158
 
159
159
  ## Integration Patterns
160
160
 
@@ -70,6 +70,7 @@ const clickAdornment = () => { showCal.value ? closeCalendar() : openCalendar();
70
70
  @keyup="range.handleKeyUp"
71
71
  @wheel.prevent="range.handleWheel"
72
72
  @click="range.handleClick"
73
+ @blur="range.handleBlur"
73
74
  >
74
75
  <template #calendar-adornment>
75
76
  <SvgIcon
@@ -146,12 +147,14 @@ Creates a controller for a masked date range input.
146
147
  - **`handleWheel(event)`**: Prevents page scroll; interprets wheel as steppers (up/down) for the focused part.
147
148
  - **`handleKeyUp(event)`**: Maintains caret position after cursor keys/steppers.
148
149
  - **`handleClick(event)`**: Captures caret position on click for restoring.
150
+ - **`handleBlur(event)`**: Validates the input and updates the validity state when the input loses focus.
149
151
  - **`onCalendarChange()`**: Marks subsequent `externalValue` updates as calendar-originated; used to optionally auto-close the popup.
150
152
 
151
153
  ## Behavior Details
152
154
 
153
155
  - **Mask and parsing**: Expects `00/00/0000 - 00/00/0000`. Parsing requires both dates to be complete (10 chars each) and valid per calendar rules.
154
156
  - **Validation**:
157
+ - Validation is performed only when the input loses focus (on blur).
155
158
  - Each side must be a valid date (including month/day bounds like Feb 29).
156
159
  - Clamped to `min`/`max` if provided; outside results in `value=null`.
157
160
  - Ordered range required unless `allowReverse=true`.
@@ -176,6 +179,7 @@ Key event bindings:
176
179
  - `@keyup="range.handleKeyUp"`
177
180
  - `@wheel.prevent="range.handleWheel"`
178
181
  - `@click="range.handleClick"`
182
+ - `@blur="range.handleBlur"`
179
183
 
180
184
  Calendar coordination:
181
185
 
@@ -48,6 +48,9 @@ const {
48
48
  placeholder,
49
49
  isValid,
50
50
  validationMessage,
51
+ hour24, // 24-hour format (0-23)
52
+ time24, // HH:MM:SS format for database
53
+ parsedRawTime, // Parsed Date object
51
54
  debugEnabled,
52
55
  debugLines,
53
56
  } = masked;
@@ -123,7 +126,12 @@ Creates a controller for a masked single-time input.
123
126
  - `cursorPos: Ref<number | undefined>`: Caret position for restoring after programmatic updates.
124
127
  - `placeholder: Ref<string>`: Format placeholder (defaults to `hh:mm AM`).
125
128
  - `digitsOnly: Computed<string>`: Raw string stripped of non-digits.
126
- - `hour`, `minute`, `period`: Readonly computed parts (numeric hour/minute, `AM`/`PM`).
129
+ - `hour: Readonly<Computed<number>>`: 12-hour format hour (1-12).
130
+ - `hour24: Readonly<Computed<number>>`: 24-hour format hour (0-23). Useful for calculations and comparisons.
131
+ - `minute: Readonly<Computed<number>>`: Minutes (0-59).
132
+ - `period: Readonly<Computed<"AM" | "PM">>`: AM or PM period.
133
+ - `time24: Readonly<Computed<string | null>>`: Time in 24-hour `HH:MM:SS` format (e.g., `"14:30:00"`) for database storage. Returns `null` if input is incomplete or invalid.
134
+ - `parsedRawTime: Readonly<Computed<Date | null>>`: The parsed time as a `Date` object (today's date with the entered time). Returns `null` if input is incomplete or invalid.
127
135
  - `isComplete: Computed<boolean>`: `true` when the raw string matches `^(\d{2}):(\d{2})\s([AP]M)$`.
128
136
  - `isValid: Computed<boolean>`: Validity considering completeness, parsability, min/max bounds, and (when enabled) required state.
129
137
  - `reason: Computed<string | undefined>`: Machine-readable reason for the current validation state:
@@ -151,6 +159,11 @@ Creates a controller for a masked single-time input.
151
159
  ## Behavior Details
152
160
 
153
161
  - **Mask and parsing**: Expects `00:00 AM`. Parsing requires the input to be complete and form a real time (`01–12` hours, `00–59` minutes), with `AM/PM`. Parsed output is a `Date` for today at the chosen time.
162
+ - **Multiple format outputs**: The composable provides the time in multiple formats for different use cases:
163
+ - `raw`: User-facing 12-hour format with AM/PM (e.g., `"02:30 PM"`)
164
+ - `hour24`: 24-hour format hour (0-23) for calculations
165
+ - `time24`: Database-friendly `HH:MM:SS` format (e.g., `"14:30:00"`)
166
+ - `parsedRawTime`: Full `Date` object with today's date and the entered time
154
167
  - **AM/PM convenience**: When caret is in the AM/PM segment and a user types `A/a` or `P/p`, the composable auto-completes to `AM`/`PM`.
155
168
  - **Emission policy**: Emits `Date` only when the raw is complete, valid, and within `min`/`max`. Otherwise emits `null`. Empty input emits `null`. When `required` is enabled, a blank or incomplete value is only considered invalid after blur.
156
169
  - **Min/Max validation**: Bounds are evaluated by minutes since midnight. Times outside bounds are invalid (`isValid=false`) and produce a range `validationMessage`.
@@ -158,13 +171,14 @@ Creates a controller for a masked single-time input.
158
171
  - **Caret persistence**: After programmatic updates (including steppers), the caret is restored to the prior position to preserve typing flow.
159
172
  - **Space key**: The input consumes Space and calls `onShowPicker` to open a time menu without inserting a space into `raw`.
160
173
  - **External sync**: When `externalValue` is set to a valid `Date`, `raw` mirrors it (e.g., from a `TimePicker` selection). If external becomes null/invalid, `raw` is preserved to avoid clobbering in-progress text.
161
- - **Styling hook**: On mount, adds a theming class (e.g., `fk-timepicker`) to the closest Kendo time picker container for styling.
174
+ - **Styling hook**: On mount, adds a theming class (e.g., `fk-timepicker`) to the parent of the closest Kendo time picker element for styling.
162
175
 
163
176
  ## Integration Patterns
164
177
 
165
178
  - **MaskedTextBox only**: Use the Quick Start to accept typed times with validation — no time menu required.
166
179
  - **Popup + TimePicker**: Bind a `TimePicker` to the same `timeValue` ref passed as `externalValue`. Use Space key (`onShowPicker`) to open the popup and keep bounds (`minTime`/`maxTime`) aligned.
167
180
  - **Minute step control**: Provide `minuteStep` or a reactive `minuteStepRef` to control ArrowUp/ArrowDown behavior in the minutes segment at runtime.
181
+ - **Database storage**: Use the `time24` computed property to get time in `HH:MM:SS` format (e.g., `"14:30:00"`), perfect for storing in SQL TIME columns or string fields. This format is sortable, unambiguous, and follows database standards.
168
182
 
169
183
  ### Important: Kendo TimePicker slot name
170
184
 
@@ -198,6 +212,8 @@ If you use `timeInput`, the slot will not render and you may waste time debuggin
198
212
  - Keep `min`/`max` aligned with your `TimePicker` configuration for consistent validation.
199
213
  - Use `debug: true` and display `debugLines` during integration to verify caret, parsed values, and masks.
200
214
  - Avoid mutating `raw` externally except through `v-model`; let the composable manage its value and emit parsed times.
215
+ - **Database storage**: Use the `time24` property to get the time in `HH:MM:SS` format (e.g., `"14:30:00"`), which is ideal for storing in SQL TIME columns or as string fields. This format is sortable, unambiguous, and database-standard.
216
+ - **24-hour calculations**: Use `hour24` for time comparisons and calculations without needing to worry about AM/PM conversions.
201
217
 
202
218
  ## Types
203
219
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@featherk/composables",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "main": "dist/featherk-composables.umd.js",
5
5
  "module": "dist/featherk-composables.es.js",
6
6
  "types": "dist/index.d.ts",