@wordpress/core-data 7.32.0 → 7.32.1-next.ff1cebbba.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/build/actions.js +375 -632
- package/build/actions.js.map +7 -1
- package/build/batch/create-batch.js +49 -62
- package/build/batch/create-batch.js.map +7 -1
- package/build/batch/default-processor.js +43 -39
- package/build/batch/default-processor.js.map +7 -1
- package/build/batch/index.js +38 -17
- package/build/batch/index.js.map +7 -1
- package/build/dynamic-entities.js +30 -32
- package/build/dynamic-entities.js.map +7 -1
- package/build/entities.js +298 -410
- package/build/entities.js.map +7 -1
- package/build/entity-context.js +29 -12
- package/build/entity-context.js.map +7 -1
- package/build/entity-provider.js +38 -46
- package/build/entity-provider.js.map +7 -1
- package/build/entity-types/attachment.js +16 -5
- package/build/entity-types/attachment.js.map +7 -1
- package/build/entity-types/base-entity-records.js +16 -42
- package/build/entity-types/base-entity-records.js.map +7 -1
- package/build/entity-types/base.js +16 -5
- package/build/entity-types/base.js.map +7 -1
- package/build/entity-types/comment.js +16 -5
- package/build/entity-types/comment.js.map +7 -1
- package/build/entity-types/global-styles-revision.js +16 -5
- package/build/entity-types/global-styles-revision.js.map +7 -1
- package/build/entity-types/helpers.js +16 -5
- package/build/entity-types/helpers.js.map +7 -1
- package/build/entity-types/index.js +16 -5
- package/build/entity-types/index.js.map +7 -1
- package/build/entity-types/menu-location.js +16 -5
- package/build/entity-types/menu-location.js.map +7 -1
- package/build/entity-types/nav-menu-item.js +16 -5
- package/build/entity-types/nav-menu-item.js.map +7 -1
- package/build/entity-types/nav-menu.js +16 -5
- package/build/entity-types/nav-menu.js.map +7 -1
- package/build/entity-types/page.js +16 -5
- package/build/entity-types/page.js.map +7 -1
- package/build/entity-types/plugin.js +16 -5
- package/build/entity-types/plugin.js.map +7 -1
- package/build/entity-types/post-revision.js +16 -5
- package/build/entity-types/post-revision.js.map +7 -1
- package/build/entity-types/post-status.js +16 -5
- package/build/entity-types/post-status.js.map +7 -1
- package/build/entity-types/post.js +16 -5
- package/build/entity-types/post.js.map +7 -1
- package/build/entity-types/settings.js +16 -5
- package/build/entity-types/settings.js.map +7 -1
- package/build/entity-types/sidebar.js +16 -5
- package/build/entity-types/sidebar.js.map +7 -1
- package/build/entity-types/taxonomy.js +16 -5
- package/build/entity-types/taxonomy.js.map +7 -1
- package/build/entity-types/term.js +16 -5
- package/build/entity-types/term.js.map +7 -1
- package/build/entity-types/theme.js +16 -5
- package/build/entity-types/theme.js.map +7 -1
- package/build/entity-types/type.js +16 -5
- package/build/entity-types/type.js.map +7 -1
- package/build/entity-types/user.js +16 -5
- package/build/entity-types/user.js.map +7 -1
- package/build/entity-types/widget-type.js +16 -5
- package/build/entity-types/widget-type.js.map +7 -1
- package/build/entity-types/widget.js +16 -5
- package/build/entity-types/widget.js.map +7 -1
- package/build/entity-types/wp-template-part.js +16 -5
- package/build/entity-types/wp-template-part.js.map +7 -1
- package/build/entity-types/wp-template.js +16 -5
- package/build/entity-types/wp-template.js.map +7 -1
- package/build/fetch/__experimental-fetch-link-suggestions.js +141 -154
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
- package/build/fetch/__experimental-fetch-url-data.js +47 -59
- package/build/fetch/__experimental-fetch-url-data.js.map +7 -1
- package/build/fetch/index.js +53 -32
- package/build/fetch/index.js.map +7 -1
- package/build/footnotes/get-footnotes-order.js +38 -25
- package/build/footnotes/get-footnotes-order.js.map +7 -1
- package/build/footnotes/get-rich-text-values-cached.js +26 -27
- package/build/footnotes/get-rich-text-values-cached.js.map +7 -1
- package/build/footnotes/index.js +68 -55
- package/build/footnotes/index.js.map +7 -1
- package/build/hooks/constants.js +33 -12
- package/build/hooks/constants.js.map +7 -1
- package/build/hooks/index.js +59 -68
- package/build/hooks/index.js.map +7 -1
- package/build/hooks/memoize.js +34 -12
- package/build/hooks/memoize.js.map +7 -1
- package/build/hooks/use-entity-block-editor.js +111 -119
- package/build/hooks/use-entity-block-editor.js.map +7 -1
- package/build/hooks/use-entity-id.js +25 -23
- package/build/hooks/use-entity-id.js.map +7 -1
- package/build/hooks/use-entity-prop.js +59 -60
- package/build/hooks/use-entity-prop.js.map +7 -1
- package/build/hooks/use-entity-record.js +95 -155
- package/build/hooks/use-entity-record.js.map +7 -1
- package/build/hooks/use-entity-records.js +131 -139
- package/build/hooks/use-entity-records.js.map +7 -1
- package/build/hooks/use-query-select.js +65 -84
- package/build/hooks/use-query-select.js.map +7 -1
- package/build/hooks/use-resource-permissions.js +92 -145
- package/build/hooks/use-resource-permissions.js.map +7 -1
- package/build/index.js +96 -153
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -14
- package/build/lock-unlock.js.map +7 -1
- package/build/locks/actions.js +36 -19
- package/build/locks/actions.js.map +7 -1
- package/build/locks/engine.js +48 -47
- package/build/locks/engine.js.map +7 -1
- package/build/locks/reducer.js +54 -63
- package/build/locks/reducer.js.map +7 -1
- package/build/locks/selectors.js +35 -30
- package/build/locks/selectors.js.map +7 -1
- package/build/locks/utils.js +37 -16
- package/build/locks/utils.js.map +7 -1
- package/build/name.js +27 -12
- package/build/name.js.map +7 -1
- package/build/private-actions.js +67 -75
- package/build/private-actions.js.map +7 -1
- package/build/private-apis.js +33 -16
- package/build/private-apis.js.map +7 -1
- package/build/private-selectors.js +204 -184
- package/build/private-selectors.js.map +7 -1
- package/build/queried-data/actions.js +32 -41
- package/build/queried-data/actions.js.map +7 -1
- package/build/queried-data/get-query-parts.js +41 -79
- package/build/queried-data/get-query-parts.js.map +7 -1
- package/build/queried-data/index.js +39 -36
- package/build/queried-data/index.js.map +7 -1
- package/build/queried-data/reducer.js +162 -193
- package/build/queried-data/reducer.js.map +7 -1
- package/build/queried-data/selectors.js +57 -85
- package/build/queried-data/selectors.js.map +7 -1
- package/build/reducer.js +279 -404
- package/build/reducer.js.map +7 -1
- package/build/resolvers.js +553 -600
- package/build/resolvers.js.map +7 -1
- package/build/selectors.js +456 -981
- package/build/selectors.js.map +7 -1
- package/build/sync.js +34 -22
- package/build/sync.js.map +7 -1
- package/build/types.js +16 -5
- package/build/types.js.map +7 -1
- package/build/utils/conservative-map-item.js +34 -27
- package/build/utils/conservative-map-item.js.map +7 -1
- package/build/utils/crdt-blocks.js +289 -0
- package/build/utils/crdt-blocks.js.map +7 -0
- package/build/utils/crdt.js +202 -0
- package/build/utils/crdt.js.map +7 -0
- package/build/utils/forward-resolver.js +24 -16
- package/build/utils/forward-resolver.js.map +7 -1
- package/build/utils/get-nested-value.js +26 -21
- package/build/utils/get-nested-value.js.map +7 -1
- package/build/utils/get-normalized-comma-separable.js +25 -17
- package/build/utils/get-normalized-comma-separable.js.map +7 -1
- package/build/utils/if-matching-action.js +25 -19
- package/build/utils/if-matching-action.js.map +7 -1
- package/build/utils/index.js +77 -108
- package/build/utils/index.js.map +7 -1
- package/build/utils/is-numeric-id.js +22 -12
- package/build/utils/is-numeric-id.js.map +7 -1
- package/build/utils/is-raw-attribute.js +22 -13
- package/build/utils/is-raw-attribute.js.map +7 -1
- package/build/utils/log-entity-deprecation.js +37 -38
- package/build/utils/log-entity-deprecation.js.map +7 -1
- package/build/utils/on-sub-key.js +30 -24
- package/build/utils/on-sub-key.js.map +7 -1
- package/build/utils/receive-intermediate-results.js +29 -6
- package/build/utils/receive-intermediate-results.js.map +7 -1
- package/build/utils/replace-action.js +24 -17
- package/build/utils/replace-action.js.map +7 -1
- package/build/utils/set-nested-value.js +25 -30
- package/build/utils/set-nested-value.js.map +7 -1
- package/build/utils/user-permissions.js +41 -13
- package/build/utils/user-permissions.js.map +7 -1
- package/build/utils/with-weak-map-cache.js +26 -22
- package/build/utils/with-weak-map-cache.js.map +7 -1
- package/build-module/actions.js +322 -601
- package/build-module/actions.js.map +7 -1
- package/build-module/batch/create-batch.js +21 -57
- package/build-module/batch/create-batch.js.map +7 -1
- package/build-module/batch/default-processor.js +14 -33
- package/build-module/batch/default-processor.js.map +7 -1
- package/build-module/batch/index.js +7 -3
- package/build-module/batch/index.js.map +7 -1
- package/build-module/dynamic-entities.js +7 -28
- package/build-module/dynamic-entities.js.map +7 -1
- package/build-module/entities.js +263 -399
- package/build-module/entities.js.map +7 -1
- package/build-module/entity-context.js +7 -7
- package/build-module/entity-context.js.map +7 -1
- package/build-module/entity-provider.js +19 -42
- package/build-module/entity-provider.js.map +7 -1
- package/build-module/entity-types/attachment.js +1 -2
- package/build-module/entity-types/attachment.js.map +7 -1
- package/build-module/entity-types/base-entity-records.js +1 -37
- package/build-module/entity-types/base-entity-records.js.map +7 -1
- package/build-module/entity-types/base.js +1 -2
- package/build-module/entity-types/base.js.map +7 -1
- package/build-module/entity-types/comment.js +1 -2
- package/build-module/entity-types/comment.js.map +7 -1
- package/build-module/entity-types/global-styles-revision.js +1 -2
- package/build-module/entity-types/global-styles-revision.js.map +7 -1
- package/build-module/entity-types/helpers.js +1 -2
- package/build-module/entity-types/helpers.js.map +7 -1
- package/build-module/entity-types/index.js +1 -2
- package/build-module/entity-types/index.js.map +7 -1
- package/build-module/entity-types/menu-location.js +1 -2
- package/build-module/entity-types/menu-location.js.map +7 -1
- package/build-module/entity-types/nav-menu-item.js +1 -2
- package/build-module/entity-types/nav-menu-item.js.map +7 -1
- package/build-module/entity-types/nav-menu.js +1 -2
- package/build-module/entity-types/nav-menu.js.map +7 -1
- package/build-module/entity-types/page.js +1 -2
- package/build-module/entity-types/page.js.map +7 -1
- package/build-module/entity-types/plugin.js +1 -2
- package/build-module/entity-types/plugin.js.map +7 -1
- package/build-module/entity-types/post-revision.js +1 -2
- package/build-module/entity-types/post-revision.js.map +7 -1
- package/build-module/entity-types/post-status.js +1 -2
- package/build-module/entity-types/post-status.js.map +7 -1
- package/build-module/entity-types/post.js +1 -2
- package/build-module/entity-types/post.js.map +7 -1
- package/build-module/entity-types/settings.js +1 -2
- package/build-module/entity-types/settings.js.map +7 -1
- package/build-module/entity-types/sidebar.js +1 -2
- package/build-module/entity-types/sidebar.js.map +7 -1
- package/build-module/entity-types/taxonomy.js +1 -2
- package/build-module/entity-types/taxonomy.js.map +7 -1
- package/build-module/entity-types/term.js +1 -2
- package/build-module/entity-types/term.js.map +7 -1
- package/build-module/entity-types/theme.js +1 -2
- package/build-module/entity-types/theme.js.map +7 -1
- package/build-module/entity-types/type.js +1 -2
- package/build-module/entity-types/type.js.map +7 -1
- package/build-module/entity-types/user.js +1 -2
- package/build-module/entity-types/user.js.map +7 -1
- package/build-module/entity-types/widget-type.js +1 -2
- package/build-module/entity-types/widget-type.js.map +7 -1
- package/build-module/entity-types/widget.js +1 -2
- package/build-module/entity-types/widget.js.map +7 -1
- package/build-module/entity-types/wp-template-part.js +1 -2
- package/build-module/entity-types/wp-template-part.js.map +7 -1
- package/build-module/entity-types/wp-template.js +1 -2
- package/build-module/entity-types/wp-template.js.map +7 -1
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +111 -149
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +20 -49
- package/build-module/fetch/__experimental-fetch-url-data.js.map +7 -1
- package/build-module/fetch/index.js +20 -15
- package/build-module/fetch/index.js.map +7 -1
- package/build-module/footnotes/get-footnotes-order.js +10 -19
- package/build-module/footnotes/get-footnotes-order.js.map +7 -1
- package/build-module/footnotes/get-rich-text-values-cached.js +8 -23
- package/build-module/footnotes/get-rich-text-values-cached.js.map +7 -1
- package/build-module/footnotes/index.js +34 -47
- package/build-module/footnotes/index.js.map +7 -1
- package/build-module/hooks/constants.js +11 -8
- package/build-module/hooks/constants.js.map +7 -1
- package/build-module/hooks/index.js +27 -15
- package/build-module/hooks/index.js.map +7 -1
- package/build-module/hooks/memoize.js +6 -8
- package/build-module/hooks/memoize.js.map +7 -1
- package/build-module/hooks/use-entity-block-editor.js +80 -110
- package/build-module/hooks/use-entity-block-editor.js.map +7 -1
- package/build-module/hooks/use-entity-id.js +7 -19
- package/build-module/hooks/use-entity-id.js.map +7 -1
- package/build-module/hooks/use-entity-prop.js +31 -55
- package/build-module/hooks/use-entity-prop.js.map +7 -1
- package/build-module/hooks/use-entity-record.js +63 -148
- package/build-module/hooks/use-entity-record.js.map +7 -1
- package/build-module/hooks/use-entity-records.js +98 -131
- package/build-module/hooks/use-entity-records.js.map +7 -1
- package/build-module/hooks/use-query-select.js +27 -71
- package/build-module/hooks/use-query-select.js.map +7 -1
- package/build-module/hooks/use-resource-permissions.js +57 -136
- package/build-module/hooks/use-resource-permissions.js.map +7 -1
- package/build-module/index.js +49 -71
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/locks/actions.js +8 -13
- package/build-module/locks/actions.js.map +7 -1
- package/build-module/locks/engine.js +17 -38
- package/build-module/locks/engine.js.map +7 -1
- package/build-module/locks/reducer.js +37 -59
- package/build-module/locks/reducer.js.map +7 -1
- package/build-module/locks/selectors.js +16 -23
- package/build-module/locks/selectors.js.map +7 -1
- package/build-module/locks/utils.js +15 -12
- package/build-module/locks/utils.js.map +7 -1
- package/build-module/name.js +5 -8
- package/build-module/name.js.map +7 -1
- package/build-module/private-actions.js +35 -69
- package/build-module/private-actions.js.map +7 -1
- package/build-module/private-apis.js +8 -8
- package/build-module/private-apis.js.map +7 -1
- package/build-module/private-selectors.js +167 -174
- package/build-module/private-selectors.js.map +7 -1
- package/build-module/queried-data/actions.js +11 -38
- package/build-module/queried-data/actions.js.map +7 -1
- package/build-module/queried-data/get-query-parts.js +20 -75
- package/build-module/queried-data/get-query-parts.js.map +7 -1
- package/build-module/queried-data/index.js +7 -4
- package/build-module/queried-data/index.js.map +7 -1
- package/build-module/queried-data/reducer.js +134 -185
- package/build-module/queried-data/reducer.js.map +7 -1
- package/build-module/queried-data/selectors.js +23 -78
- package/build-module/queried-data/selectors.js.map +7 -1
- package/build-module/reducer.js +243 -393
- package/build-module/reducer.js.map +7 -1
- package/build-module/resolvers.js +478 -549
- package/build-module/resolvers.js.map +7 -1
- package/build-module/selectors.js +410 -953
- package/build-module/selectors.js.map +7 -1
- package/build-module/sync.js +14 -17
- package/build-module/sync.js.map +7 -1
- package/build-module/types.js +1 -2
- package/build-module/types.js.map +7 -1
- package/build-module/utils/conservative-map-item.js +6 -22
- package/build-module/utils/conservative-map-item.js.map +7 -1
- package/build-module/utils/crdt-blocks.js +255 -0
- package/build-module/utils/crdt-blocks.js.map +7 -0
- package/build-module/utils/crdt.js +167 -0
- package/build-module/utils/crdt.js.map +7 -0
- package/build-module/utils/forward-resolver.js +6 -12
- package/build-module/utils/forward-resolver.js.map +7 -1
- package/build-module/utils/get-nested-value.js +9 -18
- package/build-module/utils/get-nested-value.js.map +7 -1
- package/build-module/utils/get-normalized-comma-separable.js +7 -13
- package/build-module/utils/get-normalized-comma-separable.js.map +7 -1
- package/build-module/utils/if-matching-action.js +7 -15
- package/build-module/utils/if-matching-action.js.map +7 -1
- package/build-module/utils/index.js +35 -14
- package/build-module/utils/index.js.map +7 -1
- package/build-module/utils/is-numeric-id.js +5 -9
- package/build-module/utils/is-numeric-id.js.map +7 -1
- package/build-module/utils/is-raw-attribute.js +5 -10
- package/build-module/utils/is-raw-attribute.js.map +7 -1
- package/build-module/utils/log-entity-deprecation.js +8 -31
- package/build-module/utils/log-entity-deprecation.js.map +7 -1
- package/build-module/utils/on-sub-key.js +8 -19
- package/build-module/utils/on-sub-key.js.map +7 -1
- package/build-module/utils/receive-intermediate-results.js +7 -2
- package/build-module/utils/receive-intermediate-results.js.map +7 -1
- package/build-module/utils/replace-action.js +6 -13
- package/build-module/utils/replace-action.js.map +7 -1
- package/build-module/utils/set-nested-value.js +8 -27
- package/build-module/utils/set-nested-value.js.map +7 -1
- package/build-module/utils/user-permissions.js +19 -9
- package/build-module/utils/user-permissions.js.map +7 -1
- package/build-module/utils/with-weak-map-cache.js +8 -18
- package/build-module/utils/with-weak-map-cache.js.map +7 -1
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/entities.d.ts +0 -56
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +3 -0
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/sync.d.ts +6 -1
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/types.d.ts +9 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts +30 -0
- package/build-types/utils/crdt-blocks.d.ts.map +1 -0
- package/build-types/utils/crdt.d.ts +49 -0
- package/build-types/utils/crdt.d.ts.map +1 -0
- package/package.json +26 -19
- package/src/actions.js +56 -74
- package/src/entities.js +59 -113
- package/src/private-selectors.ts +32 -7
- package/src/resolvers.js +173 -120
- package/src/selectors.ts +0 -13
- package/src/sync.ts +12 -0
- package/src/test/resolvers.js +183 -0
- package/src/types.ts +12 -0
- package/src/utils/crdt-blocks.ts +503 -0
- package/src/utils/crdt.ts +310 -0
- package/src/utils/test/crdt-blocks.ts +375 -0
- package/src/utils/test/crdt.ts +254 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/sync.js +0 -27
|
@@ -1,65 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
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_entity_prop_exports = {};
|
|
30
|
+
__export(use_entity_prop_exports, {
|
|
31
|
+
default: () => useEntityProp
|
|
6
32
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Hook that returns the value and a setter for the
|
|
22
|
-
* specified property of the nearest provided
|
|
23
|
-
* entity of the specified type.
|
|
24
|
-
*
|
|
25
|
-
* @param {string} kind The entity kind.
|
|
26
|
-
* @param {string} name The entity name.
|
|
27
|
-
* @param {string} prop The property name.
|
|
28
|
-
* @param {number|string} [_id] An entity ID to use instead of the context-provided one.
|
|
29
|
-
*
|
|
30
|
-
* @return {[*, Function, *]} An array where the first item is the
|
|
31
|
-
* property value, the second is the
|
|
32
|
-
* setter and the third is the full value
|
|
33
|
-
* object from REST API containing more
|
|
34
|
-
* information like `raw`, `rendered` and
|
|
35
|
-
* `protected` props.
|
|
36
|
-
*/
|
|
33
|
+
module.exports = __toCommonJS(use_entity_prop_exports);
|
|
34
|
+
var import_element = require("@wordpress/element");
|
|
35
|
+
var import_data = require("@wordpress/data");
|
|
36
|
+
var import_name = require("../name");
|
|
37
|
+
var import_use_entity_id = __toESM(require("./use-entity-id"));
|
|
37
38
|
function useEntityProp(kind, name, prop, _id) {
|
|
38
|
-
const providerId = (0,
|
|
39
|
-
const id = _id
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
editEntityRecord
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
}, [editEntityRecord, kind, name, id, prop]);
|
|
39
|
+
const providerId = (0, import_use_entity_id.default)(kind, name);
|
|
40
|
+
const id = _id ?? providerId;
|
|
41
|
+
const { value, fullValue } = (0, import_data.useSelect)(
|
|
42
|
+
(select) => {
|
|
43
|
+
const { getEntityRecord, getEditedEntityRecord } = select(import_name.STORE_NAME);
|
|
44
|
+
const record = getEntityRecord(kind, name, id);
|
|
45
|
+
const editedRecord = getEditedEntityRecord(kind, name, id);
|
|
46
|
+
return record && editedRecord ? {
|
|
47
|
+
value: editedRecord[prop],
|
|
48
|
+
fullValue: record[prop]
|
|
49
|
+
} : {};
|
|
50
|
+
},
|
|
51
|
+
[kind, name, id, prop]
|
|
52
|
+
);
|
|
53
|
+
const { editEntityRecord } = (0, import_data.useDispatch)(import_name.STORE_NAME);
|
|
54
|
+
const setValue = (0, import_element.useCallback)(
|
|
55
|
+
(newValue) => {
|
|
56
|
+
editEntityRecord(kind, name, id, {
|
|
57
|
+
[prop]: newValue
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
[editEntityRecord, kind, name, id, prop]
|
|
61
|
+
);
|
|
63
62
|
return [value, setValue, fullValue];
|
|
64
63
|
}
|
|
65
|
-
//# sourceMappingURL=use-entity-prop.js.map
|
|
64
|
+
//# sourceMappingURL=use-entity-prop.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/use-entity-prop.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from '../name';\nimport useEntityId from './use-entity-id';\n\n/**\n * Hook that returns the value and a setter for the\n * specified property of the nearest provided\n * entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {string} prop The property name.\n * @param {number|string} [_id] An entity ID to use instead of the context-provided one.\n *\n * @return {[*, Function, *]} An array where the first item is the\n * property value, the second is the\n * setter and the third is the full value\n * \t\t\t\t\t\t\t object from REST API containing more\n * \t\t\t\t\t\t\t information like `raw`, `rendered` and\n * \t\t\t\t\t\t\t `protected` props.\n */\nexport default function useEntityProp( kind, name, prop, _id ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\n\tconst { value, fullValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEditedEntityRecord } =\n\t\t\t\tselect( STORE_NAME );\n\t\t\tconst record = getEntityRecord( kind, name, id ); // Trigger resolver.\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn record && editedRecord\n\t\t\t\t? {\n\t\t\t\t\t\tvalue: editedRecord[ prop ],\n\t\t\t\t\t\tfullValue: record[ prop ],\n\t\t\t\t }\n\t\t\t\t: {};\n\t\t},\n\t\t[ kind, name, id, prop ]\n\t);\n\tconst { editEntityRecord } = useDispatch( STORE_NAME );\n\tconst setValue = useCallback(\n\t\t( newValue ) => {\n\t\t\teditEntityRecord( kind, name, id, {\n\t\t\t\t[ prop ]: newValue,\n\t\t\t} );\n\t\t},\n\t\t[ editEntityRecord, kind, name, id, prop ]\n\t);\n\n\treturn [ value, setValue, fullValue ];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,kBAAuC;AAKvC,kBAA2B;AAC3B,2BAAwB;AAmBT,SAAR,cAAgC,MAAM,MAAM,MAAM,KAAM;AAC9D,QAAM,iBAAa,qBAAAA,SAAa,MAAM,IAAK;AAC3C,QAAM,KAAK,OAAO;AAElB,QAAM,EAAE,OAAO,UAAU,QAAI;AAAA,IAC5B,CAAE,WAAY;AACb,YAAM,EAAE,iBAAiB,sBAAsB,IAC9C,OAAQ,sBAAW;AACpB,YAAM,SAAS,gBAAiB,MAAM,MAAM,EAAG;AAC/C,YAAM,eAAe,sBAAuB,MAAM,MAAM,EAAG;AAC3D,aAAO,UAAU,eACd;AAAA,QACA,OAAO,aAAc,IAAK;AAAA,QAC1B,WAAW,OAAQ,IAAK;AAAA,MACxB,IACA,CAAC;AAAA,IACL;AAAA,IACA,CAAE,MAAM,MAAM,IAAI,IAAK;AAAA,EACxB;AACA,QAAM,EAAE,iBAAiB,QAAI,yBAAa,sBAAW;AACrD,QAAM,eAAW;AAAA,IAChB,CAAE,aAAc;AACf,uBAAkB,MAAM,MAAM,IAAI;AAAA,QACjC,CAAE,IAAK,GAAG;AAAA,MACX,CAAE;AAAA,IACH;AAAA,IACA,CAAE,kBAAkB,MAAM,MAAM,IAAI,IAAK;AAAA,EAC1C;AAEA,SAAO,CAAE,OAAO,UAAU,SAAU;AACrC;",
|
|
6
|
+
"names": ["useEntityId"]
|
|
7
|
+
}
|
|
@@ -1,159 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
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_entity_record_exports = {};
|
|
30
|
+
__export(use_entity_record_exports, {
|
|
31
|
+
__experimentalUseEntityRecord: () => __experimentalUseEntityRecord,
|
|
32
|
+
default: () => useEntityRecord
|
|
6
33
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var _ = require("../");
|
|
14
|
-
/**
|
|
15
|
-
* WordPress dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Internal dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
34
|
+
module.exports = __toCommonJS(use_entity_record_exports);
|
|
35
|
+
var import_data = require("@wordpress/data");
|
|
36
|
+
var import_deprecated = __toESM(require("@wordpress/deprecated"));
|
|
37
|
+
var import_element = require("@wordpress/element");
|
|
38
|
+
var import_use_query_select = __toESM(require("./use-query-select"));
|
|
39
|
+
var import__ = require("../");
|
|
22
40
|
const EMPTY_OBJECT = {};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* return record.title;
|
|
45
|
-
* }
|
|
46
|
-
*
|
|
47
|
-
* // Rendered in the application:
|
|
48
|
-
* // <PageTitleDisplay id={ 1 } />
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* In the above example, when `PageTitleDisplay` is rendered into an
|
|
52
|
-
* application, the page and the resolution details will be retrieved from
|
|
53
|
-
* the store state using `getEntityRecord()`, or resolved if missing.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```js
|
|
57
|
-
* import { useCallback } from 'react';
|
|
58
|
-
* import { useDispatch } from '@wordpress/data';
|
|
59
|
-
* import { __ } from '@wordpress/i18n';
|
|
60
|
-
* import { TextControl } from '@wordpress/components';
|
|
61
|
-
* import { store as noticeStore } from '@wordpress/notices';
|
|
62
|
-
* import { useEntityRecord } from '@wordpress/core-data';
|
|
63
|
-
*
|
|
64
|
-
* function PageRenameForm( { id } ) {
|
|
65
|
-
* const page = useEntityRecord( 'postType', 'page', id );
|
|
66
|
-
* const { createSuccessNotice, createErrorNotice } =
|
|
67
|
-
* useDispatch( noticeStore );
|
|
68
|
-
*
|
|
69
|
-
* const setTitle = useCallback( ( title ) => {
|
|
70
|
-
* page.edit( { title } );
|
|
71
|
-
* }, [ page.edit ] );
|
|
72
|
-
*
|
|
73
|
-
* if ( page.isResolving ) {
|
|
74
|
-
* return 'Loading...';
|
|
75
|
-
* }
|
|
76
|
-
*
|
|
77
|
-
* async function onRename( event ) {
|
|
78
|
-
* event.preventDefault();
|
|
79
|
-
* try {
|
|
80
|
-
* await page.save();
|
|
81
|
-
* createSuccessNotice( __( 'Page renamed.' ), {
|
|
82
|
-
* type: 'snackbar',
|
|
83
|
-
* } );
|
|
84
|
-
* } catch ( error ) {
|
|
85
|
-
* createErrorNotice( error.message, { type: 'snackbar' } );
|
|
86
|
-
* }
|
|
87
|
-
* }
|
|
88
|
-
*
|
|
89
|
-
* return (
|
|
90
|
-
* <form onSubmit={ onRename }>
|
|
91
|
-
* <TextControl
|
|
92
|
-
* __nextHasNoMarginBottom
|
|
93
|
-
* __next40pxDefaultSize
|
|
94
|
-
* label={ __( 'Name' ) }
|
|
95
|
-
* value={ page.editedRecord.title }
|
|
96
|
-
* onChange={ setTitle }
|
|
97
|
-
* />
|
|
98
|
-
* <button type="submit">{ __( 'Save' ) }</button>
|
|
99
|
-
* </form>
|
|
100
|
-
* );
|
|
101
|
-
* }
|
|
102
|
-
*
|
|
103
|
-
* // Rendered in the application:
|
|
104
|
-
* // <PageRenameForm id={ 1 } />
|
|
105
|
-
* ```
|
|
106
|
-
*
|
|
107
|
-
* In the above example, updating and saving the page title is handled
|
|
108
|
-
* via the `edit()` and `save()` mutation helpers provided by
|
|
109
|
-
* `useEntityRecord()`;
|
|
110
|
-
*
|
|
111
|
-
* @return Entity record data.
|
|
112
|
-
* @template RecordType
|
|
113
|
-
*/
|
|
114
|
-
function useEntityRecord(kind, name, recordId, options = {
|
|
115
|
-
enabled: true
|
|
116
|
-
}) {
|
|
117
|
-
const {
|
|
118
|
-
editEntityRecord,
|
|
119
|
-
saveEditedEntityRecord
|
|
120
|
-
} = (0, _data.useDispatch)(_.store);
|
|
121
|
-
const mutations = (0, _element.useMemo)(() => ({
|
|
122
|
-
edit: (record, editOptions = {}) => editEntityRecord(kind, name, recordId, record, editOptions),
|
|
123
|
-
save: (saveOptions = {}) => saveEditedEntityRecord(kind, name, recordId, {
|
|
124
|
-
throwOnError: true,
|
|
125
|
-
...saveOptions
|
|
126
|
-
})
|
|
127
|
-
}), [editEntityRecord, kind, name, recordId, saveEditedEntityRecord]);
|
|
128
|
-
const {
|
|
129
|
-
editedRecord,
|
|
130
|
-
hasEdits,
|
|
131
|
-
edits
|
|
132
|
-
} = (0, _data.useSelect)(select => {
|
|
133
|
-
if (!options.enabled) {
|
|
41
|
+
function useEntityRecord(kind, name, recordId, options = { enabled: true }) {
|
|
42
|
+
const { editEntityRecord, saveEditedEntityRecord } = (0, import_data.useDispatch)(import__.store);
|
|
43
|
+
const mutations = (0, import_element.useMemo)(
|
|
44
|
+
() => ({
|
|
45
|
+
edit: (record2, editOptions = {}) => editEntityRecord(kind, name, recordId, record2, editOptions),
|
|
46
|
+
save: (saveOptions = {}) => saveEditedEntityRecord(kind, name, recordId, {
|
|
47
|
+
throwOnError: true,
|
|
48
|
+
...saveOptions
|
|
49
|
+
})
|
|
50
|
+
}),
|
|
51
|
+
[editEntityRecord, kind, name, recordId, saveEditedEntityRecord]
|
|
52
|
+
);
|
|
53
|
+
const { editedRecord, hasEdits, edits } = (0, import_data.useSelect)(
|
|
54
|
+
(select) => {
|
|
55
|
+
if (!options.enabled) {
|
|
56
|
+
return {
|
|
57
|
+
editedRecord: EMPTY_OBJECT,
|
|
58
|
+
hasEdits: false,
|
|
59
|
+
edits: EMPTY_OBJECT
|
|
60
|
+
};
|
|
61
|
+
}
|
|
134
62
|
return {
|
|
135
|
-
editedRecord:
|
|
136
|
-
|
|
137
|
-
|
|
63
|
+
editedRecord: select(import__.store).getEditedEntityRecord(
|
|
64
|
+
kind,
|
|
65
|
+
name,
|
|
66
|
+
recordId
|
|
67
|
+
),
|
|
68
|
+
hasEdits: select(import__.store).hasEditsForEntityRecord(
|
|
69
|
+
kind,
|
|
70
|
+
name,
|
|
71
|
+
recordId
|
|
72
|
+
),
|
|
73
|
+
edits: select(import__.store).getEntityRecordNonTransientEdits(
|
|
74
|
+
kind,
|
|
75
|
+
name,
|
|
76
|
+
recordId
|
|
77
|
+
)
|
|
138
78
|
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
return query(_.store).getEntityRecord(kind, name, recordId);
|
|
156
|
-
}, [kind, name, recordId, options.enabled]);
|
|
79
|
+
},
|
|
80
|
+
[kind, name, recordId, options.enabled]
|
|
81
|
+
);
|
|
82
|
+
const { data: record, ...querySelectRest } = (0, import_use_query_select.default)(
|
|
83
|
+
(query) => {
|
|
84
|
+
if (!options.enabled) {
|
|
85
|
+
return {
|
|
86
|
+
data: null
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return query(import__.store).getEntityRecord(kind, name, recordId);
|
|
90
|
+
},
|
|
91
|
+
[kind, name, recordId, options.enabled]
|
|
92
|
+
);
|
|
157
93
|
return {
|
|
158
94
|
record,
|
|
159
95
|
editedRecord,
|
|
@@ -164,10 +100,14 @@ function useEntityRecord(kind, name, recordId, options = {
|
|
|
164
100
|
};
|
|
165
101
|
}
|
|
166
102
|
function __experimentalUseEntityRecord(kind, name, recordId, options) {
|
|
167
|
-
(0,
|
|
168
|
-
alternative:
|
|
169
|
-
since:
|
|
103
|
+
(0, import_deprecated.default)(`wp.data.__experimentalUseEntityRecord`, {
|
|
104
|
+
alternative: "wp.data.useEntityRecord",
|
|
105
|
+
since: "6.1"
|
|
170
106
|
});
|
|
171
107
|
return useEntityRecord(kind, name, recordId, options);
|
|
172
108
|
}
|
|
173
|
-
|
|
109
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
__experimentalUseEntityRecord
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=use-entity-record.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/use-entity-record.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useQuerySelect from './use-query-select';\nimport { store as coreStore } from '../';\nimport type { Status } from './constants';\n\nexport interface EntityRecordResolution< RecordType > {\n\t/** The requested entity record */\n\trecord: RecordType | null;\n\n\t/** The edited entity record */\n\teditedRecord: Partial< RecordType >;\n\n\t/** The edits to the edited entity record */\n\tedits: Partial< RecordType >;\n\n\t/** Apply local (in-browser) edits to the edited entity record */\n\tedit: ( diff: Partial< RecordType > ) => void;\n\n\t/** Persist the edits to the server */\n\tsave: () => Promise< void >;\n\n\t/**\n\t * Is the record still being resolved?\n\t */\n\tisResolving: boolean;\n\n\t/**\n\t * Does the record have any local edits?\n\t */\n\thasEdits: boolean;\n\n\t/**\n\t * Is the record resolved by now?\n\t */\n\thasResolved: boolean;\n\n\t/** Resolution status */\n\tstatus: Status;\n}\n\nexport interface Options {\n\t/**\n\t * Whether to run the query or short-circuit and return null.\n\t *\n\t * @default true\n\t */\n\tenabled: boolean;\n}\n\nconst EMPTY_OBJECT = {};\n\n/**\n * Resolves the specified entity record.\n *\n * @since 6.1.0 Introduced in WordPress core.\n *\n * @param kind Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.\n * @param name Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.\n * @param recordId ID of the requested entity record.\n * @param options Optional hook options.\n * @example\n * ```js\n * import { useEntityRecord } from '@wordpress/core-data';\n *\n * function PageTitleDisplay( { id } ) {\n * const { record, isResolving } = useEntityRecord( 'postType', 'page', id );\n *\n * if ( isResolving ) {\n * return 'Loading...';\n * }\n *\n * return record.title;\n * }\n *\n * // Rendered in the application:\n * // <PageTitleDisplay id={ 1 } />\n * ```\n *\n * In the above example, when `PageTitleDisplay` is rendered into an\n * application, the page and the resolution details will be retrieved from\n * the store state using `getEntityRecord()`, or resolved if missing.\n *\n * @example\n * ```js\n * import { useCallback } from 'react';\n * import { useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n * import { TextControl } from '@wordpress/components';\n * import { store as noticeStore } from '@wordpress/notices';\n * import { useEntityRecord } from '@wordpress/core-data';\n *\n * function PageRenameForm( { id } ) {\n * \tconst page = useEntityRecord( 'postType', 'page', id );\n * \tconst { createSuccessNotice, createErrorNotice } =\n * \t\tuseDispatch( noticeStore );\n *\n * \tconst setTitle = useCallback( ( title ) => {\n * \t\tpage.edit( { title } );\n * \t}, [ page.edit ] );\n *\n * \tif ( page.isResolving ) {\n * \t\treturn 'Loading...';\n * \t}\n *\n * \tasync function onRename( event ) {\n * \t\tevent.preventDefault();\n * \t\ttry {\n * \t\t\tawait page.save();\n * \t\t\tcreateSuccessNotice( __( 'Page renamed.' ), {\n * \t\t\t\ttype: 'snackbar',\n * \t\t\t} );\n * \t\t} catch ( error ) {\n * \t\t\tcreateErrorNotice( error.message, { type: 'snackbar' } );\n * \t\t}\n * \t}\n *\n * \treturn (\n * \t\t<form onSubmit={ onRename }>\n * \t\t\t<TextControl\n *\t\t\t\t__nextHasNoMarginBottom\n *\t\t\t\t__next40pxDefaultSize\n * \t\t\t\tlabel={ __( 'Name' ) }\n * \t\t\t\tvalue={ page.editedRecord.title }\n * \t\t\t\tonChange={ setTitle }\n * \t\t\t/>\n * \t\t\t<button type=\"submit\">{ __( 'Save' ) }</button>\n * \t\t</form>\n * \t);\n * }\n *\n * // Rendered in the application:\n * // <PageRenameForm id={ 1 } />\n * ```\n *\n * In the above example, updating and saving the page title is handled\n * via the `edit()` and `save()` mutation helpers provided by\n * `useEntityRecord()`;\n *\n * @return Entity record data.\n * @template RecordType\n */\nexport default function useEntityRecord< RecordType >(\n\tkind: string,\n\tname: string,\n\trecordId: string | number,\n\toptions: Options = { enabled: true }\n): EntityRecordResolution< RecordType > {\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\n\tconst mutations = useMemo(\n\t\t() => ( {\n\t\t\tedit: ( record, editOptions: any = {} ) =>\n\t\t\t\teditEntityRecord( kind, name, recordId, record, editOptions ),\n\t\t\tsave: ( saveOptions: any = {} ) =>\n\t\t\t\tsaveEditedEntityRecord( kind, name, recordId, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t...saveOptions,\n\t\t\t\t} ),\n\t\t} ),\n\t\t[ editEntityRecord, kind, name, recordId, saveEditedEntityRecord ]\n\t);\n\n\tconst { editedRecord, hasEdits, edits } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! options.enabled ) {\n\t\t\t\treturn {\n\t\t\t\t\teditedRecord: EMPTY_OBJECT,\n\t\t\t\t\thasEdits: false,\n\t\t\t\t\tedits: EMPTY_OBJECT,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\teditedRecord: select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordId\n\t\t\t\t),\n\t\t\t\thasEdits: select( coreStore ).hasEditsForEntityRecord(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordId\n\t\t\t\t),\n\t\t\t\tedits: select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ kind, name, recordId, options.enabled ]\n\t);\n\n\tconst { data: record, ...querySelectRest } = useQuerySelect(\n\t\t( query ) => {\n\t\t\tif ( ! options.enabled ) {\n\t\t\t\treturn {\n\t\t\t\t\tdata: null,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn query( coreStore ).getEntityRecord( kind, name, recordId );\n\t\t},\n\t\t[ kind, name, recordId, options.enabled ]\n\t);\n\n\treturn {\n\t\trecord,\n\t\teditedRecord,\n\t\thasEdits,\n\t\tedits,\n\t\t...querySelectRest,\n\t\t...mutations,\n\t};\n}\n\nexport function __experimentalUseEntityRecord(\n\tkind: string,\n\tname: string,\n\trecordId: any,\n\toptions: any\n) {\n\tdeprecated( `wp.data.__experimentalUseEntityRecord`, {\n\t\talternative: 'wp.data.useEntityRecord',\n\t\tsince: '6.1',\n\t} );\n\treturn useEntityRecord( kind, name, recordId, options );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,wBAAuB;AACvB,qBAAwB;AAKxB,8BAA2B;AAC3B,eAAmC;AA+CnC,MAAM,eAAe,CAAC;AA4FP,SAAR,gBACN,MACA,MACA,UACA,UAAmB,EAAE,SAAS,KAAK,GACI;AACvC,QAAM,EAAE,kBAAkB,uBAAuB,QAChD,yBAAa,SAAAA,KAAU;AAExB,QAAM,gBAAY;AAAA,IACjB,OAAQ;AAAA,MACP,MAAM,CAAEC,SAAQ,cAAmB,CAAC,MACnC,iBAAkB,MAAM,MAAM,UAAUA,SAAQ,WAAY;AAAA,MAC7D,MAAM,CAAE,cAAmB,CAAC,MAC3B,uBAAwB,MAAM,MAAM,UAAU;AAAA,QAC7C,cAAc;AAAA,QACd,GAAG;AAAA,MACJ,CAAE;AAAA,IACJ;AAAA,IACA,CAAE,kBAAkB,MAAM,MAAM,UAAU,sBAAuB;AAAA,EAClE;AAEA,QAAM,EAAE,cAAc,UAAU,MAAM,QAAI;AAAA,IACzC,CAAE,WAAY;AACb,UAAK,CAAE,QAAQ,SAAU;AACxB,eAAO;AAAA,UACN,cAAc;AAAA,UACd,UAAU;AAAA,UACV,OAAO;AAAA,QACR;AAAA,MACD;AAEA,aAAO;AAAA,QACN,cAAc,OAAQ,SAAAD,KAAU,EAAE;AAAA,UACjC;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,QACA,UAAU,OAAQ,SAAAA,KAAU,EAAE;AAAA,UAC7B;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,QACA,OAAO,OAAQ,SAAAA,KAAU,EAAE;AAAA,UAC1B;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,MAAM,MAAM,UAAU,QAAQ,OAAQ;AAAA,EACzC;AAEA,QAAM,EAAE,MAAM,QAAQ,GAAG,gBAAgB,QAAI,wBAAAE;AAAA,IAC5C,CAAE,UAAW;AACZ,UAAK,CAAE,QAAQ,SAAU;AACxB,eAAO;AAAA,UACN,MAAM;AAAA,QACP;AAAA,MACD;AACA,aAAO,MAAO,SAAAF,KAAU,EAAE,gBAAiB,MAAM,MAAM,QAAS;AAAA,IACjE;AAAA,IACA,CAAE,MAAM,MAAM,UAAU,QAAQ,OAAQ;AAAA,EACzC;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,IACH,GAAG;AAAA,EACJ;AACD;AAEO,SAAS,8BACf,MACA,MACA,UACA,SACC;AACD,wBAAAG,SAAY,yCAAyC;AAAA,IACpD,aAAa;AAAA,IACb,OAAO;AAAA,EACR,CAAE;AACF,SAAO,gBAAiB,MAAM,MAAM,UAAU,OAAQ;AACvD;",
|
|
6
|
+
"names": ["coreStore", "record", "useQuerySelect", "deprecated"]
|
|
7
|
+
}
|