@wordpress/data 10.31.1-next.f56bd8138.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 (158) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/async-mode-provider/context.js +35 -54
  3. package/build/components/async-mode-provider/context.js.map +7 -1
  4. package/build/components/async-mode-provider/index.js +40 -25
  5. package/build/components/async-mode-provider/index.js.map +7 -1
  6. package/build/components/async-mode-provider/use-async-mode.js +25 -16
  7. package/build/components/async-mode-provider/use-async-mode.js.map +7 -1
  8. package/build/components/registry-provider/context.js +46 -64
  9. package/build/components/registry-provider/context.js.map +7 -1
  10. package/build/components/registry-provider/index.js +40 -25
  11. package/build/components/registry-provider/index.js.map +7 -1
  12. package/build/components/registry-provider/use-registry.js +25 -55
  13. package/build/components/registry-provider/use-registry.js.map +7 -1
  14. package/build/components/use-dispatch/index.js +38 -17
  15. package/build/components/use-dispatch/index.js.map +7 -1
  16. package/build/components/use-dispatch/use-dispatch-with-map.js +59 -44
  17. package/build/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
  18. package/build/components/use-dispatch/use-dispatch.js +36 -71
  19. package/build/components/use-dispatch/use-dispatch.js.map +7 -1
  20. package/build/components/use-select/index.js +79 -208
  21. package/build/components/use-select/index.js.map +7 -1
  22. package/build/components/with-dispatch/index.js +34 -107
  23. package/build/components/with-dispatch/index.js.map +7 -1
  24. package/build/components/with-registry/index.js +30 -30
  25. package/build/components/with-registry/index.js.map +7 -1
  26. package/build/components/with-select/index.js +44 -67
  27. package/build/components/with-select/index.js.map +7 -1
  28. package/build/controls.js +49 -110
  29. package/build/controls.js.map +7 -1
  30. package/build/create-selector.js +36 -11
  31. package/build/create-selector.js.map +7 -1
  32. package/build/default-registry.js +24 -10
  33. package/build/default-registry.js.map +7 -1
  34. package/build/dispatch.js +38 -31
  35. package/build/dispatch.js.map +7 -1
  36. package/build/factory.js +29 -85
  37. package/build/factory.js.map +7 -1
  38. package/build/index.js +114 -301
  39. package/build/index.js.map +7 -1
  40. package/build/lock-unlock.js +31 -14
  41. package/build/lock-unlock.js.map +7 -1
  42. package/build/plugins/index.js +36 -11
  43. package/build/plugins/index.js.map +7 -1
  44. package/build/plugins/persistence/index.js +74 -139
  45. package/build/plugins/persistence/index.js.map +7 -1
  46. package/build/plugins/persistence/storage/default.js +37 -18
  47. package/build/plugins/persistence/storage/default.js.map +7 -1
  48. package/build/plugins/persistence/storage/object.js +24 -7
  49. package/build/plugins/persistence/storage/object.js.map +7 -1
  50. package/build/promise-middleware.js +37 -20
  51. package/build/promise-middleware.js.map +7 -1
  52. package/build/redux-store/combine-reducers.js +26 -5
  53. package/build/redux-store/combine-reducers.js.map +7 -1
  54. package/build/redux-store/index.js +221 -331
  55. package/build/redux-store/index.js.map +7 -1
  56. package/build/redux-store/metadata/actions.js +51 -112
  57. package/build/redux-store/metadata/actions.js.map +7 -1
  58. package/build/redux-store/metadata/equivalent-key-map.d.js +1 -1
  59. package/build/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
  60. package/build/redux-store/metadata/reducer.js +111 -115
  61. package/build/redux-store/metadata/reducer.js.map +7 -1
  62. package/build/redux-store/metadata/selectors.js +109 -181
  63. package/build/redux-store/metadata/selectors.js.map +7 -1
  64. package/build/redux-store/metadata/utils.js +32 -35
  65. package/build/redux-store/metadata/utils.js.map +7 -1
  66. package/build/redux-store/thunk-middleware.js +24 -7
  67. package/build/redux-store/thunk-middleware.js.map +7 -1
  68. package/build/registry.js +94 -198
  69. package/build/registry.js.map +7 -1
  70. package/build/resolvers-cache-middleware.js +26 -27
  71. package/build/resolvers-cache-middleware.js.map +7 -1
  72. package/build/select.js +38 -31
  73. package/build/select.js.map +7 -1
  74. package/build/store/index.js +52 -16
  75. package/build/store/index.js.map +7 -1
  76. package/build/types.js +16 -5
  77. package/build/types.js.map +7 -1
  78. package/build/utils/emitter.js +33 -16
  79. package/build/utils/emitter.js.map +7 -1
  80. package/build-module/components/async-mode-provider/context.js +12 -49
  81. package/build-module/components/async-mode-provider/context.js.map +7 -1
  82. package/build-module/components/async-mode-provider/index.js +8 -3
  83. package/build-module/components/async-mode-provider/index.js.map +7 -1
  84. package/build-module/components/async-mode-provider/use-async-mode.js +7 -11
  85. package/build-module/components/async-mode-provider/use-async-mode.js.map +7 -1
  86. package/build-module/components/registry-provider/context.js +13 -58
  87. package/build-module/components/registry-provider/context.js.map +7 -1
  88. package/build-module/components/registry-provider/index.js +8 -3
  89. package/build-module/components/registry-provider/index.js.map +7 -1
  90. package/build-module/components/registry-provider/use-registry.js +7 -51
  91. package/build-module/components/registry-provider/use-registry.js.map +7 -1
  92. package/build-module/components/use-dispatch/index.js +7 -3
  93. package/build-module/components/use-dispatch/index.js.map +7 -1
  94. package/build-module/components/use-dispatch/use-dispatch-with-map.js +27 -35
  95. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
  96. package/build-module/components/use-dispatch/use-dispatch.js +8 -66
  97. package/build-module/components/use-dispatch/use-dispatch.js.map +7 -1
  98. package/build-module/components/use-select/index.js +45 -193
  99. package/build-module/components/use-select/index.js.map +7 -1
  100. package/build-module/components/with-dispatch/index.js +16 -104
  101. package/build-module/components/with-dispatch/index.js.map +7 -1
  102. package/build-module/components/with-registry/index.js +12 -27
  103. package/build-module/components/with-registry/index.js.map +7 -1
  104. package/build-module/components/with-select/index.js +16 -63
  105. package/build-module/components/with-select/index.js.map +7 -1
  106. package/build-module/controls.js +25 -105
  107. package/build-module/controls.js.map +7 -1
  108. package/build-module/create-selector.js +5 -8
  109. package/build-module/create-selector.js.map +7 -1
  110. package/build-module/default-registry.js +6 -6
  111. package/build-module/default-registry.js.map +7 -1
  112. package/build-module/dispatch.js +6 -27
  113. package/build-module/dispatch.js.map +7 -1
  114. package/build-module/factory.js +8 -82
  115. package/build-module/factory.js.map +7 -1
  116. package/build-module/index.js +62 -185
  117. package/build-module/index.js.map +7 -1
  118. package/build-module/lock-unlock.js +8 -7
  119. package/build-module/lock-unlock.js.map +7 -1
  120. package/build-module/plugins/index.js +5 -2
  121. package/build-module/plugins/index.js.map +7 -1
  122. package/build-module/plugins/persistence/index.js +38 -129
  123. package/build-module/plugins/persistence/index.js.map +7 -1
  124. package/build-module/plugins/persistence/storage/default.js +8 -11
  125. package/build-module/plugins/persistence/storage/default.js.map +7 -1
  126. package/build-module/plugins/persistence/storage/object.js +6 -3
  127. package/build-module/plugins/persistence/storage/object.js.map +7 -1
  128. package/build-module/promise-middleware.js +8 -14
  129. package/build-module/promise-middleware.js.map +7 -1
  130. package/build-module/redux-store/combine-reducers.js +5 -2
  131. package/build-module/redux-store/combine-reducers.js.map +7 -1
  132. package/build-module/redux-store/index.js +180 -310
  133. package/build-module/redux-store/index.js.map +7 -1
  134. package/build-module/redux-store/metadata/actions.js +30 -109
  135. package/build-module/redux-store/metadata/actions.js.map +7 -1
  136. package/build-module/redux-store/metadata/equivalent-key-map.d.js +1 -2
  137. package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
  138. package/build-module/redux-store/metadata/reducer.js +83 -108
  139. package/build-module/redux-store/metadata/reducer.js.map +7 -1
  140. package/build-module/redux-store/metadata/selectors.js +76 -175
  141. package/build-module/redux-store/metadata/selectors.js.map +7 -1
  142. package/build-module/redux-store/metadata/utils.js +10 -30
  143. package/build-module/redux-store/metadata/utils.js.map +7 -1
  144. package/build-module/redux-store/thunk-middleware.js +7 -4
  145. package/build-module/redux-store/thunk-middleware.js.map +7 -1
  146. package/build-module/registry.js +56 -187
  147. package/build-module/registry.js.map +7 -1
  148. package/build-module/resolvers-cache-middleware.js +8 -23
  149. package/build-module/resolvers-cache-middleware.js.map +7 -1
  150. package/build-module/select.js +6 -27
  151. package/build-module/select.js.map +7 -1
  152. package/build-module/store/index.js +34 -12
  153. package/build-module/store/index.js.map +7 -1
  154. package/build-module/types.js +1 -2
  155. package/build-module/types.js.map +7 -1
  156. package/build-module/utils/emitter.js +12 -13
  157. package/build-module/utils/emitter.js.map +7 -1
  158. package/package.json +17 -10
@@ -1 +1,7 @@
1
- {"version":3,"names":["_useDispatch","_interopRequireDefault","require","_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,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA","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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAuC;AACvC,mCAA8C;",
6
+ "names": []
7
+ }
@@ -1,51 +1,66 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var use_dispatch_with_map_exports = {};
30
+ __export(use_dispatch_with_map_exports, {
31
+ default: () => use_dispatch_with_map_default
6
32
  });
7
- exports.default = void 0;
8
- var _element = require("@wordpress/element");
9
- var _compose = require("@wordpress/compose");
10
- var _useRegistry = _interopRequireDefault(require("../registry-provider/use-registry"));
11
- /**
12
- * WordPress dependencies
13
- */
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
-
19
- /**
20
- * Custom react hook for returning aggregate dispatch actions using the provided
21
- * dispatchMap.
22
- *
23
- * Currently this is an internal api only and is implemented by `withDispatch`
24
- *
25
- * @param {Function} dispatchMap Receives the `registry.dispatch` function as
26
- * the first argument and the `registry` object
27
- * as the second argument. Should return an
28
- * object mapping props to functions.
29
- * @param {Array} deps An array of dependencies for the hook.
30
- * @return {Object} An object mapping props to functions created by the passed
31
- * in dispatchMap.
32
- */
33
+ module.exports = __toCommonJS(use_dispatch_with_map_exports);
34
+ var import_element = require("@wordpress/element");
35
+ var import_compose = require("@wordpress/compose");
36
+ var import_use_registry = __toESM(require("../registry-provider/use-registry"));
33
37
  const useDispatchWithMap = (dispatchMap, deps) => {
34
- const registry = (0, _useRegistry.default)();
35
- const currentDispatchMapRef = (0, _element.useRef)(dispatchMap);
36
- (0, _compose.useIsomorphicLayoutEffect)(() => {
38
+ const registry = (0, import_use_registry.default)();
39
+ const currentDispatchMapRef = (0, import_element.useRef)(dispatchMap);
40
+ (0, import_compose.useIsomorphicLayoutEffect)(() => {
37
41
  currentDispatchMapRef.current = dispatchMap;
38
42
  });
39
- return (0, _element.useMemo)(() => {
40
- const currentDispatchProps = currentDispatchMapRef.current(registry.dispatch, registry);
41
- return Object.fromEntries(Object.entries(currentDispatchProps).map(([propName, dispatcher]) => {
42
- if (typeof dispatcher !== 'function') {
43
- // eslint-disable-next-line no-console
44
- console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`);
45
- }
46
- return [propName, (...args) => currentDispatchMapRef.current(registry.dispatch, registry)[propName](...args)];
47
- }));
43
+ return (0, import_element.useMemo)(() => {
44
+ const currentDispatchProps = currentDispatchMapRef.current(
45
+ registry.dispatch,
46
+ registry
47
+ );
48
+ return Object.fromEntries(
49
+ Object.entries(currentDispatchProps).map(
50
+ ([propName, dispatcher]) => {
51
+ if (typeof dispatcher !== "function") {
52
+ console.warn(
53
+ `Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`
54
+ );
55
+ }
56
+ return [
57
+ propName,
58
+ (...args) => currentDispatchMapRef.current(registry.dispatch, registry)[propName](...args)
59
+ ];
60
+ }
61
+ )
62
+ );
48
63
  }, [registry, ...deps]);
49
64
  };
50
- var _default = exports.default = useDispatchWithMap;
51
- //# sourceMappingURL=use-dispatch-with-map.js.map
65
+ var use_dispatch_with_map_default = useDispatchWithMap;
66
+ //# sourceMappingURL=use-dispatch-with-map.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_element","require","_compose","_useRegistry","_interopRequireDefault","useDispatchWithMap","dispatchMap","deps","registry","useRegistry","currentDispatchMapRef","useRef","useIsomorphicLayoutEffect","current","useMemo","currentDispatchProps","dispatch","Object","fromEntries","entries","map","propName","dispatcher","console","warn","args","_default","exports","default"],"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":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,kBAAkB,GAAGA,CAAEC,WAAW,EAAEC,IAAI,KAAM;EACnD,MAAMC,QAAQ,GAAG,IAAAC,oBAAW,EAAC,CAAC;EAC9B,MAAMC,qBAAqB,GAAG,IAAAC,eAAM,EAAEL,WAAY,CAAC;EAEnD,IAAAM,kCAAyB,EAAE,MAAM;IAChCF,qBAAqB,CAACG,OAAO,GAAGP,WAAW;EAC5C,CAAE,CAAC;EAEH,OAAO,IAAAQ,gBAAO,EAAE,MAAM;IACrB,MAAMC,oBAAoB,GAAGL,qBAAqB,CAACG,OAAO,CACzDL,QAAQ,CAACQ,QAAQ,EACjBR,QACD,CAAC;IACD,OAAOS,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,KACRf,qBAAqB,CACnBG,OAAO,CAAEL,QAAQ,CAACQ,QAAQ,EAAER,QAAS,CAAC,CACrCa,QAAQ,CAAE,CAAE,GAAGI,IAAK,CAAC,CACzB;IACF,CACD,CACD,CAAC;EACF,CAAC,EAAE,CAAEjB,QAAQ,EAAE,GAAGD,IAAI,CAAG,CAAC;AAC3B,CAAC;AAAC,IAAAmB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEavB,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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAgC;AAChC,qBAA0C;AAK1C,0BAAwB;AAgBxB,MAAM,qBAAqB,CAAE,aAAa,SAAU;AACnD,QAAM,eAAW,oBAAAA,SAAY;AAC7B,QAAM,4BAAwB,uBAAQ,WAAY;AAElD,gDAA2B,MAAM;AAChC,0BAAsB,UAAU;AAAA,EACjC,CAAE;AAEF,aAAO,wBAAS,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": ["useRegistry"]
7
+ }
@@ -1,75 +1,40 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var use_dispatch_exports = {};
30
+ __export(use_dispatch_exports, {
31
+ default: () => use_dispatch_default
6
32
  });
7
- exports.default = void 0;
8
- var _useRegistry = _interopRequireDefault(require("../registry-provider/use-registry"));
9
- /**
10
- * Internal dependencies
11
- */
12
-
13
- /**
14
- * @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor
15
- * @template {import('../../types').AnyConfig} StoreConfig
16
- */
17
- /**
18
- * @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn
19
- * @template StoreNameOrDescriptor
20
- */
21
-
22
- /**
23
- * A custom react hook returning the current registry dispatch actions creators.
24
- *
25
- * Note: The component using this hook must be within the context of a
26
- * RegistryProvider.
27
- *
28
- * @template {undefined | string | StoreDescriptor<any>} StoreNameOrDescriptor
29
- * @param {StoreNameOrDescriptor} [storeNameOrDescriptor] Optionally provide the name of the
30
- * store or its descriptor from which to
31
- * retrieve action creators. If not
32
- * provided, the registry.dispatch
33
- * function is returned instead.
34
- *
35
- * @example
36
- * This illustrates a pattern where you may need to retrieve dynamic data from
37
- * the server via the `useSelect` hook to use in combination with the dispatch
38
- * action.
39
- *
40
- * ```jsx
41
- * import { useCallback } from 'react';
42
- * import { useDispatch, useSelect } from '@wordpress/data';
43
- * import { store as myCustomStore } from 'my-custom-store';
44
- *
45
- * function Button( { onClick, children } ) {
46
- * return <button type="button" onClick={ onClick }>{ children }</button>
47
- * }
48
- *
49
- * const SaleButton = ( { children } ) => {
50
- * const { stockNumber } = useSelect(
51
- * ( select ) => select( myCustomStore ).getStockNumber(),
52
- * []
53
- * );
54
- * const { startSale } = useDispatch( myCustomStore );
55
- * const onClick = useCallback( () => {
56
- * const discountPercent = stockNumber > 50 ? 10: 20;
57
- * startSale( discountPercent );
58
- * }, [ stockNumber ] );
59
- * return <Button onClick={ onClick }>{ children }</Button>
60
- * }
61
- *
62
- * // Rendered somewhere in the application:
63
- * //
64
- * // <SaleButton>Start Sale!</SaleButton>
65
- * ```
66
- * @return {UseDispatchReturn<StoreNameOrDescriptor>} A custom react hook.
67
- */
68
- const useDispatch = storeNameOrDescriptor => {
69
- const {
70
- dispatch
71
- } = (0, _useRegistry.default)();
33
+ module.exports = __toCommonJS(use_dispatch_exports);
34
+ var import_use_registry = __toESM(require("../registry-provider/use-registry"));
35
+ const useDispatch = (storeNameOrDescriptor) => {
36
+ const { dispatch } = (0, import_use_registry.default)();
72
37
  return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor);
73
38
  };
74
- var _default = exports.default = useDispatch;
75
- //# sourceMappingURL=use-dispatch.js.map
39
+ var use_dispatch_default = useDispatch;
40
+ //# sourceMappingURL=use-dispatch.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_useRegistry","_interopRequireDefault","require","useDispatch","storeNameOrDescriptor","dispatch","useRegistry","_default","exports","default"],"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":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;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,GAAG,IAAAC,oBAAW,EAAC,CAAC;EAClC,OAAOF,qBAAqB,KAAK,KAAK,CAAC,GACpCC,QAAQ,GACRA,QAAQ,CAAED,qBAAsB,CAAC;AACrC,CAAC;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaN,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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAwB;AAyDxB,MAAM,cAAc,CAAE,0BAA2B;AAChD,QAAM,EAAE,SAAS,QAAI,oBAAAA,SAAY;AACjC,SAAO,0BAA0B,SAC9B,WACA,SAAU,qBAAsB;AACpC;AAEA,IAAO,uBAAQ;",
6
+ "names": ["useRegistry"]
7
+ }