@wordpress/commands 1.32.0 → 1.32.1-next.b8c8708f3.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 (56) hide show
  1. package/README.md +2 -2
  2. package/build/components/command-menu.js +261 -246
  3. package/build/components/command-menu.js.map +7 -1
  4. package/build/hooks/use-command-context.js +31 -35
  5. package/build/hooks/use-command-context.js.map +7 -1
  6. package/build/hooks/use-command-loader.js +35 -92
  7. package/build/hooks/use-command-loader.js.map +7 -1
  8. package/build/hooks/use-command.js +53 -90
  9. package/build/hooks/use-command.js.map +7 -1
  10. package/build/index.js +49 -45
  11. package/build/index.js.map +7 -1
  12. package/build/lock-unlock.js +31 -15
  13. package/build/lock-unlock.js.map +7 -1
  14. package/build/private-apis.js +41 -19
  15. package/build/private-apis.js.map +7 -1
  16. package/build/store/actions.js +42 -92
  17. package/build/store/actions.js.map +7 -1
  18. package/build/store/index.js +47 -44
  19. package/build/store/index.js.map +7 -1
  20. package/build/store/private-actions.js +27 -14
  21. package/build/store/private-actions.js.map +7 -1
  22. package/build/store/reducer.js +39 -70
  23. package/build/store/reducer.js.map +7 -1
  24. package/build/store/selectors.js +47 -54
  25. package/build/store/selectors.js.map +7 -1
  26. package/build-module/components/command-menu.js +232 -229
  27. package/build-module/components/command-menu.js.map +7 -1
  28. package/build-module/hooks/use-command-context.js +11 -28
  29. package/build-module/hooks/use-command-context.js.map +7 -1
  30. package/build-module/hooks/use-command-loader.js +17 -87
  31. package/build-module/hooks/use-command-loader.js.map +7 -1
  32. package/build-module/hooks/use-command.js +25 -79
  33. package/build-module/hooks/use-command.js.map +7 -1
  34. package/build-module/index.js +14 -6
  35. package/build-module/index.js.map +7 -1
  36. package/build-module/lock-unlock.js +8 -7
  37. package/build-module/lock-unlock.js.map +7 -1
  38. package/build-module/private-apis.js +7 -11
  39. package/build-module/private-apis.js.map +7 -1
  40. package/build-module/store/actions.js +21 -88
  41. package/build-module/store/actions.js.map +7 -1
  42. package/build-module/store/index.js +12 -32
  43. package/build-module/store/index.js.map +7 -1
  44. package/build-module/store/private-actions.js +6 -10
  45. package/build-module/store/private-actions.js.map +7 -1
  46. package/build-module/store/reducer.js +20 -64
  47. package/build-module/store/reducer.js.map +7 -1
  48. package/build-module/store/selectors.js +24 -49
  49. package/build-module/store/selectors.js.map +7 -1
  50. package/build-style/style-rtl.css +7 -138
  51. package/build-style/style.css +7 -138
  52. package/package.json +18 -10
  53. package/src/components/command-menu.js +4 -1
  54. package/src/components/style.scss +10 -0
  55. package/src/hooks/use-command.js +2 -2
  56. package/src/style.scss +2 -1
@@ -1 +1,7 @@
1
- {"version":3,"names":["useEffect","useRef","useDispatch","useSelect","store","commandsStore","unlock","useCommandContext","context","getContext","initialContext","setContext","initialContextRef","current"],"sources":["@wordpress/commands/src/hooks/use-command-context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Sets the active context of the command palette\n *\n * @param {string} context Context to set.\n */\nexport default function useCommandContext( context ) {\n\tconst { getContext } = useSelect( commandsStore );\n\tconst initialContext = useRef( getContext() );\n\tconst { setContext } = unlock( useDispatch( commandsStore ) );\n\n\tuseEffect( () => {\n\t\tsetContext( context );\n\t}, [ context, setContext ] );\n\n\t// This effects ensures that on unmount, we restore the context\n\t// that was set before the component actually mounts.\n\tuseEffect( () => {\n\t\tconst initialContextRef = initialContext.current;\n\t\treturn () => setContext( initialContextRef );\n\t}, [ setContext ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,UAAU;AACjD,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,iBAAiBA,CAAEC,OAAO,EAAG;EACpD,MAAM;IAAEC;EAAW,CAAC,GAAGN,SAAS,CAAEE,aAAc,CAAC;EACjD,MAAMK,cAAc,GAAGT,MAAM,CAAEQ,UAAU,CAAC,CAAE,CAAC;EAC7C,MAAM;IAAEE;EAAW,CAAC,GAAGL,MAAM,CAAEJ,WAAW,CAAEG,aAAc,CAAE,CAAC;EAE7DL,SAAS,CAAE,MAAM;IAChBW,UAAU,CAAEH,OAAQ,CAAC;EACtB,CAAC,EAAE,CAAEA,OAAO,EAAEG,UAAU,CAAG,CAAC;;EAE5B;EACA;EACAX,SAAS,CAAE,MAAM;IAChB,MAAMY,iBAAiB,GAAGF,cAAc,CAACG,OAAO;IAChD,OAAO,MAAMF,UAAU,CAAEC,iBAAkB,CAAC;EAC7C,CAAC,EAAE,CAAED,UAAU,CAAG,CAAC;AACpB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/hooks/use-command-context.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Sets the active context of the command palette\n *\n * @param {string} context Context to set.\n */\nexport default function useCommandContext( context ) {\n\tconst { getContext } = useSelect( commandsStore );\n\tconst initialContext = useRef( getContext() );\n\tconst { setContext } = unlock( useDispatch( commandsStore ) );\n\n\tuseEffect( () => {\n\t\tsetContext( context );\n\t}, [ context, setContext ] );\n\n\t// This effects ensures that on unmount, we restore the context\n\t// that was set before the component actually mounts.\n\tuseEffect( () => {\n\t\tconst initialContextRef = initialContext.current;\n\t\treturn () => setContext( initialContextRef );\n\t}, [ setContext ] );\n}\n"],
5
+ "mappings": "AAGA,SAAS,WAAW,cAAc;AAClC,SAAS,aAAa,iBAAiB;AAKvC,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AAOR,SAAR,kBAAoC,SAAU;AACpD,QAAM,EAAE,WAAW,IAAI,UAAW,aAAc;AAChD,QAAM,iBAAiB,OAAQ,WAAW,CAAE;AAC5C,QAAM,EAAE,WAAW,IAAI,OAAQ,YAAa,aAAc,CAAE;AAE5D,YAAW,MAAM;AAChB,eAAY,OAAQ;AAAA,EACrB,GAAG,CAAE,SAAS,UAAW,CAAE;AAI3B,YAAW,MAAM;AAChB,UAAM,oBAAoB,eAAe;AACzC,WAAO,MAAM,WAAY,iBAAkB;AAAA,EAC5C,GAAG,CAAE,UAAW,CAAE;AACnB;",
6
+ "names": []
7
+ }
@@ -1,88 +1,8 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useEffect } from '@wordpress/element';
5
- import { useDispatch } from '@wordpress/data';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import { store as commandsStore } from '../store';
11
-
12
- /**
13
- * Attach a command loader to the command palette. Used for dynamic commands.
14
- *
15
- * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.
16
- *
17
- * @example
18
- * ```js
19
- * 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
- * };
28
- *
29
- * function usePageSearchCommandLoader( { search } ) {
30
- * // 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 ] );
46
- *
47
- * // Create the commands.
48
- * const commands = useMemo( () => {
49
- * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {
50
- * return {
51
- * name: record.title?.rendered + ' ' + record.id,
52
- * label: record.title?.rendered
53
- * ? record.title?.rendered
54
- * : __( '(no title)' ),
55
- * icon: icons[ postType ],
56
- * callback: ( { close } ) => {
57
- * const args = {
58
- * postType,
59
- * postId: record.id,
60
- * ...extraArgs,
61
- * };
62
- * document.location = addQueryArgs( 'site-editor.php', args );
63
- * close();
64
- * },
65
- * };
66
- * } );
67
- * }, [ records, history ] );
68
- *
69
- * return {
70
- * commands,
71
- * isLoading,
72
- * };
73
- * }
74
- *
75
- * useCommandLoader( {
76
- * name: 'myplugin/page-search',
77
- * hook: usePageSearchCommandLoader,
78
- * } );
79
- * ```
80
- */
81
- export default function useCommandLoader(loader) {
82
- const {
83
- registerCommandLoader,
84
- unregisterCommandLoader
85
- } = useDispatch(commandsStore);
1
+ import { useEffect } from "@wordpress/element";
2
+ import { useDispatch } from "@wordpress/data";
3
+ import { store as commandsStore } from "../store";
4
+ function useCommandLoader(loader) {
5
+ const { registerCommandLoader, unregisterCommandLoader } = useDispatch(commandsStore);
86
6
  useEffect(() => {
87
7
  if (loader.disabled) {
88
8
  return;
@@ -95,6 +15,16 @@ export default function useCommandLoader(loader) {
95
15
  return () => {
96
16
  unregisterCommandLoader(loader.name);
97
17
  };
98
- }, [loader.name, loader.hook, loader.context, loader.disabled, registerCommandLoader, unregisterCommandLoader]);
18
+ }, [
19
+ loader.name,
20
+ loader.hook,
21
+ loader.context,
22
+ loader.disabled,
23
+ registerCommandLoader,
24
+ unregisterCommandLoader
25
+ ]);
99
26
  }
100
- //# sourceMappingURL=use-command-loader.js.map
27
+ export {
28
+ useCommandLoader as default
29
+ };
30
+ //# sourceMappingURL=use-command-loader.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["useEffect","useDispatch","store","commandsStore","useCommandLoader","loader","registerCommandLoader","unregisterCommandLoader","disabled","name","hook","context"],"sources":["@wordpress/commands/src/hooks/use-command-loader.js"],"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"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,UAAU;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,gBAAgBA,CAAEC,MAAM,EAAG;EAClD,MAAM;IAAEC,qBAAqB;IAAEC;EAAwB,CAAC,GACvDN,WAAW,CAAEE,aAAc,CAAC;EAC7BH,SAAS,CAAE,MAAM;IAChB,IAAKK,MAAM,CAACG,QAAQ,EAAG;MACtB;IACD;IACAF,qBAAqB,CAAE;MACtBG,IAAI,EAAEJ,MAAM,CAACI,IAAI;MACjBC,IAAI,EAAEL,MAAM,CAACK,IAAI;MACjBC,OAAO,EAAEN,MAAM,CAACM;IACjB,CAAE,CAAC;IACH,OAAO,MAAM;MACZJ,uBAAuB,CAAEF,MAAM,CAACI,IAAK,CAAC;IACvC,CAAC;EACF,CAAC,EAAE,CACFJ,MAAM,CAACI,IAAI,EACXJ,MAAM,CAACK,IAAI,EACXL,MAAM,CAACM,OAAO,EACdN,MAAM,CAACG,QAAQ,EACfF,qBAAqB,EACrBC,uBAAuB,CACtB,CAAC;AACJ","ignoreList":[]}
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,40 +1,8 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useEffect, useRef } from '@wordpress/element';
5
- import { useDispatch } from '@wordpress/data';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import { store as commandsStore } from '../store';
11
-
12
- /**
13
- * Attach a command to the command palette. Used for static commands.
14
- *
15
- * @param {import('../store/actions').WPCommandConfig} command command config.
16
- *
17
- * @example
18
- * ```js
19
- * import { useCommand } from '@wordpress/commands';
20
- * import { plus } from '@wordpress/icons';
21
- *
22
- * useCommand( {
23
- * name: 'myplugin/my-command-name',
24
- * label: __( 'Add new post' ),
25
- * icon: plus,
26
- * callback: ({ close }) => {
27
- * document.location.href = 'post-new.php';
28
- * close();
29
- * },
30
- * } );
31
- * ```
32
- */
33
- export function useCommand(command) {
34
- const {
35
- registerCommand,
36
- unregisterCommand
37
- } = useDispatch(commandsStore);
1
+ import { useEffect, useRef } from "@wordpress/element";
2
+ import { useDispatch } from "@wordpress/data";
3
+ import { store as commandsStore } from "../store";
4
+ function useCommand(command) {
5
+ const { registerCommand, unregisterCommand } = useDispatch(commandsStore);
38
6
  const currentCallbackRef = useRef(command.callback);
39
7
  useEffect(() => {
40
8
  currentCallbackRef.current = command.callback;
@@ -55,52 +23,26 @@ export function useCommand(command) {
55
23
  return () => {
56
24
  unregisterCommand(command.name);
57
25
  };
58
- }, [command.name, command.label, command.searchLabel, command.icon, command.context, command.keywords, command.disabled, registerCommand, unregisterCommand]);
59
- }
60
-
61
- /**
62
- * Attach multiple commands to the command palette. Used for static commands.
63
- *
64
- * @param {import('../store/actions').WPCommandConfig[]} commands Array of command configs.
65
- *
66
- * @example
67
- * ```js
68
- * import { useCommands } from '@wordpress/commands';
69
- * import { plus, edit } from '@wordpress/icons';
70
- *
71
- * useCommands( [
72
- * {
73
- * name: 'myplugin/add-post',
74
- * label: __( 'Add new post' ),
75
- * icon: plus,
76
- * callback: ({ close }) => {
77
- * document.location.href = 'post-new.php';
78
- * close();
79
- * },
80
- * },
81
- * {
82
- * name: 'myplugin/edit-posts',
83
- * label: __( 'Edit posts' ),
84
- * icon: edit,
85
- * callback: ({ close }) => {
86
- * document.location.href = 'edit.php';
87
- * close();
88
- * },
89
- * },
90
- * ] );
91
- * ```
92
- */
93
- export function useCommands(commands) {
94
- const {
26
+ }, [
27
+ command.name,
28
+ command.label,
29
+ command.searchLabel,
30
+ command.icon,
31
+ command.context,
32
+ command.keywords,
33
+ command.disabled,
95
34
  registerCommand,
96
35
  unregisterCommand
97
- } = useDispatch(commandsStore);
36
+ ]);
37
+ }
38
+ function useCommands(commands) {
39
+ const { registerCommand, unregisterCommand } = useDispatch(commandsStore);
98
40
  const currentCallbacksRef = useRef({});
99
41
  useEffect(() => {
100
42
  if (!commands) {
101
43
  return;
102
44
  }
103
- commands.forEach(command => {
45
+ commands.forEach((command) => {
104
46
  if (command.callback) {
105
47
  currentCallbacksRef.current[command.name] = command.callback;
106
48
  }
@@ -110,7 +52,7 @@ export function useCommands(commands) {
110
52
  if (!commands) {
111
53
  return;
112
54
  }
113
- commands.forEach(command => {
55
+ commands.forEach((command) => {
114
56
  if (command.disabled) {
115
57
  return;
116
58
  }
@@ -130,10 +72,14 @@ export function useCommands(commands) {
130
72
  });
131
73
  });
132
74
  return () => {
133
- commands.forEach(command => {
75
+ commands.forEach((command) => {
134
76
  unregisterCommand(command.name);
135
77
  });
136
78
  };
137
79
  }, [commands, registerCommand, unregisterCommand]);
138
80
  }
139
- //# sourceMappingURL=use-command.js.map
81
+ export {
82
+ useCommand,
83
+ useCommands
84
+ };
85
+ //# sourceMappingURL=use-command.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["useEffect","useRef","useDispatch","store","commandsStore","useCommand","command","registerCommand","unregisterCommand","currentCallbackRef","callback","current","disabled","name","context","label","searchLabel","icon","keywords","args","useCommands","commands","currentCallbacksRef","forEach"],"sources":["@wordpress/commands/src/hooks/use-command.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } 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 to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n *\n * @example\n * ```js\n * import { useCommand } from '@wordpress/commands';\n * import { plus } from '@wordpress/icons';\n *\n * useCommand( {\n * name: 'myplugin/my-command-name',\n * label: __( 'Add new post' ),\n *\t icon: plus,\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * } );\n * ```\n */\nexport function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbackRef = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallbackRef.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\n\t\tif ( command.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommand( {\n\t\t\tname: command.name,\n\t\t\tcontext: command.context,\n\t\t\tlabel: command.label,\n\t\t\tsearchLabel: command.searchLabel,\n\t\t\ticon: command.icon,\n\t\t\tkeywords: command.keywords,\n\t\t\tcallback: ( ...args ) => currentCallbackRef.current( ...args ),\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommand( command.name );\n\t\t};\n\t}, [\n\t\tcommand.name,\n\t\tcommand.label,\n\t\tcommand.searchLabel,\n\t\tcommand.icon,\n\t\tcommand.context,\n\t\tcommand.keywords,\n\t\tcommand.disabled,\n\t\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n\n/**\n * Attach multiple commands to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig[]} commands Array of command configs.\n *\n * @example\n * ```js\n * import { useCommands } from '@wordpress/commands';\n * import { plus, edit } from '@wordpress/icons';\n *\n * useCommands( [\n * {\n * name: 'myplugin/add-post',\n * label: __( 'Add new post' ),\n * icon: plus,\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * },\n * {\n * name: 'myplugin/edit-posts',\n * label: __( 'Edit posts' ),\n * icon: edit,\n * callback: ({ close }) => {\n * document.location.href = 'edit.php';\n * close();\n * },\n * },\n * ] );\n * ```\n */\nexport function useCommands( commands ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbacksRef = useRef( {} );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.callback ) {\n\t\t\t\tcurrentCallbacksRef.current[ command.name ] = command.callback;\n\t\t\t}\n\t\t} );\n\t}, [ commands ] );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tregisterCommand( {\n\t\t\t\tname: command.name,\n\t\t\t\tcontext: command.context,\n\t\t\t\tlabel: command.label,\n\t\t\t\tsearchLabel: command.searchLabel,\n\t\t\t\ticon: command.icon,\n\t\t\t\tkeywords: command.keywords,\n\t\t\t\tcallback: ( ...args ) => {\n\t\t\t\t\tconst callback =\n\t\t\t\t\t\tcurrentCallbacksRef.current[ command.name ];\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tcallback( ...args );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tcommands.forEach( ( command ) => {\n\t\t\t\tunregisterCommand( command.name );\n\t\t\t} );\n\t\t};\n\t}, [ commands, registerCommand, unregisterCommand ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,UAAU;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAAEC,OAAO,EAAG;EACrC,MAAM;IAAEC,eAAe;IAAEC;EAAkB,CAAC,GAAGN,WAAW,CAAEE,aAAc,CAAC;EAC3E,MAAMK,kBAAkB,GAAGR,MAAM,CAAEK,OAAO,CAACI,QAAS,CAAC;EACrDV,SAAS,CAAE,MAAM;IACh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["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } 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 to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n *\n * @example\n * ```js\n * import { useCommand } from '@wordpress/commands';\n * import { plus } from '@wordpress/icons';\n *\n * useCommand( {\n * name: 'myplugin/my-command-name',\n * label: __( 'Add new post' ),\n *\t icon: plus,\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * } );\n * ```\n */\nexport function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbackRef = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallbackRef.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\n\t\tif ( command.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommand( {\n\t\t\tname: command.name,\n\t\t\tcontext: command.context,\n\t\t\tlabel: command.label,\n\t\t\tsearchLabel: command.searchLabel,\n\t\t\ticon: command.icon,\n\t\t\tkeywords: command.keywords,\n\t\t\tcallback: ( ...args ) => currentCallbackRef.current( ...args ),\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommand( command.name );\n\t\t};\n\t}, [\n\t\tcommand.name,\n\t\tcommand.label,\n\t\tcommand.searchLabel,\n\t\tcommand.icon,\n\t\tcommand.context,\n\t\tcommand.keywords,\n\t\tcommand.disabled,\n\t\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n\n/**\n * Attach multiple commands to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig[]} commands Array of command configs.\n *\n * @example\n * ```js\n * import { useCommands } from '@wordpress/commands';\n * import { plus, pencil } from '@wordpress/icons';\n *\n * useCommands( [\n * {\n * name: 'myplugin/add-post',\n * label: __( 'Add new post' ),\n * icon: plus,\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * },\n * {\n * name: 'myplugin/edit-posts',\n * label: __( 'Edit posts' ),\n * icon: pencil,\n * callback: ({ close }) => {\n * document.location.href = 'edit.php';\n * close();\n * },\n * },\n * ] );\n * ```\n */\nexport function useCommands( commands ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbacksRef = useRef( {} );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.callback ) {\n\t\t\t\tcurrentCallbacksRef.current[ command.name ] = command.callback;\n\t\t\t}\n\t\t} );\n\t}, [ commands ] );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tregisterCommand( {\n\t\t\t\tname: command.name,\n\t\t\t\tcontext: command.context,\n\t\t\t\tlabel: command.label,\n\t\t\t\tsearchLabel: command.searchLabel,\n\t\t\t\ticon: command.icon,\n\t\t\t\tkeywords: command.keywords,\n\t\t\t\tcallback: ( ...args ) => {\n\t\t\t\t\tconst callback =\n\t\t\t\t\t\tcurrentCallbacksRef.current[ command.name ];\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tcallback( ...args );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tcommands.forEach( ( command ) => {\n\t\t\t\tunregisterCommand( command.name );\n\t\t\t} );\n\t\t};\n\t}, [ commands, registerCommand, unregisterCommand ] );\n}\n"],
5
+ "mappings": "AAGA,SAAS,WAAW,cAAc;AAClC,SAAS,mBAAmB;AAK5B,SAAS,SAAS,qBAAqB;AAuBhC,SAAS,WAAY,SAAU;AACrC,QAAM,EAAE,iBAAiB,kBAAkB,IAAI,YAAa,aAAc;AAC1E,QAAM,q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AAa,QAAQ;AAAA,QACrB,MAAM,QAAQ;AAAA,QACd,UAAU,QAAQ;AAAA,QAClB,UAAU,IAAK,SAAU;AACxB,gBAAM,WACL,oBAAoB,QAAS,QAAQ,IAAK;AAC3C,cAAK,UAAW;AACf,qBAAU,GAAG,IAAK;AAAA,UACnB;AAAA,QACD;AAAA,MACD,CAAE;AAAA,IACH,CAAE;AAEF,WAAO,MAAM;AACZ,eAAS,QAAS,CAAE,YAAa;AAChC,0BAAmB,QAAQ,IAAK;AAAA,MACjC,CAAE;AAAA,IACH;AAAA,EACD,GAAG,CAAE,UAAU,iBAAiB,iBAAkB,CAAE;AACrD;",
6
+ "names": []
7
+ }
@@ -1,6 +1,14 @@
1
- export { CommandMenu } from './components/command-menu';
2
- export { privateApis } from './private-apis';
3
- export { useCommand, useCommands } from './hooks/use-command';
4
- export { default as useCommandLoader } from './hooks/use-command-loader';
5
- export { store } from './store';
6
- //# sourceMappingURL=index.js.map
1
+ import { CommandMenu } from "./components/command-menu";
2
+ import { privateApis } from "./private-apis";
3
+ import { useCommand, useCommands } from "./hooks/use-command";
4
+ import { default as default2 } from "./hooks/use-command-loader";
5
+ import { store } from "./store";
6
+ export {
7
+ CommandMenu,
8
+ privateApis,
9
+ store,
10
+ useCommand,
11
+ default2 as useCommandLoader,
12
+ useCommands
13
+ };
14
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["CommandMenu","privateApis","useCommand","useCommands","default","useCommandLoader","store"],"sources":["@wordpress/commands/src/index.js"],"sourcesContent":["export { CommandMenu } from './components/command-menu';\nexport { privateApis } from './private-apis';\nexport { useCommand, useCommands } from './hooks/use-command';\nexport { default as useCommandLoader } from './hooks/use-command-loader';\nexport { store } from './store';\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,2BAA2B;AACvD,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,UAAU,EAAEC,WAAW,QAAQ,qBAAqB;AAC7D,SAASC,OAAO,IAAIC,gBAAgB,QAAQ,4BAA4B;AACxE,SAASC,KAAK,QAAQ,SAAS","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.js"],
4
+ "sourcesContent": ["export { CommandMenu } from './components/command-menu';\nexport { privateApis } from './private-apis';\nexport { useCommand, useCommands } from './hooks/use-command';\nexport { default as useCommandLoader } from './hooks/use-command-loader';\nexport { store } from './store';\n"],
5
+ "mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,YAAY,mBAAmB;AACxC,SAAoB,WAAXA,gBAAmC;AAC5C,SAAS,aAAa;",
6
+ "names": ["default"]
7
+ }
@@ -1,9 +1,10 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
5
- export const {
1
+ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
2
+ const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
3
+ "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
4
+ "@wordpress/commands"
5
+ );
6
+ export {
6
7
  lock,
7
8
  unlock
8
- } = __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');
9
- //# sourceMappingURL=lock-unlock.js.map
9
+ };
10
+ //# sourceMappingURL=lock-unlock.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/commands/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/commands'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAE1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,+HAA+H,EAC/H,qBACD,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lock-unlock.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/commands'\n\t);\n"],
5
+ "mappings": "AAGA,SAAS,wDAAwD;AAE1D,MAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
6
+ "names": []
7
+ }
@@ -1,14 +1,10 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { default as useCommandContext } from './hooks/use-command-context';
5
- import { lock } from './lock-unlock';
6
-
7
- /**
8
- * @private
9
- */
10
- export const privateApis = {};
1
+ import { default as useCommandContext } from "./hooks/use-command-context";
2
+ import { lock } from "./lock-unlock";
3
+ const privateApis = {};
11
4
  lock(privateApis, {
12
5
  useCommandContext
13
6
  });
14
- //# sourceMappingURL=private-apis.js.map
7
+ export {
8
+ privateApis
9
+ };
10
+ //# sourceMappingURL=private-apis.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["default","useCommandContext","lock","privateApis"],"sources":["@wordpress/commands/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { default as useCommandContext } from './hooks/use-command-context';\nimport { lock } from './lock-unlock';\n\n/**\n * @private\n */\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommandContext,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,IAAIC,iBAAiB,QAAQ,6BAA6B;AAC1E,SAASC,IAAI,QAAQ,eAAe;;AAEpC;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAG,CAAC,CAAC;AAC7BD,IAAI,CAAEC,WAAW,EAAE;EAClBF;AACD,CAAE,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/private-apis.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { default as useCommandContext } from './hooks/use-command-context';\nimport { lock } from './lock-unlock';\n\n/**\n * @private\n */\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommandContext,\n} );\n"],
5
+ "mappings": "AAGA,SAAS,WAAW,yBAAyB;AAC7C,SAAS,YAAY;AAKd,MAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AACD,CAAE;",
6
+ "names": []
7
+ }
@@ -1,110 +1,43 @@
1
- /** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */
2
-
3
- /**
4
- * Configuration of a registered keyboard shortcut.
5
- *
6
- * @typedef {Object} WPCommandConfig
7
- *
8
- * @property {string} name Command name.
9
- * @property {string} label Command label.
10
- * @property {string=} searchLabel Command search label.
11
- * @property {string=} context Command context.
12
- * @property {JSX.Element} icon Command icon.
13
- * @property {Function} callback Command callback.
14
- * @property {boolean} disabled Whether to disable the command.
15
- * @property {string[]=} keywords Command keywords for search matching.
16
- */
17
-
18
- /**
19
- * @typedef {(search: string) => WPCommandConfig[]} WPCommandLoaderHook hoo
20
- */
21
-
22
- /**
23
- * Command loader config.
24
- *
25
- * @typedef {Object} WPCommandLoaderConfig
26
- *
27
- * @property {string} name Command loader name.
28
- * @property {string=} context Command loader context.
29
- * @property {WPCommandLoaderHook} hook Command loader hook.
30
- * @property {boolean} disabled Whether to disable the command loader.
31
- */
32
-
33
- /**
34
- * Returns an action object used to register a new command.
35
- *
36
- * @param {WPCommandConfig} config Command config.
37
- *
38
- * @return {Object} action.
39
- */
40
- export function registerCommand(config) {
1
+ function registerCommand(config) {
41
2
  return {
42
- type: 'REGISTER_COMMAND',
3
+ type: "REGISTER_COMMAND",
43
4
  ...config
44
5
  };
45
6
  }
46
-
47
- /**
48
- * Returns an action object used to unregister a command.
49
- *
50
- * @param {string} name Command name.
51
- *
52
- * @return {Object} action.
53
- */
54
- export function unregisterCommand(name) {
7
+ function unregisterCommand(name) {
55
8
  return {
56
- type: 'UNREGISTER_COMMAND',
9
+ type: "UNREGISTER_COMMAND",
57
10
  name
58
11
  };
59
12
  }
60
-
61
- /**
62
- * Register command loader.
63
- *
64
- * @param {WPCommandLoaderConfig} config Command loader config.
65
- *
66
- * @return {Object} action.
67
- */
68
- export function registerCommandLoader(config) {
13
+ function registerCommandLoader(config) {
69
14
  return {
70
- type: 'REGISTER_COMMAND_LOADER',
15
+ type: "REGISTER_COMMAND_LOADER",
71
16
  ...config
72
17
  };
73
18
  }
74
-
75
- /**
76
- * Unregister command loader hook.
77
- *
78
- * @param {string} name Command loader name.
79
- *
80
- * @return {Object} action.
81
- */
82
- export function unregisterCommandLoader(name) {
19
+ function unregisterCommandLoader(name) {
83
20
  return {
84
- type: 'UNREGISTER_COMMAND_LOADER',
21
+ type: "UNREGISTER_COMMAND_LOADER",
85
22
  name
86
23
  };
87
24
  }
88
-
89
- /**
90
- * Opens the command palette.
91
- *
92
- * @return {Object} action.
93
- */
94
- export function open() {
25
+ function open() {
95
26
  return {
96
- type: 'OPEN'
27
+ type: "OPEN"
97
28
  };
98
29
  }
99
-
100
- /**
101
- * Closes the command palette.
102
- *
103
- * @return {Object} action.
104
- */
105
- export function close() {
30
+ function close() {
106
31
  return {
107
- type: 'CLOSE'
32
+ type: "CLOSE"
108
33
  };
109
34
  }
110
- //# sourceMappingURL=actions.js.map
35
+ export {
36
+ close,
37
+ open,
38
+ registerCommand,
39
+ registerCommandLoader,
40
+ unregisterCommand,
41
+ unregisterCommandLoader
42
+ };
43
+ //# sourceMappingURL=actions.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["registerCommand","config","type","unregisterCommand","name","registerCommandLoader","unregisterCommandLoader","open","close"],"sources":["@wordpress/commands/src/store/actions.js"],"sourcesContent":["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPCommandConfig\n *\n * @property {string} name Command name.\n * @property {string} label Command label.\n * @property {string=} searchLabel Command search label.\n * @property {string=} context Command context.\n * @property {JSX.Element} icon Command icon.\n * @property {Function} callback Command callback.\n * @property {boolean} disabled Whether to disable the command.\n * @property {string[]=} keywords Command keywords for search matching.\n */\n\n/**\n * @typedef {(search: string) => WPCommandConfig[]} WPCommandLoaderHook hoo\n */\n\n/**\n * Command loader config.\n *\n * @typedef {Object} WPCommandLoaderConfig\n *\n * @property {string} name Command loader name.\n * @property {string=} context Command loader context.\n * @property {WPCommandLoaderHook} hook Command loader hook.\n * @property {boolean} disabled Whether to disable the command loader.\n */\n\n/**\n * Returns an action object used to register a new command.\n *\n * @param {WPCommandConfig} config Command config.\n *\n * @return {Object} action.\n */\nexport function registerCommand( config ) {\n\treturn {\n\t\ttype: 'REGISTER_COMMAND',\n\t\t...config,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a command.\n *\n * @param {string} name Command name.\n *\n * @return {Object} action.\n */\nexport function unregisterCommand( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_COMMAND',\n\t\tname,\n\t};\n}\n\n/**\n * Register command loader.\n *\n * @param {WPCommandLoaderConfig} config Command loader config.\n *\n * @return {Object} action.\n */\nexport function registerCommandLoader( config ) {\n\treturn {\n\t\ttype: 'REGISTER_COMMAND_LOADER',\n\t\t...config,\n\t};\n}\n\n/**\n * Unregister command loader hook.\n *\n * @param {string} name Command loader name.\n *\n * @return {Object} action.\n */\nexport function unregisterCommandLoader( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_COMMAND_LOADER',\n\t\tname,\n\t};\n}\n\n/**\n * Opens the command palette.\n *\n * @return {Object} action.\n */\nexport function open() {\n\treturn {\n\t\ttype: 'OPEN',\n\t};\n}\n\n/**\n * Closes the command palette.\n *\n * @return {Object} action.\n */\nexport function close() {\n\treturn {\n\t\ttype: 'CLOSE',\n\t};\n}\n"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAAEC,MAAM,EAAG;EACzC,OAAO;IACNC,IAAI,EAAE,kBAAkB;IACxB,GAAGD;EACJ,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,iBAAiBA,CAAEC,IAAI,EAAG;EACzC,OAAO;IACNF,IAAI,EAAE,oBAAoB;IAC1BE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAAEJ,MAAM,EAAG;EAC/C,OAAO;IACNC,IAAI,EAAE,yBAAyB;IAC/B,GAAGD;EACJ,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,uBAAuBA,CAAEF,IAAI,EAAG;EAC/C,OAAO;IACNF,IAAI,EAAE,2BAA2B;IACjCE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,IAAIA,CAAA,EAAG;EACtB,OAAO;IACNL,IAAI,EAAE;EACP,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,KAAKA,CAAA,EAAG;EACvB,OAAO;IACNN,IAAI,EAAE;EACP,CAAC;AACF","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/actions.js"],
4
+ "sourcesContent": ["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPCommandConfig\n *\n * @property {string} name Command name.\n * @property {string} label Command label.\n * @property {string=} searchLabel Command search label.\n * @property {string=} context Command context.\n * @property {JSX.Element} icon Command icon.\n * @property {Function} callback Command callback.\n * @property {boolean} disabled Whether to disable the command.\n * @property {string[]=} keywords Command keywords for search matching.\n */\n\n/**\n * @typedef {(search: string) => WPCommandConfig[]} WPCommandLoaderHook hoo\n */\n\n/**\n * Command loader config.\n *\n * @typedef {Object} WPCommandLoaderConfig\n *\n * @property {string} name Command loader name.\n * @property {string=} context Command loader context.\n * @property {WPCommandLoaderHook} hook Command loader hook.\n * @property {boolean} disabled Whether to disable the command loader.\n */\n\n/**\n * Returns an action object used to register a new command.\n *\n * @param {WPCommandConfig} config Command config.\n *\n * @return {Object} action.\n */\nexport function registerCommand( config ) {\n\treturn {\n\t\ttype: 'REGISTER_COMMAND',\n\t\t...config,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a command.\n *\n * @param {string} name Command name.\n *\n * @return {Object} action.\n */\nexport function unregisterCommand( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_COMMAND',\n\t\tname,\n\t};\n}\n\n/**\n * Register command loader.\n *\n * @param {WPCommandLoaderConfig} config Command loader config.\n *\n * @return {Object} action.\n */\nexport function registerCommandLoader( config ) {\n\treturn {\n\t\ttype: 'REGISTER_COMMAND_LOADER',\n\t\t...config,\n\t};\n}\n\n/**\n * Unregister command loader hook.\n *\n * @param {string} name Command loader name.\n *\n * @return {Object} action.\n */\nexport function unregisterCommandLoader( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_COMMAND_LOADER',\n\t\tname,\n\t};\n}\n\n/**\n * Opens the command palette.\n *\n * @return {Object} action.\n */\nexport function open() {\n\treturn {\n\t\ttype: 'OPEN',\n\t};\n}\n\n/**\n * Closes the command palette.\n *\n * @return {Object} action.\n */\nexport function close() {\n\treturn {\n\t\ttype: 'CLOSE',\n\t};\n}\n"],
5
+ "mappings": "AAuCO,SAAS,gBAAiB,QAAS;AACzC,SAAO;AAAA,IACN,MAAM;AAAA,IACN,GAAG;AAAA,EACJ;AACD;AASO,SAAS,kBAAmB,MAAO;AACzC,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AASO,SAAS,sBAAuB,QAAS;AAC/C,SAAO;AAAA,IACN,MAAM;AAAA,IACN,GAAG;AAAA,EACJ;AACD;AASO,SAAS,wBAAyB,MAAO;AAC/C,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AAOO,SAAS,OAAO;AACtB,SAAO;AAAA,IACN,MAAM;AAAA,EACP;AACD;AAOO,SAAS,QAAQ;AACvB,SAAO;AAAA,IACN,MAAM;AAAA,EACP;AACD;",
6
+ "names": []
7
+ }
@@ -1,38 +1,18 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createReduxStore, register } from '@wordpress/data';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import reducer from './reducer';
10
- import * as actions from './actions';
11
- import * as selectors from './selectors';
12
- import * as privateActions from './private-actions';
13
- import { unlock } from '../lock-unlock';
14
- const STORE_NAME = 'core/commands';
15
-
16
- /**
17
- * Store definition for the commands namespace.
18
- *
19
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
20
- *
21
- * @type {Object}
22
- *
23
- * @example
24
- * ```js
25
- * import { store as commandsStore } from '@wordpress/commands';
26
- * import { useDispatch } from '@wordpress/data';
27
- * ...
28
- * const { open: openCommandCenter } = useDispatch( commandsStore );
29
- * ```
30
- */
31
- export const store = createReduxStore(STORE_NAME, {
1
+ import { createReduxStore, register } from "@wordpress/data";
2
+ import reducer from "./reducer";
3
+ import * as actions from "./actions";
4
+ import * as selectors from "./selectors";
5
+ import * as privateActions from "./private-actions";
6
+ import { unlock } from "../lock-unlock";
7
+ const STORE_NAME = "core/commands";
8
+ const store = createReduxStore(STORE_NAME, {
32
9
  reducer,
33
10
  actions,
34
11
  selectors
35
12
  });
36
13
  register(store);
37
14
  unlock(store).registerPrivateActions(privateActions);
38
- //# sourceMappingURL=index.js.map
15
+ export {
16
+ store
17
+ };
18
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createReduxStore","register","reducer","actions","selectors","privateActions","unlock","STORE_NAME","store","registerPrivateActions"],"sources":["@wordpress/commands/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport * as privateActions from './private-actions';\nimport { unlock } from '../lock-unlock';\n\nconst STORE_NAME = 'core/commands';\n\n/**\n * Store definition for the commands namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n *\n * @example\n * ```js\n * import { store as commandsStore } from '@wordpress/commands';\n * import { useDispatch } from '@wordpress/data';\n * ...\n * const { open: openCommandCenter } = useDispatch( commandsStore );\n * ```\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\nunlock( store ).registerPrivateActions( privateActions );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,EAAEC,QAAQ,QAAQ,iBAAiB;;AAE5D;AACA;AACA;AACA,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,SAAS,MAAM,aAAa;AACxC,OAAO,KAAKC,cAAc,MAAM,mBAAmB;AACnD,SAASC,MAAM,QAAQ,gBAAgB;AAEvC,MAAMC,UAAU,GAAG,eAAe;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAGR,gBAAgB,CAAEO,UAAU,EAAE;EAClDL,OAAO;EACPC,OAAO;EACPC;AACD,CAAE,CAAC;AAEHH,QAAQ,CAAEO,KAAM,CAAC;AACjBF,MAAM,CAAEE,KAAM,CAAC,CAACC,sBAAsB,CAAEJ,cAAe,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport * as privateActions from './private-actions';\nimport { unlock } from '../lock-unlock';\n\nconst STORE_NAME = 'core/commands';\n\n/**\n * Store definition for the commands namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n *\n * @example\n * ```js\n * import { store as commandsStore } from '@wordpress/commands';\n * import { useDispatch } from '@wordpress/data';\n * ...\n * const { open: openCommandCenter } = useDispatch( commandsStore );\n * ```\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\nunlock( store ).registerPrivateActions( privateActions );\n"],
5
+ "mappings": "AAGA,SAAS,kBAAkB,gBAAgB;AAK3C,OAAO,aAAa;AACpB,YAAY,aAAa;AACzB,YAAY,eAAe;AAC3B,YAAY,oBAAoB;AAChC,SAAS,cAAc;AAEvB,MAAM,aAAa;AAiBZ,MAAM,QAAQ,iBAAkB,YAAY;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,SAAU,KAAM;AAChB,OAAQ,KAAM,EAAE,uBAAwB,cAAe;",
6
+ "names": []
7
+ }