mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 13:57:10 -04:00
1 line
1.3 KiB
JavaScript
1 line
1.3 KiB
JavaScript
import{ab as m,ac as f,ad as c}from"../entries/src_pages_Home.page.16dc467b.js";import{e as y,o as h,a1 as w,$ as b,A as v}from"./chunk-449c23a2.js";function M(u,n){let{target:e}=u;for(;e;){if(e.dataset&&e.dataset[n]!==void 0)return!0;e=e.parentElement}return!1}function j(u={},n){const e=y({ctrl:!1,command:!1,win:!1,shift:!1,tab:!1}),{keydown:i,keyup:d}=u,o=t=>{switch(t.key){case"Control":e.ctrl=!0;break;case"Meta":e.command=!0,e.win=!0;break;case"Shift":e.shift=!0;break;case"Tab":e.tab=!0;break}i!==void 0&&Object.keys(i).forEach(s=>{if(s!==t.key)return;const a=i[s];if(typeof a=="function")a(t);else{const{stop:l=!1,prevent:p=!1}=a;l&&t.stopPropagation(),p&&t.preventDefault(),a.handler(t)}})},r=t=>{switch(t.key){case"Control":e.ctrl=!1;break;case"Meta":e.command=!1,e.win=!1;break;case"Shift":e.shift=!1;break;case"Tab":e.tab=!1;break}d!==void 0&&Object.keys(d).forEach(s=>{if(s!==t.key)return;const a=d[s];if(typeof a=="function")a(t);else{const{stop:l=!1,prevent:p=!1}=a;l&&t.stopPropagation(),p&&t.preventDefault(),a.handler(t)}})},k=()=>{(n===void 0||n.value)&&(c("keydown",document,o),c("keyup",document,r)),n!==void 0&&v(n,t=>{t?(c("keydown",document,o),c("keyup",document,r)):(f("keydown",document,o),f("keyup",document,r))})};return m()?(h(k),w(()=>{(n===void 0||n.value)&&(f("keydown",document,o),f("keyup",document,r))})):k(),b(e)}export{M as h,j as u};
|