@featherk/composables 0.6.19 → 0.7.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.
@@ -1 +1 @@
1
- (function(ne,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):(ne=typeof globalThis<"u"?globalThis:ne||self,t(ne.FeatherKComposables={},ne.Vue,ne.useFocusTrap))})(this,(function(ne,t,Ee){"use strict";const Me=(e,n)=>{const c=t.ref(null);let O=!1,C=null,$=null;const H=[],E=".k-table-row[data-grid-row-index] [tabindex]",D=()=>{const l=e?.value?.$el;return l?l.closest(".k-grid"):null},w=l=>{const y=D();if(!y)return!1;const s=l.closest(".k-grid-aria-root");if(s)return y.contains(s);const d=l.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return d?y.contains(d):!1},k=l=>l.key==="Enter"||l.code==="Enter"||l.code==="NumpadEnter",P=()=>e?.value?.columns,A=l=>{const y=l.key||l.code;([" ","Spacebar","Space"].includes(y)||k(l))&&(l.preventDefault(),l.stopPropagation(),c.value=l.target,l.target.click())},x=l=>{if(!c.value)return;if(l.code==="Escape"){l.stopPropagation(),c.value&&c.value.focus();return}const y=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),s=document.querySelector(".k-animation-container .k-popup .k-column-menu .k-filter-menu-container");if(s){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"],v=n?.focusableMenuSelectors??d,p=Array.from(s.querySelectorAll(v.join(",")));if(p.length===0)return;const S=p.findIndex(G=>G===document.activeElement);let F;S===-1?F=0:l.shiftKey?F=(S-1+p.length)%p.length:F=(S+1)%p.length,l.preventDefault(),l.stopPropagation(),p[F]?.focus()}}else if(l.code==="ArrowUp"||l.code==="ArrowDown"){l.preventDefault(),l.stopPropagation();const d=y.findIndex(p=>p===document.activeElement);let v=d;l.code==="ArrowUp"?v=d>0?d-1:y.length-1:l.code==="ArrowDown"&&(v=d<y.length-1?d+1:0),y[v]?.focus();return}if(l.code==="Tab"){l.preventDefault(),l.stopPropagation();const d=c.value?.parentElement;(l.shiftKey?d?.previousElementSibling:d?.nextElementSibling)?.querySelector("button, [role='button'], .k-link")?.focus()}},I=()=>{C=new MutationObserver(l=>{l.forEach(y=>{y.addedNodes.forEach(s=>{if(s.nodeType===Node.ELEMENT_NODE){const d=s;if(d.classList.contains("k-animation-container")){const p=c.value;p&&(p.dataset.featherKSortable==="true"||t.nextTick(()=>{d.querySelectorAll(".k-columnmenu-item-wrapper").forEach(G=>{G.textContent?.toLowerCase().includes("sort")&&G.remove()})})),d.addEventListener("keydown",x),t.nextTick(()=>{const S=()=>{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(),S.attempts=0;else if(F.length>1){S.attempts=0;return}else S.attempts===void 0&&(S.attempts=0),S.attempts++<3&&setTimeout(S,200)};S()})}d.querySelectorAll(".k-animation-container").forEach(p=>{p.addEventListener("keydown",x)})}}),y.removedNodes.forEach(s=>{if(s.nodeType===Node.ELEMENT_NODE){const d=s;d.classList.contains("k-animation-container")&&d.removeEventListener("keydown",x),d.querySelectorAll(".k-animation-container").forEach(p=>{p.removeEventListener("keydown",x)})}})})}),C.observe(document.body,{childList:!0,subtree:!0})},K=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"]'))},m=l=>{if(!l.type||!l)return;const y=l.target;if(!y)return;const s=y.closest(".k-table-row[data-grid-row-index]");if(!w(y))return;const d=["ArrowLeft","ArrowRight"].includes(l.code);if(!(K(y)&&!(s&&d))){if(l.code==="Escape"){const v=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(v){l.preventDefault(),l.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(S=>S.setAttribute("tabindex","-1"))}catch{}v.setAttribute("tabindex","0"),v.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")){c.value=y;return}if(s){if(["ArrowDown","ArrowUp"].includes(l.code)){l.preventDefault(),l.stopPropagation();const v=(S,F)=>{let G=F==="next"?S.nextElementSibling:S.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},p=l.code==="ArrowDown"?v(s,"next"):v(s,"previous");p&&(s.setAttribute("tabindex","-1"),p.setAttribute("tabindex","0"),p.focus());return}if(["ArrowLeft","ArrowRight"].includes(l.code)){l.preventDefault(),l.stopPropagation();const v=s.querySelectorAll(E);if(v.length===0)return;let p=Array.from(v).findIndex(S=>S===document.activeElement);if(p===-1&&document.activeElement===s){v[0].focus();return}l.code==="ArrowRight"?p=p===v.length-1?0:p+1:l.code==="ArrowLeft"&&(p=p===0?v.length-1:p-1),v[p].focus();return}}}}},b=()=>{t.nextTick(()=>{const l=e.value.$el.closest(".k-grid");l&&l.classList.add("fk-grid")})},q=()=>{if(!$)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(S=>S.getAttribute("tabindex")==="0").length===1)return;const p=d.find(S=>S===document.activeElement||S.contains(document.activeElement));if(d.forEach(S=>S.setAttribute("tabindex","-1")),p){p.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,v)=>{d.setAttribute("tabindex",v===0?"0":"-1")});const s=e.value.$el.querySelector(".k-table-tbody");s&&($=new MutationObserver(()=>{l()}),$.observe(s,{childList:!0,subtree:!0}))}catch(l){console.error("Error setting up row navigation:",l)}},_=()=>{t.nextTick(()=>{const y=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");y&&y.forEach(s=>{s.setAttribute("role","button"),s.addEventListener("keydown",A)}),I(),J()})},j=()=>{const y=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");y&&y.forEach(s=>{s.removeEventListener("keydown",A)}),C&&(C.disconnect(),C=null),$&&($.disconnect(),$=null),H.forEach(s=>s()),H.length=0},J=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((s,d)=>{if(s.dataset.featherKHeaderBound==="true")return;const v=s.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!v)return;const p=P();if(p&&p[d]){const g=p[d].field??"";s.setAttribute("data-feather-k-field",g),s.setAttribute("data-feather-k-filterable",p[d].filterable===!1?"false":"true"),s.setAttribute("data-feather-k-sortable",p[d].sortable===!1?"false":"true")}const S=s.dataset.featherKFilterable!=="false",F=s.dataset.featherKSortable!=="false";v.setAttribute("tabindex","-1"),S||F?s.style.cursor="pointer":s.style.cursor="default",S?(s.setAttribute("tabindex","0"),s.setAttribute("role","button"),s.setAttribute("aria-haspopup","menu")):(s.setAttribute("tabindex","0"),s.setAttribute("role","columnheader"),s.removeAttribute("aria-haspopup"));const G=g=>{g.target?.closest(".k-column-resizer")||(c.value=s,v.click())},a=g=>{if(S)c.value=s,g.preventDefault(),g.stopPropagation(),G(g);else if(F){c.value=s;const R=s.querySelector(".k-link");R&&R.click()}};s.addEventListener("click",a),H.push(()=>{s.removeEventListener("click",a)});const f=g=>{if((k(g)||g.code==="Space")&&(S||F)){if(g.preventDefault(),g.stopPropagation(),c.value=s,c.value.focus(),S)G(g);else if(F){const R=s.querySelector(".k-link");R&&R.click()}}};s.addEventListener("keydown",f,!0),H.push(()=>{s.removeEventListener("keydown",f,!0)}),s.dataset.featherKHeaderBound="true"});const y=document.querySelector(".k-grid-header .k-table-thead");if(y&&y.dataset.featherKHeaderBound!=="true"){const s=d=>{const v=d.target.closest("th");v&&(k(d)||d.code==="Space")&&v.dataset.featherKFilterable==="false"&&v.dataset.featherKSortable==="false"&&(d.preventDefault(),d.stopImmediatePropagation())};y.addEventListener("keydown",s,!0),H.push(()=>{y.removeEventListener("keydown",s,!0)}),y.dataset.featherKHeaderBound="true"}},Q=function(l,y){const s=l?.event?.event.target,d=P();if(!s||!d)return;const v=s.classList.contains("k-grid-header-menu"),p=s.classList.contains("k-columnmenu-item"),S=d.find(F=>F.field===l?.event?.field)?.sortable&&!0;if(!v){if(p&&!S){l?.event?.sort?.filter(G=>G.field!==l?.event?.field);return}typeof y=="function"&&t.nextTick(()=>{c.value&&c.value.focus(),y(l),t.nextTick(()=>{J()})})}},oe=()=>{if(!O)try{b(),q(),_(),O=!0}catch(l){console.error("initA11y failed:",l),j()}};return t.onBeforeUnmount(()=>{j()}),{activeFilterButton:c,handleGridKeyDown:m,handleSortChange:Q,initA11y:oe}};function Te(e){const n=t.ref(""),c=t.ref(void 0),O=t.ref(!!e.debug),C=t.ref(e.dateFormat??"mm/dd/yyyy"),$=t.computed(()=>!!e.required),H=t.ref(!1),E=["ArrowUp","ArrowDown"],D=["ArrowLeft","ArrowRight"],w=t.computed(()=>(n.value??"").replace(/\D/g,"")),k=a=>a<=2?"mm":a<=5?"dd":w.value.length<=10?"yyyy":"mm",P=t.computed(()=>{const a=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(2,"0")}),A=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")}),I=a=>{if(w.value.length===0){e.onChange({value:null,event:a});return}if(w.value.length<8){e.onChange({value:null,event:a});return}if((n.value??"").length===10&&w.value.length===8){const[f,g,R]=n.value.split("/"),V=parseInt(f),B=parseInt(g),X=parseInt(R);if(_(X,V,B)){const ae=new Date(X,V-1,B);K(ae)?e.onChange({value:ae,event:a}):e.onChange({value:null,event:a})}else e.onChange({value:null,event:a})}},K=a=>{const f=e.min??void 0,g=e.max??void 0;return!(f&&a<f||g&&a>g)},m=t.computed(()=>{if((n.value??"").length===10&&w.value.length===8){const[a,f,g]=(n.value??"").split("/"),R=parseInt(a),V=parseInt(f),B=parseInt(g);if(_(B,R,V))return new Date(B,R-1,V)}return null}),b=t.computed(()=>(n.value??"").length===10&&w.value.length===8),q=(a,f)=>new Date(a,f,0).getDate(),_=(a,f,g)=>f>=1&&f<=12&&a>=1900&&g>=1&&g<=q(a,f),j=a=>{n.value=a.value;const f=a.event?.target;c.value=f?.selectionStart??0,I(a)},J=a=>{c.value=a.target.selectionStart??0},Q=(a,f,g)=>{const R=f?.selectionStart??c.value??0;c.value=R;let V=parseInt(P.value),B=parseInt(A.value),X=parseInt(x.value);if(!(w.value.length>=8)||!_(X,V,B)){const W=e.defaultValue??new Date;V=W.getMonth()+1,B=W.getDate(),X=W.getFullYear(),n.value=`${String(V).padStart(2,"0")}/${String(B).padStart(2,"0")}/${String(X)}`;const U=new Date(X,V-1,B);e.onChange({value:K(U)?U:null,event:g}),d({useRAF:!0});return}const o=k(R);if(o==="mm")V=a==="ArrowUp"?V<12?V+1:1:V>1?V-1:12;else if(o==="dd"){const W=new Date(X,V,0).getDate();B=a==="ArrowUp"?B<W?B+1:1:B>1?B-1:W}else o==="yyyy"&&(X=a==="ArrowUp"?X+1:Math.max(1,X-1));n.value=`${String(V).padStart(2,"0")}/${String(B).padStart(2,"0")}/${String(X)}`;const[i,T,L]=n.value.split("/"),N=new Date(parseInt(L),parseInt(i)-1,parseInt(T));N.toString()!=="Invalid Date"&&parseInt(L)>=1e3?e.onChange({value:K(N)?N: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(E.includes(a.key)){if(a.altKey)return;a.preventDefault(),a.stopPropagation();const f=a.target;Q(a.key,f,a);return}},l=a=>{a.preventDefault();const f=a.deltaY<0?"ArrowUp":"ArrowDown";Q(f,a.target,a)},y=a=>{const f=a.target;if(D.includes(a.key)){c.value=f?.selectionStart??0;return}if(E.includes(a.key)){if(a.altKey)return;c.value=f?.selectionStart??0}},s=a=>{H.value=!0,$.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&w.value.length===0&&(e.externalValue.value="");const f=a.target;f&&(c.value=f.selectionStart??0)},d=a=>{const f=()=>{const g=document.getElementById(e.id);if(!g)return;const R=a?.pos??c.value??g.value.length;try{g.focus(),g.setSelectionRange(R,R)}catch{}};t.nextTick(()=>{if(a?.delay&&a.delay>0){setTimeout(f,a.delay);return}if(a?.useRAF){requestAnimationFrame(f);return}f()})};e.externalValue&&t.watch(e.externalValue,a=>{if(a){const f=new Date(a);if(f.toString()!=="Invalid Date"){const g=(f.getMonth()+1).toString().padStart(2,"0"),R=f.getDate().toString().padStart(2,"0"),V=f.getFullYear().toString();n.value=`${g}/${R}/${V}`,d({delay:50});return}}},{immediate:!0});const v=t.computed(()=>[["Date",`${P.value} / ${A.value} / ${x.value}`],["Digits only",w.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]]),p=t.computed(()=>{if(!$.value){if(!b.value)return!0;const f=m.value;return f?K(f):!1}if(!H.value)return!0;const a=m.value;return!b.value||!a?!1:K(a)}),S=t.computed(()=>{if(!$.value){if(!b.value)return;const f=m.value;return f?K(f)?"valid":"out-of-bounds":"invalid-date"}if(!H.value)return;if(w.value.length===0||!b.value)return"incomplete";const a=m.value;return a?K(a)?"valid":"out-of-bounds":"invalid-date"}),F=t.computed(()=>{const a=S.value;if(!a||a==="valid")return"";if(a==="incomplete")return"Required";if(a==="invalid-date")return`Must be in ${C.value} format.`;const f=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(f&&g)return`Must be between ${f} and ${g}.`;if(f)return`Must be on or after ${f}.`;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 f=a.closest(".k-datepicker");if(!f){console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}const g=f.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:c,debugEnabled:O,debugLines:v,placeholder:C,isValid:p,reason:t.readonly(S),validationMessage:F,digitsOnly:w,month:t.readonly(P),day:t.readonly(A),year:t.readonly(x),datePart:k,handleChange:j,handleKeyDown:oe,handleWheel:l,handleKeyUp:y,handleClick:J,handleBlur:s,initStyling:G}}function Ce(e){const n=t.ref(""),c=t.ref(void 0),O=t.ref(!!e.debug),C=t.ref(!1),$=1440*60*1e3,H=365*$,E=new Date,D=new Date(E.getTime()-H),w=new Date(E.getTime()+H);e.min=e.min??D,e.max=e.max??w;const k=t.computed(()=>(n.value??"").replace(/\D/g,"")),P=(r,u)=>new Date(r,u,0).getDate(),A=(r,u,h)=>u>=1&&u<=12&&r>=1e3&&h>=1&&h<=P(r,u),x=r=>Date.UTC(r.getFullYear(),r.getMonth(),r.getDate()),I=r=>{if(!r)return null;const u=e.min??new Date(Date.now()-90*$),h=e.max??new Date,M=x(r);return M<x(u)||M>x(h)?null:r},K=(r,u)=>e.allowReverse??!1?!0:r<=u,m=t.computed(()=>(n.value?.length??0)>=23&&k.value.length>=16),b=r=>{if((r??"").length<23||k.value.length<16)return{start:null,end:null};const u=r.substring(0,10),h=r.substring(13,23),[M,Z,ee]=u.split("/").map(se=>parseInt(se||"0",10)),[ie,ce,de]=h.split("/").map(se=>parseInt(se||"0",10)),fe=new Date(ee,M-1,Z),ye=new Date(de,ie-1,ce),Se=A(ee,M,Z)&&fe.toString()!=="Invalid Date",be=A(de,ie,ce)&&ye.toString()!=="Invalid Date";return{start:Se?fe:null,end:be?ye:null}},q=e.externalValid??t.ref(!0),_=t.computed(()=>b(n.value)),j=t.computed(()=>{const r=I(_.value.start),u=I(_.value.end);return{start:r,end:u}}),J=t.computed(()=>{if(!m.value)return;const r=j.value.start,u=j.value.end;if(!r||!u)return;const h=Math.abs(x(u)-x(r));return Math.round(h/864e5+1)}),Q=t.computed(()=>{if(!m.value)return!1;const{start:r,end:u}=_.value;if(!r||!u||!j.value.start||!j.value.end)return!1;const h=j.value.start,M=j.value.end;return!(!K(h,M)||typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays)}),oe=t.computed(()=>{const{start:r,end:u}=_.value;if(!m.value)return"incomplete";if(!r||!u)return"invalid-date";if(!j.value.start||!j.value.end)return"out-of-bounds";const h=j.value.start,M=j.value.end;return K(h,M)?typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),l=t.ref(void 0),y=t.computed(()=>{if(q.value!==!1)return"";const{min:r,max:u}=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&&u?`Dates must be between ${p(r)} and ${p(u)}.`:"Dates must be within the allowed range.";case"span-exceeds-limit":return typeof e.maxSpanDays=="number"?`Date range exceeds ${e.maxSpanDays} days.`:"Date range exceeds maximum allowed span.";default:return""}}),s=["ArrowUp","ArrowDown"],d=["ArrowLeft","ArrowRight"],v=(r,u)=>String(r).padStart(u,"0"),p=r=>`${v(r.getMonth()+1,2)}/${v(r.getDate(),2)}/${v(r.getFullYear(),4)}`,S=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,u,h)=>{const M=u?.selectionStart??c.value??0;c.value=M;const{start:Z,end:ee}=b(n.value);if(!Z&&!ee){const Y=new Date,le=p(Y);n.value=`${le} - ${le}`,e.onChange({value:{start:Y,end:Y},event:h}),t.nextTick(()=>{requestAnimationFrame(()=>{const te=document.getElementById(e.id),re=c.value??0;te&&(te.focus(),te.setSelectionRange(re,re))})});return}const ie=new Date,ce=S(M);let de=Z?new Date(Z):new Date(ie),fe=ee?new Date(ee):new Date(ie);const ye=(Y,le)=>{if(le==="mm"){const te=Y.getMonth()+1,re=r==="ArrowUp"?te<12?te+1:1:te>1?te-1:12;Y.setMonth(re-1);const ge=P(Y.getFullYear(),re);Y.getDate()>ge&&Y.setDate(ge)}else if(le==="dd"){const te=P(Y.getFullYear(),Y.getMonth()+1),re=Y.getDate(),ge=r==="ArrowUp"?re<te?re+1:1:re>1?re-1:te;Y.setDate(ge)}else if(le==="yyyy"){const te=Y.getFullYear();Y.setFullYear(r==="ArrowUp"?te+1:Math.max(1,te-1));const re=P(Y.getFullYear(),Y.getMonth()+1);Y.getDate()>re&&Y.setDate(re)}};ce.side==="start"?ye(de,ce.part):ye(fe,ce.part);const Se=p(de),be=p(fe);n.value=`${Se} - ${be}`;const se=I(de),ke=I(fe);se&&ke&&K(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=c.value??0;Y&&(Y.focus(),Y.setSelectionRange(le,le))})})},G=r=>{const{start:u,end:h}=b(n.value);if(!u||!h){e.onChange({value:null,event:r});return}const M=I(u),Z=I(h);if(!M||!Z){e.onChange({value:null,event:r});return}if(!K(M,Z)){e.onChange({value:null,event:r});return}e.onChange({value:{start:M,end:Z},event:r})},a=r=>{const u=r.value??"",h=r.event;if(!u&&h&&h.type==="click"){ae(h);return}n.value=u;const M=h?.target;c.value=M?.selectionStart??0,G(r)},f=r=>{c.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(s.includes(r.key)){r.preventDefault(),r.stopPropagation();const u=r.target;F(r.key,u,r);return}},R=r=>{r.preventDefault();const u=r.deltaY<0?"ArrowUp":"ArrowDown";F(u,r.target,r)},V=r=>{if(d.includes(r.key)||s.includes(r.key)){const u=r.target;c.value=u?.selectionStart??0}},B=()=>{l.value=oe.value,(e.manageValid??!0)&&(q.value=Q.value)},X=r=>{B()},ae=r=>{console.log("Clear event:",r),n.value="",c.value=0,e.onChange({value:null,event:r}),B(),t.nextTick(()=>{const u=document.getElementById(e.id);u&&(u.focus(),u.setSelectionRange(0,0))})};e.externalValue&&t.watch(e.externalValue,r=>{const u=r?.start??null,h=r?.end??null;if(u&&h){if(n.value=`${p(u)} - ${p(h)}`,e.isOpen?.value&&C.value&&e.onRequestClose){const M=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),C.value=!1,B()},M)}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=t.computed(()=>n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0"),L=t.computed(()=>n.value&&n.value.substring(13,15).replace(/\D/g,"0")||"0"),N=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),W=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),U=t.computed(()=>{const{start:r,end:u}=b(n.value);return[{label:"Raw",value:n.value},{label:"Min Date",value:`${e.min?e.min.toDateString():"-"}`},{label:"Max Date",value:`${e.max?e.max.toDateString():"-"}`},{label:"Start",value:`${String(o.value).padStart(2,"0")} / ${String(i.value).padStart(2,"0")} / ${String(T.value).padStart(4,"0")}`},{label:"End",value:`${String(L.value).padStart(2,"0")} / ${String(N.value).padStart(2,"0")} / ${String(W.value).padStart(4,"0")}`},{label:"Digits only",value:k.value},{label:"Mask complete",value:`${m.value}`},{label:"Parsed",value:`${r?r.toDateString():"-"} | ${u?u.toDateString():"-"}`},{label:"Valid (managed)",value:`${q.value??"-"}`},{label:"Span (days)",value:`${J.value??"-"}`},{label:"Reason",value:`${oe.value??"-"}`},{label:"Cursor in",value:`${c.value??"-"} (${(()=>{const h=c.value??0,M=S(h);return`${M.side}.${M.part}`})()})`}]}),z=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`#${e.id} not found for styling.`);return}const u=r.closest("div");if(!u){console.warn(`Parent div of #${e.id} not found for styling.`);return}u.classList.contains("fk-daterangepicker")||u.classList.add("fk-daterangepicker")})};t.onMounted(()=>{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 M=h.querySelectorAll(".k-calendar-table");let Z=!1;M.forEach(ee=>{ee.tabIndex===0&&(Z?ee.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:c,debugEnabled:O,debugLines:U,digitsOnly:k,valid:q,validComputed:t.readonly(Q),reason:t.readonly(oe),validationMessage:t.readonly(y),spanDays:t.readonly(J),month1:t.readonly(o),day1:t.readonly(i),year1:t.readonly(T),month2:t.readonly(L),day2:t.readonly(N),year2:t.readonly(W),handleChange:a,handleKeyDown:g,handleWheel:R,handleKeyUp:V,handleClick:f,handleBlur:X,handleClear:ae,onCalendarChange:()=>{C.value=!0},initStyling:z}}function $e(e){const n=t.ref(""),c=t.ref(void 0),O=t.ref(!!e.debug),C=t.ref(e.timeFormat??"hh:mm AM"),$=t.computed(()=>!!e.required),H=t.ref(!1),E=["ArrowUp","ArrowDown"],D=["ArrowLeft","ArrowRight"],w=t.computed(()=>(n.value??"").replace(/\D/g,"")),k={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},P=o=>o<=2?"hh":o<=5?"mm":"ampm",A=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)}),x=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)}),I=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),K=t.computed(()=>{const o=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),i=I.value;return o===12?i==="AM"?0:12:i==="PM"?o+12:o}),m=t.computed(()=>b.value?`${String(K.value).padStart(2,"0")}:${String(x.value).padStart(2,"0")}:00`:null),b=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),q=(o,i,T)=>{let L=o%12;return L===0&&(L=12),`${String(L).padStart(2,"0")}:${String(i).padStart(2,"0")} ${T}`},_=o=>{const i=o.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!i)return null;const T=parseInt(i[1]),L=parseInt(i[2]),N=i[3].toUpperCase();if(T<1||T>12||L<0||L>59)return null;let W=T%12;N==="PM"&&(W+=12);const U=new Date;return U.setSeconds(0,0),U.setHours(W),U.setMinutes(L),U},j=o=>{if(w.value.length===0){e.onChange({value:null,event:o});return}if(!b.value){e.onChange({value:null,event:o});return}const i=_(n.value);i&&Q(i)?e.onChange({value:i,event:o}):e.onChange({value:null,event:o})},J=o=>o.getHours()*60+o.getMinutes(),Q=o=>{const i=e.min??void 0,T=e.max??void 0,L=J(o);if(i){const N=J(i);if(L<N)return!1}if(T){const N=J(T);if(L>N)return!1}return!0},oe=o=>{const i=o.getHours(),T=i>=12?"PM":"AM";n.value=q(i,o.getMinutes(),T)},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)}})})})},s=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&&Q(o)?l(o,i):l(null,i)},v=(...o)=>{const i=o[0];if(!i)return;const T=s(i);if(T==="now"){const N=new Date;oe(N),d(N,i),y();return}if(i?.value instanceof Date){const N=new Date(i.value);oe(N),d(N,i),T==="set"&&y();return}if(i?.value===null){n.value="",l(null,i);return}n.value=i.value;const L=i.event?.target;c.value=L?.selectionStart??0;try{const N=c.value??0;if(P(N)==="ampm"&&(n.value??"").length>=8){const W=n.value.charAt(6);/[Aa]/.test(W)?(n.value=`${n.value.slice(0,6)}AM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const U=document.getElementById(e.id);U&&(U.focus(),U.setSelectionRange(8,8))})})):/[Pp]/.test(W)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const U=document.getElementById(e.id);U&&(U.focus(),U.setSelectionRange(8,8))})}))}}catch{}j(i)},p=o=>{c.value=o.target.selectionStart??0},S=(o,i,T)=>{const L=i?.selectionStart??c.value??0;c.value=L;const N=P(L),W=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!W){if((n.value??"").length===0||w.value.length===0){const u=new Date,h=u.getHours(),M=h>=12?"PM":"AM";n.value=q(h,u.getMinutes(),M);const Z=_(n.value);d(Z,T),t.nextTick(()=>{requestAnimationFrame(()=>{const ee=document.getElementById(e.id),ie=c.value??0;ee&&(ee.focus(),ee.setSelectionRange(ie,ie))})})}return}let U=parseInt(W[1]),z=parseInt(W[2]),me=W[3].toUpperCase();if(N==="hh")o==="ArrowUp"?U=U<12?U+1:1:U=U>1?U-1:12;else if(N==="mm"){const u=e.minuteStepRef?.value??e.minuteStep??1;if(u===1)o==="ArrowUp"?z=z<59?z+1:0:z=z>0?z-1:59;else if(o==="ArrowUp"){const h=z%u;let M=h===0?z+u:z+(u-h);M>=60&&(M=0),z=M}else{const h=z%u;let M=h===0?z-u:z-h;M<0&&(M=60-u),z=M}}else N==="ampm"&&(me=me==="AM"?"PM":"AM");n.value=`${String(U).padStart(2,"0")}:${String(z).padStart(2,"0")} ${me}`;const r=_(n.value);d(r,T),t.nextTick(()=>{requestAnimationFrame(()=>{const u=document.getElementById(e.id),h=c.value??0;u&&(u.focus(),u.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(E.includes(o.key)){if(o.altKey)return;o.preventDefault(),o.stopPropagation();const i=o.target;S(o.key,i,o);return}},G=o=>{o.preventDefault();const i=o.deltaY<0?"ArrowUp":"ArrowDown";S(i,o.target,o)},a=o=>{const i=o.target;if(D.includes(o.key)){c.value=i?.selectionStart??0;return}if(E.includes(o.key)){if(o.altKey)return;c.value=i?.selectionStart??0}},f=o=>{H.value=!0,$.value&&e.externalValue&&e.externalValue.value===void 0&&w.value.length===0&&(e.externalValue.value="");const i=o.target;i&&(c.value=i.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const i=new Date(o);if(i.toString()!=="Invalid Date"){const T=i.getHours(),L=T>=12?"PM":"AM";n.value=q(T,i.getMinutes(),L);return}}},{immediate:!0});const g=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",A.value],["Hour (24h)",K.value],["Minute",x.value],["Period",I.value],["Time (24h)",m.value??"--:--:--"],["Digits only",w.value],["Parsed Date",R.value?.toLocaleDateString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["min",e.min?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["max",e.max?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["valid",V.value],["reason",B.value],["validationMessage",X.value]]),R=t.computed(()=>_(n.value)??null),V=t.computed(()=>{if(!$.value){if(!b.value)return!0;const i=R.value;return i?Q(i):!1}if(!H.value)return!0;const o=R.value;return!b.value||!o?!1:Q(o)}),B=t.computed(()=>{if(!$.value){if(!b.value)return;const i=R.value;return i?Q(i)?"valid":"out-of-bounds":"invalid-time"}if(!H.value)return;if(w.value.length===0||!b.value)return"incomplete";const o=R.value;return o?Q(o)?"valid":"out-of-bounds":"invalid-time"}),X=t.computed(()=>{const o=B.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-time")return`Must be in ${C.value} format.`;const i={hour:"2-digit",minute:"2-digit"},T=e.min?e.min.toLocaleTimeString("en-US",i):null,L=e.max?e.max.toLocaleTimeString("en-US",i):null;if(o==="out-of-bounds"){if(T&&L)return`Must be between ${T} and ${L}.`;if(T)return`Must be ${T} or later.`;if(L)return`Must be ${L} 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 T=i.parentElement;if(!T){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}T.classList.contains("fk-timepicker")||T.classList.add("fk-timepicker")})};return t.onMounted(()=>{ae()}),{raw:n,rules:k,debugEnabled:O,debugLines:g,placeholder:C,isValid:V,reason:t.readonly(B),validationMessage:X,isComplete:b,inRangeTime:Q,cursorPos:c,hour:t.readonly(A),hour24:t.readonly(K),minute:t.readonly(x),period:t.readonly(I),time24:t.readonly(m),parsedRawTime:t.readonly(R),handleChange:v,handleKeyDown:F,handleKeyUp:a,handleClick:p,handleWheel:G,handleBlur:f,initStyling:ae}}function Pe(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}const we=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ie=Object.prototype.toString,Fe=e=>Ie.call(e)==="[object Object]",ue=()=>{},Le=Re();function Re(){var e,n;return we&&((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,c){return t.watch(e,n,{...c,immediate:!0})}const De=we?window:void 0;function pe(e){var n;const c=t.toValue(e);return(n=c?.$el)!=null?n:c}function ve(...e){const n=[],c=()=>{n.forEach(E=>E()),n.length=0},O=(E,D,w,k)=>(E.addEventListener(D,w,k),()=>E.removeEventListener(D,w,k)),C=t.computed(()=>{const E=he(t.toValue(e[0])).filter(D=>D!=null);return E.every(D=>typeof D!="string")?E:void 0}),$=qe(()=>{var E,D;return[(D=(E=C.value)==null?void 0:E.map(w=>pe(w)))!=null?D:[De].filter(w=>w!=null),he(t.toValue(C.value?e[1]:e[0])),he(t.unref(C.value?e[2]:e[1])),t.toValue(C.value?e[3]:e[2])]},([E,D,w,k])=>{if(c(),!E?.length||!D?.length||!w?.length)return;const P=Fe(k)?{...k}:k;n.push(...E.flatMap(A=>D.flatMap(x=>w.map(I=>O(A,x,I,P)))))},{flush:"post"}),H=()=>{$(),c()};return Pe(c),H}let Ae=!1;function Ue(e,n,c={}){const{window:O=De,ignore:C=[],capture:$=!0,detectIframe:H=!1,controls:E=!1}=c;if(!O)return E?{stop:ue,cancel:ue,trigger:ue}:ue;if(Le&&!Ae){Ae=!0;const m={passive:!0};Array.from(O.document.body.children).forEach(b=>b.addEventListener("click",ue,m)),O.document.documentElement.addEventListener("click",ue,m)}let D=!0;const w=m=>t.toValue(C).some(b=>{if(typeof b=="string")return Array.from(O.document.querySelectorAll(b)).some(q=>q===m.target||m.composedPath().includes(q));{const q=pe(b);return q&&(m.target===q||m.composedPath().includes(q))}});function k(m){const b=t.toValue(m);return b&&b.$.subTree.shapeFlag===16}function P(m,b){const q=t.toValue(m),_=q.$.subTree&&q.$.subTree.children;return _==null||!Array.isArray(_)?!1:_.some(j=>j.el===b.target||b.composedPath().includes(j.el))}const A=m=>{const b=pe(e);if(m.target!=null&&!(!(b instanceof Element)&&k(e)&&P(e,m))&&!(!b||b===m.target||m.composedPath().includes(b))){if("detail"in m&&m.detail===0&&(D=!w(m)),!D){D=!0;return}n(m)}};let x=!1;const I=[ve(O,"click",m=>{x||(x=!0,setTimeout(()=>{x=!1},0),A(m))},{passive:!0,capture:$}),ve(O,"pointerdown",m=>{const b=pe(e);D=!w(m)&&!!(b&&!m.composedPath().includes(b))},{passive:!0}),H&&ve(O,"blur",m=>{setTimeout(()=>{var b;const q=pe(e);((b=O.document.activeElement)==null?void 0:b.tagName)==="IFRAME"&&!q?.contains(O.document.activeElement)&&n(m)},0)},{passive:!0})].filter(Boolean),K=()=>I.forEach(m=>m());return E?{stop:K,cancel:()=>{D=!1},trigger:m=>{D=!0,A(m),D=!1}}:K}function Oe(e){const n=t.shallowRef(null),c=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],O=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??c].flat(),C=k=>k?typeof e.initialFocus=="string"?k.querySelector(e.initialFocus)??k:typeof e.initialFocus=="function"?e.initialFocus(k)??k:k.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??k:null,{activate:$,deactivate:H}=Ee.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>C(n.value),...e.focusTrapOptions??{}});let E=null,D=t.ref(null);const w=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const k=(A,x)=>{const I=Array.from(A.querySelectorAll(x));if(!I.length)return null;const K=I.filter(m=>m.offsetParent!==null||m.getClientRects().length>0);return K[K.length-1]??I[I.length-1]??null},P=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const A of O){const x=k(P,A);if(x)return x}for(const A of O){const x=k(document,A);if(x)return x}return null};return Ue(n,k=>{D.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",k)}),t.watch(()=>e.isOpen.value,k=>{k?(D.value=null,t.nextTick(()=>{const P=w();P&&(n.value=P,setTimeout(()=>$(),0),E||(E=A=>{A.key==="Escape"&&(D.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",A))},document.addEventListener("keydown",E,!0)))})):(H(),E&&(document.removeEventListener("keydown",E,!0),E=null),n.value=null,D.value==="outside"&&t.nextTick(()=>{const P=()=>{const A=e.triggerEl?.value,x=A?.querySelector("input"),I=document.activeElement;I&&(I===x||A&&A.contains(I))&&(x??A)?.blur?.()};requestAnimationFrame(()=>setTimeout(P,0))}),e.returnFocusToTrigger!==!1&&D.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const P=()=>{const A=e.triggerEl?.value;if(!A)return;(A.querySelector("input")??A)?.focus?.()};requestAnimationFrame(()=>setTimeout(P,0))})))}),{popupRef:n,activate:$,deactivate:H,lastCloseReason:t.readonly(D),setPopupEl:k=>n.value=k}}const Ke=e=>!!e&&typeof e=="object"&&"filters"in e&&Array.isArray(e.filters),Ve=e=>!!e&&typeof e=="object"&&"field"in e,xe=(e,n)=>!e||typeof e!="object"?!1:Ke(e)?e.filters.some(c=>xe(c,n)):Ve(e)?e.field===n:!1,Be=e=>{const n=t.ref({}),c=C=>!e.value||!e.value.filters?!1:e.value.filters.some($=>xe($,C));return{activeClasses:n,hasFieldFilter:c,updateActiveClass:C=>{const $=c(C);console.log("updateActiveClass for",C,"hasFilter:",$),n.value[C]=$?"active":"",console.log("activeClasses after update",n.value)}}};ne.useGridA11y=Me,ne.useGridFilter=Be,ne.useMaskedDateInput=Te,ne.useMaskedDateRangeInput=Ce,ne.useMaskedTimeInput=$e,ne.usePopupTrap=Oe,Object.defineProperty(ne,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(ne,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):(ne=typeof globalThis<"u"?globalThis:ne||self,t(ne.FeatherKComposables={},ne.Vue,ne.useFocusTrap))})(this,(function(ne,t,Ee){"use strict";const Me=(e,n)=>{const c=t.ref(null);let N=!1,q=null,U=null;const H=[],E=".k-table-row[data-grid-row-index] [tabindex]",D=()=>{const l=e?.value?.$el;return l?l.closest(".k-grid"):null},w=l=>{const y=D();if(!y)return!1;const s=l.closest(".k-grid-aria-root");if(s)return y.contains(s);const d=l.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return d?y.contains(d):!1},k=l=>l.key==="Enter"||l.code==="Enter"||l.code==="NumpadEnter",$=()=>e?.value?.columns,A=l=>{const y=l.key||l.code;([" ","Spacebar","Space"].includes(y)||k(l))&&(l.preventDefault(),l.stopPropagation(),c.value=l.target,l.target.click())},x=l=>{if(!c.value)return;if(l.code==="Escape"){l.stopPropagation(),c.value&&c.value.focus();return}const y=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),s=document.querySelector(".k-animation-container .k-popup .k-column-menu .k-filter-menu-container");if(s){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"],v=n?.focusableMenuSelectors??d,p=Array.from(s.querySelectorAll(v.join(",")));if(p.length===0)return;const S=p.findIndex(G=>G===document.activeElement);let P;S===-1?P=0:l.shiftKey?P=(S-1+p.length)%p.length:P=(S+1)%p.length,l.preventDefault(),l.stopPropagation(),p[P]?.focus()}}else if(l.code==="ArrowUp"||l.code==="ArrowDown"){l.preventDefault(),l.stopPropagation();const d=y.findIndex(p=>p===document.activeElement);let v=d;l.code==="ArrowUp"?v=d>0?d-1:y.length-1:l.code==="ArrowDown"&&(v=d<y.length-1?d+1:0),y[v]?.focus();return}if(l.code==="Tab"){l.preventDefault(),l.stopPropagation();const d=c.value?.parentElement;(l.shiftKey?d?.previousElementSibling:d?.nextElementSibling)?.querySelector("button, [role='button'], .k-link")?.focus()}},C=()=>{q=new MutationObserver(l=>{l.forEach(y=>{y.addedNodes.forEach(s=>{if(s.nodeType===Node.ELEMENT_NODE){const d=s;if(d.classList.contains("k-animation-container")){const p=c.value;p&&(p.dataset.featherKSortable==="true"||t.nextTick(()=>{d.querySelectorAll(".k-columnmenu-item-wrapper").forEach(G=>{G.textContent?.toLowerCase().includes("sort")&&G.remove()})})),d.addEventListener("keydown",x),t.nextTick(()=>{const S=()=>{const P=Array.from(d.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(),S.attempts=0;else if(P.length>1){S.attempts=0;return}else S.attempts===void 0&&(S.attempts=0),S.attempts++<3&&setTimeout(S,200)};S()})}d.querySelectorAll(".k-animation-container").forEach(p=>{p.addEventListener("keydown",x)})}}),y.removedNodes.forEach(s=>{if(s.nodeType===Node.ELEMENT_NODE){const d=s;d.classList.contains("k-animation-container")&&d.removeEventListener("keydown",x),d.querySelectorAll(".k-animation-container").forEach(p=>{p.removeEventListener("keydown",x)})}})})}),q.observe(document.body,{childList:!0,subtree:!0})},O=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"]'))},m=l=>{if(!l.type||!l)return;const y=l.target;if(!y)return;const s=y.closest(".k-table-row[data-grid-row-index]");if(!w(y))return;const d=["ArrowLeft","ArrowRight"].includes(l.code);if(!(O(y)&&!(s&&d))){if(l.code==="Escape"){const v=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(v){l.preventDefault(),l.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(S=>S.setAttribute("tabindex","-1"))}catch{}v.setAttribute("tabindex","0"),v.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")){c.value=y;return}if(s){if(["ArrowDown","ArrowUp"].includes(l.code)){l.preventDefault(),l.stopPropagation();const v=(S,P)=>{let G=P==="next"?S.nextElementSibling:S.previousElementSibling;for(;G;){const a=G;try{if(a.classList.contains("k-table-row"))return a}catch{}G=P==="next"?G.nextElementSibling:G.previousElementSibling}return null},p=l.code==="ArrowDown"?v(s,"next"):v(s,"previous");p&&(s.setAttribute("tabindex","-1"),p.setAttribute("tabindex","0"),p.focus());return}if(["ArrowLeft","ArrowRight"].includes(l.code)){l.preventDefault(),l.stopPropagation();const v=s.querySelectorAll(E);if(v.length===0)return;let p=Array.from(v).findIndex(S=>S===document.activeElement);if(p===-1&&document.activeElement===s){v[0].focus();return}l.code==="ArrowRight"?p=p===v.length-1?0:p+1:l.code==="ArrowLeft"&&(p=p===0?v.length-1:p-1),v[p].focus();return}}}}},b=()=>{t.nextTick(()=>{const l=e.value.$el.closest(".k-grid");l&&l.classList.add("fk-grid")})},F=()=>{if(!U)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(S=>S.getAttribute("tabindex")==="0").length===1)return;const p=d.find(S=>S===document.activeElement||S.contains(document.activeElement));if(d.forEach(S=>S.setAttribute("tabindex","-1")),p){p.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,v)=>{d.setAttribute("tabindex",v===0?"0":"-1")});const s=e.value.$el.querySelector(".k-table-tbody");s&&(U=new MutationObserver(()=>{l()}),U.observe(s,{childList:!0,subtree:!0}))}catch(l){console.error("Error setting up row navigation:",l)}},_=()=>{t.nextTick(()=>{const y=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");y&&y.forEach(s=>{s.setAttribute("role","button"),s.addEventListener("keydown",A)}),C(),J()})},j=()=>{const y=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");y&&y.forEach(s=>{s.removeEventListener("keydown",A)}),q&&(q.disconnect(),q=null),U&&(U.disconnect(),U=null),H.forEach(s=>s()),H.length=0},J=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((s,d)=>{if(s.dataset.featherKHeaderBound==="true")return;const v=s.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!v)return;const p=$();if(p&&p[d]){const g=p[d].field??"";s.setAttribute("data-feather-k-field",g),s.setAttribute("data-feather-k-filterable",p[d].filterable===!1?"false":"true"),s.setAttribute("data-feather-k-sortable",p[d].sortable===!1?"false":"true")}const S=s.dataset.featherKFilterable!=="false",P=s.dataset.featherKSortable!=="false";v.setAttribute("tabindex","-1"),S||P?s.style.cursor="pointer":s.style.cursor="default",S?(s.setAttribute("tabindex","0"),s.setAttribute("role","button"),s.setAttribute("aria-haspopup","menu")):(s.setAttribute("tabindex","0"),s.setAttribute("role","columnheader"),s.removeAttribute("aria-haspopup"));const G=g=>{g.target?.closest(".k-column-resizer")||(c.value=s,v.click())},a=g=>{if(S)c.value=s,g.preventDefault(),g.stopPropagation(),G(g);else if(P){c.value=s;const L=s.querySelector(".k-link");L&&L.click()}};s.addEventListener("click",a),H.push(()=>{s.removeEventListener("click",a)});const f=g=>{if((k(g)||g.code==="Space")&&(S||P)){if(g.preventDefault(),g.stopPropagation(),c.value=s,c.value.focus(),S)G(g);else if(P){const L=s.querySelector(".k-link");L&&L.click()}}};s.addEventListener("keydown",f,!0),H.push(()=>{s.removeEventListener("keydown",f,!0)}),s.dataset.featherKHeaderBound="true"});const y=document.querySelector(".k-grid-header .k-table-thead");if(y&&y.dataset.featherKHeaderBound!=="true"){const s=d=>{const v=d.target.closest("th");v&&(k(d)||d.code==="Space")&&v.dataset.featherKFilterable==="false"&&v.dataset.featherKSortable==="false"&&(d.preventDefault(),d.stopImmediatePropagation())};y.addEventListener("keydown",s,!0),H.push(()=>{y.removeEventListener("keydown",s,!0)}),y.dataset.featherKHeaderBound="true"}},Q=function(l,y){const s=l?.event?.event.target,d=$();if(!s||!d)return;const v=s.classList.contains("k-grid-header-menu"),p=s.classList.contains("k-columnmenu-item"),S=d.find(P=>P.field===l?.event?.field)?.sortable&&!0;if(!v){if(p&&!S){l?.event?.sort?.filter(G=>G.field!==l?.event?.field);return}typeof y=="function"&&t.nextTick(()=>{c.value&&c.value.focus(),y(l),t.nextTick(()=>{J()})})}},oe=()=>{if(!N)try{b(),F(),_(),N=!0}catch(l){console.error("initA11y failed:",l),j()}};return t.onBeforeUnmount(()=>{j()}),{activeFilterButton:c,handleGridKeyDown:m,handleSortChange:Q,initA11y:oe}},Te=e=>!!e&&typeof e=="object"&&"filters"in e&&Array.isArray(e.filters),$e=e=>!!e&&typeof e=="object"&&"field"in e,we=(e,n)=>!e||typeof e!="object"?!1:Te(e)?e.filters.some(c=>we(c,n)):$e(e)?e.field===n:!1,Ce=e=>n=>e.value?.filters&&e.value.filters.some(c=>we(c,n))?"active":"";function Pe(e){const n=t.ref(""),c=t.ref(void 0),N=t.ref(!!e.debug),q=t.ref(e.dateFormat??"mm/dd/yyyy"),U=t.computed(()=>!!e.required),H=t.ref(!1),E=["ArrowUp","ArrowDown"],D=["ArrowLeft","ArrowRight"],w=t.computed(()=>(n.value??"").replace(/\D/g,"")),k=a=>a<=2?"mm":a<=5?"dd":w.value.length<=10?"yyyy":"mm",$=t.computed(()=>{const a=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(2,"0")}),A=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")}),C=a=>{if(w.value.length===0){e.onChange({value:null,event:a});return}if(w.value.length<8){e.onChange({value:null,event:a});return}if((n.value??"").length===10&&w.value.length===8){const[f,g,L]=n.value.split("/"),K=parseInt(f),V=parseInt(g),X=parseInt(L);if(_(X,K,V)){const ae=new Date(X,K-1,V);O(ae)?e.onChange({value:ae,event:a}):e.onChange({value:null,event:a})}else e.onChange({value:null,event:a})}},O=a=>{const f=e.min??void 0,g=e.max??void 0;return!(f&&a<f||g&&a>g)},m=t.computed(()=>{if((n.value??"").length===10&&w.value.length===8){const[a,f,g]=(n.value??"").split("/"),L=parseInt(a),K=parseInt(f),V=parseInt(g);if(_(V,L,K))return new Date(V,L-1,K)}return null}),b=t.computed(()=>(n.value??"").length===10&&w.value.length===8),F=(a,f)=>new Date(a,f,0).getDate(),_=(a,f,g)=>f>=1&&f<=12&&a>=1900&&g>=1&&g<=F(a,f),j=a=>{n.value=a.value;const f=a.event?.target;c.value=f?.selectionStart??0,C(a)},J=a=>{c.value=a.target.selectionStart??0},Q=(a,f,g)=>{const L=f?.selectionStart??c.value??0;c.value=L;let K=parseInt($.value),V=parseInt(A.value),X=parseInt(x.value);if(!(w.value.length>=8)||!_(X,K,V)){const W=e.defaultValue??new Date;K=W.getMonth()+1,V=W.getDate(),X=W.getFullYear(),n.value=`${String(K).padStart(2,"0")}/${String(V).padStart(2,"0")}/${String(X)}`;const R=new Date(X,K-1,V);e.onChange({value:O(R)?R:null,event:g}),d({useRAF:!0});return}const o=k(L);if(o==="mm")K=a==="ArrowUp"?K<12?K+1:1:K>1?K-1:12;else if(o==="dd"){const W=new Date(X,K,0).getDate();V=a==="ArrowUp"?V<W?V+1:1:V>1?V-1:W}else o==="yyyy"&&(X=a==="ArrowUp"?X+1:Math.max(1,X-1));n.value=`${String(K).padStart(2,"0")}/${String(V).padStart(2,"0")}/${String(X)}`;const[i,T,I]=n.value.split("/"),B=new Date(parseInt(I),parseInt(i)-1,parseInt(T));B.toString()!=="Invalid Date"&&parseInt(I)>=1e3?e.onChange({value:O(B)?B: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(E.includes(a.key)){if(a.altKey)return;a.preventDefault(),a.stopPropagation();const f=a.target;Q(a.key,f,a);return}},l=a=>{a.preventDefault();const f=a.deltaY<0?"ArrowUp":"ArrowDown";Q(f,a.target,a)},y=a=>{const f=a.target;if(D.includes(a.key)){c.value=f?.selectionStart??0;return}if(E.includes(a.key)){if(a.altKey)return;c.value=f?.selectionStart??0}},s=a=>{H.value=!0,U.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&w.value.length===0&&(e.externalValue.value="");const f=a.target;f&&(c.value=f.selectionStart??0)},d=a=>{const f=()=>{const g=document.getElementById(e.id);if(!g)return;const L=a?.pos??c.value??g.value.length;try{g.focus(),g.setSelectionRange(L,L)}catch{}};t.nextTick(()=>{if(a?.delay&&a.delay>0){setTimeout(f,a.delay);return}if(a?.useRAF){requestAnimationFrame(f);return}f()})};e.externalValue&&t.watch(e.externalValue,a=>{if(a){const f=new Date(a);if(f.toString()!=="Invalid Date"){const g=(f.getMonth()+1).toString().padStart(2,"0"),L=f.getDate().toString().padStart(2,"0"),K=f.getFullYear().toString();n.value=`${g}/${L}/${K}`,d({delay:50});return}}},{immediate:!0});const v=t.computed(()=>[["Date",`${$.value} / ${A.value} / ${x.value}`],["Digits only",w.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]]),p=t.computed(()=>{if(!U.value){if(!b.value)return!0;const f=m.value;return f?O(f):!1}if(!H.value)return!0;const a=m.value;return!b.value||!a?!1:O(a)}),S=t.computed(()=>{if(!U.value){if(!b.value)return;const f=m.value;return f?O(f)?"valid":"out-of-bounds":"invalid-date"}if(!H.value)return;if(w.value.length===0||!b.value)return"incomplete";const a=m.value;return a?O(a)?"valid":"out-of-bounds":"invalid-date"}),P=t.computed(()=>{const a=S.value;if(!a||a==="valid")return"";if(a==="incomplete")return"Required";if(a==="invalid-date")return`Must be in ${q.value} format.`;const f=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(f&&g)return`Must be between ${f} and ${g}.`;if(f)return`Must be on or after ${f}.`;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 f=a.closest(".k-datepicker");if(!f){console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}const g=f.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:c,debugEnabled:N,debugLines:v,placeholder:q,isValid:p,reason:t.readonly(S),validationMessage:P,digitsOnly:w,month:t.readonly($),day:t.readonly(A),year:t.readonly(x),datePart:k,handleChange:j,handleKeyDown:oe,handleWheel:l,handleKeyUp:y,handleClick:J,handleBlur:s,initStyling:G}}function Ie(e){const n=t.ref(""),c=t.ref(void 0),N=t.ref(!!e.debug),q=t.ref(!1),U=1440*60*1e3,H=365*U,E=new Date,D=new Date(E.getTime()-H),w=new Date(E.getTime()+H);e.min=e.min??D,e.max=e.max??w;const k=t.computed(()=>(n.value??"").replace(/\D/g,"")),$=(r,u)=>new Date(r,u,0).getDate(),A=(r,u,h)=>u>=1&&u<=12&&r>=1e3&&h>=1&&h<=$(r,u),x=r=>Date.UTC(r.getFullYear(),r.getMonth(),r.getDate()),C=r=>{if(!r)return null;const u=e.min??new Date(Date.now()-90*U),h=e.max??new Date,M=x(r);return M<x(u)||M>x(h)?null:r},O=(r,u)=>e.allowReverse??!1?!0:r<=u,m=t.computed(()=>(n.value?.length??0)>=23&&k.value.length>=16),b=r=>{if((r??"").length<23||k.value.length<16)return{start:null,end:null};const u=r.substring(0,10),h=r.substring(13,23),[M,Z,ee]=u.split("/").map(se=>parseInt(se||"0",10)),[ie,ce,de]=h.split("/").map(se=>parseInt(se||"0",10)),fe=new Date(ee,M-1,Z),ye=new Date(de,ie-1,ce),Se=A(ee,M,Z)&&fe.toString()!=="Invalid Date",be=A(de,ie,ce)&&ye.toString()!=="Invalid Date";return{start:Se?fe:null,end:be?ye:null}},F=e.externalValid??t.ref(!0),_=t.computed(()=>b(n.value)),j=t.computed(()=>{const r=C(_.value.start),u=C(_.value.end);return{start:r,end:u}}),J=t.computed(()=>{if(!m.value)return;const r=j.value.start,u=j.value.end;if(!r||!u)return;const h=Math.abs(x(u)-x(r));return Math.round(h/864e5+1)}),Q=t.computed(()=>{if(!m.value)return!1;const{start:r,end:u}=_.value;if(!r||!u||!j.value.start||!j.value.end)return!1;const h=j.value.start,M=j.value.end;return!(!O(h,M)||typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays)}),oe=t.computed(()=>{const{start:r,end:u}=_.value;if(!m.value)return"incomplete";if(!r||!u)return"invalid-date";if(!j.value.start||!j.value.end)return"out-of-bounds";const h=j.value.start,M=j.value.end;return O(h,M)?typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),l=t.ref(void 0),y=t.computed(()=>{if(F.value!==!1)return"";const{min:r,max:u}=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&&u?`Dates must be between ${p(r)} and ${p(u)}.`:"Dates must be within the allowed range.";case"span-exceeds-limit":return typeof e.maxSpanDays=="number"?`Date range exceeds ${e.maxSpanDays} days.`:"Date range exceeds maximum allowed span.";default:return""}}),s=["ArrowUp","ArrowDown"],d=["ArrowLeft","ArrowRight"],v=(r,u)=>String(r).padStart(u,"0"),p=r=>`${v(r.getMonth()+1,2)}/${v(r.getDate(),2)}/${v(r.getFullYear(),4)}`,S=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"},P=(r,u,h)=>{const M=u?.selectionStart??c.value??0;c.value=M;const{start:Z,end:ee}=b(n.value);if(!Z&&!ee){const Y=new Date,le=p(Y);n.value=`${le} - ${le}`,e.onChange({value:{start:Y,end:Y},event:h}),t.nextTick(()=>{requestAnimationFrame(()=>{const te=document.getElementById(e.id),re=c.value??0;te&&(te.focus(),te.setSelectionRange(re,re))})});return}const ie=new Date,ce=S(M);let de=Z?new Date(Z):new Date(ie),fe=ee?new Date(ee):new Date(ie);const ye=(Y,le)=>{if(le==="mm"){const te=Y.getMonth()+1,re=r==="ArrowUp"?te<12?te+1:1:te>1?te-1:12;Y.setMonth(re-1);const ge=$(Y.getFullYear(),re);Y.getDate()>ge&&Y.setDate(ge)}else if(le==="dd"){const te=$(Y.getFullYear(),Y.getMonth()+1),re=Y.getDate(),ge=r==="ArrowUp"?re<te?re+1:1:re>1?re-1:te;Y.setDate(ge)}else if(le==="yyyy"){const te=Y.getFullYear();Y.setFullYear(r==="ArrowUp"?te+1:Math.max(1,te-1));const re=$(Y.getFullYear(),Y.getMonth()+1);Y.getDate()>re&&Y.setDate(re)}};ce.side==="start"?ye(de,ce.part):ye(fe,ce.part);const Se=p(de),be=p(fe);n.value=`${Se} - ${be}`;const se=C(de),ke=C(fe);se&&ke&&O(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=c.value??0;Y&&(Y.focus(),Y.setSelectionRange(le,le))})})},G=r=>{const{start:u,end:h}=b(n.value);if(!u||!h){e.onChange({value:null,event:r});return}const M=C(u),Z=C(h);if(!M||!Z){e.onChange({value:null,event:r});return}if(!O(M,Z)){e.onChange({value:null,event:r});return}e.onChange({value:{start:M,end:Z},event:r})},a=r=>{const u=r.value??"",h=r.event;if(!u&&h&&h.type==="click"){ae(h);return}n.value=u;const M=h?.target;c.value=M?.selectionStart??0,G(r)},f=r=>{c.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(s.includes(r.key)){r.preventDefault(),r.stopPropagation();const u=r.target;P(r.key,u,r);return}},L=r=>{r.preventDefault();const u=r.deltaY<0?"ArrowUp":"ArrowDown";P(u,r.target,r)},K=r=>{if(d.includes(r.key)||s.includes(r.key)){const u=r.target;c.value=u?.selectionStart??0}},V=()=>{l.value=oe.value,(e.manageValid??!0)&&(F.value=Q.value)},X=r=>{V()},ae=r=>{console.log("Clear event:",r),n.value="",c.value=0,e.onChange({value:null,event:r}),V(),t.nextTick(()=>{const u=document.getElementById(e.id);u&&(u.focus(),u.setSelectionRange(0,0))})};e.externalValue&&t.watch(e.externalValue,r=>{const u=r?.start??null,h=r?.end??null;if(u&&h){if(n.value=`${p(u)} - ${p(h)}`,e.isOpen?.value&&q.value&&e.onRequestClose){const M=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),q.value=!1,V()},M)}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=t.computed(()=>n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0"),I=t.computed(()=>n.value&&n.value.substring(13,15).replace(/\D/g,"0")||"0"),B=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),W=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),R=t.computed(()=>{const{start:r,end:u}=b(n.value);return[{label:"Raw",value:n.value},{label:"Min Date",value:`${e.min?e.min.toDateString():"-"}`},{label:"Max Date",value:`${e.max?e.max.toDateString():"-"}`},{label:"Start",value:`${String(o.value).padStart(2,"0")} / ${String(i.value).padStart(2,"0")} / ${String(T.value).padStart(4,"0")}`},{label:"End",value:`${String(I.value).padStart(2,"0")} / ${String(B.value).padStart(2,"0")} / ${String(W.value).padStart(4,"0")}`},{label:"Digits only",value:k.value},{label:"Mask complete",value:`${m.value}`},{label:"Parsed",value:`${r?r.toDateString():"-"} | ${u?u.toDateString():"-"}`},{label:"Valid (managed)",value:`${F.value??"-"}`},{label:"Span (days)",value:`${J.value??"-"}`},{label:"Reason",value:`${oe.value??"-"}`},{label:"Cursor in",value:`${c.value??"-"} (${(()=>{const h=c.value??0,M=S(h);return`${M.side}.${M.part}`})()})`}]}),z=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`#${e.id} not found for styling.`);return}const u=r.closest("div");if(!u){console.warn(`Parent div of #${e.id} not found for styling.`);return}u.classList.contains("fk-daterangepicker")||u.classList.add("fk-daterangepicker")})};t.onMounted(()=>{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 M=h.querySelectorAll(".k-calendar-table");let Z=!1;M.forEach(ee=>{ee.tabIndex===0&&(Z?ee.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:c,debugEnabled:N,debugLines:R,digitsOnly:k,valid:F,validComputed:t.readonly(Q),reason:t.readonly(oe),validationMessage:t.readonly(y),spanDays:t.readonly(J),month1:t.readonly(o),day1:t.readonly(i),year1:t.readonly(T),month2:t.readonly(I),day2:t.readonly(B),year2:t.readonly(W),handleChange:a,handleKeyDown:g,handleWheel:L,handleKeyUp:K,handleClick:f,handleBlur:X,handleClear:ae,onCalendarChange:()=>{q.value=!0},initStyling:z}}function Le(e){const n=t.ref(""),c=t.ref(void 0),N=t.ref(!!e.debug),q=t.ref(e.timeFormat??"hh:mm AM"),U=t.computed(()=>!!e.required),H=t.ref(!1),E=["ArrowUp","ArrowDown"],D=["ArrowLeft","ArrowRight"],w=t.computed(()=>(n.value??"").replace(/\D/g,"")),k={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},$=o=>o<=2?"hh":o<=5?"mm":"ampm",A=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)}),x=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)}),C=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),O=t.computed(()=>{const o=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),i=C.value;return o===12?i==="AM"?0:12:i==="PM"?o+12:o}),m=t.computed(()=>b.value?`${String(O.value).padStart(2,"0")}:${String(x.value).padStart(2,"0")}:00`:null),b=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),F=(o,i,T)=>{let I=o%12;return I===0&&(I=12),`${String(I).padStart(2,"0")}:${String(i).padStart(2,"0")} ${T}`},_=o=>{const i=o.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!i)return null;const T=parseInt(i[1]),I=parseInt(i[2]),B=i[3].toUpperCase();if(T<1||T>12||I<0||I>59)return null;let W=T%12;B==="PM"&&(W+=12);const R=new Date;return R.setSeconds(0,0),R.setHours(W),R.setMinutes(I),R},j=o=>{if(w.value.length===0){e.onChange({value:null,event:o});return}if(!b.value){e.onChange({value:null,event:o});return}const i=_(n.value);i&&Q(i)?e.onChange({value:i,event:o}):e.onChange({value:null,event:o})},J=o=>o.getHours()*60+o.getMinutes(),Q=o=>{const i=e.min??void 0,T=e.max??void 0,I=J(o);if(i){const B=J(i);if(I<B)return!1}if(T){const B=J(T);if(I>B)return!1}return!0},oe=o=>{const i=o.getHours(),T=i>=12?"PM":"AM";n.value=F(i,o.getMinutes(),T)},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)}})})})},s=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&&Q(o)?l(o,i):l(null,i)},v=(...o)=>{const i=o[0];if(!i)return;const T=s(i);if(T==="now"){const B=new Date;oe(B),d(B,i),y();return}if(i?.value instanceof Date){const B=new Date(i.value);oe(B),d(B,i),T==="set"&&y();return}if(i?.value===null){n.value="",l(null,i);return}n.value=i.value;const I=i.event?.target;c.value=I?.selectionStart??0;try{const B=c.value??0;if($(B)==="ampm"&&(n.value??"").length>=8){const W=n.value.charAt(6);/[Aa]/.test(W)?(n.value=`${n.value.slice(0,6)}AM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const R=document.getElementById(e.id);R&&(R.focus(),R.setSelectionRange(8,8))})})):/[Pp]/.test(W)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const R=document.getElementById(e.id);R&&(R.focus(),R.setSelectionRange(8,8))})}))}}catch{}j(i)},p=o=>{c.value=o.target.selectionStart??0},S=(o,i,T)=>{const I=i?.selectionStart??c.value??0;c.value=I;const B=$(I),W=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!W){if((n.value??"").length===0||w.value.length===0){const u=new Date,h=u.getHours(),M=h>=12?"PM":"AM";n.value=F(h,u.getMinutes(),M);const Z=_(n.value);d(Z,T),t.nextTick(()=>{requestAnimationFrame(()=>{const ee=document.getElementById(e.id),ie=c.value??0;ee&&(ee.focus(),ee.setSelectionRange(ie,ie))})})}return}let R=parseInt(W[1]),z=parseInt(W[2]),me=W[3].toUpperCase();if(B==="hh")o==="ArrowUp"?R=R<12?R+1:1:R=R>1?R-1:12;else if(B==="mm"){const u=e.minuteStepRef?.value??e.minuteStep??1;if(u===1)o==="ArrowUp"?z=z<59?z+1:0:z=z>0?z-1:59;else if(o==="ArrowUp"){const h=z%u;let M=h===0?z+u:z+(u-h);M>=60&&(M=0),z=M}else{const h=z%u;let M=h===0?z-u:z-h;M<0&&(M=60-u),z=M}}else B==="ampm"&&(me=me==="AM"?"PM":"AM");n.value=`${String(R).padStart(2,"0")}:${String(z).padStart(2,"0")} ${me}`;const r=_(n.value);d(r,T),t.nextTick(()=>{requestAnimationFrame(()=>{const u=document.getElementById(e.id),h=c.value??0;u&&(u.focus(),u.setSelectionRange(h,h))})})},P=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(E.includes(o.key)){if(o.altKey)return;o.preventDefault(),o.stopPropagation();const i=o.target;S(o.key,i,o);return}},G=o=>{o.preventDefault();const i=o.deltaY<0?"ArrowUp":"ArrowDown";S(i,o.target,o)},a=o=>{const i=o.target;if(D.includes(o.key)){c.value=i?.selectionStart??0;return}if(E.includes(o.key)){if(o.altKey)return;c.value=i?.selectionStart??0}},f=o=>{H.value=!0,U.value&&e.externalValue&&e.externalValue.value===void 0&&w.value.length===0&&(e.externalValue.value="");const i=o.target;i&&(c.value=i.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const i=new Date(o);if(i.toString()!=="Invalid Date"){const T=i.getHours(),I=T>=12?"PM":"AM";n.value=F(T,i.getMinutes(),I);return}}},{immediate:!0});const g=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",A.value],["Hour (24h)",O.value],["Minute",x.value],["Period",C.value],["Time (24h)",m.value??"--:--:--"],["Digits only",w.value],["Parsed Date",L.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",V.value],["validationMessage",X.value]]),L=t.computed(()=>_(n.value)??null),K=t.computed(()=>{if(!U.value){if(!b.value)return!0;const i=L.value;return i?Q(i):!1}if(!H.value)return!0;const o=L.value;return!b.value||!o?!1:Q(o)}),V=t.computed(()=>{if(!U.value){if(!b.value)return;const i=L.value;return i?Q(i)?"valid":"out-of-bounds":"invalid-time"}if(!H.value)return;if(w.value.length===0||!b.value)return"incomplete";const o=L.value;return o?Q(o)?"valid":"out-of-bounds":"invalid-time"}),X=t.computed(()=>{const o=V.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-time")return`Must be in ${q.value} format.`;const i={hour:"2-digit",minute:"2-digit"},T=e.min?e.min.toLocaleTimeString("en-US",i):null,I=e.max?e.max.toLocaleTimeString("en-US",i):null;if(o==="out-of-bounds"){if(T&&I)return`Must be between ${T} and ${I}.`;if(T)return`Must be ${T} or later.`;if(I)return`Must be ${I} 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 T=i.parentElement;if(!T){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}T.classList.contains("fk-timepicker")||T.classList.add("fk-timepicker")})};return t.onMounted(()=>{ae()}),{raw:n,rules:k,debugEnabled:N,debugLines:g,placeholder:q,isValid:K,reason:t.readonly(V),validationMessage:X,isComplete:b,inRangeTime:Q,cursorPos:c,hour:t.readonly(A),hour24:t.readonly(O),minute:t.readonly(x),period:t.readonly(C),time24:t.readonly(m),parsedRawTime:t.readonly(L),handleChange:v,handleKeyDown:P,handleKeyUp:a,handleClick:p,handleWheel:G,handleBlur:f,initStyling:ae}}function Fe(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}const De=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Re=Object.prototype.toString,qe=e=>Re.call(e)==="[object Object]",ue=()=>{},Ue=Oe();function Oe(){var e,n;return De&&((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 Ke(e,n,c){return t.watch(e,n,{...c,immediate:!0})}const Ae=De?window:void 0;function pe(e){var n;const c=t.toValue(e);return(n=c?.$el)!=null?n:c}function ve(...e){const n=[],c=()=>{n.forEach(E=>E()),n.length=0},N=(E,D,w,k)=>(E.addEventListener(D,w,k),()=>E.removeEventListener(D,w,k)),q=t.computed(()=>{const E=he(t.toValue(e[0])).filter(D=>D!=null);return E.every(D=>typeof D!="string")?E:void 0}),U=Ke(()=>{var E,D;return[(D=(E=q.value)==null?void 0:E.map(w=>pe(w)))!=null?D:[Ae].filter(w=>w!=null),he(t.toValue(q.value?e[1]:e[0])),he(t.unref(q.value?e[2]:e[1])),t.toValue(q.value?e[3]:e[2])]},([E,D,w,k])=>{if(c(),!E?.length||!D?.length||!w?.length)return;const $=qe(k)?{...k}:k;n.push(...E.flatMap(A=>D.flatMap(x=>w.map(C=>N(A,x,C,$)))))},{flush:"post"}),H=()=>{U(),c()};return Fe(c),H}let xe=!1;function Ve(e,n,c={}){const{window:N=Ae,ignore:q=[],capture:U=!0,detectIframe:H=!1,controls:E=!1}=c;if(!N)return E?{stop:ue,cancel:ue,trigger:ue}:ue;if(Ue&&!xe){xe=!0;const m={passive:!0};Array.from(N.document.body.children).forEach(b=>b.addEventListener("click",ue,m)),N.document.documentElement.addEventListener("click",ue,m)}let D=!0;const w=m=>t.toValue(q).some(b=>{if(typeof b=="string")return Array.from(N.document.querySelectorAll(b)).some(F=>F===m.target||m.composedPath().includes(F));{const F=pe(b);return F&&(m.target===F||m.composedPath().includes(F))}});function k(m){const b=t.toValue(m);return b&&b.$.subTree.shapeFlag===16}function $(m,b){const F=t.toValue(m),_=F.$.subTree&&F.$.subTree.children;return _==null||!Array.isArray(_)?!1:_.some(j=>j.el===b.target||b.composedPath().includes(j.el))}const A=m=>{const b=pe(e);if(m.target!=null&&!(!(b instanceof Element)&&k(e)&&$(e,m))&&!(!b||b===m.target||m.composedPath().includes(b))){if("detail"in m&&m.detail===0&&(D=!w(m)),!D){D=!0;return}n(m)}};let x=!1;const C=[ve(N,"click",m=>{x||(x=!0,setTimeout(()=>{x=!1},0),A(m))},{passive:!0,capture:U}),ve(N,"pointerdown",m=>{const b=pe(e);D=!w(m)&&!!(b&&!m.composedPath().includes(b))},{passive:!0}),H&&ve(N,"blur",m=>{setTimeout(()=>{var b;const F=pe(e);((b=N.document.activeElement)==null?void 0:b.tagName)==="IFRAME"&&!F?.contains(N.document.activeElement)&&n(m)},0)},{passive:!0})].filter(Boolean),O=()=>C.forEach(m=>m());return E?{stop:O,cancel:()=>{D=!1},trigger:m=>{D=!0,A(m),D=!1}}:O}function Be(e){const n=t.shallowRef(null),c=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],N=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??c].flat(),q=k=>k?typeof e.initialFocus=="string"?k.querySelector(e.initialFocus)??k:typeof e.initialFocus=="function"?e.initialFocus(k)??k:k.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??k:null,{activate:U,deactivate:H}=Ee.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>q(n.value),...e.focusTrapOptions??{}});let E=null,D=t.ref(null);const w=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const k=(A,x)=>{const C=Array.from(A.querySelectorAll(x));if(!C.length)return null;const O=C.filter(m=>m.offsetParent!==null||m.getClientRects().length>0);return O[O.length-1]??C[C.length-1]??null},$=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const A of N){const x=k($,A);if(x)return x}for(const A of N){const x=k(document,A);if(x)return x}return null};return Ve(n,k=>{D.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",k)}),t.watch(()=>e.isOpen.value,k=>{k?(D.value=null,t.nextTick(()=>{const $=w();$&&(n.value=$,setTimeout(()=>U(),0),E||(E=A=>{A.key==="Escape"&&(D.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",A))},document.addEventListener("keydown",E,!0)))})):(H(),E&&(document.removeEventListener("keydown",E,!0),E=null),n.value=null,D.value==="outside"&&t.nextTick(()=>{const $=()=>{const A=e.triggerEl?.value,x=A?.querySelector("input"),C=document.activeElement;C&&(C===x||A&&A.contains(C))&&(x??A)?.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 A=e.triggerEl?.value;if(!A)return;(A.querySelector("input")??A)?.focus?.()};requestAnimationFrame(()=>setTimeout($,0))})))}),{popupRef:n,activate:U,deactivate:H,lastCloseReason:t.readonly(D),setPopupEl:k=>n.value=k}}ne.useGridA11y=Me,ne.useGridActiveFilter=Ce,ne.useMaskedDateInput=Pe,ne.useMaskedDateRangeInput=Ie,ne.useMaskedTimeInput=Le,ne.usePopupTrap=Be,Object.defineProperty(ne,Symbol.toStringTag,{value:"Module"})}));
@@ -1 +1,2 @@
1
- export { useGridA11y } from "../useGridA11y";
1
+ export { useGridA11y } from "./useGridA11y";
2
+ export { useGridActiveFilter } from "./useGridActiveFilter";
@@ -5,7 +5,7 @@
5
5
  * focus management, and custom behaviors for column header menus (filter/sort).
6
6
  */
7
7
  import { type Ref } from "vue";
8
- import type { GridSortChangeEvent } from "./types/kendo";
8
+ import type { GridSortChangeEvent } from "../types/kendo";
9
9
  export declare const useGridA11y: (gridRef: Ref<any>, options?: {
10
10
  focusableMenuSelectors?: string[];
11
11
  }) => {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { type Ref } from "vue";
2
+ import type { CompositeFilterDescriptor } from "@progress/kendo-data-query";
3
+ /**
4
+ * Returns a reactive function that resolves to `"active"` when the given
5
+ * field has a filter applied in the current filter tree, or `""` when it
6
+ * does not.
7
+ *
8
+ * Bind the returned function directly to column `headerClassName` inside a
9
+ * `computed` — Vue tracks the `filterRef` dependency automatically; no
10
+ * manual update call is needed.
11
+ *
12
+ * @param filterRef - Reactive grid filter descriptor (the same ref bound to the Grid).
13
+ * @returns `(field: string) => "active" | ""`
14
+ *
15
+ * @example
16
+ * const activeClass = useGridActiveFilter(filterRef);
17
+ *
18
+ * const columns = computed(() => [
19
+ * { field: "ProductName", headerClassName: activeClass("ProductName") },
20
+ * ]);
21
+ */
22
+ export declare const useGridActiveFilter: (filterRef: Ref<CompositeFilterDescriptor | undefined>) => ((field: string) => string);
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -6,4 +6,3 @@ export type { RangeChangePayload } from "./range";
6
6
  export { useMaskedTimeInput } from "./time";
7
7
  export type { ChangePayload as TimeChangePayload } from "./time";
8
8
  export { usePopupTrap } from "./trap";
9
- export { useGridFilter } from "./useGridFilter";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,108 @@
1
+ # useGridActiveFilter
2
+
3
+ [← Back to Composables README](https://github.com/NantHealth/featherk/blob/integration/packages/composables/README.md)
4
+
5
+ Composable that tracks active Grid filter state by field and provides a resolver function you can bind to Grid column definitions.
6
+
7
+ ## Prerequisites
8
+
9
+ - Vue 3 Composition API
10
+ - `@progress/kendo-data-query`
11
+ - `@progress/kendo-vue-grid`
12
+ - `@featherk/composables`
13
+
14
+ Install:
15
+
16
+ ```bash
17
+ npm install @featherk/composables
18
+ ```
19
+
20
+ ## Compatibility
21
+
22
+ - Built and tested with Kendo UI for Vue Grid v6.4.1.
23
+
24
+ ## Import
25
+
26
+ `useGridActiveFilter` is exported from the package root:
27
+
28
+ ```ts
29
+ import { useGridActiveFilter } from "@featherk/composables";
30
+ ```
31
+
32
+ ## Quick Start
33
+
34
+ ```ts
35
+ import { computed, ref } from "vue";
36
+ import type { CompositeFilterDescriptor } from "@progress/kendo-data-query";
37
+ import type { GridFilterChangeEvent, GridColumnProps } from "@progress/kendo-vue-grid";
38
+ import { useGridActiveFilter } from "@featherk/composables";
39
+
40
+ const filter = ref<CompositeFilterDescriptor | undefined>(undefined);
41
+
42
+ const activeClass = useGridActiveFilter(filter);
43
+
44
+ const columns = computed<GridColumnProps[]>(() => [
45
+ {
46
+ field: "ProductName",
47
+ title: "Product Name",
48
+ filterable: true,
49
+ headerClassName: activeClass("ProductName"),
50
+ },
51
+ {
52
+ field: "Category",
53
+ title: "Category",
54
+ filterable: true,
55
+ headerClassName: activeClass("Category"),
56
+ },
57
+ ]);
58
+
59
+ const filterChange = (event: GridFilterChangeEvent) => {
60
+ filter.value = event.filter;
61
+ };
62
+ ```
63
+
64
+ Template bindings (essentials shown):
65
+
66
+ ```html
67
+ <Grid
68
+ :columns="columns"
69
+ :filter="filter"
70
+ @filterchange="filterChange" />
71
+ ```
72
+
73
+ ## API
74
+
75
+ ### `useGridActiveFilter(filterRef: Ref<CompositeFilterDescriptor | undefined>)`
76
+
77
+ Returns a resolver function for generating field-based class flags.
78
+
79
+ - **Returns** `(field: string) => "active" | ""`
80
+ - Call the returned function inside a `computed` with the column's field name.
81
+ - Returns `"active"` when a filter exists for that field, or `""` when it does not.
82
+ - Vue tracks the `filterRef` dependency automatically — no manual update call is needed.
83
+
84
+ ## Behavior Notes
85
+
86
+ - Handles nested filter groups recursively.
87
+ - Ignores malformed/unknown filter nodes safely.
88
+ - If `filterRef` is `undefined` or has no filters, all fields resolve to `""`.
89
+
90
+ ## Typical Usage Pattern
91
+
92
+ 1. Keep a single `filter` ref that is passed to the Grid and to `useGridActiveFilter`.
93
+ 2. Call `useGridActiveFilter(filter)` once to get the `activeClass` resolver.
94
+ 3. Inside a `computed` column definition, bind `activeClass("fieldName")` to each filterable column's `headerClassName`.
95
+ 4. In `@filterchange`, set `filter.value = event.filter` — Vue reactivity handles the rest.
96
+
97
+ ## Styling
98
+
99
+ The composable only provides class state and does not ship CSS.
100
+
101
+ Example:
102
+
103
+ ```css
104
+ .k-grid .k-header.active {
105
+ font-weight: 600;
106
+ text-decoration: underline;
107
+ }
108
+ ```
@@ -78,7 +78,7 @@ usePopupTrap({
78
78
  @change="range.handleChange"
79
79
  @keydown="range.handleKeyDown"
80
80
  @keyup="range.handleKeyUp"
81
- @wheel.prevent="range.handleWheel"
81
+ @wheel="range.handleWheel"
82
82
  @click="range.handleClick"
83
83
  @blur="range.handleBlur"
84
84
  >
@@ -189,7 +189,7 @@ Key event bindings:
189
189
  - `@change="range.handleChange"`
190
190
  - `@keydown="range.handleKeyDown"`
191
191
  - `@keyup="range.handleKeyUp"`
192
- - `@wheel.prevent="range.handleWheel"`
192
+ - `@wheel="range.handleWheel"`
193
193
  - `@click="range.handleClick"`
194
194
  - `@blur="range.handleBlur"`
195
195
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@featherk/composables",
3
- "version": "0.6.19",
3
+ "version": "0.7.0",
4
4
  "main": "dist/featherk-composables.umd.js",
5
5
  "module": "dist/featherk-composables.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -43,7 +43,9 @@
43
43
  "scripts": {
44
44
  "build": "vite build && npm run build:types",
45
45
  "build:types": "vue-tsc --emitDeclarationOnly --declaration --declarationDir dist",
46
- "test": "vitest",
46
+ "test": "vitest --config vitest.config.ts",
47
+ "test:run": "vitest run --config vitest.config.ts",
48
+ "test:coverage": "vitest run --config vitest.config.ts --coverage",
47
49
  "clean": "rm -rf dist",
48
50
  "prepublishOnly": "npm run build"
49
51
  },
@@ -67,6 +69,7 @@
67
69
  "devDependencies": {
68
70
  "@types/node": "^24.5.2",
69
71
  "@vitejs/plugin-vue": "^6.0.1",
72
+ "@vue/test-utils": "^2.4.6",
70
73
  "@vueuse/core": "^13.5.0",
71
74
  "@vueuse/integrations": "^13.5.0",
72
75
  "focus-trap": "^7.6.0",
@@ -1,7 +0,0 @@
1
- import { type Ref } from "vue";
2
- import type { CompositeFilterDescriptor } from "@progress/kendo-data-query";
3
- export declare const useGridFilter: (filterRef: Ref<CompositeFilterDescriptor | undefined>) => {
4
- activeClasses: Ref<Record<string, string>, Record<string, string>>;
5
- hasFieldFilter: (field: string) => boolean;
6
- updateActiveClass: (field: string) => void;
7
- };