vue-a11y-directives 1.2.7 → 1.2.9
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 W=["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;W.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 V(e,a){a.forEach(t=>{e.removeAttribute(t)})}function D(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 X(e){const a=k(e);return a.length>0?a[0]:null}function $(e){const a=k(e);return a.length>0?a[a.length-1]:null}function J(e){return e.contains(document.activeElement)}function G(){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 y=k(e);if(y.length===0)return;const m=y[0],A=y[y.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&&D(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&&D(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 _=b=>(b.preventDefault(),b.stopPropagation(),b.stopImmediatePropagation(),!1),F=["click","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"];F.forEach(b=>{s.addEventListener(b,_,{capture:!0,once:!0})}),s.querySelectorAll("td").forEach(b=>{F.forEach(B=>{b.addEventListener(B,_,{capture:!0,once:!0})})}),setTimeout(()=>{s.__a11yNavigatingWithKeyboard=!1},50)}};return s.__a11yKeyboardHandlerAdded||(s.__a11yKeyboardHandlerAdded=!0,s.addEventListener("keydown",T,{capture:!0}),s.__a11yKeyboardHandler=T),!0},y=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,y(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 g=d=>{d.key==="Enter"||d.key};p.addEventListener("keydown",g);const M=(()=>{const d=new MutationObserver(v=>{v.forEach(s=>{s.type==="attributes"&&s.attributeName==="aria-expanded"&&p.getAttribute("aria-expanded")==="true"&&y(p)})});return d.observe(p,{attributes:!0,attributeFilter:["aria-expanded"]}),d})();e.__a11yDatePickerAriaObserver=M,e.__a11yDatePickerInput=p,e.__a11yDatePickerFocusHandler=h,e.__a11yDatePickerKeyHandler=g,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=D;exports.announceDirective=K;exports.ariaDirective=N;exports.containsActiveElement=J;exports.datePickerDirective=q;exports.default=Y;exports.focusDirective=P;exports.generateId=Q;exports.getFirstFocusable=X;exports.getFocusableElements=k;exports.getLastFocusable=$;exports.installA11yDirectives=j;exports.keyboardDirective=I;exports.removeAriaAttributes=V;exports.restoreFocus=z;exports.saveFocus=G;exports.setAriaAttributes=E;exports.skipDirective=C;exports.skipLinkDirective=H;exports.trapFocusDirective=L;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const W=["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;W.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 V(e,a){a.forEach(t=>{e.removeAttribute(t)})}function D(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 X(e){const a=k(e);return a.length>0?a[0]:null}function $(e){const a=k(e);return a.length>0?a[a.length-1]:null}function J(e){return e.contains(document.activeElement)}function G(){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 y=k(e);if(y.length===0)return;const m=y[0],A=y[y.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||{},n=i=>{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)}},H={mounted(e,a){if(!a.value)return;const t=typeof a.value=="string"?{message:a.value,priority:"polite"}:a.value;t&&t.message&&D(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&&D(t.message,t.priority||"polite")}}},K={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 _=b=>(b.preventDefault(),b.stopPropagation(),b.stopImmediatePropagation(),!1),F=["click","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"];F.forEach(b=>{s.addEventListener(b,_,{capture:!0,once:!0})}),s.querySelectorAll("td").forEach(b=>{F.forEach(B=>{b.addEventListener(B,_,{capture:!0,once:!0})})}),setTimeout(()=>{s.__a11yNavigatingWithKeyboard=!1},50)}};return s.__a11yKeyboardHandlerAdded||(s.__a11yKeyboardHandlerAdded=!0,s.addEventListener("keydown",T,{capture:!0}),s.__a11yKeyboardHandler=T),!0},y=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,y(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 g=d=>{d.key==="Enter"||d.key};p.addEventListener("keydown",g);const M=(()=>{const d=new MutationObserver(v=>{v.forEach(s=>{s.type==="attributes"&&s.attributeName==="aria-expanded"&&p.getAttribute("aria-expanded")==="true"&&y(p)})});return d.observe(p,{attributes:!0,attributeFilter:["aria-expanded"]}),d})();e.__a11yDatePickerAriaObserver=M,e.__a11yDatePickerInput=p,e.__a11yDatePickerFocusHandler=h,e.__a11yDatePickerKeyHandler=g,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":H,"a11y-skip-link":K,"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=D;exports.announceDirective=H;exports.ariaDirective=N;exports.containsActiveElement=J;exports.datePickerDirective=q;exports.default=Y;exports.focusDirective=P;exports.generateId=Q;exports.getFirstFocusable=X;exports.getFocusableElements=k;exports.getLastFocusable=$;exports.installA11yDirectives=j;exports.keyboardDirective=I;exports.removeAriaAttributes=V;exports.restoreFocus=z;exports.saveFocus=G;exports.setAriaAttributes=E;exports.skipDirective=C;exports.skipLinkDirective=K;exports.trapFocusDirective=L;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const H = ["BUTTON", "A", "INPUT", "TEXTAREA", "SELECT", "IFRAME"], K = {
|
|
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
|
-
|
|
4
|
+
H.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
|
},
|
|
@@ -95,10 +95,7 @@ const C = {
|
|
|
95
95
|
}
|
|
96
96
|
}, N = {
|
|
97
97
|
mounted(e, a) {
|
|
98
|
-
const t = a.value || {}
|
|
99
|
-
console.log("Keyboard directive mounted with config:", t);
|
|
100
|
-
const n = (i) => {
|
|
101
|
-
console.log("Key pressed:", i.key, "Config:", t);
|
|
98
|
+
const t = a.value || {}, n = (i) => {
|
|
102
99
|
const r = {
|
|
103
100
|
Enter: "enter",
|
|
104
101
|
" ": "space",
|
|
@@ -306,8 +303,8 @@ const j = {
|
|
|
306
303
|
if (!s)
|
|
307
304
|
return !1;
|
|
308
305
|
let l = null;
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
306
|
+
const S = s.querySelector("td.is-selected");
|
|
307
|
+
if (S && (l = S), !l) {
|
|
311
308
|
const f = s.querySelector("td.is-today");
|
|
312
309
|
f && (l = f);
|
|
313
310
|
}
|
|
@@ -319,20 +316,20 @@ const j = {
|
|
|
319
316
|
return !1;
|
|
320
317
|
l.setAttribute("tabindex", "0");
|
|
321
318
|
let w = 0;
|
|
322
|
-
const L = 10,
|
|
319
|
+
const L = 10, x = () => {
|
|
323
320
|
if (w++, l.focus({ preventScroll: !0 }), document.activeElement === l)
|
|
324
321
|
return !0;
|
|
325
|
-
w < L && setTimeout(
|
|
322
|
+
w < L && setTimeout(x, 10);
|
|
326
323
|
};
|
|
327
|
-
|
|
328
|
-
const
|
|
324
|
+
x();
|
|
325
|
+
const D = (f) => {
|
|
329
326
|
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(f.key)) {
|
|
330
327
|
f.preventDefault(), s.__a11yNavigatingWithKeyboard = !0;
|
|
331
|
-
const v = (b) => (b.preventDefault(), b.stopPropagation(), b.stopImmediatePropagation(), !1),
|
|
332
|
-
|
|
328
|
+
const v = (b) => (b.preventDefault(), b.stopPropagation(), b.stopImmediatePropagation(), !1), g = ["click", "mousedown", "mouseup", "pointerdown", "pointerup", "touchstart", "touchend"];
|
|
329
|
+
g.forEach((b) => {
|
|
333
330
|
s.addEventListener(b, v, { capture: !0, once: !0 });
|
|
334
331
|
}), s.querySelectorAll("td").forEach((b) => {
|
|
335
|
-
|
|
332
|
+
g.forEach((I) => {
|
|
336
333
|
b.addEventListener(I, v, { capture: !0, once: !0 });
|
|
337
334
|
});
|
|
338
335
|
}), setTimeout(() => {
|
|
@@ -340,7 +337,7 @@ const j = {
|
|
|
340
337
|
}, 50);
|
|
341
338
|
}
|
|
342
339
|
};
|
|
343
|
-
return s.__a11yKeyboardHandlerAdded || (s.__a11yKeyboardHandlerAdded = !0, s.addEventListener("keydown",
|
|
340
|
+
return s.__a11yKeyboardHandlerAdded || (s.__a11yKeyboardHandlerAdded = !0, s.addEventListener("keydown", D, { capture: !0 }), s.__a11yKeyboardHandler = D), !0;
|
|
344
341
|
}, y = (c) => {
|
|
345
342
|
d && clearTimeout(d), requestAnimationFrame(() => {
|
|
346
343
|
d = setTimeout(() => {
|
|
@@ -388,7 +385,7 @@ const j = {
|
|
|
388
385
|
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;
|
|
389
386
|
}
|
|
390
387
|
}, B = {
|
|
391
|
-
"a11y-focus":
|
|
388
|
+
"a11y-focus": K,
|
|
392
389
|
"a11y-trap-focus": C,
|
|
393
390
|
"a11y-keyboard": N,
|
|
394
391
|
"a11y-announce": q,
|
|
@@ -413,7 +410,7 @@ export {
|
|
|
413
410
|
z as containsActiveElement,
|
|
414
411
|
M as datePickerDirective,
|
|
415
412
|
ee as default,
|
|
416
|
-
|
|
413
|
+
K as focusDirective,
|
|
417
414
|
Z as generateId,
|
|
418
415
|
J as getFirstFocusable,
|
|
419
416
|
m as getFocusableElements,
|
|
@@ -1 +1 @@
|
|
|
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 D(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=m(e);return a.length>0?a[0]:null}function W(e){const a=m(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 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 b=m(e);if(b.length===0)return;const h=b[0],g=b[b.length-1];l.shiftKey&&document.activeElement===h?(l.preventDefault(),g.focus()):!l.shiftKey&&document.activeElement===g&&(l.preventDefault(),h.focus())},d=l=>{l.key==="Escape"&&i&&(l.preventDefault(),l.stopPropagation(),i())};e.addEventListener("keydown",s),e.__handleKeydown=s,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)}},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 d=r[i.key];if(d&&typeof t[d]=="function"){i.preventDefault(),t[d](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&&D(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&&D(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 d=n[r]||r;i[d]=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 d=n[r]||r;i[d]=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,d=null;const l=u=>{const _=u.getAttribute("aria-controls");let c=null;if(_&&(c=document.getElementById(_)),!c){const y=document.querySelectorAll(".el-picker-panel");for(const A of y)if(A.offsetParent!==null){c=A;break}}if(!c)return!1;let f=null;const q=c.querySelector("td.is-selected");if(q&&(f=q),!f){const y=c.querySelector("td.is-today");y&&(f=y)}if(!f){const y=c.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 Y=10,U=()=>{if(j++,f.focus({preventScroll:!0}),document.activeElement===f)return!0;j<Y&&setTimeout(U,10)};U();const M=y=>{if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(y.key)){y.preventDefault(),c.__a11yNavigatingWithKeyboard=!0;const A=v=>(v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation(),!1),R=["click","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"];R.forEach(v=>{c.addEventListener(v,A,{capture:!0,once:!0})}),c.querySelectorAll("td").forEach(v=>{R.forEach(Z=>{v.addEventListener(Z,A,{capture:!0,once:!0})})}),setTimeout(()=>{c.__a11yNavigatingWithKeyboard=!1},50)}};return c.__a11yKeyboardHandlerAdded||(c.__a11yKeyboardHandlerAdded=!0,c.addEventListener("keydown",M,{capture:!0}),c.__a11yKeyboardHandler=M),!0},b=u=>{d&&clearTimeout(d),requestAnimationFrame(()=>{d=setTimeout(()=>{l(u)},n)})},h=u=>{s=new MutationObserver(_=>{const c=document.querySelector(".el-picker-panel");c&&!r?(r=!0,b(u)):!c&&r&&(r=!1,d&&(clearTimeout(d),d=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(c=>{c.type==="attributes"&&c.attributeName==="aria-expanded"&&p.getAttribute("aria-expanded")==="true"&&b(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=D,o.announceDirective=x,o.ariaDirective=I,o.containsActiveElement=X,o.datePickerDirective=K,o.default=z,o.focusDirective=w,o.generateId=G,o.getFirstFocusable=V,o.getFocusableElements=m,o.getLastFocusable=W,o.installA11yDirectives=C,o.keyboardDirective=F,o.removeAriaAttributes=B,o.restoreFocus=J,o.saveFocus=$,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 D(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=m(e);return a.length>0?a[0]:null}function W(e){const a=m(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 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 b=m(e);if(b.length===0)return;const h=b[0],g=b[b.length-1];l.shiftKey&&document.activeElement===h?(l.preventDefault(),g.focus()):!l.shiftKey&&document.activeElement===g&&(l.preventDefault(),h.focus())},d=l=>{l.key==="Escape"&&i&&(l.preventDefault(),l.stopPropagation(),i())};e.addEventListener("keydown",s),e.__handleKeydown=s,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)}},F={mounted(e,a){const t=a.value||{},n=i=>{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 d=r[i.key];if(d&&typeof t[d]=="function"){i.preventDefault(),t[d](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&&D(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&&D(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 d=n[r]||r;i[d]=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 d=n[r]||r;i[d]=s}),E(e,i),e.__ariaAttributes=Object.keys(i)}},unmounted(e){e.__ariaAttributes&&(e.__ariaAttributes.forEach(a=>e.removeAttribute(a)),delete e.__ariaAttributes)}},H={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,d=null;const l=u=>{const _=u.getAttribute("aria-controls");let c=null;if(_&&(c=document.getElementById(_)),!c){const y=document.querySelectorAll(".el-picker-panel");for(const A of y)if(A.offsetParent!==null){c=A;break}}if(!c)return!1;let f=null;const q=c.querySelector("td.is-selected");if(q&&(f=q),!f){const y=c.querySelector("td.is-today");y&&(f=y)}if(!f){const y=c.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 Y=10,U=()=>{if(j++,f.focus({preventScroll:!0}),document.activeElement===f)return!0;j<Y&&setTimeout(U,10)};U();const M=y=>{if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(y.key)){y.preventDefault(),c.__a11yNavigatingWithKeyboard=!0;const A=v=>(v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation(),!1),R=["click","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"];R.forEach(v=>{c.addEventListener(v,A,{capture:!0,once:!0})}),c.querySelectorAll("td").forEach(v=>{R.forEach(Z=>{v.addEventListener(Z,A,{capture:!0,once:!0})})}),setTimeout(()=>{c.__a11yNavigatingWithKeyboard=!1},50)}};return c.__a11yKeyboardHandlerAdded||(c.__a11yKeyboardHandlerAdded=!0,c.addEventListener("keydown",M,{capture:!0}),c.__a11yKeyboardHandler=M),!0},b=u=>{d&&clearTimeout(d),requestAnimationFrame(()=>{d=setTimeout(()=>{l(u)},n)})},h=u=>{s=new MutationObserver(_=>{const c=document.querySelector(".el-picker-panel");c&&!r?(r=!0,b(u)):!c&&r&&(r=!1,d&&(clearTimeout(d),d=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(c=>{c.type==="attributes"&&c.attributeName==="aria-expanded"&&p.getAttribute("aria-expanded")==="true"&&b(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}},K={"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":H};function C(e){Object.entries(K).forEach(([a,t])=>{e.directive(a,t)})}const z={install:C};o.a11yDirectives=K,o.announce=D,o.announceDirective=x,o.ariaDirective=I,o.containsActiveElement=X,o.datePickerDirective=H,o.default=z,o.focusDirective=w,o.generateId=G,o.getFirstFocusable=V,o.getFocusableElements=m,o.getLastFocusable=W,o.installA11yDirectives=C,o.keyboardDirective=F,o.removeAriaAttributes=B,o.restoreFocus=J,o.saveFocus=$,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.
|
|
3
|
+
"version": "1.2.9",
|
|
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",
|
|
@@ -11,10 +11,8 @@
|
|
|
11
11
|
export default {
|
|
12
12
|
mounted(el, binding) {
|
|
13
13
|
const config = binding.value || {};
|
|
14
|
-
console.log('Keyboard directive mounted with config:', config);
|
|
15
14
|
|
|
16
15
|
const handleKeydown = (e) => {
|
|
17
|
-
console.log('Key pressed:', e.key, 'Config:', config);
|
|
18
16
|
|
|
19
17
|
// Check for direct key handlers first
|
|
20
18
|
const keyMappings = {
|