@wordpress/data 9.8.0 → 9.10.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.
- package/CHANGELOG.md +17 -4
- package/README.md +101 -2
- package/build/components/async-mode-provider/context.js +2 -3
- package/build/components/async-mode-provider/context.js.map +1 -1
- package/build/components/async-mode-provider/index.js +0 -5
- package/build/components/async-mode-provider/index.js.map +1 -1
- package/build/components/async-mode-provider/use-async-mode.js +1 -3
- package/build/components/async-mode-provider/use-async-mode.js.map +1 -1
- package/build/components/registry-provider/context.js +3 -6
- package/build/components/registry-provider/context.js.map +1 -1
- package/build/components/registry-provider/index.js +0 -5
- package/build/components/registry-provider/index.js.map +1 -1
- package/build/components/registry-provider/use-registry.js +0 -3
- package/build/components/registry-provider/use-registry.js.map +1 -1
- package/build/components/use-dispatch/index.js +0 -3
- package/build/components/use-dispatch/index.js.map +1 -1
- package/build/components/use-dispatch/use-dispatch-with-map.js +0 -7
- package/build/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
- package/build/components/use-dispatch/use-dispatch.js +0 -5
- package/build/components/use-dispatch/use-dispatch.js.map +1 -1
- package/build/components/use-select/index.js +35 -53
- package/build/components/use-select/index.js.map +1 -1
- package/build/components/with-dispatch/index.js +2 -7
- package/build/components/with-dispatch/index.js.map +1 -1
- package/build/components/with-registry/index.js +2 -5
- package/build/components/with-registry/index.js.map +1 -1
- package/build/components/with-select/index.js +2 -8
- package/build/components/with-select/index.js.map +1 -1
- package/build/controls.js +4 -10
- package/build/controls.js.map +1 -1
- package/build/default-registry.js +0 -3
- package/build/default-registry.js.map +1 -1
- package/build/dispatch.js +0 -3
- package/build/dispatch.js.map +1 -1
- package/build/factory.js +2 -5
- package/build/factory.js.map +1 -1
- package/build/index.js +7 -28
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +1 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/plugins/index.js +0 -2
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/persistence/index.js +13 -37
- package/build/plugins/persistence/index.js.map +1 -1
- package/build/plugins/persistence/storage/default.js +1 -5
- package/build/plugins/persistence/storage/default.js.map +1 -1
- package/build/plugins/persistence/storage/object.js +0 -5
- package/build/plugins/persistence/storage/object.js.map +1 -1
- package/build/promise-middleware.js +0 -5
- package/build/promise-middleware.js.map +1 -1
- package/build/redux-store/index.js +36 -117
- package/build/redux-store/index.js.map +1 -1
- package/build/redux-store/metadata/actions.js +8 -17
- package/build/redux-store/metadata/actions.js.map +1 -1
- package/build/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
- package/build/redux-store/metadata/reducer.js +1 -23
- package/build/redux-store/metadata/reducer.js.map +1 -1
- package/build/redux-store/metadata/selectors.js +8 -22
- package/build/redux-store/metadata/selectors.js.map +1 -1
- package/build/redux-store/metadata/utils.js +6 -14
- package/build/redux-store/metadata/utils.js.map +1 -1
- package/build/redux-store/thunk-middleware.js +0 -2
- package/build/redux-store/thunk-middleware.js.map +1 -1
- package/build/registry.js +29 -73
- package/build/registry.js.map +1 -1
- package/build/resolvers-cache-middleware.js +2 -8
- package/build/resolvers-cache-middleware.js.map +1 -1
- package/build/select.js +0 -3
- package/build/select.js.map +1 -1
- package/build/store/index.js +0 -7
- package/build/store/index.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils/emitter.js +2 -11
- package/build/utils/emitter.js.map +1 -1
- package/build-module/components/async-mode-provider/context.js +1 -1
- package/build-module/components/async-mode-provider/context.js.map +1 -1
- package/build-module/components/async-mode-provider/index.js.map +1 -1
- package/build-module/components/async-mode-provider/use-async-mode.js +1 -1
- package/build-module/components/async-mode-provider/use-async-mode.js.map +1 -1
- package/build-module/components/registry-provider/context.js +3 -3
- package/build-module/components/registry-provider/context.js.map +1 -1
- package/build-module/components/registry-provider/index.js.map +1 -1
- package/build-module/components/registry-provider/use-registry.js +2 -2
- package/build-module/components/registry-provider/use-registry.js.map +1 -1
- package/build-module/components/use-dispatch/index.js.map +1 -1
- package/build-module/components/use-dispatch/use-dispatch-with-map.js +2 -4
- package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
- package/build-module/components/use-dispatch/use-dispatch.js +1 -3
- package/build-module/components/use-dispatch/use-dispatch.js.map +1 -1
- package/build-module/components/use-select/index.js +35 -46
- package/build-module/components/use-select/index.js.map +1 -1
- package/build-module/components/with-dispatch/index.js +4 -6
- package/build-module/components/with-dispatch/index.js.map +1 -1
- package/build-module/components/with-registry/index.js +4 -4
- package/build-module/components/with-registry/index.js.map +1 -1
- package/build-module/components/with-select/index.js +4 -6
- package/build-module/components/with-select/index.js.map +1 -1
- package/build-module/controls.js +4 -8
- package/build-module/controls.js.map +1 -1
- package/build-module/default-registry.js.map +1 -1
- package/build-module/dispatch.js +2 -1
- package/build-module/dispatch.js.map +1 -1
- package/build-module/factory.js +2 -3
- package/build-module/factory.js.map +1 -1
- package/build-module/index.js +11 -10
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/persistence/index.js +15 -30
- package/build-module/plugins/persistence/index.js.map +1 -1
- package/build-module/plugins/persistence/storage/default.js +0 -2
- package/build-module/plugins/persistence/storage/default.js.map +1 -1
- package/build-module/plugins/persistence/storage/object.js +0 -5
- package/build-module/plugins/persistence/storage/object.js.map +1 -1
- package/build-module/promise-middleware.js +1 -3
- package/build-module/promise-middleware.js.map +1 -1
- package/build-module/redux-store/index.js +38 -101
- package/build-module/redux-store/index.js.map +1 -1
- package/build-module/redux-store/metadata/actions.js +8 -8
- package/build-module/redux-store/metadata/actions.js.map +1 -1
- package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
- package/build-module/redux-store/metadata/reducer.js +1 -21
- package/build-module/redux-store/metadata/reducer.js.map +1 -1
- package/build-module/redux-store/metadata/selectors.js +9 -13
- package/build-module/redux-store/metadata/selectors.js.map +1 -1
- package/build-module/redux-store/metadata/utils.js +6 -11
- package/build-module/redux-store/metadata/utils.js.map +1 -1
- package/build-module/redux-store/thunk-middleware.js +0 -1
- package/build-module/redux-store/thunk-middleware.js.map +1 -1
- package/build-module/registry.js +30 -67
- package/build-module/registry.js.map +1 -1
- package/build-module/resolvers-cache-middleware.js +3 -6
- package/build-module/resolvers-cache-middleware.js.map +1 -1
- package/build-module/select.js +2 -1
- package/build-module/select.js.map +1 -1
- package/build-module/store/index.js +0 -7
- package/build-module/store/index.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/utils/emitter.js +2 -10
- package/build-module/utils/emitter.js.map +1 -1
- package/build-types/components/use-select/index.d.ts.map +1 -1
- package/build-types/dispatch.d.ts +2 -2
- package/build-types/dispatch.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/plugins/persistence/index.d.ts.map +1 -1
- package/build-types/private-apis.d.ts +3 -0
- package/build-types/private-apis.d.ts.map +1 -0
- package/build-types/store/index.d.ts +1 -1
- package/build-types/types.d.ts +9 -3
- package/build-types/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/components/use-select/index.js +14 -0
- package/src/dispatch.ts +6 -9
- package/src/plugins/persistence/index.js +0 -1
- package/src/types.ts +38 -5
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 9.10.0 (2023-08-16)
|
|
6
|
+
|
|
7
|
+
### Enhancements
|
|
8
|
+
|
|
9
|
+
- Warn if the `useSelect` hook returns different values when called with the same state and parameters ([#53666](https://github.com/WordPress/gutenberg/pull/53666)).
|
|
10
|
+
|
|
11
|
+
## 9.9.0 (2023-08-10)
|
|
12
|
+
|
|
13
|
+
### Bug Fix
|
|
14
|
+
|
|
15
|
+
- Update the type definitions for dispatched actions by accounting for Promisified return values and thunks. Previously, a dispatched action's return type was the same as the return type of the original action creator, which did not account for how dispatch works internally. (Plain actions get wrapped in a Promise, and thunk actions ultimately resolve to the innermost function's return type).
|
|
16
|
+
- Update the type definition for dispatch() to handle string store descriptors correctly.
|
|
17
|
+
|
|
5
18
|
## 9.8.0 (2023-07-20)
|
|
6
19
|
|
|
7
20
|
## 9.7.0 (2023-07-05)
|
|
@@ -62,7 +75,7 @@
|
|
|
62
75
|
|
|
63
76
|
### Breaking Changes
|
|
64
77
|
|
|
65
|
-
–
|
|
78
|
+
– Add TypeScript types to the built package (via "types": "build-types" in the package.json)
|
|
66
79
|
|
|
67
80
|
### Bug Fix
|
|
68
81
|
|
|
@@ -100,9 +113,9 @@
|
|
|
100
113
|
|
|
101
114
|
### New Features
|
|
102
115
|
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
116
|
+
- Enabled thunks by default for all stores and removed the `__experimentalUseThunks` flag.
|
|
117
|
+
- Store the resolution errors in store metadata and expose them using `hasResolutionFailed` the `getResolutionError` meta-selectors ([#38669](https://github.com/WordPress/gutenberg/pull/38669)).
|
|
118
|
+
- Expose the resolution status (undefined, resolving, finished, error) via the `getResolutionState` meta-selector ([#38669](https://github.com/WordPress/gutenberg/pull/38669)).
|
|
106
119
|
|
|
107
120
|
## 6.2.1 (2022-02-10)
|
|
108
121
|
|
package/README.md
CHANGED
|
@@ -499,11 +499,11 @@ dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );
|
|
|
499
499
|
|
|
500
500
|
_Parameters_
|
|
501
501
|
|
|
502
|
-
- _storeNameOrDescriptor_ `
|
|
502
|
+
- _storeNameOrDescriptor_ `StoreNameOrDescriptor`: The store descriptor. The legacy calling convention of passing the store name is also supported.
|
|
503
503
|
|
|
504
504
|
_Returns_
|
|
505
505
|
|
|
506
|
-
- `
|
|
506
|
+
- `DispatchReturn< StoreNameOrDescriptor >`: Object containing the action creators.
|
|
507
507
|
|
|
508
508
|
### plugins
|
|
509
509
|
|
|
@@ -1028,6 +1028,105 @@ function Component() {
|
|
|
1028
1028
|
}
|
|
1029
1029
|
```
|
|
1030
1030
|
|
|
1031
|
+
## Selectors
|
|
1032
|
+
|
|
1033
|
+
The following selectors are available on the object returned by `wp.data.select( 'core' )`.
|
|
1034
|
+
|
|
1035
|
+
_Example_
|
|
1036
|
+
|
|
1037
|
+
```js
|
|
1038
|
+
import { store as coreDataStore } from '@wordpress/core-data';
|
|
1039
|
+
import { useSelect } from '@wordpress/data';
|
|
1040
|
+
|
|
1041
|
+
function Component() {
|
|
1042
|
+
const result = useSelect( ( select ) => {
|
|
1043
|
+
const query = { per_page: 20 };
|
|
1044
|
+
const selectorArgs = [ 'postType', 'page', query ];
|
|
1045
|
+
|
|
1046
|
+
return {
|
|
1047
|
+
pages: select( coreDataStore ).getEntityRecords( ...selectorArgs ),
|
|
1048
|
+
hasStartedResolution: select( coreDataStore ).hasStartedResolution(
|
|
1049
|
+
'getEntityRecords', // _selectorName_
|
|
1050
|
+
selectorArgs
|
|
1051
|
+
),
|
|
1052
|
+
hasFinishedResolution: select(
|
|
1053
|
+
coreDataStore
|
|
1054
|
+
).hasFinishedResolution( 'getEntityRecords', selectorArgs ),
|
|
1055
|
+
isResolving: select( coreDataStore ).isResolving(
|
|
1056
|
+
'getEntityRecords',
|
|
1057
|
+
selectorArgs
|
|
1058
|
+
),
|
|
1059
|
+
};
|
|
1060
|
+
} );
|
|
1061
|
+
|
|
1062
|
+
if ( result.hasStartedResolution ) {
|
|
1063
|
+
return <>Fetching data...</>;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
if ( result.isResolving ) {
|
|
1067
|
+
return (
|
|
1068
|
+
<>
|
|
1069
|
+
{
|
|
1070
|
+
// show a spinner
|
|
1071
|
+
}
|
|
1072
|
+
</>
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
if ( result.hasFinishedResolution ) {
|
|
1077
|
+
return (
|
|
1078
|
+
<>
|
|
1079
|
+
{
|
|
1080
|
+
// data is ready
|
|
1081
|
+
}
|
|
1082
|
+
</>
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
```
|
|
1087
|
+
|
|
1088
|
+
### hasFinishedResolution
|
|
1089
|
+
|
|
1090
|
+
Returns true if resolution has completed for a given selector name, and arguments set.
|
|
1091
|
+
|
|
1092
|
+
_Parameters_
|
|
1093
|
+
|
|
1094
|
+
- _state_ `State`: Data state.
|
|
1095
|
+
- _selectorName_ `string`: Selector name.
|
|
1096
|
+
- _args_ `unknown[]?`: Arguments passed to selector.
|
|
1097
|
+
|
|
1098
|
+
_Returns_
|
|
1099
|
+
|
|
1100
|
+
- `boolean`: Whether resolution has completed.
|
|
1101
|
+
|
|
1102
|
+
### hasStartedResolution
|
|
1103
|
+
|
|
1104
|
+
Returns true if resolution has already been triggered for a given selector name, and arguments set.
|
|
1105
|
+
|
|
1106
|
+
_Parameters_
|
|
1107
|
+
|
|
1108
|
+
- _state_ `State`: Data state.
|
|
1109
|
+
- _selectorName_ `string`: Selector name.
|
|
1110
|
+
- _args_ `unknown[]?`: Arguments passed to selector.
|
|
1111
|
+
|
|
1112
|
+
_Returns_
|
|
1113
|
+
|
|
1114
|
+
- `boolean`: Whether resolution has been triggered.
|
|
1115
|
+
|
|
1116
|
+
### isResolving
|
|
1117
|
+
|
|
1118
|
+
Returns true if resolution has been triggered but has not yet completed for a given selector name, and arguments set.
|
|
1119
|
+
|
|
1120
|
+
_Parameters_
|
|
1121
|
+
|
|
1122
|
+
- _state_ `State`: Data state.
|
|
1123
|
+
- _selectorName_ `string`: Selector name.
|
|
1124
|
+
- _args_ `unknown[]?`: Arguments passed to selector.
|
|
1125
|
+
|
|
1126
|
+
_Returns_
|
|
1127
|
+
|
|
1128
|
+
- `boolean`: Whether resolution is in progress.
|
|
1129
|
+
|
|
1031
1130
|
## Going further
|
|
1032
1131
|
|
|
1033
1132
|
- [What is WordPress Data?](https://unfoldingneurons.com/2020/what-is-wordpress-data/)
|
|
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.Context = exports.AsyncModeConsumer = void 0;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* WordPress dependencies
|
|
12
10
|
*/
|
|
11
|
+
|
|
13
12
|
const Context = (0, _element.createContext)(false);
|
|
14
13
|
exports.Context = Context;
|
|
15
14
|
const {
|
|
@@ -17,6 +16,7 @@ const {
|
|
|
17
16
|
Provider
|
|
18
17
|
} = Context;
|
|
19
18
|
const AsyncModeConsumer = Consumer;
|
|
19
|
+
|
|
20
20
|
/**
|
|
21
21
|
* Context Provider Component used to switch the data module component rerendering
|
|
22
22
|
* between Sync and Async modes.
|
|
@@ -52,7 +52,6 @@ const AsyncModeConsumer = Consumer;
|
|
|
52
52
|
* @param {boolean} props.value Enable Async Mode.
|
|
53
53
|
* @return {WPComponent} The component to be rendered.
|
|
54
54
|
*/
|
|
55
|
-
|
|
56
55
|
exports.AsyncModeConsumer = AsyncModeConsumer;
|
|
57
56
|
var _default = Provider;
|
|
58
57
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","Context","createContext","exports","Consumer","Provider","AsyncModeConsumer","_default","default"],"sources":["@wordpress/data/src/components/async-mode-provider/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const Context = createContext( false );\n\nconst { Consumer, Provider } = Context;\n\nexport const AsyncModeConsumer = Consumer;\n\n/**\n * Context Provider Component used to switch the data module component rerendering\n * between Sync and Async modes.\n *\n * @example\n *\n * ```js\n * import { useSelect, AsyncModeProvider } from '@wordpress/data';\n * import { store as blockEditorStore } from '@wordpress/block-editor';\n *\n * function BlockCount() {\n * const count = useSelect( ( select ) => {\n * return select( blockEditorStore ).getBlockCount()\n * }, [] );\n *\n * return count;\n * }\n *\n * function App() {\n * return (\n * <AsyncModeProvider value={ true }>\n * <BlockCount />\n * </AsyncModeProvider>\n * );\n * }\n * ```\n *\n * In this example, the BlockCount component is rerendered asynchronously.\n * It means if a more critical task is being performed (like typing in an input),\n * the rerendering is delayed until the browser becomes IDLE.\n * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior.\n *\n * @param {boolean} props.value Enable Async Mode.\n * @return {WPComponent} The component to be rendered.\n */\nexport default Provider;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,OAAO,GAAG,IAAAC,sBAAa,EAAE,KAAM,CAAC;AAACC,OAAA,CAAAF,OAAA,GAAAA,OAAA;AAE9C,MAAM;EAAEG,QAAQ;EAAEC;AAAS,CAAC,GAAGJ,OAAO;AAE/B,MAAMK,iBAAiB,GAAGF,QAAQ;;AAEzC;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;AAlCAD,OAAA,CAAAG,iBAAA,GAAAA,iBAAA;AAAA,IAAAC,QAAA,GAmCeF,QAAQ;AAAAF,OAAA,CAAAK,OAAA,GAAAD,QAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -23,12 +22,8 @@ Object.defineProperty(exports, "useAsyncMode", {
|
|
|
23
22
|
return _useAsyncMode.default;
|
|
24
23
|
}
|
|
25
24
|
});
|
|
26
|
-
|
|
27
25
|
var _useAsyncMode = _interopRequireDefault(require("./use-async-mode"));
|
|
28
|
-
|
|
29
26
|
var _context = _interopRequireWildcard(require("./context"));
|
|
30
|
-
|
|
31
27
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
|
-
|
|
33
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
34
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/components/async-mode-provider/index.js"],"
|
|
1
|
+
{"version":3,"names":["_useAsyncMode","_interopRequireDefault","require","_context","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"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,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,uBAAA,CAAAF,OAAA;AAA4E,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA"}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = useAsyncMode;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _context = require("./context");
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* WordPress dependencies
|
|
14
11
|
*/
|
|
@@ -16,6 +13,7 @@ var _context = require("./context");
|
|
|
16
13
|
/**
|
|
17
14
|
* Internal dependencies
|
|
18
15
|
*/
|
|
16
|
+
|
|
19
17
|
function useAsyncMode() {
|
|
20
18
|
return (0, _element.useContext)(_context.Context);
|
|
21
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/components/async-mode-provider/use-async-mode.js"],"
|
|
1
|
+
{"version":3,"names":["_element","require","_context","useAsyncMode","useContext","Context"],"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":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGe,SAASE,YAAYA,CAAA,EAAG;EACtC,OAAO,IAAAC,mBAAU,EAAEC,gBAAQ,CAAC;AAC7B"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.RegistryConsumer = exports.Context = void 0;
|
|
9
|
-
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
9
|
var _defaultRegistry = _interopRequireDefault(require("../../default-registry"));
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* WordPress dependencies
|
|
16
12
|
*/
|
|
@@ -18,12 +14,14 @@ var _defaultRegistry = _interopRequireDefault(require("../../default-registry"))
|
|
|
18
14
|
/**
|
|
19
15
|
* Internal dependencies
|
|
20
16
|
*/
|
|
17
|
+
|
|
21
18
|
const Context = (0, _element.createContext)(_defaultRegistry.default);
|
|
22
19
|
exports.Context = Context;
|
|
23
20
|
const {
|
|
24
21
|
Consumer,
|
|
25
22
|
Provider
|
|
26
23
|
} = Context;
|
|
24
|
+
|
|
27
25
|
/**
|
|
28
26
|
* A custom react Context consumer exposing the provided `registry` to
|
|
29
27
|
* children components. Used along with the RegistryProvider.
|
|
@@ -55,8 +53,8 @@ const {
|
|
|
55
53
|
* }
|
|
56
54
|
* ```
|
|
57
55
|
*/
|
|
58
|
-
|
|
59
56
|
const RegistryConsumer = Consumer;
|
|
57
|
+
|
|
60
58
|
/**
|
|
61
59
|
* A custom Context provider for exposing the provided `registry` to children
|
|
62
60
|
* components via a consumer.
|
|
@@ -64,7 +62,6 @@ const RegistryConsumer = Consumer;
|
|
|
64
62
|
* See <a name="#RegistryConsumer">RegistryConsumer</a> documentation for
|
|
65
63
|
* example.
|
|
66
64
|
*/
|
|
67
|
-
|
|
68
65
|
exports.RegistryConsumer = RegistryConsumer;
|
|
69
66
|
var _default = Provider;
|
|
70
67
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_defaultRegistry","_interopRequireDefault","Context","createContext","defaultRegistry","exports","Consumer","Provider","RegistryConsumer","_default","default"],"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 );\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://reactjs.org/docs/context.html#contextprovider\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":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGO,MAAMG,OAAO,GAAG,IAAAC,sBAAa,EAAEC,wBAAgB,CAAC;AAACC,OAAA,CAAAH,OAAA,GAAAA,OAAA;AAExD,MAAM;EAAEI,QAAQ;EAAEC;AAAS,CAAC,GAAGL,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;AACO,MAAMM,gBAAgB,GAAGF,QAAQ;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AANAD,OAAA,CAAAG,gBAAA,GAAAA,gBAAA;AAAA,IAAAC,QAAA,GAOeF,QAAQ;AAAAF,OAAA,CAAAK,OAAA,GAAAD,QAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -23,12 +22,8 @@ Object.defineProperty(exports, "useRegistry", {
|
|
|
23
22
|
return _useRegistry.default;
|
|
24
23
|
}
|
|
25
24
|
});
|
|
26
|
-
|
|
27
25
|
var _context = _interopRequireWildcard(require("./context"));
|
|
28
|
-
|
|
29
26
|
var _useRegistry = _interopRequireDefault(require("./use-registry"));
|
|
30
|
-
|
|
31
27
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
|
-
|
|
33
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
34
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/components/registry-provider/index.js"],"
|
|
1
|
+
{"version":3,"names":["_context","_interopRequireWildcard","require","_useRegistry","_interopRequireDefault","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"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,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAwD,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/components/registry-provider/use-registry.js"],"
|
|
1
|
+
{"version":3,"names":["_element","require","_context","useRegistry","useContext","Context"],"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":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;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;AACe,SAASE,WAAWA,CAAA,EAAG;EACrC,OAAO,IAAAC,mBAAU,EAAEC,gBAAQ,CAAC;AAC7B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -17,8 +16,6 @@ Object.defineProperty(exports, "useDispatchWithMap", {
|
|
|
17
16
|
return _useDispatchWithMap.default;
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
|
-
|
|
21
19
|
var _useDispatch = _interopRequireDefault(require("./use-dispatch"));
|
|
22
|
-
|
|
23
20
|
var _useDispatchWithMap = _interopRequireDefault(require("./use-dispatch-with-map"));
|
|
24
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/components/use-dispatch/index.js"],"
|
|
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"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
9
|
var _compose = require("@wordpress/compose");
|
|
13
|
-
|
|
14
10
|
var _useRegistry = _interopRequireDefault(require("../registry-provider/use-registry"));
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* WordPress dependencies
|
|
18
13
|
*/
|
|
@@ -48,12 +43,10 @@ const useDispatchWithMap = (dispatchMap, deps) => {
|
|
|
48
43
|
// eslint-disable-next-line no-console
|
|
49
44
|
console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`);
|
|
50
45
|
}
|
|
51
|
-
|
|
52
46
|
return [propName, (...args) => currentDispatchMap.current(registry.dispatch, registry)[propName](...args)];
|
|
53
47
|
}));
|
|
54
48
|
}, [registry, ...deps]);
|
|
55
49
|
};
|
|
56
|
-
|
|
57
50
|
var _default = useDispatchWithMap;
|
|
58
51
|
exports.default = _default;
|
|
59
52
|
//# sourceMappingURL=use-dispatch-with-map.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_useRegistry","_interopRequireDefault","useDispatchWithMap","dispatchMap","deps","registry","useRegistry","currentDispatchMap","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 currentDispatchMap = useRef( dispatchMap );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tcurrentDispatchMap.current = dispatchMap;\n\t} );\n\n\treturn useMemo( () => {\n\t\tconst currentDispatchProps = currentDispatchMap.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\tcurrentDispatchMap\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,kBAAkB,GAAG,IAAAC,eAAM,EAAEL,WAAY,CAAC;EAEhD,IAAAM,kCAAyB,EAAE,MAAM;IAChCF,kBAAkB,CAACG,OAAO,GAAGP,WAAW;EACzC,CAAE,CAAC;EAEH,OAAO,IAAAQ,gBAAO,EAAE,MAAM;IACrB,MAAMC,oBAAoB,GAAGL,kBAAkB,CAACG,OAAO,CACtDL,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,CACV,YAAYH,QAAU,sEACxB,CAAC;MACF;MACA,OAAO,CACNA,QAAQ,EACR,CAAE,GAAGI,IAAI,KACRf,kBAAkB,CAChBG,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,GAEarB,kBAAkB;AAAAsB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _useRegistry = _interopRequireDefault(require("../registry-provider/use-registry"));
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Internal dependencies
|
|
14
11
|
*/
|
|
@@ -17,7 +14,6 @@ var _useRegistry = _interopRequireDefault(require("../registry-provider/use-regi
|
|
|
17
14
|
* @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor
|
|
18
15
|
* @template {import('../../types').AnyConfig} StoreConfig
|
|
19
16
|
*/
|
|
20
|
-
|
|
21
17
|
/**
|
|
22
18
|
* @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn
|
|
23
19
|
* @template StoreNameOrDescriptor
|
|
@@ -75,7 +71,6 @@ const useDispatch = storeNameOrDescriptor => {
|
|
|
75
71
|
} = (0, _useRegistry.default)();
|
|
76
72
|
return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor);
|
|
77
73
|
};
|
|
78
|
-
|
|
79
74
|
var _default = useDispatch;
|
|
80
75
|
exports.default = _default;
|
|
81
76
|
//# sourceMappingURL=use-dispatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 { useDispatch, useSelect } from '@wordpress/data';\n * import { useCallback } from '@wordpress/element';\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,GAEaJ,WAAW;AAAAK,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|