vue-a11y-directives 1.2.1 → 1.2.2

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
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=["BUTTON","A","INPUT","TEXTAREA","SELECT","IFRAME"],F={mounted(e,a){const t=typeof a.value=="object"?a.value:{delay:a.value||0},n=t.delay||0,i=t.select||!1;R.includes(e.tagName)||e.hasAttribute("tabindex")||e.hasAttribute("contenteditable")||(e.setAttribute("tabindex","0"),e.__a11yFocusAddedTabindex=!0),setTimeout(()=>{e.focus&&(e.focus(),i&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")&&e.select())},n)},unmounted(e){e.__a11yFocusAddedTabindex&&(e.removeAttribute("tabindex"),delete e.__a11yFocusAddedTabindex)}};function _(e){if(!e)return[];const a=["a[href]","button:not([disabled])","textarea:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"audio[controls]","video[controls]"];return Array.from(e.querySelectorAll(a.join(", "))).filter(n=>{const i=window.getComputedStyle(n);return n.offsetWidth>0&&n.offsetHeight>0&&i.visibility!=="hidden"&&i.display!=="none"})}function E(e,a){Object.entries(a).forEach(([t,n])=>{n!=null&&e.setAttribute(t,n)})}function B(e,a){a.forEach(t=>{e.removeAttribute(t)})}function g(e,a="polite"){const t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-live",a),t.setAttribute("aria-atomic","true"),t.style.position="absolute",t.style.left="-10000px",t.style.width="1px",t.style.height="1px",t.style.overflow="hidden",document.body.appendChild(t),setTimeout(()=>{t.textContent=e},100),setTimeout(()=>{document.body.removeChild(t)},3e3)}function W(e){const a=_(e);return a.length>0?a[0]:null}function V(e){const a=_(e);return a.length>0?a[a.length-1]:null}function X(e){return e.contains(document.activeElement)}function $(){return document.activeElement}function J(e){e&&e.focus&&e.focus()}function G(e="a11y"){return`${e}-${Math.random().toString(36).substr(2,9)}`}const O={mounted(e,a){const t=a.value||{},n=t.autoFocus!==!1,i=t.onEscape||null,r=document.activeElement;e.__previousFocus=r,n&&setTimeout(()=>{const u=_(e);u.length>0&&u[0].focus()},100);const o=u=>{if(u.key!=="Tab")return;const y=_(e);if(y.length===0)return;const k=y[0],A=y[y.length-1];u.shiftKey&&document.activeElement===k?(u.preventDefault(),A.focus()):!u.shiftKey&&document.activeElement===A&&(u.preventDefault(),k.focus())},d=u=>{u.key==="Escape"&&i&&(u.preventDefault(),u.stopPropagation(),i())};e.addEventListener("keydown",o),e.__handleKeydown=o,i&&(document.addEventListener("keydown",d,!0),e.__handleEscape=d)},unmounted(e){e.__handleKeydown&&(e.removeEventListener("keydown",e.__handleKeydown),delete e.__handleKeydown),e.__handleEscape&&(document.removeEventListener("keydown",e.__handleEscape,!0),delete e.__handleEscape),e.__previousFocus&&(setTimeout(()=>{if(e.__previousFocus&&document.body.contains(e.__previousFocus)&&typeof e.__previousFocus.focus=="function")try{e.__previousFocus.focus()}catch(a){console.warn("Could not restore focus:",a)}},0),delete e.__previousFocus)}},P={mounted(e,a){const t=a.value||{};console.log("Keyboard directive mounted with config:",t);const n=i=>{console.log("Key pressed:",i.key,"Config:",t);const r={Enter:"enter"," ":"space",Escape:"escape",ArrowUp:"arrowUp",ArrowDown:"arrowDown",ArrowLeft:"arrowLeft",ArrowRight:"arrowRight",Tab:"tab",Delete:"delete",Backspace:"backspace"};let o="";(i.ctrlKey||i.metaKey)&&(o+="ctrl+"),i.altKey&&(o+="alt+"),i.shiftKey&&(o+="shift+"),o+=i.key.toLowerCase();const d=r[i.key];if(d&&typeof t[d]=="function"){i.preventDefault(),t[d](i);return}if(t[o]&&typeof t[o]=="function"){i.preventDefault(),t[o](i);return}if(t[i.key]&&typeof t[i.key]=="function"){i.preventDefault(),t[i.key](i);return}if(t.arrows&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(i.key)&&typeof t.arrows=="function"){i.preventDefault(),t.arrows(i);return}if(t.handlers){if(t.handlers[i.key]&&typeof t.handlers[i.key]=="function"){i.preventDefault(),t.handlers[i.key](i);return}if(t.handlers[o]&&typeof t.handlers[o]=="function"){i.preventDefault(),t.handlers[o](i);return}}if(t.custom&&typeof t.custom=="function"){t.custom(i);return}t.enter===!0&&i.key==="Enter"&&!["INPUT","TEXTAREA","SELECT"].includes(i.target.tagName)&&(i.preventDefault(),e.click&&e.click()),t.space===!0&&i.key===" "&&["BUTTON","A"].includes(e.tagName)&&(i.preventDefault(),e.click&&e.click())};e.addEventListener("keydown",n),e.__keyboardHandler=n},unmounted(e){e.__keyboardHandler&&(e.removeEventListener("keydown",e.__keyboardHandler),delete e.__keyboardHandler)}},L={mounted(e,a){if(!a.value)return;const t=typeof a.value=="string"?{message:a.value,priority:"polite"}:a.value;t&&t.message&&g(t.message,t.priority||"polite")},updated(e,a){if(a.value!==a.oldValue&&a.value){const t=typeof a.value=="string"?{message:a.value,priority:"polite"}:a.value;t&&t.message&&g(t.message,t.priority||"polite")}}},I={mounted(e,a){const t=a.value,n=i=>{i.preventDefault();const r=document.querySelector(t);r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus(),r.scrollIntoView({behavior:"smooth",block:"start"}))};e.addEventListener("click",n),e.__skipLinkHandler=n,e.setAttribute("role","link"),t&&e.setAttribute("aria-label",`Skip to ${t.replace("#","")}`)},unmounted(e){e.__skipLinkHandler&&(e.removeEventListener("click",e.__skipLinkHandler),delete e.__skipLinkHandler)}},K={mounted(e,a){T(e,a)},updated(e,a){T(e,a)},unmounted(e){delete e.__a11ySkipOriginalTabIndex,delete e.__a11ySkipOriginalAriaHidden,delete e.__a11ySkipChildrenState}};function T(e,a){if(a.value===void 0?!0:!!a.value){e.__a11ySkipOriginalTabIndex===void 0&&(e.__a11ySkipOriginalTabIndex=e.getAttribute("tabindex")),e.__a11ySkipOriginalAriaHidden===void 0&&(e.__a11ySkipOriginalAriaHidden=e.getAttribute("aria-hidden")),e.setAttribute("tabindex","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute("data-a11y-skip","true");const n=e.querySelectorAll('a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])');e.__a11ySkipChildrenState||(e.__a11ySkipChildrenState=[]),n.forEach((i,r)=>{e.__a11ySkipChildrenState[r]||(e.__a11ySkipChildrenState[r]={tabIndex:i.getAttribute("tabindex"),disabled:i.disabled}),i.setAttribute("tabindex","-1"),"disabled"in i&&(i.disabled=!0)}),a.modifiers.noInteraction&&(e.style.pointerEvents="none"),a.modifiers.visual&&(e.style.opacity="0.5",e.style.filter="grayscale(100%)",e.style.pointerEvents="none")}else{e.__a11ySkipOriginalTabIndex!==void 0?e.__a11ySkipOriginalTabIndex===null?e.removeAttribute("tabindex"):e.setAttribute("tabindex",e.__a11ySkipOriginalTabIndex):e.removeAttribute("tabindex"),e.__a11ySkipOriginalAriaHidden!==void 0?e.__a11ySkipOriginalAriaHidden===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",e.__a11ySkipOriginalAriaHidden):e.removeAttribute("aria-hidden"),e.removeAttribute("data-a11y-skip");const n=e.querySelectorAll("a, button, input, select, textarea, [tabindex]");e.__a11ySkipChildrenState&&n.forEach((i,r)=>{const o=e.__a11ySkipChildrenState[r];o&&(o.tabIndex===null?i.removeAttribute("tabindex"):i.setAttribute("tabindex",o.tabIndex),"disabled"in i&&(i.disabled=o.disabled))}),a.modifiers.noInteraction&&(e.style.pointerEvents=""),a.modifiers.visual&&(e.style.opacity="",e.style.filter="",e.style.pointerEvents="")}}const H={mounted(e,a){const t=a.value||{},n={label:"aria-label",labelledby:"aria-labelledby",describedby:"aria-describedby",expanded:"aria-expanded",pressed:"aria-pressed",selected:"aria-selected",checked:"aria-checked",disabled:"aria-disabled",hidden:"aria-hidden",invalid:"aria-invalid",required:"aria-required",live:"aria-live",atomic:"aria-atomic",busy:"aria-busy",controls:"aria-controls",owns:"aria-owns",haspopup:"aria-haspopup",level:"aria-level",modal:"aria-modal",multiselectable:"aria-multiselectable",orientation:"aria-orientation",placeholder:"aria-placeholder",readonly:"aria-readonly",relevant:"aria-relevant",valuemax:"aria-valuemax",valuemin:"aria-valuemin",valuenow:"aria-valuenow",valuetext:"aria-valuetext"},i={};Object.entries(t).forEach(([r,o])=>{const d=n[r]||r;i[d]=o}),E(e,i),e.__ariaAttributes=Object.keys(i)},updated(e,a){if(JSON.stringify(a.value)!==JSON.stringify(a.oldValue)){e.__ariaAttributes&&e.__ariaAttributes.forEach(r=>e.removeAttribute(r));const t=a.value||{},n={label:"aria-label",labelledby:"aria-labelledby",describedby:"aria-describedby",expanded:"aria-expanded",pressed:"aria-pressed",selected:"aria-selected",checked:"aria-checked",disabled:"aria-disabled",hidden:"aria-hidden",invalid:"aria-invalid",required:"aria-required",live:"aria-live",atomic:"aria-atomic",busy:"aria-busy",controls:"aria-controls",owns:"aria-owns",haspopup:"aria-haspopup",level:"aria-level",modal:"aria-modal"},i={};Object.entries(t).forEach(([r,o])=>{const d=n[r]||r;i[d]=o}),E(e,i),e.__ariaAttributes=Object.keys(i)}},unmounted(e){e.__ariaAttributes&&(e.__ariaAttributes.forEach(a=>e.removeAttribute(a)),delete e.__ariaAttributes)}},C={mounted(e,a){const t=a.value||{},n=t.delay||100,i={panel:t.panelSelector||".el-picker-panel, .el-date-picker, .v-picker, .v-date-picker, .ant-picker-dropdown, .p-datepicker",selectedDay:t.selectedSelector||"td.is-selected, td.selected, td.is-today.is-selected, .v-date-picker-table__current, .ant-picker-cell-selected, .p-highlight",availableDay:t.availableSelector||"td:not(.disabled):not(.is-disabled):not([disabled]), .v-date-picker-table__events, .ant-picker-cell:not(.ant-picker-cell-disabled), .p-datepicker-calendar td:not(.p-disabled)",input:t.inputSelector||".el-input__inner, input, .v-text-field__input, .ant-picker-input, .p-inputtext"};let r=!1,o=null,d=null;const u=c=>{const b=c.getAttribute("aria-controls");let s=null;if(b&&(s=document.getElementById(b)),!s){const f=document.querySelectorAll(".el-picker-panel");for(const m of f)if(m.offsetParent!==null){s=m;break}}if(!s)return!1;let l=null;const w=s.querySelector("td.is-selected");if(w&&(l=w),!l){const f=s.querySelector("td.is-today");f&&(l=f)}if(!l){const f=s.querySelector(".el-date-table tbody td:not(.disabled):not(.is-disabled)");f&&(l=f)}if(!l)return!1;l.setAttribute("tabindex","0");let S=0;const j=10,x=()=>{if(S++,l.focus({preventScroll:!0}),document.activeElement===l)return!0;S<j&&setTimeout(x,10)};if(x(),!s.__a11yKeyboardHandlerAdded){s.__a11yKeyboardHandlerAdded=!0;const f=m=>{if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(m.key)){s.__a11yNavigatingWithKeyboard=!0;const M=v=>{s.__a11yNavigatingWithKeyboard&&(v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation())};["click","mousedown","mouseup","pointerdown","pointerup"].forEach(v=>{s.addEventListener(v,M,{capture:!0,once:!0})}),setTimeout(()=>{s.__a11yNavigatingWithKeyboard=!1},100)}};s.addEventListener("keydown",f),s.__a11yKeyboardHandler=f}return!0},y=c=>{d&&clearTimeout(d),requestAnimationFrame(()=>{d=setTimeout(()=>{u(c)},n)})},k=c=>{o=new MutationObserver(b=>{const s=document.querySelector(".el-picker-panel");s&&!r?(r=!0,y(c)):!s&&r&&(r=!1,d&&(clearTimeout(d),d=null))}),o.observe(document.body,{childList:!0,subtree:!0})},p=(()=>{let c=e.querySelector(i.input);return c||(c=e.querySelectorAll("input")[0]),c||e})();k(p);const h=()=>{};p.addEventListener("focus",h),p.addEventListener("click",h);const D=c=>{c.key==="Enter"||c.key};p.addEventListener("keydown",D);const U=(()=>{const c=new MutationObserver(b=>{b.forEach(s=>{s.type==="attributes"&&s.attributeName==="aria-expanded"&&p.getAttribute("aria-expanded")==="true"&&y(p)})});return c.observe(p,{attributes:!0,attributeFilter:["aria-expanded"]}),c})();e.__a11yDatePickerAriaObserver=U,e.__a11yDatePickerInput=p,e.__a11yDatePickerFocusHandler=h,e.__a11yDatePickerKeyHandler=D,e.__a11yDatePickerObserver=o},unmounted(e){if(e.__a11yDatePickerTimeout&&clearTimeout(e.__a11yDatePickerTimeout),e.__a11yDatePickerInput){const a=e.__a11yDatePickerInput;e.__a11yDatePickerFocusHandler&&(a.removeEventListener("focus",e.__a11yDatePickerFocusHandler),a.removeEventListener("click",e.__a11yDatePickerFocusHandler)),e.__a11yDatePickerKeyHandler&&a.removeEventListener("keydown",e.__a11yDatePickerKeyHandler)}e.__a11yDatePickerObserver&&e.__a11yDatePickerObserver.disconnect(),e.__a11yDatePickerAriaObserver&&e.__a11yDatePickerAriaObserver.disconnect(),delete e.__a11yDatePickerInput,delete e.__a11yDatePickerFocusHandler,delete e.__a11yDatePickerKeyHandler,delete e.__a11yDatePickerObserver,delete e.__a11yDatePickerAriaObserver,delete e.__a11yDatePickerTimeout}},N={"a11y-focus":F,"a11y-trap-focus":O,"a11y-keyboard":P,"a11y-announce":L,"a11y-skip-link":I,"a11y-skip":K,"a11y-aria":H,"a11y-date-picker":C};function q(e){Object.entries(N).forEach(([a,t])=>{e.directive(a,t)})}const z={install:q};exports.a11yDirectives=N;exports.announce=g;exports.announceDirective=L;exports.ariaDirective=H;exports.containsActiveElement=X;exports.datePickerDirective=C;exports.default=z;exports.focusDirective=F;exports.generateId=G;exports.getFirstFocusable=W;exports.getFocusableElements=_;exports.getLastFocusable=V;exports.installA11yDirectives=q;exports.keyboardDirective=P;exports.removeAriaAttributes=B;exports.restoreFocus=J;exports.saveFocus=$;exports.setAriaAttributes=E;exports.skipDirective=K;exports.skipLinkDirective=I;exports.trapFocusDirective=O;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const G=["BUTTON","A","INPUT","TEXTAREA","SELECT","IFRAME"],P={mounted(e,a){const t=typeof a.value=="object"?a.value:{delay:a.value||0},n=t.delay||0,i=t.select||!1;G.includes(e.tagName)||e.hasAttribute("tabindex")||e.hasAttribute("contenteditable")||(e.setAttribute("tabindex","0"),e.__a11yFocusAddedTabindex=!0),setTimeout(()=>{e.focus&&(e.focus(),i&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")&&e.select())},n)},unmounted(e){e.__a11yFocusAddedTabindex&&(e.removeAttribute("tabindex"),delete e.__a11yFocusAddedTabindex)}};function k(e){if(!e)return[];const a=["a[href]","button:not([disabled])","textarea:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"audio[controls]","video[controls]"];return Array.from(e.querySelectorAll(a.join(", "))).filter(n=>{const i=window.getComputedStyle(n);return n.offsetWidth>0&&n.offsetHeight>0&&i.visibility!=="hidden"&&i.display!=="none"})}function E(e,a){Object.entries(a).forEach(([t,n])=>{n!=null&&e.setAttribute(t,n)})}function W(e,a){a.forEach(t=>{e.removeAttribute(t)})}function g(e,a="polite"){const t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-live",a),t.setAttribute("aria-atomic","true"),t.style.position="absolute",t.style.left="-10000px",t.style.width="1px",t.style.height="1px",t.style.overflow="hidden",document.body.appendChild(t),setTimeout(()=>{t.textContent=e},100),setTimeout(()=>{document.body.removeChild(t)},3e3)}function V(e){const a=k(e);return a.length>0?a[0]:null}function X(e){const a=k(e);return a.length>0?a[a.length-1]:null}function $(e){return e.contains(document.activeElement)}function J(){return document.activeElement}function z(e){e&&e.focus&&e.focus()}function Q(e="a11y"){return`${e}-${Math.random().toString(36).substr(2,9)}`}const L={mounted(e,a){const t=a.value||{},n=t.autoFocus!==!1,i=t.onEscape||null,r=document.activeElement;e.__previousFocus=r,n&&setTimeout(()=>{const u=k(e);u.length>0&&u[0].focus()},100);const o=u=>{if(u.key!=="Tab")return;const b=k(e);if(b.length===0)return;const m=b[0],A=b[b.length-1];u.shiftKey&&document.activeElement===m?(u.preventDefault(),A.focus()):!u.shiftKey&&document.activeElement===A&&(u.preventDefault(),m.focus())},c=u=>{u.key==="Escape"&&i&&(u.preventDefault(),u.stopPropagation(),i())};e.addEventListener("keydown",o),e.__handleKeydown=o,i&&(document.addEventListener("keydown",c,!0),e.__handleEscape=c)},unmounted(e){e.__handleKeydown&&(e.removeEventListener("keydown",e.__handleKeydown),delete e.__handleKeydown),e.__handleEscape&&(document.removeEventListener("keydown",e.__handleEscape,!0),delete e.__handleEscape),e.__previousFocus&&(setTimeout(()=>{if(e.__previousFocus&&document.body.contains(e.__previousFocus)&&typeof e.__previousFocus.focus=="function")try{e.__previousFocus.focus()}catch(a){console.warn("Could not restore focus:",a)}},0),delete e.__previousFocus)}},I={mounted(e,a){const t=a.value||{};console.log("Keyboard directive mounted with config:",t);const n=i=>{console.log("Key pressed:",i.key,"Config:",t);const r={Enter:"enter"," ":"space",Escape:"escape",ArrowUp:"arrowUp",ArrowDown:"arrowDown",ArrowLeft:"arrowLeft",ArrowRight:"arrowRight",Tab:"tab",Delete:"delete",Backspace:"backspace"};let o="";(i.ctrlKey||i.metaKey)&&(o+="ctrl+"),i.altKey&&(o+="alt+"),i.shiftKey&&(o+="shift+"),o+=i.key.toLowerCase();const c=r[i.key];if(c&&typeof t[c]=="function"){i.preventDefault(),t[c](i);return}if(t[o]&&typeof t[o]=="function"){i.preventDefault(),t[o](i);return}if(t[i.key]&&typeof t[i.key]=="function"){i.preventDefault(),t[i.key](i);return}if(t.arrows&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(i.key)&&typeof t.arrows=="function"){i.preventDefault(),t.arrows(i);return}if(t.handlers){if(t.handlers[i.key]&&typeof t.handlers[i.key]=="function"){i.preventDefault(),t.handlers[i.key](i);return}if(t.handlers[o]&&typeof t.handlers[o]=="function"){i.preventDefault(),t.handlers[o](i);return}}if(t.custom&&typeof t.custom=="function"){t.custom(i);return}t.enter===!0&&i.key==="Enter"&&!["INPUT","TEXTAREA","SELECT"].includes(i.target.tagName)&&(i.preventDefault(),e.click&&e.click()),t.space===!0&&i.key===" "&&["BUTTON","A"].includes(e.tagName)&&(i.preventDefault(),e.click&&e.click())};e.addEventListener("keydown",n),e.__keyboardHandler=n},unmounted(e){e.__keyboardHandler&&(e.removeEventListener("keydown",e.__keyboardHandler),delete e.__keyboardHandler)}},K={mounted(e,a){if(!a.value)return;const t=typeof a.value=="string"?{message:a.value,priority:"polite"}:a.value;t&&t.message&&g(t.message,t.priority||"polite")},updated(e,a){if(a.value!==a.oldValue&&a.value){const t=typeof a.value=="string"?{message:a.value,priority:"polite"}:a.value;t&&t.message&&g(t.message,t.priority||"polite")}}},H={mounted(e,a){const t=a.value,n=i=>{i.preventDefault();const r=document.querySelector(t);r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus(),r.scrollIntoView({behavior:"smooth",block:"start"}))};e.addEventListener("click",n),e.__skipLinkHandler=n,e.setAttribute("role","link"),t&&e.setAttribute("aria-label",`Skip to ${t.replace("#","")}`)},unmounted(e){e.__skipLinkHandler&&(e.removeEventListener("click",e.__skipLinkHandler),delete e.__skipLinkHandler)}},C={mounted(e,a){O(e,a)},updated(e,a){O(e,a)},unmounted(e){delete e.__a11ySkipOriginalTabIndex,delete e.__a11ySkipOriginalAriaHidden,delete e.__a11ySkipChildrenState}};function O(e,a){if(a.value===void 0?!0:!!a.value){e.__a11ySkipOriginalTabIndex===void 0&&(e.__a11ySkipOriginalTabIndex=e.getAttribute("tabindex")),e.__a11ySkipOriginalAriaHidden===void 0&&(e.__a11ySkipOriginalAriaHidden=e.getAttribute("aria-hidden")),e.setAttribute("tabindex","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute("data-a11y-skip","true");const n=e.querySelectorAll('a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])');e.__a11ySkipChildrenState||(e.__a11ySkipChildrenState=[]),n.forEach((i,r)=>{e.__a11ySkipChildrenState[r]||(e.__a11ySkipChildrenState[r]={tabIndex:i.getAttribute("tabindex"),disabled:i.disabled}),i.setAttribute("tabindex","-1"),"disabled"in i&&(i.disabled=!0)}),a.modifiers.noInteraction&&(e.style.pointerEvents="none"),a.modifiers.visual&&(e.style.opacity="0.5",e.style.filter="grayscale(100%)",e.style.pointerEvents="none")}else{e.__a11ySkipOriginalTabIndex!==void 0?e.__a11ySkipOriginalTabIndex===null?e.removeAttribute("tabindex"):e.setAttribute("tabindex",e.__a11ySkipOriginalTabIndex):e.removeAttribute("tabindex"),e.__a11ySkipOriginalAriaHidden!==void 0?e.__a11ySkipOriginalAriaHidden===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",e.__a11ySkipOriginalAriaHidden):e.removeAttribute("aria-hidden"),e.removeAttribute("data-a11y-skip");const n=e.querySelectorAll("a, button, input, select, textarea, [tabindex]");e.__a11ySkipChildrenState&&n.forEach((i,r)=>{const o=e.__a11ySkipChildrenState[r];o&&(o.tabIndex===null?i.removeAttribute("tabindex"):i.setAttribute("tabindex",o.tabIndex),"disabled"in i&&(i.disabled=o.disabled))}),a.modifiers.noInteraction&&(e.style.pointerEvents=""),a.modifiers.visual&&(e.style.opacity="",e.style.filter="",e.style.pointerEvents="")}}const N={mounted(e,a){const t=a.value||{},n={label:"aria-label",labelledby:"aria-labelledby",describedby:"aria-describedby",expanded:"aria-expanded",pressed:"aria-pressed",selected:"aria-selected",checked:"aria-checked",disabled:"aria-disabled",hidden:"aria-hidden",invalid:"aria-invalid",required:"aria-required",live:"aria-live",atomic:"aria-atomic",busy:"aria-busy",controls:"aria-controls",owns:"aria-owns",haspopup:"aria-haspopup",level:"aria-level",modal:"aria-modal",multiselectable:"aria-multiselectable",orientation:"aria-orientation",placeholder:"aria-placeholder",readonly:"aria-readonly",relevant:"aria-relevant",valuemax:"aria-valuemax",valuemin:"aria-valuemin",valuenow:"aria-valuenow",valuetext:"aria-valuetext"},i={};Object.entries(t).forEach(([r,o])=>{const c=n[r]||r;i[c]=o}),E(e,i),e.__ariaAttributes=Object.keys(i)},updated(e,a){if(JSON.stringify(a.value)!==JSON.stringify(a.oldValue)){e.__ariaAttributes&&e.__ariaAttributes.forEach(r=>e.removeAttribute(r));const t=a.value||{},n={label:"aria-label",labelledby:"aria-labelledby",describedby:"aria-describedby",expanded:"aria-expanded",pressed:"aria-pressed",selected:"aria-selected",checked:"aria-checked",disabled:"aria-disabled",hidden:"aria-hidden",invalid:"aria-invalid",required:"aria-required",live:"aria-live",atomic:"aria-atomic",busy:"aria-busy",controls:"aria-controls",owns:"aria-owns",haspopup:"aria-haspopup",level:"aria-level",modal:"aria-modal"},i={};Object.entries(t).forEach(([r,o])=>{const c=n[r]||r;i[c]=o}),E(e,i),e.__ariaAttributes=Object.keys(i)}},unmounted(e){e.__ariaAttributes&&(e.__ariaAttributes.forEach(a=>e.removeAttribute(a)),delete e.__ariaAttributes)}},q={mounted(e,a){const t=a.value||{},n=t.delay||100,i={panel:t.panelSelector||".el-picker-panel, .el-date-picker, .v-picker, .v-date-picker, .ant-picker-dropdown, .p-datepicker",selectedDay:t.selectedSelector||"td.is-selected, td.selected, td.is-today.is-selected, .v-date-picker-table__current, .ant-picker-cell-selected, .p-highlight",availableDay:t.availableSelector||"td:not(.disabled):not(.is-disabled):not([disabled]), .v-date-picker-table__events, .ant-picker-cell:not(.ant-picker-cell-disabled), .p-datepicker-calendar td:not(.p-disabled)",input:t.inputSelector||".el-input__inner, input, .v-text-field__input, .ant-picker-input, .p-inputtext"};let r=!1,o=null,c=null;const u=d=>{const v=d.getAttribute("aria-controls");let s=null;if(v&&(s=document.getElementById(v)),!s){const f=document.querySelectorAll(".el-picker-panel");for(const _ of f)if(_.offsetParent!==null){s=_;break}}if(!s)return!1;let l=null;const S=s.querySelector("td.is-selected");if(S&&(l=S),!l){const f=s.querySelector("td.is-today");f&&(l=f)}if(!l){const f=s.querySelector(".el-date-table tbody td:not(.disabled):not(.is-disabled)");f&&(l=f)}if(!l)return!1;l.setAttribute("tabindex","0");let w=0;const R=10,x=()=>{if(w++,l.focus({preventScroll:!0}),document.activeElement===l)return!0;w<R&&setTimeout(x,10)};x();const T=f=>{if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(f.key)){f.preventDefault(),s.__a11yNavigatingWithKeyboard=!0;const _=y=>(console.log("[DEBUG] Preventing",y.type,"during keyboard navigation"),y.preventDefault(),y.stopPropagation(),y.stopImmediatePropagation(),!1),F=["click","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"];F.forEach(y=>{s.addEventListener(y,_,{capture:!0,once:!0})}),s.querySelectorAll("td").forEach(y=>{F.forEach(B=>{y.addEventListener(B,_,{capture:!0,once:!0})})}),setTimeout(()=>{s.__a11yNavigatingWithKeyboard=!1,console.log("[DEBUG] Keyboard navigation complete")},50)}};return s.__a11yKeyboardHandlerAdded||(s.__a11yKeyboardHandlerAdded=!0,s.addEventListener("keydown",T,{capture:!0}),s.__a11yKeyboardHandler=T,console.log("[DEBUG] Keyboard navigation handler installed")),!0},b=d=>{c&&clearTimeout(c),requestAnimationFrame(()=>{c=setTimeout(()=>{u(d)},n)})},m=d=>{o=new MutationObserver(v=>{const s=document.querySelector(".el-picker-panel");s&&!r?(r=!0,b(d)):!s&&r&&(r=!1,c&&(clearTimeout(c),c=null))}),o.observe(document.body,{childList:!0,subtree:!0})},p=(()=>{let d=e.querySelector(i.input);return d||(d=e.querySelectorAll("input")[0]),d||e})();m(p);const h=()=>{};p.addEventListener("focus",h),p.addEventListener("click",h);const D=d=>{d.key==="Enter"||d.key};p.addEventListener("keydown",D);const M=(()=>{const d=new MutationObserver(v=>{v.forEach(s=>{s.type==="attributes"&&s.attributeName==="aria-expanded"&&p.getAttribute("aria-expanded")==="true"&&b(p)})});return d.observe(p,{attributes:!0,attributeFilter:["aria-expanded"]}),d})();e.__a11yDatePickerAriaObserver=M,e.__a11yDatePickerInput=p,e.__a11yDatePickerFocusHandler=h,e.__a11yDatePickerKeyHandler=D,e.__a11yDatePickerObserver=o},unmounted(e){if(e.__a11yDatePickerTimeout&&clearTimeout(e.__a11yDatePickerTimeout),e.__a11yDatePickerInput){const a=e.__a11yDatePickerInput;e.__a11yDatePickerFocusHandler&&(a.removeEventListener("focus",e.__a11yDatePickerFocusHandler),a.removeEventListener("click",e.__a11yDatePickerFocusHandler)),e.__a11yDatePickerKeyHandler&&a.removeEventListener("keydown",e.__a11yDatePickerKeyHandler)}e.__a11yDatePickerObserver&&e.__a11yDatePickerObserver.disconnect(),e.__a11yDatePickerAriaObserver&&e.__a11yDatePickerAriaObserver.disconnect(),delete e.__a11yDatePickerInput,delete e.__a11yDatePickerFocusHandler,delete e.__a11yDatePickerKeyHandler,delete e.__a11yDatePickerObserver,delete e.__a11yDatePickerAriaObserver,delete e.__a11yDatePickerTimeout}},U={"a11y-focus":P,"a11y-trap-focus":L,"a11y-keyboard":I,"a11y-announce":K,"a11y-skip-link":H,"a11y-skip":C,"a11y-aria":N,"a11y-date-picker":q};function j(e){Object.entries(U).forEach(([a,t])=>{e.directive(a,t)})}const Y={install:j};exports.a11yDirectives=U;exports.announce=g;exports.announceDirective=K;exports.ariaDirective=N;exports.containsActiveElement=$;exports.datePickerDirective=q;exports.default=Y;exports.focusDirective=P;exports.generateId=Q;exports.getFirstFocusable=V;exports.getFocusableElements=k;exports.getLastFocusable=X;exports.installA11yDirectives=j;exports.keyboardDirective=I;exports.removeAriaAttributes=W;exports.restoreFocus=z;exports.saveFocus=J;exports.setAriaAttributes=E;exports.skipDirective=C;exports.skipLinkDirective=H;exports.trapFocusDirective=L;
@@ -1,7 +1,7 @@
1
- const L = ["BUTTON", "A", "INPUT", "TEXTAREA", "SELECT", "IFRAME"], I = {
1
+ const K = ["BUTTON", "A", "INPUT", "TEXTAREA", "SELECT", "IFRAME"], H = {
2
2
  mounted(e, a) {
3
3
  const t = typeof a.value == "object" ? a.value : { delay: a.value || 0 }, n = t.delay || 0, i = t.select || !1;
4
- L.includes(e.tagName) || e.hasAttribute("tabindex") || e.hasAttribute("contenteditable") || (e.setAttribute("tabindex", "0"), e.__a11yFocusAddedTabindex = !0), setTimeout(() => {
4
+ K.includes(e.tagName) || e.hasAttribute("tabindex") || e.hasAttribute("contenteditable") || (e.setAttribute("tabindex", "0"), e.__a11yFocusAddedTabindex = !0), setTimeout(() => {
5
5
  e.focus && (e.focus(), i && (e.tagName === "INPUT" || e.tagName === "TEXTAREA") && e.select());
6
6
  }, n);
7
7
  },
@@ -27,17 +27,17 @@ function m(e) {
27
27
  return n.offsetWidth > 0 && n.offsetHeight > 0 && i.visibility !== "hidden" && i.display !== "none";
28
28
  });
29
29
  }
30
- function S(e, a) {
30
+ function T(e, a) {
31
31
  Object.entries(a).forEach(([t, n]) => {
32
32
  n != null && e.setAttribute(t, n);
33
33
  });
34
34
  }
35
- function V(e, a) {
35
+ function X(e, a) {
36
36
  a.forEach((t) => {
37
37
  e.removeAttribute(t);
38
38
  });
39
39
  }
40
- function D(e, a = "polite") {
40
+ function F(e, a = "polite") {
41
41
  const t = document.createElement("div");
42
42
  t.setAttribute("role", "status"), t.setAttribute("aria-live", a), t.setAttribute("aria-atomic", "true"), t.style.position = "absolute", t.style.left = "-10000px", t.style.width = "1px", t.style.height = "1px", t.style.overflow = "hidden", document.body.appendChild(t), setTimeout(() => {
43
43
  t.textContent = e;
@@ -45,27 +45,27 @@ function D(e, a = "polite") {
45
45
  document.body.removeChild(t);
46
46
  }, 3e3);
47
47
  }
48
- function X(e) {
48
+ function $(e) {
49
49
  const a = m(e);
50
50
  return a.length > 0 ? a[0] : null;
51
51
  }
52
- function $(e) {
52
+ function J(e) {
53
53
  const a = m(e);
54
54
  return a.length > 0 ? a[a.length - 1] : null;
55
55
  }
56
- function J(e) {
56
+ function z(e) {
57
57
  return e.contains(document.activeElement);
58
58
  }
59
- function G() {
59
+ function Q() {
60
60
  return document.activeElement;
61
61
  }
62
- function z(e) {
62
+ function Y(e) {
63
63
  e && e.focus && e.focus();
64
64
  }
65
- function Q(e = "a11y") {
65
+ function Z(e = "a11y") {
66
66
  return `${e}-${Math.random().toString(36).substr(2, 9)}`;
67
67
  }
68
- const K = {
68
+ const C = {
69
69
  mounted(e, a) {
70
70
  const t = a.value || {}, n = t.autoFocus !== !1, i = t.onEscape || null, r = document.activeElement;
71
71
  e.__previousFocus = r, n && setTimeout(() => {
@@ -74,10 +74,10 @@ const K = {
74
74
  }, 100);
75
75
  const o = (u) => {
76
76
  if (u.key !== "Tab") return;
77
- const y = m(e);
78
- if (y.length === 0) return;
79
- const v = y[0], h = y[y.length - 1];
80
- u.shiftKey && document.activeElement === v ? (u.preventDefault(), h.focus()) : !u.shiftKey && document.activeElement === h && (u.preventDefault(), v.focus());
77
+ const b = m(e);
78
+ if (b.length === 0) return;
79
+ const k = b[0], h = b[b.length - 1];
80
+ u.shiftKey && document.activeElement === k ? (u.preventDefault(), h.focus()) : !u.shiftKey && document.activeElement === h && (u.preventDefault(), k.focus());
81
81
  }, d = (u) => {
82
82
  u.key === "Escape" && i && (u.preventDefault(), u.stopPropagation(), i());
83
83
  };
@@ -93,7 +93,7 @@ const K = {
93
93
  }
94
94
  }, 0), delete e.__previousFocus);
95
95
  }
96
- }, H = {
96
+ }, N = {
97
97
  mounted(e, a) {
98
98
  const t = a.value || {};
99
99
  console.log("Keyboard directive mounted with config:", t);
@@ -151,19 +151,19 @@ const K = {
151
151
  unmounted(e) {
152
152
  e.__keyboardHandler && (e.removeEventListener("keydown", e.__keyboardHandler), delete e.__keyboardHandler);
153
153
  }
154
- }, C = {
154
+ }, q = {
155
155
  mounted(e, a) {
156
156
  if (!a.value) return;
157
157
  const t = typeof a.value == "string" ? { message: a.value, priority: "polite" } : a.value;
158
- t && t.message && D(t.message, t.priority || "polite");
158
+ t && t.message && F(t.message, t.priority || "polite");
159
159
  },
160
160
  updated(e, a) {
161
161
  if (a.value !== a.oldValue && a.value) {
162
162
  const t = typeof a.value == "string" ? { message: a.value, priority: "polite" } : a.value;
163
- t && t.message && D(t.message, t.priority || "polite");
163
+ t && t.message && F(t.message, t.priority || "polite");
164
164
  }
165
165
  }
166
- }, N = {
166
+ }, U = {
167
167
  mounted(e, a) {
168
168
  const t = a.value, n = (i) => {
169
169
  i.preventDefault();
@@ -175,18 +175,18 @@ const K = {
175
175
  unmounted(e) {
176
176
  e.__skipLinkHandler && (e.removeEventListener("click", e.__skipLinkHandler), delete e.__skipLinkHandler);
177
177
  }
178
- }, q = {
178
+ }, R = {
179
179
  mounted(e, a) {
180
- T(e, a);
180
+ O(e, a);
181
181
  },
182
182
  updated(e, a) {
183
- T(e, a);
183
+ O(e, a);
184
184
  },
185
185
  unmounted(e) {
186
186
  delete e.__a11ySkipOriginalTabIndex, delete e.__a11ySkipOriginalAriaHidden, delete e.__a11ySkipChildrenState;
187
187
  }
188
188
  };
189
- function T(e, a) {
189
+ function O(e, a) {
190
190
  if (a.value === void 0 ? !0 : !!a.value) {
191
191
  e.__a11ySkipOriginalTabIndex === void 0 && (e.__a11ySkipOriginalTabIndex = e.getAttribute("tabindex")), e.__a11ySkipOriginalAriaHidden === void 0 && (e.__a11ySkipOriginalAriaHidden = e.getAttribute("aria-hidden")), e.setAttribute("tabindex", "-1"), e.setAttribute("aria-hidden", "true"), e.setAttribute("data-a11y-skip", "true");
192
192
  const n = e.querySelectorAll(
@@ -209,7 +209,7 @@ function T(e, a) {
209
209
  }), a.modifiers.noInteraction && (e.style.pointerEvents = ""), a.modifiers.visual && (e.style.opacity = "", e.style.filter = "", e.style.pointerEvents = "");
210
210
  }
211
211
  }
212
- const U = {
212
+ const j = {
213
213
  mounted(e, a) {
214
214
  const t = a.value || {}, n = {
215
215
  label: "aria-label",
@@ -244,7 +244,7 @@ const U = {
244
244
  Object.entries(t).forEach(([r, o]) => {
245
245
  const d = n[r] || r;
246
246
  i[d] = o;
247
- }), S(e, i), e.__ariaAttributes = Object.keys(i);
247
+ }), T(e, i), e.__ariaAttributes = Object.keys(i);
248
248
  },
249
249
  updated(e, a) {
250
250
  if (JSON.stringify(a.value) !== JSON.stringify(a.oldValue)) {
@@ -273,13 +273,13 @@ const U = {
273
273
  Object.entries(t).forEach(([r, o]) => {
274
274
  const d = n[r] || r;
275
275
  i[d] = o;
276
- }), S(e, i), e.__ariaAttributes = Object.keys(i);
276
+ }), T(e, i), e.__ariaAttributes = Object.keys(i);
277
277
  }
278
278
  },
279
279
  unmounted(e) {
280
280
  e.__ariaAttributes && (e.__ariaAttributes.forEach((a) => e.removeAttribute(a)), delete e.__ariaAttributes);
281
281
  }
282
- }, R = {
282
+ }, B = {
283
283
  mounted(e, a) {
284
284
  const t = a.value || {}, n = t.delay || 100, i = {
285
285
  // Panel selectors (where the calendar appears)
@@ -293,13 +293,13 @@ const U = {
293
293
  };
294
294
  let r = !1, o = null, d = null;
295
295
  const u = (c) => {
296
- const b = c.getAttribute("aria-controls");
296
+ const _ = c.getAttribute("aria-controls");
297
297
  let s = null;
298
- if (b && (s = document.getElementById(b)), !s) {
298
+ if (_ && (s = document.getElementById(_)), !s) {
299
299
  const f = document.querySelectorAll(".el-picker-panel");
300
- for (const k of f)
301
- if (k.offsetParent !== null) {
302
- s = k;
300
+ for (const v of f)
301
+ if (v.offsetParent !== null) {
302
+ s = v;
303
303
  break;
304
304
  }
305
305
  }
@@ -319,39 +319,38 @@ const U = {
319
319
  return !1;
320
320
  l.setAttribute("tabindex", "0");
321
321
  let w = 0;
322
- const O = 10, x = () => {
322
+ const L = 10, D = () => {
323
323
  if (w++, l.focus({ preventScroll: !0 }), document.activeElement === l)
324
324
  return !0;
325
- w < O && setTimeout(x, 10);
325
+ w < L && setTimeout(D, 10);
326
326
  };
327
- if (x(), !s.__a11yKeyboardHandlerAdded) {
328
- s.__a11yKeyboardHandlerAdded = !0;
329
- const f = (k) => {
330
- if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(k.key)) {
331
- s.__a11yNavigatingWithKeyboard = !0;
332
- const P = (_) => {
333
- s.__a11yNavigatingWithKeyboard && (_.preventDefault(), _.stopPropagation(), _.stopImmediatePropagation());
334
- };
335
- ["click", "mousedown", "mouseup", "pointerdown", "pointerup"].forEach((_) => {
336
- s.addEventListener(_, P, { capture: !0, once: !0 });
337
- }), setTimeout(() => {
338
- s.__a11yNavigatingWithKeyboard = !1;
339
- }, 100);
340
- }
341
- };
342
- s.addEventListener("keydown", f), s.__a11yKeyboardHandler = f;
343
- }
344
- return !0;
345
- }, y = (c) => {
327
+ D();
328
+ const S = (f) => {
329
+ if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(f.key)) {
330
+ f.preventDefault(), s.__a11yNavigatingWithKeyboard = !0;
331
+ const v = (y) => (console.log("[DEBUG] Preventing", y.type, "during keyboard navigation"), y.preventDefault(), y.stopPropagation(), y.stopImmediatePropagation(), !1), x = ["click", "mousedown", "mouseup", "pointerdown", "pointerup", "touchstart", "touchend"];
332
+ x.forEach((y) => {
333
+ s.addEventListener(y, v, { capture: !0, once: !0 });
334
+ }), s.querySelectorAll("td").forEach((y) => {
335
+ x.forEach((I) => {
336
+ y.addEventListener(I, v, { capture: !0, once: !0 });
337
+ });
338
+ }), setTimeout(() => {
339
+ s.__a11yNavigatingWithKeyboard = !1, console.log("[DEBUG] Keyboard navigation complete");
340
+ }, 50);
341
+ }
342
+ };
343
+ return s.__a11yKeyboardHandlerAdded || (s.__a11yKeyboardHandlerAdded = !0, s.addEventListener("keydown", S, { capture: !0 }), s.__a11yKeyboardHandler = S, console.log("[DEBUG] Keyboard navigation handler installed")), !0;
344
+ }, b = (c) => {
346
345
  d && clearTimeout(d), requestAnimationFrame(() => {
347
346
  d = setTimeout(() => {
348
347
  u(c);
349
348
  }, n);
350
349
  });
351
- }, v = (c) => {
352
- o = new MutationObserver((b) => {
350
+ }, k = (c) => {
351
+ o = new MutationObserver((_) => {
353
352
  const s = document.querySelector(".el-picker-panel");
354
- s && !r ? (r = !0, y(c)) : !s && r && (r = !1, d && (clearTimeout(d), d = null));
353
+ s && !r ? (r = !0, b(c)) : !s && r && (r = !1, d && (clearTimeout(d), d = null));
355
354
  }), o.observe(document.body, {
356
355
  childList: !0,
357
356
  subtree: !0
@@ -360,7 +359,7 @@ const U = {
360
359
  let c = e.querySelector(i.input);
361
360
  return c || (c = e.querySelectorAll("input")[0]), c || e;
362
361
  })();
363
- v(p);
362
+ k(p);
364
363
  const A = () => {
365
364
  };
366
365
  p.addEventListener("focus", A), p.addEventListener("click", A);
@@ -368,10 +367,10 @@ const U = {
368
367
  c.key === "Enter" || c.key;
369
368
  };
370
369
  p.addEventListener("keydown", E);
371
- const F = (() => {
372
- const c = new MutationObserver((b) => {
373
- b.forEach((s) => {
374
- s.type === "attributes" && s.attributeName === "aria-expanded" && p.getAttribute("aria-expanded") === "true" && y(p);
370
+ const P = (() => {
371
+ const c = new MutationObserver((_) => {
372
+ _.forEach((s) => {
373
+ s.type === "attributes" && s.attributeName === "aria-expanded" && p.getAttribute("aria-expanded") === "true" && b(p);
375
374
  });
376
375
  });
377
376
  return c.observe(p, {
@@ -379,7 +378,7 @@ const U = {
379
378
  attributeFilter: ["aria-expanded"]
380
379
  }), c;
381
380
  })();
382
- e.__a11yDatePickerAriaObserver = F, e.__a11yDatePickerInput = p, e.__a11yDatePickerFocusHandler = A, e.__a11yDatePickerKeyHandler = E, e.__a11yDatePickerObserver = o;
381
+ e.__a11yDatePickerAriaObserver = P, e.__a11yDatePickerInput = p, e.__a11yDatePickerFocusHandler = A, e.__a11yDatePickerKeyHandler = E, e.__a11yDatePickerObserver = o;
383
382
  },
384
383
  unmounted(e) {
385
384
  if (e.__a11yDatePickerTimeout && clearTimeout(e.__a11yDatePickerTimeout), e.__a11yDatePickerInput) {
@@ -388,44 +387,44 @@ const U = {
388
387
  }
389
388
  e.__a11yDatePickerObserver && e.__a11yDatePickerObserver.disconnect(), e.__a11yDatePickerAriaObserver && e.__a11yDatePickerAriaObserver.disconnect(), delete e.__a11yDatePickerInput, delete e.__a11yDatePickerFocusHandler, delete e.__a11yDatePickerKeyHandler, delete e.__a11yDatePickerObserver, delete e.__a11yDatePickerAriaObserver, delete e.__a11yDatePickerTimeout;
390
389
  }
391
- }, j = {
392
- "a11y-focus": I,
393
- "a11y-trap-focus": K,
394
- "a11y-keyboard": H,
395
- "a11y-announce": C,
396
- "a11y-skip-link": N,
397
- "a11y-skip": q,
398
- "a11y-aria": U,
399
- "a11y-date-picker": R
390
+ }, M = {
391
+ "a11y-focus": H,
392
+ "a11y-trap-focus": C,
393
+ "a11y-keyboard": N,
394
+ "a11y-announce": q,
395
+ "a11y-skip-link": U,
396
+ "a11y-skip": R,
397
+ "a11y-aria": j,
398
+ "a11y-date-picker": B
400
399
  };
401
- function M(e) {
402
- Object.entries(j).forEach(([a, t]) => {
400
+ function G(e) {
401
+ Object.entries(M).forEach(([a, t]) => {
403
402
  e.directive(a, t);
404
403
  });
405
404
  }
406
- const Y = {
407
- install: M
405
+ const ee = {
406
+ install: G
408
407
  };
409
408
  export {
410
- j as a11yDirectives,
411
- D as announce,
412
- C as announceDirective,
413
- U as ariaDirective,
414
- J as containsActiveElement,
415
- R as datePickerDirective,
416
- Y as default,
417
- I as focusDirective,
418
- Q as generateId,
419
- X as getFirstFocusable,
409
+ M as a11yDirectives,
410
+ F as announce,
411
+ q as announceDirective,
412
+ j as ariaDirective,
413
+ z as containsActiveElement,
414
+ B as datePickerDirective,
415
+ ee as default,
416
+ H as focusDirective,
417
+ Z as generateId,
418
+ $ as getFirstFocusable,
420
419
  m as getFocusableElements,
421
- $ as getLastFocusable,
422
- M as installA11yDirectives,
423
- H as keyboardDirective,
424
- V as removeAriaAttributes,
425
- z as restoreFocus,
426
- G as saveFocus,
427
- S as setAriaAttributes,
428
- q as skipDirective,
429
- N as skipLinkDirective,
430
- K as trapFocusDirective
420
+ J as getLastFocusable,
421
+ G as installA11yDirectives,
422
+ N as keyboardDirective,
423
+ X as removeAriaAttributes,
424
+ Y as restoreFocus,
425
+ Q as saveFocus,
426
+ T as setAriaAttributes,
427
+ R as skipDirective,
428
+ U as skipLinkDirective,
429
+ C as trapFocusDirective
431
430
  };
@@ -1 +1 @@
1
- (function(o,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(o=typeof globalThis<"u"?globalThis:o||self,_(o.VueA11yDirectives={}))})(this,function(o){"use strict";const _=["BUTTON","A","INPUT","TEXTAREA","SELECT","IFRAME"],S={mounted(e,a){const t=typeof a.value=="object"?a.value:{delay:a.value||0},n=t.delay||0,i=t.select||!1;_.includes(e.tagName)||e.hasAttribute("tabindex")||e.hasAttribute("contenteditable")||(e.setAttribute("tabindex","0"),e.__a11yFocusAddedTabindex=!0),setTimeout(()=>{e.focus&&(e.focus(),i&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")&&e.select())},n)},unmounted(e){e.__a11yFocusAddedTabindex&&(e.removeAttribute("tabindex"),delete e.__a11yFocusAddedTabindex)}};function k(e){if(!e)return[];const a=["a[href]","button:not([disabled])","textarea:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"audio[controls]","video[controls]"];return Array.from(e.querySelectorAll(a.join(", "))).filter(n=>{const i=window.getComputedStyle(n);return n.offsetWidth>0&&n.offsetHeight>0&&i.visibility!=="hidden"&&i.display!=="none"})}function E(e,a){Object.entries(a).forEach(([t,n])=>{n!=null&&e.setAttribute(t,n)})}function M(e,a){a.forEach(t=>{e.removeAttribute(t)})}function g(e,a="polite"){const t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-live",a),t.setAttribute("aria-atomic","true"),t.style.position="absolute",t.style.left="-10000px",t.style.width="1px",t.style.height="1px",t.style.overflow="hidden",document.body.appendChild(t),setTimeout(()=>{t.textContent=e},100),setTimeout(()=>{document.body.removeChild(t)},3e3)}function R(e){const a=k(e);return a.length>0?a[0]:null}function B(e){const a=k(e);return a.length>0?a[a.length-1]:null}function W(e){return e.contains(document.activeElement)}function V(){return document.activeElement}function X(e){e&&e.focus&&e.focus()}function $(e="a11y"){return`${e}-${Math.random().toString(36).substr(2,9)}`}const T={mounted(e,a){const t=a.value||{},n=t.autoFocus!==!1,i=t.onEscape||null,r=document.activeElement;e.__previousFocus=r,n&&setTimeout(()=>{const l=k(e);l.length>0&&l[0].focus()},100);const s=l=>{if(l.key!=="Tab")return;const b=k(e);if(b.length===0)return;const A=b[0],D=b[b.length-1];l.shiftKey&&document.activeElement===A?(l.preventDefault(),D.focus()):!l.shiftKey&&document.activeElement===D&&(l.preventDefault(),A.focus())},c=l=>{l.key==="Escape"&&i&&(l.preventDefault(),l.stopPropagation(),i())};e.addEventListener("keydown",s),e.__handleKeydown=s,i&&(document.addEventListener("keydown",c,!0),e.__handleEscape=c)},unmounted(e){e.__handleKeydown&&(e.removeEventListener("keydown",e.__handleKeydown),delete e.__handleKeydown),e.__handleEscape&&(document.removeEventListener("keydown",e.__handleEscape,!0),delete e.__handleEscape),e.__previousFocus&&(setTimeout(()=>{if(e.__previousFocus&&document.body.contains(e.__previousFocus)&&typeof e.__previousFocus.focus=="function")try{e.__previousFocus.focus()}catch(a){console.warn("Could not restore focus:",a)}},0),delete e.__previousFocus)}},F={mounted(e,a){const t=a.value||{};console.log("Keyboard directive mounted with config:",t);const n=i=>{console.log("Key pressed:",i.key,"Config:",t);const r={Enter:"enter"," ":"space",Escape:"escape",ArrowUp:"arrowUp",ArrowDown:"arrowDown",ArrowLeft:"arrowLeft",ArrowRight:"arrowRight",Tab:"tab",Delete:"delete",Backspace:"backspace"};let s="";(i.ctrlKey||i.metaKey)&&(s+="ctrl+"),i.altKey&&(s+="alt+"),i.shiftKey&&(s+="shift+"),s+=i.key.toLowerCase();const c=r[i.key];if(c&&typeof t[c]=="function"){i.preventDefault(),t[c](i);return}if(t[s]&&typeof t[s]=="function"){i.preventDefault(),t[s](i);return}if(t[i.key]&&typeof t[i.key]=="function"){i.preventDefault(),t[i.key](i);return}if(t.arrows&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(i.key)&&typeof t.arrows=="function"){i.preventDefault(),t.arrows(i);return}if(t.handlers){if(t.handlers[i.key]&&typeof t.handlers[i.key]=="function"){i.preventDefault(),t.handlers[i.key](i);return}if(t.handlers[s]&&typeof t.handlers[s]=="function"){i.preventDefault(),t.handlers[s](i);return}}if(t.custom&&typeof t.custom=="function"){t.custom(i);return}t.enter===!0&&i.key==="Enter"&&!["INPUT","TEXTAREA","SELECT"].includes(i.target.tagName)&&(i.preventDefault(),e.click&&e.click()),t.space===!0&&i.key===" "&&["BUTTON","A"].includes(e.tagName)&&(i.preventDefault(),e.click&&e.click())};e.addEventListener("keydown",n),e.__keyboardHandler=n},unmounted(e){e.__keyboardHandler&&(e.removeEventListener("keydown",e.__keyboardHandler),delete e.__keyboardHandler)}},x={mounted(e,a){if(!a.value)return;const t=typeof a.value=="string"?{message:a.value,priority:"polite"}:a.value;t&&t.message&&g(t.message,t.priority||"polite")},updated(e,a){if(a.value!==a.oldValue&&a.value){const t=typeof a.value=="string"?{message:a.value,priority:"polite"}:a.value;t&&t.message&&g(t.message,t.priority||"polite")}}},O={mounted(e,a){const t=a.value,n=i=>{i.preventDefault();const r=document.querySelector(t);r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus(),r.scrollIntoView({behavior:"smooth",block:"start"}))};e.addEventListener("click",n),e.__skipLinkHandler=n,e.setAttribute("role","link"),t&&e.setAttribute("aria-label",`Skip to ${t.replace("#","")}`)},unmounted(e){e.__skipLinkHandler&&(e.removeEventListener("click",e.__skipLinkHandler),delete e.__skipLinkHandler)}},P={mounted(e,a){L(e,a)},updated(e,a){L(e,a)},unmounted(e){delete e.__a11ySkipOriginalTabIndex,delete e.__a11ySkipOriginalAriaHidden,delete e.__a11ySkipChildrenState}};function L(e,a){if(a.value===void 0?!0:!!a.value){e.__a11ySkipOriginalTabIndex===void 0&&(e.__a11ySkipOriginalTabIndex=e.getAttribute("tabindex")),e.__a11ySkipOriginalAriaHidden===void 0&&(e.__a11ySkipOriginalAriaHidden=e.getAttribute("aria-hidden")),e.setAttribute("tabindex","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute("data-a11y-skip","true");const n=e.querySelectorAll('a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])');e.__a11ySkipChildrenState||(e.__a11ySkipChildrenState=[]),n.forEach((i,r)=>{e.__a11ySkipChildrenState[r]||(e.__a11ySkipChildrenState[r]={tabIndex:i.getAttribute("tabindex"),disabled:i.disabled}),i.setAttribute("tabindex","-1"),"disabled"in i&&(i.disabled=!0)}),a.modifiers.noInteraction&&(e.style.pointerEvents="none"),a.modifiers.visual&&(e.style.opacity="0.5",e.style.filter="grayscale(100%)",e.style.pointerEvents="none")}else{e.__a11ySkipOriginalTabIndex!==void 0?e.__a11ySkipOriginalTabIndex===null?e.removeAttribute("tabindex"):e.setAttribute("tabindex",e.__a11ySkipOriginalTabIndex):e.removeAttribute("tabindex"),e.__a11ySkipOriginalAriaHidden!==void 0?e.__a11ySkipOriginalAriaHidden===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",e.__a11ySkipOriginalAriaHidden):e.removeAttribute("aria-hidden"),e.removeAttribute("data-a11y-skip");const n=e.querySelectorAll("a, button, input, select, textarea, [tabindex]");e.__a11ySkipChildrenState&&n.forEach((i,r)=>{const s=e.__a11ySkipChildrenState[r];s&&(s.tabIndex===null?i.removeAttribute("tabindex"):i.setAttribute("tabindex",s.tabIndex),"disabled"in i&&(i.disabled=s.disabled))}),a.modifiers.noInteraction&&(e.style.pointerEvents=""),a.modifiers.visual&&(e.style.opacity="",e.style.filter="",e.style.pointerEvents="")}}const I={mounted(e,a){const t=a.value||{},n={label:"aria-label",labelledby:"aria-labelledby",describedby:"aria-describedby",expanded:"aria-expanded",pressed:"aria-pressed",selected:"aria-selected",checked:"aria-checked",disabled:"aria-disabled",hidden:"aria-hidden",invalid:"aria-invalid",required:"aria-required",live:"aria-live",atomic:"aria-atomic",busy:"aria-busy",controls:"aria-controls",owns:"aria-owns",haspopup:"aria-haspopup",level:"aria-level",modal:"aria-modal",multiselectable:"aria-multiselectable",orientation:"aria-orientation",placeholder:"aria-placeholder",readonly:"aria-readonly",relevant:"aria-relevant",valuemax:"aria-valuemax",valuemin:"aria-valuemin",valuenow:"aria-valuenow",valuetext:"aria-valuetext"},i={};Object.entries(t).forEach(([r,s])=>{const c=n[r]||r;i[c]=s}),E(e,i),e.__ariaAttributes=Object.keys(i)},updated(e,a){if(JSON.stringify(a.value)!==JSON.stringify(a.oldValue)){e.__ariaAttributes&&e.__ariaAttributes.forEach(r=>e.removeAttribute(r));const t=a.value||{},n={label:"aria-label",labelledby:"aria-labelledby",describedby:"aria-describedby",expanded:"aria-expanded",pressed:"aria-pressed",selected:"aria-selected",checked:"aria-checked",disabled:"aria-disabled",hidden:"aria-hidden",invalid:"aria-invalid",required:"aria-required",live:"aria-live",atomic:"aria-atomic",busy:"aria-busy",controls:"aria-controls",owns:"aria-owns",haspopup:"aria-haspopup",level:"aria-level",modal:"aria-modal"},i={};Object.entries(t).forEach(([r,s])=>{const c=n[r]||r;i[c]=s}),E(e,i),e.__ariaAttributes=Object.keys(i)}},unmounted(e){e.__ariaAttributes&&(e.__ariaAttributes.forEach(a=>e.removeAttribute(a)),delete e.__ariaAttributes)}},K={mounted(e,a){const t=a.value||{},n=t.delay||100,i={panel:t.panelSelector||".el-picker-panel, .el-date-picker, .v-picker, .v-date-picker, .ant-picker-dropdown, .p-datepicker",selectedDay:t.selectedSelector||"td.is-selected, td.selected, td.is-today.is-selected, .v-date-picker-table__current, .ant-picker-cell-selected, .p-highlight",availableDay:t.availableSelector||"td:not(.disabled):not(.is-disabled):not([disabled]), .v-date-picker-table__events, .ant-picker-cell:not(.ant-picker-cell-disabled), .p-datepicker-calendar td:not(.p-disabled)",input:t.inputSelector||".el-input__inner, input, .v-text-field__input, .ant-picker-input, .p-inputtext"};let r=!1,s=null,c=null;const l=u=>{const v=u.getAttribute("aria-controls");let d=null;if(v&&(d=document.getElementById(v)),!d){const y=document.querySelectorAll(".el-picker-panel");for(const h of y)if(h.offsetParent!==null){d=h;break}}if(!d)return!1;let f=null;const q=d.querySelector("td.is-selected");if(q&&(f=q),!f){const y=d.querySelector("td.is-today");y&&(f=y)}if(!f){const y=d.querySelector(".el-date-table tbody td:not(.disabled):not(.is-disabled)");y&&(f=y)}if(!f)return!1;f.setAttribute("tabindex","0");let j=0;const z=10,U=()=>{if(j++,f.focus({preventScroll:!0}),document.activeElement===f)return!0;j<z&&setTimeout(U,10)};if(U(),!d.__a11yKeyboardHandlerAdded){d.__a11yKeyboardHandlerAdded=!0;const y=h=>{if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(h.key)){d.__a11yNavigatingWithKeyboard=!0;const Q=m=>{d.__a11yNavigatingWithKeyboard&&(m.preventDefault(),m.stopPropagation(),m.stopImmediatePropagation())};["click","mousedown","mouseup","pointerdown","pointerup"].forEach(m=>{d.addEventListener(m,Q,{capture:!0,once:!0})}),setTimeout(()=>{d.__a11yNavigatingWithKeyboard=!1},100)}};d.addEventListener("keydown",y),d.__a11yKeyboardHandler=y}return!0},b=u=>{c&&clearTimeout(c),requestAnimationFrame(()=>{c=setTimeout(()=>{l(u)},n)})},A=u=>{s=new MutationObserver(v=>{const d=document.querySelector(".el-picker-panel");d&&!r?(r=!0,b(u)):!d&&r&&(r=!1,c&&(clearTimeout(c),c=null))}),s.observe(document.body,{childList:!0,subtree:!0})},p=(()=>{let u=e.querySelector(i.input);return u||(u=e.querySelectorAll("input")[0]),u||e})();A(p);const w=()=>{};p.addEventListener("focus",w),p.addEventListener("click",w);const N=u=>{u.key==="Enter"||u.key};p.addEventListener("keydown",N);const G=(()=>{const u=new MutationObserver(v=>{v.forEach(d=>{d.type==="attributes"&&d.attributeName==="aria-expanded"&&p.getAttribute("aria-expanded")==="true"&&b(p)})});return u.observe(p,{attributes:!0,attributeFilter:["aria-expanded"]}),u})();e.__a11yDatePickerAriaObserver=G,e.__a11yDatePickerInput=p,e.__a11yDatePickerFocusHandler=w,e.__a11yDatePickerKeyHandler=N,e.__a11yDatePickerObserver=s},unmounted(e){if(e.__a11yDatePickerTimeout&&clearTimeout(e.__a11yDatePickerTimeout),e.__a11yDatePickerInput){const a=e.__a11yDatePickerInput;e.__a11yDatePickerFocusHandler&&(a.removeEventListener("focus",e.__a11yDatePickerFocusHandler),a.removeEventListener("click",e.__a11yDatePickerFocusHandler)),e.__a11yDatePickerKeyHandler&&a.removeEventListener("keydown",e.__a11yDatePickerKeyHandler)}e.__a11yDatePickerObserver&&e.__a11yDatePickerObserver.disconnect(),e.__a11yDatePickerAriaObserver&&e.__a11yDatePickerAriaObserver.disconnect(),delete e.__a11yDatePickerInput,delete e.__a11yDatePickerFocusHandler,delete e.__a11yDatePickerKeyHandler,delete e.__a11yDatePickerObserver,delete e.__a11yDatePickerAriaObserver,delete e.__a11yDatePickerTimeout}},H={"a11y-focus":S,"a11y-trap-focus":T,"a11y-keyboard":F,"a11y-announce":x,"a11y-skip-link":O,"a11y-skip":P,"a11y-aria":I,"a11y-date-picker":K};function C(e){Object.entries(H).forEach(([a,t])=>{e.directive(a,t)})}const J={install:C};o.a11yDirectives=H,o.announce=g,o.announceDirective=x,o.ariaDirective=I,o.containsActiveElement=W,o.datePickerDirective=K,o.default=J,o.focusDirective=S,o.generateId=$,o.getFirstFocusable=R,o.getFocusableElements=k,o.getLastFocusable=B,o.installA11yDirectives=C,o.keyboardDirective=F,o.removeAriaAttributes=M,o.restoreFocus=X,o.saveFocus=V,o.setAriaAttributes=E,o.skipDirective=P,o.skipLinkDirective=O,o.trapFocusDirective=T,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(o,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(o=typeof globalThis<"u"?globalThis:o||self,k(o.VueA11yDirectives={}))})(this,function(o){"use strict";const k=["BUTTON","A","INPUT","TEXTAREA","SELECT","IFRAME"],w={mounted(e,a){const t=typeof a.value=="object"?a.value:{delay:a.value||0},n=t.delay||0,i=t.select||!1;k.includes(e.tagName)||e.hasAttribute("tabindex")||e.hasAttribute("contenteditable")||(e.setAttribute("tabindex","0"),e.__a11yFocusAddedTabindex=!0),setTimeout(()=>{e.focus&&(e.focus(),i&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")&&e.select())},n)},unmounted(e){e.__a11yFocusAddedTabindex&&(e.removeAttribute("tabindex"),delete e.__a11yFocusAddedTabindex)}};function m(e){if(!e)return[];const a=["a[href]","button:not([disabled])","textarea:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"audio[controls]","video[controls]"];return Array.from(e.querySelectorAll(a.join(", "))).filter(n=>{const i=window.getComputedStyle(n);return n.offsetWidth>0&&n.offsetHeight>0&&i.visibility!=="hidden"&&i.display!=="none"})}function E(e,a){Object.entries(a).forEach(([t,n])=>{n!=null&&e.setAttribute(t,n)})}function B(e,a){a.forEach(t=>{e.removeAttribute(t)})}function g(e,a="polite"){const t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-live",a),t.setAttribute("aria-atomic","true"),t.style.position="absolute",t.style.left="-10000px",t.style.width="1px",t.style.height="1px",t.style.overflow="hidden",document.body.appendChild(t),setTimeout(()=>{t.textContent=e},100),setTimeout(()=>{document.body.removeChild(t)},3e3)}function G(e){const a=m(e);return a.length>0?a[0]:null}function V(e){const a=m(e);return a.length>0?a[a.length-1]:null}function W(e){return e.contains(document.activeElement)}function X(){return document.activeElement}function $(e){e&&e.focus&&e.focus()}function J(e="a11y"){return`${e}-${Math.random().toString(36).substr(2,9)}`}const T={mounted(e,a){const t=a.value||{},n=t.autoFocus!==!1,i=t.onEscape||null,r=document.activeElement;e.__previousFocus=r,n&&setTimeout(()=>{const l=m(e);l.length>0&&l[0].focus()},100);const s=l=>{if(l.key!=="Tab")return;const v=m(e);if(v.length===0)return;const h=v[0],D=v[v.length-1];l.shiftKey&&document.activeElement===h?(l.preventDefault(),D.focus()):!l.shiftKey&&document.activeElement===D&&(l.preventDefault(),h.focus())},c=l=>{l.key==="Escape"&&i&&(l.preventDefault(),l.stopPropagation(),i())};e.addEventListener("keydown",s),e.__handleKeydown=s,i&&(document.addEventListener("keydown",c,!0),e.__handleEscape=c)},unmounted(e){e.__handleKeydown&&(e.removeEventListener("keydown",e.__handleKeydown),delete e.__handleKeydown),e.__handleEscape&&(document.removeEventListener("keydown",e.__handleEscape,!0),delete e.__handleEscape),e.__previousFocus&&(setTimeout(()=>{if(e.__previousFocus&&document.body.contains(e.__previousFocus)&&typeof e.__previousFocus.focus=="function")try{e.__previousFocus.focus()}catch(a){console.warn("Could not restore focus:",a)}},0),delete e.__previousFocus)}},F={mounted(e,a){const t=a.value||{};console.log("Keyboard directive mounted with config:",t);const n=i=>{console.log("Key pressed:",i.key,"Config:",t);const r={Enter:"enter"," ":"space",Escape:"escape",ArrowUp:"arrowUp",ArrowDown:"arrowDown",ArrowLeft:"arrowLeft",ArrowRight:"arrowRight",Tab:"tab",Delete:"delete",Backspace:"backspace"};let s="";(i.ctrlKey||i.metaKey)&&(s+="ctrl+"),i.altKey&&(s+="alt+"),i.shiftKey&&(s+="shift+"),s+=i.key.toLowerCase();const c=r[i.key];if(c&&typeof t[c]=="function"){i.preventDefault(),t[c](i);return}if(t[s]&&typeof t[s]=="function"){i.preventDefault(),t[s](i);return}if(t[i.key]&&typeof t[i.key]=="function"){i.preventDefault(),t[i.key](i);return}if(t.arrows&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(i.key)&&typeof t.arrows=="function"){i.preventDefault(),t.arrows(i);return}if(t.handlers){if(t.handlers[i.key]&&typeof t.handlers[i.key]=="function"){i.preventDefault(),t.handlers[i.key](i);return}if(t.handlers[s]&&typeof t.handlers[s]=="function"){i.preventDefault(),t.handlers[s](i);return}}if(t.custom&&typeof t.custom=="function"){t.custom(i);return}t.enter===!0&&i.key==="Enter"&&!["INPUT","TEXTAREA","SELECT"].includes(i.target.tagName)&&(i.preventDefault(),e.click&&e.click()),t.space===!0&&i.key===" "&&["BUTTON","A"].includes(e.tagName)&&(i.preventDefault(),e.click&&e.click())};e.addEventListener("keydown",n),e.__keyboardHandler=n},unmounted(e){e.__keyboardHandler&&(e.removeEventListener("keydown",e.__keyboardHandler),delete e.__keyboardHandler)}},x={mounted(e,a){if(!a.value)return;const t=typeof a.value=="string"?{message:a.value,priority:"polite"}:a.value;t&&t.message&&g(t.message,t.priority||"polite")},updated(e,a){if(a.value!==a.oldValue&&a.value){const t=typeof a.value=="string"?{message:a.value,priority:"polite"}:a.value;t&&t.message&&g(t.message,t.priority||"polite")}}},O={mounted(e,a){const t=a.value,n=i=>{i.preventDefault();const r=document.querySelector(t);r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus(),r.scrollIntoView({behavior:"smooth",block:"start"}))};e.addEventListener("click",n),e.__skipLinkHandler=n,e.setAttribute("role","link"),t&&e.setAttribute("aria-label",`Skip to ${t.replace("#","")}`)},unmounted(e){e.__skipLinkHandler&&(e.removeEventListener("click",e.__skipLinkHandler),delete e.__skipLinkHandler)}},P={mounted(e,a){L(e,a)},updated(e,a){L(e,a)},unmounted(e){delete e.__a11ySkipOriginalTabIndex,delete e.__a11ySkipOriginalAriaHidden,delete e.__a11ySkipChildrenState}};function L(e,a){if(a.value===void 0?!0:!!a.value){e.__a11ySkipOriginalTabIndex===void 0&&(e.__a11ySkipOriginalTabIndex=e.getAttribute("tabindex")),e.__a11ySkipOriginalAriaHidden===void 0&&(e.__a11ySkipOriginalAriaHidden=e.getAttribute("aria-hidden")),e.setAttribute("tabindex","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute("data-a11y-skip","true");const n=e.querySelectorAll('a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])');e.__a11ySkipChildrenState||(e.__a11ySkipChildrenState=[]),n.forEach((i,r)=>{e.__a11ySkipChildrenState[r]||(e.__a11ySkipChildrenState[r]={tabIndex:i.getAttribute("tabindex"),disabled:i.disabled}),i.setAttribute("tabindex","-1"),"disabled"in i&&(i.disabled=!0)}),a.modifiers.noInteraction&&(e.style.pointerEvents="none"),a.modifiers.visual&&(e.style.opacity="0.5",e.style.filter="grayscale(100%)",e.style.pointerEvents="none")}else{e.__a11ySkipOriginalTabIndex!==void 0?e.__a11ySkipOriginalTabIndex===null?e.removeAttribute("tabindex"):e.setAttribute("tabindex",e.__a11ySkipOriginalTabIndex):e.removeAttribute("tabindex"),e.__a11ySkipOriginalAriaHidden!==void 0?e.__a11ySkipOriginalAriaHidden===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",e.__a11ySkipOriginalAriaHidden):e.removeAttribute("aria-hidden"),e.removeAttribute("data-a11y-skip");const n=e.querySelectorAll("a, button, input, select, textarea, [tabindex]");e.__a11ySkipChildrenState&&n.forEach((i,r)=>{const s=e.__a11ySkipChildrenState[r];s&&(s.tabIndex===null?i.removeAttribute("tabindex"):i.setAttribute("tabindex",s.tabIndex),"disabled"in i&&(i.disabled=s.disabled))}),a.modifiers.noInteraction&&(e.style.pointerEvents=""),a.modifiers.visual&&(e.style.opacity="",e.style.filter="",e.style.pointerEvents="")}}const I={mounted(e,a){const t=a.value||{},n={label:"aria-label",labelledby:"aria-labelledby",describedby:"aria-describedby",expanded:"aria-expanded",pressed:"aria-pressed",selected:"aria-selected",checked:"aria-checked",disabled:"aria-disabled",hidden:"aria-hidden",invalid:"aria-invalid",required:"aria-required",live:"aria-live",atomic:"aria-atomic",busy:"aria-busy",controls:"aria-controls",owns:"aria-owns",haspopup:"aria-haspopup",level:"aria-level",modal:"aria-modal",multiselectable:"aria-multiselectable",orientation:"aria-orientation",placeholder:"aria-placeholder",readonly:"aria-readonly",relevant:"aria-relevant",valuemax:"aria-valuemax",valuemin:"aria-valuemin",valuenow:"aria-valuenow",valuetext:"aria-valuetext"},i={};Object.entries(t).forEach(([r,s])=>{const c=n[r]||r;i[c]=s}),E(e,i),e.__ariaAttributes=Object.keys(i)},updated(e,a){if(JSON.stringify(a.value)!==JSON.stringify(a.oldValue)){e.__ariaAttributes&&e.__ariaAttributes.forEach(r=>e.removeAttribute(r));const t=a.value||{},n={label:"aria-label",labelledby:"aria-labelledby",describedby:"aria-describedby",expanded:"aria-expanded",pressed:"aria-pressed",selected:"aria-selected",checked:"aria-checked",disabled:"aria-disabled",hidden:"aria-hidden",invalid:"aria-invalid",required:"aria-required",live:"aria-live",atomic:"aria-atomic",busy:"aria-busy",controls:"aria-controls",owns:"aria-owns",haspopup:"aria-haspopup",level:"aria-level",modal:"aria-modal"},i={};Object.entries(t).forEach(([r,s])=>{const c=n[r]||r;i[c]=s}),E(e,i),e.__ariaAttributes=Object.keys(i)}},unmounted(e){e.__ariaAttributes&&(e.__ariaAttributes.forEach(a=>e.removeAttribute(a)),delete e.__ariaAttributes)}},K={mounted(e,a){const t=a.value||{},n=t.delay||100,i={panel:t.panelSelector||".el-picker-panel, .el-date-picker, .v-picker, .v-date-picker, .ant-picker-dropdown, .p-datepicker",selectedDay:t.selectedSelector||"td.is-selected, td.selected, td.is-today.is-selected, .v-date-picker-table__current, .ant-picker-cell-selected, .p-highlight",availableDay:t.availableSelector||"td:not(.disabled):not(.is-disabled):not([disabled]), .v-date-picker-table__events, .ant-picker-cell:not(.ant-picker-cell-disabled), .p-datepicker-calendar td:not(.p-disabled)",input:t.inputSelector||".el-input__inner, input, .v-text-field__input, .ant-picker-input, .p-inputtext"};let r=!1,s=null,c=null;const l=u=>{const _=u.getAttribute("aria-controls");let d=null;if(_&&(d=document.getElementById(_)),!d){const y=document.querySelectorAll(".el-picker-panel");for(const A of y)if(A.offsetParent!==null){d=A;break}}if(!d)return!1;let f=null;const q=d.querySelector("td.is-selected");if(q&&(f=q),!f){const y=d.querySelector("td.is-today");y&&(f=y)}if(!f){const y=d.querySelector(".el-date-table tbody td:not(.disabled):not(.is-disabled)");y&&(f=y)}if(!f)return!1;f.setAttribute("tabindex","0");let U=0;const Y=10,j=()=>{if(U++,f.focus({preventScroll:!0}),document.activeElement===f)return!0;U<Y&&setTimeout(j,10)};j();const M=y=>{if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(y.key)){y.preventDefault(),d.__a11yNavigatingWithKeyboard=!0;const A=b=>(console.log("[DEBUG] Preventing",b.type,"during keyboard navigation"),b.preventDefault(),b.stopPropagation(),b.stopImmediatePropagation(),!1),R=["click","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"];R.forEach(b=>{d.addEventListener(b,A,{capture:!0,once:!0})}),d.querySelectorAll("td").forEach(b=>{R.forEach(Z=>{b.addEventListener(Z,A,{capture:!0,once:!0})})}),setTimeout(()=>{d.__a11yNavigatingWithKeyboard=!1,console.log("[DEBUG] Keyboard navigation complete")},50)}};return d.__a11yKeyboardHandlerAdded||(d.__a11yKeyboardHandlerAdded=!0,d.addEventListener("keydown",M,{capture:!0}),d.__a11yKeyboardHandler=M,console.log("[DEBUG] Keyboard navigation handler installed")),!0},v=u=>{c&&clearTimeout(c),requestAnimationFrame(()=>{c=setTimeout(()=>{l(u)},n)})},h=u=>{s=new MutationObserver(_=>{const d=document.querySelector(".el-picker-panel");d&&!r?(r=!0,v(u)):!d&&r&&(r=!1,c&&(clearTimeout(c),c=null))}),s.observe(document.body,{childList:!0,subtree:!0})},p=(()=>{let u=e.querySelector(i.input);return u||(u=e.querySelectorAll("input")[0]),u||e})();h(p);const S=()=>{};p.addEventListener("focus",S),p.addEventListener("click",S);const N=u=>{u.key==="Enter"||u.key};p.addEventListener("keydown",N);const Q=(()=>{const u=new MutationObserver(_=>{_.forEach(d=>{d.type==="attributes"&&d.attributeName==="aria-expanded"&&p.getAttribute("aria-expanded")==="true"&&v(p)})});return u.observe(p,{attributes:!0,attributeFilter:["aria-expanded"]}),u})();e.__a11yDatePickerAriaObserver=Q,e.__a11yDatePickerInput=p,e.__a11yDatePickerFocusHandler=S,e.__a11yDatePickerKeyHandler=N,e.__a11yDatePickerObserver=s},unmounted(e){if(e.__a11yDatePickerTimeout&&clearTimeout(e.__a11yDatePickerTimeout),e.__a11yDatePickerInput){const a=e.__a11yDatePickerInput;e.__a11yDatePickerFocusHandler&&(a.removeEventListener("focus",e.__a11yDatePickerFocusHandler),a.removeEventListener("click",e.__a11yDatePickerFocusHandler)),e.__a11yDatePickerKeyHandler&&a.removeEventListener("keydown",e.__a11yDatePickerKeyHandler)}e.__a11yDatePickerObserver&&e.__a11yDatePickerObserver.disconnect(),e.__a11yDatePickerAriaObserver&&e.__a11yDatePickerAriaObserver.disconnect(),delete e.__a11yDatePickerInput,delete e.__a11yDatePickerFocusHandler,delete e.__a11yDatePickerKeyHandler,delete e.__a11yDatePickerObserver,delete e.__a11yDatePickerAriaObserver,delete e.__a11yDatePickerTimeout}},H={"a11y-focus":w,"a11y-trap-focus":T,"a11y-keyboard":F,"a11y-announce":x,"a11y-skip-link":O,"a11y-skip":P,"a11y-aria":I,"a11y-date-picker":K};function C(e){Object.entries(H).forEach(([a,t])=>{e.directive(a,t)})}const z={install:C};o.a11yDirectives=H,o.announce=g,o.announceDirective=x,o.ariaDirective=I,o.containsActiveElement=W,o.datePickerDirective=K,o.default=z,o.focusDirective=w,o.generateId=J,o.getFirstFocusable=G,o.getFocusableElements=m,o.getLastFocusable=V,o.installA11yDirectives=C,o.keyboardDirective=F,o.removeAriaAttributes=B,o.restoreFocus=$,o.saveFocus=X,o.setAriaAttributes=E,o.skipDirective=P,o.skipLinkDirective=O,o.trapFocusDirective=T,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-a11y-directives",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "A comprehensive set of Vue 3 directives for building accessible web applications with WCAG compliance",
5
5
  "main": "dist/vue-a11y-directives.cjs.js",
6
6
  "module": "dist/vue-a11y-directives.esm.js",
@@ -127,39 +127,60 @@ export default {
127
127
 
128
128
  // Setup keyboard navigation handler on the calendar panel
129
129
  // This prevents auto-selection when using arrow keys
130
- if (!calendarPanel.__a11yKeyboardHandlerAdded) {
131
- calendarPanel.__a11yKeyboardHandlerAdded = true;
132
-
133
- const handleKeyboardNav = (e) => {
134
- // Check if it's an arrow key
135
- if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
136
- // Mark that we're navigating with keyboard
137
- calendarPanel.__a11yNavigatingWithKeyboard = true;
138
-
139
- // Prevent any click events that might be triggered
140
- const preventClickDuringNav = (clickEvent) => {
141
- if (calendarPanel.__a11yNavigatingWithKeyboard) {
142
- clickEvent.preventDefault();
143
- clickEvent.stopPropagation();
144
- clickEvent.stopImmediatePropagation();
145
- }
146
- };
147
-
148
- // Add click preventers
149
- const eventTypes = ['click', 'mousedown', 'mouseup', 'pointerdown', 'pointerup'];
130
+ // We need to capture the keydown BEFORE Element Plus processes it
131
+ const handleKeyboardNav = (e) => {
132
+ // Check if it's an arrow key
133
+ if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
134
+ // Find the currently focused cell
135
+ const focusedCell = document.activeElement;
136
+
137
+ // Prevent any default behavior on the table/cell
138
+ e.preventDefault();
139
+
140
+ // Mark that we're navigating with keyboard
141
+ calendarPanel.__a11yNavigatingWithKeyboard = true;
142
+
143
+ // Prevent ALL click/selection events that might be triggered
144
+ const preventAutoSelect = (event) => {
145
+ console.log('[DEBUG] Preventing', event.type, 'during keyboard navigation');
146
+ event.preventDefault();
147
+ event.stopPropagation();
148
+ event.stopImmediatePropagation();
149
+ return false;
150
+ };
151
+
152
+ // Add preventers for all possible selection events
153
+ const eventTypes = ['click', 'mousedown', 'mouseup', 'pointerdown', 'pointerup', 'touchstart', 'touchend'];
154
+
155
+ // Add to the entire calendar panel
156
+ eventTypes.forEach(eventType => {
157
+ calendarPanel.addEventListener(eventType, preventAutoSelect, { capture: true, once: true });
158
+ });
159
+
160
+ // Also add to all table cells to be extra safe
161
+ const allCells = calendarPanel.querySelectorAll('td');
162
+ allCells.forEach(cell => {
150
163
  eventTypes.forEach(eventType => {
151
- calendarPanel.addEventListener(eventType, preventClickDuringNav, { capture: true, once: true });
164
+ cell.addEventListener(eventType, preventAutoSelect, { capture: true, once: true });
152
165
  });
153
-
154
- // Clear the flag after a short delay
155
- setTimeout(() => {
156
- calendarPanel.__a11yNavigatingWithKeyboard = false;
157
- }, 100);
158
- }
159
- };
160
-
161
- calendarPanel.addEventListener('keydown', handleKeyboardNav);
166
+ });
167
+
168
+ // Let Element Plus's navigation happen (it moves focus)
169
+ // But our preventers will stop any selection
170
+ setTimeout(() => {
171
+ // Clear the flag after Element Plus has moved focus
172
+ calendarPanel.__a11yNavigatingWithKeyboard = false;
173
+ console.log('[DEBUG] Keyboard navigation complete');
174
+ }, 50);
175
+ }
176
+ };
177
+
178
+ // Add keyboard handler with capture: true to intercept BEFORE Element Plus
179
+ if (!calendarPanel.__a11yKeyboardHandlerAdded) {
180
+ calendarPanel.__a11yKeyboardHandlerAdded = true;
181
+ calendarPanel.addEventListener('keydown', handleKeyboardNav, { capture: true });
162
182
  calendarPanel.__a11yKeyboardHandler = handleKeyboardNav;
183
+ console.log('[DEBUG] Keyboard navigation handler installed');
163
184
  }
164
185
 
165
186
  return true;