@wordpress/commands 1.31.1-next.f56bd8138.0 → 1.32.1-next.47f435fc9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +2 -2
  3. package/build/components/command-menu.js +261 -246
  4. package/build/components/command-menu.js.map +7 -1
  5. package/build/hooks/use-command-context.js +31 -35
  6. package/build/hooks/use-command-context.js.map +7 -1
  7. package/build/hooks/use-command-loader.js +35 -92
  8. package/build/hooks/use-command-loader.js.map +7 -1
  9. package/build/hooks/use-command.js +53 -90
  10. package/build/hooks/use-command.js.map +7 -1
  11. package/build/index.js +49 -45
  12. package/build/index.js.map +7 -1
  13. package/build/lock-unlock.js +31 -15
  14. package/build/lock-unlock.js.map +7 -1
  15. package/build/private-apis.js +41 -19
  16. package/build/private-apis.js.map +7 -1
  17. package/build/store/actions.js +42 -92
  18. package/build/store/actions.js.map +7 -1
  19. package/build/store/index.js +47 -44
  20. package/build/store/index.js.map +7 -1
  21. package/build/store/private-actions.js +27 -14
  22. package/build/store/private-actions.js.map +7 -1
  23. package/build/store/reducer.js +39 -70
  24. package/build/store/reducer.js.map +7 -1
  25. package/build/store/selectors.js +47 -54
  26. package/build/store/selectors.js.map +7 -1
  27. package/build-module/components/command-menu.js +232 -229
  28. package/build-module/components/command-menu.js.map +7 -1
  29. package/build-module/hooks/use-command-context.js +11 -28
  30. package/build-module/hooks/use-command-context.js.map +7 -1
  31. package/build-module/hooks/use-command-loader.js +17 -87
  32. package/build-module/hooks/use-command-loader.js.map +7 -1
  33. package/build-module/hooks/use-command.js +25 -79
  34. package/build-module/hooks/use-command.js.map +7 -1
  35. package/build-module/index.js +14 -6
  36. package/build-module/index.js.map +7 -1
  37. package/build-module/lock-unlock.js +8 -7
  38. package/build-module/lock-unlock.js.map +7 -1
  39. package/build-module/private-apis.js +7 -11
  40. package/build-module/private-apis.js.map +7 -1
  41. package/build-module/store/actions.js +21 -88
  42. package/build-module/store/actions.js.map +7 -1
  43. package/build-module/store/index.js +12 -32
  44. package/build-module/store/index.js.map +7 -1
  45. package/build-module/store/private-actions.js +6 -10
  46. package/build-module/store/private-actions.js.map +7 -1
  47. package/build-module/store/reducer.js +20 -64
  48. package/build-module/store/reducer.js.map +7 -1
  49. package/build-module/store/selectors.js +24 -49
  50. package/build-module/store/selectors.js.map +7 -1
  51. package/build-style/style-rtl.css +7 -138
  52. package/build-style/style.css +7 -138
  53. package/package.json +18 -10
  54. package/src/components/command-menu.js +4 -1
  55. package/src/components/style.scss +10 -0
  56. package/src/hooks/use-command.js +2 -2
  57. package/src/style.scss +2 -1
@@ -1,25 +1,29 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var reducer_exports = {};
19
+ __export(reducer_exports, {
20
+ default: () => reducer_default
5
21
  });
6
- exports.default = void 0;
7
- var _data = require("@wordpress/data");
8
- /**
9
- * WordPress dependencies
10
- */
11
-
12
- /**
13
- * Reducer returning the registered commands
14
- *
15
- * @param {Object} state Current state.
16
- * @param {Object} action Dispatched action.
17
- *
18
- * @return {Object} Updated state.
19
- */
22
+ module.exports = __toCommonJS(reducer_exports);
23
+ var import_data = require("@wordpress/data");
20
24
  function commands(state = {}, action) {
21
25
  switch (action.type) {
22
- case 'REGISTER_COMMAND':
26
+ case "REGISTER_COMMAND":
23
27
  return {
24
28
  ...state,
25
29
  [action.name]: {
@@ -32,29 +36,16 @@ function commands(state = {}, action) {
32
36
  keywords: action.keywords
33
37
  }
34
38
  };
35
- case 'UNREGISTER_COMMAND':
36
- {
37
- const {
38
- [action.name]: _,
39
- ...remainingState
40
- } = state;
41
- return remainingState;
42
- }
39
+ case "UNREGISTER_COMMAND": {
40
+ const { [action.name]: _, ...remainingState } = state;
41
+ return remainingState;
42
+ }
43
43
  }
44
44
  return state;
45
45
  }
46
-
47
- /**
48
- * Reducer returning the command loaders
49
- *
50
- * @param {Object} state Current state.
51
- * @param {Object} action Dispatched action.
52
- *
53
- * @return {Object} Updated state.
54
- */
55
46
  function commandLoaders(state = {}, action) {
56
47
  switch (action.type) {
57
- case 'REGISTER_COMMAND_LOADER':
48
+ case "REGISTER_COMMAND_LOADER":
58
49
  return {
59
50
  ...state,
60
51
  [action.name]: {
@@ -63,56 +54,34 @@ function commandLoaders(state = {}, action) {
63
54
  hook: action.hook
64
55
  }
65
56
  };
66
- case 'UNREGISTER_COMMAND_LOADER':
67
- {
68
- const {
69
- [action.name]: _,
70
- ...remainingState
71
- } = state;
72
- return remainingState;
73
- }
57
+ case "UNREGISTER_COMMAND_LOADER": {
58
+ const { [action.name]: _, ...remainingState } = state;
59
+ return remainingState;
60
+ }
74
61
  }
75
62
  return state;
76
63
  }
77
-
78
- /**
79
- * Reducer returning the command palette open state.
80
- *
81
- * @param {Object} state Current state.
82
- * @param {Object} action Dispatched action.
83
- *
84
- * @return {boolean} Updated state.
85
- */
86
64
  function isOpen(state = false, action) {
87
65
  switch (action.type) {
88
- case 'OPEN':
66
+ case "OPEN":
89
67
  return true;
90
- case 'CLOSE':
68
+ case "CLOSE":
91
69
  return false;
92
70
  }
93
71
  return state;
94
72
  }
95
-
96
- /**
97
- * Reducer returning the command palette's active context.
98
- *
99
- * @param {Object} state Current state.
100
- * @param {Object} action Dispatched action.
101
- *
102
- * @return {boolean} Updated state.
103
- */
104
- function context(state = 'root', action) {
73
+ function context(state = "root", action) {
105
74
  switch (action.type) {
106
- case 'SET_CONTEXT':
75
+ case "SET_CONTEXT":
107
76
  return action.context;
108
77
  }
109
78
  return state;
110
79
  }
111
- const reducer = (0, _data.combineReducers)({
80
+ const reducer = (0, import_data.combineReducers)({
112
81
  commands,
113
82
  commandLoaders,
114
83
  isOpen,
115
84
  context
116
85
  });
117
- var _default = exports.default = reducer;
118
- //# sourceMappingURL=reducer.js.map
86
+ var reducer_default = reducer;
87
+ //# sourceMappingURL=reducer.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_data","require","commands","state","action","type","name","label","searchLabel","context","callback","icon","keywords","_","remainingState","commandLoaders","hook","isOpen","reducer","combineReducers","_default","exports","default"],"sources":["@wordpress/commands/src/store/reducer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the registered commands\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commands( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tlabel: action.label,\n\t\t\t\t\tsearchLabel: action.searchLabel,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t\tkeywords: action.keywords,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command loaders\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commandLoaders( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND_LOADER':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\thook: action.hook,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND_LOADER': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette open state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction isOpen( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN':\n\t\t\treturn true;\n\t\tcase 'CLOSE':\n\t\t\treturn false;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette's active context.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction context( state = 'root', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CONTEXT':\n\t\t\treturn action.context;\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n} );\n\nexport default reducer;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EACvC,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,kBAAkB;MACtB,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,IAAI,GAAI;UAChBA,IAAI,EAAEF,MAAM,CAACE,IAAI;UACjBC,KAAK,EAAEH,MAAM,CAACG,KAAK;UACnBC,WAAW,EAAEJ,MAAM,CAACI,WAAW;UAC/BC,OAAO,EAAEL,MAAM,CAACK,OAAO;UACvBC,QAAQ,EAAEN,MAAM,CAACM,QAAQ;UACzBC,IAAI,EAAEP,MAAM,CAACO,IAAI;UACjBC,QAAQ,EAAER,MAAM,CAACQ;QAClB;MACD,CAAC;IACF,KAAK,oBAAoB;MAAE;QAC1B,MAAM;UAAE,CAAER,MAAM,CAACE,IAAI,GAAIO,CAAC;UAAE,GAAGC;QAAe,CAAC,GAAGX,KAAK;QACvD,OAAOW,cAAc;MACtB;EACD;EAEA,OAAOX,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASY,cAAcA,CAAEZ,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EAC7C,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,yBAAyB;MAC7B,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,IAAI,GAAI;UAChBA,IAAI,EAAEF,MAAM,CAACE,IAAI;UACjBG,OAAO,EAAEL,MAAM,CAACK,OAAO;UACvBO,IAAI,EAAEZ,MAAM,CAACY;QACd;MACD,CAAC;IACF,KAAK,2BAA2B;MAAE;QACjC,MAAM;UAAE,CAAEZ,MAAM,CAACE,IAAI,GAAIO,CAAC;UAAE,GAAGC;QAAe,CAAC,GAAGX,KAAK;QACvD,OAAOW,cAAc;MACtB;EACD;EAEA,OAAOX,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASc,MAAMA,CAAEd,KAAK,GAAG,KAAK,EAAEC,MAAM,EAAG;EACxC,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,MAAM;MACV,OAAO,IAAI;IACZ,KAAK,OAAO;MACX,OAAO,KAAK;EACd;EAEA,OAAOF,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASM,OAAOA,CAAEN,KAAK,GAAG,MAAM,EAAEC,MAAM,EAAG;EAC1C,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,aAAa;MACjB,OAAOD,MAAM,CAACK,OAAO;EACvB;EAEA,OAAON,KAAK;AACb;AAEA,MAAMe,OAAO,GAAG,IAAAC,qBAAe,EAAE;EAChCjB,QAAQ;EACRa,cAAc;EACdE,MAAM;EACNR;AACD,CAAE,CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEWJ,OAAO","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/reducer.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the registered commands\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commands( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tlabel: action.label,\n\t\t\t\t\tsearchLabel: action.searchLabel,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t\tkeywords: action.keywords,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command loaders\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commandLoaders( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND_LOADER':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\thook: action.hook,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND_LOADER': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette open state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction isOpen( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN':\n\t\t\treturn true;\n\t\tcase 'CLOSE':\n\t\t\treturn false;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette's active context.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction context( state = 'root', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CONTEXT':\n\t\t\treturn action.context;\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n} );\n\nexport default reducer;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAUhC,SAAS,SAAU,QAAQ,CAAC,GAAG,QAAS;AACvC,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG;AAAA,UAChB,MAAM,OAAO;AAAA,UACb,OAAO,OAAO;AAAA,UACd,aAAa,OAAO;AAAA,UACpB,SAAS,OAAO;AAAA,UAChB,UAAU,OAAO;AAAA,UACjB,MAAM,OAAO;AAAA,UACb,UAAU,OAAO;AAAA,QAClB;AAAA,MACD;AAAA,IACD,KAAK,sBAAsB;AAC1B,YAAM,EAAE,CAAE,OAAO,IAAK,GAAG,GAAG,GAAG,eAAe,IAAI;AAClD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,eAAgB,QAAQ,CAAC,GAAG,QAAS;AAC7C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG;AAAA,UAChB,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,UAChB,MAAM,OAAO;AAAA,QACd;AAAA,MACD;AAAA,IACD,KAAK,6BAA6B;AACjC,YAAM,EAAE,CAAE,OAAO,IAAK,GAAG,GAAG,GAAG,eAAe,IAAI;AAClD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,OAAQ,QAAQ,OAAO,QAAS;AACxC,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,EACT;AAEA,SAAO;AACR;AAUA,SAAS,QAAS,QAAQ,QAAQ,QAAS;AAC1C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,OAAO;AAAA,EAChB;AAEA,SAAO;AACR;AAEA,MAAM,cAAU,6BAAiB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,IAAO,kBAAQ;",
6
+ "names": []
7
+ }
@@ -1,61 +1,54 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var selectors_exports = {};
19
+ __export(selectors_exports, {
20
+ getCommandLoaders: () => getCommandLoaders,
21
+ getCommands: () => getCommands,
22
+ getContext: () => getContext,
23
+ isOpen: () => isOpen
5
24
  });
6
- exports.getCommands = exports.getCommandLoaders = void 0;
7
- exports.getContext = getContext;
8
- exports.isOpen = isOpen;
9
- var _data = require("@wordpress/data");
10
- /**
11
- * WordPress dependencies
12
- */
13
-
14
- /**
15
- * Returns the registered static commands.
16
- *
17
- * @param {Object} state State tree.
18
- * @param {boolean} contextual Whether to return only contextual commands.
19
- *
20
- * @return {import('./actions').WPCommandConfig[]} The list of registered commands.
21
- */
22
- const getCommands = exports.getCommands = (0, _data.createSelector)((state, contextual = false) => Object.values(state.commands).filter(command => {
23
- const isContextual = command.context && command.context === state.context;
24
- return contextual ? isContextual : !isContextual;
25
- }), state => [state.commands, state.context]);
26
-
27
- /**
28
- * Returns the registered command loaders.
29
- *
30
- * @param {Object} state State tree.
31
- * @param {boolean} contextual Whether to return only contextual command loaders.
32
- *
33
- * @return {import('./actions').WPCommandLoaderConfig[]} The list of registered command loaders.
34
- */
35
- const getCommandLoaders = exports.getCommandLoaders = (0, _data.createSelector)((state, contextual = false) => Object.values(state.commandLoaders).filter(loader => {
36
- const isContextual = loader.context && loader.context === state.context;
37
- return contextual ? isContextual : !isContextual;
38
- }), state => [state.commandLoaders, state.context]);
39
-
40
- /**
41
- * Returns whether the command palette is open.
42
- *
43
- * @param {Object} state State tree.
44
- *
45
- * @return {boolean} Returns whether the command palette is open.
46
- */
25
+ module.exports = __toCommonJS(selectors_exports);
26
+ var import_data = require("@wordpress/data");
27
+ const getCommands = (0, import_data.createSelector)(
28
+ (state, contextual = false) => Object.values(state.commands).filter((command) => {
29
+ const isContextual = command.context && command.context === state.context;
30
+ return contextual ? isContextual : !isContextual;
31
+ }),
32
+ (state) => [state.commands, state.context]
33
+ );
34
+ const getCommandLoaders = (0, import_data.createSelector)(
35
+ (state, contextual = false) => Object.values(state.commandLoaders).filter((loader) => {
36
+ const isContextual = loader.context && loader.context === state.context;
37
+ return contextual ? isContextual : !isContextual;
38
+ }),
39
+ (state) => [state.commandLoaders, state.context]
40
+ );
47
41
  function isOpen(state) {
48
42
  return state.isOpen;
49
43
  }
50
-
51
- /**
52
- * Returns whether the active context.
53
- *
54
- * @param {Object} state State tree.
55
- *
56
- * @return {string} Context.
57
- */
58
44
  function getContext(state) {
59
45
  return state.context;
60
46
  }
61
- //# sourceMappingURL=selectors.js.map
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ getCommandLoaders,
50
+ getCommands,
51
+ getContext,
52
+ isOpen
53
+ });
54
+ //# sourceMappingURL=selectors.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_data","require","getCommands","exports","createSelector","state","contextual","Object","values","commands","filter","command","isContextual","context","getCommandLoaders","commandLoaders","loader","isOpen","getContext"],"sources":["@wordpress/commands/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector } from '@wordpress/data';\n\n/**\n * Returns the registered static commands.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual commands.\n *\n * @return {import('./actions').WPCommandConfig[]} The list of registered commands.\n */\nexport const getCommands = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commands ).filter( ( command ) => {\n\t\t\tconst isContextual =\n\t\t\t\tcommand.context && command.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commands, state.context ]\n);\n\n/**\n * Returns the registered command loaders.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual command loaders.\n *\n * @return {import('./actions').WPCommandLoaderConfig[]} The list of registered command loaders.\n */\nexport const getCommandLoaders = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commandLoaders ).filter( ( loader ) => {\n\t\t\tconst isContextual =\n\t\t\t\tloader.context && loader.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commandLoaders, state.context ]\n);\n\n/**\n * Returns whether the command palette is open.\n *\n * @param {Object} state State tree.\n *\n * @return {boolean} Returns whether the command palette is open.\n */\nexport function isOpen( state ) {\n\treturn state.isOpen;\n}\n\n/**\n * Returns whether the active context.\n *\n * @param {Object} state State tree.\n *\n * @return {string} Context.\n */\nexport function getContext( state ) {\n\treturn state.context;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,IAAAE,oBAAc,EACxC,CAAEC,KAAK,EAAEC,UAAU,GAAG,KAAK,KAC1BC,MAAM,CAACC,MAAM,CAAEH,KAAK,CAACI,QAAS,CAAC,CAACC,MAAM,CAAIC,OAAO,IAAM;EACtD,MAAMC,YAAY,GACjBD,OAAO,CAACE,OAAO,IAAIF,OAAO,CAACE,OAAO,KAAKR,KAAK,CAACQ,OAAO;EACrD,OAAOP,UAAU,GAAGM,YAAY,GAAG,CAAEA,YAAY;AAClD,CAAE,CAAC,EACFP,KAAK,IAAM,CAAEA,KAAK,CAACI,QAAQ,EAAEJ,KAAK,CAACQ,OAAO,CAC7C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,GAAAX,OAAA,CAAAW,iBAAA,GAAG,IAAAV,oBAAc,EAC9C,CAAEC,KAAK,EAAEC,UAAU,GAAG,KAAK,KAC1BC,MAAM,CAACC,MAAM,CAAEH,KAAK,CAACU,cAAe,CAAC,CAACL,MAAM,CAAIM,MAAM,IAAM;EAC3D,MAAMJ,YAAY,GACjBI,MAAM,CAACH,OAAO,IAAIG,MAAM,CAACH,OAAO,KAAKR,KAAK,CAACQ,OAAO;EACnD,OAAOP,UAAU,GAAGM,YAAY,GAAG,CAAEA,YAAY;AAClD,CAAE,CAAC,EACFP,KAAK,IAAM,CAAEA,KAAK,CAACU,cAAc,EAAEV,KAAK,CAACQ,OAAO,CACnD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,MAAMA,CAAEZ,KAAK,EAAG;EAC/B,OAAOA,KAAK,CAACY,MAAM;AACpB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAAEb,KAAK,EAAG;EACnC,OAAOA,KAAK,CAACQ,OAAO;AACrB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/selectors.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector } from '@wordpress/data';\n\n/**\n * Returns the registered static commands.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual commands.\n *\n * @return {import('./actions').WPCommandConfig[]} The list of registered commands.\n */\nexport const getCommands = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commands ).filter( ( command ) => {\n\t\t\tconst isContextual =\n\t\t\t\tcommand.context && command.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commands, state.context ]\n);\n\n/**\n * Returns the registered command loaders.\n *\n * @param {Object} state State tree.\n * @param {boolean} contextual Whether to return only contextual command loaders.\n *\n * @return {import('./actions').WPCommandLoaderConfig[]} The list of registered command loaders.\n */\nexport const getCommandLoaders = createSelector(\n\t( state, contextual = false ) =>\n\t\tObject.values( state.commandLoaders ).filter( ( loader ) => {\n\t\t\tconst isContextual =\n\t\t\t\tloader.context && loader.context === state.context;\n\t\t\treturn contextual ? isContextual : ! isContextual;\n\t\t} ),\n\t( state ) => [ state.commandLoaders, state.context ]\n);\n\n/**\n * Returns whether the command palette is open.\n *\n * @param {Object} state State tree.\n *\n * @return {boolean} Returns whether the command palette is open.\n */\nexport function isOpen( state ) {\n\treturn state.isOpen;\n}\n\n/**\n * Returns whether the active context.\n *\n * @param {Object} state State tree.\n *\n * @return {string} Context.\n */\nexport function getContext( state ) {\n\treturn state.context;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA+B;AAUxB,MAAM,kBAAc;AAAA,EAC1B,CAAE,OAAO,aAAa,UACrB,OAAO,OAAQ,MAAM,QAAS,EAAE,OAAQ,CAAE,YAAa;AACtD,UAAM,eACL,QAAQ,WAAW,QAAQ,YAAY,MAAM;AAC9C,WAAO,aAAa,eAAe,CAAE;AAAA,EACtC,CAAE;AAAA,EACH,CAAE,UAAW,CAAE,MAAM,UAAU,MAAM,OAAQ;AAC9C;AAUO,MAAM,wBAAoB;AAAA,EAChC,CAAE,OAAO,aAAa,UACrB,OAAO,OAAQ,MAAM,cAAe,EAAE,OAAQ,CAAE,WAAY;AAC3D,UAAM,eACL,OAAO,WAAW,OAAO,YAAY,MAAM;AAC5C,WAAO,aAAa,eAAe,CAAE;AAAA,EACtC,CAAE;AAAA,EACH,CAAE,UAAW,CAAE,MAAM,gBAAgB,MAAM,OAAQ;AACpD;AASO,SAAS,OAAQ,OAAQ;AAC/B,SAAO,MAAM;AACd;AASO,SAAS,WAAY,OAAQ;AACnC,SAAO,MAAM;AACd;",
6
+ "names": []
7
+ }