@featherk/composables 0.6.3 → 0.6.4
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(Z,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):(Z=typeof globalThis<"u"?globalThis:Z||self,t(Z.FeatherKComposables={},Z.Vue,Z.useFocusTrap))})(this,(function(Z,t,we){"use strict";const ke=e=>{const r=t.ref(null);let f=!1,L=null,q=null;const K=[],N=".k-table-row[data-grid-row-index] [tabindex]",A=()=>e?.value?.columns,k=a=>{const p=a.key||a.code;[" ","Spacebar","Space","Enter"].includes(p)&&(a.preventDefault(),a.stopPropagation(),r.value=a.target,a.target.click())},b=a=>{if(!r.value)return;if(a.code==="Escape"){a.preventDefault(),a.stopPropagation(),r.value&&r.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(a.code==="Tab"){const u=[".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(u.join(",")));if(y.length===0)return;const x=y.findIndex(P=>P===document.activeElement);let w;x===-1?w=0:a.shiftKey?w=(x-1+y.length)%y.length:w=(x+1)%y.length,a.preventDefault(),a.stopPropagation(),y[w]?.focus();return}}else if(a.code==="ArrowUp"||a.code==="ArrowDown"){a.preventDefault(),a.stopPropagation();const u=p.findIndex(x=>x===document.activeElement);let y=u;a.code==="ArrowUp"?y=u>0?u-1:p.length-1:a.code==="ArrowDown"&&(y=u<p.length-1?u+1:0),p[y]?.focus();return}a.code==="Tab"&&(a.preventDefault(),a.stopPropagation(),a.shiftKey?(r.value?.previousElementSibling).focus():(r.value?.nextElementSibling).focus())},D=()=>{L=new MutationObserver(a=>{a.forEach(p=>{p.addedNodes.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const u=i;if(u.classList.contains("k-animation-container")){const x=r.value;x&&(x.dataset.featherKSortable==="true"||t.nextTick(()=>{u.querySelectorAll(".k-columnmenu-item-wrapper").forEach(H=>{H.textContent?.toLowerCase().includes("sort")&&H.remove()})})),u.addEventListener("keydown",b),t.nextTick(()=>{const w=()=>{const P=Array.from(u.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(),w.attempts=0;else if(P.length>1){w.attempts=0;return}else w.attempts===void 0&&(w.attempts=0),w.attempts++<3&&setTimeout(w,200)};w()})}u.querySelectorAll(".k-animation-container").forEach(x=>{x.addEventListener("keydown",b)})}}),p.removedNodes.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const u=i;u.classList.contains("k-animation-container")&&u.removeEventListener("keydown",b),u.querySelectorAll(".k-animation-container").forEach(x=>{x.removeEventListener("keydown",b)})}})})}),L.observe(document.body,{childList:!0,subtree:!0})},C=a=>{if(!a.type||!a)return;const p=a.target;if(p){if(a.code==="Escape"){const i=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(i){a.preventDefault(),a.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(a.code)){if(a.preventDefault(),p.classList.contains("k-grid-header-menu")&&p.classList.contains("k-grid-column-menu")){r.value=p;return}const i=p.closest(".k-table-row[data-grid-row-index]");if(i){if(["ArrowDown","ArrowUp"].includes(a.code)){const u=(x,w)=>{let P=w==="next"?x.nextElementSibling:x.previousElementSibling;for(;P;){const H=P;try{if(H.hasAttribute&&H.classList.contains("k-table-row"))return H}catch{}P=w==="next"?P.nextElementSibling:P.previousElementSibling}return null},y=a.code==="ArrowDown"?u(i,"next"):u(i,"previous");y&&(i.setAttribute("tabindex","-1"),y.setAttribute("tabindex","0"),y.focus());return}if(["ArrowLeft","ArrowRight"].includes(a.code)){a.preventDefault();const u=i.querySelectorAll(N);if(u.length===0)return;let y=Array.from(u).findIndex(x=>x===document.activeElement);if(y===-1&&document.activeElement===i){u[0].focus();return}a.code==="ArrowRight"?y=y===u.length-1?0:y+1:a.code==="ArrowLeft"&&(y=y===u.length-1?y-1:u.length-1),u[y].focus();return}}}}},E=()=>{t.nextTick(()=>{const a=e.value.$el.closest(".k-grid");a&&a.classList.add("fk-grid")})},S=()=>{if(!q)try{const a=()=>{try{const u=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!u||u.length===0||u.filter(w=>w.getAttribute("tabindex")==="0").length===1)return;const x=u.find(w=>w===document.activeElement||w.contains(document.activeElement));if(u.forEach(w=>w.setAttribute("tabindex","-1")),x){x.setAttribute("tabindex","0");return}u[0].setAttribute("tabindex","0")}catch(u){console.error("ensureSingleTabindex error:",u)}},p=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));p.length>0&&p.forEach((u,y)=>{u.setAttribute("tabindex",y===0?"0":"-1")});const i=e.value.$el.querySelector(".k-table-tbody");i&&(q=new MutationObserver(()=>{a()}),q.observe(i,{childList:!0,subtree:!0}))}catch(a){console.error("Error setting up row navigation:",a)}},$=()=>{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",k)}),D(),m()})},F=()=>{const p=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");p&&p.forEach(i=>{i.removeEventListener("keydown",k)}),L&&(L.disconnect(),L=null),q&&(q.disconnect(),q=null),K.forEach(i=>i()),K.length=0},m=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((i,u)=>{const y=i.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!y)return;const x=A();if(x&&x[u]){const B=x[u].field??"";i.setAttribute("data-feather-k-field",B),i.setAttribute("data-feather-k-filterable",x[u].filterable===!1?"false":"true"),i.setAttribute("data-feather-k-sortable",x[u].sortable===!1?"false":"true")}const w=i.dataset.featherKFilterable!=="false",P=i.dataset.featherKSortable!=="false";y.setAttribute("tabindex","-1"),w||P?i.style.cursor="pointer":i.style.cursor="default",w?(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=B=>{B.target?.closest(".k-column-resizer")||(r.value=i,y.click())},G=B=>{if(w)r.value=i,B.preventDefault(),B.stopPropagation(),H(B);else if(P){r.value=i;const _=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0});i.dispatchEvent(_)}};i.addEventListener("click",G),K.push(()=>{i.removeEventListener("click",G)});const te=B=>{if((B.code==="Enter"||B.code==="Space")&&(w||P)){if(r.value=i,r.value.focus(),w)B.preventDefault(),B.stopPropagation(),H(B);else if(P){const _=i.querySelector(".k-link");_&&_.click()}}};i.addEventListener("keydown",te,!0),K.push(()=>{i.removeEventListener("keydown",te,!0)})});const p=document.querySelector(".k-grid-header .k-table-thead");if(p){const i=u=>{const y=u.target.closest("th");y&&(u.code==="Enter"||u.code==="Space")&&y.dataset.featherKFilterable==="false"&&y.dataset.featherKSortable==="false"&&(u.preventDefault(),u.stopImmediatePropagation())};p.addEventListener("keydown",i,!0),K.push(()=>{p.removeEventListener("keydown",i,!0)})}},h=function(a,p){const i=a?.event.event.target,u=A();if(!i||!u)return;const y=i.classList.contains("k-link"),x=i.classList.contains("k-columnmenu-item"),w=u.find(P=>P.field===a.event.field)?.sortable&&!0;if(!y){if(x&&!w){(a.event.sort&&void 0)?.filter(H=>H.field!==a.event.field);return}typeof p=="function"&&t.nextTick(()=>{r.value&&r.value.focus(),p(a)})}},U=()=>{if(!f)try{E(),S(),$(),f=!0}catch(a){console.error("initA11y failed:",a),F()}};return t.onBeforeUnmount(()=>{F()}),{activeFilterButton:r,handleGridKeyDown:C,handleSortChange:h,initA11y:U}};function De(e){const r=t.ref(""),f=t.ref(void 0),L=t.ref(!!e.debug),q=t.ref(e.dateFormat??"mm/dd/yyyy"),K=t.computed(()=>!!e.required),N=t.ref(!1),A=["ArrowUp","ArrowDown"],k=["ArrowLeft","ArrowRight"],b=t.computed(()=>(r.value??"").replace(/\D/g,"")),D=l=>l<=2?"mm":l<=5?"dd":b.value.length<=10?"yyyy":"mm",C=t.computed(()=>{const l=r.value&&r.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(l).toString().padStart(2,"0")}),E=t.computed(()=>{const l=r.value&&r.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(l).toString().padStart(2,"0")}),S=t.computed(()=>{const l=r.value&&r.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(l).toString().padStart(4,"0")}),$=l=>{if(b.value.length===0){e.onChange({value:null,event:l});return}if(b.value.length<8){e.onChange({value:null,event:l});return}if((r.value??"").length===10&&b.value.length===8){const[d,I,J]=r.value.split("/"),o=parseInt(d),s=parseInt(I),v=parseInt(J);if(a(v,o,s)){const T=new Date(v,o-1,s);F(T)?e.onChange({value:T,event:l}):e.onChange({value:null,event:l})}else e.onChange({value:null,event:l})}},F=l=>{const d=e.min??void 0,I=e.max??void 0;return!(d&&l<d||I&&l>I)},m=t.computed(()=>{if((r.value??"").length===10&&b.value.length===8){const[l,d,I]=(r.value??"").split("/"),J=parseInt(l),o=parseInt(d),s=parseInt(I);if(a(s,J,o))return new Date(s,J-1,o)}return null}),h=t.computed(()=>(r.value??"").length===10&&b.value.length===8),U=(l,d)=>new Date(l,d,0).getDate(),a=(l,d,I)=>d>=1&&d<=12&&l>=1900&&I>=1&&I<=U(l,d),p=l=>{r.value=l.value;const d=l.event?.target;f.value=d?.selectionStart??0,$(l)},i=l=>{f.value=l.target.selectionStart??0},u=(l,d,I)=>{const J=d?.selectionStart??f.value??0;f.value=J;let o=parseInt(C.value),s=parseInt(E.value),v=parseInt(S.value);if(!(b.value.length>=8)||!a(v,o,s)){const j=e.defaultValue??new Date;o=j.getMonth()+1,s=j.getDate(),v=j.getFullYear(),r.value=`${String(o).padStart(2,"0")}/${String(s).padStart(2,"0")}/${String(v)}`;const n=new Date(v,o-1,s);e.onChange({value:F(n)?n:null,event:I}),t.nextTick(()=>{requestAnimationFrame(()=>{const c=document.getElementById(e.id),g=f.value??0;c&&(c.focus(),c.setSelectionRange(g,g))})});return}const R=D(J);if(R==="mm")o=l==="ArrowUp"?o<12?o+1:1:o>1?o-1:12;else if(R==="dd"){const j=new Date(v,o,0).getDate();s=l==="ArrowUp"?s<j?s+1:1:s>1?s-1:j}else R==="yyyy"&&(v=l==="ArrowUp"?v+1:Math.max(1,v-1));r.value=`${String(o).padStart(2,"0")}/${String(s).padStart(2,"0")}/${String(v)}`;const[ee,W,Y]=r.value.split("/"),ne=new Date(parseInt(Y),parseInt(ee)-1,parseInt(W));ne.toString()!=="Invalid Date"&&parseInt(Y)>=1e3?e.onChange({value:F(ne)?ne:null,event:I}):e.onChange({value:null,event:I}),t.nextTick(()=>{requestAnimationFrame(()=>{const j=document.getElementById(e.id),n=f.value??0;j&&(j.focus(),j.setSelectionRange(n,n))})})},y=l=>{if(l.code==="Space"||l.key===" "){e.onShowCalendar(l);return}if(A.includes(l.key)){l.preventDefault();const d=l.target;u(l.key,d,l)}},x=l=>{l.preventDefault();const d=l.deltaY<0?"ArrowUp":"ArrowDown";u(d,l.target,l)},w=l=>{const d=l.target;if(k.includes(l.key)){f.value=d?.selectionStart??0;return}A.includes(l.key)&&(l.preventDefault(),f.value=d?.selectionStart??0)},P=l=>{N.value=!0,K.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&b.value.length===0&&(e.externalValue.value="");const d=l.target;d&&(f.value=d.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,l=>{if(l){const d=new Date(l);if(d.toString()!=="Invalid Date"){const I=(d.getMonth()+1).toString().padStart(2,"0"),J=d.getDate().toString().padStart(2,"0"),o=d.getFullYear().toString();r.value=`${I}/${J}/${o}`;return}}},{immediate:!0});const H=t.computed(()=>[["Date",`${C.value} / ${E.value} / ${S.value}`],["Digits only",b.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(!K.value){if(!h.value)return!0;const d=m.value;return d?F(d):!1}if(!N.value)return!0;const l=m.value;return!h.value||!l?!1:F(l)}),te=t.computed(()=>{if(!K.value){if(!h.value)return;const d=m.value;return d?F(d)?"valid":"out-of-bounds":"invalid-date"}if(!N.value)return;if(b.value.length===0||!h.value)return"incomplete";const l=m.value;return l?F(l)?"valid":"out-of-bounds":"invalid-date"}),B=t.computed(()=>{const l=te.value;if(!l||l==="valid")return"";if(l==="incomplete")return"Required";if(l==="invalid-date")return`Must be in ${q.value} format.`;const d=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(l==="out-of-bounds"){if(d&&I)return`Must be between ${d} and ${I}.`;if(d)return`Must be on or after ${d}.`;if(I)return`Must be on or before ${I}.`}return""}),_=()=>{t.nextTick(()=>{const l=document.getElementById(e.id);if(!l){console.warn(`ID (#${e.id}) not found for styling.`);return}const d=l.closest(".k-datepicker");if(d){const I=d.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:r,cursorPos:f,debugEnabled:L,debugLines:H,placeholder:q,isValid:G,reason:t.readonly(te),validationMessage:B,digitsOnly:b,month:t.readonly(C),day:t.readonly(E),year:t.readonly(S),datePart:D,handleChange:p,handleKeyDown:y,handleWheel:x,handleKeyUp:w,handleClick:i,handleBlur:P}}function Ae(e){const r=t.ref(""),f=t.ref(void 0),L=t.ref(!!e.debug),q=t.ref(!1),N=365*(1440*60*1e3),A=new Date,k=new Date(A.getTime()-N),b=new Date(A.getTime()+N);e.min=e.min??k,e.max=e.max??b;const D=t.computed(()=>(r.value??"").replace(/\D/g,"")),C=(n,c)=>new Date(n,c,0).getDate(),E=(n,c,g)=>c>=1&&c<=12&&n>=1e3&&g>=1&&g<=C(n,c),S=n=>Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()),$=n=>{if(!n)return null;const c=e.min,g=e.max,M=S(n);return M<S(c)||M>S(g)?null:n},F=(n,c)=>e.allowReverse??!1?!0:n<=c,m=t.computed(()=>(r.value?.length??0)>=23&&D.value.length>=16),h=n=>{if((n??"").length<23||D.value.length<16)return{start:null,end:null};const c=n.substring(0,10),g=n.substring(13,23),[M,V,z]=c.split("/").map(oe=>parseInt(oe||"0",10)),[ce,le,ie]=g.split("/").map(oe=>parseInt(oe||"0",10)),se=new Date(z,M-1,V),de=new Date(ie,ce-1,le),ye=E(z,M,V)&&se.toString()!=="Invalid Date",ge=E(ie,ce,le)&&de.toString()!=="Invalid Date";return{start:ye?se:null,end:ge?de:null}},U=e.externalValid??t.ref(void 0),a=t.computed(()=>h(r.value)),p=t.computed(()=>{const n=$(a.value.start),c=$(a.value.end);return{start:n,end:c}}),i=t.computed(()=>{if(!m.value)return;const n=p.value.start,c=p.value.end;if(!n||!c)return;const g=V=>Date.UTC(V.getFullYear(),V.getMonth(),V.getDate()),M=Math.abs(g(c)-g(n));return Math.round(M/864e5)}),u=t.computed(()=>{const{start:n,end:c}=a.value;if(!m.value)return;if(!n||!c||!p.value.start||!p.value.end)return!1;const g=p.value.start,M=p.value.end;return!(!F(g,M)||typeof e.maxSpanDays=="number"&&i.value!==void 0&&i.value>e.maxSpanDays)}),y=t.computed(()=>{const{start:n,end:c}=a.value;if(!m.value)return"incomplete";if(!n||!c)return"invalid-date";if(!p.value.start||!p.value.end)return"out-of-bounds";const g=p.value.start,M=p.value.end;return F(g,M)?typeof e.maxSpanDays=="number"&&i.value!==void 0&&i.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),x=t.computed(()=>{const{start:n,end:c}=a.value,{min:g,max:M}=e;switch(console.table({start:n,end:c,min:g,max:M}),y.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&&(S(n)<S(g)||S(c)<S(g)||S(n)>S(M)||S(c)>S(M))?`Dates must be between ${G(g)} and ${G(M)}.`:"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(u,n=>{(e.manageValid??!0)&&(U.value=n)},{immediate:!0});const w=["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)}`,te=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"},B=(n,c,g)=>{const M=c?.selectionStart??f.value??0;f.value=M;const{start:V,end:z}=h(r.value);if(!V&&!z){const O=new Date,re=G(O);r.value=`${re} - ${re}`,e.onChange({value:{start:O,end:O},event:g}),t.nextTick(()=>{requestAnimationFrame(()=>{const X=document.getElementById(e.id),Q=f.value??0;X&&(X.focus(),X.setSelectionRange(Q,Q))})});return}const ce=new Date,le=te(M);let ie=V?new Date(V):new Date(ce),se=z?new Date(z):new Date(ce);const de=(O,re)=>{if(re==="mm"){const X=O.getMonth()+1,Q=n==="ArrowUp"?X<12?X+1:1:X>1?X-1:12;O.setMonth(Q-1);const fe=C(O.getFullYear(),Q);O.getDate()>fe&&O.setDate(fe)}else if(re==="dd"){const X=C(O.getFullYear(),O.getMonth()+1),Q=O.getDate(),fe=n==="ArrowUp"?Q<X?Q+1:1:Q>1?Q-1:X;O.setDate(fe)}else if(re==="yyyy"){const X=O.getFullYear();O.setFullYear(n==="ArrowUp"?X+1:Math.max(1,X-1));const Q=C(O.getFullYear(),O.getMonth()+1);O.getDate()>Q&&O.setDate(Q)}};le.side==="start"?de(ie,le.part):de(se,le.part);const ye=G(ie),ge=G(se);r.value=`${ye} - ${ge}`;const oe=$(ie),he=$(se);oe&&he&&F(oe,he)?e.onChange({value:{start:oe,end:he},event:g}):e.onChange({value:null,event:g}),t.nextTick(()=>{requestAnimationFrame(()=>{const O=document.getElementById(e.id),re=f.value??0;O&&(O.focus(),O.setSelectionRange(re,re))})})},_=n=>{const{start:c,end:g}=h(r.value);if(!c||!g){e.onChange({value:null,event:n});return}const M=$(c),V=$(g);if(!M||!V){e.onChange({value:null,event:n});return}if(!F(M,V)){e.onChange({value:null,event:n});return}e.onChange({value:{start:M,end:V},event:n})},l=n=>{r.value=n.value;const c=n.event?.target;f.value=c?.selectionStart??0,_(n)},d=n=>{f.value=n.target.selectionStart??0},I=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(w.includes(n.key)){n.preventDefault();const c=n.target;B(n.key,c,n)}},J=n=>{n.preventDefault();const c=n.deltaY<0?"ArrowUp":"ArrowDown";B(c,n.target,n)},o=n=>{if(P.includes(n.key)||w.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,g=n?.end??null;if(c&&g){if(r.value=`${G(c)} - ${G(g)}`,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},M)}return}},{immediate:!0});const s=t.computed(()=>r.value&&r.value.substring(0,2).replace(/\D/g,"0")||"0"),v=t.computed(()=>r.value&&r.value.substring(3,5).replace(/\D/g,"0")||"0"),T=t.computed(()=>r.value&&r.value.substring(6,10).replace(/\D/g,"0")||"0"),R=t.computed(()=>r.value&&r.value.substring(13,15).replace(/\D/g,"0")||"0"),ee=t.computed(()=>r.value&&r.value.substring(16,18).replace(/\D/g,"0")||"0"),W=t.computed(()=>r.value&&r.value.substring(19,23).replace(/\D/g,"0")||"0"),Y=t.computed(()=>{const{start:n,end:c}=h(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(s.value).padStart(2,"0")} / ${String(v.value).padStart(2,"0")} / ${String(T.value).padStart(4,"0")}`},{label:"End",value:`${String(R.value).padStart(2,"0")} / ${String(ee.value).padStart(2,"0")} / ${String(W.value).padStart(4,"0")}`},{label:"Digits only",value:D.value},{label:"Mask complete",value:`${m.value}`},{label:"Parsed",value:`${n?n.toDateString():"-"} | ${c?c.toDateString():"-"}`},{label:"Valid (managed)",value:`${U.value??"-"}`},{label:"Span (days)",value:`${i.value??"-"}`},{label:"Reason",value:`${y.value??"-"}`},{label:"Cursor in",value:`${f.value??"-"} (${(()=>{const g=f.value??0,M=te(g);return`${M.side}.${M.part}`})()})`}]}),ne=()=>{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(()=>{ne()});const j=()=>{t.nextTick(()=>{try{const n=Array.from(document.querySelectorAll(".k-animation-container"));if(!n.length)return;const g=[...n].reverse().find(z=>z.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!g)return;const M=g.querySelectorAll(".k-calendar-table");let V=!1;M.forEach(z=>{z.tabIndex===0&&(V?z.tabIndex=-1:V=!0)})}catch(n){console.warn(n)}})};return e.isOpen&&t.watch(e.isOpen,n=>{n&&setTimeout(()=>j(),0)},{immediate:!1}),{raw:r,cursorPos:f,debugEnabled:L,debugLines:Y,digitsOnly:D,valid:U,validComputed:t.readonly(u),reason:t.readonly(y),validationMessage:t.readonly(x),spanDays:t.readonly(i),month1:t.readonly(s),day1:t.readonly(v),year1:t.readonly(T),month2:t.readonly(R),day2:t.readonly(ee),year2:t.readonly(W),handleChange:l,handleKeyDown:I,handleWheel:J,handleKeyUp:o,handleClick:d,onCalendarChange:()=>{q.value=!0}}}function Ee(e){const r=t.ref(""),f=t.ref(void 0),L=t.ref(!!e.debug),q=t.ref(e.timeFormat??"hh:mm AM"),K=t.computed(()=>!!e.required),N=t.ref(!1),A=["ArrowUp","ArrowDown"],k=["ArrowLeft","ArrowRight"],b=t.computed(()=>(r.value??"").replace(/\D/g,"")),D={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",E=t.computed(()=>{const o=r.value&&r.value.substring(0,2).replace(/\D/g,"0")||"0",s=parseInt(o);return Math.min(Math.max(s,0),23)}),S=t.computed(()=>{const o=r.value&&r.value.substring(3,5).replace(/\D/g,"0")||"0",s=parseInt(o);return Math.min(Math.max(s,0),59)}),$=t.computed(()=>(r.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),F=t.computed(()=>{const o=parseInt(r.value?.substring(0,2).replace(/\D/g,"0")||"0"),s=$.value;return o===12?s==="AM"?0:12:s==="PM"?o+12:o}),m=t.computed(()=>h.value?`${String(F.value).padStart(2,"0")}:${String(S.value).padStart(2,"0")}:00`:null),h=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(r.value??"")),U=(o,s,v)=>{let T=o%12;return T===0&&(T=12),`${String(T).padStart(2,"0")}:${String(s).padStart(2,"0")} ${v}`},a=o=>{const s=o.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!s)return null;const v=parseInt(s[1]),T=parseInt(s[2]),R=s[3].toUpperCase();if(v<1||v>12||T<0||T>59)return null;let ee=v%12;R==="PM"&&(ee+=12);const W=new Date;return W.setSeconds(0,0),W.setHours(ee),W.setMinutes(T),W},p=o=>{if(b.value.length===0){e.onChange({value:null,event:o});return}if(!h.value){e.onChange({value:null,event:o});return}const s=a(r.value);s&&u(s)?e.onChange({value:s,event:o}):e.onChange({value:null,event:o})},i=o=>o.getHours()*60+o.getMinutes(),u=o=>{const s=e.min??void 0,v=e.max??void 0,T=i(o);if(s){const R=i(s);if(T<R)return!1}if(v){const R=i(v);if(T>R)return!1}return!0},y=o=>{r.value=o.value;const s=o.event?.target;f.value=s?.selectionStart??0;try{const v=f.value??0;if(C(v)==="ampm"&&(r.value??"").length>=8){const T=r.value.charAt(6);/[Aa]/.test(T)?(r.value=`${r.value.slice(0,6)}AM${r.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const R=document.getElementById(e.id);R&&(R.focus(),R.setSelectionRange(8,8))})})):/[Pp]/.test(T)&&(r.value=`${r.value.slice(0,6)}PM${r.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const R=document.getElementById(e.id);R&&(R.focus(),R.setSelectionRange(8,8))})}))}}catch{}p(o)},x=o=>{f.value=o.target.selectionStart??0},w=(o,s,v)=>{const T=s?.selectionStart??f.value??0;f.value=T;const R=C(T),ee=(r.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!ee){if((r.value??"").length===0||b.value.length===0){const n=new Date,c=n.getHours(),g=c>=12?"PM":"AM";r.value=U(c,n.getMinutes(),g);const M=a(r.value);M&&u(M)?e.onChange({value:M,event:v}):e.onChange({value:null,event:v}),t.nextTick(()=>{requestAnimationFrame(()=>{const V=document.getElementById(e.id),z=f.value??0;V&&(V.focus(),V.setSelectionRange(z,z))})})}return}let W=parseInt(ee[1]),Y=parseInt(ee[2]),ne=ee[3].toUpperCase();if(R==="hh")o==="ArrowUp"?W=W<12?W+1:1:W=W>1?W-1:12;else if(R==="mm"){const n=e.minuteStepRef?.value??e.minuteStep??1;if(n===1)o==="ArrowUp"?Y=Y<59?Y+1:0:Y=Y>0?Y-1:59;else if(o==="ArrowUp"){const c=Y%n;let g=c===0?Y+n:Y+(n-c);g>=60&&(g=0),Y=g}else{const c=Y%n;let g=c===0?Y-n:Y-c;g<0&&(g=60-n),Y=g}}else R==="ampm"&&(ne=ne==="AM"?"PM":"AM");r.value=`${String(W).padStart(2,"0")}:${String(Y).padStart(2,"0")} ${ne}`;const j=a(r.value);j&&u(j)?e.onChange({value:j,event:v}):e.onChange({value:null,event:v}),t.nextTick(()=>{requestAnimationFrame(()=>{const n=document.getElementById(e.id),c=f.value??0;n&&(n.focus(),n.setSelectionRange(c,c))})})},P=o=>{if(o.code==="Space"||o.key===" "){e.onShowPicker(o);return}if(A.includes(o.key)){o.preventDefault();const s=o.target;w(o.key,s,o)}},H=o=>{o.preventDefault();const s=o.deltaY<0?"ArrowUp":"ArrowDown";w(s,o.target,o)},G=o=>{const s=o.target;if(k.includes(o.key)){f.value=s?.selectionStart??0;return}A.includes(o.key)&&(o.preventDefault(),f.value=s?.selectionStart??0)},te=o=>{N.value=!0,K.value&&e.externalValue&&e.externalValue.value===void 0&&b.value.length===0&&(e.externalValue.value="");const s=o.target;s&&(f.value=s.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const s=new Date(o);if(s.toString()!=="Invalid Date"){const v=s.getHours(),T=v>=12?"PM":"AM";r.value=U(v,s.getMinutes(),T);return}}},{immediate:!0});const B=t.computed(()=>[["Time",r.value||"--:-- --"],["Hour (12h)",E.value],["Hour (24h)",F.value],["Minute",S.value],["Period",$.value],["Time (24h)",m.value??"--:--:--"],["Digits only",b.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",l.value],["reason",d.value],["validationMessage",I.value]]),_=t.computed(()=>a(r.value)??null),l=t.computed(()=>{if(!K.value){if(!h.value)return!0;const s=_.value;return s?u(s):!1}if(!N.value)return!0;const o=_.value;return!h.value||!o?!1:u(o)}),d=t.computed(()=>{if(!K.value){if(!h.value)return;const s=_.value;return s?u(s)?"valid":"out-of-bounds":"invalid-time"}if(!N.value)return;if(b.value.length===0||!h.value)return"incomplete";const o=_.value;return o?u(o)?"valid":"out-of-bounds":"invalid-time"}),I=t.computed(()=>{const o=d.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-time")return`Must be in ${q.value} format.`;const s={hour:"2-digit",minute:"2-digit"},v=e.min?e.min.toLocaleTimeString("en-US",s):null,T=e.max?e.max.toLocaleTimeString("en-US",s):null;if(o==="out-of-bounds"){if(v&&T)return`Must be between ${v} and ${T}.`;if(v)return`Must be ${v} or later.`;if(T)return`Must be ${T} or earlier.`}return""}),J=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`#${e.id} not found for styling.`);return}const s=o.closest(".k-timepicker");if(!s)console.warn(`.k-timepicker parent of #${e.id} not found for styling.`);else{const v=s.parentElement;v?v.classList.add("fk-timepicker"):console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`)}})};return t.onMounted(()=>{J()}),{raw:r,rules:D,debugEnabled:L,debugLines:B,placeholder:q,isValid:l,reason:t.readonly(d),validationMessage:I,isComplete:h,inRangeTime:u,cursorPos:f,hour:t.readonly(E),hour24:t.readonly(F),minute:t.readonly(S),period:t.readonly($),time24:t.readonly(m),parsedRawTime:t.readonly(_),handleChange:y,handleKeyDown:P,handleKeyUp:G,handleClick:x,handleWheel:H,handleBlur:te}}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=()=>{},$e=Ie();function Ie(){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 Ce(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(A=>A()),r.length=0},L=(A,k,b,D)=>(A.addEventListener(k,b,D),()=>A.removeEventListener(k,b,D)),q=t.computed(()=>{const A=me(t.toValue(e[0])).filter(k=>k!=null);return A.every(k=>typeof k!="string")?A:void 0}),K=Ce(()=>{var A,k;return[(k=(A=q.value)==null?void 0:A.map(b=>ue(b)))!=null?k:[be].filter(b=>b!=null),me(t.toValue(q.value?e[1]:e[0])),me(t.unref(q.value?e[2]:e[1])),t.toValue(q.value?e[3]:e[2])]},([A,k,b,D])=>{if(f(),!A?.length||!k?.length||!b?.length)return;const C=Te(D)?{...D}:D;r.push(...A.flatMap(E=>k.flatMap(S=>b.map($=>L(E,S,$,C)))))},{flush:"post"}),N=()=>{K(),f()};return xe(f),N}let Se=!1;function Pe(e,r,f={}){const{window:L=be,ignore:q=[],capture:K=!0,detectIframe:N=!1,controls:A=!1}=f;if(!L)return A?{stop:ae,cancel:ae,trigger:ae}:ae;if($e&&!Se){Se=!0;const m={passive:!0};Array.from(L.document.body.children).forEach(h=>h.addEventListener("click",ae,m)),L.document.documentElement.addEventListener("click",ae,m)}let k=!0;const b=m=>t.toValue(q).some(h=>{if(typeof h=="string")return Array.from(L.document.querySelectorAll(h)).some(U=>U===m.target||m.composedPath().includes(U));{const U=ue(h);return U&&(m.target===U||m.composedPath().includes(U))}});function D(m){const h=t.toValue(m);return h&&h.$.subTree.shapeFlag===16}function C(m,h){const U=t.toValue(m),a=U.$.subTree&&U.$.subTree.children;return a==null||!Array.isArray(a)?!1:a.some(p=>p.el===h.target||h.composedPath().includes(p.el))}const E=m=>{const h=ue(e);if(m.target!=null&&!(!(h instanceof Element)&&D(e)&&C(e,m))&&!(!h||h===m.target||m.composedPath().includes(h))){if("detail"in m&&m.detail===0&&(k=!b(m)),!k){k=!0;return}r(m)}};let S=!1;const $=[pe(L,"click",m=>{S||(S=!0,setTimeout(()=>{S=!1},0),E(m))},{passive:!0,capture:K}),pe(L,"pointerdown",m=>{const h=ue(e);k=!b(m)&&!!(h&&!m.composedPath().includes(h))},{passive:!0}),N&&pe(L,"blur",m=>{setTimeout(()=>{var h;const U=ue(e);((h=L.document.activeElement)==null?void 0:h.tagName)==="IFRAME"&&!U?.contains(L.document.activeElement)&&r(m)},0)},{passive:!0})].filter(Boolean),F=()=>$.forEach(m=>m());return A?{stop:F,cancel:()=>{k=!1},trigger:m=>{k=!0,E(m),k=!1}}:F}function Le(e){const r=t.shallowRef(null),f=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],L=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??f].flat(),q=D=>D?typeof e.initialFocus=="string"?D.querySelector(e.initialFocus)??D:typeof e.initialFocus=="function"?e.initialFocus(D)??D:D.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??D:null,{activate:K,deactivate:N}=we.useFocusTrap(r,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>r.value,initialFocus:()=>q(r.value),...e.focusTrapOptions??{}});let A=null,k=t.ref(null);const b=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const D=(E,S)=>{const $=Array.from(E.querySelectorAll(S));if(!$.length)return null;const F=$.filter(m=>m.offsetParent!==null||m.getClientRects().length>0);return F[F.length-1]??$[$.length-1]??null},C=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const E of L){const S=D(C,E);if(S)return S}for(const E of L){const S=D(document,E);if(S)return S}return null};return Pe(r,D=>{k.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",D)}),t.watch(()=>e.isOpen.value,D=>{D?(k.value=null,t.nextTick(()=>{const C=b();C&&(r.value=C,setTimeout(()=>K(),0),A||(A=E=>{E.key==="Escape"&&(k.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",E))},document.addEventListener("keydown",A,!0)))})):(N(),A&&(document.removeEventListener("keydown",A,!0),A=null),r.value=null,k.value==="outside"&&t.nextTick(()=>{const C=()=>{const E=e.triggerEl?.value,S=E?.querySelector("input"),$=document.activeElement;$&&($===S||E&&E.contains($))&&(S??E)?.blur?.()};requestAnimationFrame(()=>setTimeout(C,0))}),e.returnFocusToTrigger!==!1&&k.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const C=()=>{const E=e.triggerEl?.value;if(!E)return;(E.querySelector("input")??E)?.focus?.()};requestAnimationFrame(()=>setTimeout(C,0))})))}),{popupRef:r,activate:K,deactivate:N,lastCloseReason:t.readonly(k),setPopupEl:D=>r.value=D}}Z.useGridA11y=ke,Z.useMaskedDateInput=De,Z.useMaskedDateRangeInput=Ae,Z.useMaskedTimeInput=Ee,Z.usePopupTrap=Le,Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -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`
|
|
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
|
|
|
@@ -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
|
|
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
|
|
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
|
|