@wordpress/commands 1.52.0 → 1.53.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 (34) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/command-menu.cjs +2 -2
  3. package/build/components/command-menu.cjs.map +3 -3
  4. package/build/components/use-recent-commands.cjs.map +2 -2
  5. package/build/hooks/use-command-context.cjs.map +2 -2
  6. package/build/hooks/use-command-loader.cjs.map +2 -2
  7. package/build/hooks/use-command.cjs.map +2 -2
  8. package/build/lock-unlock.cjs.map +2 -2
  9. package/build/private-apis.cjs.map +2 -2
  10. package/build/store/index.cjs.map +2 -2
  11. package/build/store/reducer.cjs.map +2 -2
  12. package/build/store/selectors.cjs.map +2 -2
  13. package/build-module/components/command-menu.mjs +2 -3
  14. package/build-module/components/command-menu.mjs.map +2 -2
  15. package/build-module/components/use-recent-commands.mjs.map +2 -2
  16. package/build-module/hooks/use-command-context.mjs.map +2 -2
  17. package/build-module/hooks/use-command-loader.mjs.map +2 -2
  18. package/build-module/hooks/use-command.mjs.map +2 -2
  19. package/build-module/lock-unlock.mjs.map +2 -2
  20. package/build-module/private-apis.mjs.map +2 -2
  21. package/build-module/store/index.mjs.map +2 -2
  22. package/build-module/store/reducer.mjs.map +2 -2
  23. package/build-module/store/selectors.mjs.map +2 -2
  24. package/package.json +13 -12
  25. package/src/components/command-menu.js +1 -14
  26. package/src/components/use-recent-commands.js +0 -7
  27. package/src/hooks/use-command-context.js +0 -7
  28. package/src/hooks/use-command-loader.js +0 -7
  29. package/src/hooks/use-command.js +0 -7
  30. package/src/lock-unlock.js +0 -3
  31. package/src/private-apis.js +0 -3
  32. package/src/store/index.js +0 -7
  33. package/src/store/reducer.js +0 -3
  34. package/src/store/selectors.js +0 -3
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.53.0 (2026-08-12)
6
+
7
+ ### Internal
8
+
9
+ - Import `withIgnoreIMEEvents` from `@wordpress/keycodes` instead of unlocking it from `@wordpress/components`. Adds a `@wordpress/keycodes` dependency ([#81343](https://github.com/WordPress/gutenberg/pull/81343)).
10
+
5
11
  ## 1.52.0 (2026-07-29)
6
12
 
7
13
  ### Internal
@@ -40,12 +40,12 @@ var import_element = require("@wordpress/element");
40
40
  var import_i18n = require("@wordpress/i18n");
41
41
  var import_components = require("@wordpress/components");
42
42
  var import_keyboard_shortcuts = require("@wordpress/keyboard-shortcuts");
43
+ var import_keycodes = require("@wordpress/keycodes");
43
44
  var import_icons = require("@wordpress/icons");
44
45
  var import_store = require("../store/index.cjs");
45
46
  var import_lock_unlock = require("../lock-unlock.cjs");
46
47
  var import_use_recent_commands = require("./use-recent-commands.cjs");
47
48
  var import_jsx_runtime = require("react/jsx-runtime");
48
- var { withIgnoreIMEEvents } = (0, import_lock_unlock.unlock)(import_components.privateApis);
49
49
  var ITEM_ID_PREFIX = "command-palette-item-";
50
50
  var inputLabel = (0, import_i18n.__)("Search commands and settings");
51
51
  var CATEGORY_ICONS = {
@@ -275,7 +275,7 @@ function CommandMenu() {
275
275
  (0, import_keyboard_shortcuts.useShortcut)(
276
276
  "core/commands",
277
277
  /** @type {React.KeyboardEventHandler} */
278
- withIgnoreIMEEvents((event) => {
278
+ (0, import_keycodes.withIgnoreIMEEvents)((event) => {
279
279
  if (event.defaultPrevented) {
280
280
  return;
281
281
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/components/command-menu.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { Command, useCommandState } from 'cmdk';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tisValidElement,\n\tComponent,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tModal,\n\tTextHighlight,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport {\n\tstore as keyboardShortcutsStore,\n\tuseShortcut,\n} from '@wordpress/keyboard-shortcuts';\nimport { Icon, search as inputIcon, arrowRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\nimport {\n\trecordUsage,\n\tuseLoaderCollector,\n\tuseRecentCommands,\n} from './use-recent-commands';\n\nconst { withIgnoreIMEEvents } = unlock( componentsPrivateApis );\n\n// Namespaces item ids to avoid collisions with other elements on the page.\nconst ITEM_ID_PREFIX = 'command-palette-item-';\nconst inputLabel = __( 'Search commands and settings' );\n\n/**\n * Icons enforced per command category.\n * Categories listed here will always use the specified icon,\n * ignoring whatever icon the command itself provides.\n */\nconst CATEGORY_ICONS = {\n\tview: arrowRight,\n};\n\n/**\n * Translatable labels for command categories.\n */\nconst CATEGORY_LABELS = {\n\tcommand: __( 'Command' ),\n\tview: __( 'View' ),\n\tedit: __( 'Edit' ),\n\taction: __( 'Action' ),\n\tworkflow: __( 'Workflow' ),\n};\n\n/**\n * Function that checks if the parameter is a valid icon.\n * Taken from @wordpress/blocks/src/api/utils.js and copied\n * in case requirements diverge and to avoid a dependency on @wordpress/blocks.\n *\n * @param {*} icon Parameter to be checked.\n *\n * @return {boolean} True if the parameter is a valid icon and false otherwise.\n */\n\nexport function isValidIcon( icon ) {\n\treturn (\n\t\t!! icon &&\n\t\t( typeof icon === 'string' ||\n\t\t\tisValidElement( icon ) ||\n\t\t\ttypeof icon === 'function' ||\n\t\t\ticon instanceof Component )\n\t);\n}\n\nfunction CommandItem( { command, search, category, valuePrefix } ) {\n\tconst { close } = useDispatch( commandsStore );\n\tconst commandCategory = category ?? command.category;\n\tconst label = command.searchLabel ?? command.label;\n\tconst value = valuePrefix ? `${ valuePrefix }${ command.name }` : label;\n\treturn (\n\t\t<Command.Item\n\t\t\tkey={ command.name }\n\t\t\tid={ `${ ITEM_ID_PREFIX }${ value.toLowerCase() }` }\n\t\t\tvalue={ value }\n\t\t\tkeywords={\n\t\t\t\tvaluePrefix\n\t\t\t\t\t? [ ...( command.keywords ?? [] ), label ]\n\t\t\t\t\t: command.keywords\n\t\t\t}\n\t\t\tonSelect={ () => {\n\t\t\t\trecordUsage( command.name );\n\t\t\t\tcommand.callback( { close } );\n\t\t\t} }\n\t\t>\n\t\t\t<HStack\n\t\t\t\talignment=\"left\"\n\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t'has-icon':\n\t\t\t\t\t\tCATEGORY_ICONS[ commandCategory ] || command.icon,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ CATEGORY_ICONS[ commandCategory ] ? (\n\t\t\t\t\t<Icon icon={ CATEGORY_ICONS[ commandCategory ] } />\n\t\t\t\t) : (\n\t\t\t\t\tisValidIcon( command.icon ) && (\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t)\n\t\t\t\t) }\n\t\t\t\t<span className=\"commands-command-menu__item-label\">\n\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t\t{ CATEGORY_LABELS[ commandCategory ] && (\n\t\t\t\t\t<span className=\"commands-command-menu__item-category\">\n\t\t\t\t\t\t{ CATEGORY_LABELS[ commandCategory ] }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</Command.Item>\n\t);\n}\n\nfunction CommandMenuLoader( { name, search, hook, category, valuePrefix } ) {\n\tconst { setLoaderLoading } = unlock( useDispatch( commandsStore ) );\n\tconst { isLoading: loading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoaderLoading( name, loading );\n\t}, [ setLoaderLoading, name, loading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tcategory={ command.category ?? category }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction CommandMenuLoaderWrapper( { hook, ...props } ) {\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\tconst currentLoaderRef = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoaderRef.current !== hook ) {\n\t\t\tcurrentLoaderRef.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={ currentLoaderRef.current }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction CommandList( { search, commands, loaders, valuePrefix } ) {\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\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\tname={ loader.name }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tcategory={ loader.category }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction RecentLoaderRunner( { hook, name, filterNames, onResolved } ) {\n\tuseLoaderCollector( hook, name, filterNames, onResolved );\n\treturn null;\n}\n\nfunction RecentGroup() {\n\tconst { commands, loaders, recentSet, onResolved } = useRecentCommands();\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Recent' ) }>\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<RecentLoaderRunner\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\tname={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tfilterNames={ recentSet }\n\t\t\t\t\tonResolved={ onResolved }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch=\"\"\n\t\t\t\t\tvaluePrefix=\"recent-\"\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nfunction SuggestionsGroup() {\n\tconst { commands, loaders } = useSelect( ( select ) => {\n\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\treturn {\n\t\t\tcommands: getCommands( true ),\n\t\t\tloaders: getCommandLoaders( true ),\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Suggestions' ) }>\n\t\t\t<CommandList search=\"\" commands={ commands } loaders={ loaders } />\n\t\t</Command.Group>\n\t);\n}\n\nfunction ResultsGroup( { search } ) {\n\tconst { commands, contextualCommands, loaders, contextualLoaders } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( false ),\n\t\t\t\tcontextualCommands: getCommands( true ),\n\t\t\t\tloaders: getCommandLoaders( false ),\n\t\t\t\tcontextualLoaders: getCommandLoaders( true ),\n\t\t\t};\n\t\t}, [] );\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Results' ) }>\n\t\t\t<CommandList\n\t\t\t\tsearch={ search }\n\t\t\t\tcommands={ commands }\n\t\t\t\tloaders={ loaders }\n\t\t\t/>\n\t\t\t<CommandList\n\t\t\t\tsearch={ search }\n\t\t\t\tcommands={ contextualCommands }\n\t\t\t\tloaders={ contextualLoaders }\n\t\t\t/>\n\t\t</Command.Group>\n\t);\n}\n\nfunction CommandInput( { search, setSearch } ) {\n\tconst commandMenuInput = useRef();\n\tconst _value = useCommandState( ( state ) => state.value );\n\tconst selectedItemId = _value ? `${ ITEM_ID_PREFIX }${ _value }` : null;\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tcommandMenuInput.current.focus();\n\t}, [] );\n\treturn (\n\t\t<Command.Input\n\t\t\tref={ commandMenuInput }\n\t\t\tvalue={ search }\n\t\t\tonValueChange={ setSearch }\n\t\t\tplaceholder={ inputLabel }\n\t\t\taria-activedescendant={ selectedItemId }\n\t\t/>\n\t);\n}\n\n/**\n * @ignore\n */\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst { isOpen: paletteIsOpen, loadersLoading } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisOpen: select( commandsStore ).isOpen(),\n\t\t\tloadersLoading: unlock( select( commandsStore ) ).isLoading(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\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/** @type {React.KeyboardEventHandler} */\n\t\twithIgnoreIMEEvents( ( event ) => {\n\t\t\t// Bails to avoid obscuring the effect of the preceding handler(s).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tif ( paletteIsOpen ) {\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 closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tif ( ! paletteIsOpen ) {\n\t\treturn false;\n\t}\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\tsize=\"medium\"\n\t\t\tcontentLabel={ __( 'Command palette' ) }\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ inputLabel } loop>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__header-search-icon\"\n\t\t\t\t\t\t\ticon={ inputIcon }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<CommandInput\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetSearch={ setSearch }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List label={ __( 'Command suggestions' ) }>\n\t\t\t\t\t\t{ search && ! loadersLoading && (\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{ ! search && <RecentGroup /> }\n\t\t\t\t\t\t{ ! search && <SuggestionsGroup /> }\n\t\t\t\t\t\t{ search && <ResultsGroup search={ search } /> }\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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;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gB;AACtB,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,kBAAiB;AAAA,MACjB,gBAAiB;AAAA,MACjB,0BAAwB;AAAA,MACxB,MAAK;AAAA,MACL,kBAAe,gBAAI,iBAAkB;AAAA,MAErC,sDAAC,SAAI,WAAU,oCACd,uDAAC,uBAAQ,OAAQ,YAAa,MAAI,MACjC;AAAA,qDAAC,SAAI,WAAU,iCACd;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,MAAO,aAAAI;AAAA;AAAA,UACR;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,WACD;AAAA,QACA,6CAAC,oBAAQ,MAAR,EAAa,WAAQ,gBAAI,qBAAsB,GAC7C;AAAA,oBAAU,CAAE,kBACb,4CAAC,oBAAQ,OAAR,EACE,8BAAI,mBAAoB,GAC3B;AAAA,UAEC,CAAE,UAAU,4CAAC,eAAY;AAAA,UACzB,CAAE,UAAU,4CAAC,oBAAiB;AAAA,UAC9B,UAAU,4CAAC,gBAAa,QAAkB;AAAA,WAC7C;AAAA,SACD,GACD;AAAA;AAAA,EACD;AAEF;",
6
- "names": ["componentsPrivateApis", "commandsStore", "HStack", "clsx", "keyboardShortcutsStore", "inputIcon"]
4
+ "sourcesContent": ["import { Command, useCommandState } from 'cmdk';\nimport clsx from 'clsx';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tisValidElement,\n\tComponent,\n} 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 { withIgnoreIMEEvents } from '@wordpress/keycodes';\nimport { Icon, search as inputIcon, arrowRight } from '@wordpress/icons';\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\nimport {\n\trecordUsage,\n\tuseLoaderCollector,\n\tuseRecentCommands,\n} from './use-recent-commands';\n\n// Namespaces item ids to avoid collisions with other elements on the page.\nconst ITEM_ID_PREFIX = 'command-palette-item-';\nconst inputLabel = __( 'Search commands and settings' );\n\n/**\n * Icons enforced per command category.\n * Categories listed here will always use the specified icon,\n * ignoring whatever icon the command itself provides.\n */\nconst CATEGORY_ICONS = {\n\tview: arrowRight,\n};\n\n/**\n * Translatable labels for command categories.\n */\nconst CATEGORY_LABELS = {\n\tcommand: __( 'Command' ),\n\tview: __( 'View' ),\n\tedit: __( 'Edit' ),\n\taction: __( 'Action' ),\n\tworkflow: __( 'Workflow' ),\n};\n\n/**\n * Function that checks if the parameter is a valid icon.\n * Taken from @wordpress/blocks/src/api/utils.js and copied\n * in case requirements diverge and to avoid a dependency on @wordpress/blocks.\n *\n * @param {*} icon Parameter to be checked.\n *\n * @return {boolean} True if the parameter is a valid icon and false otherwise.\n */\n\nexport function isValidIcon( icon ) {\n\treturn (\n\t\t!! icon &&\n\t\t( typeof icon === 'string' ||\n\t\t\tisValidElement( icon ) ||\n\t\t\ttypeof icon === 'function' ||\n\t\t\ticon instanceof Component )\n\t);\n}\n\nfunction CommandItem( { command, search, category, valuePrefix } ) {\n\tconst { close } = useDispatch( commandsStore );\n\tconst commandCategory = category ?? command.category;\n\tconst label = command.searchLabel ?? command.label;\n\tconst value = valuePrefix ? `${ valuePrefix }${ command.name }` : label;\n\treturn (\n\t\t<Command.Item\n\t\t\tkey={ command.name }\n\t\t\tid={ `${ ITEM_ID_PREFIX }${ value.toLowerCase() }` }\n\t\t\tvalue={ value }\n\t\t\tkeywords={\n\t\t\t\tvaluePrefix\n\t\t\t\t\t? [ ...( command.keywords ?? [] ), label ]\n\t\t\t\t\t: command.keywords\n\t\t\t}\n\t\t\tonSelect={ () => {\n\t\t\t\trecordUsage( command.name );\n\t\t\t\tcommand.callback( { close } );\n\t\t\t} }\n\t\t>\n\t\t\t<HStack\n\t\t\t\talignment=\"left\"\n\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t'has-icon':\n\t\t\t\t\t\tCATEGORY_ICONS[ commandCategory ] || command.icon,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ CATEGORY_ICONS[ commandCategory ] ? (\n\t\t\t\t\t<Icon icon={ CATEGORY_ICONS[ commandCategory ] } />\n\t\t\t\t) : (\n\t\t\t\t\tisValidIcon( command.icon ) && (\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t)\n\t\t\t\t) }\n\t\t\t\t<span className=\"commands-command-menu__item-label\">\n\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t\t{ CATEGORY_LABELS[ commandCategory ] && (\n\t\t\t\t\t<span className=\"commands-command-menu__item-category\">\n\t\t\t\t\t\t{ CATEGORY_LABELS[ commandCategory ] }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</Command.Item>\n\t);\n}\n\nfunction CommandMenuLoader( { name, search, hook, category, valuePrefix } ) {\n\tconst { setLoaderLoading } = unlock( useDispatch( commandsStore ) );\n\tconst { isLoading: loading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoaderLoading( name, loading );\n\t}, [ setLoaderLoading, name, loading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tcategory={ command.category ?? category }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction CommandMenuLoaderWrapper( { hook, ...props } ) {\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\tconst currentLoaderRef = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoaderRef.current !== hook ) {\n\t\t\tcurrentLoaderRef.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={ currentLoaderRef.current }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction CommandList( { search, commands, loaders, valuePrefix } ) {\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\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\tname={ loader.name }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tcategory={ loader.category }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction RecentLoaderRunner( { hook, name, filterNames, onResolved } ) {\n\tuseLoaderCollector( hook, name, filterNames, onResolved );\n\treturn null;\n}\n\nfunction RecentGroup() {\n\tconst { commands, loaders, recentSet, onResolved } = useRecentCommands();\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Recent' ) }>\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<RecentLoaderRunner\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\tname={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tfilterNames={ recentSet }\n\t\t\t\t\tonResolved={ onResolved }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch=\"\"\n\t\t\t\t\tvaluePrefix=\"recent-\"\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nfunction SuggestionsGroup() {\n\tconst { commands, loaders } = useSelect( ( select ) => {\n\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\treturn {\n\t\t\tcommands: getCommands( true ),\n\t\t\tloaders: getCommandLoaders( true ),\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Suggestions' ) }>\n\t\t\t<CommandList search=\"\" commands={ commands } loaders={ loaders } />\n\t\t</Command.Group>\n\t);\n}\n\nfunction ResultsGroup( { search } ) {\n\tconst { commands, contextualCommands, loaders, contextualLoaders } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( false ),\n\t\t\t\tcontextualCommands: getCommands( true ),\n\t\t\t\tloaders: getCommandLoaders( false ),\n\t\t\t\tcontextualLoaders: getCommandLoaders( true ),\n\t\t\t};\n\t\t}, [] );\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Results' ) }>\n\t\t\t<CommandList\n\t\t\t\tsearch={ search }\n\t\t\t\tcommands={ commands }\n\t\t\t\tloaders={ loaders }\n\t\t\t/>\n\t\t\t<CommandList\n\t\t\t\tsearch={ search }\n\t\t\t\tcommands={ contextualCommands }\n\t\t\t\tloaders={ contextualLoaders }\n\t\t\t/>\n\t\t</Command.Group>\n\t);\n}\n\nfunction CommandInput( { search, setSearch } ) {\n\tconst commandMenuInput = useRef();\n\tconst _value = useCommandState( ( state ) => state.value );\n\tconst selectedItemId = _value ? `${ ITEM_ID_PREFIX }${ _value }` : null;\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tcommandMenuInput.current.focus();\n\t}, [] );\n\treturn (\n\t\t<Command.Input\n\t\t\tref={ commandMenuInput }\n\t\t\tvalue={ search }\n\t\t\tonValueChange={ setSearch }\n\t\t\tplaceholder={ inputLabel }\n\t\t\taria-activedescendant={ selectedItemId }\n\t\t/>\n\t);\n}\n\n/**\n * @ignore\n */\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst { isOpen: paletteIsOpen, loadersLoading } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisOpen: select( commandsStore ).isOpen(),\n\t\t\tloadersLoading: unlock( select( commandsStore ) ).isLoading(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\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/** @type {React.KeyboardEventHandler} */\n\t\twithIgnoreIMEEvents( ( event ) => {\n\t\t\t// Bails to avoid obscuring the effect of the preceding handler(s).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tif ( paletteIsOpen ) {\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 closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tif ( ! paletteIsOpen ) {\n\t\treturn false;\n\t}\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\tsize=\"medium\"\n\t\t\tcontentLabel={ __( 'Command palette' ) }\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ inputLabel } loop>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__header-search-icon\"\n\t\t\t\t\t\t\ticon={ inputIcon }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<CommandInput\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetSearch={ setSearch }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List label={ __( 'Command suggestions' ) }>\n\t\t\t\t\t\t{ search && ! loadersLoading && (\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{ ! search && <RecentGroup /> }\n\t\t\t\t\t\t{ ! search && <SuggestionsGroup /> }\n\t\t\t\t\t\t{ search && <ResultsGroup search={ search } /> }\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyC;AACzC,kBAAiB;AACjB,kBAAuC;AACvC,qBAMO;AACP,kBAAmB;AACnB,wBAIO;AACP,gCAGO;AACP,sBAAoC;AACpC,mBAAsD;AACtD,mBAAuC;AACvC,yBAAuB;AACvB,iCAIO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C;AAAA,qDAAC,SAAI,WAAU,iCACd;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,MAAO,aAAAI;AAAA;AAAA,UACR;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,WACD;AAAA,QACA,6CAAC,oBAAQ,MAAR,EAAa,WAAQ,gBAAI,qBAAsB,GAC7C;AAAA,oBAAU,CAAE,kBACb,4CAAC,oBAAQ,OAAR,EACE,8BAAI,mBAAoB,GAC3B;AAAA,UAEC,CAAE,UAAU,4CAAC,eAAY;AAAA,UACzB,CAAE,UAAU,4CAAC,oBAAiB;AAAA,UAC9B,UAAU,4CAAC,gBAAa,QAAkB;AAAA,WAC7C;AAAA,SACD,GACD;AAAA;AAAA,EACD;AAEF;",
6
+ "names": ["commandsStore", "HStack", "clsx", "keyboardShortcutsStore", "inputIcon"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/components/use-recent-commands.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tselect as globalSelect,\n\tdispatch,\n} from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useCallback, useEffect, useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst MAX_RECENTLY_SAVED = 30;\nconst MAX_RECENTLY_DISPLAYED = 5;\nconst EMPTY_ARRAY = [];\nconst EMPTY_SET = new Set();\n\nexport function recordUsage( name ) {\n\tconst current =\n\t\tglobalSelect( preferencesStore ).get(\n\t\t\t'core/commands',\n\t\t\t'recentlyUsed'\n\t\t) ?? [];\n\tconst next = [ name, ...current.filter( ( n ) => n !== name ) ].slice(\n\t\t0,\n\t\tMAX_RECENTLY_SAVED\n\t);\n\tdispatch( preferencesStore ).set( 'core/commands', 'recentlyUsed', next );\n}\n\nexport function useLoaderCollector( hook, name, filterNames, onResolved ) {\n\tconst { setLoaderLoading } = unlock( useDispatch( commandsStore ) );\n\tconst { isLoading: loading, commands = [] } = hook( { search: '' } ) ?? {};\n\n\tuseEffect( () => {\n\t\tsetLoaderLoading( name, loading );\n\t}, [ setLoaderLoading, name, loading ] );\n\n\tconst filtered = filterNames\n\t\t? commands.filter( ( c ) => filterNames.has( c.name ) )\n\t\t: commands;\n\n\tuseEffect( () => {\n\t\tonResolved( name, filtered );\n\t}, [ onResolved, name, filtered ] );\n\n\t// Clear this loader's entries when it unmounts.\n\tuseEffect( () => {\n\t\treturn () => onResolved( name, [] );\n\t}, [ onResolved, name ] );\n}\n\nexport function useRecentCommands() {\n\tconst {\n\t\tcontextualCommands,\n\t\tstaticCommands,\n\t\tcontextualLoaders,\n\t\tstaticLoaders,\n\t\trecentlyUsedNames = EMPTY_ARRAY,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\treturn {\n\t\t\tcontextualCommands: getCommands( true ),\n\t\t\tstaticCommands: getCommands( false ),\n\t\t\tcontextualLoaders: getCommandLoaders( true ),\n\t\t\tstaticLoaders: getCommandLoaders( false ),\n\t\t\trecentlyUsedNames: select( preferencesStore ).get(\n\t\t\t\t'core/commands',\n\t\t\t\t'recentlyUsed'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst [ resolvedMap, setResolvedMap ] = useState( () => new Map() );\n\n\tconst onResolved = useCallback( ( loaderName, cmds ) => {\n\t\tsetResolvedMap( ( prev ) => {\n\t\t\tconst prevCmds = prev.get( loaderName );\n\t\t\tif (\n\t\t\t\tprevCmds &&\n\t\t\t\tprevCmds.length === cmds.length &&\n\t\t\t\tprevCmds.every( ( c, i ) => c.name === cmds[ i ].name )\n\t\t\t) {\n\t\t\t\treturn prev;\n\t\t\t}\n\t\t\tconst next = new Map( prev );\n\t\t\tnext.set( loaderName, cmds );\n\t\t\treturn next;\n\t\t} );\n\t}, [] );\n\n\tconst { recentNames, recentSet } = useMemo( () => {\n\t\tconst names = recentlyUsedNames.slice( 0, MAX_RECENTLY_DISPLAYED );\n\t\treturn { recentNames: names, recentSet: new Set( names ) };\n\t}, [ recentlyUsedNames ] );\n\n\tif ( ! recentlyUsedNames.length ) {\n\t\treturn {\n\t\t\tcommands: [],\n\t\t\tloaders: [],\n\t\t\trecentSet: EMPTY_SET,\n\t\t\tonResolved,\n\t\t};\n\t}\n\n\tconst allStaticCommands = [ ...contextualCommands, ...staticCommands ];\n\tconst loaders = [ ...contextualLoaders, ...staticLoaders ];\n\n\t// Merge static commands with loader-resolved commands.\n\tconst allByName = new Map();\n\tallStaticCommands.forEach( ( c ) => allByName.set( c.name, c ) );\n\tfor ( const cmds of resolvedMap.values() ) {\n\t\tcmds.forEach( ( c ) => {\n\t\t\tif ( ! allByName.has( c.name ) ) {\n\t\t\t\tallByName.set( c.name, c );\n\t\t\t}\n\t\t} );\n\t}\n\t// Return in recency order.\n\tconst commands = recentNames\n\t\t.map( ( n ) => allByName.get( n ) )\n\t\t.filter( Boolean );\n\n\treturn { commands, loaders, recentSet, onResolved };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAKO;AACP,yBAA0C;AAC1C,qBAA0D;AAK1D,mBAAuC;AACvC,yBAAuB;AAEvB,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAC/B,IAAM,cAAc,CAAC;AACrB,IAAM,YAAY,oBAAI,IAAI;AAEnB,SAAS,YAAa,MAAO;AACnC,QAAM,cACL,YAAAA,QAAc,mBAAAC,KAAiB,EAAE;AAAA,IAChC;AAAA,IACA;AAAA,EACD,KAAK,CAAC;AACP,QAAM,OAAO,CAAE,MAAM,GAAG,QAAQ,OAAQ,CAAE,MAAO,MAAM,IAAK,CAAE,EAAE;AAAA,IAC/D;AAAA,IACA;AAAA,EACD;AACA,4BAAU,mBAAA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,\n\tselect as globalSelect,\n\tdispatch,\n} from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useCallback, useEffect, useMemo, useState } from '@wordpress/element';\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst MAX_RECENTLY_SAVED = 30;\nconst MAX_RECENTLY_DISPLAYED = 5;\nconst EMPTY_ARRAY = [];\nconst EMPTY_SET = new Set();\n\nexport function recordUsage( name ) {\n\tconst current =\n\t\tglobalSelect( preferencesStore ).get(\n\t\t\t'core/commands',\n\t\t\t'recentlyUsed'\n\t\t) ?? [];\n\tconst next = [ name, ...current.filter( ( n ) => n !== name ) ].slice(\n\t\t0,\n\t\tMAX_RECENTLY_SAVED\n\t);\n\tdispatch( preferencesStore ).set( 'core/commands', 'recentlyUsed', next );\n}\n\nexport function useLoaderCollector( hook, name, filterNames, onResolved ) {\n\tconst { setLoaderLoading } = unlock( useDispatch( commandsStore ) );\n\tconst { isLoading: loading, commands = [] } = hook( { search: '' } ) ?? {};\n\n\tuseEffect( () => {\n\t\tsetLoaderLoading( name, loading );\n\t}, [ setLoaderLoading, name, loading ] );\n\n\tconst filtered = filterNames\n\t\t? commands.filter( ( c ) => filterNames.has( c.name ) )\n\t\t: commands;\n\n\tuseEffect( () => {\n\t\tonResolved( name, filtered );\n\t}, [ onResolved, name, filtered ] );\n\n\t// Clear this loader's entries when it unmounts.\n\tuseEffect( () => {\n\t\treturn () => onResolved( name, [] );\n\t}, [ onResolved, name ] );\n}\n\nexport function useRecentCommands() {\n\tconst {\n\t\tcontextualCommands,\n\t\tstaticCommands,\n\t\tcontextualLoaders,\n\t\tstaticLoaders,\n\t\trecentlyUsedNames = EMPTY_ARRAY,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\treturn {\n\t\t\tcontextualCommands: getCommands( true ),\n\t\t\tstaticCommands: getCommands( false ),\n\t\t\tcontextualLoaders: getCommandLoaders( true ),\n\t\t\tstaticLoaders: getCommandLoaders( false ),\n\t\t\trecentlyUsedNames: select( preferencesStore ).get(\n\t\t\t\t'core/commands',\n\t\t\t\t'recentlyUsed'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst [ resolvedMap, setResolvedMap ] = useState( () => new Map() );\n\n\tconst onResolved = useCallback( ( loaderName, cmds ) => {\n\t\tsetResolvedMap( ( prev ) => {\n\t\t\tconst prevCmds = prev.get( loaderName );\n\t\t\tif (\n\t\t\t\tprevCmds &&\n\t\t\t\tprevCmds.length === cmds.length &&\n\t\t\t\tprevCmds.every( ( c, i ) => c.name === cmds[ i ].name )\n\t\t\t) {\n\t\t\t\treturn prev;\n\t\t\t}\n\t\t\tconst next = new Map( prev );\n\t\t\tnext.set( loaderName, cmds );\n\t\t\treturn next;\n\t\t} );\n\t}, [] );\n\n\tconst { recentNames, recentSet } = useMemo( () => {\n\t\tconst names = recentlyUsedNames.slice( 0, MAX_RECENTLY_DISPLAYED );\n\t\treturn { recentNames: names, recentSet: new Set( names ) };\n\t}, [ recentlyUsedNames ] );\n\n\tif ( ! recentlyUsedNames.length ) {\n\t\treturn {\n\t\t\tcommands: [],\n\t\t\tloaders: [],\n\t\t\trecentSet: EMPTY_SET,\n\t\t\tonResolved,\n\t\t};\n\t}\n\n\tconst allStaticCommands = [ ...contextualCommands, ...staticCommands ];\n\tconst loaders = [ ...contextualLoaders, ...staticLoaders ];\n\n\t// Merge static commands with loader-resolved commands.\n\tconst allByName = new Map();\n\tallStaticCommands.forEach( ( c ) => allByName.set( c.name, c ) );\n\tfor ( const cmds of resolvedMap.values() ) {\n\t\tcmds.forEach( ( c ) => {\n\t\t\tif ( ! allByName.has( c.name ) ) {\n\t\t\t\tallByName.set( c.name, c );\n\t\t\t}\n\t\t} );\n\t}\n\t// Return in recency order.\n\tconst commands = recentNames\n\t\t.map( ( n ) => allByName.get( n ) )\n\t\t.filter( Boolean );\n\n\treturn { commands, loaders, recentSet, onResolved };\n}\n"],
5
+ "mappings": ";;;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AmB,GAAG,aAAc;AAGzD,QAAM,YAAY,oBAAI,IAAI;AAC1B,oBAAkB,QAAS,CAAE,MAAO,UAAU,IAAK,EAAE,MAAM,CAAE,CAAE;AAC/D,aAAY,QAAQ,YAAY,OAAO,GAAI;AAC1C,SAAK,QAAS,CAAE,MAAO;AACtB,UAAK,CAAE,UAAU,IAAK,EAAE,IAAK,GAAI;AAChC,kBAAU,IAAK,EAAE,MAAM,CAAE;AAAA,MAC1B;AAAA,IACD,CAAE;AAAA,EACH;AAEA,QAAM,WAAW,YACf,IAAK,CAAE,MAAO,UAAU,IAAK,CAAE,CAAE,EACjC,OAAQ,OAAQ;AAElB,SAAO,EAAE,UAAU,SAAS,WAAW,WAAW;AACnD;",
6
6
  "names": ["globalSelect", "preferencesStore", "commandsStore"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/use-command-context.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Sets the active context of the command palette\n *\n * @param {string} context Context to set.\n */\nexport default function useCommandContext( context ) {\n\tconst { getContext } = useSelect( commandsStore );\n\tconst initialContext = useRef( getContext() );\n\tconst { setContext } = unlock( useDispatch( commandsStore ) );\n\n\tuseEffect( () => {\n\t\tsetContext( context );\n\t}, [ context, setContext ] );\n\n\t// This effects ensures that on unmount, we restore the context\n\t// that was set before the component actually mounts.\n\tuseEffect( () => {\n\t\tconst initialContextRef = initialContext.current;\n\t\treturn () => setContext( initialContextRef );\n\t}, [ setContext ] );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAkC;AAClC,kBAAuC;AAKvC,mBAAuC;AACvC,yBAAuB;AAOR,SAAR,kBAAoC,SAAU;AACpD,QAAM,EAAE,WAAW,QAAI,uBAAW,aAAAA,KAAc;AAChD,QAAM,qBAAiB,uBAAQ,WAAW,CAAE;AAC5C,QAAM,EAAE,WAAW,QAAI,+BAAQ,yBAAa,aAAAA,KAAc,CAAE;AAE5D,gCAAW,MAAM;AAChB,eAAY,OAAQ;AAAA,EACrB,GAAG,CAAE,SAAS,UAAW,CAAE;AAI3B,gCAAW,MAAM;AAChB,UAAM,oBAAoB,eAAe;AACzC,WAAO,MAAM,WAAY,iBAAkB;AAAA,EAC5C,GAAG,CAAE,UAAW,CAAE;AACnB;",
4
+ "sourcesContent": ["import { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Sets the active context of the command palette\n *\n * @param {string} context Context to set.\n */\nexport default function useCommandContext( context ) {\n\tconst { getContext } = useSelect( commandsStore );\n\tconst initialContext = useRef( getContext() );\n\tconst { setContext } = unlock( useDispatch( commandsStore ) );\n\n\tuseEffect( () => {\n\t\tsetContext( context );\n\t}, [ context, setContext ] );\n\n\t// This effects ensures that on unmount, we restore the context\n\t// that was set before the component actually mounts.\n\tuseEffect( () => {\n\t\tconst initialContextRef = initialContext.current;\n\t\treturn () => setContext( initialContextRef );\n\t}, [ setContext ] );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAkC;AAClC,kBAAuC;AACvC,mBAAuC;AACvC,yBAAuB;AAOR,SAAR,kBAAoC,SAAU;AACpD,QAAM,EAAE,WAAW,QAAI,uBAAW,aAAAA,KAAc;AAChD,QAAM,qBAAiB,uBAAQ,WAAW,CAAE;AAC5C,QAAM,EAAE,WAAW,QAAI,+BAAQ,yBAAa,aAAAA,KAAc,CAAE;AAE5D,gCAAW,MAAM;AAChB,eAAY,OAAQ;AAAA,EACrB,GAAG,CAAE,SAAS,UAAW,CAAE;AAI3B,gCAAW,MAAM;AAChB,UAAM,oBAAoB,eAAe;AACzC,WAAO,MAAM,WAAY,iBAAkB;AAAA,EAC5C,GAAG,CAAE,UAAW,CAAE;AACnB;",
6
6
  "names": ["commandsStore"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/use-command-loader.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette. Used for dynamic commands.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { addQueryArgs } from '@wordpress/url';\n * import { useCommandLoader } from '@wordpress/commands';\n * import { page } from '@wordpress/icons';\n * import { useSelect } from '@wordpress/data';\n * import { store as coreStore } from '@wordpress/core-data';\n * import { useMemo } from '@wordpress/element';\n *\n * function usePageSearchCommandLoader( { search } ) {\n * // Retrieve the pages for the \"search\" term.\n * const { records, isLoading } = useSelect(\n * ( select ) => {\n * const { getEntityRecords } = select( coreStore );\n * const query = {\n * search: !! search ? search : undefined,\n * per_page: 10,\n * orderby: search ? 'relevance' : 'date',\n * };\n * return {\n * records: getEntityRecords( 'postType', 'page', query ),\n * isLoading: ! select( coreStore ).hasFinishedResolution(\n * 'getEntityRecords',\n * [ 'postType', 'page', query ]\n * ),\n * };\n * },\n * [ search ]\n * );\n *\n * // Create the commands.\n * const commands = useMemo( () => {\n * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n * return {\n * name: record.title?.rendered + ' ' + record.id,\n * label: record.title?.rendered\n * ? record.title?.rendered\n * : __( '(no title)' ),\n * icon: page,\n * category: 'edit',\n * callback: ( { close } ) => {\n * const args = {\n * \t\t\t\t\t\t\tp: '/page',\n * \t\t\t\t\t\t\tpostId: record.id,\n * };\n * document.location = addQueryArgs( 'site-editor.php', args );\n * close();\n * },\n * };\n * } );\n * }, [ records ] );\n *\n * return {\n * commands,\n * isLoading,\n * };\n * }\n *\n * useCommandLoader( {\n * name: 'myplugin/page-search',\n * hook: usePageSearchCommandLoader,\n * } );\n * ```\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tif ( loader.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t\tcategory: loader.category,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tloader.category,\n\t\tloader.disabled,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0B;AAC1B,kBAA4B;AAK5B,mBAAuC;AAwExB,SAAR,iBAAmC,QAAS;AAClD,QAAM,EAAE,uBAAuB,wBAAwB,QACtD,yBAAa,aAAAA,KAAc;AAC5B,gCAAW,MAAM;AAChB,QAAK,OAAO,UAAW;AACtB;AAAA,IACD;AACA,0BAAuB;AAAA,MACtB,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,IAClB,CAAE;AACF,WAAO,MAAM;AACZ,8BAAyB,OAAO,IAAK;AAAA,IACtC;AAAA,EACD,GAAG;AAAA,IACF,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
4
+ "sourcesContent": ["import { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette. Used for dynamic commands.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { addQueryArgs } from '@wordpress/url';\n * import { useCommandLoader } from '@wordpress/commands';\n * import { page } from '@wordpress/icons';\n * import { useSelect } from '@wordpress/data';\n * import { store as coreStore } from '@wordpress/core-data';\n * import { useMemo } from '@wordpress/element';\n *\n * function usePageSearchCommandLoader( { search } ) {\n * // Retrieve the pages for the \"search\" term.\n * const { records, isLoading } = useSelect(\n * ( select ) => {\n * const { getEntityRecords } = select( coreStore );\n * const query = {\n * search: !! search ? search : undefined,\n * per_page: 10,\n * orderby: search ? 'relevance' : 'date',\n * };\n * return {\n * records: getEntityRecords( 'postType', 'page', query ),\n * isLoading: ! select( coreStore ).hasFinishedResolution(\n * 'getEntityRecords',\n * [ 'postType', 'page', query ]\n * ),\n * };\n * },\n * [ search ]\n * );\n *\n * // Create the commands.\n * const commands = useMemo( () => {\n * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n * return {\n * name: record.title?.rendered + ' ' + record.id,\n * label: record.title?.rendered\n * ? record.title?.rendered\n * : __( '(no title)' ),\n * icon: page,\n * category: 'edit',\n * callback: ( { close } ) => {\n * const args = {\n * \t\t\t\t\t\t\tp: '/page',\n * \t\t\t\t\t\t\tpostId: record.id,\n * };\n * document.location = addQueryArgs( 'site-editor.php', args );\n * close();\n * },\n * };\n * } );\n * }, [ records ] );\n *\n * return {\n * commands,\n * isLoading,\n * };\n * }\n *\n * useCommandLoader( {\n * name: 'myplugin/page-search',\n * hook: usePageSearchCommandLoader,\n * } );\n * ```\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tif ( loader.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t\tcategory: loader.category,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tloader.category,\n\t\tloader.disabled,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0B;AAC1B,kBAA4B;AAC5B,mBAAuC;AAwExB,SAAR,iBAAmC,QAAS;AAClD,QAAM,EAAE,uBAAuB,wBAAwB,QACtD,yBAAa,aAAAA,KAAc;AAC5B,gCAAW,MAAM;AAChB,QAAK,OAAO,UAAW;AACtB;AAAA,IACD;AACA,0BAAuB;AAAA,MACtB,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,IAClB,CAAE;AACF,WAAO,MAAM;AACZ,8BAAyB,OAAO,IAAK;AAAA,IACtC;AAAA,EACD,GAAG;AAAA,IACF,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
6
  "names": ["commandsStore"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/use-command.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n *\n * @example\n * ```js\n * import { useCommand } from '@wordpress/commands';\n * import { plus } from '@wordpress/icons';\n *\n * useCommand( {\n * name: 'myplugin/my-command-name',\n * label: __( 'Add new post' ),\n *\t icon: plus,\n * category: 'command',\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * } );\n * ```\n */\nexport function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbackRef = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallbackRef.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\n\t\tif ( command.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommand( {\n\t\t\tname: command.name,\n\t\t\tcontext: command.context,\n\t\t\tcategory: command.category,\n\t\t\tlabel: command.label,\n\t\t\tsearchLabel: command.searchLabel,\n\t\t\ticon: command.icon,\n\t\t\tkeywords: command.keywords,\n\t\t\tcallback: ( ...args ) => currentCallbackRef.current( ...args ),\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommand( command.name );\n\t\t};\n\t}, [\n\t\tcommand.name,\n\t\tcommand.label,\n\t\tcommand.searchLabel,\n\t\tcommand.icon,\n\t\tcommand.context,\n\t\tcommand.category,\n\t\tcommand.keywords,\n\t\tcommand.disabled,\n\t\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n\n/**\n * Attach multiple commands to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig[]} commands Array of command configs.\n *\n * @example\n * ```js\n * import { useCommands } from '@wordpress/commands';\n * import { plus, pencil } from '@wordpress/icons';\n *\n * useCommands( [\n * {\n * name: 'myplugin/add-post',\n * label: __( 'Add new post' ),\n * icon: plus,\n * category: 'command',\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * },\n * {\n * name: 'myplugin/edit-posts',\n * label: __( 'Edit posts' ),\n * icon: pencil,\n * category: 'view',\n * callback: ({ close }) => {\n * document.location.href = 'edit.php';\n * close();\n * },\n * },\n * ] );\n * ```\n */\nexport function useCommands( commands ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbacksRef = useRef( {} );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.callback ) {\n\t\t\t\tcurrentCallbacksRef.current[ command.name ] = command.callback;\n\t\t\t}\n\t\t} );\n\t}, [ commands ] );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tregisterCommand( {\n\t\t\t\tname: command.name,\n\t\t\t\tcontext: command.context,\n\t\t\t\tcategory: command.category,\n\t\t\t\tlabel: command.label,\n\t\t\t\tsearchLabel: command.searchLabel,\n\t\t\t\ticon: command.icon,\n\t\t\t\tkeywords: command.keywords,\n\t\t\t\tcallback: ( ...args ) => {\n\t\t\t\t\tconst callback =\n\t\t\t\t\t\tcurrentCallbacksRef.current[ command.name ];\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tcallback( ...args );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tcommands.forEach( ( command ) => {\n\t\t\t\tunregisterCommand( command.name );\n\t\t\t} );\n\t\t};\n\t}, [ commands, registerCommand, unregisterCommand ] );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAkC;AAClC,kBAA4B;AAK5B,mBAAuC;AAwBhC,SAAS,WAAY,SAAU;AACrC,QAAM,EAAE,iBAAiB,kBAAkB,QAAI,yBAAa,aAAAA,KAAc;AAC1E,QAAM,yBAAqB,uBAAQ,QAAQ,QAAS;AACpD,gCAAW,MAAM;AAChB,uBAAmB,UAAU,QAAQ;AAAA,EACtC,GAAG,CAAE,QAAQ,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,MAAM,QAAQ;AAAA,QACd,UAAU,QAAQ;AAAA,QAClB,UAAU,IAAK,SAAU;AACxB,gBAAM,WACL,oBAAoB,QAAS,QAAQ,IAAK;AAC3C,cAAK,UAAW;AACf,qBAAU,GAAG,IAAK;AAAA,UACnB;AAAA,QACD;AAAA,MACD,CAAE;AAAA,IACH,CAAE;AAEF,WAAO,MAAM;AACZ,eAAS,QAAS,CAAE,YAAa;AAChC,0BAAmB,QAAQ,IAAK;AAAA,MACjC,CAAE;AAAA,IACH;AAAA,EACD,GAAG,CAAE,UAAU,iBAAiB,iBAAkB,CAAE;AACrD;",
4
+ "sourcesContent": ["import { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n *\n * @example\n * ```js\n * import { useCommand } from '@wordpress/commands';\n * import { plus } from '@wordpress/icons';\n *\n * useCommand( {\n * name: 'myplugin/my-command-name',\n * label: __( 'Add new post' ),\n *\t icon: plus,\n * category: 'command',\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * } );\n * ```\n */\nexport function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbackRef = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallbackRef.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\n\t\tif ( command.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommand( {\n\t\t\tname: command.name,\n\t\t\tcontext: command.context,\n\t\t\tcategory: command.category,\n\t\t\tlabel: command.label,\n\t\t\tsearchLabel: command.searchLabel,\n\t\t\ticon: command.icon,\n\t\t\tkeywords: command.keywords,\n\t\t\tcallback: ( ...args ) => currentCallbackRef.current( ...args ),\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommand( command.name );\n\t\t};\n\t}, [\n\t\tcommand.name,\n\t\tcommand.label,\n\t\tcommand.searchLabel,\n\t\tcommand.icon,\n\t\tcommand.context,\n\t\tcommand.category,\n\t\tcommand.keywords,\n\t\tcommand.disabled,\n\t\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n\n/**\n * Attach multiple commands to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig[]} commands Array of command configs.\n *\n * @example\n * ```js\n * import { useCommands } from '@wordpress/commands';\n * import { plus, pencil } from '@wordpress/icons';\n *\n * useCommands( [\n * {\n * name: 'myplugin/add-post',\n * label: __( 'Add new post' ),\n * icon: plus,\n * category: 'command',\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * },\n * {\n * name: 'myplugin/edit-posts',\n * label: __( 'Edit posts' ),\n * icon: pencil,\n * category: 'view',\n * callback: ({ close }) => {\n * document.location.href = 'edit.php';\n * close();\n * },\n * },\n * ] );\n * ```\n */\nexport function useCommands( commands ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbacksRef = useRef( {} );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.callback ) {\n\t\t\t\tcurrentCallbacksRef.current[ command.name ] = command.callback;\n\t\t\t}\n\t\t} );\n\t}, [ commands ] );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tregisterCommand( {\n\t\t\t\tname: command.name,\n\t\t\t\tcontext: command.context,\n\t\t\t\tcategory: command.category,\n\t\t\t\tlabel: command.label,\n\t\t\t\tsearchLabel: command.searchLabel,\n\t\t\t\ticon: command.icon,\n\t\t\t\tkeywords: command.keywords,\n\t\t\t\tcallback: ( ...args ) => {\n\t\t\t\t\tconst callback =\n\t\t\t\t\t\tcurrentCallbacksRef.current[ command.name ];\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tcallback( ...args );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tcommands.forEach( ( command ) => {\n\t\t\t\tunregisterCommand( command.name );\n\t\t\t} );\n\t\t};\n\t}, [ commands, registerCommand, unregisterCommand ] );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAkC;AAClC,kBAA4B;AAC5B,mBAAuC;AAwBhC,SAAS,WAAY,SAAU;AACrC,QAAM,EAAE,iBAAiB,kBAAkB,QAAI,yBAAa,aAAAA,KAAc;AAC1E,QAAM,yBAAqB,uBAAQ,QAAQ,QAAS;AACpD,gCAAW,MAAM;AAChB,uBAAmB,UAAU,QAAQ;AAAA,EACtC,GAAG,CAAE,QAAQ,QAAS,CAAE;AAExB,gCAAW,MAAM;AAChB,QAAK,QAAQ,UAAW;AACvB;AAAA,IACD;AACA,oBAAiB;AAAA,MAChB,MAAM,QAAQ;AAAA,MACd,SAAS,QAAQ;AAAA,MACjB,UAAU,QAAQ;AAAA,MAClB,OAAO,QAAQ;AAAA,MACf,aAAa,QAAQ;AAAA,MACrB,MAAM,QAAQ;AAAA,MACd,UAAU,QAAQ;AAAA,MAClB,UAAU,IAAK,SAAU,mBAAmB,QAAS,GAAG,IAAK;AAAA,IAC9D,CAAE;AACF,WAAO,MAAM;AACZ,wBAAmB,QAAQ,IAAK;AAAA,IACjC;AAAA,EACD,GAAG;AAAA,IACF,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EACD,CAAE;AACH;AAoCO,SAAS,YAAa,UAAW;AACvC,QAAM,EAAE,iBAAiB,kBAAkB,QAAI,yBAAa,aAAAA,KAAc;AAC1E,QAAM,0BAAsB,uBAAQ,CAAC,CAAE;AAEvC,gCAAW,MAAM;AAChB,QAAK,CAAE,UAAW;AACjB;AAAA,IACD;AACA,aAAS,QAAS,CAAE,YAAa;AAChC,UAAK,QAAQ,UAAW;AACvB,4BAAoB,QAAS,QAAQ,IAAK,IAAI,QAAQ;AAAA,MACvD;AAAA,IACD,CAAE;AAAA,EACH,GAAG,CAAE,QAAS,CAAE;AAEhB,gCAAW,MAAM;AAChB,QAAK,CAAE,UAAW;AACjB;AAAA,IACD;AACA,aAAS,QAAS,CAAE,YAAa;AAChC,UAAK,QAAQ,UAAW;AACvB;AAAA,MACD;AACA,sBAAiB;AAAA,QAChB,MAAM,QAAQ;AAAA,QACd,SAAS,QAAQ;AAAA,QACjB,UAAU,QAAQ;AAAA,QAClB,OAAO,QAAQ;AAAA,QACf,aAAa,QAAQ;AAAA,QACrB,MAAM,QAAQ;AAAA,QACd,UAAU,QAAQ;AAAA,QAClB,UAAU,IAAK,SAAU;AACxB,gBAAM,WACL,oBAAoB,QAAS,QAAQ,IAAK;AAC3C,cAAK,UAAW;AACf,qBAAU,GAAG,IAAK;AAAA,UACnB;AAAA,QACD;AAAA,MACD,CAAE;AAAA,IACH,CAAE;AAEF,WAAO,MAAM;AACZ,eAAS,QAAS,CAAE,YAAa;AAChC,0BAAmB,QAAQ,IAAK;AAAA,MACjC,CAAE;AAAA,IACH;AAAA,EACD,GAAG,CAAE,UAAU,iBAAiB,iBAAkB,CAAE;AACrD;",
6
6
  "names": ["commandsStore"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/lock-unlock.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/commands'\n\t);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAiE;AAE1D,IAAM,EAAE,MAAM,OAAO,QAC3B;AAAA,EACC;AAAA,EACA;AACD;",
4
+ "sourcesContent": ["import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/commands'\n\t);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAiE;AAE1D,IAAM,EAAE,MAAM,OAAO,QAC3B;AAAA,EACC;AAAA,EACA;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/private-apis.js"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { default as useCommandContext } from './hooks/use-command-context';\nimport { lock } from './lock-unlock';\n\n/**\n * @private\n */\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommandContext,\n} );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iCAA6C;AAC7C,yBAAqB;AAKd,IAAM,cAAc,CAAC;AAAA,IAC5B,yBAAM,aAAa;AAAA,EAClB,8CAAAA;AACD,CAAE;",
4
+ "sourcesContent": ["import { default as useCommandContext } from './hooks/use-command-context';\nimport { lock } from './lock-unlock';\n\n/**\n * @private\n */\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommandContext,\n} );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAA6C;AAC7C,yBAAqB;AAKd,IAAM,cAAc,CAAC;AAAA,IAC5B,yBAAM,aAAa;AAAA,EAClB,8CAAAA;AACD,CAAE;",
6
6
  "names": ["useCommandContext"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport * as privateActions from './private-actions';\nimport * as privateSelectors from './private-selectors';\nimport { unlock } from '../lock-unlock';\n\nconst STORE_NAME = 'core/commands';\n\n/**\n * Store definition for the commands namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n *\n * @example\n * ```js\n * import { store as commandsStore } from '@wordpress/commands';\n * import { useDispatch } from '@wordpress/data';\n * ...\n * const { open: openCommandCenter } = useDispatch( commandsStore );\n * ```\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\nunlock( store ).registerPrivateActions( privateActions );\nunlock( store ).registerPrivateSelectors( privateSelectors );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA2C;AAK3C,qBAAoB;AACpB,cAAyB;AACzB,gBAA2B;AAC3B,qBAAgC;AAChC,uBAAkC;AAClC,yBAAuB;AAEvB,IAAM,aAAa;AAiBZ,IAAM,YAAQ,8BAAkB,YAAY;AAAA,EAClD,wBAAAA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAAA,IAEF,sBAAU,KAAM;AAAA,IAChB,2BAAQ,KAAM,EAAE,uBAAwB,cAAe;AAAA,IACvD,2BAAQ,KAAM,EAAE,yBAA0B,gBAAiB;",
4
+ "sourcesContent": ["import { createReduxStore, register } from '@wordpress/data';\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport * as privateActions from './private-actions';\nimport * as privateSelectors from './private-selectors';\nimport { unlock } from '../lock-unlock';\n\nconst STORE_NAME = 'core/commands';\n\n/**\n * Store definition for the commands namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n *\n * @example\n * ```js\n * import { store as commandsStore } from '@wordpress/commands';\n * import { useDispatch } from '@wordpress/data';\n * ...\n * const { open: openCommandCenter } = useDispatch( commandsStore );\n * ```\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\nunlock( store ).registerPrivateActions( privateActions );\nunlock( store ).registerPrivateSelectors( privateSelectors );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2C;AAC3C,qBAAoB;AACpB,cAAyB;AACzB,gBAA2B;AAC3B,qBAAgC;AAChC,uBAAkC;AAClC,yBAAuB;AAEvB,IAAM,aAAa;AAiBZ,IAAM,YAAQ,8BAAkB,YAAY;AAAA,EAClD,wBAAAA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAAA,IAEF,sBAAU,KAAM;AAAA,IAChB,2BAAQ,KAAM,EAAE,uBAAwB,cAAe;AAAA,IACvD,2BAAQ,KAAM,EAAE,yBAA0B,gBAAiB;",
6
6
  "names": ["reducer"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/reducer.js"],
4
- "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\tcategory: action.category,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t\tkeywords: action.keywords,\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\tcategory: action.category,\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\nfunction loaderStates( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_LOADER_LOADING':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: action.isLoading,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n\tloaderStates,\n} );\n\nexport default reducer;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAUhC,SAAS,SAAU,QAAQ,CAAC,GAAG,QAAS;AACvC,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG;AAAA,UAChB,MAAM,OAAO;AAAA,UACb,OAAO,OAAO;AAAA,UACd,aAAa,OAAO;AAAA,UACpB,SAAS,OAAO;AAAA,UAChB,UAAU,OAAO;AAAA,UACjB,UAAU,OAAO;AAAA,UACjB,MAAM,OAAO;AAAA,UACb,UAAU,OAAO;AAAA,QAClB;AAAA,MACD;AAAA,IACD,KAAK,sBAAsB;AAC1B,YAAM,EAAE,CAAE,OAAO,IAAK,GAAG,GAAG,GAAG,eAAe,IAAI;AAClD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,eAAgB,QAAQ,CAAC,GAAG,QAAS;AAC7C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG;AAAA,UAChB,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,UAChB,UAAU,OAAO;AAAA,UACjB,MAAM,OAAO;AAAA,QACd;AAAA,MACD;AAAA,IACD,KAAK,6BAA6B;AACjC,YAAM,EAAE,CAAE,OAAO,IAAK,GAAG,GAAG,GAAG,eAAe,IAAI;AAClD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,OAAQ,QAAQ,OAAO,QAAS;AACxC,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,EACT;AAEA,SAAO;AACR;AAUA,SAAS,QAAS,QAAQ,QAAQ,QAAS;AAC1C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,OAAO;AAAA,EAChB;AAEA,SAAO;AACR;AAEA,SAAS,aAAc,QAAQ,CAAC,GAAG,QAAS;AAC3C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG,OAAO;AAAA,MACzB;AAAA,EACF;AAEA,SAAO;AACR;AAEA,IAAM,cAAU,6BAAiB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,IAAO,kBAAQ;",
4
+ "sourcesContent": ["import { 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\tcategory: action.category,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t\tkeywords: action.keywords,\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\tcategory: action.category,\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\nfunction loaderStates( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_LOADER_LOADING':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: action.isLoading,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n\tloaderStates,\n} );\n\nexport default reducer;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC;AAUhC,SAAS,SA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S,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG,OAAO;AAAA,MACzB;AAAA,EACF;AAEA,SAAO;AACR;AAEA,IAAM,cAAU,6BAAiB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,IAAO,kBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/selectors.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector } from '@wordpress/data';\n\n/**\n * Returns the registered static commands.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual commands.\n *\n * @return {import('./actions').WPCommandConfig[]} The list of registered commands.\n */\nexport const getCommands = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commands ).filter( ( command ) => {\n\t\t\tconst isContextual =\n\t\t\t\tcommand.context && command.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commands, state.context ]\n);\n\n/**\n * Returns the registered command loaders.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual command loaders.\n *\n * @return {import('./actions').WPCommandLoaderConfig[]} The list of registered command loaders.\n */\nexport const getCommandLoaders = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commandLoaders ).filter( ( loader ) => {\n\t\t\tconst isContextual =\n\t\t\t\tloader.context && loader.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commandLoaders, state.context ]\n);\n\n/**\n * Returns whether the command palette is open.\n *\n * @param {Object} state State tree.\n *\n * @return {boolean} Returns whether the command palette is open.\n */\nexport function isOpen( state ) {\n\treturn state.isOpen;\n}\n\n/**\n * Returns whether the active context.\n *\n * @param {Object} state State tree.\n *\n * @return {string} Context.\n */\nexport function getContext( state ) {\n\treturn state.context;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA+B;AAUxB,IAAM,kBAAc;AAAA,EAC1B,CAAE,OAAO,aAAa,UACrB,OAAO,OAAQ,MAAM,QAAS,EAAE,OAAQ,CAAE,YAAa;AACtD,UAAM,eACL,QAAQ,WAAW,QAAQ,YAAY,MAAM;AAC9C,WAAO,aAAa,eAAe,CAAE;AAAA,EACtC,CAAE;AAAA,EACH,CAAE,UAAW,CAAE,MAAM,UAAU,MAAM,OAAQ;AAC9C;AAUO,IAAM,wBAAoB;AAAA,EAChC,CAAE,OAAO,aAAa,UACrB,OAAO,OAAQ,MAAM,cAAe,EAAE,OAAQ,CAAE,WAAY;AAC3D,UAAM,eACL,OAAO,WAAW,OAAO,YAAY,MAAM;AAC5C,WAAO,aAAa,eAAe,CAAE;AAAA,EACtC,CAAE;AAAA,EACH,CAAE,UAAW,CAAE,MAAM,gBAAgB,MAAM,OAAQ;AACpD;AASO,SAAS,OAAQ,OAAQ;AAC/B,SAAO,MAAM;AACd;AASO,SAAS,WAAY,OAAQ;AACnC,SAAO,MAAM;AACd;",
4
+ "sourcesContent": ["import { createSelector } from '@wordpress/data';\n\n/**\n * Returns the registered static commands.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual commands.\n *\n * @return {import('./actions').WPCommandConfig[]} The list of registered commands.\n */\nexport const getCommands = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commands ).filter( ( command ) => {\n\t\t\tconst isContextual =\n\t\t\t\tcommand.context && command.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commands, state.context ]\n);\n\n/**\n * Returns the registered command loaders.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual command loaders.\n *\n * @return {import('./actions').WPCommandLoaderConfig[]} The list of registered command loaders.\n */\nexport const getCommandLoaders = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commandLoaders ).filter( ( loader ) => {\n\t\t\tconst isContextual =\n\t\t\t\tloader.context && loader.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commandLoaders, state.context ]\n);\n\n/**\n * Returns whether the command palette is open.\n *\n * @param {Object} state State tree.\n *\n * @return {boolean} Returns whether the command palette is open.\n */\nexport function isOpen( state ) {\n\treturn state.isOpen;\n}\n\n/**\n * Returns whether the active context.\n *\n * @param {Object} state State tree.\n *\n * @return {string} Context.\n */\nexport function getContext( state ) {\n\treturn state.context;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+B;AAUxB,IAAM,kBAAc;AAAA,EAC1B,CAAE,OAAO,aAAa,UACrB,OAAO,OAAQ,MAAM,QAAS,EAAE,OAAQ,CAAE,YAAa;AACtD,UAAM,eACL,QAAQ,WAAW,QAAQ,YAAY,MAAM;AAC9C,WAAO,aAAa,eAAe,CAAE;AAAA,EACtC,CAAE;AAAA,EACH,CAAE,UAAW,CAAE,MAAM,UAAU,MAAM,OAAQ;AAC9C;AAUO,IAAM,wBAAoB;AAAA,EAChC,CAAE,OAAO,aAAa,UACrB,OAAO,OAAQ,MAAM,cAAe,EAAE,OAAQ,CAAE,WAAY;AAC3D,UAAM,eACL,OAAO,WAAW,OAAO,YAAY,MAAM;AAC5C,WAAO,aAAa,eAAe,CAAE;AAAA,EACtC,CAAE;AAAA,EACH,CAAE,UAAW,CAAE,MAAM,gBAAgB,MAAM,OAAQ;AACpD;AASO,SAAS,OAAQ,OAAQ;AAC/B,SAAO,MAAM;AACd;AASO,SAAS,WAAY,OAAQ;AACnC,SAAO,MAAM;AACd;",
6
6
  "names": []
7
7
  }
@@ -13,13 +13,13 @@ import { __ } from "@wordpress/i18n";
13
13
  import {
14
14
  Modal,
15
15
  TextHighlight,
16
- __experimentalHStack as HStack,
17
- privateApis as componentsPrivateApis
16
+ __experimentalHStack as HStack
18
17
  } from "@wordpress/components";
19
18
  import {
20
19
  store as keyboardShortcutsStore,
21
20
  useShortcut
22
21
  } from "@wordpress/keyboard-shortcuts";
22
+ import { withIgnoreIMEEvents } from "@wordpress/keycodes";
23
23
  import { Icon, search as inputIcon, arrowRight } from "@wordpress/icons";
24
24
  import { store as commandsStore } from "../store/index.mjs";
25
25
  import { unlock } from "../lock-unlock.mjs";
@@ -29,7 +29,6 @@ import {
29
29
  useRecentCommands
30
30
  } from "./use-recent-commands.mjs";
31
31
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
32
- var { withIgnoreIMEEvents } = unlock(componentsPrivateApis);
33
32
  var ITEM_ID_PREFIX = "command-palette-item-";
34
33
  var inputLabel = __("Search commands and settings");
35
34
  var CATEGORY_ICONS = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/components/command-menu.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { Command, useCommandState } from 'cmdk';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tisValidElement,\n\tComponent,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tModal,\n\tTextHighlight,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport {\n\tstore as keyboardShortcutsStore,\n\tuseShortcut,\n} from '@wordpress/keyboard-shortcuts';\nimport { Icon, search as inputIcon, arrowRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\nimport {\n\trecordUsage,\n\tuseLoaderCollector,\n\tuseRecentCommands,\n} from './use-recent-commands';\n\nconst { withIgnoreIMEEvents } = unlock( componentsPrivateApis );\n\n// Namespaces item ids to avoid collisions with other elements on the page.\nconst ITEM_ID_PREFIX = 'command-palette-item-';\nconst inputLabel = __( 'Search commands and settings' );\n\n/**\n * Icons enforced per command category.\n * Categories listed here will always use the specified icon,\n * ignoring whatever icon the command itself provides.\n */\nconst CATEGORY_ICONS = {\n\tview: arrowRight,\n};\n\n/**\n * Translatable labels for command categories.\n */\nconst CATEGORY_LABELS = {\n\tcommand: __( 'Command' ),\n\tview: __( 'View' ),\n\tedit: __( 'Edit' ),\n\taction: __( 'Action' ),\n\tworkflow: __( 'Workflow' ),\n};\n\n/**\n * Function that checks if the parameter is a valid icon.\n * Taken from @wordpress/blocks/src/api/utils.js and copied\n * in case requirements diverge and to avoid a dependency on @wordpress/blocks.\n *\n * @param {*} icon Parameter to be checked.\n *\n * @return {boolean} True if the parameter is a valid icon and false otherwise.\n */\n\nexport function isValidIcon( icon ) {\n\treturn (\n\t\t!! icon &&\n\t\t( typeof icon === 'string' ||\n\t\t\tisValidElement( icon ) ||\n\t\t\ttypeof icon === 'function' ||\n\t\t\ticon instanceof Component )\n\t);\n}\n\nfunction CommandItem( { command, search, category, valuePrefix } ) {\n\tconst { close } = useDispatch( commandsStore );\n\tconst commandCategory = category ?? command.category;\n\tconst label = command.searchLabel ?? command.label;\n\tconst value = valuePrefix ? `${ valuePrefix }${ command.name }` : label;\n\treturn (\n\t\t<Command.Item\n\t\t\tkey={ command.name }\n\t\t\tid={ `${ ITEM_ID_PREFIX }${ value.toLowerCase() }` }\n\t\t\tvalue={ value }\n\t\t\tkeywords={\n\t\t\t\tvaluePrefix\n\t\t\t\t\t? [ ...( command.keywords ?? [] ), label ]\n\t\t\t\t\t: command.keywords\n\t\t\t}\n\t\t\tonSelect={ () => {\n\t\t\t\trecordUsage( command.name );\n\t\t\t\tcommand.callback( { close } );\n\t\t\t} }\n\t\t>\n\t\t\t<HStack\n\t\t\t\talignment=\"left\"\n\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t'has-icon':\n\t\t\t\t\t\tCATEGORY_ICONS[ commandCategory ] || command.icon,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ CATEGORY_ICONS[ commandCategory ] ? (\n\t\t\t\t\t<Icon icon={ CATEGORY_ICONS[ commandCategory ] } />\n\t\t\t\t) : (\n\t\t\t\t\tisValidIcon( command.icon ) && (\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t)\n\t\t\t\t) }\n\t\t\t\t<span className=\"commands-command-menu__item-label\">\n\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t\t{ CATEGORY_LABELS[ commandCategory ] && (\n\t\t\t\t\t<span className=\"commands-command-menu__item-category\">\n\t\t\t\t\t\t{ CATEGORY_LABELS[ commandCategory ] }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</Command.Item>\n\t);\n}\n\nfunction CommandMenuLoader( { name, search, hook, category, valuePrefix } ) {\n\tconst { setLoaderLoading } = unlock( useDispatch( commandsStore ) );\n\tconst { isLoading: loading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoaderLoading( name, loading );\n\t}, [ setLoaderLoading, name, loading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tcategory={ command.category ?? category }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction CommandMenuLoaderWrapper( { hook, ...props } ) {\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\tconst currentLoaderRef = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoaderRef.current !== hook ) {\n\t\t\tcurrentLoaderRef.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={ currentLoaderRef.current }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction CommandList( { search, commands, loaders, valuePrefix } ) {\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\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\tname={ loader.name }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tcategory={ loader.category }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction RecentLoaderRunner( { hook, name, filterNames, onResolved } ) {\n\tuseLoaderCollector( hook, name, filterNames, onResolved );\n\treturn null;\n}\n\nfunction RecentGroup() {\n\tconst { commands, loaders, recentSet, onResolved } = useRecentCommands();\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Recent' ) }>\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<RecentLoaderRunner\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\tname={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tfilterNames={ recentSet }\n\t\t\t\t\tonResolved={ onResolved }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch=\"\"\n\t\t\t\t\tvaluePrefix=\"recent-\"\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nfunction SuggestionsGroup() {\n\tconst { commands, loaders } = useSelect( ( select ) => {\n\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\treturn {\n\t\t\tcommands: getCommands( true ),\n\t\t\tloaders: getCommandLoaders( true ),\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Suggestions' ) }>\n\t\t\t<CommandList search=\"\" commands={ commands } loaders={ loaders } />\n\t\t</Command.Group>\n\t);\n}\n\nfunction ResultsGroup( { search } ) {\n\tconst { commands, contextualCommands, loaders, contextualLoaders } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( false ),\n\t\t\t\tcontextualCommands: getCommands( true ),\n\t\t\t\tloaders: getCommandLoaders( false ),\n\t\t\t\tcontextualLoaders: getCommandLoaders( true ),\n\t\t\t};\n\t\t}, [] );\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Results' ) }>\n\t\t\t<CommandList\n\t\t\t\tsearch={ search }\n\t\t\t\tcommands={ commands }\n\t\t\t\tloaders={ loaders }\n\t\t\t/>\n\t\t\t<CommandList\n\t\t\t\tsearch={ search }\n\t\t\t\tcommands={ contextualCommands }\n\t\t\t\tloaders={ contextualLoaders }\n\t\t\t/>\n\t\t</Command.Group>\n\t);\n}\n\nfunction CommandInput( { search, setSearch } ) {\n\tconst commandMenuInput = useRef();\n\tconst _value = useCommandState( ( state ) => state.value );\n\tconst selectedItemId = _value ? `${ ITEM_ID_PREFIX }${ _value }` : null;\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tcommandMenuInput.current.focus();\n\t}, [] );\n\treturn (\n\t\t<Command.Input\n\t\t\tref={ commandMenuInput }\n\t\t\tvalue={ search }\n\t\t\tonValueChange={ setSearch }\n\t\t\tplaceholder={ inputLabel }\n\t\t\taria-activedescendant={ selectedItemId }\n\t\t/>\n\t);\n}\n\n/**\n * @ignore\n */\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst { isOpen: paletteIsOpen, loadersLoading } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisOpen: select( commandsStore ).isOpen(),\n\t\t\tloadersLoading: unlock( select( commandsStore ) ).isLoading(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\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/** @type {React.KeyboardEventHandler} */\n\t\twithIgnoreIMEEvents( ( event ) => {\n\t\t\t// Bails to avoid obscuring the effect of the preceding handler(s).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tif ( paletteIsOpen ) {\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 closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tif ( ! paletteIsOpen ) {\n\t\treturn false;\n\t}\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\tsize=\"medium\"\n\t\t\tcontentLabel={ __( 'Command palette' ) }\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ inputLabel } loop>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__header-search-icon\"\n\t\t\t\t\t\t\ticon={ inputIcon }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<CommandInput\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetSearch={ setSearch }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List label={ __( 'Command suggestions' ) }>\n\t\t\t\t\t\t{ search && ! loadersLoading && (\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{ ! search && <RecentGroup /> }\n\t\t\t\t\t\t{ ! search && <SuggestionsGroup /> }\n\t\t\t\t\t\t{ search && <ResultsGroup search={ search } /> }\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"],
5
- "mappings": ";AAGA,SAAS,SAAS,uBAAuB;AACzC,OAAO,UAAU;AAKjB,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,eAAe;AAAA,OACT;AACP;AAAA,EACC,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,MAAM,UAAU,WAAW,kBAAkB;AAKtD,SAAS,SAAS,qBA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a,MAAI,MACjC;AAAA,6BAAC,SAAI,WAAU,iCACd;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,MAAO;AAAA;AAAA,UACR;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,WACD;AAAA,QACA,qBAAC,QAAQ,MAAR,EAAa,OAAQ,GAAI,qBAAsB,GAC7C;AAAA,oBAAU,CAAE,kBACb,oBAAC,QAAQ,OAAR,EACE,aAAI,mBAAoB,GAC3B;AAAA,UAEC,CAAE,UAAU,oBAAC,eAAY;AAAA,UACzB,CAAE,UAAU,oBAAC,oBAAiB;AAAA,UAC9B,UAAU,oBAAC,gBAAa,QAAkB;AAAA,WAC7C;AAAA,SACD,GACD;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["import { Command, useCommandState } from 'cmdk';\nimport clsx from 'clsx';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tisValidElement,\n\tComponent,\n} 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 { withIgnoreIMEEvents } from '@wordpress/keycodes';\nimport { Icon, search as inputIcon, arrowRight } from '@wordpress/icons';\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\nimport {\n\trecordUsage,\n\tuseLoaderCollector,\n\tuseRecentCommands,\n} from './use-recent-commands';\n\n// Namespaces item ids to avoid collisions with other elements on the page.\nconst ITEM_ID_PREFIX = 'command-palette-item-';\nconst inputLabel = __( 'Search commands and settings' );\n\n/**\n * Icons enforced per command category.\n * Categories listed here will always use the specified icon,\n * ignoring whatever icon the command itself provides.\n */\nconst CATEGORY_ICONS = {\n\tview: arrowRight,\n};\n\n/**\n * Translatable labels for command categories.\n */\nconst CATEGORY_LABELS = {\n\tcommand: __( 'Command' ),\n\tview: __( 'View' ),\n\tedit: __( 'Edit' ),\n\taction: __( 'Action' ),\n\tworkflow: __( 'Workflow' ),\n};\n\n/**\n * Function that checks if the parameter is a valid icon.\n * Taken from @wordpress/blocks/src/api/utils.js and copied\n * in case requirements diverge and to avoid a dependency on @wordpress/blocks.\n *\n * @param {*} icon Parameter to be checked.\n *\n * @return {boolean} True if the parameter is a valid icon and false otherwise.\n */\n\nexport function isValidIcon( icon ) {\n\treturn (\n\t\t!! icon &&\n\t\t( typeof icon === 'string' ||\n\t\t\tisValidElement( icon ) ||\n\t\t\ttypeof icon === 'function' ||\n\t\t\ticon instanceof Component )\n\t);\n}\n\nfunction CommandItem( { command, search, category, valuePrefix } ) {\n\tconst { close } = useDispatch( commandsStore );\n\tconst commandCategory = category ?? command.category;\n\tconst label = command.searchLabel ?? command.label;\n\tconst value = valuePrefix ? `${ valuePrefix }${ command.name }` : label;\n\treturn (\n\t\t<Command.Item\n\t\t\tkey={ command.name }\n\t\t\tid={ `${ ITEM_ID_PREFIX }${ value.toLowerCase() }` }\n\t\t\tvalue={ value }\n\t\t\tkeywords={\n\t\t\t\tvaluePrefix\n\t\t\t\t\t? [ ...( command.keywords ?? [] ), label ]\n\t\t\t\t\t: command.keywords\n\t\t\t}\n\t\t\tonSelect={ () => {\n\t\t\t\trecordUsage( command.name );\n\t\t\t\tcommand.callback( { close } );\n\t\t\t} }\n\t\t>\n\t\t\t<HStack\n\t\t\t\talignment=\"left\"\n\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t'has-icon':\n\t\t\t\t\t\tCATEGORY_ICONS[ commandCategory ] || command.icon,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ CATEGORY_ICONS[ commandCategory ] ? (\n\t\t\t\t\t<Icon icon={ CATEGORY_ICONS[ commandCategory ] } />\n\t\t\t\t) : (\n\t\t\t\t\tisValidIcon( command.icon ) && (\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t)\n\t\t\t\t) }\n\t\t\t\t<span className=\"commands-command-menu__item-label\">\n\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t\t{ CATEGORY_LABELS[ commandCategory ] && (\n\t\t\t\t\t<span className=\"commands-command-menu__item-category\">\n\t\t\t\t\t\t{ CATEGORY_LABELS[ commandCategory ] }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</Command.Item>\n\t);\n}\n\nfunction CommandMenuLoader( { name, search, hook, category, valuePrefix } ) {\n\tconst { setLoaderLoading } = unlock( useDispatch( commandsStore ) );\n\tconst { isLoading: loading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoaderLoading( name, loading );\n\t}, [ setLoaderLoading, name, loading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tcategory={ command.category ?? category }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction CommandMenuLoaderWrapper( { hook, ...props } ) {\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\tconst currentLoaderRef = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoaderRef.current !== hook ) {\n\t\t\tcurrentLoaderRef.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={ currentLoaderRef.current }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction CommandList( { search, commands, loaders, valuePrefix } ) {\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\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\tname={ loader.name }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tcategory={ loader.category }\n\t\t\t\t\tvaluePrefix={ valuePrefix }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction RecentLoaderRunner( { hook, name, filterNames, onResolved } ) {\n\tuseLoaderCollector( hook, name, filterNames, onResolved );\n\treturn null;\n}\n\nfunction RecentGroup() {\n\tconst { commands, loaders, recentSet, onResolved } = useRecentCommands();\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Recent' ) }>\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<RecentLoaderRunner\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\tname={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tfilterNames={ recentSet }\n\t\t\t\t\tonResolved={ onResolved }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<CommandItem\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tcommand={ command }\n\t\t\t\t\tsearch=\"\"\n\t\t\t\t\tvaluePrefix=\"recent-\"\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nfunction SuggestionsGroup() {\n\tconst { commands, loaders } = useSelect( ( select ) => {\n\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\treturn {\n\t\t\tcommands: getCommands( true ),\n\t\t\tloaders: getCommandLoaders( true ),\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Suggestions' ) }>\n\t\t\t<CommandList search=\"\" commands={ commands } loaders={ loaders } />\n\t\t</Command.Group>\n\t);\n}\n\nfunction ResultsGroup( { search } ) {\n\tconst { commands, contextualCommands, loaders, contextualLoaders } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( false ),\n\t\t\t\tcontextualCommands: getCommands( true ),\n\t\t\t\tloaders: getCommandLoaders( false ),\n\t\t\t\tcontextualLoaders: getCommandLoaders( true ),\n\t\t\t};\n\t\t}, [] );\n\n\treturn (\n\t\t<Command.Group heading={ __( 'Results' ) }>\n\t\t\t<CommandList\n\t\t\t\tsearch={ search }\n\t\t\t\tcommands={ commands }\n\t\t\t\tloaders={ loaders }\n\t\t\t/>\n\t\t\t<CommandList\n\t\t\t\tsearch={ search }\n\t\t\t\tcommands={ contextualCommands }\n\t\t\t\tloaders={ contextualLoaders }\n\t\t\t/>\n\t\t</Command.Group>\n\t);\n}\n\nfunction CommandInput( { search, setSearch } ) {\n\tconst commandMenuInput = useRef();\n\tconst _value = useCommandState( ( state ) => state.value );\n\tconst selectedItemId = _value ? `${ ITEM_ID_PREFIX }${ _value }` : null;\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tcommandMenuInput.current.focus();\n\t}, [] );\n\treturn (\n\t\t<Command.Input\n\t\t\tref={ commandMenuInput }\n\t\t\tvalue={ search }\n\t\t\tonValueChange={ setSearch }\n\t\t\tplaceholder={ inputLabel }\n\t\t\taria-activedescendant={ selectedItemId }\n\t\t/>\n\t);\n}\n\n/**\n * @ignore\n */\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst { isOpen: paletteIsOpen, loadersLoading } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisOpen: select( commandsStore ).isOpen(),\n\t\t\tloadersLoading: unlock( select( commandsStore ) ).isLoading(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\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/** @type {React.KeyboardEventHandler} */\n\t\twithIgnoreIMEEvents( ( event ) => {\n\t\t\t// Bails to avoid obscuring the effect of the preceding handler(s).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tif ( paletteIsOpen ) {\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 closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tif ( ! paletteIsOpen ) {\n\t\treturn false;\n\t}\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\tsize=\"medium\"\n\t\t\tcontentLabel={ __( 'Command palette' ) }\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ inputLabel } loop>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__header-search-icon\"\n\t\t\t\t\t\t\ticon={ inputIcon }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<CommandInput\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetSearch={ setSearch }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List label={ __( 'Command suggestions' ) }>\n\t\t\t\t\t\t{ search && ! loadersLoading && (\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{ ! search && <RecentGroup /> }\n\t\t\t\t\t\t{ ! search && <SuggestionsGroup /> }\n\t\t\t\t\t\t{ search && <ResultsGroup search={ search } /> }\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"],
5
+ "mappings": ";AAAA,SAAS,SAAS,uBAAuB;AACzC,OAAO,UAAU;AACjB,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP;AAAA,EACC,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,2BAA2B;AACpC,SAAS,MAAM,UAAU,WAAW,kBAAkB;AACtD,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AACvB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAkEJ,SA0CD,UAlCG,KARF;AA/DH,IAAM,iBAAiB;AACvB,IAAM,aAAa,GAAI,8BAA+B;AAOtD,IAAM,iBAAiB;AAAA,EACtB,MAAM;AACP;AAKA,IAAM,kBAAkB;AA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oBAAU,CAAE,kBACb,oBAAC,QAAQ,OAAR,EACE,aAAI,mBAAoB,GAC3B;AAAA,UAEC,CAAE,UAAU,oBAAC,eAAY;AAAA,UACzB,CAAE,UAAU,oBAAC,oBAAiB;AAAA,UAC9B,UAAU,oBAAC,gBAAa,QAAkB;AAAA,WAC7C;AAAA,SACD,GACD;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/components/use-recent-commands.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tselect as globalSelect,\n\tdispatch,\n} from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useCallback, useEffect, useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst MAX_RECENTLY_SAVED = 30;\nconst MAX_RECENTLY_DISPLAYED = 5;\nconst EMPTY_ARRAY = [];\nconst EMPTY_SET = new Set();\n\nexport function recordUsage( name ) {\n\tconst current =\n\t\tglobalSelect( preferencesStore ).get(\n\t\t\t'core/commands',\n\t\t\t'recentlyUsed'\n\t\t) ?? [];\n\tconst next = [ name, ...current.filter( ( n ) => n !== name ) ].slice(\n\t\t0,\n\t\tMAX_RECENTLY_SAVED\n\t);\n\tdispatch( preferencesStore ).set( 'core/commands', 'recentlyUsed', next );\n}\n\nexport function useLoaderCollector( hook, name, filterNames, onResolved ) {\n\tconst { setLoaderLoading } = unlock( useDispatch( commandsStore ) );\n\tconst { isLoading: loading, commands = [] } = hook( { search: '' } ) ?? {};\n\n\tuseEffect( () => {\n\t\tsetLoaderLoading( name, loading );\n\t}, [ setLoaderLoading, name, loading ] );\n\n\tconst filtered = filterNames\n\t\t? commands.filter( ( c ) => filterNames.has( c.name ) )\n\t\t: commands;\n\n\tuseEffect( () => {\n\t\tonResolved( name, filtered );\n\t}, [ onResolved, name, filtered ] );\n\n\t// Clear this loader's entries when it unmounts.\n\tuseEffect( () => {\n\t\treturn () => onResolved( name, [] );\n\t}, [ onResolved, name ] );\n}\n\nexport function useRecentCommands() {\n\tconst {\n\t\tcontextualCommands,\n\t\tstaticCommands,\n\t\tcontextualLoaders,\n\t\tstaticLoaders,\n\t\trecentlyUsedNames = EMPTY_ARRAY,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\treturn {\n\t\t\tcontextualCommands: getCommands( true ),\n\t\t\tstaticCommands: getCommands( false ),\n\t\t\tcontextualLoaders: getCommandLoaders( true ),\n\t\t\tstaticLoaders: getCommandLoaders( false ),\n\t\t\trecentlyUsedNames: select( preferencesStore ).get(\n\t\t\t\t'core/commands',\n\t\t\t\t'recentlyUsed'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst [ resolvedMap, setResolvedMap ] = useState( () => new Map() );\n\n\tconst onResolved = useCallback( ( loaderName, cmds ) => {\n\t\tsetResolvedMap( ( prev ) => {\n\t\t\tconst prevCmds = prev.get( loaderName );\n\t\t\tif (\n\t\t\t\tprevCmds &&\n\t\t\t\tprevCmds.length === cmds.length &&\n\t\t\t\tprevCmds.every( ( c, i ) => c.name === cmds[ i ].name )\n\t\t\t) {\n\t\t\t\treturn prev;\n\t\t\t}\n\t\t\tconst next = new Map( prev );\n\t\t\tnext.set( loaderName, cmds );\n\t\t\treturn next;\n\t\t} );\n\t}, [] );\n\n\tconst { recentNames, recentSet } = useMemo( () => {\n\t\tconst names = recentlyUsedNames.slice( 0, MAX_RECENTLY_DISPLAYED );\n\t\treturn { recentNames: names, recentSet: new Set( names ) };\n\t}, [ recentlyUsedNames ] );\n\n\tif ( ! recentlyUsedNames.length ) {\n\t\treturn {\n\t\t\tcommands: [],\n\t\t\tloaders: [],\n\t\t\trecentSet: EMPTY_SET,\n\t\t\tonResolved,\n\t\t};\n\t}\n\n\tconst allStaticCommands = [ ...contextualCommands, ...staticCommands ];\n\tconst loaders = [ ...contextualLoaders, ...staticLoaders ];\n\n\t// Merge static commands with loader-resolved commands.\n\tconst allByName = new Map();\n\tallStaticCommands.forEach( ( c ) => allByName.set( c.name, c ) );\n\tfor ( const cmds of resolvedMap.values() ) {\n\t\tcmds.forEach( ( c ) => {\n\t\t\tif ( ! allByName.has( c.name ) ) {\n\t\t\t\tallByName.set( c.name, c );\n\t\t\t}\n\t\t} );\n\t}\n\t// Return in recency order.\n\tconst commands = recentNames\n\t\t.map( ( n ) => allByName.get( n ) )\n\t\t.filter( Boolean );\n\n\treturn { commands, loaders, recentSet, onResolved };\n}\n"],
5
- "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,OACM;AACP,SAAS,SAAS,wBAAwB;AAC1C,SAAS,aAAa,WAAW,SAAS,gBAAgB;AAK1D,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AAEvB,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAC/B,IAAM,cAAc,CAAC;AACrB,IAAM,YAAY,oBAAI,IAAI;AAEnB,SAAS,YAAa,MAAO;AACnC,QAAM,UACL,aAAc,gBAAiB,EAAE;AAAA,IAChC;AAAA,IACA;AAAA,EACD,KAAK,CAAC;AACP,QAAM,OAAO,CAAE,MAAM,GAAG,QAAQ,OAAQ,CAAE,MAAO,MAAM,IAAK,CAAE,EAAE;AAAA,IAC/D;AAAA,IACA;AAAA,EACD;AACA,WAAU,gBAAiB,EAAE,IAAK,iBAAiB,gBAAgB,IAAK;AACzE;AAEO,SAAS,mBAAoB,MAAM,MAAM,aAAa,YAAa;AACzE,QAAM,EAAE,iBAAiB,IAAI,OAAQ,YAAa,aAAc,CAAE;AAClE,QAAM,EAAE,WAAW,SAAS,WAAW,CAAC,EAAE,IAAI,KAAM,EAAE,QAAQ,GAAG,CAAE,KAAK,CAAC;AAEzE,YAAW,MAAM;AAChB,qBAAkB,MAAM,OAAQ;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,aAAa,UAAU,IAAI,QAAS,MAAM;AACjD,UAAM,QAAQ,kBAAkB,MAAO,GAAG,sBAAuB;AACjE,WAAO,EAAE,aAAa,OAAO,WAAW,IAAI,IAAK,KAAM,EAAE;AAAA,EAC1D,GAAG,CAAE,iBAAkB,CAAE;AAEzB,MAAK,CAAE,kBAAkB,QAAS;AACjC,WAAO;AAAA,MACN,UAAU,CAAC;AAAA,MACX,SAAS,CAAC;AAAA,MACV,WAAW;AAAA,MACX;AAAA,IACD;AAAA,EACD;AAEA,QAAM,oBAAoB,CAAE,GAAG,oBAAoB,GAAG,cAAe;AACrE,QAAM,UAAU,CAAE,GAAG,mBAAmB,GAAG,aAAc;AAGzD,QAAM,YAAY,oBAAI,IAAI;AAC1B,oBAAkB,QAAS,CAAE,MAAO,UAAU,IAAK,EAAE,MAAM,CAAE,CAAE;AAC/D,aAAY,QAAQ,YAAY,OAAO,GAAI;AAC1C,SAAK,QAAS,CAAE,MAAO;AACtB,UAAK,CAAE,UAAU,IAAK,EAAE,IAAK,GAAI;AAChC,kBAAU,IAAK,EAAE,MAAM,CAAE;AAAA,MAC1B;AAAA,IACD,CAAE;AAAA,EACH;AAEA,QAAM,WAAW,YACf,IAAK,CAAE,MAAO,UAAU,IAAK,CAAE,CAAE,EACjC,OAAQ,OAAQ;AAElB,SAAO,EAAE,UAAU,SAAS,WAAW,WAAW;AACnD;",
4
+ "sourcesContent": ["import {\n\tuseSelect,\n\tuseDispatch,\n\tselect as globalSelect,\n\tdispatch,\n} from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useCallback, useEffect, useMemo, useState } from '@wordpress/element';\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst MAX_RECENTLY_SAVED = 30;\nconst MAX_RECENTLY_DISPLAYED = 5;\nconst EMPTY_ARRAY = [];\nconst EMPTY_SET = new Set();\n\nexport function recordUsage( name ) {\n\tconst current =\n\t\tglobalSelect( preferencesStore ).get(\n\t\t\t'core/commands',\n\t\t\t'recentlyUsed'\n\t\t) ?? [];\n\tconst next = [ name, ...current.filter( ( n ) => n !== name ) ].slice(\n\t\t0,\n\t\tMAX_RECENTLY_SAVED\n\t);\n\tdispatch( preferencesStore ).set( 'core/commands', 'recentlyUsed', next );\n}\n\nexport function useLoaderCollector( hook, name, filterNames, onResolved ) {\n\tconst { setLoaderLoading } = unlock( useDispatch( commandsStore ) );\n\tconst { isLoading: loading, commands = [] } = hook( { search: '' } ) ?? {};\n\n\tuseEffect( () => {\n\t\tsetLoaderLoading( name, loading );\n\t}, [ setLoaderLoading, name, loading ] );\n\n\tconst filtered = filterNames\n\t\t? commands.filter( ( c ) => filterNames.has( c.name ) )\n\t\t: commands;\n\n\tuseEffect( () => {\n\t\tonResolved( name, filtered );\n\t}, [ onResolved, name, filtered ] );\n\n\t// Clear this loader's entries when it unmounts.\n\tuseEffect( () => {\n\t\treturn () => onResolved( name, [] );\n\t}, [ onResolved, name ] );\n}\n\nexport function useRecentCommands() {\n\tconst {\n\t\tcontextualCommands,\n\t\tstaticCommands,\n\t\tcontextualLoaders,\n\t\tstaticLoaders,\n\t\trecentlyUsedNames = EMPTY_ARRAY,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\treturn {\n\t\t\tcontextualCommands: getCommands( true ),\n\t\t\tstaticCommands: getCommands( false ),\n\t\t\tcontextualLoaders: getCommandLoaders( true ),\n\t\t\tstaticLoaders: getCommandLoaders( false ),\n\t\t\trecentlyUsedNames: select( preferencesStore ).get(\n\t\t\t\t'core/commands',\n\t\t\t\t'recentlyUsed'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst [ resolvedMap, setResolvedMap ] = useState( () => new Map() );\n\n\tconst onResolved = useCallback( ( loaderName, cmds ) => {\n\t\tsetResolvedMap( ( prev ) => {\n\t\t\tconst prevCmds = prev.get( loaderName );\n\t\t\tif (\n\t\t\t\tprevCmds &&\n\t\t\t\tprevCmds.length === cmds.length &&\n\t\t\t\tprevCmds.every( ( c, i ) => c.name === cmds[ i ].name )\n\t\t\t) {\n\t\t\t\treturn prev;\n\t\t\t}\n\t\t\tconst next = new Map( prev );\n\t\t\tnext.set( loaderName, cmds );\n\t\t\treturn next;\n\t\t} );\n\t}, [] );\n\n\tconst { recentNames, recentSet } = useMemo( () => {\n\t\tconst names = recentlyUsedNames.slice( 0, MAX_RECENTLY_DISPLAYED );\n\t\treturn { recentNames: names, recentSet: new Set( names ) };\n\t}, [ recentlyUsedNames ] );\n\n\tif ( ! recentlyUsedNames.length ) {\n\t\treturn {\n\t\t\tcommands: [],\n\t\t\tloaders: [],\n\t\t\trecentSet: EMPTY_SET,\n\t\t\tonResolved,\n\t\t};\n\t}\n\n\tconst allStaticCommands = [ ...contextualCommands, ...staticCommands ];\n\tconst loaders = [ ...contextualLoaders, ...staticLoaders ];\n\n\t// Merge static commands with loader-resolved commands.\n\tconst allByName = new Map();\n\tallStaticCommands.forEach( ( c ) => allByName.set( c.name, c ) );\n\tfor ( const cmds of resolvedMap.values() ) {\n\t\tcmds.forEach( ( c ) => {\n\t\t\tif ( ! allByName.has( c.name ) ) {\n\t\t\t\tallByName.set( c.name, c );\n\t\t\t}\n\t\t} );\n\t}\n\t// Return in recency order.\n\tconst commands = recentNames\n\t\t.map( ( n ) => allByName.get( n ) )\n\t\t.filter( Boolean );\n\n\treturn { commands, loaders, recentSet, onResolved };\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,OACM;AACP,SAAS,SAAS,wBAAwB;AAC1C,SAAS,aAAa,WAAW,SAAS,gBAAgB;AAC1D,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AAEvB,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAC/B,IAAM,cAAc,CAAC;AACrB,IAAM,YAAY,oBAAI,IAAI;AAEnB,SAAS,YAAa,MAAO;AACnC,QAAM,UACL,aAAc,gBAAiB,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AE,MAAO,UAAU,IAAK,CAAE,CAAE,EACjC,OAAQ,OAAQ;AAElB,SAAO,EAAE,UAAU,SAAS,WAAW,WAAW;AACnD;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/use-command-context.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Sets the active context of the command palette\n *\n * @param {string} context Context to set.\n */\nexport default function useCommandContext( context ) {\n\tconst { getContext } = useSelect( commandsStore );\n\tconst initialContext = useRef( getContext() );\n\tconst { setContext } = unlock( useDispatch( commandsStore ) );\n\n\tuseEffect( () => {\n\t\tsetContext( context );\n\t}, [ context, setContext ] );\n\n\t// This effects ensures that on unmount, we restore the context\n\t// that was set before the component actually mounts.\n\tuseEffect( () => {\n\t\tconst initialContextRef = initialContext.current;\n\t\treturn () => setContext( initialContextRef );\n\t}, [ setContext ] );\n}\n"],
5
- "mappings": ";AAGA,SAAS,WAAW,cAAc;AAClC,SAAS,aAAa,iBAAiB;AAKvC,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AAOR,SAAR,kBAAoC,SAAU;AACpD,QAAM,EAAE,WAAW,IAAI,UAAW,aAAc;AAChD,QAAM,iBAAiB,OAAQ,WAAW,CAAE;AAC5C,QAAM,EAAE,WAAW,IAAI,OAAQ,YAAa,aAAc,CAAE;AAE5D,YAAW,MAAM;AAChB,eAAY,OAAQ;AAAA,EACrB,GAAG,CAAE,SAAS,UAAW,CAAE;AAI3B,YAAW,MAAM;AAChB,UAAM,oBAAoB,eAAe;AACzC,WAAO,MAAM,WAAY,iBAAkB;AAAA,EAC5C,GAAG,CAAE,UAAW,CAAE;AACnB;",
4
+ "sourcesContent": ["import { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Sets the active context of the command palette\n *\n * @param {string} context Context to set.\n */\nexport default function useCommandContext( context ) {\n\tconst { getContext } = useSelect( commandsStore );\n\tconst initialContext = useRef( getContext() );\n\tconst { setContext } = unlock( useDispatch( commandsStore ) );\n\n\tuseEffect( () => {\n\t\tsetContext( context );\n\t}, [ context, setContext ] );\n\n\t// This effects ensures that on unmount, we restore the context\n\t// that was set before the component actually mounts.\n\tuseEffect( () => {\n\t\tconst initialContextRef = initialContext.current;\n\t\treturn () => setContext( initialContextRef );\n\t}, [ setContext ] );\n}\n"],
5
+ "mappings": ";AAAA,SAAS,WAAW,cAAc;AAClC,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AAOR,SAAR,kBAAoC,SAAU;AACpD,QAAM,EAAE,WAAW,IAAI,UAAW,aAAc;AAChD,QAAM,iBAAiB,OAAQ,WAAW,CAAE;AAC5C,QAAM,EAAE,WAAW,IAAI,OAAQ,YAAa,aAAc,CAAE;AAE5D,YAAW,MAAM;AAChB,eAAY,OAAQ;AAAA,EACrB,GAAG,CAAE,SAAS,UAAW,CAAE;AAI3B,YAAW,MAAM;AAChB,UAAM,oBAAoB,eAAe;AACzC,WAAO,MAAM,WAAY,iBAAkB;AAAA,EAC5C,GAAG,CAAE,UAAW,CAAE;AACnB;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/use-command-loader.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette. Used for dynamic commands.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { addQueryArgs } from '@wordpress/url';\n * import { useCommandLoader } from '@wordpress/commands';\n * import { page } from '@wordpress/icons';\n * import { useSelect } from '@wordpress/data';\n * import { store as coreStore } from '@wordpress/core-data';\n * import { useMemo } from '@wordpress/element';\n *\n * function usePageSearchCommandLoader( { search } ) {\n * // Retrieve the pages for the \"search\" term.\n * const { records, isLoading } = useSelect(\n * ( select ) => {\n * const { getEntityRecords } = select( coreStore );\n * const query = {\n * search: !! search ? search : undefined,\n * per_page: 10,\n * orderby: search ? 'relevance' : 'date',\n * };\n * return {\n * records: getEntityRecords( 'postType', 'page', query ),\n * isLoading: ! select( coreStore ).hasFinishedResolution(\n * 'getEntityRecords',\n * [ 'postType', 'page', query ]\n * ),\n * };\n * },\n * [ search ]\n * );\n *\n * // Create the commands.\n * const commands = useMemo( () => {\n * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n * return {\n * name: record.title?.rendered + ' ' + record.id,\n * label: record.title?.rendered\n * ? record.title?.rendered\n * : __( '(no title)' ),\n * icon: page,\n * category: 'edit',\n * callback: ( { close } ) => {\n * const args = {\n * \t\t\t\t\t\t\tp: '/page',\n * \t\t\t\t\t\t\tpostId: record.id,\n * };\n * document.location = addQueryArgs( 'site-editor.php', args );\n * close();\n * },\n * };\n * } );\n * }, [ records ] );\n *\n * return {\n * commands,\n * isLoading,\n * };\n * }\n *\n * useCommandLoader( {\n * name: 'myplugin/page-search',\n * hook: usePageSearchCommandLoader,\n * } );\n * ```\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tif ( loader.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t\tcategory: loader.category,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tloader.category,\n\t\tloader.disabled,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],
5
- "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAK5B,SAAS,SAAS,qBAAqB;AAwExB,SAAR,iBAAmC,QAAS;AAClD,QAAM,EAAE,uBAAuB,wBAAwB,IACtD,YAAa,aAAc;AAC5B,YAAW,MAAM;AAChB,QAAK,OAAO,UAAW;AACtB;AAAA,IACD;AACA,0BAAuB;AAAA,MACtB,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,IAClB,CAAE;AACF,WAAO,MAAM;AACZ,8BAAyB,OAAO,IAAK;AAAA,IACtC;AAAA,EACD,GAAG;AAAA,IACF,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
4
+ "sourcesContent": ["import { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette. Used for dynamic commands.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { addQueryArgs } from '@wordpress/url';\n * import { useCommandLoader } from '@wordpress/commands';\n * import { page } from '@wordpress/icons';\n * import { useSelect } from '@wordpress/data';\n * import { store as coreStore } from '@wordpress/core-data';\n * import { useMemo } from '@wordpress/element';\n *\n * function usePageSearchCommandLoader( { search } ) {\n * // Retrieve the pages for the \"search\" term.\n * const { records, isLoading } = useSelect(\n * ( select ) => {\n * const { getEntityRecords } = select( coreStore );\n * const query = {\n * search: !! search ? search : undefined,\n * per_page: 10,\n * orderby: search ? 'relevance' : 'date',\n * };\n * return {\n * records: getEntityRecords( 'postType', 'page', query ),\n * isLoading: ! select( coreStore ).hasFinishedResolution(\n * 'getEntityRecords',\n * [ 'postType', 'page', query ]\n * ),\n * };\n * },\n * [ search ]\n * );\n *\n * // Create the commands.\n * const commands = useMemo( () => {\n * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n * return {\n * name: record.title?.rendered + ' ' + record.id,\n * label: record.title?.rendered\n * ? record.title?.rendered\n * : __( '(no title)' ),\n * icon: page,\n * category: 'edit',\n * callback: ( { close } ) => {\n * const args = {\n * \t\t\t\t\t\t\tp: '/page',\n * \t\t\t\t\t\t\tpostId: record.id,\n * };\n * document.location = addQueryArgs( 'site-editor.php', args );\n * close();\n * },\n * };\n * } );\n * }, [ records ] );\n *\n * return {\n * commands,\n * isLoading,\n * };\n * }\n *\n * useCommandLoader( {\n * name: 'myplugin/page-search',\n * hook: usePageSearchCommandLoader,\n * } );\n * ```\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tif ( loader.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t\tcategory: loader.category,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tloader.category,\n\t\tloader.disabled,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],
5
+ "mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,SAAS,qBAAqB;AAwExB,SAAR,iBAAmC,QAAS;AAClD,QAAM,EAAE,uBAAuB,wBAAwB,IACtD,YAAa,aAAc;AAC5B,YAAW,MAAM;AAChB,QAAK,OAAO,UAAW;AACtB;AAAA,IACD;AACA,0BAAuB;AAAA,MACtB,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,IAClB,CAAE;AACF,WAAO,MAAM;AACZ,8BAAyB,OAAO,IAAK;AAAA,IACtC;AAAA,EACD,GAAG;AAAA,IACF,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/use-command.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n *\n * @example\n * ```js\n * import { useCommand } from '@wordpress/commands';\n * import { plus } from '@wordpress/icons';\n *\n * useCommand( {\n * name: 'myplugin/my-command-name',\n * label: __( 'Add new post' ),\n *\t icon: plus,\n * category: 'command',\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * } );\n * ```\n */\nexport function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbackRef = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallbackRef.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\n\t\tif ( command.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommand( {\n\t\t\tname: command.name,\n\t\t\tcontext: command.context,\n\t\t\tcategory: command.category,\n\t\t\tlabel: command.label,\n\t\t\tsearchLabel: command.searchLabel,\n\t\t\ticon: command.icon,\n\t\t\tkeywords: command.keywords,\n\t\t\tcallback: ( ...args ) => currentCallbackRef.current( ...args ),\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommand( command.name );\n\t\t};\n\t}, [\n\t\tcommand.name,\n\t\tcommand.label,\n\t\tcommand.searchLabel,\n\t\tcommand.icon,\n\t\tcommand.context,\n\t\tcommand.category,\n\t\tcommand.keywords,\n\t\tcommand.disabled,\n\t\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n\n/**\n * Attach multiple commands to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig[]} commands Array of command configs.\n *\n * @example\n * ```js\n * import { useCommands } from '@wordpress/commands';\n * import { plus, pencil } from '@wordpress/icons';\n *\n * useCommands( [\n * {\n * name: 'myplugin/add-post',\n * label: __( 'Add new post' ),\n * icon: plus,\n * category: 'command',\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * },\n * {\n * name: 'myplugin/edit-posts',\n * label: __( 'Edit posts' ),\n * icon: pencil,\n * category: 'view',\n * callback: ({ close }) => {\n * document.location.href = 'edit.php';\n * close();\n * },\n * },\n * ] );\n * ```\n */\nexport function useCommands( commands ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbacksRef = useRef( {} );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.callback ) {\n\t\t\t\tcurrentCallbacksRef.current[ command.name ] = command.callback;\n\t\t\t}\n\t\t} );\n\t}, [ commands ] );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tregisterCommand( {\n\t\t\t\tname: command.name,\n\t\t\t\tcontext: command.context,\n\t\t\t\tcategory: command.category,\n\t\t\t\tlabel: command.label,\n\t\t\t\tsearchLabel: command.searchLabel,\n\t\t\t\ticon: command.icon,\n\t\t\t\tkeywords: command.keywords,\n\t\t\t\tcallback: ( ...args ) => {\n\t\t\t\t\tconst callback =\n\t\t\t\t\t\tcurrentCallbacksRef.current[ command.name ];\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tcallback( ...args );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tcommands.forEach( ( command ) => {\n\t\t\t\tunregisterCommand( command.name );\n\t\t\t} );\n\t\t};\n\t}, [ commands, registerCommand, unregisterCommand ] );\n}\n"],
5
- "mappings": ";AAGA,SAAS,WAAW,cAAc;AAClC,SAAS,mBAAmB;AAK5B,SAAS,SAAS,qBAAqB;AAwBhC,SAAS,WAAY,SAAU;AACrC,QAAM,EAAE,iBAAiB,kBAAkB,IAAI,YAAa,aAAc;AAC1E,QAAM,qBAAqB,OAAQ,QAAQ,QAAS;AACpD,YAAW,MAAM;AAChB,uBAAmB,UAAU,QAAQ;AAAA,EACtC,GAAG,CAAE,QAAQ,QAAS,CAAE;AAExB,YAAW,MAAM;AAChB,QAAK,QAAQ,UAAW;AACvB;AAAA,IACD;AACA,oBAAiB;AAAA,MAChB,MAAM,QAAQ;AAAA,MACd,SAAS,QAAQ;AAAA,MACjB,UAAU,QAAQ;AAAA,MAClB,OAAO,QAAQ;AAAA,MACf,aAAa,QAAQ;AAAA,MACrB,MAAM,QAAQ;AAAA,MACd,UAAU,QAAQ;AAAA,MAClB,UAAU,IAAK,SAAU,mBAAmB,QAAS,GAAG,IAAK;AAAA,IAC9D,CAAE;AACF,WAAO,MAAM;AACZ,wBAAmB,QAAQ,IAAK;AAAA,IACjC;AAAA,EACD,GAAG;AAAA,IACF,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EACD,CAAE;AACH;AAoCO,SAAS,YAAa,UAAW;AACvC,QAAM,EAAE,iBAAiB,kBAAkB,IAAI,YAAa,aAAc;AAC1E,QAAM,sBAAsB,OAAQ,CAAC,CAAE;AAEvC,YAAW,MAAM;AAChB,QAAK,CAAE,UAAW;AACjB;AAAA,IACD;AACA,aAAS,QAAS,CAAE,YAAa;AAChC,UAAK,QAAQ,UAAW;AACvB,4BAAoB,QAAS,QAAQ,IAAK,IAAI,QAAQ;AAAA,MACvD;AAAA,IACD,CAAE;AAAA,EACH,GAAG,CAAE,QAAS,CAAE;AAEhB,YAAW,MAAM;AAChB,QAAK,CAAE,UAAW;AACjB;AAAA,IACD;AACA,aAAS,QAAS,CAAE,YAAa;AAChC,UAAK,QAAQ,UAAW;AACvB;AAAA,MACD;AACA,sBAAiB;AAAA,QAChB,MAAM,QAAQ;AAAA,QACd,SAAS,QAAQ;AAAA,QACjB,UAAU,QAAQ;AAAA,QAClB,OAAO,QAAQ;AAAA,QACf,aAAa,QAAQ;AAAA,QACrB,MAAM,QAAQ;AAAA,QACd,UAAU,QAAQ;AAAA,QAClB,UAAU,IAAK,SAAU;AACxB,gBAAM,WACL,oBAAoB,QAAS,QAAQ,IAAK;AAC3C,cAAK,UAAW;AACf,qBAAU,GAAG,IAAK;AAAA,UACnB;AAAA,QACD;AAAA,MACD,CAAE;AAAA,IACH,CAAE;AAEF,WAAO,MAAM;AACZ,eAAS,QAAS,CAAE,YAAa;AAChC,0BAAmB,QAAQ,IAAK;AAAA,MACjC,CAAE;AAAA,IACH;AAAA,EACD,GAAG,CAAE,UAAU,iBAAiB,iBAAkB,CAAE;AACrD;",
4
+ "sourcesContent": ["import { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n *\n * @example\n * ```js\n * import { useCommand } from '@wordpress/commands';\n * import { plus } from '@wordpress/icons';\n *\n * useCommand( {\n * name: 'myplugin/my-command-name',\n * label: __( 'Add new post' ),\n *\t icon: plus,\n * category: 'command',\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * } );\n * ```\n */\nexport function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbackRef = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallbackRef.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\n\t\tif ( command.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommand( {\n\t\t\tname: command.name,\n\t\t\tcontext: command.context,\n\t\t\tcategory: command.category,\n\t\t\tlabel: command.label,\n\t\t\tsearchLabel: command.searchLabel,\n\t\t\ticon: command.icon,\n\t\t\tkeywords: command.keywords,\n\t\t\tcallback: ( ...args ) => currentCallbackRef.current( ...args ),\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommand( command.name );\n\t\t};\n\t}, [\n\t\tcommand.name,\n\t\tcommand.label,\n\t\tcommand.searchLabel,\n\t\tcommand.icon,\n\t\tcommand.context,\n\t\tcommand.category,\n\t\tcommand.keywords,\n\t\tcommand.disabled,\n\t\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n\n/**\n * Attach multiple commands to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig[]} commands Array of command configs.\n *\n * @example\n * ```js\n * import { useCommands } from '@wordpress/commands';\n * import { plus, pencil } from '@wordpress/icons';\n *\n * useCommands( [\n * {\n * name: 'myplugin/add-post',\n * label: __( 'Add new post' ),\n * icon: plus,\n * category: 'command',\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * },\n * {\n * name: 'myplugin/edit-posts',\n * label: __( 'Edit posts' ),\n * icon: pencil,\n * category: 'view',\n * callback: ({ close }) => {\n * document.location.href = 'edit.php';\n * close();\n * },\n * },\n * ] );\n * ```\n */\nexport function useCommands( commands ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbacksRef = useRef( {} );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.callback ) {\n\t\t\t\tcurrentCallbacksRef.current[ command.name ] = command.callback;\n\t\t\t}\n\t\t} );\n\t}, [ commands ] );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tregisterCommand( {\n\t\t\t\tname: command.name,\n\t\t\t\tcontext: command.context,\n\t\t\t\tcategory: command.category,\n\t\t\t\tlabel: command.label,\n\t\t\t\tsearchLabel: command.searchLabel,\n\t\t\t\ticon: command.icon,\n\t\t\t\tkeywords: command.keywords,\n\t\t\t\tcallback: ( ...args ) => {\n\t\t\t\t\tconst callback =\n\t\t\t\t\t\tcurrentCallbacksRef.current[ command.name ];\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tcallback( ...args );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tcommands.forEach( ( command ) => {\n\t\t\t\tunregisterCommand( command.name );\n\t\t\t} );\n\t\t};\n\t}, [ commands, registerCommand, unregisterCommand ] );\n}\n"],
5
+ "mappings": ";AAAA,SAAS,WAAW,cAAc;AAClC,SAAS,mBAAmB;AAC5B,SAAS,SAAS,qBAAqB;AAwBhC,SAAS,WAAY,SAAU;AACrC,QAAM,EAAE,iBAAiB,kBAAkB,IAAI,YAAa,aAAc;AAC1E,QAAM,qBAAqB,OAAQ,QAAQ,QAAS;AACpD,YAAW,MAAM;AAChB,uBAAmB,UAAU,QAAQ;AAAA,EACtC,GAAG,CAAE,QAAQ,QAAS,CAAE;AAExB,YAAW,MAAM;AAChB,QAAK,QAAQ,UAA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U;AACxB,gBAAM,WACL,oBAAoB,QAAS,QAAQ,IAAK;AAC3C,cAAK,UAAW;AACf,qBAAU,GAAG,IAAK;AAAA,UACnB;AAAA,QACD;AAAA,MACD,CAAE;AAAA,IACH,CAAE;AAEF,WAAO,MAAM;AACZ,eAAS,QAAS,CAAE,YAAa;AAChC,0BAAmB,QAAQ,IAAK;AAAA,MACjC,CAAE;AAAA,IACH;AAAA,EACD,GAAG,CAAE,UAAU,iBAAiB,iBAAkB,CAAE;AACrD;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/lock-unlock.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/commands'\n\t);\n"],
5
- "mappings": ";AAGA,SAAS,wDAAwD;AAE1D,IAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
4
+ "sourcesContent": ["import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/commands'\n\t);\n"],
5
+ "mappings": ";AAAA,SAAS,wDAAwD;AAE1D,IAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/private-apis.js"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { default as useCommandContext } from './hooks/use-command-context';\nimport { lock } from './lock-unlock';\n\n/**\n * @private\n */\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommandContext,\n} );\n"],
5
- "mappings": ";AAGA,SAAS,WAAW,yBAAyB;AAC7C,SAAS,YAAY;AAKd,IAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AACD,CAAE;",
4
+ "sourcesContent": ["import { default as useCommandContext } from './hooks/use-command-context';\nimport { lock } from './lock-unlock';\n\n/**\n * @private\n */\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommandContext,\n} );\n"],
5
+ "mappings": ";AAAA,SAAS,WAAW,yBAAyB;AAC7C,SAAS,YAAY;AAKd,IAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AACD,CAAE;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport * as privateActions from './private-actions';\nimport * as privateSelectors from './private-selectors';\nimport { unlock } from '../lock-unlock';\n\nconst STORE_NAME = 'core/commands';\n\n/**\n * Store definition for the commands namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n *\n * @example\n * ```js\n * import { store as commandsStore } from '@wordpress/commands';\n * import { useDispatch } from '@wordpress/data';\n * ...\n * const { open: openCommandCenter } = useDispatch( commandsStore );\n * ```\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\nunlock( store ).registerPrivateActions( privateActions );\nunlock( store ).registerPrivateSelectors( privateSelectors );\n"],
5
- "mappings": ";AAGA,SAAS,kBAAkB,gBAAgB;AAK3C,OAAO,aAAa;AACpB,YAAY,aAAa;AACzB,YAAY,eAAe;AAC3B,YAAY,oBAAoB;AAChC,YAAY,sBAAsB;AAClC,SAAS,cAAc;AAEvB,IAAM,aAAa;AAiBZ,IAAM,QAAQ,iBAAkB,YAAY;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,SAAU,KAAM;AAChB,OAAQ,KAAM,EAAE,uBAAwB,cAAe;AACvD,OAAQ,KAAM,EAAE,yBAA0B,gBAAiB;",
4
+ "sourcesContent": ["import { createReduxStore, register } from '@wordpress/data';\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport * as privateActions from './private-actions';\nimport * as privateSelectors from './private-selectors';\nimport { unlock } from '../lock-unlock';\n\nconst STORE_NAME = 'core/commands';\n\n/**\n * Store definition for the commands namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n *\n * @example\n * ```js\n * import { store as commandsStore } from '@wordpress/commands';\n * import { useDispatch } from '@wordpress/data';\n * ...\n * const { open: openCommandCenter } = useDispatch( commandsStore );\n * ```\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\nunlock( store ).registerPrivateActions( privateActions );\nunlock( store ).registerPrivateSelectors( privateSelectors );\n"],
5
+ "mappings": ";AAAA,SAAS,kBAAkB,gBAAgB;AAC3C,OAAO,aAAa;AACpB,YAAY,aAAa;AACzB,YAAY,eAAe;AAC3B,YAAY,oBAAoB;AAChC,YAAY,sBAAsB;AAClC,SAAS,cAAc;AAEvB,IAAM,aAAa;AAiBZ,IAAM,QAAQ,iBAAkB,YAAY;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,SAAU,KAAM;AAChB,OAAQ,KAAM,EAAE,uBAAwB,cAAe;AACvD,OAAQ,KAAM,EAAE,yBAA0B,gBAAiB;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/reducer.js"],
4
- "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\tcategory: action.category,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t\tkeywords: action.keywords,\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\tcategory: action.category,\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\nfunction loaderStates( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_LOADER_LOADING':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: action.isLoading,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n\tloaderStates,\n} );\n\nexport default reducer;\n"],
5
- "mappings": ";AAGA,SAAS,uBAAuB;AAUhC,SAAS,SAAU,QAAQ,CAAC,GAAG,QAAS;AACvC,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG;AAAA,UAChB,MAAM,OAAO;AAAA,UACb,OAAO,OAAO;AAAA,UACd,aAAa,OAAO;AAAA,UACpB,SAAS,OAAO;AAAA,UAChB,UAAU,OAAO;AAAA,UACjB,UAAU,OAAO;AAAA,UACjB,MAAM,OAAO;AAAA,UACb,UAAU,OAAO;AAAA,QAClB;AAAA,MACD;AAAA,IACD,KAAK,sBAAsB;AAC1B,YAAM,EAAE,CAAE,OAAO,IAAK,GAAG,GAAG,GAAG,eAAe,IAAI;AAClD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,eAAgB,QAAQ,CAAC,GAAG,QAAS;AAC7C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG;AAAA,UAChB,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,UAChB,UAAU,OAAO;AAAA,UACjB,MAAM,OAAO;AAAA,QACd;AAAA,MACD;AAAA,IACD,KAAK,6BAA6B;AACjC,YAAM,EAAE,CAAE,OAAO,IAAK,GAAG,GAAG,GAAG,eAAe,IAAI;AAClD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,OAAQ,QAAQ,OAAO,QAAS;AACxC,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,EACT;AAEA,SAAO;AACR;AAUA,SAAS,QAAS,QAAQ,QAAQ,QAAS;AAC1C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,OAAO;AAAA,EAChB;AAEA,SAAO;AACR;AAEA,SAAS,aAAc,QAAQ,CAAC,GAAG,QAAS;AAC3C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG,OAAO;AAAA,MACzB;AAAA,EACF;AAEA,SAAO;AACR;AAEA,IAAM,UAAU,gBAAiB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,IAAO,kBAAQ;",
4
+ "sourcesContent": ["import { 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\tcategory: action.category,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t\tkeywords: action.keywords,\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\tcategory: action.category,\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\nfunction loaderStates( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_LOADER_LOADING':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: action.isLoading,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {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AAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,OAAO;AAAA,EAChB;AAEA,SAAO;AACR;AAEA,SAAS,aAAc,QAAQ,CAAC,GAAG,QAAS;AAC3C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG,OAAO;AAAA,MACzB;AAAA,EACF;AAEA,SAAO;AACR;AAEA,IAAM,UAAU,gBAAiB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,IAAO,kBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/selectors.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector } from '@wordpress/data';\n\n/**\n * Returns the registered static commands.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual commands.\n *\n * @return {import('./actions').WPCommandConfig[]} The list of registered commands.\n */\nexport const getCommands = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commands ).filter( ( command ) => {\n\t\t\tconst isContextual =\n\t\t\t\tcommand.context && command.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commands, state.context ]\n);\n\n/**\n * Returns the registered command loaders.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual command loaders.\n *\n * @return {import('./actions').WPCommandLoaderConfig[]} The list of registered command loaders.\n */\nexport const getCommandLoaders = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commandLoaders ).filter( ( loader ) => {\n\t\t\tconst isContextual =\n\t\t\t\tloader.context && loader.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commandLoaders, state.context ]\n);\n\n/**\n * Returns whether the command palette is open.\n *\n * @param {Object} state State tree.\n *\n * @return {boolean} Returns whether the command palette is open.\n */\nexport function isOpen( state ) {\n\treturn state.isOpen;\n}\n\n/**\n * Returns whether the active context.\n *\n * @param {Object} state State tree.\n *\n * @return {string} Context.\n */\nexport function getContext( state ) {\n\treturn state.context;\n}\n"],
5
- "mappings": ";AAGA,SAAS,sBAAsB;AAUxB,IAAM,cAAc;AAAA,EAC1B,CAAE,OAAO,aAAa,UACrB,OAAO,OAAQ,MAAM,QAAS,EAAE,OAAQ,CAAE,YAAa;AACtD,UAAM,eACL,QAAQ,WAAW,QAAQ,YAAY,MAAM;AAC9C,WAAO,aAAa,eAAe,CAAE;AAAA,EACtC,CAAE;AAAA,EACH,CAAE,UAAW,CAAE,MAAM,UAAU,MAAM,OAAQ;AAC9C;AAUO,IAAM,oBAAoB;AAAA,EAChC,CAAE,OAAO,aAAa,UACrB,OAAO,OAAQ,MAAM,cAAe,EAAE,OAAQ,CAAE,WAAY;AAC3D,UAAM,eACL,OAAO,WAAW,OAAO,YAAY,MAAM;AAC5C,WAAO,aAAa,eAAe,CAAE;AAAA,EACtC,CAAE;AAAA,EACH,CAAE,UAAW,CAAE,MAAM,gBAAgB,MAAM,OAAQ;AACpD;AASO,SAAS,OAAQ,OAAQ;AAC/B,SAAO,MAAM;AACd;AASO,SAAS,WAAY,OAAQ;AACnC,SAAO,MAAM;AACd;",
4
+ "sourcesContent": ["import { createSelector } from '@wordpress/data';\n\n/**\n * Returns the registered static commands.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual commands.\n *\n * @return {import('./actions').WPCommandConfig[]} The list of registered commands.\n */\nexport const getCommands = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commands ).filter( ( command ) => {\n\t\t\tconst isContextual =\n\t\t\t\tcommand.context && command.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commands, state.context ]\n);\n\n/**\n * Returns the registered command loaders.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual command loaders.\n *\n * @return {import('./actions').WPCommandLoaderConfig[]} The list of registered command loaders.\n */\nexport const getCommandLoaders = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commandLoaders ).filter( ( loader ) => {\n\t\t\tconst isContextual =\n\t\t\t\tloader.context && loader.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commandLoaders, state.context ]\n);\n\n/**\n * Returns whether the command palette is open.\n *\n * @param {Object} state State tree.\n *\n * @return {boolean} Returns whether the command palette is open.\n */\nexport function isOpen( state ) {\n\treturn state.isOpen;\n}\n\n/**\n * Returns whether the active context.\n *\n * @param {Object} state State tree.\n *\n * @return {string} Context.\n */\nexport function getContext( state ) {\n\treturn state.context;\n}\n"],
5
+ "mappings": ";AAAA,SAAS,sBAAsB;AAUxB,IAAM,cAAc;AAAA,EAC1B,CAAE,OAAO,aAAa,UACrB,OAAO,OAAQ,MAAM,QAAS,EAAE,OAAQ,CAAE,YAAa;AACtD,UAAM,eACL,QAAQ,WAAW,QAAQ,YAAY,MAAM;AAC9C,WAAO,aAAa,eAAe,CAAE;AAAA,EACtC,CAAE;AAAA,EACH,CAAE,UAAW,CAAE,MAAM,UAAU,MAAM,OAAQ;AAC9C;AAUO,IAAM,oBAAoB;AAAA,EAChC,CAAE,OAAO,aAAa,UACrB,OAAO,OAAQ,MAAM,cAAe,EAAE,OAAQ,CAAE,WAAY;AAC3D,UAAM,eACL,OAAO,WAAW,OAAO,YAAY,MAAM;AAC5C,WAAO,aAAa,eAAe,CAAE;AAAA,EACtC,CAAE;AAAA,EACH,CAAE,UAAW,CAAE,MAAM,gBAAgB,MAAM,OAAQ;AACpD;AASO,SAAS,OAAQ,OAAQ;AAC/B,SAAO,MAAM;AACd;AASO,SAAS,WAAY,OAAQ;AACnC,SAAO,MAAM;AACd;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/commands",
3
- "version": "1.52.0",
3
+ "version": "1.53.0",
4
4
  "description": "Handles the commands menu.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -43,16 +43,17 @@
43
43
  },
44
44
  "wpScript": true,
45
45
  "dependencies": {
46
- "@wordpress/base-styles": "^12.0.0",
47
- "@wordpress/components": "^38.0.0",
48
- "@wordpress/data": "^10.52.0",
49
- "@wordpress/element": "^8.4.0",
50
- "@wordpress/i18n": "^6.25.0",
51
- "@wordpress/icons": "^15.3.0",
52
- "@wordpress/keyboard-shortcuts": "^5.52.0",
53
- "@wordpress/preferences": "^4.52.0",
54
- "@wordpress/private-apis": "^1.52.0",
55
- "@wordpress/warning": "^3.52.0",
46
+ "@wordpress/base-styles": "^12.1.0",
47
+ "@wordpress/components": "^39.0.0",
48
+ "@wordpress/data": "^10.53.0",
49
+ "@wordpress/element": "^8.5.0",
50
+ "@wordpress/i18n": "^6.26.0",
51
+ "@wordpress/icons": "^15.4.0",
52
+ "@wordpress/keyboard-shortcuts": "^5.53.0",
53
+ "@wordpress/keycodes": "^4.53.0",
54
+ "@wordpress/preferences": "^4.53.0",
55
+ "@wordpress/private-apis": "^1.53.0",
56
+ "@wordpress/warning": "^3.53.0",
56
57
  "clsx": "^2.1.1",
57
58
  "cmdk": "^1.0.0"
58
59
  },
@@ -63,5 +64,5 @@
63
64
  "publishConfig": {
64
65
  "access": "public"
65
66
  },
66
- "gitHead": "7e8b17a983f9391d3ebc7717af2a1c9ed7efc7ab"
67
+ "gitHead": "989764d42ff93e33684aaf0b96a5b7f3d9bbff52"
67
68
  }
@@ -1,12 +1,5 @@
1
- /**
2
- * External dependencies
3
- */
4
1
  import { Command, useCommandState } from 'cmdk';
5
2
  import clsx from 'clsx';
6
-
7
- /**
8
- * WordPress dependencies
9
- */
10
3
  import { useSelect, useDispatch } from '@wordpress/data';
11
4
  import {
12
5
  useState,
@@ -20,17 +13,13 @@ import {
20
13
  Modal,
21
14
  TextHighlight,
22
15
  __experimentalHStack as HStack,
23
- privateApis as componentsPrivateApis,
24
16
  } from '@wordpress/components';
25
17
  import {
26
18
  store as keyboardShortcutsStore,
27
19
  useShortcut,
28
20
  } from '@wordpress/keyboard-shortcuts';
21
+ import { withIgnoreIMEEvents } from '@wordpress/keycodes';
29
22
  import { Icon, search as inputIcon, arrowRight } from '@wordpress/icons';
30
-
31
- /**
32
- * Internal dependencies
33
- */
34
23
  import { store as commandsStore } from '../store';
35
24
  import { unlock } from '../lock-unlock';
36
25
  import {
@@ -39,8 +28,6 @@ import {
39
28
  useRecentCommands,
40
29
  } from './use-recent-commands';
41
30
 
42
- const { withIgnoreIMEEvents } = unlock( componentsPrivateApis );
43
-
44
31
  // Namespaces item ids to avoid collisions with other elements on the page.
45
32
  const ITEM_ID_PREFIX = 'command-palette-item-';
46
33
  const inputLabel = __( 'Search commands and settings' );
@@ -1,6 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import {
5
2
  useSelect,
6
3
  useDispatch,
@@ -9,10 +6,6 @@ import {
9
6
  } from '@wordpress/data';
10
7
  import { store as preferencesStore } from '@wordpress/preferences';
11
8
  import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
9
  import { store as commandsStore } from '../store';
17
10
  import { unlock } from '../lock-unlock';
18
11
 
@@ -1,12 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { useEffect, useRef } from '@wordpress/element';
5
2
  import { useDispatch, useSelect } from '@wordpress/data';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
3
  import { store as commandsStore } from '../store';
11
4
  import { unlock } from '../lock-unlock';
12
5
 
@@ -1,12 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { useEffect } from '@wordpress/element';
5
2
  import { useDispatch } from '@wordpress/data';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
3
  import { store as commandsStore } from '../store';
11
4
 
12
5
  /**
@@ -1,12 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { useEffect, useRef } from '@wordpress/element';
5
2
  import { useDispatch } from '@wordpress/data';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
3
  import { store as commandsStore } from '../store';
11
4
 
12
5
  /**
@@ -1,6 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
5
2
 
6
3
  export const { lock, unlock } =
@@ -1,6 +1,3 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  import { default as useCommandContext } from './hooks/use-command-context';
5
2
  import { lock } from './lock-unlock';
6
3
 
@@ -1,11 +1,4 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { createReduxStore, register } from '@wordpress/data';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
2
  import reducer from './reducer';
10
3
  import * as actions from './actions';
11
4
  import * as selectors from './selectors';
@@ -1,6 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { combineReducers } from '@wordpress/data';
5
2
 
6
3
  /**
@@ -1,6 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { createSelector } from '@wordpress/data';
5
2
 
6
3
  /**