@wordpress/commands 1.41.1-next.v.202603161435.0 → 1.43.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 (35) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/build/components/command-menu.cjs +156 -154
  3. package/build/components/command-menu.cjs.map +3 -3
  4. package/build/components/use-recent-commands.cjs +125 -0
  5. package/build/components/use-recent-commands.cjs.map +7 -0
  6. package/build/store/index.cjs +2 -0
  7. package/build/store/index.cjs.map +2 -2
  8. package/build/store/private-actions.cjs +11 -2
  9. package/build/store/private-actions.cjs.map +2 -2
  10. package/build/store/private-selectors.cjs +32 -0
  11. package/build/store/private-selectors.cjs.map +7 -0
  12. package/build/store/reducer.cjs +12 -1
  13. package/build/store/reducer.cjs.map +2 -2
  14. package/build-module/components/command-menu.mjs +160 -154
  15. package/build-module/components/command-menu.mjs.map +2 -2
  16. package/build-module/components/use-recent-commands.mjs +104 -0
  17. package/build-module/components/use-recent-commands.mjs.map +7 -0
  18. package/build-module/store/index.mjs +2 -0
  19. package/build-module/store/index.mjs.map +2 -2
  20. package/build-module/store/private-actions.mjs +9 -1
  21. package/build-module/store/private-actions.mjs.map +2 -2
  22. package/build-module/store/private-selectors.mjs +8 -0
  23. package/build-module/store/private-selectors.mjs.map +7 -0
  24. package/build-module/store/reducer.mjs +12 -1
  25. package/build-module/store/reducer.mjs.map +2 -2
  26. package/build-style/style-rtl.css +25 -21
  27. package/build-style/style.css +25 -21
  28. package/package.json +12 -11
  29. package/src/components/command-menu.js +179 -161
  30. package/src/components/style.scss +32 -29
  31. package/src/components/use-recent-commands.js +131 -0
  32. package/src/store/index.js +2 -0
  33. package/src/store/private-actions.js +16 -0
  34. package/src/store/private-selectors.js +10 -0
  35. package/src/store/reducer.js +13 -0
@@ -10,6 +10,7 @@ import reducer from './reducer';
10
10
  import * as actions from './actions';
11
11
  import * as selectors from './selectors';
12
12
  import * as privateActions from './private-actions';
13
+ import * as privateSelectors from './private-selectors';
13
14
  import { unlock } from '../lock-unlock';
14
15
 
15
16
  const STORE_NAME = 'core/commands';
@@ -37,3 +38,4 @@ export const store = createReduxStore( STORE_NAME, {
37
38
 
38
39
  register( store );
39
40
  unlock( store ).registerPrivateActions( privateActions );
41
+ unlock( store ).registerPrivateSelectors( privateSelectors );
@@ -11,3 +11,19 @@ export function setContext( context ) {
11
11
  context,
12
12
  };
13
13
  }
14
+
15
+ /**
16
+ * Sets whether a command loader is currently loading.
17
+ *
18
+ * @param {string} name Command loader name.
19
+ * @param {boolean} isLoading Whether the loader is loading.
20
+ *
21
+ * @return {Object} action.
22
+ */
23
+ export function setLoaderLoading( name, isLoading ) {
24
+ return {
25
+ type: 'SET_LOADER_LOADING',
26
+ name,
27
+ isLoading,
28
+ };
29
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns whether any command loader is currently loading.
3
+ *
4
+ * @param {Object} state State tree.
5
+ *
6
+ * @return {boolean} Whether any loader is loading.
7
+ */
8
+ export function isLoading( state ) {
9
+ return Object.values( state.loaderStates ).some( Boolean );
10
+ }
@@ -101,11 +101,24 @@ function context( state = 'root', action ) {
101
101
  return state;
102
102
  }
103
103
 
104
+ function loaderStates( state = {}, action ) {
105
+ switch ( action.type ) {
106
+ case 'SET_LOADER_LOADING':
107
+ return {
108
+ ...state,
109
+ [ action.name ]: action.isLoading,
110
+ };
111
+ }
112
+
113
+ return state;
114
+ }
115
+
104
116
  const reducer = combineReducers( {
105
117
  commands,
106
118
  commandLoaders,
107
119
  isOpen,
108
120
  context,
121
+ loaderStates,
109
122
  } );
110
123
 
111
124
  export default reducer;