@wordpress/commands 0.6.4 → 0.8.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 (33) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +2 -2
  3. package/build/components/command-menu.js +3 -3
  4. package/build/components/command-menu.js.map +1 -1
  5. package/build/hooks/use-command-context.js +1 -1
  6. package/build/hooks/use-command-context.js.map +1 -1
  7. package/build/hooks/use-command-loader.js +1 -1
  8. package/build/hooks/use-command-loader.js.map +1 -1
  9. package/build/hooks/use-command.js +1 -1
  10. package/build/hooks/use-command.js.map +1 -1
  11. package/build/store/actions.js +2 -2
  12. package/build/store/actions.js.map +1 -1
  13. package/build/store/reducer.js +2 -2
  14. package/build/store/reducer.js.map +1 -1
  15. package/build-module/components/command-menu.js +3 -3
  16. package/build-module/components/command-menu.js.map +1 -1
  17. package/build-module/hooks/use-command-context.js +1 -1
  18. package/build-module/hooks/use-command-context.js.map +1 -1
  19. package/build-module/hooks/use-command-loader.js +1 -1
  20. package/build-module/hooks/use-command-loader.js.map +1 -1
  21. package/build-module/hooks/use-command.js +1 -1
  22. package/build-module/hooks/use-command.js.map +1 -1
  23. package/build-module/store/actions.js +2 -2
  24. package/build-module/store/actions.js.map +1 -1
  25. package/build-module/store/reducer.js +2 -2
  26. package/build-module/store/reducer.js.map +1 -1
  27. package/package.json +9 -9
  28. package/src/components/command-menu.js +3 -3
  29. package/src/hooks/use-command-context.js +1 -1
  30. package/src/hooks/use-command-loader.js +1 -1
  31. package/src/hooks/use-command.js +1 -1
  32. package/src/store/actions.js +2 -2
  33. package/src/store/reducer.js +2 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.8.0 (2023-07-05)
6
+
7
+ ## 0.7.0 (2023-06-23)
8
+
5
9
  ## 0.6.0 (2023-06-07)
6
10
 
7
11
  ## 0.5.0 (2023-05-24)
package/README.md CHANGED
@@ -38,7 +38,7 @@ _Type_
38
38
 
39
39
  ### useCommand
40
40
 
41
- Attach a command to the Global command menu.
41
+ Attach a command to the command palette.
42
42
 
43
43
  _Parameters_
44
44
 
@@ -46,7 +46,7 @@ _Parameters_
46
46
 
47
47
  ### useCommandLoader
48
48
 
49
- Attach a command loader to the Global command menu.
49
+ Attach a command loader to the command palette.
50
50
 
51
51
  _Parameters_
52
52
 
@@ -173,7 +173,7 @@ function CommandMenu() {
173
173
  registerShortcut({
174
174
  name: 'core/commands',
175
175
  category: 'global',
176
- description: (0, _i18n.__)('Open the global command menu'),
176
+ description: (0, _i18n.__)('Open the command palette'),
177
177
  keyCombination: {
178
178
  modifier: 'primary',
179
179
  character: 'k'
@@ -201,7 +201,7 @@ function CommandMenu() {
201
201
  };
202
202
 
203
203
  (0, _element.useEffect)(() => {
204
- // Focus the command menu input when mounting the modal.
204
+ // Focus the command palette input when mounting the modal.
205
205
  if (isOpen) {
206
206
  commandMenuInput.current.focus();
207
207
  }
@@ -220,7 +220,7 @@ function CommandMenu() {
220
220
  }, (0, _element.createElement)("div", {
221
221
  className: "commands-command-menu__container"
222
222
  }, (0, _element.createElement)(_cmdk.Command, {
223
- label: (0, _i18n.__)('Global Command Menu')
223
+ label: (0, _i18n.__)('Command palette')
224
224
  }, (0, _element.createElement)("div", {
225
225
  className: "commands-command-menu__header"
226
226
  }, (0, _element.createElement)(_cmdk.Command.Input, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/components/command-menu.js"],"names":["CommandMenuLoader","name","search","hook","setLoader","close","isLoading","commands","length","map","command","searchLabel","label","callback","icon","CommandMenuLoaderWrapper","currentLoader","key","setKey","current","prevKey","CommandMenuGroup","isContextual","loaders","select","getCommands","getCommandLoaders","commandsStore","loader","CommandMenu","registerShortcut","keyboardShortcutsStore","setSearch","isOpen","open","setLoaders","commandMenuInput","category","description","keyCombination","modifier","character","event","preventDefault","bindGlobal","value","closeAndReset","focus","Object","values","some","Boolean"],"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Ae1B,OAAf,EAAyB2B,IAAzB,CAA+BC,OAA/B,CAAlB;AAEA,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAC,uBADX;AAEC,IAAA,gBAAgB,EAAC,gCAFlB;AAGC,IAAA,cAAc,EAAGL,aAHlB;AAIC,IAAA,wBAAwB;AAJzB,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,aAAD;AAAS,IAAA,KAAK,EAAG,cAAI,qBAAJ;AAAjB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,aAAD,CAAS,KAAT;AACC,IAAA,GAAG,EAAGV,gBADP;AAEC,IAAA,KAAK,EAAGlC,MAFT;AAGC,IAAA,aAAa,EAAG8B,SAHjB;AAIC,IAAA,WAAW,EAAG,cAAI,0BAAJ;AAJf,IADD,CADD,EASC,4BAAC,aAAD,CAAS,IAAT,QACG9B,MAAM,IAAI,CAAEI,SAAZ,IACD,4BAAC,aAAD,CAAS,KAAT,QACG,cAAI,mBAAJ,CADH,CAFF,EAMC,4BAAC,gBAAD;AACC,IAAA,MAAM,EAAGJ,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAG0C,aAHT;AAIC,IAAA,YAAY;AAJb,IAND,EAYG5C,MAAM,IACP,4BAAC,gBAAD;AACC,IAAA,MAAM,EAAGA,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAG0C;AAHT,IAbF,CATD,CADD,CAND,CADD;AAyCA","sourcesContent":["/**\n * External dependencies\n */\nimport { Command } from 'cmdk';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tModal,\n\tTextHighlight,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport {\n\tstore as keyboardShortcutsStore,\n\tuseShortcut,\n} from '@wordpress/keyboard-shortcuts';\nimport { Icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Command.List>\n\t\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t\t<Command.Item\n\t\t\t\t\t\tkey={ command.name }\n\t\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Command.Item>\n\t\t\t\t) ) }\n\t\t\t</Command.List>\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst isOpen = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\tconst commandMenuInput = useRef();\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the global command menu' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\tif ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tuseEffect( () => {\n\t\t// Focus the command menu input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ __( 'Global Command Menu' ) }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Command.Input\n\t\t\t\t\t\t\tref={ commandMenuInput }\n\t\t\t\t\t\t\tvalue={ search }\n\t\t\t\t\t\t\tonValueChange={ setSearch }\n\t\t\t\t\t\t\tplaceholder={ __( 'Type a command or search' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/components/command-menu.js"],"names":["CommandMenuLoader","name","search","hook","setLoader","close","isLoading","commands","length","map","command","searchLabel","label","callback","icon","CommandMenuLoaderWrapper","currentLoader","key","setKey","current","prevKey","CommandMenuGroup","isContextual","loaders","select","getCommands","getCommandLoaders","commandsStore","loader","CommandMenu","registerShortcut","keyboardShortcutsStore","setSearch","isOpen","open","setLoaders","commandMenuInput","category","description","keyCombination","modifier","character","event","preventDefault","bindGlobal","value","closeAndReset","focus","Object","values","some","Boolean"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AAIA;;AAKA;;AAzBA;AACA;AACA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A,SAAS,EAAC,uBADX;AAEC,IAAA,gBAAgB,EAAC,gCAFlB;AAGC,IAAA,cAAc,EAAGL,aAHlB;AAIC,IAAA,wBAAwB;AAJzB,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,aAAD;AAAS,IAAA,KAAK,EAAG,cAAI,iBAAJ;AAAjB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,aAAD,CAAS,KAAT;AACC,IAAA,GAAG,EAAGV,gBADP;AAEC,IAAA,KAAK,EAAGlC,MAFT;AAGC,IAAA,aAAa,EAAG8B,SAHjB;AAIC,IAAA,WAAW,EAAG,cAAI,0BAAJ;AAJf,IADD,CADD,EASC,4BAAC,aAAD,CAAS,IAAT,QACG9B,MAAM,IAAI,CAAEI,SAAZ,IACD,4BAAC,aAAD,CAAS,KAAT,QACG,cAAI,mBAAJ,CADH,CAFF,EAMC,4BAAC,gBAAD;AACC,IAAA,MAAM,EAAGJ,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAG0C,aAHT;AAIC,IAAA,YAAY;AAJb,IAND,EAYG5C,MAAM,IACP,4BAAC,gBAAD;AACC,IAAA,MAAM,EAAGA,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAG0C;AAHT,IAbF,CATD,CADD,CAND,CADD;AAyCA","sourcesContent":["/**\n * External dependencies\n */\nimport { Command } from 'cmdk';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tModal,\n\tTextHighlight,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport {\n\tstore as keyboardShortcutsStore,\n\tuseShortcut,\n} from '@wordpress/keyboard-shortcuts';\nimport { Icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Command.List>\n\t\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t\t<Command.Item\n\t\t\t\t\t\tkey={ command.name }\n\t\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Command.Item>\n\t\t\t\t) ) }\n\t\t\t</Command.List>\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst isOpen = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\tconst commandMenuInput = useRef();\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the command palette' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\tif ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ __( 'Command palette' ) }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Command.Input\n\t\t\t\t\t\t\tref={ commandMenuInput }\n\t\t\t\t\t\t\tvalue={ search }\n\t\t\t\t\t\t\tonValueChange={ setSearch }\n\t\t\t\t\t\t\tplaceholder={ __( 'Type a command or search' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
@@ -22,7 +22,7 @@ var _lockUnlock = require("../lock-unlock");
22
22
  */
23
23
 
24
24
  /**
25
- * Sets the active context of the command center
25
+ * Sets the active context of the command palette
26
26
  *
27
27
  * @param {string} context Context to set.
28
28
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/hooks/use-command-context.js"],"names":["useCommandContext","context","getContext","commandsStore","initialContext","setContext","initialContextRef","current"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACe,SAASA,iBAAT,CAA4BC,OAA5B,EAAsC;AACpD,QAAM;AAAEC,IAAAA;AAAF,MAAiB,qBAAWC,YAAX,CAAvB;AACA,QAAMC,cAAc,GAAG,qBAAQF,UAAU,EAAlB,CAAvB;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAiB,wBAAQ,uBAAaF,YAAb,CAAR,CAAvB;AAEA,0BAAW,MAAM;AAChBE,IAAAA,UAAU,CAAEJ,OAAF,CAAV;AACA,GAFD,EAEG,CAAEA,OAAF,EAAWI,UAAX,CAFH,EALoD,CASpD;AACA;;AACA,0BAAW,MAAM;AAChB,UAAMC,iBAAiB,GAAGF,cAAc,CAACG,OAAzC;AACA,WAAO,MAAMF,UAAU,CAAEC,iBAAF,CAAvB;AACA,GAHD,EAGG,CAAED,UAAF,CAHH;AAIA","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 center\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"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/hooks/use-command-context.js"],"names":["useCommandContext","context","getContext","commandsStore","initialContext","setContext","initialContextRef","current"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACe,SAASA,iBAAT,CAA4BC,OAA5B,EAAsC;AACpD,QAAM;AAAEC,IAAAA;AAAF,MAAiB,qBAAWC,YAAX,CAAvB;AACA,QAAMC,cAAc,GAAG,qBAAQF,UAAU,EAAlB,CAAvB;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAiB,wBAAQ,uBAAaF,YAAb,CAAR,CAAvB;AAEA,0BAAW,MAAM;AAChBE,IAAAA,UAAU,CAAEJ,OAAF,CAAV;AACA,GAFD,EAEG,CAAEA,OAAF,EAAWI,UAAX,CAFH,EALoD,CASpD;AACA;;AACA,0BAAW,MAAM;AAChB,UAAMC,iBAAiB,GAAGF,cAAc,CAACG,OAAzC;AACA,WAAO,MAAMF,UAAU,CAAEC,iBAAF,CAAvB;AACA,GAHD,EAGG,CAAED,UAAF,CAHH;AAIA","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"]}
@@ -20,7 +20,7 @@ var _store = require("../store");
20
20
  */
21
21
 
22
22
  /**
23
- * Attach a command loader to the Global command menu.
23
+ * Attach a command loader to the command palette.
24
24
  *
25
25
  * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.
26
26
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/hooks/use-command-loader.js"],"names":["useCommandLoader","loader","registerCommandLoader","unregisterCommandLoader","commandsStore","name","hook","context"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,gBAAT,CAA2BC,MAA3B,EAAoC;AAClD,QAAM;AAAEC,IAAAA,qBAAF;AAAyBC,IAAAA;AAAzB,MACL,uBAAaC,YAAb,CADD;AAEA,0BAAW,MAAM;AAChBF,IAAAA,qBAAqB,CAAE;AACtBG,MAAAA,IAAI,EAAEJ,MAAM,CAACI,IADS;AAEtBC,MAAAA,IAAI,EAAEL,MAAM,CAACK,IAFS;AAGtBC,MAAAA,OAAO,EAAEN,MAAM,CAACM;AAHM,KAAF,CAArB;AAKA,WAAO,MAAM;AACZJ,MAAAA,uBAAuB,CAAEF,MAAM,CAACI,IAAT,CAAvB;AACA,KAFD;AAGA,GATD,EASG,CACFJ,MAAM,CAACI,IADL,EAEFJ,MAAM,CAACK,IAFL,EAGFL,MAAM,CAACM,OAHL,EAIFL,qBAJE,EAKFC,uBALE,CATH;AAgBA","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 Global command menu.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\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\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/hooks/use-command-loader.js"],"names":["useCommandLoader","loader","registerCommandLoader","unregisterCommandLoader","commandsStore","name","hook","context"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,gBAAT,CAA2BC,MAA3B,EAAoC;AAClD,QAAM;AAAEC,IAAAA,qBAAF;AAAyBC,IAAAA;AAAzB,MACL,uBAAaC,YAAb,CADD;AAEA,0BAAW,MAAM;AAChBF,IAAAA,qBAAqB,CAAE;AACtBG,MAAAA,IAAI,EAAEJ,MAAM,CAACI,IADS;AAEtBC,MAAAA,IAAI,EAAEL,MAAM,CAACK,IAFS;AAGtBC,MAAAA,OAAO,EAAEN,MAAM,CAACM;AAHM,KAAF,CAArB;AAKA,WAAO,MAAM;AACZJ,MAAAA,uBAAuB,CAAEF,MAAM,CAACI,IAAT,CAAvB;AACA,KAFD;AAGA,GATD,EASG,CACFJ,MAAM,CAACI,IADL,EAEFJ,MAAM,CAACK,IAFL,EAGFL,MAAM,CAACM,OAHL,EAIFL,qBAJE,EAKFC,uBALE,CATH;AAgBA","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.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\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\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"]}
@@ -20,7 +20,7 @@ var _store = require("../store");
20
20
  */
21
21
 
22
22
  /**
23
- * Attach a command to the Global command menu.
23
+ * Attach a command to the command palette.
24
24
  *
25
25
  * @param {import('../store/actions').WPCommandConfig} command command config.
26
26
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/hooks/use-command.js"],"names":["useCommand","command","registerCommand","unregisterCommand","commandsStore","currentCallback","callback","current","name","context","label","searchLabel","icon","args"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,UAAT,CAAqBC,OAArB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAyC,uBAAaC,YAAb,CAA/C;AACA,QAAMC,eAAe,GAAG,qBAAQJ,OAAO,CAACK,QAAhB,CAAxB;AACA,0BAAW,MAAM;AAChBD,IAAAA,eAAe,CAACE,OAAhB,GAA0BN,OAAO,CAACK,QAAlC;AACA,GAFD,EAEG,CAAEL,OAAO,CAACK,QAAV,CAFH;AAIA,0BAAW,MAAM;AAChBJ,IAAAA,eAAe,CAAE;AAChBM,MAAAA,IAAI,EAAEP,OAAO,CAACO,IADE;AAEhBC,MAAAA,OAAO,EAAER,OAAO,CAACQ,OAFD;AAGhBC,MAAAA,KAAK,EAAET,OAAO,CAACS,KAHC;AAIhBC,MAAAA,WAAW,EAAEV,OAAO,CAACU,WAJL;AAKhBC,MAAAA,IAAI,EAAEX,OAAO,CAACW,IALE;AAMhBN,MAAAA,QAAQ,EAAE,CAAE,GAAGO,IAAL,KAAeR,eAAe,CAACE,OAAhB,CAAyB,GAAGM,IAA5B;AANT,KAAF,CAAf;AAQA,WAAO,MAAM;AACZV,MAAAA,iBAAiB,CAAEF,OAAO,CAACO,IAAV,CAAjB;AACA,KAFD;AAGA,GAZD,EAYG,CACFP,OAAO,CAACO,IADN,EAEFP,OAAO,CAACS,KAFN,EAGFT,OAAO,CAACU,WAHN,EAIFV,OAAO,CAACW,IAJN,EAKFX,OAAO,CAACQ,OALN,EAMFP,eANE,EAOFC,iBAPE,CAZH;AAqBA","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 Global command menu.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n */\nexport default function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallback = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\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\tcallback: ( ...args ) => currentCallback.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\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/hooks/use-command.js"],"names":["useCommand","command","registerCommand","unregisterCommand","commandsStore","currentCallback","callback","current","name","context","label","searchLabel","icon","args"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,UAAT,CAAqBC,OAArB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAyC,uBAAaC,YAAb,CAA/C;AACA,QAAMC,eAAe,GAAG,qBAAQJ,OAAO,CAACK,QAAhB,CAAxB;AACA,0BAAW,MAAM;AAChBD,IAAAA,eAAe,CAACE,OAAhB,GAA0BN,OAAO,CAACK,QAAlC;AACA,GAFD,EAEG,CAAEL,OAAO,CAACK,QAAV,CAFH;AAIA,0BAAW,MAAM;AAChBJ,IAAAA,eAAe,CAAE;AAChBM,MAAAA,IAAI,EAAEP,OAAO,CAACO,IADE;AAEhBC,MAAAA,OAAO,EAAER,OAAO,CAACQ,OAFD;AAGhBC,MAAAA,KAAK,EAAET,OAAO,CAACS,KAHC;AAIhBC,MAAAA,WAAW,EAAEV,OAAO,CAACU,WAJL;AAKhBC,MAAAA,IAAI,EAAEX,OAAO,CAACW,IALE;AAMhBN,MAAAA,QAAQ,EAAE,CAAE,GAAGO,IAAL,KAAeR,eAAe,CAACE,OAAhB,CAAyB,GAAGM,IAA5B;AANT,KAAF,CAAf;AAQA,WAAO,MAAM;AACZV,MAAAA,iBAAiB,CAAEF,OAAO,CAACO,IAAV,CAAjB;AACA,KAFD;AAGA,GAZD,EAYG,CACFP,OAAO,CAACO,IADN,EAEFP,OAAO,CAACS,KAFN,EAGFT,OAAO,CAACU,WAHN,EAIFV,OAAO,CAACW,IAJN,EAKFX,OAAO,CAACQ,OALN,EAMFP,eANE,EAOFC,iBAPE,CAZH;AAqBA","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.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n */\nexport default function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallback = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\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\tcallback: ( ...args ) => currentCallback.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\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n"]}
@@ -98,7 +98,7 @@ function unregisterCommandLoader(name) {
98
98
  };
99
99
  }
100
100
  /**
101
- * Opens the command center.
101
+ * Opens the command palette.
102
102
  *
103
103
  * @return {Object} action.
104
104
  */
@@ -110,7 +110,7 @@ function open() {
110
110
  };
111
111
  }
112
112
  /**
113
- * Closes the command center.
113
+ * Closes the command palette.
114
114
  *
115
115
  * @return {Object} action.
116
116
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/store/actions.js"],"names":["registerCommand","config","type","unregisterCommand","name","registerCommandLoader","unregisterCommandLoader","open","close"],"mappings":";;;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,MAA1B,EAAmC;AACzC,SAAO;AACNC,IAAAA,IAAI,EAAE,kBADA;AAEN,OAAGD;AAFG,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,SAAO;AACNF,IAAAA,IAAI,EAAE,oBADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,qBAAT,CAAgCJ,MAAhC,EAAyC;AAC/C,SAAO;AACNC,IAAAA,IAAI,EAAE,yBADA;AAEN,OAAGD;AAFG,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,uBAAT,CAAkCF,IAAlC,EAAyC;AAC/C,SAAO;AACNF,IAAAA,IAAI,EAAE,2BADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASG,IAAT,GAAgB;AACtB,SAAO;AACNL,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASM,KAAT,GAAiB;AACvB,SAAO;AACNN,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA","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 */\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 */\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 center.\n *\n * @return {Object} action.\n */\nexport function open() {\n\treturn {\n\t\ttype: 'OPEN',\n\t};\n}\n\n/**\n * Closes the command center.\n *\n * @return {Object} action.\n */\nexport function close() {\n\treturn {\n\t\ttype: 'CLOSE',\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/store/actions.js"],"names":["registerCommand","config","type","unregisterCommand","name","registerCommandLoader","unregisterCommandLoader","open","close"],"mappings":";;;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,MAA1B,EAAmC;AACzC,SAAO;AACNC,IAAAA,IAAI,EAAE,kBADA;AAEN,OAAGD;AAFG,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,SAAO;AACNF,IAAAA,IAAI,EAAE,oBADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,qBAAT,CAAgCJ,MAAhC,EAAyC;AAC/C,SAAO;AACNC,IAAAA,IAAI,EAAE,yBADA;AAEN,OAAGD;AAFG,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,uBAAT,CAAkCF,IAAlC,EAAyC;AAC/C,SAAO;AACNF,IAAAA,IAAI,EAAE,2BADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASG,IAAT,GAAgB;AACtB,SAAO;AACNL,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASM,KAAT,GAAiB;AACvB,SAAO;AACNN,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA","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 */\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 */\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"]}
@@ -79,7 +79,7 @@ function commandLoaders(state = {}, action) {
79
79
  return state;
80
80
  }
81
81
  /**
82
- * Reducer returning the command center open state.
82
+ * Reducer returning the command palette open state.
83
83
  *
84
84
  * @param {Object} state Current state.
85
85
  * @param {Object} action Dispatched action.
@@ -100,7 +100,7 @@ function isOpen(state = false, action) {
100
100
  return state;
101
101
  }
102
102
  /**
103
- * Reducer returning the command center's active context.
103
+ * Reducer returning the command palette's active context.
104
104
  *
105
105
  * @param {Object} state Current state.
106
106
  * @param {Object} action Dispatched action.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/store/reducer.js"],"names":["commands","state","action","type","name","label","searchLabel","context","callback","icon","_","remainingState","commandLoaders","hook","isOpen","reducer"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAT,CAAmBC,KAAK,GAAG,EAA3B,EAA+BC,MAA/B,EAAwC;AACvC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,kBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,IAAT,GAAiB;AAChBA,UAAAA,IAAI,EAAEF,MAAM,CAACE,IADG;AAEhBC,UAAAA,KAAK,EAAEH,MAAM,CAACG,KAFE;AAGhBC,UAAAA,WAAW,EAAEJ,MAAM,CAACI,WAHJ;AAIhBC,UAAAA,OAAO,EAAEL,MAAM,CAACK,OAJA;AAKhBC,UAAAA,QAAQ,EAAEN,MAAM,CAACM,QALD;AAMhBC,UAAAA,IAAI,EAAEP,MAAM,CAACO;AANG;AAFX,OAAP;;AAWD,SAAK,oBAAL;AAA2B;AAC1B,cAAM;AAAE,WAAEP,MAAM,CAACE,IAAT,GAAiBM,CAAnB;AAAsB,aAAGC;AAAzB,YAA4CV,KAAlD;AACA,eAAOU,cAAP;AACA;AAhBF;;AAmBA,SAAOV,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASW,cAAT,CAAyBX,KAAK,GAAG,EAAjC,EAAqCC,MAArC,EAA8C;AAC7C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,yBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,IAAT,GAAiB;AAChBA,UAAAA,IAAI,EAAEF,MAAM,CAACE,IADG;AAEhBG,UAAAA,OAAO,EAAEL,MAAM,CAACK,OAFA;AAGhBM,UAAAA,IAAI,EAAEX,MAAM,CAACW;AAHG;AAFX,OAAP;;AAQD,SAAK,2BAAL;AAAkC;AACjC,cAAM;AAAE,WAAEX,MAAM,CAACE,IAAT,GAAiBM,CAAnB;AAAsB,aAAGC;AAAzB,YAA4CV,KAAlD;AACA,eAAOU,cAAP;AACA;AAbF;;AAgBA,SAAOV,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASa,MAAT,CAAiBb,KAAK,GAAG,KAAzB,EAAgCC,MAAhC,EAAyC;AACxC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,MAAL;AACC,aAAO,IAAP;;AACD,SAAK,OAAL;AACC,aAAO,KAAP;AAJF;;AAOA,SAAOF,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASM,OAAT,CAAkBN,KAAK,GAAG,MAA1B,EAAkCC,MAAlC,EAA2C;AAC1C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,aAAL;AACC,aAAOD,MAAM,CAACK,OAAd;AAFF;;AAKA,SAAON,KAAP;AACA;;AAED,MAAMc,OAAO,GAAG,2BAAiB;AAChCf,EAAAA,QADgC;AAEhCY,EAAAA,cAFgC;AAGhCE,EAAAA,MAHgC;AAIhCP,EAAAA;AAJgC,CAAjB,CAAhB;eAOeQ,O","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the registered commands\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commands( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tlabel: action.label,\n\t\t\t\t\tsearchLabel: action.searchLabel,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command loaders\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commandLoaders( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND_LOADER':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\thook: action.hook,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND_LOADER': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command center open state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction isOpen( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN':\n\t\t\treturn true;\n\t\tcase 'CLOSE':\n\t\t\treturn false;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command center's active context.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction context( state = 'root', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CONTEXT':\n\t\t\treturn action.context;\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n} );\n\nexport default reducer;\n"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/store/reducer.js"],"names":["commands","state","action","type","name","label","searchLabel","context","callback","icon","_","remainingState","commandLoaders","hook","isOpen","reducer"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAT,CAAmBC,KAAK,GAAG,EAA3B,EAA+BC,MAA/B,EAAwC;AACvC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,kBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,IAAT,GAAiB;AAChBA,UAAAA,IAAI,EAAEF,MAAM,CAACE,IADG;AAEhBC,UAAAA,KAAK,EAAEH,MAAM,CAACG,KAFE;AAGhBC,UAAAA,WAAW,EAAEJ,MAAM,CAACI,WAHJ;AAIhBC,UAAAA,OAAO,EAAEL,MAAM,CAACK,OAJA;AAKhBC,UAAAA,QAAQ,EAAEN,MAAM,CAACM,QALD;AAMhBC,UAAAA,IAAI,EAAEP,MAAM,CAACO;AANG;AAFX,OAAP;;AAWD,SAAK,oBAAL;AAA2B;AAC1B,cAAM;AAAE,WAAEP,MAAM,CAACE,IAAT,GAAiBM,CAAnB;AAAsB,aAAGC;AAAzB,YAA4CV,KAAlD;AACA,eAAOU,cAAP;AACA;AAhBF;;AAmBA,SAAOV,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASW,cAAT,CAAyBX,KAAK,GAAG,EAAjC,EAAqCC,MAArC,EAA8C;AAC7C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,yBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,IAAT,GAAiB;AAChBA,UAAAA,IAAI,EAAEF,MAAM,CAACE,IADG;AAEhBG,UAAAA,OAAO,EAAEL,MAAM,CAACK,OAFA;AAGhBM,UAAAA,IAAI,EAAEX,MAAM,CAACW;AAHG;AAFX,OAAP;;AAQD,SAAK,2BAAL;AAAkC;AACjC,cAAM;AAAE,WAAEX,MAAM,CAACE,IAAT,GAAiBM,CAAnB;AAAsB,aAAGC;AAAzB,YAA4CV,KAAlD;AACA,eAAOU,cAAP;AACA;AAbF;;AAgBA,SAAOV,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASa,MAAT,CAAiBb,KAAK,GAAG,KAAzB,EAAgCC,MAAhC,EAAyC;AACxC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,MAAL;AACC,aAAO,IAAP;;AACD,SAAK,OAAL;AACC,aAAO,KAAP;AAJF;;AAOA,SAAOF,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASM,OAAT,CAAkBN,KAAK,GAAG,MAA1B,EAAkCC,MAAlC,EAA2C;AAC1C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,aAAL;AACC,aAAOD,MAAM,CAACK,OAAd;AAFF;;AAKA,SAAON,KAAP;AACA;;AAED,MAAMc,OAAO,GAAG,2BAAiB;AAChCf,EAAAA,QADgC;AAEhCY,EAAAA,cAFgC;AAGhCE,EAAAA,MAHgC;AAIhCP,EAAAA;AAJgC,CAAjB,CAAhB;eAOeQ,O","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the registered commands\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commands( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tlabel: action.label,\n\t\t\t\t\tsearchLabel: action.searchLabel,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command loaders\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commandLoaders( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND_LOADER':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\thook: action.hook,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND_LOADER': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette open state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction isOpen( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN':\n\t\t\treturn true;\n\t\tcase 'CLOSE':\n\t\t\treturn false;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette's active context.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction context( state = 'root', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CONTEXT':\n\t\t\treturn action.context;\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n} );\n\nexport default reducer;\n"]}
@@ -157,7 +157,7 @@ export function CommandMenu() {
157
157
  registerShortcut({
158
158
  name: 'core/commands',
159
159
  category: 'global',
160
- description: __('Open the global command menu'),
160
+ description: __('Open the command palette'),
161
161
  keyCombination: {
162
162
  modifier: 'primary',
163
163
  character: 'k'
@@ -185,7 +185,7 @@ export function CommandMenu() {
185
185
  };
186
186
 
187
187
  useEffect(() => {
188
- // Focus the command menu input when mounting the modal.
188
+ // Focus the command palette input when mounting the modal.
189
189
  if (isOpen) {
190
190
  commandMenuInput.current.focus();
191
191
  }
@@ -204,7 +204,7 @@ export function CommandMenu() {
204
204
  }, createElement("div", {
205
205
  className: "commands-command-menu__container"
206
206
  }, createElement(Command, {
207
- label: __('Global Command Menu')
207
+ label: __('Command palette')
208
208
  }, createElement("div", {
209
209
  className: "commands-command-menu__header"
210
210
  }, createElement(Command.Input, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/components/command-menu.js"],"names":["Command","useSelect","useDispatch","useState","useEffect","useRef","useCallback","__","Modal","TextHighlight","__experimentalHStack","HStack","store","keyboardShortcutsStore","useShortcut","Icon","commandsStore","CommandMenuLoader","name","search","hook","setLoader","close","isLoading","commands","length","map","command","searchLabel","label","callback","icon","CommandMenuLoaderWrapper","currentLoader","key","setKey","current","prevKey","CommandMenuGroup","isContextual","loaders","select","getCommands","getCommandLoaders","loader","CommandMenu","registerShortcut","setSearch","isOpen","open","setLoaders","commandMenuInput","category","description","keyCombination","modifier","character","event","preventDefault","bindGlobal","value","closeAndReset","focus","Object","values","some","Boolean"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,MAAxB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,MAA9B,EAAsCC,WAAtC,QAAyD,oBAAzD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,KADD,EAECC,aAFD,EAGCC,oBAAoB,IAAIC,MAHzB,QAIO,uBAJP;AAKA,SACCC,KAAK,IAAIC,sBAD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AAA,gBAAgB,CAACf,OAAjB,CAAyB0B,KAAzB;AACA;AACD,GALQ,EAKN,CAAEd,MAAF,CALM,CAAT;;AAOA,MAAK,CAAEA,MAAP,EAAgB;AACf,WAAO,KAAP;AACA;;AACD,QAAMzB,SAAS,GAAGwC,MAAM,CAACC,MAAP,CAAexB,OAAf,EAAyByB,IAAzB,CAA+BC,OAA/B,CAAlB;AAEA,SACC,cAAC,KAAD;AACC,IAAA,SAAS,EAAC,uBADX;AAEC,IAAA,gBAAgB,EAAC,gCAFlB;AAGC,IAAA,cAAc,EAAGL,aAHlB;AAIC,IAAA,wBAAwB;AAJzB,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,OAAD;AAAS,IAAA,KAAK,EAAGtD,EAAE,CAAE,qBAAF;AAAnB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,OAAD,CAAS,KAAT;AACC,IAAA,GAAG,EAAG4C,gBADP;AAEC,IAAA,KAAK,EAAGhC,MAFT;AAGC,IAAA,aAAa,EAAG4B,SAHjB;AAIC,IAAA,WAAW,EAAGxC,EAAE,CAAE,0BAAF;AAJjB,IADD,CADD,EASC,cAAC,OAAD,CAAS,IAAT,QACGY,MAAM,IAAI,CAAEI,SAAZ,IACD,cAAC,OAAD,CAAS,KAAT,QACGhB,EAAE,CAAE,mBAAF,CADL,CAFF,EAMC,cAAC,gBAAD;AACC,IAAA,MAAM,EAAGY,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAGwC,aAHT;AAIC,IAAA,YAAY;AAJb,IAND,EAYG1C,MAAM,IACP,cAAC,gBAAD;AACC,IAAA,MAAM,EAAGA,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAGwC;AAHT,IAbF,CATD,CADD,CAND,CADD;AAyCA","sourcesContent":["/**\n * External dependencies\n */\nimport { Command } from 'cmdk';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tModal,\n\tTextHighlight,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport {\n\tstore as keyboardShortcutsStore,\n\tuseShortcut,\n} from '@wordpress/keyboard-shortcuts';\nimport { Icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Command.List>\n\t\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t\t<Command.Item\n\t\t\t\t\t\tkey={ command.name }\n\t\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Command.Item>\n\t\t\t\t) ) }\n\t\t\t</Command.List>\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst isOpen = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\tconst commandMenuInput = useRef();\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the global command menu' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\tif ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tuseEffect( () => {\n\t\t// Focus the command menu input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ __( 'Global Command Menu' ) }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Command.Input\n\t\t\t\t\t\t\tref={ commandMenuInput }\n\t\t\t\t\t\t\tvalue={ search }\n\t\t\t\t\t\t\tonValueChange={ setSearch }\n\t\t\t\t\t\t\tplaceholder={ __( 'Type a command or search' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/components/command-menu.js"],"names":["Command","useSelect","useDispatch","useState","useEffect","useRef","useCallback","__","Modal","TextHighlight","__experimentalHStack","HStack","store","keyboardShortcutsStore","useShortcut","Icon","commandsStore","CommandMenuLoader","name","search","hook","setLoader","close","isLoading","commands","length","map","command","searchLabel","label","callback","icon","CommandMenuLoaderWrapper","currentLoader","key","setKey","current","prevKey","CommandMenuGroup","isContextual","loaders","select","getCommands","getCommandLoaders","loader","CommandMenu","registerShortcut","setSearch","isOpen","open","setLoaders","commandMenuInput","category","description","keyCombination","modifier","character","event","preventDefault","bindGlobal","value","closeAndReset","focus","Object","values","some","Boolean"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,MAAxB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,MAA9B,EAAsCC,WAAtC,QAAyD,oBAAzD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,KADD,EAECC,aAFD,EAGCC,oBAAoB,IAAIC,MAHzB,QAIO,uBAJP;AAKA,SACCC,KAAK,IAAIC,sBADV,EAECC,WAFD,QAGO,+BAHP;AAIA,SAASC,IAAT,QAAqB,kBAArB;AAEA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,UAAvC;;AAEA,SAASC,iBAAT,CAA4B;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,MAAR;AAAgBC,EAAAA,IAAhB;AAAsBC,EAAAA,SAAtB;AAAiCC,EAAAA;AAAjC,CAA5B,EAAuE;AAAA;;AACtE,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAQ,GAAG;AAAxB,eAA+BJ,IAAI,CAAE;AAAED,IAAAA;AAAF,GAAF,CAAnC,yCAAqD,EAA3D;AACAf,EAAAA,SAAS,CAAE,MAAM;AAChBiB,IAAAA,SAAS,CAAEH,IAAF,EAAQK,SAAR,CAAT;AACA,GAFQ,EAEN,CAAEF,SAAF,EAAaH,IAAb,EAAmBK,SAAnB,CAFM,CAAT;;AAIA,MAAK,CAAEC,QAAQ,CAACC,MAAhB,EAAyB;AACxB,WAAO,IAAP;AACA;;AAED,SACC,8BACC,cAAC,OAAD,CAAS,IAAT,QACGD,QAAQ,C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;AAJjB,IADD,CADD,EASC,cAAC,OAAD,CAAS,IAAT,QACGY,MAAM,IAAI,CAAEI,SAAZ,IACD,cAAC,OAAD,CAAS,KAAT,QACGhB,EAAE,CAAE,mBAAF,CADL,CAFF,EAMC,cAAC,gBAAD;AACC,IAAA,MAAM,EAAGY,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAGwC,aAHT;AAIC,IAAA,YAAY;AAJb,IAND,EAYG1C,MAAM,IACP,cAAC,gBAAD;AACC,IAAA,MAAM,EAAGA,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAGwC;AAHT,IAbF,CATD,CADD,CAND,CADD;AAyCA","sourcesContent":["/**\n * External dependencies\n */\nimport { Command } from 'cmdk';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tModal,\n\tTextHighlight,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport {\n\tstore as keyboardShortcutsStore,\n\tuseShortcut,\n} from '@wordpress/keyboard-shortcuts';\nimport { Icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Command.List>\n\t\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t\t<Command.Item\n\t\t\t\t\t\tkey={ command.name }\n\t\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Command.Item>\n\t\t\t\t) ) }\n\t\t\t</Command.List>\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst isOpen = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\tconst commandMenuInput = useRef();\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the command palette' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\tif ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ __( 'Command palette' ) }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Command.Input\n\t\t\t\t\t\t\tref={ commandMenuInput }\n\t\t\t\t\t\t\tvalue={ search }\n\t\t\t\t\t\t\tonValueChange={ setSearch }\n\t\t\t\t\t\t\tplaceholder={ __( 'Type a command or search' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
@@ -10,7 +10,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
10
10
  import { store as commandsStore } from '../store';
11
11
  import { unlock } from '../lock-unlock';
12
12
  /**
13
- * Sets the active context of the command center
13
+ * Sets the active context of the command palette
14
14
  *
15
15
  * @param {string} context Context to set.
16
16
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/hooks/use-command-context.js"],"names":["useEffect","useRef","useDispatch","useSelect","store","commandsStore","unlock","useCommandContext","context","getContext","initialContext","setContext","initialContextRef","current"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,UAAvC;AACA,SAASC,MAAT,QAAuB,gBAAvB;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,iBAAT,CAA4BC,OAA5B,EAAsC;AACpD,QAAM;AAAEC,IAAAA;AAAF,MAAiBN,SAAS,CAAEE,aAAF,CAAhC;AACA,QAAMK,cAAc,GAAGT,MAAM,CAAEQ,UAAU,EAAZ,CAA7B;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAiBL,MAAM,CAAEJ,WAAW,CAAEG,aAAF,CAAb,CAA7B;AAEAL,EAAAA,SAAS,CAAE,MAAM;AAChBW,IAAAA,UAAU,CAAEH,OAAF,CAAV;AACA,GAFQ,EAEN,CAAEA,OAAF,EAAWG,UAAX,CAFM,CAAT,CALoD,CASpD;AACA;;AACAX,EAAAA,SAAS,CAAE,MAAM;AAChB,UAAMY,iBAAiB,GAAGF,cAAc,CAACG,OAAzC;AACA,WAAO,MAAMF,UAAU,CAAEC,iBAAF,CAAvB;AACA,GAHQ,EAGN,CAAED,UAAF,CAHM,CAAT;AAIA","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 center\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"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/hooks/use-command-context.js"],"names":["useEffect","useRef","useDispatch","useSelect","store","commandsStore","unlock","useCommandContext","context","getContext","initialContext","setContext","initialContextRef","current"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,UAAvC;AACA,SAASC,MAAT,QAAuB,gBAAvB;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,iBAAT,CAA4BC,OAA5B,EAAsC;AACpD,QAAM;AAAEC,IAAAA;AAAF,MAAiBN,SAAS,CAAEE,aAAF,CAAhC;AACA,QAAMK,cAAc,GAAGT,MAAM,CAAEQ,UAAU,EAAZ,CAA7B;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAiBL,MAAM,CAAEJ,WAAW,CAAEG,aAAF,CAAb,CAA7B;AAEAL,EAAAA,SAAS,CAAE,MAAM;AAChBW,IAAAA,UAAU,CAAEH,OAAF,CAAV;AACA,GAFQ,EAEN,CAAEA,OAAF,EAAWG,UAAX,CAFM,CAAT,CALoD,CASpD;AACA;;AACAX,EAAAA,SAAS,CAAE,MAAM;AAChB,UAAMY,iBAAiB,GAAGF,cAAc,CAACG,OAAzC;AACA,WAAO,MAAMF,UAAU,CAAEC,iBAAF,CAAvB;AACA,GAHQ,EAGN,CAAED,UAAF,CAHM,CAAT;AAIA","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"]}
@@ -9,7 +9,7 @@ import { useDispatch } from '@wordpress/data';
9
9
 
10
10
  import { store as commandsStore } from '../store';
11
11
  /**
12
- * Attach a command loader to the Global command menu.
12
+ * Attach a command loader to the command palette.
13
13
  *
14
14
  * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.
15
15
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/hooks/use-command-loader.js"],"names":["useEffect","useDispatch","store","commandsStore","useCommandLoader","loader","registerCommandLoader","unregisterCommandLoader","name","hook","context"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,UAAvC;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,gBAAT,CAA2BC,MAA3B,EAAoC;AAClD,QAAM;AAAEC,IAAAA,qBAAF;AAAyBC,IAAAA;AAAzB,MACLN,WAAW,CAAEE,aAAF,CADZ;AAEAH,EAAAA,SAAS,CAAE,MAAM;AAChBM,IAAAA,qBAAqB,CAAE;AACtBE,MAAAA,IAAI,EAAEH,MAAM,CAACG,IADS;AAEtBC,MAAAA,IAAI,EAAEJ,MAAM,CAACI,IAFS;AAGtBC,MAAAA,OAAO,EAAEL,MAAM,CAACK;AAHM,KAAF,CAArB;AAKA,WAAO,MAAM;AACZH,MAAAA,uBAAuB,CAAEF,MAAM,CAACG,IAAT,CAAvB;AACA,KAFD;AAGA,GATQ,EASN,CACFH,MAAM,CAACG,IADL,EAEFH,MAAM,CAACI,IAFL,EAGFJ,MAAM,CAACK,OAHL,EAIFJ,qBAJE,EAKFC,uBALE,CATM,CAAT;AAgBA","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 Global command menu.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\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\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/hooks/use-command-loader.js"],"names":["useEffect","useDispatch","store","commandsStore","useCommandLoader","loader","registerCommandLoader","unregisterCommandLoader","name","hook","context"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,UAAvC;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,gBAAT,CAA2BC,MAA3B,EAAoC;AAClD,QAAM;AAAEC,IAAAA,qBAAF;AAAyBC,IAAAA;AAAzB,MACLN,WAAW,CAAEE,aAAF,CADZ;AAEAH,EAAAA,SAAS,CAAE,MAAM;AAChBM,IAAAA,qBAAqB,CAAE;AACtBE,MAAAA,IAAI,EAAEH,MAAM,CAACG,IADS;AAEtBC,MAAAA,IAAI,EAAEJ,MAAM,CAACI,IAFS;AAGtBC,MAAAA,OAAO,EAAEL,MAAM,CAACK;AAHM,KAAF,CAArB;AAKA,WAAO,MAAM;AACZH,MAAAA,uBAAuB,CAAEF,MAAM,CAACG,IAAT,CAAvB;AACA,KAFD;AAGA,GATQ,EASN,CACFH,MAAM,CAACG,IADL,EAEFH,MAAM,CAACI,IAFL,EAGFJ,MAAM,CAACK,OAHL,EAIFJ,qBAJE,EAKFC,uBALE,CATM,CAAT;AAgBA","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.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\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\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"]}
@@ -9,7 +9,7 @@ import { useDispatch } from '@wordpress/data';
9
9
 
10
10
  import { store as commandsStore } from '../store';
11
11
  /**
12
- * Attach a command to the Global command menu.
12
+ * Attach a command to the command palette.
13
13
  *
14
14
  * @param {import('../store/actions').WPCommandConfig} command command config.
15
15
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/hooks/use-command.js"],"names":["useEffect","useRef","useDispatch","store","commandsStore","useCommand","command","registerCommand","unregisterCommand","currentCallback","callback","current","name","context","label","searchLabel","icon","args"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,UAAvC;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,UAAT,CAAqBC,OAArB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAyCN,WAAW,CAAEE,aAAF,CAA1D;AACA,QAAMK,eAAe,GAAGR,MAAM,CAAEK,OAAO,CAACI,QAAV,CAA9B;AACAV,EAAAA,SAAS,CAAE,MAAM;AAChBS,IAAAA,eAAe,CAACE,OAAhB,GAA0BL,OAAO,CAACI,QAAlC;AACA,GAFQ,EAEN,CAAEJ,OAAO,CAACI,QAAV,CAFM,CAAT;AAIAV,EAAAA,SAAS,CAAE,MAAM;AAChBO,IAAAA,eAAe,CAAE;AAChBK,MAAAA,IAAI,EAAEN,OAAO,CAACM,IADE;AAEhBC,MAAAA,OAAO,EAAEP,OAAO,CAACO,OAFD;AAGhBC,MAAAA,KAAK,EAAER,OAAO,CAACQ,KAHC;AAIhBC,MAAAA,WAAW,EAAET,OAAO,CAACS,WAJL;AAKhBC,MAAAA,IAAI,EAAEV,OAAO,CAACU,IALE;AAMhBN,MAAAA,QAAQ,EAAE,CAAE,GAAGO,IAAL,KAAeR,eAAe,CAACE,OAAhB,CAAyB,GAAGM,IAA5B;AANT,KAAF,CAAf;AAQA,WAAO,MAAM;AACZT,MAAAA,iBAAiB,CAAEF,OAAO,CAACM,IAAV,CAAjB;AACA,KAFD;AAGA,GAZQ,EAYN,CACFN,OAAO,CAACM,IADN,EAEFN,OAAO,CAACQ,KAFN,EAGFR,OAAO,CAACS,WAHN,EAIFT,OAAO,CAACU,IAJN,EAKFV,OAAO,CAACO,OALN,EAMFN,eANE,EAOFC,iBAPE,CAZM,CAAT;AAqBA","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 Global command menu.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n */\nexport default function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallback = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\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\tcallback: ( ...args ) => currentCallback.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\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/hooks/use-command.js"],"names":["useEffect","useRef","useDispatch","store","commandsStore","useCommand","command","registerCommand","unregisterCommand","currentCallback","callback","current","name","context","label","searchLabel","icon","args"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,UAAvC;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,UAAT,CAAqBC,OAArB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAyCN,WAAW,CAAEE,aAAF,CAA1D;AACA,QAAMK,eAAe,GAAGR,MAAM,CAAEK,OAAO,CAACI,QAAV,CAA9B;AACAV,EAAAA,SAAS,CAAE,MAAM;AAChBS,IAAAA,eAAe,CAACE,OAAhB,GAA0BL,OAAO,CAACI,QAAlC;AACA,GAFQ,EAEN,CAAEJ,OAAO,CAACI,QAAV,CAFM,CAAT;AAIAV,EAAAA,SAAS,CAAE,MAAM;AAChBO,IAAAA,eAAe,CAAE;AAChBK,MAAAA,IAAI,EAAEN,OAAO,CAACM,IADE;AAEhBC,MAAAA,OAAO,EAAEP,OAAO,CAACO,OAFD;AAGhBC,MAAAA,KAAK,EAAER,OAAO,CAACQ,KAHC;AAIhBC,MAAAA,WAAW,EAAET,OAAO,CAACS,WAJL;AAKhBC,MAAAA,IAAI,EAAEV,OAAO,CAACU,IALE;AAMhBN,MAAAA,QAAQ,EAAE,CAAE,GAAGO,IAAL,KAAeR,eAAe,CAACE,OAAhB,CAAyB,GAAGM,IAA5B;AANT,KAAF,CAAf;AAQA,WAAO,MAAM;AACZT,MAAAA,iBAAiB,CAAEF,OAAO,CAACM,IAAV,CAAjB;AACA,KAFD;AAGA,GAZQ,EAYN,CACFN,OAAO,CAACM,IADN,EAEFN,OAAO,CAACQ,KAFN,EAGFR,OAAO,CAACS,WAHN,EAIFT,OAAO,CAACU,IAJN,EAKFV,OAAO,CAACO,OALN,EAMFN,eANE,EAOFC,iBAPE,CAZM,CAAT;AAqBA","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.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n */\nexport default function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallback = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\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\tcallback: ( ...args ) => currentCallback.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\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n"]}
@@ -83,7 +83,7 @@ export function unregisterCommandLoader(name) {
83
83
  };
84
84
  }
85
85
  /**
86
- * Opens the command center.
86
+ * Opens the command palette.
87
87
  *
88
88
  * @return {Object} action.
89
89
  */
@@ -94,7 +94,7 @@ export function open() {
94
94
  };
95
95
  }
96
96
  /**
97
- * Closes the command center.
97
+ * Closes the command palette.
98
98
  *
99
99
  * @return {Object} action.
100
100
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/store/actions.js"],"names":["registerCommand","config","type","unregisterCommand","name","registerCommandLoader","unregisterCommandLoader","open","close"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAT,CAA0BC,MAA1B,EAAmC;AACzC,SAAO;AACNC,IAAAA,IAAI,EAAE,kBADA;AAEN,OAAGD;AAFG,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,SAAO;AACNF,IAAAA,IAAI,EAAE,oBADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAAgCJ,MAAhC,EAAyC;AAC/C,SAAO;AACNC,IAAAA,IAAI,EAAE,yBADA;AAEN,OAAGD;AAFG,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,uBAAT,CAAkCF,IAAlC,EAAyC;AAC/C,SAAO;AACNF,IAAAA,IAAI,EAAE,2BADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,IAAT,GAAgB;AACtB,SAAO;AACNL,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,KAAT,GAAiB;AACvB,SAAO;AACNN,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA","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 */\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 */\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 center.\n *\n * @return {Object} action.\n */\nexport function open() {\n\treturn {\n\t\ttype: 'OPEN',\n\t};\n}\n\n/**\n * Closes the command center.\n *\n * @return {Object} action.\n */\nexport function close() {\n\treturn {\n\t\ttype: 'CLOSE',\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/store/actions.js"],"names":["registerCommand","config","type","unregisterCommand","name","registerCommandLoader","unregisterCommandLoader","open","close"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAT,CAA0BC,MAA1B,EAAmC;AACzC,SAAO;AACNC,IAAAA,IAAI,EAAE,kBADA;AAEN,OAAGD;AAFG,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,SAAO;AACNF,IAAAA,IAAI,EAAE,oBADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAAgCJ,MAAhC,EAAyC;AAC/C,SAAO;AACNC,IAAAA,IAAI,EAAE,yBADA;AAEN,OAAGD;AAFG,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,uBAAT,CAAkCF,IAAlC,EAAyC;AAC/C,SAAO;AACNF,IAAAA,IAAI,EAAE,2BADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,IAAT,GAAgB;AACtB,SAAO;AACNL,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,KAAT,GAAiB;AACvB,SAAO;AACNN,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA","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 */\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 */\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"]}
@@ -71,7 +71,7 @@ function commandLoaders(state = {}, action) {
71
71
  return state;
72
72
  }
73
73
  /**
74
- * Reducer returning the command center open state.
74
+ * Reducer returning the command palette open state.
75
75
  *
76
76
  * @param {Object} state Current state.
77
77
  * @param {Object} action Dispatched action.
@@ -92,7 +92,7 @@ function isOpen(state = false, action) {
92
92
  return state;
93
93
  }
94
94
  /**
95
- * Reducer returning the command center's active context.
95
+ * Reducer returning the command palette's active context.
96
96
  *
97
97
  * @param {Object} state Current state.
98
98
  * @param {Object} action Dispatched action.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/commands/src/store/reducer.js"],"names":["combineReducers","commands","state","action","type","name","label","searchLabel","context","callback","icon","_","remainingState","commandLoaders","hook","isOpen","reducer"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,QAAT,CAAmBC,KAAK,GAAG,EAA3B,EAA+BC,MAA/B,EAAwC;AACvC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,kBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,IAAT,GAAiB;AAChBA,UAAAA,IAAI,EAAEF,MAAM,CAACE,IADG;AAEhBC,UAAAA,KAAK,EAAEH,MAAM,CAACG,KAFE;AAGhBC,UAAAA,WAAW,EAAEJ,MAAM,CAACI,WAHJ;AAIhBC,UAAAA,OAAO,EAAEL,MAAM,CAACK,OAJA;AAKhBC,UAAAA,QAAQ,EAAEN,MAAM,CAACM,QALD;AAMhBC,UAAAA,IAAI,EAAEP,MAAM,CAACO;AANG;AAFX,OAAP;;AAWD,SAAK,oBAAL;AAA2B;AAC1B,cAAM;AAAE,WAAEP,MAAM,CAACE,IAAT,GAAiBM,CAAnB;AAAsB,aAAGC;AAAzB,YAA4CV,KAAlD;AACA,eAAOU,cAAP;AACA;AAhBF;;AAmBA,SAAOV,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASW,cAAT,CAAyBX,KAAK,GAAG,EAAjC,EAAqCC,MAArC,EAA8C;AAC7C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,yBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,IAAT,GAAiB;AAChBA,UAAAA,IAAI,EAAEF,MAAM,CAACE,IADG;AAEhBG,UAAAA,OAAO,EAAEL,MAAM,CAACK,OAFA;AAGhBM,UAAAA,IAAI,EAAEX,MAAM,CAACW;AAHG;AAFX,OAAP;;AAQD,SAAK,2BAAL;AAAkC;AACjC,cAAM;AAAE,WAAEX,MAAM,CAACE,IAAT,GAAiBM,CAAnB;AAAsB,aAAGC;AAAzB,YAA4CV,KAAlD;AACA,eAAOU,cAAP;AACA;AAbF;;AAgBA,SAAOV,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASa,MAAT,CAAiBb,KAAK,GAAG,KAAzB,EAAgCC,MAAhC,EAAyC;AACxC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,MAAL;AACC,aAAO,IAAP;;AACD,SAAK,OAAL;AACC,aAAO,KAAP;AAJF;;AAOA,SAAOF,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASM,OAAT,CAAkBN,KAAK,GAAG,MAA1B,EAAkCC,MAAlC,EAA2C;AAC1C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,aAAL;AACC,aAAOD,MAAM,CAACK,OAAd;AAFF;;AAKA,SAAON,KAAP;AACA;;AAED,MAAMc,OAAO,GAAGhB,eAAe,CAAE;AAChCC,EAAAA,QADgC;AAEhCY,EAAAA,cAFgC;AAGhCE,EAAAA,MAHgC;AAIhCP,EAAAA;AAJgC,CAAF,CAA/B;AAOA,eAAeQ,OAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the registered commands\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commands( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tlabel: action.label,\n\t\t\t\t\tsearchLabel: action.searchLabel,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command loaders\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commandLoaders( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND_LOADER':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\thook: action.hook,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND_LOADER': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command center open state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction isOpen( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN':\n\t\t\treturn true;\n\t\tcase 'CLOSE':\n\t\t\treturn false;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command center's active context.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction context( state = 'root', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CONTEXT':\n\t\t\treturn action.context;\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n} );\n\nexport default reducer;\n"]}
1
+ {"version":3,"sources":["@wordpress/commands/src/store/reducer.js"],"names":["combineReducers","commands","state","action","type","name","label","searchLabel","context","callback","icon","_","remainingState","commandLoaders","hook","isOpen","reducer"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,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;AACA;;;AACA,SAASa,MAAT,CAAiBb,KAAK,GAAG,KAAzB,EAAgCC,MAAhC,EAAyC;AACxC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,MAAL;AACC,aAAO,IAAP;;AACD,SAAK,OAAL;AACC,aAAO,KAAP;AAJF;;AAOA,SAAOF,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASM,OAAT,CAAkBN,KAAK,GAAG,MAA1B,EAAkCC,MAAlC,EAA2C;AAC1C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,aAAL;AACC,aAAOD,MAAM,CAACK,OAAd;AAFF;;AAKA,SAAON,KAAP;AACA;;AAED,MAAMc,OAAO,GAAGhB,eAAe,CAAE;AAChCC,EAAAA,QADgC;AAEhCY,EAAAA,cAFgC;AAGhCE,EAAAA,MAHgC;AAIhCP,EAAAA;AAJgC,CAAF,CAA/B;AAOA,eAAeQ,OAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the registered commands\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commands( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tlabel: action.label,\n\t\t\t\t\tsearchLabel: action.searchLabel,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command loaders\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commandLoaders( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND_LOADER':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\thook: action.hook,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND_LOADER': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette open state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction isOpen( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN':\n\t\t\treturn true;\n\t\tcase 'CLOSE':\n\t\t\treturn false;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette's active context.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction context( state = 'root', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CONTEXT':\n\t\t\treturn action.context;\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n} );\n\nexport default reducer;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/commands",
3
- "version": "0.6.4",
3
+ "version": "0.8.0",
4
4
  "description": "Handles the commands menu.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,13 +27,13 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/components": "^25.1.4",
31
- "@wordpress/data": "^9.5.2",
32
- "@wordpress/element": "^5.12.1",
33
- "@wordpress/i18n": "^4.35.1",
34
- "@wordpress/icons": "^9.26.2",
35
- "@wordpress/keyboard-shortcuts": "^4.12.2",
36
- "@wordpress/private-apis": "^0.17.1",
30
+ "@wordpress/components": "^25.3.0",
31
+ "@wordpress/data": "^9.7.0",
32
+ "@wordpress/element": "^5.14.0",
33
+ "@wordpress/i18n": "^4.37.0",
34
+ "@wordpress/icons": "^9.28.0",
35
+ "@wordpress/keyboard-shortcuts": "^4.14.0",
36
+ "@wordpress/private-apis": "^0.19.0",
37
37
  "cmdk": "^0.2.0",
38
38
  "rememo": "^4.0.2"
39
39
  },
@@ -43,5 +43,5 @@
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "gitHead": "65fb4cd5187a47ca274c24c04a220bcdb2ddfa67"
46
+ "gitHead": "bcd13d59b22553b3c9dc5869077bff1e864cf9f5"
47
47
  }
@@ -155,7 +155,7 @@ export function CommandMenu() {
155
155
  registerShortcut( {
156
156
  name: 'core/commands',
157
157
  category: 'global',
158
- description: __( 'Open the global command menu' ),
158
+ description: __( 'Open the command palette' ),
159
159
  keyCombination: {
160
160
  modifier: 'primary',
161
161
  character: 'k',
@@ -192,7 +192,7 @@ export function CommandMenu() {
192
192
  };
193
193
 
194
194
  useEffect( () => {
195
- // Focus the command menu input when mounting the modal.
195
+ // Focus the command palette input when mounting the modal.
196
196
  if ( isOpen ) {
197
197
  commandMenuInput.current.focus();
198
198
  }
@@ -211,7 +211,7 @@ export function CommandMenu() {
211
211
  __experimentalHideHeader
212
212
  >
213
213
  <div className="commands-command-menu__container">
214
- <Command label={ __( 'Global Command Menu' ) }>
214
+ <Command label={ __( 'Command palette' ) }>
215
215
  <div className="commands-command-menu__header">
216
216
  <Command.Input
217
217
  ref={ commandMenuInput }
@@ -11,7 +11,7 @@ import { store as commandsStore } from '../store';
11
11
  import { unlock } from '../lock-unlock';
12
12
 
13
13
  /**
14
- * Sets the active context of the command center
14
+ * Sets the active context of the command palette
15
15
  *
16
16
  * @param {string} context Context to set.
17
17
  */
@@ -10,7 +10,7 @@ import { useDispatch } from '@wordpress/data';
10
10
  import { store as commandsStore } from '../store';
11
11
 
12
12
  /**
13
- * Attach a command loader to the Global command menu.
13
+ * Attach a command loader to the command palette.
14
14
  *
15
15
  * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.
16
16
  */
@@ -10,7 +10,7 @@ import { useDispatch } from '@wordpress/data';
10
10
  import { store as commandsStore } from '../store';
11
11
 
12
12
  /**
13
- * Attach a command to the Global command menu.
13
+ * Attach a command to the command palette.
14
14
  *
15
15
  * @param {import('../store/actions').WPCommandConfig} command command config.
16
16
  */
@@ -84,7 +84,7 @@ export function unregisterCommandLoader( name ) {
84
84
  }
85
85
 
86
86
  /**
87
- * Opens the command center.
87
+ * Opens the command palette.
88
88
  *
89
89
  * @return {Object} action.
90
90
  */
@@ -95,7 +95,7 @@ export function open() {
95
95
  }
96
96
 
97
97
  /**
98
- * Closes the command center.
98
+ * Closes the command palette.
99
99
  *
100
100
  * @return {Object} action.
101
101
  */
@@ -63,7 +63,7 @@ function commandLoaders( state = {}, action ) {
63
63
  }
64
64
 
65
65
  /**
66
- * Reducer returning the command center open state.
66
+ * Reducer returning the command palette open state.
67
67
  *
68
68
  * @param {Object} state Current state.
69
69
  * @param {Object} action Dispatched action.
@@ -82,7 +82,7 @@ function isOpen( state = false, action ) {
82
82
  }
83
83
 
84
84
  /**
85
- * Reducer returning the command center's active context.
85
+ * Reducer returning the command palette's active context.
86
86
  *
87
87
  * @param {Object} state Current state.
88
88
  * @param {Object} action Dispatched action.