@wordpress/commands 0.28.0 → 1.0.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.
- package/CHANGELOG.md +12 -0
- package/build/components/command-menu.js +96 -81
- package/build/components/command-menu.js.map +1 -1
- package/build-module/components/command-menu.js +98 -81
- package/build-module/components/command-menu.js.map +1 -1
- package/package.json +12 -11
- package/src/components/command-menu.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.0.0 (2024-05-31)
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- Increase the minimum required Node.js version to v18.12.0 matching long-term support releases ([#31270](https://github.com/WordPress/gutenberg/pull/61930)). Learn more about [Node.js releases](https://nodejs.org/en/about/previous-releases).
|
|
10
|
+
|
|
11
|
+
## 0.29.0 (2024-05-16)
|
|
12
|
+
|
|
13
|
+
### Internal
|
|
14
|
+
|
|
15
|
+
- Replaced `classnames` package with the faster and smaller `clsx` package ([#61138](https://github.com/WordPress/gutenberg/pull/61138)).
|
|
16
|
+
|
|
5
17
|
## 0.28.0 (2024-05-02)
|
|
6
18
|
|
|
7
19
|
## 0.27.0 (2024-04-19)
|
|
@@ -7,9 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.CommandMenu = CommandMenu;
|
|
8
8
|
exports.CommandMenuGroup = CommandMenuGroup;
|
|
9
9
|
exports.CommandMenuLoaderWrapper = CommandMenuLoaderWrapper;
|
|
10
|
-
var _react = require("react");
|
|
11
10
|
var _cmdk = require("cmdk");
|
|
12
|
-
var
|
|
11
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
12
|
var _data = require("@wordpress/data");
|
|
14
13
|
var _element = require("@wordpress/element");
|
|
15
14
|
var _i18n = require("@wordpress/i18n");
|
|
@@ -17,6 +16,7 @@ var _components = require("@wordpress/components");
|
|
|
17
16
|
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
18
17
|
var _icons = require("@wordpress/icons");
|
|
19
18
|
var _store = require("../store");
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
20
|
/**
|
|
21
21
|
* External dependencies
|
|
22
22
|
*/
|
|
@@ -50,27 +50,32 @@ function CommandMenuLoader({
|
|
|
50
50
|
if (!commands.length) {
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
|
-
return (0,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
53
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
54
|
+
children: commands.map(command => {
|
|
55
|
+
var _command$searchLabel;
|
|
56
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_cmdk.Command.Item, {
|
|
57
|
+
value: (_command$searchLabel = command.searchLabel) !== null && _command$searchLabel !== void 0 ? _command$searchLabel : command.label,
|
|
58
|
+
onSelect: () => command.callback({
|
|
59
|
+
close
|
|
60
|
+
}),
|
|
61
|
+
id: command.name,
|
|
62
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
63
|
+
alignment: "left",
|
|
64
|
+
className: (0, _clsx.default)('commands-command-menu__item', {
|
|
65
|
+
'has-icon': command.icon
|
|
66
|
+
}),
|
|
67
|
+
children: [command.icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
68
|
+
icon: command.icon
|
|
69
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
70
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextHighlight, {
|
|
71
|
+
text: command.label,
|
|
72
|
+
highlight: search
|
|
73
|
+
})
|
|
74
|
+
})]
|
|
75
|
+
})
|
|
76
|
+
}, command.name);
|
|
77
|
+
})
|
|
78
|
+
});
|
|
74
79
|
}
|
|
75
80
|
function CommandMenuLoaderWrapper({
|
|
76
81
|
hook,
|
|
@@ -91,13 +96,12 @@ function CommandMenuLoaderWrapper({
|
|
|
91
96
|
setKey(prevKey => prevKey + 1);
|
|
92
97
|
}
|
|
93
98
|
}, [hook]);
|
|
94
|
-
return (0,
|
|
95
|
-
key: key,
|
|
99
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CommandMenuLoader, {
|
|
96
100
|
hook: currentLoader.current,
|
|
97
101
|
search: search,
|
|
98
102
|
setLoader: setLoader,
|
|
99
103
|
close: close
|
|
100
|
-
});
|
|
104
|
+
}, key);
|
|
101
105
|
}
|
|
102
106
|
function CommandMenuGroup({
|
|
103
107
|
isContextual,
|
|
@@ -121,33 +125,37 @@ function CommandMenuGroup({
|
|
|
121
125
|
if (!commands.length && !loaders.length) {
|
|
122
126
|
return null;
|
|
123
127
|
}
|
|
124
|
-
return (0,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
128
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_cmdk.Command.Group, {
|
|
129
|
+
children: [commands.map(command => {
|
|
130
|
+
var _command$searchLabel2;
|
|
131
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_cmdk.Command.Item, {
|
|
132
|
+
value: (_command$searchLabel2 = command.searchLabel) !== null && _command$searchLabel2 !== void 0 ? _command$searchLabel2 : command.label,
|
|
133
|
+
onSelect: () => command.callback({
|
|
134
|
+
close
|
|
135
|
+
}),
|
|
136
|
+
id: command.name,
|
|
137
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
138
|
+
alignment: "left",
|
|
139
|
+
className: (0, _clsx.default)('commands-command-menu__item', {
|
|
140
|
+
'has-icon': command.icon
|
|
141
|
+
}),
|
|
142
|
+
children: [command.icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
143
|
+
icon: command.icon
|
|
144
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
145
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextHighlight, {
|
|
146
|
+
text: command.label,
|
|
147
|
+
highlight: search
|
|
148
|
+
})
|
|
149
|
+
})]
|
|
150
|
+
})
|
|
151
|
+
}, command.name);
|
|
152
|
+
}), loaders.map(loader => /*#__PURE__*/(0, _jsxRuntime.jsx)(CommandMenuLoaderWrapper, {
|
|
153
|
+
hook: loader.hook,
|
|
154
|
+
search: search,
|
|
155
|
+
setLoader: setLoader,
|
|
156
|
+
close: close
|
|
157
|
+
}, loader.name))]
|
|
158
|
+
});
|
|
151
159
|
}
|
|
152
160
|
function CommandInput({
|
|
153
161
|
isOpen,
|
|
@@ -166,7 +174,7 @@ function CommandInput({
|
|
|
166
174
|
commandMenuInput.current.focus();
|
|
167
175
|
}
|
|
168
176
|
}, [isOpen]);
|
|
169
|
-
return (0,
|
|
177
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_cmdk.Command.Input, {
|
|
170
178
|
ref: commandMenuInput,
|
|
171
179
|
value: search,
|
|
172
180
|
onValueChange: setSearch,
|
|
@@ -247,36 +255,43 @@ function CommandMenu() {
|
|
|
247
255
|
}
|
|
248
256
|
};
|
|
249
257
|
const isLoading = Object.values(loaders).some(Boolean);
|
|
250
|
-
return (0,
|
|
258
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
|
|
251
259
|
className: "commands-command-menu",
|
|
252
260
|
overlayClassName: "commands-command-menu__overlay",
|
|
253
261
|
onRequestClose: closeAndReset,
|
|
254
262
|
__experimentalHideHeader: true,
|
|
255
|
-
contentLabel: (0, _i18n.__)('Command palette')
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
263
|
+
contentLabel: (0, _i18n.__)('Command palette'),
|
|
264
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
265
|
+
className: "commands-command-menu__container",
|
|
266
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_cmdk.Command, {
|
|
267
|
+
label: inputLabel,
|
|
268
|
+
onKeyDown: onKeyDown,
|
|
269
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
270
|
+
className: "commands-command-menu__header",
|
|
271
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(CommandInput, {
|
|
272
|
+
search: search,
|
|
273
|
+
setSearch: setSearch,
|
|
274
|
+
isOpen: isOpen
|
|
275
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
276
|
+
icon: _icons.search
|
|
277
|
+
})]
|
|
278
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_cmdk.Command.List, {
|
|
279
|
+
ref: commandListRef,
|
|
280
|
+
children: [search && !isLoading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_cmdk.Command.Empty, {
|
|
281
|
+
children: (0, _i18n.__)('No results found.')
|
|
282
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(CommandMenuGroup, {
|
|
283
|
+
search: search,
|
|
284
|
+
setLoader: setLoader,
|
|
285
|
+
close: closeAndReset,
|
|
286
|
+
isContextual: true
|
|
287
|
+
}), search && /*#__PURE__*/(0, _jsxRuntime.jsx)(CommandMenuGroup, {
|
|
288
|
+
search: search,
|
|
289
|
+
setLoader: setLoader,
|
|
290
|
+
close: closeAndReset
|
|
291
|
+
})]
|
|
292
|
+
})]
|
|
293
|
+
})
|
|
294
|
+
})
|
|
295
|
+
});
|
|
281
296
|
}
|
|
282
297
|
//# sourceMappingURL=command-menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cmdk","require","_classnames","_interopRequireDefault","_data","_element","_i18n","_components","_keyboardShortcuts","_icons","_store","inputLabel","__","CommandMenuLoader","name","search","hook","setLoader","close","_hook","isLoading","commands","useEffect","length","_react","createElement","Fragment","map","command","_command$searchLabel","Command","Item","key","value","searchLabel","label","onSelect","callback","id","__experimentalHStack","alignment","className","classnames","icon","Icon","TextHighlight","text","highlight","CommandMenuLoaderWrapper","currentLoader","useRef","setKey","useState","current","prevKey","CommandMenuGroup","isContextual","loaders","useSelect","select","getCommands","getCommandLoaders","commandsStore","Group","_command$searchLabel2","loader","CommandInput","isOpen","setSearch","commandMenuInput","_value","useCommandState","state","selectedItemId","useMemo","item","document","querySelector","getAttribute","focus","Input","ref","onValueChange","placeholder","CommandMenu","registerShortcut","useDispatch","keyboardShortcutsStore","open","setLoaders","commandListRef","category","description","keyCombination","modifier","character","removeAttribute","setAttribute","useShortcut","event","defaultPrevented","preventDefault","bindGlobal","useCallback","closeAndReset","onKeyDown","nativeEvent","isComposing","keyCode","Object","values","some","Boolean","Modal","overlayClassName","onRequestClose","__experimentalHideHeader","contentLabel","inputIcon","List","Empty"],"sources":["@wordpress/commands/src/components/command-menu.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Command, useCommandState } from 'cmdk';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\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 { Icon, search as inputIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nconst inputLabel = __( 'Search commands and settings' );\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ classnames( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ classnames( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nfunction CommandInput( { isOpen, search, setSearch } ) {\n\tconst commandMenuInput = useRef();\n\tconst _value = useCommandState( ( state ) => state.value );\n\tconst selectedItemId = useMemo( () => {\n\t\tconst item = document.querySelector(\n\t\t\t`[cmdk-item=\"\"][data-value=\"${ _value }\"]`\n\t\t);\n\t\treturn item?.getAttribute( 'id' );\n\t}, [ _value ] );\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\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\ticon={ search }\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 = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\tconst commandListRef = useRef();\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the command palette.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\t// Temporary fix for the suggestions Listbox labeling.\n\t// See https://github.com/pacocoursey/cmdk/issues/196\n\tuseEffect( () => {\n\t\tcommandListRef.current?.removeAttribute( 'aria-labelledby' );\n\t\tcommandListRef.current?.setAttribute(\n\t\t\t'aria-label',\n\t\t\t__( 'Command suggestions' )\n\t\t);\n\t}, [ commandListRef.current ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t/** @type {import('react').KeyboardEventHandler} */\n\t\t( 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 ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\n\tconst onKeyDown = ( event ) => {\n\t\tif (\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.nativeEvent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t\tcontentLabel={ __( 'Command palette' ) }\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ inputLabel } onKeyDown={ onKeyDown }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\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\tisOpen={ isOpen }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Icon icon={ inputIcon } />\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List ref={ commandListRef }>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA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;IAChBxC,MAAM,EAAGA,MAAQ;IACjBE,SAAS,EAAGA,SAAW;IACvBC,KAAK,EAAGsF;EAAe,CACvB,CAEW,CACN,CACL,CACC,CAAC;AAEV","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_cmdk","require","_clsx","_interopRequireDefault","_data","_element","_i18n","_components","_keyboardShortcuts","_icons","_store","_jsxRuntime","inputLabel","__","CommandMenuLoader","name","search","hook","setLoader","close","_hook","isLoading","commands","useEffect","length","jsx","Fragment","children","map","command","_command$searchLabel","Command","Item","value","searchLabel","label","onSelect","callback","id","jsxs","__experimentalHStack","alignment","className","clsx","icon","Icon","TextHighlight","text","highlight","CommandMenuLoaderWrapper","currentLoader","useRef","key","setKey","useState","current","prevKey","CommandMenuGroup","isContextual","loaders","useSelect","select","getCommands","getCommandLoaders","commandsStore","Group","_command$searchLabel2","loader","CommandInput","isOpen","setSearch","commandMenuInput","_value","useCommandState","state","selectedItemId","useMemo","item","document","querySelector","getAttribute","focus","Input","ref","onValueChange","placeholder","CommandMenu","registerShortcut","useDispatch","keyboardShortcutsStore","open","setLoaders","commandListRef","category","description","keyCombination","modifier","character","removeAttribute","setAttribute","useShortcut","event","defaultPrevented","preventDefault","bindGlobal","useCallback","closeAndReset","onKeyDown","nativeEvent","isComposing","keyCode","Object","values","some","Boolean","Modal","overlayClassName","onRequestClose","__experimentalHideHeader","contentLabel","inputIcon","List","Empty"],"sources":["@wordpress/commands/src/components/command-menu.js"],"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\tuseCallback,\n\tuseMemo,\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 { Icon, search as inputIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nconst inputLabel = __( 'Search commands and settings' );\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nfunction CommandInput( { isOpen, search, setSearch } ) {\n\tconst commandMenuInput = useRef();\n\tconst _value = useCommandState( ( state ) => state.value );\n\tconst selectedItemId = useMemo( () => {\n\t\tconst item = document.querySelector(\n\t\t\t`[cmdk-item=\"\"][data-value=\"${ _value }\"]`\n\t\t);\n\t\treturn item?.getAttribute( 'id' );\n\t}, [ _value ] );\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\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\ticon={ search }\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 = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\tconst commandListRef = useRef();\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the command palette.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\t// Temporary fix for the suggestions Listbox labeling.\n\t// See https://github.com/pacocoursey/cmdk/issues/196\n\tuseEffect( () => {\n\t\tcommandListRef.current?.removeAttribute( 'aria-labelledby' );\n\t\tcommandListRef.current?.setAttribute(\n\t\t\t'aria-label',\n\t\t\t__( 'Command suggestions' )\n\t\t);\n\t}, [ commandListRef.current ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t/** @type {import('react').KeyboardEventHandler} */\n\t\t( 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 ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\n\tconst onKeyDown = ( event ) => {\n\t\tif (\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.nativeEvent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t\tcontentLabel={ __( 'Command palette' ) }\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ inputLabel } onKeyDown={ onKeyDown }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\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\tisOpen={ isOpen }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Icon icon={ inputIcon } />\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List ref={ commandListRef }>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAOA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAKA,IAAAO,kBAAA,GAAAP,OAAA;AAIA,IAAAQ,MAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AAAkD,IAAAU,WAAA,GAAAV,OAAA;AAhClD;AACA;AACA;;AAIA;AACA;AACA;;AAqBA;AACA;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QAAA,CACY,CAAC;MAAA,CACP;IAAC,CACN;EAAC,CACA,CAAC;AAEV","ignoreList":[]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
5
4
|
import { Command, useCommandState } from 'cmdk';
|
|
6
|
-
import
|
|
5
|
+
import clsx from 'clsx';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* WordPress dependencies
|
|
@@ -19,6 +18,9 @@ import { Icon, search as inputIcon } from '@wordpress/icons';
|
|
|
19
18
|
* Internal dependencies
|
|
20
19
|
*/
|
|
21
20
|
import { store as commandsStore } from '../store';
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
24
|
const inputLabel = __('Search commands and settings');
|
|
23
25
|
function CommandMenuLoader({
|
|
24
26
|
name,
|
|
@@ -40,27 +42,32 @@ function CommandMenuLoader({
|
|
|
40
42
|
if (!commands.length) {
|
|
41
43
|
return null;
|
|
42
44
|
}
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
46
|
+
children: commands.map(command => {
|
|
47
|
+
var _command$searchLabel;
|
|
48
|
+
return /*#__PURE__*/_jsx(Command.Item, {
|
|
49
|
+
value: (_command$searchLabel = command.searchLabel) !== null && _command$searchLabel !== void 0 ? _command$searchLabel : command.label,
|
|
50
|
+
onSelect: () => command.callback({
|
|
51
|
+
close
|
|
52
|
+
}),
|
|
53
|
+
id: command.name,
|
|
54
|
+
children: /*#__PURE__*/_jsxs(HStack, {
|
|
55
|
+
alignment: "left",
|
|
56
|
+
className: clsx('commands-command-menu__item', {
|
|
57
|
+
'has-icon': command.icon
|
|
58
|
+
}),
|
|
59
|
+
children: [command.icon && /*#__PURE__*/_jsx(Icon, {
|
|
60
|
+
icon: command.icon
|
|
61
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
62
|
+
children: /*#__PURE__*/_jsx(TextHighlight, {
|
|
63
|
+
text: command.label,
|
|
64
|
+
highlight: search
|
|
65
|
+
})
|
|
66
|
+
})]
|
|
67
|
+
})
|
|
68
|
+
}, command.name);
|
|
69
|
+
})
|
|
70
|
+
});
|
|
64
71
|
}
|
|
65
72
|
export function CommandMenuLoaderWrapper({
|
|
66
73
|
hook,
|
|
@@ -81,13 +88,12 @@ export function CommandMenuLoaderWrapper({
|
|
|
81
88
|
setKey(prevKey => prevKey + 1);
|
|
82
89
|
}
|
|
83
90
|
}, [hook]);
|
|
84
|
-
return
|
|
85
|
-
key: key,
|
|
91
|
+
return /*#__PURE__*/_jsx(CommandMenuLoader, {
|
|
86
92
|
hook: currentLoader.current,
|
|
87
93
|
search: search,
|
|
88
94
|
setLoader: setLoader,
|
|
89
95
|
close: close
|
|
90
|
-
});
|
|
96
|
+
}, key);
|
|
91
97
|
}
|
|
92
98
|
export function CommandMenuGroup({
|
|
93
99
|
isContextual,
|
|
@@ -111,33 +117,37 @@ export function CommandMenuGroup({
|
|
|
111
117
|
if (!commands.length && !loaders.length) {
|
|
112
118
|
return null;
|
|
113
119
|
}
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
120
|
+
return /*#__PURE__*/_jsxs(Command.Group, {
|
|
121
|
+
children: [commands.map(command => {
|
|
122
|
+
var _command$searchLabel2;
|
|
123
|
+
return /*#__PURE__*/_jsx(Command.Item, {
|
|
124
|
+
value: (_command$searchLabel2 = command.searchLabel) !== null && _command$searchLabel2 !== void 0 ? _command$searchLabel2 : command.label,
|
|
125
|
+
onSelect: () => command.callback({
|
|
126
|
+
close
|
|
127
|
+
}),
|
|
128
|
+
id: command.name,
|
|
129
|
+
children: /*#__PURE__*/_jsxs(HStack, {
|
|
130
|
+
alignment: "left",
|
|
131
|
+
className: clsx('commands-command-menu__item', {
|
|
132
|
+
'has-icon': command.icon
|
|
133
|
+
}),
|
|
134
|
+
children: [command.icon && /*#__PURE__*/_jsx(Icon, {
|
|
135
|
+
icon: command.icon
|
|
136
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
137
|
+
children: /*#__PURE__*/_jsx(TextHighlight, {
|
|
138
|
+
text: command.label,
|
|
139
|
+
highlight: search
|
|
140
|
+
})
|
|
141
|
+
})]
|
|
142
|
+
})
|
|
143
|
+
}, command.name);
|
|
144
|
+
}), loaders.map(loader => /*#__PURE__*/_jsx(CommandMenuLoaderWrapper, {
|
|
145
|
+
hook: loader.hook,
|
|
146
|
+
search: search,
|
|
147
|
+
setLoader: setLoader,
|
|
148
|
+
close: close
|
|
149
|
+
}, loader.name))]
|
|
150
|
+
});
|
|
141
151
|
}
|
|
142
152
|
function CommandInput({
|
|
143
153
|
isOpen,
|
|
@@ -156,7 +166,7 @@ function CommandInput({
|
|
|
156
166
|
commandMenuInput.current.focus();
|
|
157
167
|
}
|
|
158
168
|
}, [isOpen]);
|
|
159
|
-
return
|
|
169
|
+
return /*#__PURE__*/_jsx(Command.Input, {
|
|
160
170
|
ref: commandMenuInput,
|
|
161
171
|
value: search,
|
|
162
172
|
onValueChange: setSearch,
|
|
@@ -237,36 +247,43 @@ export function CommandMenu() {
|
|
|
237
247
|
}
|
|
238
248
|
};
|
|
239
249
|
const isLoading = Object.values(loaders).some(Boolean);
|
|
240
|
-
return
|
|
250
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
241
251
|
className: "commands-command-menu",
|
|
242
252
|
overlayClassName: "commands-command-menu__overlay",
|
|
243
253
|
onRequestClose: closeAndReset,
|
|
244
254
|
__experimentalHideHeader: true,
|
|
245
|
-
contentLabel: __('Command palette')
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
255
|
+
contentLabel: __('Command palette'),
|
|
256
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
257
|
+
className: "commands-command-menu__container",
|
|
258
|
+
children: /*#__PURE__*/_jsxs(Command, {
|
|
259
|
+
label: inputLabel,
|
|
260
|
+
onKeyDown: onKeyDown,
|
|
261
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
262
|
+
className: "commands-command-menu__header",
|
|
263
|
+
children: [/*#__PURE__*/_jsx(CommandInput, {
|
|
264
|
+
search: search,
|
|
265
|
+
setSearch: setSearch,
|
|
266
|
+
isOpen: isOpen
|
|
267
|
+
}), /*#__PURE__*/_jsx(Icon, {
|
|
268
|
+
icon: inputIcon
|
|
269
|
+
})]
|
|
270
|
+
}), /*#__PURE__*/_jsxs(Command.List, {
|
|
271
|
+
ref: commandListRef,
|
|
272
|
+
children: [search && !isLoading && /*#__PURE__*/_jsx(Command.Empty, {
|
|
273
|
+
children: __('No results found.')
|
|
274
|
+
}), /*#__PURE__*/_jsx(CommandMenuGroup, {
|
|
275
|
+
search: search,
|
|
276
|
+
setLoader: setLoader,
|
|
277
|
+
close: closeAndReset,
|
|
278
|
+
isContextual: true
|
|
279
|
+
}), search && /*#__PURE__*/_jsx(CommandMenuGroup, {
|
|
280
|
+
search: search,
|
|
281
|
+
setLoader: setLoader,
|
|
282
|
+
close: closeAndReset
|
|
283
|
+
})]
|
|
284
|
+
})]
|
|
285
|
+
})
|
|
286
|
+
})
|
|
287
|
+
});
|
|
271
288
|
}
|
|
272
289
|
//# sourceMappingURL=command-menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Command","useCommandState","classnames","useSelect","useDispatch","useState","useEffect","useRef","useCallback","useMemo","__","Modal","TextHighlight","__experimentalHStack","HStack","store","keyboardShortcutsStore","useShortcut","Icon","search","inputIcon","commandsStore","inputLabel","CommandMenuLoader","name","hook","setLoader","close","_hook","isLoading","commands","length","createElement","Fragment","map","command","_command$searchLabel","Item","key","value","searchLabel","label","onSelect","callback","id","alignment","className","icon","text","highlight","CommandMenuLoaderWrapper","currentLoader","setKey","current","prevKey","CommandMenuGroup","isContextual","loaders","select","getCommands","getCommandLoaders","Group","_command$searchLabel2","loader","CommandInput","isOpen","setSearch","commandMenuInput","_value","state","selectedItemId","item","document","querySelector","getAttribute","focus","Input","ref","onValueChange","placeholder","CommandMenu","registerShortcut","open","setLoaders","commandListRef","category","description","keyCombination","modifier","character","removeAttribute","setAttribute","event","defaultPrevented","preventDefault","bindGlobal","closeAndReset","onKeyDown","nativeEvent","isComposing","keyCode","Object","values","some","Boolean","overlayClassName","onRequestClose","__experimentalHideHeader","contentLabel","List","Empty"],"sources":["@wordpress/commands/src/components/command-menu.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Command, useCommandState } from 'cmdk';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\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 { Icon, search as inputIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nconst inputLabel = __( 'Search commands and settings' );\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ classnames( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ classnames( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nfunction CommandInput( { isOpen, search, setSearch } ) {\n\tconst commandMenuInput = useRef();\n\tconst _value = useCommandState( ( state ) => state.value );\n\tconst selectedItemId = useMemo( () => {\n\t\tconst item = document.querySelector(\n\t\t\t`[cmdk-item=\"\"][data-value=\"${ _value }\"]`\n\t\t);\n\t\treturn item?.getAttribute( 'id' );\n\t}, [ _value ] );\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\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\ticon={ search }\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 = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\tconst commandListRef = useRef();\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the command palette.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\t// Temporary fix for the suggestions Listbox labeling.\n\t// See https://github.com/pacocoursey/cmdk/issues/196\n\tuseEffect( () => {\n\t\tcommandListRef.current?.removeAttribute( 'aria-labelledby' );\n\t\tcommandListRef.current?.setAttribute(\n\t\t\t'aria-label',\n\t\t\t__( 'Command suggestions' )\n\t\t);\n\t}, [ commandListRef.current ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t/** @type {import('react').KeyboardEventHandler} */\n\t\t( 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 ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\n\tconst onKeyDown = ( event ) => {\n\t\tif (\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.nativeEvent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t\tcontentLabel={ __( 'Command palette' ) }\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ inputLabel } onKeyDown={ onKeyDown }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\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\tisOpen={ isOpen }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Icon icon={ inputIcon } />\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List ref={ commandListRef }>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,eAAe,QAAQ,MAAM;AAC/C,OAAOC,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,QAAQ,EACRC,SAAS,EACTC,MAAM,EAC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AI,EAAG3B;EAAW,CAAE,CACtB,CAAC,EACNY,aAAA,CAAChC,OAAO,CAAC6G,IAAI;IAAChC,GAAG,EAAGO;EAAgB,GACjCjE,MAAM,IAAI,CAAEU,SAAS,IACtBG,aAAA,CAAChC,OAAO,CAAC8G,KAAK,QACXpG,EAAE,CAAE,mBAAoB,CACZ,CACf,EACDsB,aAAA,CAACuB,gBAAgB;IAChBpC,MAAM,EAAGA,MAAQ;IACjBO,SAAS,EAAGA,SAAW;IACvBC,KAAK,EAAGqE,aAAe;IACvBxC,YAAY;EAAA,CACZ,CAAC,EACArC,MAAM,IACPa,aAAA,CAACuB,gBAAgB;IAChBpC,MAAM,EAAGA,MAAQ;IACjBO,SAAS,EAAGA,SAAW;IACvBC,KAAK,EAAGqE;EAAe,CACvB,CAEW,CACN,CACL,CACC,CAAC;AAEV","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Command","useCommandState","clsx","useSelect","useDispatch","useState","useEffect","useRef","useCallback","useMemo","__","Modal","TextHighlight","__experimentalHStack","HStack","store","keyboardShortcutsStore","useShortcut","Icon","search","inputIcon","commandsStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","inputLabel","CommandMenuLoader","name","hook","setLoader","close","_hook","isLoading","commands","length","children","map","command","_command$searchLabel","Item","value","searchLabel","label","onSelect","callback","id","alignment","className","icon","text","highlight","CommandMenuLoaderWrapper","currentLoader","key","setKey","current","prevKey","CommandMenuGroup","isContextual","loaders","select","getCommands","getCommandLoaders","Group","_command$searchLabel2","loader","CommandInput","isOpen","setSearch","commandMenuInput","_value","state","selectedItemId","item","document","querySelector","getAttribute","focus","Input","ref","onValueChange","placeholder","CommandMenu","registerShortcut","open","setLoaders","commandListRef","category","description","keyCombination","modifier","character","removeAttribute","setAttribute","event","defaultPrevented","preventDefault","bindGlobal","closeAndReset","onKeyDown","nativeEvent","isComposing","keyCode","Object","values","some","Boolean","overlayClassName","onRequestClose","__experimentalHideHeader","contentLabel","List","Empty"],"sources":["@wordpress/commands/src/components/command-menu.js"],"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\tuseCallback,\n\tuseMemo,\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 { Icon, search as inputIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nconst inputLabel = __( 'Search commands and settings' );\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nfunction CommandInput( { isOpen, search, setSearch } ) {\n\tconst commandMenuInput = useRef();\n\tconst _value = useCommandState( ( state ) => state.value );\n\tconst selectedItemId = useMemo( () => {\n\t\tconst item = document.querySelector(\n\t\t\t`[cmdk-item=\"\"][data-value=\"${ _value }\"]`\n\t\t);\n\t\treturn item?.getAttribute( 'id' );\n\t}, [ _value ] );\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\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\ticon={ search }\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 = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\tconst commandListRef = useRef();\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the command palette.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\t// Temporary fix for the suggestions Listbox labeling.\n\t// See https://github.com/pacocoursey/cmdk/issues/196\n\tuseEffect( () => {\n\t\tcommandListRef.current?.removeAttribute( 'aria-labelledby' );\n\t\tcommandListRef.current?.setAttribute(\n\t\t\t'aria-label',\n\t\t\t__( 'Command suggestions' )\n\t\t);\n\t}, [ commandListRef.current ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t/** @type {import('react').KeyboardEventHandler} */\n\t\t( 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 ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\n\tconst onKeyDown = ( event ) => {\n\t\tif (\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.nativeEvent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t\tcontentLabel={ __( 'Command palette' ) }\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ inputLabel } onKeyDown={ onKeyDown }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\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\tisOpen={ isOpen }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Icon icon={ inputIcon } />\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List ref={ commandListRef }>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,eAAe,Q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C,YAAY,EAAGvG,EAAE,CAAE,iBAAkB,CAAG;IAAA4B,QAAA,eAExCf,IAAA;MAAK2B,SAAS,EAAC,kCAAkC;MAAAZ,QAAA,eAChDb,KAAA,CAACzB,OAAO;QAAC6C,KAAK,EAAGjB,UAAY;QAAC0E,SAAS,EAAGA,SAAW;QAAAhE,QAAA,gBACpDb,KAAA;UAAKyB,SAAS,EAAC,+BAA+B;UAAAZ,QAAA,gBAC7Cf,IAAA,CAAC8C,YAAY;YACZlD,MAAM,EAAGA,MAAQ;YACjBoD,SAAS,EAAGA,SAAW;YACvBD,MAAM,EAAGA;UAAQ,CACjB,CAAC,eACF/C,IAAA,CAACL,IAAI;YAACiC,IAAI,EAAG/B;UAAW,CAAE,CAAC;QAAA,CACvB,CAAC,eACNK,KAAA,CAACzB,OAAO,CAACkH,IAAI;UAAChC,GAAG,EAAGO,cAAgB;UAAAnD,QAAA,GACjCnB,MAAM,IAAI,CAAEgB,SAAS,iBACtBZ,IAAA,CAACvB,OAAO,CAACmH,KAAK;YAAA7E,QAAA,EACX5B,EAAE,CAAE,mBAAoB;UAAC,CACb,CACf,eACDa,IAAA,CAACqC,gBAAgB;YAChBzC,MAAM,EAAGA,MAAQ;YACjBa,SAAS,EAAGA,SAAW;YACvBC,KAAK,EAAGoE,aAAe;YACvBxC,YAAY;UAAA,CACZ,CAAC,EACA1C,MAAM,iBACPI,IAAA,CAACqC,gBAAgB;YAChBzC,MAAM,EAAGA,MAAQ;YACjBa,SAAS,EAAGA,SAAW;YACvBC,KAAK,EAAGoE;UAAe,CACvB,CACD;QAAA,CACY,CAAC;MAAA,CACP;IAAC,CACN;EAAC,CACA,CAAC;AAEV","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/commands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Handles the commands menu.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -20,21 +20,22 @@
|
|
|
20
20
|
"url": "https://github.com/WordPress/gutenberg/issues"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": ">=12"
|
|
23
|
+
"node": ">=18.12.0",
|
|
24
|
+
"npm": ">=8.19.2"
|
|
24
25
|
},
|
|
25
26
|
"main": "build/index.js",
|
|
26
27
|
"module": "build-module/index.js",
|
|
27
28
|
"react-native": "src/index",
|
|
28
29
|
"dependencies": {
|
|
29
30
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/components": "^
|
|
31
|
-
"@wordpress/data": "^
|
|
32
|
-
"@wordpress/element": "^
|
|
33
|
-
"@wordpress/i18n": "^
|
|
34
|
-
"@wordpress/icons": "^
|
|
35
|
-
"@wordpress/keyboard-shortcuts": "^
|
|
36
|
-
"@wordpress/private-apis": "^0.
|
|
37
|
-
"
|
|
31
|
+
"@wordpress/components": "^28.0.0",
|
|
32
|
+
"@wordpress/data": "^10.0.0",
|
|
33
|
+
"@wordpress/element": "^6.0.0",
|
|
34
|
+
"@wordpress/i18n": "^5.0.0",
|
|
35
|
+
"@wordpress/icons": "^10.0.0",
|
|
36
|
+
"@wordpress/keyboard-shortcuts": "^5.0.0",
|
|
37
|
+
"@wordpress/private-apis": "^1.0.0",
|
|
38
|
+
"clsx": "^2.1.1",
|
|
38
39
|
"cmdk": "^0.2.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
@@ -44,5 +45,5 @@
|
|
|
44
45
|
"publishConfig": {
|
|
45
46
|
"access": "public"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "2f30cddff15723ac7017fd009fc5913b7b419400"
|
|
48
49
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Command, useCommandState } from 'cmdk';
|
|
5
|
-
import
|
|
5
|
+
import clsx from 'clsx';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -55,7 +55,7 @@ function CommandMenuLoader( { name, search, hook, setLoader, close } ) {
|
|
|
55
55
|
>
|
|
56
56
|
<HStack
|
|
57
57
|
alignment="left"
|
|
58
|
-
className={
|
|
58
|
+
className={ clsx( 'commands-command-menu__item', {
|
|
59
59
|
'has-icon': command.icon,
|
|
60
60
|
} ) }
|
|
61
61
|
>
|
|
@@ -126,7 +126,7 @@ export function CommandMenuGroup( { isContextual, search, setLoader, close } ) {
|
|
|
126
126
|
>
|
|
127
127
|
<HStack
|
|
128
128
|
alignment="left"
|
|
129
|
-
className={
|
|
129
|
+
className={ clsx( 'commands-command-menu__item', {
|
|
130
130
|
'has-icon': command.icon,
|
|
131
131
|
} ) }
|
|
132
132
|
>
|