@wordpress/commands 0.2.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 (53) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE.md +788 -0
  3. package/README.md +35 -0
  4. package/build/components/command-menu.js +213 -0
  5. package/build/components/command-menu.js.map +1 -0
  6. package/build/hooks/use-command-loader.js +48 -0
  7. package/build/hooks/use-command-loader.js.map +1 -0
  8. package/build/hooks/use-command.js +48 -0
  9. package/build/hooks/use-command.js.map +1 -0
  10. package/build/index.js +22 -0
  11. package/build/index.js.map +1 -0
  12. package/build/private-apis.js +35 -0
  13. package/build/private-apis.js.map +1 -0
  14. package/build/store/actions.js +116 -0
  15. package/build/store/actions.js.map +1 -0
  16. package/build/store/index.js +45 -0
  17. package/build/store/index.js.map +1 -0
  18. package/build/store/reducer.js +99 -0
  19. package/build/store/reducer.js.map +1 -0
  20. package/build/store/selectors.js +33 -0
  21. package/build/store/selectors.js.map +1 -0
  22. package/build-module/components/command-menu.js +198 -0
  23. package/build-module/components/command-menu.js.map +1 -0
  24. package/build-module/hooks/use-command-loader.js +38 -0
  25. package/build-module/hooks/use-command-loader.js.map +1 -0
  26. package/build-module/hooks/use-command.js +38 -0
  27. package/build-module/hooks/use-command.js.map +1 -0
  28. package/build-module/index.js +3 -0
  29. package/build-module/index.js.map +1 -0
  30. package/build-module/private-apis.js +20 -0
  31. package/build-module/private-apis.js.map +1 -0
  32. package/build-module/store/actions.js +103 -0
  33. package/build-module/store/actions.js.map +1 -0
  34. package/build-module/store/index.js +27 -0
  35. package/build-module/store/index.js.map +1 -0
  36. package/build-module/store/reducer.js +90 -0
  37. package/build-module/store/reducer.js.map +1 -0
  38. package/build-module/store/selectors.js +21 -0
  39. package/build-module/store/selectors.js.map +1 -0
  40. package/build-style/style-rtl.css +264 -0
  41. package/build-style/style.css +264 -0
  42. package/package.json +47 -0
  43. package/src/components/command-menu.js +216 -0
  44. package/src/components/style.scss +179 -0
  45. package/src/hooks/use-command-loader.js +30 -0
  46. package/src/hooks/use-command.js +41 -0
  47. package/src/index.js +2 -0
  48. package/src/private-apis.js +22 -0
  49. package/src/store/actions.js +91 -0
  50. package/src/store/index.js +28 -0
  51. package/src/store/reducer.js +81 -0
  52. package/src/store/selectors.js +29 -0
  53. package/src/style.scss +1 -0
@@ -0,0 +1,29 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import createSelector from 'rememo';
5
+
6
+ function unique( array ) {
7
+ return array.filter(
8
+ ( value, index, current ) => current.indexOf( value ) === index
9
+ );
10
+ }
11
+
12
+ export const getGroups = createSelector(
13
+ ( state ) =>
14
+ unique(
15
+ Object.keys( state.commands ).concat(
16
+ Object.keys( state.commandLoaders )
17
+ )
18
+ ),
19
+ ( state ) => [ state.commands, state.commandLoaders ]
20
+ );
21
+ export const getCommands = createSelector(
22
+ ( state, group ) => Object.values( state.commands[ group ] ?? {} ),
23
+ ( state, group ) => [ state.commands[ group ] ]
24
+ );
25
+
26
+ export const getCommandLoaders = createSelector(
27
+ ( state, group ) => Object.values( state.commandLoaders[ group ] ?? {} ),
28
+ ( state, group ) => [ state.commandLoaders[ group ] ]
29
+ );
package/src/style.scss ADDED
@@ -0,0 +1 @@
1
+ @import "./components/style.scss";