WordPress/wp-includes/js/dist/keyboard-shortcuts.min.js
ellatrix 1fbf5fa51d Editor: Update npm packages.
Updates the editor npm packages to latest versions.

See https://github.com/WordPress/wordpress-develop/pull/6612.

Props ellatrix, mukesh27, youknowriad, mamaduka.


Built from https://develop.svn.wordpress.org/trunk@58187


git-svn-id: http://core.svn.wordpress.org/trunk@57650 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-23 19:39:28 +00:00

2 lines
2.9 KiB
JavaScript

/*! This file is auto-generated */
(()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ShortcutProvider:()=>K,__unstableUseShortcutEventMatch:()=>R,store:()=>h,useShortcut:()=>T});var o={};e.r(o),e.d(o,{registerShortcut:()=>i,unregisterShortcut:()=>a});var r={};e.r(r),e.d(r,{getAllShortcutKeyCombinations:()=>w,getAllShortcutRawKeyCombinations:()=>p,getCategoryShortcuts:()=>b,getShortcutAliases:()=>m,getShortcutDescription:()=>f,getShortcutKeyCombination:()=>y,getShortcutRepresentation:()=>S});const n=window.wp.data;const c=function(e={},t){switch(t.type){case"REGISTER_SHORTCUT":return{...e,[t.name]:{category:t.category,keyCombination:t.keyCombination,aliases:t.aliases,description:t.description}};case"UNREGISTER_SHORTCUT":const{[t.name]:o,...r}=e;return r}return e};function i({name:e,category:t,description:o,keyCombination:r,aliases:n}){return{type:"REGISTER_SHORTCUT",name:e,category:t,keyCombination:r,aliases:n,description:o}}function a(e){return{type:"UNREGISTER_SHORTCUT",name:e}}const s=window.wp.keycodes,u=[],d={display:s.displayShortcut,raw:s.rawShortcut,ariaLabel:s.shortcutAriaLabel};function l(e,t){return e?e.modifier?d[t][e.modifier](e.character):e.character:null}function y(e,t){return e[t]?e[t].keyCombination:null}function S(e,t,o="display"){return l(y(e,t),o)}function f(e,t){return e[t]?e[t].description:null}function m(e,t){return e[t]&&e[t].aliases?e[t].aliases:u}const w=(0,n.createSelector)(((e,t)=>[y(e,t),...m(e,t)].filter(Boolean)),((e,t)=>[e[t]])),p=(0,n.createSelector)(((e,t)=>w(e,t).map((e=>l(e,"raw")))),((e,t)=>[e[t]])),b=(0,n.createSelector)(((e,t)=>Object.entries(e).filter((([,e])=>e.category===t)).map((([e])=>e))),(e=>[e])),h=(0,n.createReduxStore)("core/keyboard-shortcuts",{reducer:c,actions:o,selectors:r});(0,n.register)(h);const g=window.wp.element;function R(){const{getAllShortcutKeyCombinations:e}=(0,n.useSelect)(h);return function(t,o){return e(t).some((({modifier:e,character:t})=>s.isKeyboardEvent[e](o,t)))}}const C=new Set,E=e=>{for(const t of C)t(e)},v=(0,g.createContext)({add:e=>{0===C.size&&document.addEventListener("keydown",E),C.add(e)},delete:e=>{C.delete(e),0===C.size&&document.removeEventListener("keydown",E)}});function T(e,t,{isDisabled:o=!1}={}){const r=(0,g.useContext)(v),n=R(),c=(0,g.useRef)();(0,g.useEffect)((()=>{c.current=t}),[t]),(0,g.useEffect)((()=>{if(!o)return r.add(t),()=>{r.delete(t)};function t(t){n(e,t)&&c.current(t)}}),[e,o,r])}const k=window.React,{Provider:O}=v;function K(e){const[t]=(0,g.useState)((()=>new Set));return(0,k.createElement)(O,{value:t},(0,k.createElement)("div",{...e,onKeyDown:function(o){e.onKeyDown&&e.onKeyDown(o);for(const e of t)e(o)}}))}(window.wp=window.wp||{}).keyboardShortcuts=t})();