@wordpress/commands 0.10.0 → 0.11.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 +2 -0
- package/build/components/command-menu.js +25 -40
- package/build/components/command-menu.js.map +1 -1
- package/build/hooks/use-command-context.js +3 -7
- package/build/hooks/use-command-context.js.map +1 -1
- package/build/hooks/use-command-loader.js +0 -4
- package/build/hooks/use-command-loader.js.map +1 -1
- package/build/hooks/use-command.js +0 -4
- package/build/hooks/use-command.js.map +1 -1
- package/build/index.js +0 -6
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +1 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +1 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +5 -11
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +2 -11
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +0 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/reducer.js +7 -18
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +33 -4
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/command-menu.js +26 -35
- package/build-module/components/command-menu.js.map +1 -1
- package/build-module/hooks/use-command-context.js +5 -4
- package/build-module/hooks/use-command-context.js.map +1 -1
- package/build-module/hooks/use-command-loader.js +2 -2
- package/build-module/hooks/use-command-loader.js.map +1 -1
- package/build-module/hooks/use-command.js +2 -2
- package/build-module/hooks/use-command.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +5 -5
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +2 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/reducer.js +8 -17
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +34 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +36 -18
- package/build-style/style.css +36 -18
- package/package.json +12 -10
- package/src/components/command-menu.js +17 -7
- package/src/components/style.scss +38 -19
- package/src/store/selectors.js +30 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.CommandMenu = CommandMenu;
|
|
7
8
|
exports.CommandMenuGroup = CommandMenuGroup;
|
|
8
9
|
exports.CommandMenuLoaderWrapper = CommandMenuLoaderWrapper;
|
|
9
|
-
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
11
|
var _cmdk = require("cmdk");
|
|
13
|
-
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
13
|
var _data = require("@wordpress/data");
|
|
15
|
-
|
|
16
14
|
var _i18n = require("@wordpress/i18n");
|
|
17
|
-
|
|
18
15
|
var _components = require("@wordpress/components");
|
|
19
|
-
|
|
20
16
|
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
21
|
-
|
|
22
17
|
var _icons = require("@wordpress/icons");
|
|
23
|
-
|
|
24
18
|
var _store = require("../store");
|
|
25
|
-
|
|
26
19
|
/**
|
|
27
20
|
* External dependencies
|
|
28
21
|
*/
|
|
@@ -34,6 +27,7 @@ var _store = require("../store");
|
|
|
34
27
|
/**
|
|
35
28
|
* Internal dependencies
|
|
36
29
|
*/
|
|
30
|
+
|
|
37
31
|
function CommandMenuLoader({
|
|
38
32
|
name,
|
|
39
33
|
search,
|
|
@@ -42,7 +36,6 @@ function CommandMenuLoader({
|
|
|
42
36
|
close
|
|
43
37
|
}) {
|
|
44
38
|
var _hook;
|
|
45
|
-
|
|
46
39
|
const {
|
|
47
40
|
isLoading,
|
|
48
41
|
commands = []
|
|
@@ -52,14 +45,11 @@ function CommandMenuLoader({
|
|
|
52
45
|
(0, _element.useEffect)(() => {
|
|
53
46
|
setLoader(name, isLoading);
|
|
54
47
|
}, [setLoader, name, isLoading]);
|
|
55
|
-
|
|
56
48
|
if (!commands.length) {
|
|
57
49
|
return null;
|
|
58
50
|
}
|
|
59
|
-
|
|
60
51
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_cmdk.Command.List, null, commands.map(command => {
|
|
61
52
|
var _command$searchLabel;
|
|
62
|
-
|
|
63
53
|
return (0, _element.createElement)(_cmdk.Command.Item, {
|
|
64
54
|
key: command.name,
|
|
65
55
|
value: (_command$searchLabel = command.searchLabel) !== null && _command$searchLabel !== void 0 ? _command$searchLabel : command.label,
|
|
@@ -69,8 +59,10 @@ function CommandMenuLoader({
|
|
|
69
59
|
id: command.name
|
|
70
60
|
}, (0, _element.createElement)(_components.__experimentalHStack, {
|
|
71
61
|
alignment: "left",
|
|
72
|
-
className:
|
|
73
|
-
|
|
62
|
+
className: (0, _classnames.default)('commands-command-menu__item', {
|
|
63
|
+
'has-icon': command.icon
|
|
64
|
+
})
|
|
65
|
+
}, command.icon && (0, _element.createElement)(_icons.Icon, {
|
|
74
66
|
icon: command.icon
|
|
75
67
|
}), (0, _element.createElement)("span", null, (0, _element.createElement)(_components.TextHighlight, {
|
|
76
68
|
text: command.label,
|
|
@@ -78,7 +70,6 @@ function CommandMenuLoader({
|
|
|
78
70
|
}))));
|
|
79
71
|
})));
|
|
80
72
|
}
|
|
81
|
-
|
|
82
73
|
function CommandMenuLoaderWrapper({
|
|
83
74
|
hook,
|
|
84
75
|
search,
|
|
@@ -106,7 +97,6 @@ function CommandMenuLoaderWrapper({
|
|
|
106
97
|
close: close
|
|
107
98
|
});
|
|
108
99
|
}
|
|
109
|
-
|
|
110
100
|
function CommandMenuGroup({
|
|
111
101
|
isContextual,
|
|
112
102
|
search,
|
|
@@ -126,14 +116,11 @@ function CommandMenuGroup({
|
|
|
126
116
|
loaders: getCommandLoaders(isContextual)
|
|
127
117
|
};
|
|
128
118
|
}, [isContextual]);
|
|
129
|
-
|
|
130
119
|
if (!commands.length && !loaders.length) {
|
|
131
120
|
return null;
|
|
132
121
|
}
|
|
133
|
-
|
|
134
122
|
return (0, _element.createElement)(_cmdk.Command.Group, null, commands.map(command => {
|
|
135
123
|
var _command$searchLabel2;
|
|
136
|
-
|
|
137
124
|
return (0, _element.createElement)(_cmdk.Command.Item, {
|
|
138
125
|
key: command.name,
|
|
139
126
|
value: (_command$searchLabel2 = command.searchLabel) !== null && _command$searchLabel2 !== void 0 ? _command$searchLabel2 : command.label,
|
|
@@ -143,8 +130,10 @@ function CommandMenuGroup({
|
|
|
143
130
|
id: command.name
|
|
144
131
|
}, (0, _element.createElement)(_components.__experimentalHStack, {
|
|
145
132
|
alignment: "left",
|
|
146
|
-
className:
|
|
147
|
-
|
|
133
|
+
className: (0, _classnames.default)('commands-command-menu__item', {
|
|
134
|
+
'has-icon': command.icon
|
|
135
|
+
})
|
|
136
|
+
}, command.icon && (0, _element.createElement)(_icons.Icon, {
|
|
148
137
|
icon: command.icon
|
|
149
138
|
}), (0, _element.createElement)("span", null, (0, _element.createElement)(_components.TextHighlight, {
|
|
150
139
|
text: command.label,
|
|
@@ -158,16 +147,13 @@ function CommandMenuGroup({
|
|
|
158
147
|
close: close
|
|
159
148
|
})));
|
|
160
149
|
}
|
|
161
|
-
|
|
162
150
|
function CommandInput({
|
|
163
151
|
isOpen,
|
|
164
152
|
search,
|
|
165
153
|
setSearch
|
|
166
154
|
}) {
|
|
167
155
|
const commandMenuInput = (0, _element.useRef)();
|
|
168
|
-
|
|
169
156
|
const _value = (0, _cmdk.useCommandState)(state => state.value);
|
|
170
|
-
|
|
171
157
|
const selectedItemId = (0, _element.useMemo)(() => {
|
|
172
158
|
const item = document.querySelector(`[cmdk-item=""][data-value="${_value}"]`);
|
|
173
159
|
return item?.getAttribute('id');
|
|
@@ -182,11 +168,11 @@ function CommandInput({
|
|
|
182
168
|
ref: commandMenuInput,
|
|
183
169
|
value: search,
|
|
184
170
|
onValueChange: setSearch,
|
|
185
|
-
placeholder: (0, _i18n.__)('
|
|
186
|
-
"aria-activedescendant": selectedItemId
|
|
171
|
+
placeholder: (0, _i18n.__)('Search for commands'),
|
|
172
|
+
"aria-activedescendant": selectedItemId,
|
|
173
|
+
icon: search
|
|
187
174
|
});
|
|
188
175
|
}
|
|
189
|
-
|
|
190
176
|
function CommandMenu() {
|
|
191
177
|
const {
|
|
192
178
|
registerShortcut
|
|
@@ -202,20 +188,18 @@ function CommandMenu() {
|
|
|
202
188
|
registerShortcut({
|
|
203
189
|
name: 'core/commands',
|
|
204
190
|
category: 'global',
|
|
205
|
-
description: (0, _i18n.__)('Open the command palette'),
|
|
191
|
+
description: (0, _i18n.__)('Open the command palette.'),
|
|
206
192
|
keyCombination: {
|
|
207
193
|
modifier: 'primary',
|
|
208
194
|
character: 'k'
|
|
209
195
|
}
|
|
210
196
|
});
|
|
211
197
|
}, [registerShortcut]);
|
|
212
|
-
(0, _keyboardShortcuts.useShortcut)('core/commands',
|
|
213
|
-
/** @type {import('react').KeyboardEventHandler} */
|
|
198
|
+
(0, _keyboardShortcuts.useShortcut)('core/commands', /** @type {import('react').KeyboardEventHandler} */
|
|
214
199
|
event => {
|
|
215
200
|
// Bails to avoid obscuring the effect of the preceding handler(s).
|
|
216
201
|
if (event.defaultPrevented) return;
|
|
217
202
|
event.preventDefault();
|
|
218
|
-
|
|
219
203
|
if (isOpen) {
|
|
220
204
|
close();
|
|
221
205
|
} else {
|
|
@@ -224,29 +208,28 @@ function CommandMenu() {
|
|
|
224
208
|
}, {
|
|
225
209
|
bindGlobal: true
|
|
226
210
|
});
|
|
227
|
-
const setLoader = (0, _element.useCallback)((name, value) => setLoaders(current => ({
|
|
211
|
+
const setLoader = (0, _element.useCallback)((name, value) => setLoaders(current => ({
|
|
212
|
+
...current,
|
|
228
213
|
[name]: value
|
|
229
214
|
})), []);
|
|
230
|
-
|
|
231
215
|
const closeAndReset = () => {
|
|
232
216
|
setSearch('');
|
|
233
217
|
close();
|
|
234
218
|
};
|
|
235
|
-
|
|
236
219
|
if (!isOpen) {
|
|
237
220
|
return false;
|
|
238
221
|
}
|
|
239
|
-
|
|
240
222
|
const onKeyDown = event => {
|
|
241
|
-
if (
|
|
242
|
-
|
|
223
|
+
if (
|
|
224
|
+
// Ignore keydowns from IMEs
|
|
225
|
+
event.nativeEvent.isComposing ||
|
|
226
|
+
// Workaround for Mac Safari where the final Enter/Backspace of an IME composition
|
|
243
227
|
// is `isComposing=false`, even though it's technically still part of the composition.
|
|
244
228
|
// These can only be detected by keyCode.
|
|
245
229
|
event.keyCode === 229) {
|
|
246
230
|
event.preventDefault();
|
|
247
231
|
}
|
|
248
232
|
};
|
|
249
|
-
|
|
250
233
|
const isLoading = Object.values(loaders).some(Boolean);
|
|
251
234
|
return (0, _element.createElement)(_components.Modal, {
|
|
252
235
|
className: "commands-command-menu",
|
|
@@ -260,7 +243,9 @@ function CommandMenu() {
|
|
|
260
243
|
onKeyDown: onKeyDown
|
|
261
244
|
}, (0, _element.createElement)("div", {
|
|
262
245
|
className: "commands-command-menu__header"
|
|
263
|
-
}, (0, _element.createElement)(
|
|
246
|
+
}, (0, _element.createElement)(_icons.Icon, {
|
|
247
|
+
icon: _icons.search
|
|
248
|
+
}), (0, _element.createElement)(CommandInput, {
|
|
264
249
|
search: search,
|
|
265
250
|
setSearch: setSearch,
|
|
266
251
|
isOpen: isOpen
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/commands/src/components/command-menu.js"],"names":["CommandMenuLoader","name","search","hook","setLoader","close","isLoading","commands","length","map","command","searchLabel","label","callback","icon","CommandMenuLoaderWrapper","currentLoader","key","setKey","current","prevKey","CommandMenuGroup","isContextual","loaders","select","getCommands","getCommandLoaders","commandsStore","loader","CommandInput","isOpen","setSearch","commandMenuInput","_value","state","value","selectedItemId","item","document","querySelector","getAttribute","focus","CommandMenu","registerShortcut","keyboardShortcutsStore","open","setLoaders","category","description","keyCombination","modifier","character","event","defaultPrevented","preventDefault","bindGlobal","closeAndReset","onKeyDown","nativeEvent","isComposing","keyCode","Object","values","some","Boolean"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAQA;;AACA;;AAKA;;AAIA;;AAKA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAqBA;AACA;AACA;AAGA,SAASA,iBAAT,CAA4B;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,MAAR;AAAgBC,EAAAA,IAAhB;AAAsBC,EAAAA,SAAtB;AAAiCC,EAAAA;AAAjC,CAA5B,EAAuE;AAAA;;AACtE,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAQ,GAAG;AAAxB,eAA+BJ,IAAI,CAAE;AAAED,IAAAA;AAAF,GAAF,CAAnC,yCAAqD,EAA3D;AACA,0BAAW,MAAM;AAChBE,IAAAA,SAAS,CAAEH,IAAF,EAAQK,SAAR,CAAT;AACA,GAFD,EAEG,CAAEF,SAAF,EAAaH,IAAb,EAAmBK,SAAnB,CAFH;;AAIA,MAAK,CAAEC,QAAQ,CAACC,MAAhB,EAAyB;AACxB,WAAO,IAAP;AACA;;AAED,SACC,qDACC,4BAAC,aAAD,CAAS,IAAT,QACGD,QAAQ,CAACE,GAAT,CAAgBC,OAAF;AAAA;;AAAA,WACf,4BAAC,aAAD,CAAS,IAAT;AACC,MAAA,GAAG,EAAGA,OAAO,CAACT,IADf;AAEC,MAAA,KAAK,0BAAGS,OAAO,CAACC,WAAX,uEAA0BD,OAAO,CAACE,KAFxC;AAGC,MAAA,QAAQ,EAAG,MAAMF,OAAO,CAACG,QAAR,CAAkB;AAAER,QAAAA;AAAF,OAAlB,CAHlB;AAIC,MAAA,EAAE,EAAGK,OAAO,CAACT;AAJd,OAMC,4BAAC,gCAAD;AACC,MAAA,SAAS,EAAC,MADX;AAEC,MAAA,SAAS,EAAC;AAFX,OAIC,4BAAC,WAAD;AAAM,MAAA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C,IAAA,cAAc,EAAGR,aAHlB;AAIC,IAAA,wBAAwB;AAJzB,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,aAAD;AACC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CADT;AAEC,IAAA,SAAS,EAAGC;AAFb,KAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,YAAD;AACC,IAAA,MAAM,EAAGvD,MADV;AAEC,IAAA,SAAS,EAAG6B,SAFb;AAGC,IAAA,MAAM,EAAGD;AAHV,IADD,CAJD,EAWC,4BAAC,aAAD,CAAS,IAAT,QACG5B,MAAM,IAAI,CAAEI,SAAZ,IACD,4BAAC,aAAD,CAAS,KAAT,QACG,cAAI,mBAAJ,CADH,CAFF,EAMC,4BAAC,gBAAD;AACC,IAAA,MAAM,EAAGJ,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAGoD,aAHT;AAIC,IAAA,YAAY;AAJb,IAND,EAYGtD,MAAM,IACP,4BAAC,gBAAD;AACC,IAAA,MAAM,EAAGA,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAGoD;AAHT,IAbF,CAXD,CADD,CAND,CADD;AA2CA","sourcesContent":["/**\n * External dependencies\n */\nimport { Command, useCommandState } from 'cmdk';\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 } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Command.List>\n\t\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t\t<Command.Item\n\t\t\t\t\t\tkey={ command.name }\n\t\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\t\tid={ command.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Command.Item>\n\t\t\t\t) ) }\n\t\t\t</Command.List>\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\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=\"commands-command-menu__item\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\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={ __( 'Type a command or search' ) }\n\t\t\taria-activedescendant={ selectedItemId }\n\t\t/>\n\t);\n}\n\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst isOpen = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\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 {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 ) return;\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>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command\n\t\t\t\t\tlabel={ __( 'Command palette' ) }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t>\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</div>\n\t\t\t\t\t<Command.List>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"names":["_element","require","_cmdk","_classnames","_interopRequireDefault","_data","_i18n","_components","_keyboardShortcuts","_icons","_store","CommandMenuLoader","name","search","hook","setLoader","close","_hook","isLoading","commands","useEffect","length","createElement","Fragment","Command","List","map","command","_command$searchLabel","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","category","description","keyCombination","modifier","character","useShortcut","event","defaultPrevented","preventDefault","bindGlobal","useCallback","closeAndReset","onKeyDown","nativeEvent","isComposing","keyCode","Object","values","some","Boolean","Modal","overlayClassName","onRequestClose","__experimentalHideHeader","inputIcon","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\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Command.List>\n\t\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t\t<Command.Item\n\t\t\t\t\t\tkey={ command.name }\n\t\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\t\tid={ command.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'commands-command-menu__item',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Command.Item>\n\t\t\t\t) ) }\n\t\t\t</Command.List>\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\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={ __( 'Search for commands' ) }\n\t\t\taria-activedescendant={ selectedItemId }\n\t\t\ticon={ search }\n\t\t/>\n\t);\n}\n\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst isOpen = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\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 {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 ) return;\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>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command\n\t\t\t\t\tlabel={ __( 'Command palette' ) }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Icon icon={ inputIcon } />\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</div>\n\t\t\t\t\t<Command.List>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AAPA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAKA,IAAAI,KAAA,GAAAJ,OAAA;AAQA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAKA,IAAAO,kBAAA,GAAAP,OAAA;AAIA,IAAAQ,MAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AAhCA;AACA;AACA;;AAIA;AACA;AACA;;AAqBA;AACA;AACA;;AAGA,SAASU,iBAAiBA,CAAE;EAAEC,IAAI;EAAEC,MAAM;EAAEC,IAAI;EAAEC,SAAS;EAAEC;AAAM,CAAC,E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AQ,CACjB,CACG,CAAC,EACN,IAAAjE,QAAA,CAAAsB,aAAA,EAACpB,KAAA,CAAAsB,OAAO,CAACC,IAAI,QACVZ,MAAM,IAAI,CAAEK,SAAS,IACtB,IAAAlB,QAAA,CAAAsB,aAAA,EAACpB,KAAA,CAAAsB,OAAO,CAAC0F,KAAK,QACX,IAAAhC,QAAE,EAAE,mBAAoB,CACZ,CACf,EACD,IAAAlF,QAAA,CAAAsB,aAAA,EAAC+B,gBAAgB;IAChBxC,MAAM,EAAGA,MAAQ;IACjBE,SAAS,EAAGA,SAAW;IACvBC,KAAK,EAAGoF,aAAe;IACvB9C,YAAY;EAAA,CACZ,CAAC,EACAzC,MAAM,IACP,IAAAb,QAAA,CAAAsB,aAAA,EAAC+B,gBAAgB;IAChBxC,MAAM,EAAGA,MAAQ;IACjBE,SAAS,EAAGA,SAAW;IACvBC,KAAK,EAAGoF;EAAe,CACvB,CAEW,CACN,CACL,CACC,CAAC;AAEV"}
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = useCommandContext;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
9
|
var _store = require("../store");
|
|
13
|
-
|
|
14
10
|
var _lockUnlock = require("../lock-unlock");
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* WordPress dependencies
|
|
18
13
|
*/
|
|
@@ -36,9 +31,10 @@ function useCommandContext(context) {
|
|
|
36
31
|
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
37
32
|
(0, _element.useEffect)(() => {
|
|
38
33
|
setContext(context);
|
|
39
|
-
}, [context, setContext]);
|
|
40
|
-
// that was set before the component actually mounts.
|
|
34
|
+
}, [context, setContext]);
|
|
41
35
|
|
|
36
|
+
// This effects ensures that on unmount, we restore the context
|
|
37
|
+
// that was set before the component actually mounts.
|
|
42
38
|
(0, _element.useEffect)(() => {
|
|
43
39
|
const initialContextRef = initialContext.current;
|
|
44
40
|
return () => setContext(initialContextRef);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_store","_lockUnlock","useCommandContext","context","getContext","useSelect","commandsStore","initialContext","useRef","setContext","unlock","useDispatch","useEffect","initialContextRef","current"],"sources":["@wordpress/commands/src/hooks/use-command-context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Sets the active context of the command palette\n *\n * @param {string} context Context to set.\n */\nexport default function useCommandContext( context ) {\n\tconst { getContext } = useSelect( commandsStore );\n\tconst initialContext = useRef( getContext() );\n\tconst { setContext } = unlock( useDispatch( commandsStore ) );\n\n\tuseEffect( () => {\n\t\tsetContext( context );\n\t}, [ context, setContext ] );\n\n\t// This effects ensures that on unmount, we restore the context\n\t// that was set before the component actually mounts.\n\tuseEffect( () => {\n\t\tconst initialContextRef = initialContext.current;\n\t\treturn () => setContext( initialContextRef );\n\t}, [ setContext ] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACe,SAASI,iBAAiBA,CAAEC,OAAO,EAAG;EACpD,MAAM;IAAEC;EAAW,CAAC,GAAG,IAAAC,eAAS,EAAEC,YAAc,CAAC;EACjD,MAAMC,cAAc,GAAG,IAAAC,eAAM,EAAEJ,UAAU,CAAC,CAAE,CAAC;EAC7C,MAAM;IAAEK;EAAW,CAAC,GAAG,IAAAC,kBAAM,EAAE,IAAAC,iBAAW,EAAEL,YAAc,CAAE,CAAC;EAE7D,IAAAM,kBAAS,EAAE,MAAM;IAChBH,UAAU,CAAEN,OAAQ,CAAC;EACtB,CAAC,EAAE,CAAEA,OAAO,EAAEM,UAAU,CAAG,CAAC;;EAE5B;EACA;EACA,IAAAG,kBAAS,EAAE,MAAM;IAChB,MAAMC,iBAAiB,GAAGN,cAAc,CAACO,OAAO;IAChD,OAAO,MAAML,UAAU,CAAEI,iBAAkB,CAAC;EAC7C,CAAC,EAAE,CAAEJ,UAAU,CAAG,CAAC;AACpB"}
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = useCommandLoader;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
9
|
var _store = require("../store");
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* WordPress dependencies
|
|
16
12
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_store","useCommandLoader","loader","registerCommandLoader","unregisterCommandLoader","useDispatch","commandsStore","useEffect","name","hook","context"],"sources":["@wordpress/commands/src/hooks/use-command-loader.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASG,gBAAgBA,CAAEC,MAAM,EAAG;EAClD,MAAM;IAAEC,qBAAqB;IAAEC;EAAwB,CAAC,GACvD,IAAAC,iBAAW,EAAEC,YAAc,CAAC;EAC7B,IAAAC,kBAAS,EAAE,MAAM;IAChBJ,qBAAqB,CAAE;MACtBK,IAAI,EAAEN,MAAM,CAACM,IAAI;MACjBC,IAAI,EAAEP,MAAM,CAACO,IAAI;MACjBC,OAAO,EAAER,MAAM,CAACQ;IACjB,CAAE,CAAC;IACH,OAAO,MAAM;MACZN,uBAAuB,CAAEF,MAAM,CAACM,IAAK,CAAC;IACvC,CAAC;EACF,CAAC,EAAE,CACFN,MAAM,CAACM,IAAI,EACXN,MAAM,CAACO,IAAI,EACXP,MAAM,CAACQ,OAAO,EACdP,qBAAqB,EACrBC,uBAAuB,CACtB,CAAC;AACJ"}
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = useCommand;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
9
|
var _store = require("../store");
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* WordPress dependencies
|
|
16
12
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_store","useCommand","command","registerCommand","unregisterCommand","useDispatch","commandsStore","currentCallback","useRef","callback","useEffect","current","name","context","label","searchLabel","icon","args"],"sources":["@wordpress/commands/src/hooks/use-command.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command to the command palette.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n */\nexport default function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallback = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\n\t\tregisterCommand( {\n\t\t\tname: command.name,\n\t\t\tcontext: command.context,\n\t\t\tlabel: command.label,\n\t\t\tsearchLabel: command.searchLabel,\n\t\t\ticon: command.icon,\n\t\t\tcallback: ( ...args ) => currentCallback.current( ...args ),\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommand( command.name );\n\t\t};\n\t}, [\n\t\tcommand.name,\n\t\tcommand.label,\n\t\tcommand.searchLabel,\n\t\tcommand.icon,\n\t\tcommand.context,\n\t\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASG,UAAUA,CAAEC,OAAO,EAAG;EAC7C,MAAM;IAAEC,eAAe;IAAEC;EAAkB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAc,CAAC;EAC3E,MAAMC,eAAe,GAAG,IAAAC,eAAM,EAAEN,OAAO,CAACO,QAAS,CAAC;EAClD,IAAAC,kBAAS,EAAE,MAAM;IAChBH,eAAe,CAACI,OAAO,GAAGT,OAAO,CAACO,QAAQ;EAC3C,CAAC,EAAE,CAAEP,OAAO,CAACO,QAAQ,CAAG,CAAC;EAEzB,IAAAC,kBAAS,EAAE,MAAM;IAChBP,eAAe,CAAE;MAChBS,IAAI,EAAEV,OAAO,CAACU,IAAI;MAClBC,OAAO,EAAEX,OAAO,CAACW,OAAO;MACxBC,KAAK,EAAEZ,OAAO,CAACY,KAAK;MACpBC,WAAW,EAAEb,OAAO,CAACa,WAAW;MAChCC,IAAI,EAAEd,OAAO,CAACc,IAAI;MAClBP,QAAQ,EAAEA,CAAE,GAAGQ,IAAI,KAAMV,eAAe,CAACI,OAAO,CAAE,GAAGM,IAAK;IAC3D,CAAE,CAAC;IACH,OAAO,MAAM;MACZb,iBAAiB,CAAEF,OAAO,CAACU,IAAK,CAAC;IAClC,CAAC;EACF,CAAC,EAAE,CACFV,OAAO,CAACU,IAAI,EACZV,OAAO,CAACY,KAAK,EACbZ,OAAO,CAACa,WAAW,EACnBb,OAAO,CAACc,IAAI,EACZd,OAAO,CAACW,OAAO,EACfV,eAAe,EACfC,iBAAiB,CAChB,CAAC;AACJ"}
|
package/build/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -35,14 +34,9 @@ Object.defineProperty(exports, "useCommandLoader", {
|
|
|
35
34
|
return _useCommandLoader.default;
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
|
-
|
|
39
37
|
var _commandMenu = require("./components/command-menu");
|
|
40
|
-
|
|
41
38
|
var _privateApis = require("./private-apis");
|
|
42
|
-
|
|
43
39
|
var _useCommand = _interopRequireDefault(require("./hooks/use-command"));
|
|
44
|
-
|
|
45
40
|
var _useCommandLoader = _interopRequireDefault(require("./hooks/use-command-loader"));
|
|
46
|
-
|
|
47
41
|
var _store = require("./store");
|
|
48
42
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/commands/src/index.js"],"
|
|
1
|
+
{"version":3,"names":["_commandMenu","require","_privateApis","_useCommand","_interopRequireDefault","_useCommandLoader","_store"],"sources":["@wordpress/commands/src/index.js"],"sourcesContent":["export { CommandMenu } from './components/command-menu';\nexport { privateApis } from './private-apis';\nexport { default as useCommand } from './hooks/use-command';\nexport { default as useCommandLoader } from './hooks/use-command-loader';\nexport { store } from './store';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA"}
|
package/build/lock-unlock.js
CHANGED
package/build/lock-unlock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_privateApis","require","lock","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/commands/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/commands'\n\t);\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5B,IAAAC,6DAAgD,EAC/C,8GAA8G,EAC9G,qBACD,CAAC;AAACC,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA"}
|
package/build/private-apis.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.privateApis = void 0;
|
|
9
|
-
|
|
10
8
|
var _useCommandContext = _interopRequireDefault(require("./hooks/use-command-context"));
|
|
11
|
-
|
|
12
9
|
var _lockUnlock = require("./lock-unlock");
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* Internal dependencies
|
|
16
12
|
*/
|
|
13
|
+
|
|
17
14
|
const privateApis = {};
|
|
18
15
|
exports.privateApis = privateApis;
|
|
19
16
|
(0, _lockUnlock.lock)(privateApis, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_useCommandContext","_interopRequireDefault","require","_lockUnlock","privateApis","exports","lock","useCommandContext"],"sources":["@wordpress/commands/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { default as useCommandContext } from './hooks/use-command-context';\nimport { lock } from './lock-unlock';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommandContext,\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIO,MAAME,WAAW,GAAG,CAAC,CAAC;AAACC,OAAA,CAAAD,WAAA,GAAAA,WAAA;AAC9B,IAAAE,gBAAI,EAAEF,WAAW,EAAE;EAClBG,iBAAiB,EAAjBA;AACD,CAAE,CAAC"}
|
package/build/store/actions.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.registerCommand = registerCommand;
|
|
|
9
9
|
exports.registerCommandLoader = registerCommandLoader;
|
|
10
10
|
exports.unregisterCommand = unregisterCommand;
|
|
11
11
|
exports.unregisterCommandLoader = unregisterCommandLoader;
|
|
12
|
-
|
|
13
12
|
/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -52,6 +51,7 @@ function registerCommand(config) {
|
|
|
52
51
|
...config
|
|
53
52
|
};
|
|
54
53
|
}
|
|
54
|
+
|
|
55
55
|
/**
|
|
56
56
|
* Returns an action object used to unregister a command.
|
|
57
57
|
*
|
|
@@ -59,14 +59,13 @@ function registerCommand(config) {
|
|
|
59
59
|
*
|
|
60
60
|
* @return {Object} action.
|
|
61
61
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
62
|
function unregisterCommand(name) {
|
|
65
63
|
return {
|
|
66
64
|
type: 'UNREGISTER_COMMAND',
|
|
67
65
|
name
|
|
68
66
|
};
|
|
69
67
|
}
|
|
68
|
+
|
|
70
69
|
/**
|
|
71
70
|
* Register command loader.
|
|
72
71
|
*
|
|
@@ -74,14 +73,13 @@ function unregisterCommand(name) {
|
|
|
74
73
|
*
|
|
75
74
|
* @return {Object} action.
|
|
76
75
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
76
|
function registerCommandLoader(config) {
|
|
80
77
|
return {
|
|
81
78
|
type: 'REGISTER_COMMAND_LOADER',
|
|
82
79
|
...config
|
|
83
80
|
};
|
|
84
81
|
}
|
|
82
|
+
|
|
85
83
|
/**
|
|
86
84
|
* Unregister command loader hook.
|
|
87
85
|
*
|
|
@@ -89,33 +87,29 @@ function registerCommandLoader(config) {
|
|
|
89
87
|
*
|
|
90
88
|
* @return {Object} action.
|
|
91
89
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
90
|
function unregisterCommandLoader(name) {
|
|
95
91
|
return {
|
|
96
92
|
type: 'UNREGISTER_COMMAND_LOADER',
|
|
97
93
|
name
|
|
98
94
|
};
|
|
99
95
|
}
|
|
96
|
+
|
|
100
97
|
/**
|
|
101
98
|
* Opens the command palette.
|
|
102
99
|
*
|
|
103
100
|
* @return {Object} action.
|
|
104
101
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
102
|
function open() {
|
|
108
103
|
return {
|
|
109
104
|
type: 'OPEN'
|
|
110
105
|
};
|
|
111
106
|
}
|
|
107
|
+
|
|
112
108
|
/**
|
|
113
109
|
* Closes the command palette.
|
|
114
110
|
*
|
|
115
111
|
* @return {Object} action.
|
|
116
112
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
113
|
function close() {
|
|
120
114
|
return {
|
|
121
115
|
type: 'CLOSE'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["registerCommand","config","type","unregisterCommand","name","registerCommandLoader","unregisterCommandLoader","open","close"],"sources":["@wordpress/commands/src/store/actions.js"],"sourcesContent":["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPCommandConfig\n *\n * @property {string} name Command name.\n * @property {string} label Command label.\n * @property {string=} searchLabel Command search label.\n * @property {string=} context Command context.\n * @property {JSX.Element} icon Command icon.\n * @property {Function} callback Command callback.\n */\n\n/**\n * @typedef {(search: string) => WPCommandConfig[]} WPCommandLoaderHook hoo\n */\n\n/**\n * Command loader config.\n *\n * @typedef {Object} WPCommandLoaderConfig\n *\n * @property {string} name Command loader name.\n * @property {string=} context Command loader context.\n * @property {WPCommandLoaderHook} hook Command loader hook.\n */\n\n/**\n * Returns an action object used to register a new command.\n *\n * @param {WPCommandConfig} config Command config.\n *\n * @return {Object} action.\n */\nexport function registerCommand( config ) {\n\treturn {\n\t\ttype: 'REGISTER_COMMAND',\n\t\t...config,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a command.\n *\n * @param {string} name Command name.\n *\n * @return {Object} action.\n */\nexport function unregisterCommand( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_COMMAND',\n\t\tname,\n\t};\n}\n\n/**\n * Register command loader.\n *\n * @param {WPCommandLoaderConfig} config Command loader config.\n *\n * @return {Object} action.\n */\nexport function registerCommandLoader( config ) {\n\treturn {\n\t\ttype: 'REGISTER_COMMAND_LOADER',\n\t\t...config,\n\t};\n}\n\n/**\n * Unregister command loader hook.\n *\n * @param {string} name Command loader name.\n *\n * @return {Object} action.\n */\nexport function unregisterCommandLoader( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_COMMAND_LOADER',\n\t\tname,\n\t};\n}\n\n/**\n * Opens the command palette.\n *\n * @return {Object} action.\n */\nexport function open() {\n\treturn {\n\t\ttype: 'OPEN',\n\t};\n}\n\n/**\n * Closes the command palette.\n *\n * @return {Object} action.\n */\nexport function close() {\n\treturn {\n\t\ttype: 'CLOSE',\n\t};\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAeA,CAAEC,MAAM,EAAG;EACzC,OAAO;IACNC,IAAI,EAAE,kBAAkB;IACxB,GAAGD;EACJ,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,iBAAiBA,CAAEC,IAAI,EAAG;EACzC,OAAO;IACNF,IAAI,EAAE,oBAAoB;IAC1BE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAAEJ,MAAM,EAAG;EAC/C,OAAO;IACNC,IAAI,EAAE,yBAAyB;IAC/B,GAAGD;EACJ,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,uBAAuBA,CAAEF,IAAI,EAAG;EAC/C,OAAO;IACNF,IAAI,EAAE,2BAA2B;IACjCE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASG,IAAIA,CAAA,EAAG;EACtB,OAAO;IACNL,IAAI,EAAE;EACP,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASM,KAAKA,CAAA,EAAG;EACvB,OAAO;IACNN,IAAI,EAAE;EACP,CAAC;AACF"}
|
package/build/store/index.js
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.store = void 0;
|
|
9
|
-
|
|
10
8
|
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
9
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
13
|
-
|
|
14
10
|
var actions = _interopRequireWildcard(require("./actions"));
|
|
15
|
-
|
|
16
11
|
var selectors = _interopRequireWildcard(require("./selectors"));
|
|
17
|
-
|
|
18
12
|
var privateActions = _interopRequireWildcard(require("./private-actions"));
|
|
19
|
-
|
|
20
13
|
var _lockUnlock = require("../lock-unlock");
|
|
21
|
-
|
|
22
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
-
|
|
24
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
-
|
|
26
16
|
/**
|
|
27
17
|
* WordPress dependencies
|
|
28
18
|
*/
|
|
@@ -30,7 +20,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
30
20
|
/**
|
|
31
21
|
* Internal dependencies
|
|
32
22
|
*/
|
|
23
|
+
|
|
33
24
|
const STORE_NAME = 'core/commands';
|
|
25
|
+
|
|
34
26
|
/**
|
|
35
27
|
* Store definition for the commands namespace.
|
|
36
28
|
*
|
|
@@ -38,7 +30,6 @@ const STORE_NAME = 'core/commands';
|
|
|
38
30
|
*
|
|
39
31
|
* @type {Object}
|
|
40
32
|
*/
|
|
41
|
-
|
|
42
33
|
const store = (0, _data.createReduxStore)(STORE_NAME, {
|
|
43
34
|
reducer: _reducer.default,
|
|
44
35
|
actions,
|