@wordpress/commands 0.4.0 → 0.6.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 +4 -0
- package/README.md +28 -0
- package/build/components/command-menu.js +78 -72
- package/build/components/command-menu.js.map +1 -1
- package/build/hooks/use-command-context.js +47 -0
- package/build/hooks/use-command-context.js.map +1 -0
- package/build/hooks/use-command-loader.js +6 -11
- package/build/hooks/use-command-loader.js.map +1 -1
- package/build/hooks/use-command.js +4 -3
- package/build/hooks/use-command.js.map +1 -1
- package/build/index.js +26 -0
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +19 -0
- package/build/lock-unlock.js.map +1 -0
- package/build/private-apis.js +5 -21
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +19 -40
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +5 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +21 -0
- package/build/store/private-actions.js.map +1 -0
- package/build/store/reducer.js +38 -34
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +14 -17
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/command-menu.js +78 -72
- package/build-module/components/command-menu.js.map +1 -1
- package/build-module/hooks/use-command-context.js +36 -0
- package/build-module/hooks/use-command-context.js.map +1 -0
- package/build-module/hooks/use-command-loader.js +6 -11
- package/build-module/hooks/use-command-loader.js.map +1 -1
- package/build-module/hooks/use-command.js +4 -3
- package/build-module/hooks/use-command.js.map +1 -1
- package/build-module/index.js +3 -0
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +9 -0
- package/build-module/lock-unlock.js.map +1 -0
- package/build-module/private-apis.js +3 -15
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +19 -40
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +3 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +14 -0
- package/build-module/store/private-actions.js.map +1 -0
- package/build-module/store/reducer.js +38 -34
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +11 -16
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +6 -1
- package/build-style/style.css +6 -1
- package/package.json +9 -9
- package/src/components/command-menu.js +38 -35
- package/src/components/style.scss +8 -1
- package/src/hooks/use-command-context.js +33 -0
- package/src/hooks/use-command-loader.js +12 -6
- package/src/hooks/use-command.js +5 -3
- package/src/index.js +3 -0
- package/src/lock-unlock.js +10 -0
- package/src/private-apis.js +3 -17
- package/src/store/actions.js +17 -26
- package/src/store/index.js +3 -0
- package/src/store/private-actions.js +13 -0
- package/src/store/reducer.js +33 -27
- package/src/store/selectors.js +18 -20
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -24,6 +24,34 @@ Undocumented declaration.
|
|
|
24
24
|
|
|
25
25
|
Undocumented declaration.
|
|
26
26
|
|
|
27
|
+
### store
|
|
28
|
+
|
|
29
|
+
Store definition for the commands namespace.
|
|
30
|
+
|
|
31
|
+
_Related_
|
|
32
|
+
|
|
33
|
+
- <https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore>
|
|
34
|
+
|
|
35
|
+
_Type_
|
|
36
|
+
|
|
37
|
+
- `Object`
|
|
38
|
+
|
|
39
|
+
### useCommand
|
|
40
|
+
|
|
41
|
+
Attach a command to the Global command menu.
|
|
42
|
+
|
|
43
|
+
_Parameters_
|
|
44
|
+
|
|
45
|
+
- _command_ `import('../store/actions').WPCommandConfig`: command config.
|
|
46
|
+
|
|
47
|
+
### useCommandLoader
|
|
48
|
+
|
|
49
|
+
Attach a command loader to the Global command menu.
|
|
50
|
+
|
|
51
|
+
_Parameters_
|
|
52
|
+
|
|
53
|
+
- _loader_ `import('../store/actions').WPCommandLoaderConfig`: command loader config.
|
|
54
|
+
|
|
27
55
|
<!-- END TOKEN(Autogenerated API docs) -->
|
|
28
56
|
|
|
29
57
|
## Contributing to this package
|
|
@@ -34,16 +34,15 @@ var _store = require("../store");
|
|
|
34
34
|
/**
|
|
35
35
|
* Internal dependencies
|
|
36
36
|
*/
|
|
37
|
-
function CommandMenuLoader(
|
|
37
|
+
function CommandMenuLoader({
|
|
38
|
+
name,
|
|
39
|
+
search,
|
|
40
|
+
hook,
|
|
41
|
+
setLoader,
|
|
42
|
+
close
|
|
43
|
+
}) {
|
|
38
44
|
var _hook;
|
|
39
45
|
|
|
40
|
-
let {
|
|
41
|
-
name,
|
|
42
|
-
search,
|
|
43
|
-
hook,
|
|
44
|
-
setLoader,
|
|
45
|
-
close
|
|
46
|
-
} = _ref;
|
|
47
46
|
const {
|
|
48
47
|
isLoading,
|
|
49
48
|
commands = []
|
|
@@ -53,30 +52,38 @@ function CommandMenuLoader(_ref) {
|
|
|
53
52
|
(0, _element.useEffect)(() => {
|
|
54
53
|
setLoader(name, isLoading);
|
|
55
54
|
}, [setLoader, name, isLoading]);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
55
|
+
|
|
56
|
+
if (!commands.length) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_cmdk.Command.List, null, commands.map(command => {
|
|
61
|
+
var _command$searchLabel;
|
|
62
|
+
|
|
63
|
+
return (0, _element.createElement)(_cmdk.Command.Item, {
|
|
64
|
+
key: command.name,
|
|
65
|
+
value: (_command$searchLabel = command.searchLabel) !== null && _command$searchLabel !== void 0 ? _command$searchLabel : command.label,
|
|
66
|
+
onSelect: () => command.callback({
|
|
67
|
+
close
|
|
68
|
+
})
|
|
69
|
+
}, (0, _element.createElement)(_components.__experimentalHStack, {
|
|
70
|
+
alignment: "left",
|
|
71
|
+
className: "commands-command-menu__item"
|
|
72
|
+
}, (0, _element.createElement)(_icons.Icon, {
|
|
73
|
+
icon: command.icon
|
|
74
|
+
}), (0, _element.createElement)("span", null, (0, _element.createElement)(_components.TextHighlight, {
|
|
75
|
+
text: command.label,
|
|
76
|
+
highlight: search
|
|
77
|
+
}))));
|
|
78
|
+
})));
|
|
71
79
|
}
|
|
72
80
|
|
|
73
|
-
function CommandMenuLoaderWrapper(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
} = _ref2;
|
|
81
|
+
function CommandMenuLoaderWrapper({
|
|
82
|
+
hook,
|
|
83
|
+
search,
|
|
84
|
+
setLoader,
|
|
85
|
+
close
|
|
86
|
+
}) {
|
|
80
87
|
// The "hook" prop is actually a custom React hook
|
|
81
88
|
// so to avoid breaking the rules of hooks
|
|
82
89
|
// the CommandMenuLoaderWrapper component need to be
|
|
@@ -99,13 +106,12 @@ function CommandMenuLoaderWrapper(_ref2) {
|
|
|
99
106
|
});
|
|
100
107
|
}
|
|
101
108
|
|
|
102
|
-
function CommandMenuGroup(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
} = _ref3;
|
|
109
|
+
function CommandMenuGroup({
|
|
110
|
+
isContextual,
|
|
111
|
+
search,
|
|
112
|
+
setLoader,
|
|
113
|
+
close
|
|
114
|
+
}) {
|
|
109
115
|
const {
|
|
110
116
|
commands,
|
|
111
117
|
loaders
|
|
@@ -115,25 +121,34 @@ function CommandMenuGroup(_ref3) {
|
|
|
115
121
|
getCommandLoaders
|
|
116
122
|
} = select(_store.store);
|
|
117
123
|
return {
|
|
118
|
-
commands: getCommands(
|
|
119
|
-
loaders: getCommandLoaders(
|
|
124
|
+
commands: getCommands(isContextual),
|
|
125
|
+
loaders: getCommandLoaders(isContextual)
|
|
120
126
|
};
|
|
121
|
-
}, [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
}, [isContextual]);
|
|
128
|
+
|
|
129
|
+
if (!commands.length && !loaders.length) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return (0, _element.createElement)(_cmdk.Command.Group, null, commands.map(command => {
|
|
134
|
+
var _command$searchLabel2;
|
|
135
|
+
|
|
136
|
+
return (0, _element.createElement)(_cmdk.Command.Item, {
|
|
137
|
+
key: command.name,
|
|
138
|
+
value: (_command$searchLabel2 = command.searchLabel) !== null && _command$searchLabel2 !== void 0 ? _command$searchLabel2 : command.label,
|
|
139
|
+
onSelect: () => command.callback({
|
|
140
|
+
close
|
|
141
|
+
})
|
|
142
|
+
}, (0, _element.createElement)(_components.__experimentalHStack, {
|
|
143
|
+
alignment: "left",
|
|
144
|
+
className: "commands-command-menu__item"
|
|
145
|
+
}, (0, _element.createElement)(_icons.Icon, {
|
|
146
|
+
icon: command.icon
|
|
147
|
+
}), (0, _element.createElement)("span", null, (0, _element.createElement)(_components.TextHighlight, {
|
|
148
|
+
text: command.label,
|
|
149
|
+
highlight: search
|
|
150
|
+
}))));
|
|
151
|
+
}), loaders.map(loader => (0, _element.createElement)(CommandMenuLoaderWrapper, {
|
|
137
152
|
key: loader.name,
|
|
138
153
|
hook: loader.hook,
|
|
139
154
|
search: search,
|
|
@@ -147,19 +162,7 @@ function CommandMenu() {
|
|
|
147
162
|
registerShortcut
|
|
148
163
|
} = (0, _data.useDispatch)(_keyboardShortcuts.store);
|
|
149
164
|
const [search, setSearch] = (0, _element.useState)('');
|
|
150
|
-
const
|
|
151
|
-
groups,
|
|
152
|
-
isOpen
|
|
153
|
-
} = (0, _data.useSelect)(select => {
|
|
154
|
-
const {
|
|
155
|
-
getGroups,
|
|
156
|
-
isOpen: _isOpen
|
|
157
|
-
} = select(_store.store);
|
|
158
|
-
return {
|
|
159
|
-
groups: getGroups(),
|
|
160
|
-
isOpen: _isOpen()
|
|
161
|
-
};
|
|
162
|
-
}, []);
|
|
165
|
+
const isOpen = (0, _data.useSelect)(select => select(_store.store).isOpen(), []);
|
|
163
166
|
const {
|
|
164
167
|
open,
|
|
165
168
|
close
|
|
@@ -225,12 +228,15 @@ function CommandMenu() {
|
|
|
225
228
|
value: search,
|
|
226
229
|
onValueChange: setSearch,
|
|
227
230
|
placeholder: (0, _i18n.__)('Type a command or search')
|
|
228
|
-
})),
|
|
229
|
-
|
|
230
|
-
|
|
231
|
+
})), (0, _element.createElement)(_cmdk.Command.List, null, search && !isLoading && (0, _element.createElement)(_cmdk.Command.Empty, null, (0, _i18n.__)('No results found.')), (0, _element.createElement)(CommandMenuGroup, {
|
|
232
|
+
search: search,
|
|
233
|
+
setLoader: setLoader,
|
|
234
|
+
close: closeAndReset,
|
|
235
|
+
isContextual: true
|
|
236
|
+
}), search && (0, _element.createElement)(CommandMenuGroup, {
|
|
231
237
|
search: search,
|
|
232
238
|
setLoader: setLoader,
|
|
233
239
|
close: closeAndReset
|
|
234
|
-
})))))
|
|
240
|
+
})))));
|
|
235
241
|
}
|
|
236
242
|
//# sourceMappingURL=command-menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/commands/src/components/command-menu.js"],"names":["CommandMenuLoader","name","search","hook","setLoader","close","isLoading","commands","map","command","callback","icon","label","CommandMenuLoaderWrapper","currentLoader","key","setKey","current","prevKey","CommandMenuGroup","group","loaders","select","getCommands","getCommandLoaders","commandsStore","loader","CommandMenu","registerShortcut","keyboardShortcutsStore","setSearch","groups","isOpen","getGroups","_isOpen","open","setLoaders","commandMenuInput","category","description","keyCombination","modifier","character","event","preventDefault","bindGlobal","value","closeAndReset","focus","Object","values","some","Boolean"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AAIA;;AAKA;;AAz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C,iBAAD;AACC,IAAA,SAAS,EAAC,uBADX;AAEC,IAAA,gBAAgB,EAAC,gCAFlB;AAGC,IAAA,cAAc,EAAGL,aAHlB;AAIC,IAAA,wBAAwB;AAJzB,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,aAAD;AAAS,IAAA,KAAK,EAAG,cAAI,qBAAJ;AAAjB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,aAAD,CAAS,KAAT;AACC,IAAA,GAAG,EAAGV,gBADP;AAEC,IAAA,KAAK,EAAGnC,MAFT;AAGC,IAAA,aAAa,EAAG4B,SAHjB;AAIC,IAAA,WAAW,EAAG,cAAI,0BAAJ;AAJf,IADD,CADD,EASG5B,MAAM,IACP,4BAAC,aAAD,CAAS,IAAT,QACG,CAAEI,SAAF,IACD,4BAAC,aAAD,CAAS,KAAT,QACG,cAAI,mBAAJ,CADH,CAFF,EAMGyB,MAAM,CAACvB,GAAP,CAAcY,KAAF,IACb,4BAAC,gBAAD;AACC,IAAA,GAAG,EAAGA,KADP;AAEC,IAAA,KAAK,EAAGA,KAFT;AAGC,IAAA,MAAM,EAAGlB,MAHV;AAIC,IAAA,SAAS,EAAGE,SAJb;AAKC,IAAA,KAAK,EAAG2C;AALT,IADC,CANH,CAVF,CADD,CAND,CADD;AAuCA","sourcesContent":["/**\n * External dependencies\n */\nimport { Command } from 'cmdk';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tModal,\n\tTextHighlight,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport {\n\tstore as keyboardShortcutsStore,\n\tuseShortcut,\n} from '@wordpress/keyboard-shortcuts';\nimport { Icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\treturn (\n\t\t<>\n\t\t\t<Command.List>\n\t\t\t\t{ isLoading && (\n\t\t\t\t\t<Command.Loading>{ __( 'Searching…' ) }</Command.Loading>\n\t\t\t\t) }\n\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.name }\n\t\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Command.Item>\n\t\t\t\t) ) }\n\t\t\t</Command.List>\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { group, 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( group ),\n\t\t\t\tloaders: getCommandLoaders( group ),\n\t\t\t};\n\t\t},\n\t\t[ group ]\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.name }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst { groups, isOpen } = useSelect( ( select ) => {\n\t\tconst { getGroups, isOpen: _isOpen } = select( commandsStore );\n\t\treturn {\n\t\t\tgroups: getGroups(),\n\t\t\tisOpen: _isOpen(),\n\t\t};\n\t}, [] );\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\tconst commandMenuInput = useRef();\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the global command menu' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\tif ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tuseEffect( () => {\n\t\t// Focus the command menu input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ __( 'Global Command Menu' ) }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Command.Input\n\t\t\t\t\t\t\tref={ commandMenuInput }\n\t\t\t\t\t\t\tvalue={ search }\n\t\t\t\t\t\t\tonValueChange={ setSearch }\n\t\t\t\t\t\t\tplaceholder={ __( 'Type a command or search' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ search && (\n\t\t\t\t\t\t<Command.List>\n\t\t\t\t\t\t\t{ ! isLoading && (\n\t\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ groups.map( ( group ) => (\n\t\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\t\tkey={ group }\n\t\t\t\t\t\t\t\t\tgroup={ group }\n\t\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t</Command.List>\n\t\t\t\t\t) }\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/components/command-menu.js"],"names":["CommandMenuLoader","name","search","hook","setLoader","close","isLoading","commands","length","map","command","searchLabel","label","callback","icon","CommandMenuLoaderWrapper","currentLoader","key","setKey","current","prevKey","CommandMenuGroup","isContextual","loaders","select","getCommands","getCommandLoaders","commandsStore","loader","CommandMenu","registerShortcut","keyboardShortcutsStore","setSearch","isOpen","open","setLoaders","commandMenuInput","category","description","keyCombination","modifier","character","event","preventDefault","bindGlobal","value","closeAndReset","focus","Object","values","some","Boolean"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AAIA;;AAKA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAGA,SAASA,iBAAT,CAA4B;AAAEC,EAAAA,IAAF;AAAQ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;AAIC,IAAA,wBAAwB;AAJzB,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,aAAD;AAAS,IAAA,KAAK,EAAG,cAAI,qBAAJ;AAAjB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,aAAD,CAAS,KAAT;AACC,IAAA,GAAG,EAAGV,gBADP;AAEC,IAAA,KAAK,EAAGlC,MAFT;AAGC,IAAA,aAAa,EAAG8B,SAHjB;AAIC,IAAA,WAAW,EAAG,cAAI,0BAAJ;AAJf,IADD,CADD,EASC,4BAAC,aAAD,CAAS,IAAT,QACG9B,MAAM,IAAI,CAAEI,SAAZ,IACD,4BAAC,aAAD,CAAS,KAAT,QACG,cAAI,mBAAJ,CADH,CAFF,EAMC,4BAAC,gBAAD;AACC,IAAA,MAAM,EAAGJ,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAG0C,aAHT;AAIC,IAAA,YAAY;AAJb,IAND,EAYG5C,MAAM,IACP,4BAAC,gBAAD;AACC,IAAA,MAAM,EAAGA,MADV;AAEC,IAAA,SAAS,EAAGE,SAFb;AAGC,IAAA,KAAK,EAAG0C;AAHT,IAbF,CATD,CADD,CAND,CADD;AAyCA","sourcesContent":["/**\n * External dependencies\n */\nimport { Command } from 'cmdk';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tModal,\n\tTextHighlight,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport {\n\tstore as keyboardShortcutsStore,\n\tuseShortcut,\n} from '@wordpress/keyboard-shortcuts';\nimport { Icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Command.List>\n\t\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t\t<Command.Item\n\t\t\t\t\t\tkey={ command.name }\n\t\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Command.Item>\n\t\t\t\t) ) }\n\t\t\t</Command.List>\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoader = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoader.current !== hook ) {\n\t\t\tcurrentLoader.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoader.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName=\"commands-command-menu__item\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst isOpen = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\tconst commandMenuInput = useRef();\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the global command menu' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\tif ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tuseEffect( () => {\n\t\t// Focus the command menu input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ __( 'Global Command Menu' ) }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Command.Input\n\t\t\t\t\t\t\tref={ commandMenuInput }\n\t\t\t\t\t\t\tvalue={ search }\n\t\t\t\t\t\t\tonValueChange={ setSearch }\n\t\t\t\t\t\t\tplaceholder={ __( 'Type a command or search' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useCommandContext;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
|
+
|
|
12
|
+
var _store = require("../store");
|
|
13
|
+
|
|
14
|
+
var _lockUnlock = require("../lock-unlock");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* WordPress dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sets the active context of the command center
|
|
26
|
+
*
|
|
27
|
+
* @param {string} context Context to set.
|
|
28
|
+
*/
|
|
29
|
+
function useCommandContext(context) {
|
|
30
|
+
const {
|
|
31
|
+
getContext
|
|
32
|
+
} = (0, _data.useSelect)(_store.store);
|
|
33
|
+
const initialContext = (0, _element.useRef)(getContext());
|
|
34
|
+
const {
|
|
35
|
+
setContext
|
|
36
|
+
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
37
|
+
(0, _element.useEffect)(() => {
|
|
38
|
+
setContext(context);
|
|
39
|
+
}, [context, setContext]); // This effects ensures that on unmount, we restore the context
|
|
40
|
+
// that was set before the component actually mounts.
|
|
41
|
+
|
|
42
|
+
(0, _element.useEffect)(() => {
|
|
43
|
+
const initialContextRef = initialContext.current;
|
|
44
|
+
return () => setContext(initialContextRef);
|
|
45
|
+
}, [setContext]);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=use-command-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/hooks/use-command-context.js"],"names":["useCommandContext","context","getContext","commandsStore","initialContext","setContext","initialContextRef","current"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACe,SAASA,iBAAT,CAA4BC,OAA5B,EAAsC;AACpD,QAAM;AAAEC,IAAAA;AAAF,MAAiB,qBAAWC,YAAX,CAAvB;AACA,QAAMC,cAAc,GAAG,qBAAQF,UAAU,EAAlB,CAAvB;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAiB,wBAAQ,uBAAaF,YAAb,CAAR,CAAvB;AAEA,0BAAW,MAAM;AAChBE,IAAAA,UAAU,CAAEJ,OAAF,CAAV;AACA,GAFD,EAEG,CAAEA,OAAF,EAAWI,UAAX,CAFH,EALoD,CASpD;AACA;;AACA,0BAAW,MAAM;AAChB,UAAMC,iBAAiB,GAAGF,cAAc,CAACG,OAAzC;AACA,WAAO,MAAMF,UAAU,CAAEC,iBAAF,CAAvB;AACA,GAHD,EAGG,CAAED,UAAF,CAHH;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Sets the active context of the command center\n *\n * @param {string} context Context to set.\n */\nexport default function useCommandContext( context ) {\n\tconst { getContext } = useSelect( commandsStore );\n\tconst initialContext = useRef( getContext() );\n\tconst { setContext } = unlock( useDispatch( commandsStore ) );\n\n\tuseEffect( () => {\n\t\tsetContext( context );\n\t}, [ context, setContext ] );\n\n\t// This effects ensures that on unmount, we restore the context\n\t// that was set before the component actually mounts.\n\tuseEffect( () => {\n\t\tconst initialContextRef = initialContext.current;\n\t\treturn () => setContext( initialContextRef );\n\t}, [ setContext ] );\n}\n"]}
|
|
@@ -24,25 +24,20 @@ var _store = require("../store");
|
|
|
24
24
|
*
|
|
25
25
|
* @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.
|
|
26
26
|
*/
|
|
27
|
-
function useCommandLoader(
|
|
28
|
-
let {
|
|
29
|
-
name,
|
|
30
|
-
group,
|
|
31
|
-
hook
|
|
32
|
-
} = _ref;
|
|
27
|
+
function useCommandLoader(loader) {
|
|
33
28
|
const {
|
|
34
29
|
registerCommandLoader,
|
|
35
30
|
unregisterCommandLoader
|
|
36
31
|
} = (0, _data.useDispatch)(_store.store);
|
|
37
32
|
(0, _element.useEffect)(() => {
|
|
38
33
|
registerCommandLoader({
|
|
39
|
-
name,
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
name: loader.name,
|
|
35
|
+
hook: loader.hook,
|
|
36
|
+
context: loader.context
|
|
42
37
|
});
|
|
43
38
|
return () => {
|
|
44
|
-
unregisterCommandLoader(name
|
|
39
|
+
unregisterCommandLoader(loader.name);
|
|
45
40
|
};
|
|
46
|
-
}, [name,
|
|
41
|
+
}, [loader.name, loader.hook, loader.context, registerCommandLoader, unregisterCommandLoader]);
|
|
47
42
|
}
|
|
48
43
|
//# sourceMappingURL=use-command-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/commands/src/hooks/use-command-loader.js"],"names":["useCommandLoader","
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/hooks/use-command-loader.js"],"names":["useCommandLoader","loader","registerCommandLoader","unregisterCommandLoader","commandsStore","name","hook","context"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,gBAAT,CAA2BC,MAA3B,EAAoC;AAClD,QAAM;AAAEC,IAAAA,qBAAF;AAAyBC,IAAAA;AAAzB,MACL,uBAAaC,YAAb,CADD;AAEA,0BAAW,MAAM;AAChBF,IAAAA,qBAAqB,CAAE;AACtBG,MAAAA,IAAI,EAAEJ,MAAM,CAACI,IADS;AAEtBC,MAAAA,IAAI,EAAEL,MAAM,CAACK,IAFS;AAGtBC,MAAAA,OAAO,EAAEN,MAAM,CAACM;AAHM,KAAF,CAArB;AAKA,WAAO,MAAM;AACZJ,MAAAA,uBAAuB,CAAEF,MAAM,CAACI,IAAT,CAAvB;AACA,KAFD;AAGA,GATD,EASG,CACFJ,MAAM,CAACI,IADL,EAEFJ,MAAM,CAACK,IAFL,EAGFL,MAAM,CAACM,OAHL,EAIFL,qBAJE,EAKFC,uBALE,CATH;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the Global command menu.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"]}
|
|
@@ -36,14 +36,15 @@ function useCommand(command) {
|
|
|
36
36
|
(0, _element.useEffect)(() => {
|
|
37
37
|
registerCommand({
|
|
38
38
|
name: command.name,
|
|
39
|
-
|
|
39
|
+
context: command.context,
|
|
40
40
|
label: command.label,
|
|
41
|
+
searchLabel: command.searchLabel,
|
|
41
42
|
icon: command.icon,
|
|
42
43
|
callback: currentCallback.current
|
|
43
44
|
});
|
|
44
45
|
return () => {
|
|
45
|
-
unregisterCommand(command.name
|
|
46
|
+
unregisterCommand(command.name);
|
|
46
47
|
};
|
|
47
|
-
}, [command.name, command.label, command.
|
|
48
|
+
}, [command.name, command.label, command.searchLabel, command.icon, command.context, registerCommand, unregisterCommand]);
|
|
48
49
|
}
|
|
49
50
|
//# sourceMappingURL=use-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/commands/src/hooks/use-command.js"],"names":["useCommand","command","registerCommand","unregisterCommand","commandsStore","currentCallback","callback","current","name","
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/hooks/use-command.js"],"names":["useCommand","command","registerCommand","unregisterCommand","commandsStore","currentCallback","callback","current","name","context","label","searchLabel","icon"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,UAAT,CAAqBC,OAArB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAyC,uBAAaC,YAAb,CAA/C;AACA,QAAMC,eAAe,GAAG,qBAAQJ,OAAO,CAACK,QAAhB,CAAxB;AACA,0BAAW,MAAM;AAChBD,IAAAA,eAAe,CAACE,OAAhB,GAA0BN,OAAO,CAACK,QAAlC;AACA,GAFD,EAEG,CAAEL,OAAO,CAACK,QAAV,CAFH;AAIA,0BAAW,MAAM;AAChBJ,IAAAA,eAAe,CAAE;AAChBM,MAAAA,IAAI,EAAEP,OAAO,CAACO,IADE;AAEhBC,MAAAA,OAAO,EAAER,OAAO,CAACQ,OAFD;AAGhBC,MAAAA,KAAK,EAAET,OAAO,CAACS,KAHC;AAIhBC,MAAAA,WAAW,EAAEV,OAAO,CAACU,WAJL;AAKhBC,MAAAA,IAAI,EAAEX,OAAO,CAACW,IALE;AAMhBN,MAAAA,QAAQ,EAAED,eAAe,CAACE;AANV,KAAF,CAAf;AAQA,WAAO,MAAM;AACZJ,MAAAA,iBAAiB,CAAEF,OAAO,CAACO,IAAV,CAAjB;AACA,KAFD;AAGA,GAZD,EAYG,CACFP,OAAO,CAACO,IADN,EAEFP,OAAO,CAACS,KAFN,EAGFT,OAAO,CAACU,WAHN,EAIFV,OAAO,CAACW,IAJN,EAKFX,OAAO,CAACQ,OALN,EAMFP,eANE,EAOFC,iBAPE,CAZH;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command to the Global command menu.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n */\nexport default function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallback = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\n\t\tregisterCommand( {\n\t\t\tname: command.name,\n\t\t\tcontext: command.context,\n\t\t\tlabel: command.label,\n\t\t\tsearchLabel: command.searchLabel,\n\t\t\ticon: command.icon,\n\t\t\tcallback: currentCallback.current,\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"]}
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -15,8 +17,32 @@ Object.defineProperty(exports, "privateApis", {
|
|
|
15
17
|
return _privateApis.privateApis;
|
|
16
18
|
}
|
|
17
19
|
});
|
|
20
|
+
Object.defineProperty(exports, "store", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return _store.store;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "useCommand", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _useCommand.default;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "useCommandLoader", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _useCommandLoader.default;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
18
38
|
|
|
19
39
|
var _commandMenu = require("./components/command-menu");
|
|
20
40
|
|
|
21
41
|
var _privateApis = require("./private-apis");
|
|
42
|
+
|
|
43
|
+
var _useCommand = _interopRequireDefault(require("./hooks/use-command"));
|
|
44
|
+
|
|
45
|
+
var _useCommandLoader = _interopRequireDefault(require("./hooks/use-command-loader"));
|
|
46
|
+
|
|
47
|
+
var _store = require("./store");
|
|
22
48
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/commands/src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA","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"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unlock = exports.lock = void 0;
|
|
7
|
+
|
|
8
|
+
var _privateApis = require("@wordpress/private-apis");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* WordPress dependencies
|
|
12
|
+
*/
|
|
13
|
+
const {
|
|
14
|
+
lock,
|
|
15
|
+
unlock
|
|
16
|
+
} = (0, _privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/commands');
|
|
17
|
+
exports.unlock = unlock;
|
|
18
|
+
exports.lock = lock;
|
|
19
|
+
//# sourceMappingURL=lock-unlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/lock-unlock.js"],"names":["lock","unlock"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAM;AAAEA,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZ,mEACC,8GADD,EAEC,qBAFD,CADM","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"]}
|
package/build/private-apis.js
CHANGED
|
@@ -5,34 +5,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.privateApis = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _useCommandContext = _interopRequireDefault(require("./hooks/use-command-context"));
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var _useCommandLoader = _interopRequireDefault(require("./hooks/use-command-loader"));
|
|
15
|
-
|
|
16
|
-
var _store = require("./store");
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* WordPress dependencies
|
|
20
|
-
*/
|
|
12
|
+
var _lockUnlock = require("./lock-unlock");
|
|
21
13
|
|
|
22
14
|
/**
|
|
23
15
|
* Internal dependencies
|
|
24
16
|
*/
|
|
25
|
-
const {
|
|
26
|
-
lock,
|
|
27
|
-
unlock
|
|
28
|
-
} = (0, _privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/commands');
|
|
29
|
-
exports.unlock = unlock;
|
|
30
|
-
exports.lock = lock;
|
|
31
17
|
const privateApis = {};
|
|
32
18
|
exports.privateApis = privateApis;
|
|
33
|
-
lock(privateApis, {
|
|
34
|
-
|
|
35
|
-
useCommandLoader: _useCommandLoader.default,
|
|
36
|
-
store: _store.store
|
|
19
|
+
(0, _lockUnlock.lock)(privateApis, {
|
|
20
|
+
useCommandContext: _useCommandContext.default
|
|
37
21
|
});
|
|
38
22
|
//# sourceMappingURL=private-apis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/commands/src/private-apis.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/private-apis.js"],"names":["privateApis","useCommandContext"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIO,MAAMA,WAAW,GAAG,EAApB;;AACP,sBAAMA,WAAN,EAAmB;AAClBC,EAAAA,iBAAiB,EAAjBA;AADkB,CAAnB","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"]}
|