summaryrefslogtreecommitdiffstats
path: root/wp-includes/js/dist/commands.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:51:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:51:18 +0000
commit0e41b5d52fdc6af6442816b5f465c9db9f84e126 (patch)
treee139a90049b158d4eed892d1662ee7f5c358fa31 /wp-includes/js/dist/commands.js
parentAdding upstream version 6.5.5+dfsg1. (diff)
downloadwordpress-upstream.tar.xz
wordpress-upstream.zip
Adding upstream version 6.6.1+dfsg1.upstream/6.6.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/js/dist/commands.js')
-rw-r--r--wp-includes/js/dist/commands.js579
1 files changed, 118 insertions, 461 deletions
diff --git a/wp-includes/js/dist/commands.js b/wp-includes/js/dist/commands.js
index 9c766e8..7b89adf 100644
--- a/wp-includes/js/dist/commands.js
+++ b/wp-includes/js/dist/commands.js
@@ -1,72 +1,6 @@
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
-/***/ 5755:
-/***/ ((module, exports) => {
-
-var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
- Copyright (c) 2018 Jed Watson.
- Licensed under the MIT License (MIT), see
- http://jedwatson.github.io/classnames
-*/
-/* global define */
-
-(function () {
- 'use strict';
-
- var hasOwn = {}.hasOwnProperty;
- var nativeCodeString = '[native code]';
-
- function classNames() {
- var classes = [];
-
- for (var i = 0; i < arguments.length; i++) {
- var arg = arguments[i];
- if (!arg) continue;
-
- var argType = typeof arg;
-
- if (argType === 'string' || argType === 'number') {
- classes.push(arg);
- } else if (Array.isArray(arg)) {
- if (arg.length) {
- var inner = classNames.apply(null, arg);
- if (inner) {
- classes.push(inner);
- }
- }
- } else if (argType === 'object') {
- if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
- classes.push(arg.toString());
- continue;
- }
-
- for (var key in arg) {
- if (hasOwn.call(arg, key) && arg[key]) {
- classes.push(key);
- }
- }
- }
- }
-
- return classes.join(' ');
- }
-
- if ( true && module.exports) {
- classNames.default = classNames;
- module.exports = classNames;
- } else if (true) {
- // register as 'classnames', consistent with npm package name
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
- return classNames;
- }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else {}
-}());
-
-
-/***/ }),
-
/***/ 6007:
/***/ ((module) => {
@@ -327,8 +261,6 @@ __webpack_require__.d(private_actions_namespaceObject, {
setContext: () => (setContext)
});
-;// CONCATENATED MODULE: external "React"
-const external_React_namespaceObject = window["React"];
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -344,6 +276,8 @@ function _extends() {
};
return _extends.apply(this, arguments);
}
+;// CONCATENATED MODULE: external "React"
+const external_React_namespaceObject = window["React"];
;// CONCATENATED MODULE: ./node_modules/@radix-ui/primitive/dist/index.module.js
function $e42e1063c40fb3ef$export$b9ecd428b558ff10(originalEventHandler, ourEventHandler, { checkForDefaultPrevented: checkForDefaultPrevented = true } = {}) {
return function handleEvent(event) {
@@ -3202,9 +3136,8 @@ var command_score = __webpack_require__(6007);
;// CONCATENATED MODULE: ./node_modules/cmdk/dist/index.mjs
var ue='[cmdk-list-sizer=""]',M='[cmdk-group=""]',N='[cmdk-group-items=""]',de='[cmdk-group-heading=""]',ee='[cmdk-item=""]',Z=`${ee}:not([aria-disabled="true"])`,z="cmdk-item-select",S="data-value",fe=(n,a)=>command_score(n,a),te=external_React_namespaceObject.createContext(void 0),k=()=>external_React_namespaceObject.useContext(te),re=external_React_namespaceObject.createContext(void 0),U=()=>external_React_namespaceObject.useContext(re),ne=external_React_namespaceObject.createContext(void 0),oe=external_React_namespaceObject.forwardRef((n,a)=>{let r=external_React_namespaceObject.useRef(null),o=x(()=>({search:"",value:"",filtered:{count:0,items:new Map,groups:new Set}})),u=x(()=>new Set),l=x(()=>new Map),p=x(()=>new Map),f=x(()=>new Set),d=ae(n),{label:v,children:E,value:R,onValueChange:w,filter:O,shouldFilter:ie,...D}=n,F=external_React_namespaceObject.useId(),g=external_React_namespaceObject.useId(),A=external_React_namespaceObject.useId(),y=ye();L(()=>{if(R!==void 0){let e=R.trim().toLowerCase();o.current.value=e,y(6,W),h.emit()}},[R]);let h=external_React_namespaceObject.useMemo(()=>({subscribe:e=>(f.current.add(e),()=>f.current.delete(e)),snapshot:()=>o.current,setState:(e,c,i)=>{var s,m,b;if(!Object.is(o.current[e],c)){if(o.current[e]=c,e==="search")j(),G(),y(1,V);else if(e==="value")if(((s=d.current)==null?void 0:s.value)!==void 0){(b=(m=d.current).onValueChange)==null||b.call(m,c);return}else i||y(5,W);h.emit()}},emit:()=>{f.current.forEach(e=>e())}}),[]),K=external_React_namespaceObject.useMemo(()=>({value:(e,c)=>{c!==p.current.get(e)&&(p.current.set(e,c),o.current.filtered.items.set(e,B(c)),y(2,()=>{G(),h.emit()}))},item:(e,c)=>(u.current.add(e),c&&(l.current.has(c)?l.current.get(c).add(e):l.current.set(c,new Set([e]))),y(3,()=>{j(),G(),o.current.value||V(),h.emit()}),()=>{p.current.delete(e),u.current.delete(e),o.current.filtered.items.delete(e),y(4,()=>{j(),V(),h.emit()})}),group:e=>(l.current.has(e)||l.current.set(e,new Set),()=>{p.current.delete(e),l.current.delete(e)}),filter:()=>d.current.shouldFilter,label:v||n["aria-label"],listId:F,inputId:A,labelId:g}),[]);function B(e){var i;let c=((i=d.current)==null?void 0:i.filter)??fe;return e?c(e,o.current.search):0}function G(){if(!r.current||!o.current.search||d.current.shouldFilter===!1)return;let e=o.current.filtered.items,c=[];o.current.filtered.groups.forEach(s=>{let m=l.current.get(s),b=0;m.forEach(P=>{let ce=e.get(P);b=Math.max(ce,b)}),c.push([s,b])});let i=r.current.querySelector(ue);I().sort((s,m)=>{let b=s.getAttribute(S),P=m.getAttribute(S);return(e.get(P)??0)-(e.get(b)??0)}).forEach(s=>{let m=s.closest(N);m?m.appendChild(s.parentElement===m?s:s.closest(`${N} > *`)):i.appendChild(s.parentElement===i?s:s.closest(`${N} > *`))}),c.sort((s,m)=>m[1]-s[1]).forEach(s=>{let m=r.current.querySelector(`${M}[${S}="${s[0]}"]`);m==null||m.parentElement.appendChild(m)})}function V(){let e=I().find(i=>!i.ariaDisabled),c=e==null?void 0:e.getAttribute(S);h.setState("value",c||void 0)}function j(){if(!o.current.search||d.current.shouldFilter===!1){o.current.filtered.count=u.current.size;return}o.current.filtered.groups=new Set;let e=0;for(let c of u.current){let i=p.current.get(c),s=B(i);o.current.filtered.items.set(c,s),s>0&&e++}for(let[c,i]of l.current)for(let s of i)if(o.current.filtered.items.get(s)>0){o.current.filtered.groups.add(c);break}o.current.filtered.count=e}function W(){var c,i,s;let e=_();e&&(((c=e.parentElement)==null?void 0:c.firstChild)===e&&((s=(i=e.closest(M))==null?void 0:i.querySelector(de))==null||s.scrollIntoView({block:"nearest"})),e.scrollIntoView({block:"nearest"}))}function _(){return r.current.querySelector(`${ee}[aria-selected="true"]`)}function I(){return Array.from(r.current.querySelectorAll(Z))}function q(e){let i=I()[e];i&&h.setState("value",i.getAttribute(S))}function $(e){var b;let c=_(),i=I(),s=i.findIndex(P=>P===c),m=i[s+e];(b=d.current)!=null&&b.loop&&(m=s+e<0?i[i.length-1]:s+e===i.length?i[0]:i[s+e]),m&&h.setState("value",m.getAttribute(S))}function J(e){let c=_(),i=c==null?void 0:c.closest(M),s;for(;i&&!s;)i=e>0?Se(i,M):Ce(i,M),s=i==null?void 0:i.querySelector(Z);s?h.setState("value",s.getAttribute(S)):$(e)}let Q=()=>q(I().length-1),X=e=>{e.preventDefault(),e.metaKey?Q():e.altKey?J(1):$(1)},Y=e=>{e.preventDefault(),e.metaKey?q(0):e.altKey?J(-1):$(-1)};return external_React_namespaceObject.createElement("div",{ref:H([r,a]),...D,"cmdk-root":"",onKeyDown:e=>{var c;if((c=D.onKeyDown)==null||c.call(D,e),!e.defaultPrevented)switch(e.key){case"n":case"j":{e.ctrlKey&&X(e);break}case"ArrowDown":{X(e);break}case"p":case"k":{e.ctrlKey&&Y(e);break}case"ArrowUp":{Y(e);break}case"Home":{e.preventDefault(),q(0);break}case"End":{e.preventDefault(),Q();break}case"Enter":{e.preventDefault();let i=_();if(i){let s=new Event(z);i.dispatchEvent(s)}}}}},external_React_namespaceObject.createElement("label",{"cmdk-label":"",htmlFor:K.inputId,id:K.labelId,style:xe},v),external_React_namespaceObject.createElement(re.Provider,{value:h},external_React_namespaceObject.createElement(te.Provider,{value:K},E)))}),me=external_React_namespaceObject.forwardRef((n,a)=>{let r=external_React_namespaceObject.useId(),o=external_React_namespaceObject.useRef(null),u=external_React_namespaceObject.useContext(ne),l=k(),p=ae(n);L(()=>l.item(r,u),[]);let f=se(r,o,[n.value,n.children,o]),d=U(),v=T(g=>g.value&&g.value===f.current),E=T(g=>l.filter()===!1?!0:g.search?g.filtered.items.get(r)>0:!0);external_React_namespaceObject.useEffect(()=>{let g=o.current;if(!(!g||n.disabled))return g.addEventListener(z,R),()=>g.removeEventListener(z,R)},[E,n.onSelect,n.disabled]);function R(){var g,A;(A=(g=p.current).onSelect)==null||A.call(g,f.current)}function w(){d.setState("value",f.current,!0)}if(!E)return null;let{disabled:O,value:ie,onSelect:D,...F}=n;return external_React_namespaceObject.createElement("div",{ref:H([o,a]),...F,"cmdk-item":"",role:"option","aria-disabled":O||void 0,"aria-selected":v||void 0,"data-selected":v||void 0,onPointerMove:O?void 0:w,onClick:O?void 0:R},n.children)}),pe=external_React_namespaceObject.forwardRef((n,a)=>{let{heading:r,children:o,...u}=n,l=external_React_namespaceObject.useId(),p=external_React_namespaceObject.useRef(null),f=external_React_namespaceObject.useRef(null),d=external_React_namespaceObject.useId(),v=k(),E=T(w=>v.filter()===!1?!0:w.search?w.filtered.groups.has(l):!0);L(()=>v.group(l),[]),se(l,p,[n.value,n.heading,f]);let R=external_React_namespaceObject.createElement(ne.Provider,{value:l},o);return external_React_namespaceObject.createElement("div",{ref:H([p,a]),...u,"cmdk-group":"",role:"presentation",hidden:E?void 0:!0},r&&external_React_namespaceObject.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:d},r),external_React_namespaceObject.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?d:void 0},R))}),ge=external_React_namespaceObject.forwardRef((n,a)=>{let{alwaysRender:r,...o}=n,u=external_React_namespaceObject.useRef(null),l=T(p=>!p.search);return!r&&!l?null:external_React_namespaceObject.createElement("div",{ref:H([u,a]),...o,"cmdk-separator":"",role:"separator"})}),ve=external_React_namespaceObject.forwardRef((n,a)=>{let{onValueChange:r,...o}=n,u=n.value!=null,l=U(),p=T(d=>d.search),f=k();return external_React_namespaceObject.useEffect(()=>{n.value!=null&&l.setState("search",n.value)},[n.value]),external_React_namespaceObject.createElement("input",{ref:a,...o,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":f.listId,"aria-labelledby":f.labelId,id:f.inputId,type:"text",value:u?n.value:p,onChange:d=>{u||l.setState("search",d.target.value),r==null||r(d.target.value)}})}),Re=external_React_namespaceObject.forwardRef((n,a)=>{let{children:r,...o}=n,u=external_React_namespaceObject.useRef(null),l=external_React_namespaceObject.useRef(null),p=k();return external_React_namespaceObject.useEffect(()=>{if(l.current&&u.current){let f=l.current,d=u.current,v,E=new ResizeObserver(()=>{v=requestAnimationFrame(()=>{let R=f.getBoundingClientRect().height;d.style.setProperty("--cmdk-list-height",R.toFixed(1)+"px")})});return E.observe(f),()=>{cancelAnimationFrame(v),E.unobserve(f)}}},[]),external_React_namespaceObject.createElement("div",{ref:H([u,a]),...o,"cmdk-list":"",role:"listbox","aria-label":"Suggestions",id:p.listId,"aria-labelledby":p.inputId},external_React_namespaceObject.createElement("div",{ref:l,"cmdk-list-sizer":""},r))}),be=external_React_namespaceObject.forwardRef((n,a)=>{let{open:r,onOpenChange:o,container:u,...l}=n;return external_React_namespaceObject.createElement($5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9,{open:r,onOpenChange:o},external_React_namespaceObject.createElement($5d3850c4d0b4e6c7$export$602eac185826482c,{container:u},external_React_namespaceObject.createElement($5d3850c4d0b4e6c7$export$c6fdb837b070b4ff,{"cmdk-overlay":""}),external_React_namespaceObject.createElement($5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2,{"aria-label":n.label,"cmdk-dialog":""},external_React_namespaceObject.createElement(oe,{ref:a,...l}))))}),he=external_React_namespaceObject.forwardRef((n,a)=>{let r=external_React_namespaceObject.useRef(!0),o=T(u=>u.filtered.count===0);return external_React_namespaceObject.useEffect(()=>{r.current=!1},[]),r.current||!o?null:external_React_namespaceObject.createElement("div",{ref:a,...n,"cmdk-empty":"",role:"presentation"})}),Ee=external_React_namespaceObject.forwardRef((n,a)=>{let{progress:r,children:o,...u}=n;return external_React_namespaceObject.createElement("div",{ref:a,...u,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":"Loading..."},external_React_namespaceObject.createElement("div",{"aria-hidden":!0},o))}),Le=Object.assign(oe,{List:Re,Item:me,Input:ve,Group:pe,Separator:ge,Dialog:be,Empty:he,Loading:Ee});function Se(n,a){let r=n.nextElementSibling;for(;r;){if(r.matches(a))return r;r=r.nextElementSibling}}function Ce(n,a){let r=n.previousElementSibling;for(;r;){if(r.matches(a))return r;r=r.previousElementSibling}}function ae(n){let a=external_React_namespaceObject.useRef(n);return L(()=>{a.current=n}),a}var L=typeof window>"u"?external_React_namespaceObject.useEffect:external_React_namespaceObject.useLayoutEffect;function x(n){let a=external_React_namespaceObject.useRef();return a.current===void 0&&(a.current=n()),a}function H(n){return a=>{n.forEach(r=>{typeof r=="function"?r(a):r!=null&&(r.current=a)})}}function T(n){let a=U(),r=()=>n(a.snapshot());return external_React_namespaceObject.useSyncExternalStore(a.subscribe,r,r)}function se(n,a,r){let o=external_React_namespaceObject.useRef(),u=k();return L(()=>{var p;let l=(()=>{var f;for(let d of r){if(typeof d=="string")return d.trim().toLowerCase();if(typeof d=="object"&&"current"in d&&d.current)return(f=d.current.textContent)==null?void 0:f.trim().toLowerCase()}})();u.value(n,l),(p=a.current)==null||p.setAttribute(S,l),o.current=l}),o}var ye=()=>{let[n,a]=external_React_namespaceObject.useState(),r=x(()=>new Map);return L(()=>{r.current.forEach(o=>o()),r.current=new Map},[n]),(o,u)=>{r.current.set(o,u),a({})}},xe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};
-// EXTERNAL MODULE: ./node_modules/classnames/index.js
-var classnames = __webpack_require__(5755);
-var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
+;// CONCATENATED MODULE: ./node_modules/clsx/dist/clsx.mjs
+function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}/* harmony default export */ const dist_clsx = (clsx);
;// CONCATENATED MODULE: external ["wp","data"]
const external_wp_data_namespaceObject = window["wp"]["data"];
;// CONCATENATED MODULE: external ["wp","element"]
@@ -3249,18 +3182,21 @@ function Icon({
;// CONCATENATED MODULE: external ["wp","primitives"]
const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
+;// CONCATENATED MODULE: external "ReactJSXRuntime"
+const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/search.js
-
/**
* WordPress dependencies
*/
-const search = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
+
+const search = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
- viewBox: "0 0 24 24"
-}, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
- d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z"
-}));
+ viewBox: "0 0 24 24",
+ children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
+ d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z"
+ })
+});
/* harmony default export */ const library_search = (search);
;// CONCATENATED MODULE: ./node_modules/@wordpress/commands/build-module/store/reducer.js
@@ -3485,307 +3421,9 @@ function actions_close() {
};
}
-;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js
-
-
-/** @typedef {(...args: any[]) => *[]} GetDependants */
-
-/** @typedef {() => void} Clear */
-
-/**
- * @typedef {{
- * getDependants: GetDependants,
- * clear: Clear
- * }} EnhancedSelector
- */
-
-/**
- * Internal cache entry.
- *
- * @typedef CacheNode
- *
- * @property {?CacheNode|undefined} [prev] Previous node.
- * @property {?CacheNode|undefined} [next] Next node.
- * @property {*[]} args Function arguments for cache entry.
- * @property {*} val Function result.
- */
-
-/**
- * @typedef Cache
- *
- * @property {Clear} clear Function to clear cache.
- * @property {boolean} [isUniqueByDependants] Whether dependants are valid in
- * considering cache uniqueness. A cache is unique if dependents are all arrays
- * or objects.
- * @property {CacheNode?} [head] Cache head.
- * @property {*[]} [lastDependants] Dependants from previous invocation.
- */
-
-/**
- * Arbitrary value used as key for referencing cache object in WeakMap tree.
- *
- * @type {{}}
- */
-var LEAF_KEY = {};
-
-/**
- * Returns the first argument as the sole entry in an array.
- *
- * @template T
- *
- * @param {T} value Value to return.
- *
- * @return {[T]} Value returned as entry in array.
- */
-function arrayOf(value) {
- return [value];
-}
-
-/**
- * Returns true if the value passed is object-like, or false otherwise. A value
- * is object-like if it can support property assignment, e.g. object or array.
- *
- * @param {*} value Value to test.
- *
- * @return {boolean} Whether value is object-like.
- */
-function isObjectLike(value) {
- return !!value && 'object' === typeof value;
-}
-
-/**
- * Creates and returns a new cache object.
- *
- * @return {Cache} Cache object.
- */
-function createCache() {
- /** @type {Cache} */
- var cache = {
- clear: function () {
- cache.head = null;
- },
- };
-
- return cache;
-}
-
-/**
- * Returns true if entries within the two arrays are strictly equal by
- * reference from a starting index.
- *
- * @param {*[]} a First array.
- * @param {*[]} b Second array.
- * @param {number} fromIndex Index from which to start comparison.
- *
- * @return {boolean} Whether arrays are shallowly equal.
- */
-function isShallowEqual(a, b, fromIndex) {
- var i;
-
- if (a.length !== b.length) {
- return false;
- }
-
- for (i = fromIndex; i < a.length; i++) {
- if (a[i] !== b[i]) {
- return false;
- }
- }
-
- return true;
-}
-
-/**
- * Returns a memoized selector function. The getDependants function argument is
- * called before the memoized selector and is expected to return an immutable
- * reference or array of references on which the selector depends for computing
- * its own return value. The memoize cache is preserved only as long as those
- * dependant references remain the same. If getDependants returns a different
- * reference(s), the cache is cleared and the selector value regenerated.
- *
- * @template {(...args: *[]) => *} S
- *
- * @param {S} selector Selector function.
- * @param {GetDependants=} getDependants Dependant getter returning an array of
- * references used in cache bust consideration.
- */
-/* harmony default export */ function rememo(selector, getDependants) {
- /** @type {WeakMap<*,*>} */
- var rootCache;
-
- /** @type {GetDependants} */
- var normalizedGetDependants = getDependants ? getDependants : arrayOf;
-
- /**
- * Returns the cache for a given dependants array. When possible, a WeakMap
- * will be used to create a unique cache for each set of dependants. This
- * is feasible due to the nature of WeakMap in allowing garbage collection
- * to occur on entries where the key object is no longer referenced. Since
- * WeakMap requires the key to be an object, this is only possible when the
- * dependant is object-like. The root cache is created as a hierarchy where
- * each top-level key is the first entry in a dependants set, the value a
- * WeakMap where each key is the next dependant, and so on. This continues
- * so long as the dependants are object-like. If no dependants are object-
- * like, then the cache is shared across all invocations.
- *
- * @see isObjectLike
- *
- * @param {*[]} dependants Selector dependants.
- *
- * @return {Cache} Cache object.
- */
- function getCache(dependants) {
- var caches = rootCache,
- isUniqueByDependants = true,
- i,
- dependant,
- map,
- cache;
-
- for (i = 0; i < dependants.length; i++) {
- dependant = dependants[i];
-
- // Can only compose WeakMap from object-like key.
- if (!isObjectLike(dependant)) {
- isUniqueByDependants = false;
- break;
- }
-
- // Does current segment of cache already have a WeakMap?
- if (caches.has(dependant)) {
- // Traverse into nested WeakMap.
- caches = caches.get(dependant);
- } else {
- // Create, set, and traverse into a new one.
- map = new WeakMap();
- caches.set(dependant, map);
- caches = map;
- }
- }
-
- // We use an arbitrary (but consistent) object as key for the last item
- // in the WeakMap to serve as our running cache.
- if (!caches.has(LEAF_KEY)) {
- cache = createCache();
- cache.isUniqueByDependants = isUniqueByDependants;
- caches.set(LEAF_KEY, cache);
- }
-
- return caches.get(LEAF_KEY);
- }
-
- /**
- * Resets root memoization cache.
- */
- function clear() {
- rootCache = new WeakMap();
- }
-
- /* eslint-disable jsdoc/check-param-names */
- /**
- * The augmented selector call, considering first whether dependants have
- * changed before passing it to underlying memoize function.
- *
- * @param {*} source Source object for derivation.
- * @param {...*} extraArgs Additional arguments to pass to selector.
- *
- * @return {*} Selector result.
- */
- /* eslint-enable jsdoc/check-param-names */
- function callSelector(/* source, ...extraArgs */) {
- var len = arguments.length,
- cache,
- node,
- i,
- args,
- dependants;
-
- // Create copy of arguments (avoid leaking deoptimization).
- args = new Array(len);
- for (i = 0; i < len; i++) {
- args[i] = arguments[i];
- }
-
- dependants = normalizedGetDependants.apply(null, args);
- cache = getCache(dependants);
-
- // If not guaranteed uniqueness by dependants (primitive type), shallow
- // compare against last dependants and, if references have changed,
- // destroy cache to recalculate result.
- if (!cache.isUniqueByDependants) {
- if (
- cache.lastDependants &&
- !isShallowEqual(dependants, cache.lastDependants, 0)
- ) {
- cache.clear();
- }
-
- cache.lastDependants = dependants;
- }
-
- node = cache.head;
- while (node) {
- // Check whether node arguments match arguments
- if (!isShallowEqual(node.args, args, 1)) {
- node = node.next;
- continue;
- }
-
- // At this point we can assume we've found a match
-
- // Surface matched node to head if not already
- if (node !== cache.head) {
- // Adjust siblings to point to each other.
- /** @type {CacheNode} */ (node.prev).next = node.next;
- if (node.next) {
- node.next.prev = node.prev;
- }
-
- node.next = cache.head;
- node.prev = null;
- /** @type {CacheNode} */ (cache.head).prev = node;
- cache.head = node;
- }
-
- // Return immediately
- return node.val;
- }
-
- // No cached value found. Continue to insertion phase:
-
- node = /** @type {CacheNode} */ ({
- // Generate the result from original function
- val: selector.apply(null, args),
- });
-
- // Avoid including the source object in the cache.
- args[0] = null;
- node.args = args;
-
- // Don't need to check whether node is already head, since it would
- // have been returned above already if it was
-
- // Shift existing head down list
- if (cache.head) {
- cache.head.prev = node;
- node.next = cache.head;
- }
-
- cache.head = node;
-
- return node.val;
- }
-
- callSelector.getDependants = normalizedGetDependants;
- callSelector.clear = clear;
- clear();
-
- return /** @type {S & EnhancedSelector} */ (callSelector);
-}
-
;// CONCATENATED MODULE: ./node_modules/@wordpress/commands/build-module/store/selectors.js
/**
- * External dependencies
+ * WordPress dependencies
*/
@@ -3797,7 +3435,7 @@ function isShallowEqual(a, b, fromIndex) {
*
* @return {import('./actions').WPCommandConfig[]} The list of registered commands.
*/
-const getCommands = rememo((state, contextual = false) => Object.values(state.commands).filter(command => {
+const getCommands = (0,external_wp_data_namespaceObject.createSelector)((state, contextual = false) => Object.values(state.commands).filter(command => {
const isContextual = command.context && command.context === state.context;
return contextual ? isContextual : !isContextual;
}), state => [state.commands, state.context]);
@@ -3810,7 +3448,7 @@ const getCommands = rememo((state, contextual = false) => Object.values(state.co
*
* @return {import('./actions').WPCommandLoaderConfig[]} The list of registered command loaders.
*/
-const getCommandLoaders = rememo((state, contextual = false) => Object.values(state.commandLoaders).filter(loader => {
+const getCommandLoaders = (0,external_wp_data_namespaceObject.createSelector)((state, contextual = false) => Object.values(state.commandLoaders).filter(loader => {
const isContextual = loader.context && loader.context === state.context;
return contextual ? isContextual : !isContextual;
}), state => [state.commandLoaders, state.context]);
@@ -3862,7 +3500,7 @@ const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
const {
lock,
unlock
-} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/commands');
+} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/commands');
;// CONCATENATED MODULE: ./node_modules/@wordpress/commands/build-module/store/index.js
/**
@@ -3904,7 +3542,6 @@ const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME,
unlock(store).registerPrivateActions(private_actions_namespaceObject);
;// CONCATENATED MODULE: ./node_modules/@wordpress/commands/build-module/components/command-menu.js
-
/**
* External dependencies
*/
@@ -3925,7 +3562,10 @@ unlock(store).registerPrivateActions(private_actions_namespaceObject);
* Internal dependencies
*/
-const inputLabel = (0,external_wp_i18n_namespaceObject.__)('Search for commands');
+
+
+
+const inputLabel = (0,external_wp_i18n_namespaceObject.__)('Search commands and settings');
function CommandMenuLoader({
name,
search,
@@ -3946,27 +3586,32 @@ function CommandMenuLoader({
if (!commands.length) {
return null;
}
- return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, commands.map(command => {
- var _command$searchLabel;
- return (0,external_React_namespaceObject.createElement)(Le.Item, {
- key: command.name,
- value: (_command$searchLabel = command.searchLabel) !== null && _command$searchLabel !== void 0 ? _command$searchLabel : command.label,
- onSelect: () => command.callback({
- close
- }),
- id: command.name
- }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
- alignment: "left",
- className: classnames_default()('commands-command-menu__item', {
- 'has-icon': command.icon
- })
- }, command.icon && (0,external_React_namespaceObject.createElement)(icon, {
- icon: command.icon
- }), (0,external_React_namespaceObject.createElement)("span", null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.TextHighlight, {
- text: command.label,
- highlight: search
- }))));
- }));
+ return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
+ children: commands.map(command => {
+ var _command$searchLabel;
+ return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Le.Item, {
+ value: (_command$searchLabel = command.searchLabel) !== null && _command$searchLabel !== void 0 ? _command$searchLabel : command.label,
+ onSelect: () => command.callback({
+ close
+ }),
+ id: command.name,
+ children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
+ alignment: "left",
+ className: dist_clsx('commands-command-menu__item', {
+ 'has-icon': command.icon
+ }),
+ children: [command.icon && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
+ icon: command.icon
+ }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
+ children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextHighlight, {
+ text: command.label,
+ highlight: search
+ })
+ })]
+ })
+ }, command.name);
+ })
+ });
}
function CommandMenuLoaderWrapper({
hook,
@@ -3987,13 +3632,12 @@ function CommandMenuLoaderWrapper({
setKey(prevKey => prevKey + 1);
}
}, [hook]);
- return (0,external_React_namespaceObject.createElement)(CommandMenuLoader, {
- key: key,
+ return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommandMenuLoader, {
hook: currentLoader.current,
search: search,
setLoader: setLoader,
close: close
- });
+ }, key);
}
function CommandMenuGroup({
isContextual,
@@ -4017,33 +3661,37 @@ function CommandMenuGroup({
if (!commands.length && !loaders.length) {
return null;
}
- return (0,external_React_namespaceObject.createElement)(Le.Group, null, commands.map(command => {
- var _command$searchLabel2;
- return (0,external_React_namespaceObject.createElement)(Le.Item, {
- key: command.name,
- value: (_command$searchLabel2 = command.searchLabel) !== null && _command$searchLabel2 !== void 0 ? _command$searchLabel2 : command.label,
- onSelect: () => command.callback({
- close
- }),
- id: command.name
- }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
- alignment: "left",
- className: classnames_default()('commands-command-menu__item', {
- 'has-icon': command.icon
- })
- }, command.icon && (0,external_React_namespaceObject.createElement)(icon, {
- icon: command.icon
- }), (0,external_React_namespaceObject.createElement)("span", null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.TextHighlight, {
- text: command.label,
- highlight: search
- }))));
- }), loaders.map(loader => (0,external_React_namespaceObject.createElement)(CommandMenuLoaderWrapper, {
- key: loader.name,
- hook: loader.hook,
- search: search,
- setLoader: setLoader,
- close: close
- })));
+ return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Le.Group, {
+ children: [commands.map(command => {
+ var _command$searchLabel2;
+ return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Le.Item, {
+ value: (_command$searchLabel2 = command.searchLabel) !== null && _command$searchLabel2 !== void 0 ? _command$searchLabel2 : command.label,
+ onSelect: () => command.callback({
+ close
+ }),
+ id: command.name,
+ children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
+ alignment: "left",
+ className: dist_clsx('commands-command-menu__item', {
+ 'has-icon': command.icon
+ }),
+ children: [command.icon && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
+ icon: command.icon
+ }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
+ children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextHighlight, {
+ text: command.label,
+ highlight: search
+ })
+ })]
+ })
+ }, command.name);
+ }), loaders.map(loader => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommandMenuLoaderWrapper, {
+ hook: loader.hook,
+ search: search,
+ setLoader: setLoader,
+ close: close
+ }, loader.name))]
+ });
}
function CommandInput({
isOpen,
@@ -4062,7 +3710,7 @@ function CommandInput({
commandMenuInput.current.focus();
}
}, [isOpen]);
- return (0,external_React_namespaceObject.createElement)(Le.Input, {
+ return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Le.Input, {
ref: commandMenuInput,
value: search,
onValueChange: setSearch,
@@ -4108,7 +3756,9 @@ function CommandMenu() {
(0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/commands', /** @type {import('react').KeyboardEventHandler} */
event => {
// Bails to avoid obscuring the effect of the preceding handler(s).
- if (event.defaultPrevented) return;
+ if (event.defaultPrevented) {
+ return;
+ }
event.preventDefault();
if (isOpen) {
close();
@@ -4141,37 +3791,44 @@ function CommandMenu() {
}
};
const isLoading = Object.values(loaders).some(Boolean);
- return (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
+ return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
className: "commands-command-menu",
overlayClassName: "commands-command-menu__overlay",
onRequestClose: closeAndReset,
__experimentalHideHeader: true,
- contentLabel: (0,external_wp_i18n_namespaceObject.__)('Command palette')
- }, (0,external_React_namespaceObject.createElement)("div", {
- className: "commands-command-menu__container"
- }, (0,external_React_namespaceObject.createElement)(Le, {
- label: inputLabel,
- onKeyDown: onKeyDown
- }, (0,external_React_namespaceObject.createElement)("div", {
- className: "commands-command-menu__header"
- }, (0,external_React_namespaceObject.createElement)(icon, {
- icon: library_search
- }), (0,external_React_namespaceObject.createElement)(CommandInput, {
- search: search,
- setSearch: setSearch,
- isOpen: isOpen
- })), (0,external_React_namespaceObject.createElement)(Le.List, {
- ref: commandListRef
- }, search && !isLoading && (0,external_React_namespaceObject.createElement)(Le.Empty, null, (0,external_wp_i18n_namespaceObject.__)('No results found.')), (0,external_React_namespaceObject.createElement)(CommandMenuGroup, {
- search: search,
- setLoader: setLoader,
- close: closeAndReset,
- isContextual: true
- }), search && (0,external_React_namespaceObject.createElement)(CommandMenuGroup, {
- search: search,
- setLoader: setLoader,
- close: closeAndReset
- })))));
+ contentLabel: (0,external_wp_i18n_namespaceObject.__)('Command palette'),
+ children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
+ className: "commands-command-menu__container",
+ children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Le, {
+ label: inputLabel,
+ onKeyDown: onKeyDown,
+ children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
+ className: "commands-command-menu__header",
+ children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommandInput, {
+ search: search,
+ setSearch: setSearch,
+ isOpen: isOpen
+ }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
+ icon: library_search
+ })]
+ }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Le.List, {
+ ref: commandListRef,
+ children: [search && !isLoading && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Le.Empty, {
+ children: (0,external_wp_i18n_namespaceObject.__)('No results found.')
+ }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommandMenuGroup, {
+ search: search,
+ setLoader: setLoader,
+ close: closeAndReset,
+ isContextual: true
+ }), search && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommandMenuGroup, {
+ search: search,
+ setLoader: setLoader,
+ close: closeAndReset
+ })]
+ })]
+ })
+ })
+ });
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/commands/build-module/hooks/use-command-context.js