@wordpress/commands 1.36.1-next.8fd3f8831.0 → 1.37.1-next.06ee73755.0

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.
Files changed (35) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +53 -53
  3. package/build/components/command-menu.cjs +1 -1
  4. package/build/hooks/use-command-loader.cjs.map +1 -1
  5. package/build/index.cjs +1 -1
  6. package/build/private-apis.cjs +1 -1
  7. package/build/store/index.cjs +4 -4
  8. package/build-module/components/{command-menu.js → command-menu.mjs} +3 -3
  9. package/build-module/hooks/{use-command-context.js → use-command-context.mjs} +3 -3
  10. package/build-module/hooks/{use-command-loader.js → use-command-loader.mjs} +2 -2
  11. package/build-module/hooks/use-command-loader.mjs.map +7 -0
  12. package/build-module/hooks/{use-command.js → use-command.mjs} +2 -2
  13. package/build-module/index.mjs +15 -0
  14. package/build-module/{lock-unlock.js → lock-unlock.mjs} +1 -1
  15. package/build-module/{private-apis.js → private-apis.mjs} +3 -3
  16. package/build-module/store/{actions.js → actions.mjs} +1 -1
  17. package/build-module/store/{index.js → index.mjs} +6 -6
  18. package/build-module/store/{private-actions.js → private-actions.mjs} +1 -1
  19. package/build-module/store/{reducer.js → reducer.mjs} +1 -1
  20. package/build-module/store/{selectors.js → selectors.mjs} +1 -1
  21. package/package.json +12 -13
  22. package/src/hooks/use-command-loader.js +28 -28
  23. package/build-module/hooks/use-command-loader.js.map +0 -7
  24. package/build-module/index.js +0 -15
  25. /package/build-module/components/{command-menu.js.map → command-menu.mjs.map} +0 -0
  26. /package/build-module/hooks/{use-command-context.js.map → use-command-context.mjs.map} +0 -0
  27. /package/build-module/hooks/{use-command.js.map → use-command.mjs.map} +0 -0
  28. /package/build-module/{index.js.map → index.mjs.map} +0 -0
  29. /package/build-module/{lock-unlock.js.map → lock-unlock.mjs.map} +0 -0
  30. /package/build-module/{private-apis.js.map → private-apis.mjs.map} +0 -0
  31. /package/build-module/store/{actions.js.map → actions.mjs.map} +0 -0
  32. /package/build-module/store/{index.js.map → index.mjs.map} +0 -0
  33. /package/build-module/store/{private-actions.js.map → private-actions.mjs.map} +0 -0
  34. /package/build-module/store/{reducer.js.map → reducer.mjs.map} +0 -0
  35. /package/build-module/store/{selectors.js.map → selectors.mjs.map} +0 -0
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Gutenberg
2
2
 
3
- Copyright 2016-2025 by the contributors
3
+ Copyright 2016-2026 by the contributors
4
4
 
5
5
  **License for Contributions (on and after April 15, 2021)**
6
6
 
package/README.md CHANGED
@@ -122,65 +122,65 @@ Attach a command loader to the command palette. Used for dynamic commands.
122
122
  _Usage_
123
123
 
124
124
  ```js
125
+ import { __ } from '@wordpress/i18n';
126
+ import { addQueryArgs } from '@wordpress/url';
125
127
  import { useCommandLoader } from '@wordpress/commands';
126
- import { post, page, layout, symbolFilled } from '@wordpress/icons';
127
-
128
- const icons = {
129
- post,
130
- page,
131
- wp_template: layout,
132
- wp_template_part: symbolFilled,
133
- };
128
+ import { page } from '@wordpress/icons';
129
+ import { useSelect } from '@wordpress/data';
130
+ import { store as coreStore } from '@wordpress/core-data';
131
+ import { useMemo } from '@wordpress/element';
134
132
 
135
133
  function usePageSearchCommandLoader( { search } ) {
136
- // Retrieve the pages for the "search" term.
137
- const { records, isLoading } = useSelect( ( select ) => {
138
- const { getEntityRecords } = select( coreStore );
139
- const query = {
140
- search: !! search ? search : undefined,
141
- per_page: 10,
142
- orderby: search ? 'relevance' : 'date',
143
- };
144
- return {
145
- records: getEntityRecords( 'postType', 'page', query ),
146
- isLoading: ! select( coreStore ).hasFinishedResolution(
147
- 'getEntityRecords',
148
- 'postType', 'page', query ]
149
- ),
150
- };
151
- }, [ search ] );
152
-
153
- // Create the commands.
154
- const commands = useMemo( () => {
155
- return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {
156
- return {
157
- name: record.title?.rendered + ' ' + record.id,
158
- label: record.title?.rendered
159
- ? record.title?.rendered
160
- : __( '(no title)' ),
161
- icon: icons[ postType ],
162
- callback: ( { close } ) => {
163
- const args = {
164
- postType,
165
- postId: record.id,
166
- ...extraArgs,
167
- };
168
- document.location = addQueryArgs( 'site-editor.php', args );
169
- close();
170
- },
171
- };
172
- } );
173
- }, [ records, history ] );
174
-
175
- return {
176
- commands,
177
- isLoading,
178
- };
134
+ // Retrieve the pages for the "search" term.
135
+ const { records, isLoading } = useSelect(
136
+ ( select ) => {
137
+ const { getEntityRecords } = select( coreStore );
138
+ const query = {
139
+ search: !! search ? search : undefined,
140
+ per_page: 10,
141
+ orderby: search ? 'relevance' : 'date',
142
+ };
143
+ return {
144
+ records: getEntityRecords( 'postType', 'page', query ),
145
+ isLoading: ! select( coreStore ).hasFinishedResolution(
146
+ 'getEntityRecords',
147
+ [ 'postType', 'page', query ]
148
+ ),
149
+ };
150
+ },
151
+ [ search ]
152
+ );
153
+
154
+ // Create the commands.
155
+ const commands = useMemo( () => {
156
+ return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {
157
+ return {
158
+ name: record.title?.rendered + ' ' + record.id,
159
+ label: record.title?.rendered
160
+ ? record.title?.rendered
161
+ : __( '(no title)' ),
162
+ icon: page,
163
+ callback: ( { close } ) => {
164
+ const args = {
165
+ p: '/page',
166
+ postId: record.id,
167
+ };
168
+ document.location = addQueryArgs( 'site-editor.php', args );
169
+ close();
170
+ },
171
+ };
172
+ } );
173
+ }, [ records ] );
174
+
175
+ return {
176
+ commands,
177
+ isLoading,
178
+ };
179
179
  }
180
180
 
181
181
  useCommandLoader( {
182
- name: 'myplugin/page-search',
183
- hook: usePageSearchCommandLoader,
182
+ name: 'myplugin/page-search',
183
+ hook: usePageSearchCommandLoader,
184
184
  } );
185
185
  ```
186
186
 
@@ -35,7 +35,7 @@ __export(command_menu_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(command_menu_exports);
37
37
  var import_cmdk = require("cmdk");
38
- var import_clsx = __toESM(require("clsx"), 1);
38
+ var import_clsx = __toESM(require("clsx"));
39
39
  var import_data = require("@wordpress/data");
40
40
  var import_element = require("@wordpress/element");
41
41
  var import_i18n = require("@wordpress/i18n");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/use-command-loader.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette. Used for dynamic commands.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n *\n * @example\n * ```js\n * import { useCommandLoader } from '@wordpress/commands';\n * import { post, page, layout, symbolFilled } from '@wordpress/icons';\n *\n * const icons = {\n * post,\n * page,\n * wp_template: layout,\n * wp_template_part: symbolFilled,\n * };\n *\n * function usePageSearchCommandLoader( { search } ) {\n * // Retrieve the pages for the \"search\" term.\n * const { records, isLoading } = useSelect( ( select ) => {\n * const { getEntityRecords } = select( coreStore );\n * const query = {\n * search: !! search ? search : undefined,\n * per_page: 10,\n * orderby: search ? 'relevance' : 'date',\n * };\n * return {\n * records: getEntityRecords( 'postType', 'page', query ),\n * isLoading: ! select( coreStore ).hasFinishedResolution(\n * 'getEntityRecords',\n * 'postType', 'page', query ]\n * ),\n * };\n * }, [ search ] );\n *\n * // Create the commands.\n * const commands = useMemo( () => {\n * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n * return {\n * name: record.title?.rendered + ' ' + record.id,\n * label: record.title?.rendered\n * ? record.title?.rendered\n * : __( '(no title)' ),\n * icon: icons[ postType ],\n * callback: ( { close } ) => {\n * const args = {\n * postType,\n * postId: record.id,\n * ...extraArgs,\n * };\n * document.location = addQueryArgs( 'site-editor.php', args );\n * close();\n * },\n * };\n * } );\n * }, [ records, history ] );\n *\n * return {\n * commands,\n * isLoading,\n * };\n * }\n *\n * useCommandLoader( {\n * name: 'myplugin/page-search',\n * hook: usePageSearchCommandLoader,\n * } );\n * ```\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tif ( loader.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tloader.disabled,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette. Used for dynamic commands.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { addQueryArgs } from '@wordpress/url';\n * import { useCommandLoader } from '@wordpress/commands';\n * import { page } from '@wordpress/icons';\n * import { useSelect } from '@wordpress/data';\n * import { store as coreStore } from '@wordpress/core-data';\n * import { useMemo } from '@wordpress/element';\n *\n * function usePageSearchCommandLoader( { search } ) {\n * // Retrieve the pages for the \"search\" term.\n * const { records, isLoading } = useSelect(\n * ( select ) => {\n * const { getEntityRecords } = select( coreStore );\n * const query = {\n * search: !! search ? search : undefined,\n * per_page: 10,\n * orderby: search ? 'relevance' : 'date',\n * };\n * return {\n * records: getEntityRecords( 'postType', 'page', query ),\n * isLoading: ! select( coreStore ).hasFinishedResolution(\n * 'getEntityRecords',\n * [ 'postType', 'page', query ]\n * ),\n * };\n * },\n * [ search ]\n * );\n *\n * // Create the commands.\n * const commands = useMemo( () => {\n * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n * return {\n * name: record.title?.rendered + ' ' + record.id,\n * label: record.title?.rendered\n * ? record.title?.rendered\n * : __( '(no title)' ),\n * icon: page,\n * callback: ( { close } ) => {\n * const args = {\n * \t\t\t\t\t\t\tp: '/page',\n * \t\t\t\t\t\t\tpostId: record.id,\n * };\n * document.location = addQueryArgs( 'site-editor.php', args );\n * close();\n * },\n * };\n * } );\n * }, [ records ] );\n *\n * return {\n * commands,\n * isLoading,\n * };\n * }\n *\n * useCommandLoader( {\n * name: 'myplugin/page-search',\n * hook: usePageSearchCommandLoader,\n * } );\n * ```\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tif ( loader.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tloader.disabled,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0B;AAC1B,kBAA4B;AAK5B,mBAAuC;AAuExB,SAAR,iBAAmC,QAAS;AAClD,QAAM,EAAE,uBAAuB,wBAAwB,QACtD,yBAAa,aAAAA,KAAc;AAC5B,gCAAW,MAAM;AAChB,QAAK,OAAO,UAAW;AACtB;AAAA,IACD;AACA,0BAAuB;AAAA,MACtB,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,IACjB,CAAE;AACF,WAAO,MAAM;AACZ,8BAAyB,OAAO,IAAK;AAAA,IACtC;AAAA,EACD,GAAG;AAAA,IACF,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
6
  "names": ["commandsStore"]
7
7
  }
package/build/index.cjs CHANGED
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(index_exports);
40
40
  var import_command_menu = require("./components/command-menu.cjs");
41
41
  var import_private_apis = require("./private-apis.cjs");
42
42
  var import_use_command = require("./hooks/use-command.cjs");
43
- var import_use_command_loader = __toESM(require("./hooks/use-command-loader.cjs"), 1);
43
+ var import_use_command_loader = __toESM(require("./hooks/use-command-loader.cjs"));
44
44
  var import_store = require("./store/index.cjs");
45
45
  // Annotate the CommonJS export names for ESM import in node:
46
46
  0 && (module.exports = {
@@ -32,7 +32,7 @@ __export(private_apis_exports, {
32
32
  privateApis: () => privateApis
33
33
  });
34
34
  module.exports = __toCommonJS(private_apis_exports);
35
- var import_use_command_context = __toESM(require("./hooks/use-command-context.cjs"), 1);
35
+ var import_use_command_context = __toESM(require("./hooks/use-command-context.cjs"));
36
36
  var import_lock_unlock = require("./lock-unlock.cjs");
37
37
  var privateApis = {};
38
38
  (0, import_lock_unlock.lock)(privateApis, {
@@ -33,10 +33,10 @@ __export(store_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(store_exports);
35
35
  var import_data = require("@wordpress/data");
36
- var import_reducer = __toESM(require("./reducer.cjs"), 1);
37
- var actions = __toESM(require("./actions.cjs"), 1);
38
- var selectors = __toESM(require("./selectors.cjs"), 1);
39
- var privateActions = __toESM(require("./private-actions.cjs"), 1);
36
+ var import_reducer = __toESM(require("./reducer.cjs"));
37
+ var actions = __toESM(require("./actions.cjs"));
38
+ var selectors = __toESM(require("./selectors.cjs"));
39
+ var privateActions = __toESM(require("./private-actions.cjs"));
40
40
  var import_lock_unlock = require("../lock-unlock.cjs");
41
41
  var STORE_NAME = "core/commands";
42
42
  var store = (0, import_data.createReduxStore)(STORE_NAME, {
@@ -21,8 +21,8 @@ import {
21
21
  useShortcut
22
22
  } from "@wordpress/keyboard-shortcuts";
23
23
  import { Icon, search as inputIcon } from "@wordpress/icons";
24
- import { store as commandsStore } from "../store/index.js";
25
- import { unlock } from "../lock-unlock.js";
24
+ import { store as commandsStore } from "../store/index.mjs";
25
+ import { unlock } from "../lock-unlock.mjs";
26
26
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
27
27
  var { withIgnoreIMEEvents } = unlock(componentsPrivateApis);
28
28
  var inputLabel = __("Search commands and settings");
@@ -273,4 +273,4 @@ export {
273
273
  CommandMenuGroup,
274
274
  CommandMenuLoaderWrapper
275
275
  };
276
- //# sourceMappingURL=command-menu.js.map
276
+ //# sourceMappingURL=command-menu.mjs.map
@@ -1,8 +1,8 @@
1
1
  // packages/commands/src/hooks/use-command-context.js
2
2
  import { useEffect, useRef } from "@wordpress/element";
3
3
  import { useDispatch, useSelect } from "@wordpress/data";
4
- import { store as commandsStore } from "../store/index.js";
5
- import { unlock } from "../lock-unlock.js";
4
+ import { store as commandsStore } from "../store/index.mjs";
5
+ import { unlock } from "../lock-unlock.mjs";
6
6
  function useCommandContext(context) {
7
7
  const { getContext } = useSelect(commandsStore);
8
8
  const initialContext = useRef(getContext());
@@ -18,4 +18,4 @@ function useCommandContext(context) {
18
18
  export {
19
19
  useCommandContext as default
20
20
  };
21
- //# sourceMappingURL=use-command-context.js.map
21
+ //# sourceMappingURL=use-command-context.mjs.map
@@ -1,7 +1,7 @@
1
1
  // packages/commands/src/hooks/use-command-loader.js
2
2
  import { useEffect } from "@wordpress/element";
3
3
  import { useDispatch } from "@wordpress/data";
4
- import { store as commandsStore } from "../store/index.js";
4
+ import { store as commandsStore } from "../store/index.mjs";
5
5
  function useCommandLoader(loader) {
6
6
  const { registerCommandLoader, unregisterCommandLoader } = useDispatch(commandsStore);
7
7
  useEffect(() => {
@@ -28,4 +28,4 @@ function useCommandLoader(loader) {
28
28
  export {
29
29
  useCommandLoader as default
30
30
  };
31
- //# sourceMappingURL=use-command-loader.js.map
31
+ //# sourceMappingURL=use-command-loader.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/hooks/use-command-loader.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette. Used for dynamic commands.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { addQueryArgs } from '@wordpress/url';\n * import { useCommandLoader } from '@wordpress/commands';\n * import { page } from '@wordpress/icons';\n * import { useSelect } from '@wordpress/data';\n * import { store as coreStore } from '@wordpress/core-data';\n * import { useMemo } from '@wordpress/element';\n *\n * function usePageSearchCommandLoader( { search } ) {\n * // Retrieve the pages for the \"search\" term.\n * const { records, isLoading } = useSelect(\n * ( select ) => {\n * const { getEntityRecords } = select( coreStore );\n * const query = {\n * search: !! search ? search : undefined,\n * per_page: 10,\n * orderby: search ? 'relevance' : 'date',\n * };\n * return {\n * records: getEntityRecords( 'postType', 'page', query ),\n * isLoading: ! select( coreStore ).hasFinishedResolution(\n * 'getEntityRecords',\n * [ 'postType', 'page', query ]\n * ),\n * };\n * },\n * [ search ]\n * );\n *\n * // Create the commands.\n * const commands = useMemo( () => {\n * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n * return {\n * name: record.title?.rendered + ' ' + record.id,\n * label: record.title?.rendered\n * ? record.title?.rendered\n * : __( '(no title)' ),\n * icon: page,\n * callback: ( { close } ) => {\n * const args = {\n * \t\t\t\t\t\t\tp: '/page',\n * \t\t\t\t\t\t\tpostId: record.id,\n * };\n * document.location = addQueryArgs( 'site-editor.php', args );\n * close();\n * },\n * };\n * } );\n * }, [ records ] );\n *\n * return {\n * commands,\n * isLoading,\n * };\n * }\n *\n * useCommandLoader( {\n * name: 'myplugin/page-search',\n * hook: usePageSearchCommandLoader,\n * } );\n * ```\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tif ( loader.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tloader.disabled,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAK5B,SAAS,SAAS,qBAAqB;AAuExB,SAAR,iBAAmC,QAAS;AAClD,QAAM,EAAE,uBAAuB,wBAAwB,IACtD,YAAa,aAAc;AAC5B,YAAW,MAAM;AAChB,QAAK,OAAO,UAAW;AACtB;AAAA,IACD;AACA,0BAAuB;AAAA,MACtB,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,IACjB,CAAE;AACF,WAAO,MAAM;AACZ,8BAAyB,OAAO,IAAK;AAAA,IACtC;AAAA,EACD,GAAG;AAAA,IACF,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  // packages/commands/src/hooks/use-command.js
2
2
  import { useEffect, useRef } from "@wordpress/element";
3
3
  import { useDispatch } from "@wordpress/data";
4
- import { store as commandsStore } from "../store/index.js";
4
+ import { store as commandsStore } from "../store/index.mjs";
5
5
  function useCommand(command) {
6
6
  const { registerCommand, unregisterCommand } = useDispatch(commandsStore);
7
7
  const currentCallbackRef = useRef(command.callback);
@@ -83,4 +83,4 @@ export {
83
83
  useCommand,
84
84
  useCommands
85
85
  };
86
- //# sourceMappingURL=use-command.js.map
86
+ //# sourceMappingURL=use-command.mjs.map
@@ -0,0 +1,15 @@
1
+ // packages/commands/src/index.js
2
+ import { CommandMenu } from "./components/command-menu.mjs";
3
+ import { privateApis } from "./private-apis.mjs";
4
+ import { useCommand, useCommands } from "./hooks/use-command.mjs";
5
+ import { default as default2 } from "./hooks/use-command-loader.mjs";
6
+ import { store } from "./store/index.mjs";
7
+ export {
8
+ CommandMenu,
9
+ privateApis,
10
+ store,
11
+ useCommand,
12
+ default2 as useCommandLoader,
13
+ useCommands
14
+ };
15
+ //# sourceMappingURL=index.mjs.map
@@ -8,4 +8,4 @@ export {
8
8
  lock,
9
9
  unlock
10
10
  };
11
- //# sourceMappingURL=lock-unlock.js.map
11
+ //# sourceMappingURL=lock-unlock.mjs.map
@@ -1,6 +1,6 @@
1
1
  // packages/commands/src/private-apis.js
2
- import { default as useCommandContext } from "./hooks/use-command-context.js";
3
- import { lock } from "./lock-unlock.js";
2
+ import { default as useCommandContext } from "./hooks/use-command-context.mjs";
3
+ import { lock } from "./lock-unlock.mjs";
4
4
  var privateApis = {};
5
5
  lock(privateApis, {
6
6
  useCommandContext
@@ -8,4 +8,4 @@ lock(privateApis, {
8
8
  export {
9
9
  privateApis
10
10
  };
11
- //# sourceMappingURL=private-apis.js.map
11
+ //# sourceMappingURL=private-apis.mjs.map
@@ -41,4 +41,4 @@ export {
41
41
  unregisterCommand,
42
42
  unregisterCommandLoader
43
43
  };
44
- //# sourceMappingURL=actions.js.map
44
+ //# sourceMappingURL=actions.mjs.map
@@ -1,10 +1,10 @@
1
1
  // packages/commands/src/store/index.js
2
2
  import { createReduxStore, register } from "@wordpress/data";
3
- import reducer from "./reducer.js";
4
- import * as actions from "./actions.js";
5
- import * as selectors from "./selectors.js";
6
- import * as privateActions from "./private-actions.js";
7
- import { unlock } from "../lock-unlock.js";
3
+ import reducer from "./reducer.mjs";
4
+ import * as actions from "./actions.mjs";
5
+ import * as selectors from "./selectors.mjs";
6
+ import * as privateActions from "./private-actions.mjs";
7
+ import { unlock } from "../lock-unlock.mjs";
8
8
  var STORE_NAME = "core/commands";
9
9
  var store = createReduxStore(STORE_NAME, {
10
10
  reducer,
@@ -16,4 +16,4 @@ unlock(store).registerPrivateActions(privateActions);
16
16
  export {
17
17
  store
18
18
  };
19
- //# sourceMappingURL=index.js.map
19
+ //# sourceMappingURL=index.mjs.map
@@ -8,4 +8,4 @@ function setContext(context) {
8
8
  export {
9
9
  setContext
10
10
  };
11
- //# sourceMappingURL=private-actions.js.map
11
+ //# sourceMappingURL=private-actions.mjs.map
@@ -66,4 +66,4 @@ var reducer_default = reducer;
66
66
  export {
67
67
  reducer_default as default
68
68
  };
69
- //# sourceMappingURL=reducer.js.map
69
+ //# sourceMappingURL=reducer.mjs.map
@@ -26,4 +26,4 @@ export {
26
26
  getContext,
27
27
  isOpen
28
28
  };
29
- //# sourceMappingURL=selectors.js.map
29
+ //# sourceMappingURL=selectors.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/commands",
3
- "version": "1.36.1-next.8fd3f8831.0",
3
+ "version": "1.37.1-next.06ee73755.0",
4
4
  "description": "Handles the commands menu.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,12 +31,11 @@
31
31
  "build-types",
32
32
  "*.md"
33
33
  ],
34
- "type": "module",
35
34
  "main": "build/index.cjs",
36
- "module": "build-module/index.js",
35
+ "module": "build-module/index.mjs",
37
36
  "exports": {
38
37
  ".": {
39
- "import": "./build-module/index.js",
38
+ "import": "./build-module/index.mjs",
40
39
  "require": "./build/index.cjs"
41
40
  },
42
41
  "./package.json": "./package.json",
@@ -45,14 +44,14 @@
45
44
  "react-native": "src/index",
46
45
  "wpScript": true,
47
46
  "dependencies": {
48
- "@wordpress/base-styles": "^6.12.1-next.8fd3f8831.0",
49
- "@wordpress/components": "^31.0.1-next.8fd3f8831.0",
50
- "@wordpress/data": "^10.36.1-next.8fd3f8831.0",
51
- "@wordpress/element": "^6.36.1-next.8fd3f8831.0",
52
- "@wordpress/i18n": "^6.9.1-next.8fd3f8831.0",
53
- "@wordpress/icons": "^11.3.1-next.8fd3f8831.0",
54
- "@wordpress/keyboard-shortcuts": "^5.36.1-next.8fd3f8831.0",
55
- "@wordpress/private-apis": "^1.36.1-next.8fd3f8831.0",
47
+ "@wordpress/base-styles": "^6.13.2-next.06ee73755.0",
48
+ "@wordpress/components": "^32.0.1-next.06ee73755.0",
49
+ "@wordpress/data": "^10.37.1-next.06ee73755.0",
50
+ "@wordpress/element": "^6.37.1-next.06ee73755.0",
51
+ "@wordpress/i18n": "^6.10.1-next.06ee73755.0",
52
+ "@wordpress/icons": "^11.4.1-next.06ee73755.0",
53
+ "@wordpress/keyboard-shortcuts": "^5.37.1-next.06ee73755.0",
54
+ "@wordpress/private-apis": "^1.37.1-next.06ee73755.0",
56
55
  "clsx": "^2.1.1",
57
56
  "cmdk": "^1.0.0"
58
57
  },
@@ -63,5 +62,5 @@
63
62
  "publishConfig": {
64
63
  "access": "public"
65
64
  },
66
- "gitHead": "e582b351bc4c4b8734bb087f63a3beec9875c3c7"
65
+ "gitHead": "fd315436f44683a993d5f053789b5279d95b2872"
67
66
  }
@@ -16,33 +16,34 @@ import { store as commandsStore } from '../store';
16
16
  *
17
17
  * @example
18
18
  * ```js
19
+ * import { __ } from '@wordpress/i18n';
20
+ * import { addQueryArgs } from '@wordpress/url';
19
21
  * import { useCommandLoader } from '@wordpress/commands';
20
- * import { post, page, layout, symbolFilled } from '@wordpress/icons';
21
- *
22
- * const icons = {
23
- * post,
24
- * page,
25
- * wp_template: layout,
26
- * wp_template_part: symbolFilled,
27
- * };
22
+ * import { page } from '@wordpress/icons';
23
+ * import { useSelect } from '@wordpress/data';
24
+ * import { store as coreStore } from '@wordpress/core-data';
25
+ * import { useMemo } from '@wordpress/element';
28
26
  *
29
27
  * function usePageSearchCommandLoader( { search } ) {
30
28
  * // Retrieve the pages for the "search" term.
31
- * const { records, isLoading } = useSelect( ( select ) => {
32
- * const { getEntityRecords } = select( coreStore );
33
- * const query = {
34
- * search: !! search ? search : undefined,
35
- * per_page: 10,
36
- * orderby: search ? 'relevance' : 'date',
37
- * };
38
- * return {
39
- * records: getEntityRecords( 'postType', 'page', query ),
40
- * isLoading: ! select( coreStore ).hasFinishedResolution(
41
- * 'getEntityRecords',
42
- * 'postType', 'page', query ]
43
- * ),
44
- * };
45
- * }, [ search ] );
29
+ * const { records, isLoading } = useSelect(
30
+ * ( select ) => {
31
+ * const { getEntityRecords } = select( coreStore );
32
+ * const query = {
33
+ * search: !! search ? search : undefined,
34
+ * per_page: 10,
35
+ * orderby: search ? 'relevance' : 'date',
36
+ * };
37
+ * return {
38
+ * records: getEntityRecords( 'postType', 'page', query ),
39
+ * isLoading: ! select( coreStore ).hasFinishedResolution(
40
+ * 'getEntityRecords',
41
+ * [ 'postType', 'page', query ]
42
+ * ),
43
+ * };
44
+ * },
45
+ * [ search ]
46
+ * );
46
47
  *
47
48
  * // Create the commands.
48
49
  * const commands = useMemo( () => {
@@ -52,19 +53,18 @@ import { store as commandsStore } from '../store';
52
53
  * label: record.title?.rendered
53
54
  * ? record.title?.rendered
54
55
  * : __( '(no title)' ),
55
- * icon: icons[ postType ],
56
+ * icon: page,
56
57
  * callback: ( { close } ) => {
57
58
  * const args = {
58
- * postType,
59
- * postId: record.id,
60
- * ...extraArgs,
59
+ * p: '/page',
60
+ * postId: record.id,
61
61
  * };
62
62
  * document.location = addQueryArgs( 'site-editor.php', args );
63
63
  * close();
64
64
  * },
65
65
  * };
66
66
  * } );
67
- * }, [ records, history ] );
67
+ * }, [ records ] );
68
68
  *
69
69
  * return {
70
70
  * commands,
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hooks/use-command-loader.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette. Used for dynamic commands.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n *\n * @example\n * ```js\n * import { useCommandLoader } from '@wordpress/commands';\n * import { post, page, layout, symbolFilled } from '@wordpress/icons';\n *\n * const icons = {\n * post,\n * page,\n * wp_template: layout,\n * wp_template_part: symbolFilled,\n * };\n *\n * function usePageSearchCommandLoader( { search } ) {\n * // Retrieve the pages for the \"search\" term.\n * const { records, isLoading } = useSelect( ( select ) => {\n * const { getEntityRecords } = select( coreStore );\n * const query = {\n * search: !! search ? search : undefined,\n * per_page: 10,\n * orderby: search ? 'relevance' : 'date',\n * };\n * return {\n * records: getEntityRecords( 'postType', 'page', query ),\n * isLoading: ! select( coreStore ).hasFinishedResolution(\n * 'getEntityRecords',\n * 'postType', 'page', query ]\n * ),\n * };\n * }, [ search ] );\n *\n * // Create the commands.\n * const commands = useMemo( () => {\n * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n * return {\n * name: record.title?.rendered + ' ' + record.id,\n * label: record.title?.rendered\n * ? record.title?.rendered\n * : __( '(no title)' ),\n * icon: icons[ postType ],\n * callback: ( { close } ) => {\n * const args = {\n * postType,\n * postId: record.id,\n * ...extraArgs,\n * };\n * document.location = addQueryArgs( 'site-editor.php', args );\n * close();\n * },\n * };\n * } );\n * }, [ records, history ] );\n *\n * return {\n * commands,\n * isLoading,\n * };\n * }\n *\n * useCommandLoader( {\n * name: 'myplugin/page-search',\n * hook: usePageSearchCommandLoader,\n * } );\n * ```\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tif ( loader.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tloader.disabled,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],
5
- "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAK5B,SAAS,SAAS,qBAAqB;AAuExB,SAAR,iBAAmC,QAAS;AAClD,QAAM,EAAE,uBAAuB,wBAAwB,IACtD,YAAa,aAAc;AAC5B,YAAW,MAAM;AAChB,QAAK,OAAO,UAAW;AACtB;AAAA,IACD;AACA,0BAAuB;AAAA,MACtB,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,IACjB,CAAE;AACF,WAAO,MAAM;AACZ,8BAAyB,OAAO,IAAK;AAAA,IACtC;AAAA,EACD,GAAG;AAAA,IACF,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
- "names": []
7
- }
@@ -1,15 +0,0 @@
1
- // packages/commands/src/index.js
2
- import { CommandMenu } from "./components/command-menu.js";
3
- import { privateApis } from "./private-apis.js";
4
- import { useCommand, useCommands } from "./hooks/use-command.js";
5
- import { default as default2 } from "./hooks/use-command-loader.js";
6
- import { store } from "./store/index.js";
7
- export {
8
- CommandMenu,
9
- privateApis,
10
- store,
11
- useCommand,
12
- default2 as useCommandLoader,
13
- useCommands
14
- };
15
- //# sourceMappingURL=index.js.map
File without changes