@wordpress/data 10.32.0 → 10.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 (157) hide show
  1. package/build/components/async-mode-provider/context.js +35 -54
  2. package/build/components/async-mode-provider/context.js.map +7 -1
  3. package/build/components/async-mode-provider/index.js +40 -25
  4. package/build/components/async-mode-provider/index.js.map +7 -1
  5. package/build/components/async-mode-provider/use-async-mode.js +25 -16
  6. package/build/components/async-mode-provider/use-async-mode.js.map +7 -1
  7. package/build/components/registry-provider/context.js +46 -64
  8. package/build/components/registry-provider/context.js.map +7 -1
  9. package/build/components/registry-provider/index.js +40 -25
  10. package/build/components/registry-provider/index.js.map +7 -1
  11. package/build/components/registry-provider/use-registry.js +25 -55
  12. package/build/components/registry-provider/use-registry.js.map +7 -1
  13. package/build/components/use-dispatch/index.js +38 -17
  14. package/build/components/use-dispatch/index.js.map +7 -1
  15. package/build/components/use-dispatch/use-dispatch-with-map.js +59 -44
  16. package/build/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
  17. package/build/components/use-dispatch/use-dispatch.js +36 -71
  18. package/build/components/use-dispatch/use-dispatch.js.map +7 -1
  19. package/build/components/use-select/index.js +79 -208
  20. package/build/components/use-select/index.js.map +7 -1
  21. package/build/components/with-dispatch/index.js +34 -107
  22. package/build/components/with-dispatch/index.js.map +7 -1
  23. package/build/components/with-registry/index.js +30 -30
  24. package/build/components/with-registry/index.js.map +7 -1
  25. package/build/components/with-select/index.js +44 -67
  26. package/build/components/with-select/index.js.map +7 -1
  27. package/build/controls.js +49 -110
  28. package/build/controls.js.map +7 -1
  29. package/build/create-selector.js +36 -11
  30. package/build/create-selector.js.map +7 -1
  31. package/build/default-registry.js +24 -10
  32. package/build/default-registry.js.map +7 -1
  33. package/build/dispatch.js +38 -31
  34. package/build/dispatch.js.map +7 -1
  35. package/build/factory.js +29 -85
  36. package/build/factory.js.map +7 -1
  37. package/build/index.js +114 -301
  38. package/build/index.js.map +7 -1
  39. package/build/lock-unlock.js +31 -14
  40. package/build/lock-unlock.js.map +7 -1
  41. package/build/plugins/index.js +36 -11
  42. package/build/plugins/index.js.map +7 -1
  43. package/build/plugins/persistence/index.js +74 -139
  44. package/build/plugins/persistence/index.js.map +7 -1
  45. package/build/plugins/persistence/storage/default.js +37 -18
  46. package/build/plugins/persistence/storage/default.js.map +7 -1
  47. package/build/plugins/persistence/storage/object.js +24 -7
  48. package/build/plugins/persistence/storage/object.js.map +7 -1
  49. package/build/promise-middleware.js +37 -20
  50. package/build/promise-middleware.js.map +7 -1
  51. package/build/redux-store/combine-reducers.js +26 -5
  52. package/build/redux-store/combine-reducers.js.map +7 -1
  53. package/build/redux-store/index.js +221 -331
  54. package/build/redux-store/index.js.map +7 -1
  55. package/build/redux-store/metadata/actions.js +51 -112
  56. package/build/redux-store/metadata/actions.js.map +7 -1
  57. package/build/redux-store/metadata/equivalent-key-map.d.js +1 -1
  58. package/build/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
  59. package/build/redux-store/metadata/reducer.js +111 -115
  60. package/build/redux-store/metadata/reducer.js.map +7 -1
  61. package/build/redux-store/metadata/selectors.js +109 -181
  62. package/build/redux-store/metadata/selectors.js.map +7 -1
  63. package/build/redux-store/metadata/utils.js +32 -35
  64. package/build/redux-store/metadata/utils.js.map +7 -1
  65. package/build/redux-store/thunk-middleware.js +24 -7
  66. package/build/redux-store/thunk-middleware.js.map +7 -1
  67. package/build/registry.js +94 -198
  68. package/build/registry.js.map +7 -1
  69. package/build/resolvers-cache-middleware.js +26 -27
  70. package/build/resolvers-cache-middleware.js.map +7 -1
  71. package/build/select.js +38 -31
  72. package/build/select.js.map +7 -1
  73. package/build/store/index.js +52 -16
  74. package/build/store/index.js.map +7 -1
  75. package/build/types.js +16 -5
  76. package/build/types.js.map +7 -1
  77. package/build/utils/emitter.js +33 -16
  78. package/build/utils/emitter.js.map +7 -1
  79. package/build-module/components/async-mode-provider/context.js +12 -49
  80. package/build-module/components/async-mode-provider/context.js.map +7 -1
  81. package/build-module/components/async-mode-provider/index.js +8 -3
  82. package/build-module/components/async-mode-provider/index.js.map +7 -1
  83. package/build-module/components/async-mode-provider/use-async-mode.js +7 -11
  84. package/build-module/components/async-mode-provider/use-async-mode.js.map +7 -1
  85. package/build-module/components/registry-provider/context.js +13 -58
  86. package/build-module/components/registry-provider/context.js.map +7 -1
  87. package/build-module/components/registry-provider/index.js +8 -3
  88. package/build-module/components/registry-provider/index.js.map +7 -1
  89. package/build-module/components/registry-provider/use-registry.js +7 -51
  90. package/build-module/components/registry-provider/use-registry.js.map +7 -1
  91. package/build-module/components/use-dispatch/index.js +7 -3
  92. package/build-module/components/use-dispatch/index.js.map +7 -1
  93. package/build-module/components/use-dispatch/use-dispatch-with-map.js +27 -35
  94. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
  95. package/build-module/components/use-dispatch/use-dispatch.js +8 -66
  96. package/build-module/components/use-dispatch/use-dispatch.js.map +7 -1
  97. package/build-module/components/use-select/index.js +45 -193
  98. package/build-module/components/use-select/index.js.map +7 -1
  99. package/build-module/components/with-dispatch/index.js +16 -104
  100. package/build-module/components/with-dispatch/index.js.map +7 -1
  101. package/build-module/components/with-registry/index.js +12 -27
  102. package/build-module/components/with-registry/index.js.map +7 -1
  103. package/build-module/components/with-select/index.js +16 -63
  104. package/build-module/components/with-select/index.js.map +7 -1
  105. package/build-module/controls.js +25 -105
  106. package/build-module/controls.js.map +7 -1
  107. package/build-module/create-selector.js +5 -8
  108. package/build-module/create-selector.js.map +7 -1
  109. package/build-module/default-registry.js +6 -6
  110. package/build-module/default-registry.js.map +7 -1
  111. package/build-module/dispatch.js +6 -27
  112. package/build-module/dispatch.js.map +7 -1
  113. package/build-module/factory.js +8 -82
  114. package/build-module/factory.js.map +7 -1
  115. package/build-module/index.js +62 -185
  116. package/build-module/index.js.map +7 -1
  117. package/build-module/lock-unlock.js +8 -7
  118. package/build-module/lock-unlock.js.map +7 -1
  119. package/build-module/plugins/index.js +5 -2
  120. package/build-module/plugins/index.js.map +7 -1
  121. package/build-module/plugins/persistence/index.js +38 -129
  122. package/build-module/plugins/persistence/index.js.map +7 -1
  123. package/build-module/plugins/persistence/storage/default.js +8 -11
  124. package/build-module/plugins/persistence/storage/default.js.map +7 -1
  125. package/build-module/plugins/persistence/storage/object.js +6 -3
  126. package/build-module/plugins/persistence/storage/object.js.map +7 -1
  127. package/build-module/promise-middleware.js +8 -14
  128. package/build-module/promise-middleware.js.map +7 -1
  129. package/build-module/redux-store/combine-reducers.js +5 -2
  130. package/build-module/redux-store/combine-reducers.js.map +7 -1
  131. package/build-module/redux-store/index.js +180 -310
  132. package/build-module/redux-store/index.js.map +7 -1
  133. package/build-module/redux-store/metadata/actions.js +30 -109
  134. package/build-module/redux-store/metadata/actions.js.map +7 -1
  135. package/build-module/redux-store/metadata/equivalent-key-map.d.js +1 -2
  136. package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
  137. package/build-module/redux-store/metadata/reducer.js +83 -108
  138. package/build-module/redux-store/metadata/reducer.js.map +7 -1
  139. package/build-module/redux-store/metadata/selectors.js +76 -175
  140. package/build-module/redux-store/metadata/selectors.js.map +7 -1
  141. package/build-module/redux-store/metadata/utils.js +10 -30
  142. package/build-module/redux-store/metadata/utils.js.map +7 -1
  143. package/build-module/redux-store/thunk-middleware.js +7 -4
  144. package/build-module/redux-store/thunk-middleware.js.map +7 -1
  145. package/build-module/registry.js +56 -187
  146. package/build-module/registry.js.map +7 -1
  147. package/build-module/resolvers-cache-middleware.js +8 -23
  148. package/build-module/resolvers-cache-middleware.js.map +7 -1
  149. package/build-module/select.js +6 -27
  150. package/build-module/select.js.map +7 -1
  151. package/build-module/store/index.js +34 -12
  152. package/build-module/store/index.js.map +7 -1
  153. package/build-module/types.js +1 -2
  154. package/build-module/types.js.map +7 -1
  155. package/build-module/utils/emitter.js +12 -13
  156. package/build-module/utils/emitter.js.map +7 -1
  157. package/package.json +17 -10
@@ -1,3 +1,8 @@
1
- export { default as useAsyncMode } from './use-async-mode';
2
- export { default as AsyncModeProvider, AsyncModeConsumer } from './context';
3
- //# sourceMappingURL=index.js.map
1
+ import { default as default2 } from "./use-async-mode";
2
+ import { default as default3, AsyncModeConsumer } from "./context";
3
+ export {
4
+ AsyncModeConsumer,
5
+ default3 as AsyncModeProvider,
6
+ default2 as useAsyncMode
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["default","useAsyncMode","AsyncModeProvider","AsyncModeConsumer"],"sources":["@wordpress/data/src/components/async-mode-provider/index.js"],"sourcesContent":["export { default as useAsyncMode } from './use-async-mode';\nexport { default as AsyncModeProvider, AsyncModeConsumer } from './context';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,YAAY,QAAQ,kBAAkB;AAC1D,SAASD,OAAO,IAAIE,iBAAiB,EAAEC,iBAAiB,QAAQ,WAAW","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/async-mode-provider/index.js"],
4
+ "sourcesContent": ["export { default as useAsyncMode } from './use-async-mode';\nexport { default as AsyncModeProvider, AsyncModeConsumer } from './context';\n"],
5
+ "mappings": "AAAA,SAAoB,WAAXA,gBAA+B;AACxC,SAAoB,WAAXA,UAA8B,yBAAyB;",
6
+ "names": ["default"]
7
+ }
@@ -1,13 +1,9 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useContext } from '@wordpress/element';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { Context } from './context';
10
- export default function useAsyncMode() {
1
+ import { useContext } from "@wordpress/element";
2
+ import { Context } from "./context";
3
+ function useAsyncMode() {
11
4
  return useContext(Context);
12
5
  }
13
- //# sourceMappingURL=use-async-mode.js.map
6
+ export {
7
+ useAsyncMode as default
8
+ };
9
+ //# sourceMappingURL=use-async-mode.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["useContext","Context","useAsyncMode"],"sources":["@wordpress/data/src/components/async-mode-provider/use-async-mode.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Context } from './context';\n\nexport default function useAsyncMode() {\n\treturn useContext( Context );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;AACA,SAASC,OAAO,QAAQ,WAAW;AAEnC,eAAe,SAASC,YAAYA,CAAA,EAAG;EACtC,OAAOF,UAAU,CAAEC,OAAQ,CAAC;AAC7B","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/async-mode-provider/use-async-mode.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Context } from './context';\n\nexport default function useAsyncMode() {\n\treturn useContext( Context );\n}\n"],
5
+ "mappings": "AAGA,SAAS,kBAAkB;AAK3B,SAAS,eAAe;AAET,SAAR,eAAgC;AACtC,SAAO,WAAY,OAAQ;AAC5B;",
6
+ "names": []
7
+ }
@@ -1,58 +1,13 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createContext } from '@wordpress/element';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import defaultRegistry from '../../default-registry';
10
- export const Context = createContext(defaultRegistry);
11
- Context.displayName = 'RegistryProviderContext';
12
- const {
13
- Consumer,
14
- Provider
15
- } = Context;
16
-
17
- /**
18
- * A custom react Context consumer exposing the provided `registry` to
19
- * children components. Used along with the RegistryProvider.
20
- *
21
- * You can read more about the react context api here:
22
- * https://react.dev/learn/passing-data-deeply-with-context#step-3-provide-the-context
23
- *
24
- * @example
25
- * ```js
26
- * import {
27
- * RegistryProvider,
28
- * RegistryConsumer,
29
- * createRegistry
30
- * } from '@wordpress/data';
31
- *
32
- * const registry = createRegistry( {} );
33
- *
34
- * const App = ( { props } ) => {
35
- * return <RegistryProvider value={ registry }>
36
- * <div>Hello There</div>
37
- * <RegistryConsumer>
38
- * { ( registry ) => (
39
- * <ComponentUsingRegistry
40
- * { ...props }
41
- * registry={ registry }
42
- * ) }
43
- * </RegistryConsumer>
44
- * </RegistryProvider>
45
- * }
46
- * ```
47
- */
48
- export const RegistryConsumer = Consumer;
49
-
50
- /**
51
- * A custom Context provider for exposing the provided `registry` to children
52
- * components via a consumer.
53
- *
54
- * See <a name="#RegistryConsumer">RegistryConsumer</a> documentation for
55
- * example.
56
- */
57
- export default Provider;
58
- //# sourceMappingURL=context.js.map
1
+ import { createContext } from "@wordpress/element";
2
+ import defaultRegistry from "../../default-registry";
3
+ const Context = createContext(defaultRegistry);
4
+ Context.displayName = "RegistryProviderContext";
5
+ const { Consumer, Provider } = Context;
6
+ const RegistryConsumer = Consumer;
7
+ var context_default = Provider;
8
+ export {
9
+ Context,
10
+ RegistryConsumer,
11
+ context_default as default
12
+ };
13
+ //# sourceMappingURL=context.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createContext","defaultRegistry","Context","displayName","Consumer","Provider","RegistryConsumer"],"sources":["@wordpress/data/src/components/registry-provider/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport defaultRegistry from '../../default-registry';\n\nexport const Context = createContext( defaultRegistry );\nContext.displayName = 'RegistryProviderContext';\n\nconst { Consumer, Provider } = Context;\n\n/**\n * A custom react Context consumer exposing the provided `registry` to\n * children components. Used along with the RegistryProvider.\n *\n * You can read more about the react context api here:\n * https://react.dev/learn/passing-data-deeply-with-context#step-3-provide-the-context\n *\n * @example\n * ```js\n * import {\n * RegistryProvider,\n * RegistryConsumer,\n * createRegistry\n * } from '@wordpress/data';\n *\n * const registry = createRegistry( {} );\n *\n * const App = ( { props } ) => {\n * return <RegistryProvider value={ registry }>\n * <div>Hello There</div>\n * <RegistryConsumer>\n * { ( registry ) => (\n * <ComponentUsingRegistry\n * \t\t{ ...props }\n * \t registry={ registry }\n * ) }\n * </RegistryConsumer>\n * </RegistryProvider>\n * }\n * ```\n */\nexport const RegistryConsumer = Consumer;\n\n/**\n * A custom Context provider for exposing the provided `registry` to children\n * components via a consumer.\n *\n * See <a name=\"#RegistryConsumer\">RegistryConsumer</a> documentation for\n * example.\n */\nexport default Provider;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,oBAAoB;;AAElD;AACA;AACA;AACA,OAAOC,eAAe,MAAM,wBAAwB;AAEpD,OAAO,MAAMC,OAAO,GAAGF,aAAa,CAAEC,eAAgB,CAAC;AACvDC,OAAO,CAACC,WAAW,GAAG,yBAAyB;AAE/C,MAAM;EAAEC,QAAQ;EAAEC;AAAS,CAAC,GAAGH,OAAO;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,gBAAgB,GAAGF,QAAQ;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeC,QAAQ","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/registry-provider/context.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport defaultRegistry from '../../default-registry';\n\nexport const Context = createContext( defaultRegistry );\nContext.displayName = 'RegistryProviderContext';\n\nconst { Consumer, Provider } = Context;\n\n/**\n * A custom react Context consumer exposing the provided `registry` to\n * children components. Used along with the RegistryProvider.\n *\n * You can read more about the react context api here:\n * https://react.dev/learn/passing-data-deeply-with-context#step-3-provide-the-context\n *\n * @example\n * ```js\n * import {\n * RegistryProvider,\n * RegistryConsumer,\n * createRegistry\n * } from '@wordpress/data';\n *\n * const registry = createRegistry( {} );\n *\n * const App = ( { props } ) => {\n * return <RegistryProvider value={ registry }>\n * <div>Hello There</div>\n * <RegistryConsumer>\n * { ( registry ) => (\n * <ComponentUsingRegistry\n * \t\t{ ...props }\n * \t registry={ registry }\n * ) }\n * </RegistryConsumer>\n * </RegistryProvider>\n * }\n * ```\n */\nexport const RegistryConsumer = Consumer;\n\n/**\n * A custom Context provider for exposing the provided `registry` to children\n * components via a consumer.\n *\n * See <a name=\"#RegistryConsumer\">RegistryConsumer</a> documentation for\n * example.\n */\nexport default Provider;\n"],
5
+ "mappings": "AAGA,SAAS,qBAAqB;AAK9B,OAAO,qBAAqB;AAErB,MAAM,UAAU,cAAe,eAAgB;AACtD,QAAQ,cAAc;AAEtB,MAAM,EAAE,UAAU,SAAS,IAAI;AAiCxB,MAAM,mBAAmB;AAShC,IAAO,kBAAQ;",
6
+ "names": []
7
+ }
@@ -1,3 +1,8 @@
1
- export { default as RegistryProvider, RegistryConsumer } from './context';
2
- export { default as useRegistry } from './use-registry';
3
- //# sourceMappingURL=index.js.map
1
+ import { default as default2, RegistryConsumer } from "./context";
2
+ import { default as default3 } from "./use-registry";
3
+ export {
4
+ RegistryConsumer,
5
+ default2 as RegistryProvider,
6
+ default3 as useRegistry
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["default","RegistryProvider","RegistryConsumer","useRegistry"],"sources":["@wordpress/data/src/components/registry-provider/index.js"],"sourcesContent":["export { default as RegistryProvider, RegistryConsumer } from './context';\nexport { default as useRegistry } from './use-registry';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,gBAAgB,EAAEC,gBAAgB,QAAQ,WAAW;AACzE,SAASF,OAAO,IAAIG,WAAW,QAAQ,gBAAgB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/registry-provider/index.js"],
4
+ "sourcesContent": ["export { default as RegistryProvider, RegistryConsumer } from './context';\nexport { default as useRegistry } from './use-registry';\n"],
5
+ "mappings": "AAAA,SAAoB,WAAXA,UAA6B,wBAAwB;AAC9D,SAAoB,WAAXA,gBAA8B;",
6
+ "names": ["default"]
7
+ }
@@ -1,53 +1,9 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useContext } from '@wordpress/element';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { Context } from './context';
10
-
11
- /**
12
- * A custom react hook exposing the registry context for use.
13
- *
14
- * This exposes the `registry` value provided via the
15
- * <a href="#RegistryProvider">Registry Provider</a> to a component implementing
16
- * this hook.
17
- *
18
- * It acts similarly to the `useContext` react hook.
19
- *
20
- * Note: Generally speaking, `useRegistry` is a low level hook that in most cases
21
- * won't be needed for implementation. Most interactions with the `@wordpress/data`
22
- * API can be performed via the `useSelect` hook, or the `withSelect` and
23
- * `withDispatch` higher order components.
24
- *
25
- * @example
26
- * ```js
27
- * import {
28
- * RegistryProvider,
29
- * createRegistry,
30
- * useRegistry,
31
- * } from '@wordpress/data';
32
- *
33
- * const registry = createRegistry( {} );
34
- *
35
- * const SomeChildUsingRegistry = ( props ) => {
36
- * const registry = useRegistry();
37
- * // ...logic implementing the registry in other react hooks.
38
- * };
39
- *
40
- *
41
- * const ParentProvidingRegistry = ( props ) => {
42
- * return <RegistryProvider value={ registry }>
43
- * <SomeChildUsingRegistry { ...props } />
44
- * </RegistryProvider>
45
- * };
46
- * ```
47
- *
48
- * @return {Function} A custom react hook exposing the registry context value.
49
- */
50
- export default function useRegistry() {
1
+ import { useContext } from "@wordpress/element";
2
+ import { Context } from "./context";
3
+ function useRegistry() {
51
4
  return useContext(Context);
52
5
  }
53
- //# sourceMappingURL=use-registry.js.map
6
+ export {
7
+ useRegistry as default
8
+ };
9
+ //# sourceMappingURL=use-registry.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["useContext","Context","useRegistry"],"sources":["@wordpress/data/src/components/registry-provider/use-registry.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Context } from './context';\n\n/**\n * A custom react hook exposing the registry context for use.\n *\n * This exposes the `registry` value provided via the\n * <a href=\"#RegistryProvider\">Registry Provider</a> to a component implementing\n * this hook.\n *\n * It acts similarly to the `useContext` react hook.\n *\n * Note: Generally speaking, `useRegistry` is a low level hook that in most cases\n * won't be needed for implementation. Most interactions with the `@wordpress/data`\n * API can be performed via the `useSelect` hook, or the `withSelect` and\n * `withDispatch` higher order components.\n *\n * @example\n * ```js\n * import {\n * RegistryProvider,\n * createRegistry,\n * useRegistry,\n * } from '@wordpress/data';\n *\n * const registry = createRegistry( {} );\n *\n * const SomeChildUsingRegistry = ( props ) => {\n * const registry = useRegistry();\n * // ...logic implementing the registry in other react hooks.\n * };\n *\n *\n * const ParentProvidingRegistry = ( props ) => {\n * return <RegistryProvider value={ registry }>\n * <SomeChildUsingRegistry { ...props } />\n * </RegistryProvider>\n * };\n * ```\n *\n * @return {Function} A custom react hook exposing the registry context value.\n */\nexport default function useRegistry() {\n\treturn useContext( Context );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;AACA,SAASC,OAAO,QAAQ,WAAW;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAAA,EAAG;EACrC,OAAOF,UAAU,CAAEC,OAAQ,CAAC;AAC7B","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/registry-provider/use-registry.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Context } from './context';\n\n/**\n * A custom react hook exposing the registry context for use.\n *\n * This exposes the `registry` value provided via the\n * <a href=\"#RegistryProvider\">Registry Provider</a> to a component implementing\n * this hook.\n *\n * It acts similarly to the `useContext` react hook.\n *\n * Note: Generally speaking, `useRegistry` is a low level hook that in most cases\n * won't be needed for implementation. Most interactions with the `@wordpress/data`\n * API can be performed via the `useSelect` hook, or the `withSelect` and\n * `withDispatch` higher order components.\n *\n * @example\n * ```js\n * import {\n * RegistryProvider,\n * createRegistry,\n * useRegistry,\n * } from '@wordpress/data';\n *\n * const registry = createRegistry( {} );\n *\n * const SomeChildUsingRegistry = ( props ) => {\n * const registry = useRegistry();\n * // ...logic implementing the registry in other react hooks.\n * };\n *\n *\n * const ParentProvidingRegistry = ( props ) => {\n * return <RegistryProvider value={ registry }>\n * <SomeChildUsingRegistry { ...props } />\n * </RegistryProvider>\n * };\n * ```\n *\n * @return {Function} A custom react hook exposing the registry context value.\n */\nexport default function useRegistry() {\n\treturn useContext( Context );\n}\n"],
5
+ "mappings": "AAGA,SAAS,kBAAkB;AAK3B,SAAS,eAAe;AAyCT,SAAR,cAA+B;AACrC,SAAO,WAAY,OAAQ;AAC5B;",
6
+ "names": []
7
+ }
@@ -1,3 +1,7 @@
1
- export { default as useDispatch } from './use-dispatch';
2
- export { default as useDispatchWithMap } from './use-dispatch-with-map';
3
- //# sourceMappingURL=index.js.map
1
+ import { default as default2 } from "./use-dispatch";
2
+ import { default as default3 } from "./use-dispatch-with-map";
3
+ export {
4
+ default2 as useDispatch,
5
+ default3 as useDispatchWithMap
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["default","useDispatch","useDispatchWithMap"],"sources":["@wordpress/data/src/components/use-dispatch/index.js"],"sourcesContent":["export { default as useDispatch } from './use-dispatch';\nexport { default as useDispatchWithMap } from './use-dispatch-with-map';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAAW,QAAQ,gBAAgB;AACvD,SAASD,OAAO,IAAIE,kBAAkB,QAAQ,yBAAyB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/use-dispatch/index.js"],
4
+ "sourcesContent": ["export { default as useDispatch } from './use-dispatch';\nexport { default as useDispatchWithMap } from './use-dispatch-with-map';\n"],
5
+ "mappings": "AAAA,SAAoB,WAAXA,gBAA8B;AACvC,SAAoB,WAAXA,gBAAqC;",
6
+ "names": ["default"]
7
+ }
@@ -1,28 +1,6 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useMemo, useRef } from '@wordpress/element';
5
- import { useIsomorphicLayoutEffect } from '@wordpress/compose';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import useRegistry from '../registry-provider/use-registry';
11
-
12
- /**
13
- * Custom react hook for returning aggregate dispatch actions using the provided
14
- * dispatchMap.
15
- *
16
- * Currently this is an internal api only and is implemented by `withDispatch`
17
- *
18
- * @param {Function} dispatchMap Receives the `registry.dispatch` function as
19
- * the first argument and the `registry` object
20
- * as the second argument. Should return an
21
- * object mapping props to functions.
22
- * @param {Array} deps An array of dependencies for the hook.
23
- * @return {Object} An object mapping props to functions created by the passed
24
- * in dispatchMap.
25
- */
1
+ import { useMemo, useRef } from "@wordpress/element";
2
+ import { useIsomorphicLayoutEffect } from "@wordpress/compose";
3
+ import useRegistry from "../registry-provider/use-registry";
26
4
  const useDispatchWithMap = (dispatchMap, deps) => {
27
5
  const registry = useRegistry();
28
6
  const currentDispatchMapRef = useRef(dispatchMap);
@@ -30,15 +8,29 @@ const useDispatchWithMap = (dispatchMap, deps) => {
30
8
  currentDispatchMapRef.current = dispatchMap;
31
9
  });
32
10
  return useMemo(() => {
33
- const currentDispatchProps = currentDispatchMapRef.current(registry.dispatch, registry);
34
- return Object.fromEntries(Object.entries(currentDispatchProps).map(([propName, dispatcher]) => {
35
- if (typeof dispatcher !== 'function') {
36
- // eslint-disable-next-line no-console
37
- console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`);
38
- }
39
- return [propName, (...args) => currentDispatchMapRef.current(registry.dispatch, registry)[propName](...args)];
40
- }));
11
+ const currentDispatchProps = currentDispatchMapRef.current(
12
+ registry.dispatch,
13
+ registry
14
+ );
15
+ return Object.fromEntries(
16
+ Object.entries(currentDispatchProps).map(
17
+ ([propName, dispatcher]) => {
18
+ if (typeof dispatcher !== "function") {
19
+ console.warn(
20
+ `Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`
21
+ );
22
+ }
23
+ return [
24
+ propName,
25
+ (...args) => currentDispatchMapRef.current(registry.dispatch, registry)[propName](...args)
26
+ ];
27
+ }
28
+ )
29
+ );
41
30
  }, [registry, ...deps]);
42
31
  };
43
- export default useDispatchWithMap;
44
- //# sourceMappingURL=use-dispatch-with-map.js.map
32
+ var use_dispatch_with_map_default = useDispatchWithMap;
33
+ export {
34
+ use_dispatch_with_map_default as default
35
+ };
36
+ //# sourceMappingURL=use-dispatch-with-map.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["useMemo","useRef","useIsomorphicLayoutEffect","useRegistry","useDispatchWithMap","dispatchMap","deps","registry","currentDispatchMapRef","current","currentDispatchProps","dispatch","Object","fromEntries","entries","map","propName","dispatcher","console","warn","args"],"sources":["@wordpress/data/src/components/use-dispatch/use-dispatch-with-map.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\n\n/**\n * Custom react hook for returning aggregate dispatch actions using the provided\n * dispatchMap.\n *\n * Currently this is an internal api only and is implemented by `withDispatch`\n *\n * @param {Function} dispatchMap Receives the `registry.dispatch` function as\n * the first argument and the `registry` object\n * as the second argument. Should return an\n * object mapping props to functions.\n * @param {Array} deps An array of dependencies for the hook.\n * @return {Object} An object mapping props to functions created by the passed\n * in dispatchMap.\n */\nconst useDispatchWithMap = ( dispatchMap, deps ) => {\n\tconst registry = useRegistry();\n\tconst currentDispatchMapRef = useRef( dispatchMap );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tcurrentDispatchMapRef.current = dispatchMap;\n\t} );\n\n\treturn useMemo( () => {\n\t\tconst currentDispatchProps = currentDispatchMapRef.current(\n\t\t\tregistry.dispatch,\n\t\t\tregistry\n\t\t);\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( currentDispatchProps ).map(\n\t\t\t\t( [ propName, dispatcher ] ) => {\n\t\t\t\t\tif ( typeof dispatcher !== 'function' ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`Property ${ propName } returned from dispatchMap in useDispatchWithMap must be a function.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn [\n\t\t\t\t\t\tpropName,\n\t\t\t\t\t\t( ...args ) =>\n\t\t\t\t\t\t\tcurrentDispatchMapRef\n\t\t\t\t\t\t\t\t.current( registry.dispatch, registry )\n\t\t\t\t\t\t\t\t[ propName ]( ...args ),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t}, [ registry, ...deps ] );\n};\n\nexport default useDispatchWithMap;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,MAAM,QAAQ,oBAAoB;AACpD,SAASC,yBAAyB,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA,OAAOC,WAAW,MAAM,mCAAmC;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAGA,CAAEC,WAAW,EAAEC,IAAI,KAAM;EACnD,MAAMC,QAAQ,GAAGJ,WAAW,CAAC,CAAC;EAC9B,MAAMK,qBAAqB,GAAGP,MAAM,CAAEI,WAAY,CAAC;EAEnDH,yBAAyB,CAAE,MAAM;IAChCM,qBAAqB,CAACC,OAAO,GAAGJ,WAAW;EAC5C,CAAE,CAAC;EAEH,OAAOL,OAAO,CAAE,MAAM;IACrB,MAAMU,oBAAoB,GAAGF,qBAAqB,CAACC,OAAO,CACzDF,QAAQ,CAACI,QAAQ,EACjBJ,QACD,CAAC;IACD,OAAOK,MAAM,CAACC,WAAW,CACxBD,MAAM,CAACE,OAAO,CAAEJ,oBAAqB,CAAC,CAACK,GAAG,CACzC,CAAE,CAAEC,QAAQ,EAAEC,UAAU,CAAE,KAAM;MAC/B,IAAK,OAAOA,UAAU,KAAK,UAAU,EAAG;QACvC;QACAC,OAAO,CAACC,IAAI,CACX,YAAaH,QAAQ,sEACtB,CAAC;MACF;MACA,OAAO,CACNA,QAAQ,EACR,CAAE,GAAGI,IAAI,KACRZ,qBAAqB,CACnBC,OAAO,CAAEF,QAAQ,CAACI,QAAQ,EAAEJ,QAAS,CAAC,CACrCS,QAAQ,CAAE,CAAE,GAAGI,IAAK,CAAC,CACzB;IACF,CACD,CACD,CAAC;EACF,CAAC,EAAE,CAAEb,QAAQ,EAAE,GAAGD,IAAI,CAAG,CAAC;AAC3B,CAAC;AAED,eAAeF,kBAAkB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/use-dispatch/use-dispatch-with-map.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\n\n/**\n * Custom react hook for returning aggregate dispatch actions using the provided\n * dispatchMap.\n *\n * Currently this is an internal api only and is implemented by `withDispatch`\n *\n * @param {Function} dispatchMap Receives the `registry.dispatch` function as\n * the first argument and the `registry` object\n * as the second argument. Should return an\n * object mapping props to functions.\n * @param {Array} deps An array of dependencies for the hook.\n * @return {Object} An object mapping props to functions created by the passed\n * in dispatchMap.\n */\nconst useDispatchWithMap = ( dispatchMap, deps ) => {\n\tconst registry = useRegistry();\n\tconst currentDispatchMapRef = useRef( dispatchMap );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tcurrentDispatchMapRef.current = dispatchMap;\n\t} );\n\n\treturn useMemo( () => {\n\t\tconst currentDispatchProps = currentDispatchMapRef.current(\n\t\t\tregistry.dispatch,\n\t\t\tregistry\n\t\t);\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( currentDispatchProps ).map(\n\t\t\t\t( [ propName, dispatcher ] ) => {\n\t\t\t\t\tif ( typeof dispatcher !== 'function' ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`Property ${ propName } returned from dispatchMap in useDispatchWithMap must be a function.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn [\n\t\t\t\t\t\tpropName,\n\t\t\t\t\t\t( ...args ) =>\n\t\t\t\t\t\t\tcurrentDispatchMapRef\n\t\t\t\t\t\t\t\t.current( registry.dispatch, registry )\n\t\t\t\t\t\t\t\t[ propName ]( ...args ),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t}, [ registry, ...deps ] );\n};\n\nexport default useDispatchWithMap;\n"],
5
+ "mappings": "AAGA,SAAS,SAAS,cAAc;AAChC,SAAS,iCAAiC;AAK1C,OAAO,iBAAiB;AAgBxB,MAAM,qBAAqB,CAAE,aAAa,SAAU;AACnD,QAAM,WAAW,YAAY;AAC7B,QAAM,wBAAwB,OAAQ,WAAY;AAElD,4BAA2B,MAAM;AAChC,0BAAsB,UAAU;AAAA,EACjC,CAAE;AAEF,SAAO,QAAS,MAAM;AACrB,UAAM,uBAAuB,sBAAsB;AAAA,MAClD,SAAS;AAAA,MACT;AAAA,IACD;AACA,WAAO,OAAO;AAAA,MACb,OAAO,QAAS,oBAAqB,EAAE;AAAA,QACtC,CAAE,CAAE,UAAU,UAAW,MAAO;AAC/B,cAAK,OAAO,eAAe,YAAa;AAEvC,oBAAQ;AAAA,cACP,YAAa,QAAS;AAAA,YACvB;AAAA,UACD;AACA,iBAAO;AAAA,YACN;AAAA,YACA,IAAK,SACJ,sBACE,QAAS,SAAS,UAAU,QAAS,EACpC,QAAS,EAAG,GAAG,IAAK;AAAA,UACzB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,GAAG,CAAE,UAAU,GAAG,IAAK,CAAE;AAC1B;AAEA,IAAO,gCAAQ;",
6
+ "names": []
7
+ }
@@ -1,68 +1,10 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import useRegistry from '../registry-provider/use-registry';
5
-
6
- /**
7
- * @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor
8
- * @template {import('../../types').AnyConfig} StoreConfig
9
- */
10
- /**
11
- * @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn
12
- * @template StoreNameOrDescriptor
13
- */
14
-
15
- /**
16
- * A custom react hook returning the current registry dispatch actions creators.
17
- *
18
- * Note: The component using this hook must be within the context of a
19
- * RegistryProvider.
20
- *
21
- * @template {undefined | string | StoreDescriptor<any>} StoreNameOrDescriptor
22
- * @param {StoreNameOrDescriptor} [storeNameOrDescriptor] Optionally provide the name of the
23
- * store or its descriptor from which to
24
- * retrieve action creators. If not
25
- * provided, the registry.dispatch
26
- * function is returned instead.
27
- *
28
- * @example
29
- * This illustrates a pattern where you may need to retrieve dynamic data from
30
- * the server via the `useSelect` hook to use in combination with the dispatch
31
- * action.
32
- *
33
- * ```jsx
34
- * import { useCallback } from 'react';
35
- * import { useDispatch, useSelect } from '@wordpress/data';
36
- * import { store as myCustomStore } from 'my-custom-store';
37
- *
38
- * function Button( { onClick, children } ) {
39
- * return <button type="button" onClick={ onClick }>{ children }</button>
40
- * }
41
- *
42
- * const SaleButton = ( { children } ) => {
43
- * const { stockNumber } = useSelect(
44
- * ( select ) => select( myCustomStore ).getStockNumber(),
45
- * []
46
- * );
47
- * const { startSale } = useDispatch( myCustomStore );
48
- * const onClick = useCallback( () => {
49
- * const discountPercent = stockNumber > 50 ? 10: 20;
50
- * startSale( discountPercent );
51
- * }, [ stockNumber ] );
52
- * return <Button onClick={ onClick }>{ children }</Button>
53
- * }
54
- *
55
- * // Rendered somewhere in the application:
56
- * //
57
- * // <SaleButton>Start Sale!</SaleButton>
58
- * ```
59
- * @return {UseDispatchReturn<StoreNameOrDescriptor>} A custom react hook.
60
- */
61
- const useDispatch = storeNameOrDescriptor => {
62
- const {
63
- dispatch
64
- } = useRegistry();
1
+ import useRegistry from "../registry-provider/use-registry";
2
+ const useDispatch = (storeNameOrDescriptor) => {
3
+ const { dispatch } = useRegistry();
65
4
  return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor);
66
5
  };
67
- export default useDispatch;
68
- //# sourceMappingURL=use-dispatch.js.map
6
+ var use_dispatch_default = useDispatch;
7
+ export {
8
+ use_dispatch_default as default
9
+ };
10
+ //# sourceMappingURL=use-dispatch.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["useRegistry","useDispatch","storeNameOrDescriptor","dispatch"],"sources":["@wordpress/data/src/components/use-dispatch/use-dispatch.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\n\n/**\n * @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor\n * @template {import('../../types').AnyConfig} StoreConfig\n */\n/**\n * @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn\n * @template StoreNameOrDescriptor\n */\n\n/**\n * A custom react hook returning the current registry dispatch actions creators.\n *\n * Note: The component using this hook must be within the context of a\n * RegistryProvider.\n *\n * @template {undefined | string | StoreDescriptor<any>} StoreNameOrDescriptor\n * @param {StoreNameOrDescriptor} [storeNameOrDescriptor] Optionally provide the name of the\n * store or its descriptor from which to\n * retrieve action creators. If not\n * provided, the registry.dispatch\n * function is returned instead.\n *\n * @example\n * This illustrates a pattern where you may need to retrieve dynamic data from\n * the server via the `useSelect` hook to use in combination with the dispatch\n * action.\n *\n * ```jsx\n * import { useCallback } from 'react';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Button( { onClick, children } ) {\n * return <button type=\"button\" onClick={ onClick }>{ children }</button>\n * }\n *\n * const SaleButton = ( { children } ) => {\n * const { stockNumber } = useSelect(\n * ( select ) => select( myCustomStore ).getStockNumber(),\n * []\n * );\n * const { startSale } = useDispatch( myCustomStore );\n * const onClick = useCallback( () => {\n * const discountPercent = stockNumber > 50 ? 10: 20;\n * startSale( discountPercent );\n * }, [ stockNumber ] );\n * return <Button onClick={ onClick }>{ children }</Button>\n * }\n *\n * // Rendered somewhere in the application:\n * //\n * // <SaleButton>Start Sale!</SaleButton>\n * ```\n * @return {UseDispatchReturn<StoreNameOrDescriptor>} A custom react hook.\n */\nconst useDispatch = ( storeNameOrDescriptor ) => {\n\tconst { dispatch } = useRegistry();\n\treturn storeNameOrDescriptor === void 0\n\t\t? dispatch\n\t\t: dispatch( storeNameOrDescriptor );\n};\n\nexport default useDispatch;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,WAAW,MAAM,mCAAmC;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAKC,qBAAqB,IAAM;EAChD,MAAM;IAAEC;EAAS,CAAC,GAAGH,WAAW,CAAC,CAAC;EAClC,OAAOE,qBAAqB,KAAK,KAAK,CAAC,GACpCC,QAAQ,GACRA,QAAQ,CAAED,qBAAsB,CAAC;AACrC,CAAC;AAED,eAAeD,WAAW","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/use-dispatch/use-dispatch.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\n\n/**\n * @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor\n * @template {import('../../types').AnyConfig} StoreConfig\n */\n/**\n * @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn\n * @template StoreNameOrDescriptor\n */\n\n/**\n * A custom react hook returning the current registry dispatch actions creators.\n *\n * Note: The component using this hook must be within the context of a\n * RegistryProvider.\n *\n * @template {undefined | string | StoreDescriptor<any>} StoreNameOrDescriptor\n * @param {StoreNameOrDescriptor} [storeNameOrDescriptor] Optionally provide the name of the\n * store or its descriptor from which to\n * retrieve action creators. If not\n * provided, the registry.dispatch\n * function is returned instead.\n *\n * @example\n * This illustrates a pattern where you may need to retrieve dynamic data from\n * the server via the `useSelect` hook to use in combination with the dispatch\n * action.\n *\n * ```jsx\n * import { useCallback } from 'react';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Button( { onClick, children } ) {\n * return <button type=\"button\" onClick={ onClick }>{ children }</button>\n * }\n *\n * const SaleButton = ( { children } ) => {\n * const { stockNumber } = useSelect(\n * ( select ) => select( myCustomStore ).getStockNumber(),\n * []\n * );\n * const { startSale } = useDispatch( myCustomStore );\n * const onClick = useCallback( () => {\n * const discountPercent = stockNumber > 50 ? 10: 20;\n * startSale( discountPercent );\n * }, [ stockNumber ] );\n * return <Button onClick={ onClick }>{ children }</Button>\n * }\n *\n * // Rendered somewhere in the application:\n * //\n * // <SaleButton>Start Sale!</SaleButton>\n * ```\n * @return {UseDispatchReturn<StoreNameOrDescriptor>} A custom react hook.\n */\nconst useDispatch = ( storeNameOrDescriptor ) => {\n\tconst { dispatch } = useRegistry();\n\treturn storeNameOrDescriptor === void 0\n\t\t? dispatch\n\t\t: dispatch( storeNameOrDescriptor );\n};\n\nexport default useDispatch;\n"],
5
+ "mappings": "AAGA,OAAO,iBAAiB;AAyDxB,MAAM,cAAc,CAAE,0BAA2B;AAChD,QAAM,EAAE,SAAS,IAAI,YAAY;AACjC,SAAO,0BAA0B,SAC9B,WACA,SAAU,qBAAsB;AACpC;AAEA,IAAO,uBAAQ;",
6
+ "names": []
7
+ }