@wordpress/core-data 7.51.0 → 7.53.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 +22 -0
- package/README.md +1 -0
- package/build/actions.cjs +64 -2
- package/build/actions.cjs.map +3 -3
- package/build/awareness/awareness-state.cjs.map +2 -2
- package/build/awareness/base-awareness.cjs.map +2 -2
- package/build/awareness/block-lookup.cjs.map +2 -2
- package/build/awareness/post-editor-awareness.cjs +7 -0
- package/build/awareness/post-editor-awareness.cjs.map +2 -2
- package/build/awareness/typed-awareness.cjs.map +2 -2
- package/build/awareness/types.cjs.map +1 -1
- package/build/awareness/utils.cjs.map +2 -2
- package/build/batch/create-batch.cjs.map +2 -2
- package/build/batch/default-processor.cjs.map +2 -2
- package/build/components/entities-saved-states/entity-record-item.cjs +67 -0
- package/build/components/entities-saved-states/entity-record-item.cjs.map +7 -0
- package/build/components/entities-saved-states/entity-type-list.cjs +135 -0
- package/build/components/entities-saved-states/entity-type-list.cjs.map +7 -0
- package/build/components/entities-saved-states/hooks/use-is-dirty.cjs +101 -0
- package/build/components/entities-saved-states/hooks/use-is-dirty.cjs.map +7 -0
- package/build/components/entities-saved-states/index.cjs +215 -0
- package/build/components/entities-saved-states/index.cjs.map +7 -0
- package/build/dynamic-entities.cjs.map +2 -2
- package/build/entities.cjs +2 -0
- package/build/entities.cjs.map +2 -2
- package/build/entity-context.cjs.map +2 -2
- package/build/entity-provider.cjs.map +2 -2
- package/build/entity-types/attachment.cjs.map +1 -1
- package/build/entity-types/base.cjs.map +1 -1
- package/build/entity-types/comment.cjs.map +1 -1
- package/build/entity-types/font-collection.cjs.map +1 -1
- package/build/entity-types/font-family.cjs.map +1 -1
- package/build/entity-types/global-styles-revision.cjs.map +1 -1
- package/build/entity-types/helpers.cjs.map +1 -1
- package/build/entity-types/icon.cjs.map +1 -1
- package/build/entity-types/index.cjs.map +1 -1
- package/build/entity-types/menu-location.cjs.map +1 -1
- package/build/entity-types/nav-menu-item.cjs.map +1 -1
- package/build/entity-types/nav-menu.cjs.map +1 -1
- package/build/entity-types/page.cjs.map +1 -1
- package/build/entity-types/plugin.cjs.map +1 -1
- package/build/entity-types/post-revision.cjs.map +1 -1
- package/build/entity-types/post-status.cjs.map +1 -1
- package/build/entity-types/post.cjs.map +1 -1
- package/build/entity-types/settings.cjs.map +1 -1
- package/build/entity-types/sidebar.cjs.map +1 -1
- package/build/entity-types/taxonomy.cjs.map +1 -1
- package/build/entity-types/term.cjs.map +1 -1
- package/build/entity-types/theme.cjs.map +1 -1
- package/build/entity-types/type.cjs.map +1 -1
- package/build/entity-types/user.cjs.map +1 -1
- package/build/entity-types/widget-type.cjs.map +1 -1
- package/build/entity-types/widget.cjs.map +1 -1
- package/build/entity-types/wp-template-part.cjs.map +1 -1
- package/build/entity-types/wp-template.cjs.map +1 -1
- package/build/fetch/__experimental-fetch-link-suggestions.cjs.map +2 -2
- package/build/fetch/__experimental-fetch-url-data.cjs.map +2 -2
- package/build/fetch/index.cjs.map +2 -2
- package/build/footnotes/get-footnotes-order.cjs.map +2 -2
- package/build/footnotes/get-rich-text-values-cached.cjs.map +2 -2
- package/build/footnotes/index.cjs +12 -1
- package/build/footnotes/index.cjs.map +3 -3
- package/build/hooks/index.cjs.map +2 -2
- package/build/hooks/use-entity-block-editor.cjs.map +2 -2
- package/build/hooks/use-entity-id.cjs.map +2 -2
- package/build/hooks/use-entity-prop.cjs.map +2 -2
- package/build/hooks/use-entity-record.cjs.map +2 -2
- package/build/hooks/use-entity-records.cjs +2 -2
- package/build/hooks/use-entity-records.cjs.map +2 -2
- package/build/hooks/use-post-editor-awareness-state.cjs.map +2 -2
- package/build/hooks/use-query-select.cjs.map +2 -2
- package/build/hooks/use-resource-permissions.cjs.map +2 -2
- package/build/hooks/utils.cjs.map +2 -2
- package/build/index.cjs.map +2 -2
- package/build/lock-unlock.cjs.map +2 -2
- package/build/locks/actions.cjs.map +2 -2
- package/build/locks/engine.cjs.map +2 -2
- package/build/locks/reducer.cjs.map +2 -2
- package/build/locks/selectors.cjs.map +2 -2
- package/build/private-actions.cjs +132 -0
- package/build/private-actions.cjs.map +3 -3
- package/build/private-apis.cjs +22 -0
- package/build/private-apis.cjs.map +3 -3
- package/build/private-selectors.cjs +5 -0
- package/build/private-selectors.cjs.map +2 -2
- package/build/queried-data/get-query-parts.cjs.map +2 -2
- package/build/queried-data/reducer.cjs.map +2 -2
- package/build/queried-data/selectors.cjs.map +2 -2
- package/build/reducer.cjs.map +2 -2
- package/build/resolvers.cjs +21 -26
- package/build/resolvers.cjs.map +2 -2
- package/build/selectors.cjs.map +2 -2
- package/build/sync.cjs +26 -0
- package/build/sync.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build/utils/block-selection-history.cjs.map +2 -2
- package/build/utils/clear-unchanged-edits.cjs.map +2 -2
- package/build/utils/conservative-map-item.cjs.map +2 -2
- package/build/utils/crdt-blocks.cjs.map +2 -2
- package/build/utils/crdt-selection.cjs.map +2 -2
- package/build/utils/crdt-text.cjs.map +2 -2
- package/build/utils/crdt-user-selections.cjs +43 -16
- package/build/utils/crdt-user-selections.cjs.map +3 -3
- package/build/utils/crdt-utils.cjs.map +2 -2
- package/build/utils/crdt.cjs +4 -2
- package/build/utils/crdt.cjs.map +2 -2
- package/build/utils/get-template-info.cjs +53 -0
- package/build/utils/get-template-info.cjs.map +7 -0
- package/build/utils/get-template-part-icon.cjs +43 -0
- package/build/utils/get-template-part-icon.cjs.map +7 -0
- package/build/utils/log-entity-deprecation.cjs.map +2 -2
- package/build/utils/save-crdt-doc.cjs.map +2 -2
- package/build-module/actions.mjs +68 -2
- package/build-module/actions.mjs.map +2 -2
- package/build-module/awareness/awareness-state.mjs.map +2 -2
- package/build-module/awareness/base-awareness.mjs.map +2 -2
- package/build-module/awareness/block-lookup.mjs.map +2 -2
- package/build-module/awareness/post-editor-awareness.mjs +7 -0
- package/build-module/awareness/post-editor-awareness.mjs.map +2 -2
- package/build-module/awareness/typed-awareness.mjs.map +2 -2
- package/build-module/awareness/utils.mjs.map +2 -2
- package/build-module/batch/create-batch.mjs.map +2 -2
- package/build-module/batch/default-processor.mjs.map +2 -2
- package/build-module/components/entities-saved-states/entity-record-item.mjs +46 -0
- package/build-module/components/entities-saved-states/entity-record-item.mjs.map +7 -0
- package/build-module/components/entities-saved-states/entity-type-list.mjs +104 -0
- package/build-module/components/entities-saved-states/entity-type-list.mjs.map +7 -0
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs +76 -0
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs.map +7 -0
- package/build-module/components/entities-saved-states/index.mjs +187 -0
- package/build-module/components/entities-saved-states/index.mjs.map +7 -0
- package/build-module/dynamic-entities.mjs.map +2 -2
- package/build-module/entities.mjs +2 -0
- package/build-module/entities.mjs.map +2 -2
- package/build-module/entity-context.mjs.map +2 -2
- package/build-module/entity-provider.mjs.map +2 -2
- package/build-module/fetch/__experimental-fetch-link-suggestions.mjs.map +2 -2
- package/build-module/fetch/__experimental-fetch-url-data.mjs.map +2 -2
- package/build-module/fetch/index.mjs.map +2 -2
- package/build-module/footnotes/get-footnotes-order.mjs.map +2 -2
- package/build-module/footnotes/get-rich-text-values-cached.mjs.map +2 -2
- package/build-module/footnotes/index.mjs +12 -1
- package/build-module/footnotes/index.mjs.map +2 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/use-entity-block-editor.mjs.map +2 -2
- package/build-module/hooks/use-entity-id.mjs.map +2 -2
- package/build-module/hooks/use-entity-prop.mjs.map +2 -2
- package/build-module/hooks/use-entity-record.mjs.map +2 -2
- package/build-module/hooks/use-entity-records.mjs +2 -2
- package/build-module/hooks/use-entity-records.mjs.map +2 -2
- package/build-module/hooks/use-post-editor-awareness-state.mjs.map +2 -2
- package/build-module/hooks/use-query-select.mjs.map +2 -2
- package/build-module/hooks/use-resource-permissions.mjs.map +2 -2
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/index.mjs.map +2 -2
- package/build-module/lock-unlock.mjs.map +2 -2
- package/build-module/locks/actions.mjs.map +2 -2
- package/build-module/locks/engine.mjs.map +2 -2
- package/build-module/locks/reducer.mjs.map +2 -2
- package/build-module/locks/selectors.mjs.map +2 -2
- package/build-module/private-actions.mjs +131 -0
- package/build-module/private-actions.mjs.map +2 -2
- package/build-module/private-apis.mjs +21 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/private-selectors.mjs +4 -0
- package/build-module/private-selectors.mjs.map +2 -2
- package/build-module/queried-data/get-query-parts.mjs.map +2 -2
- package/build-module/queried-data/reducer.mjs.map +2 -2
- package/build-module/queried-data/selectors.mjs.map +2 -2
- package/build-module/reducer.mjs.map +2 -2
- package/build-module/resolvers.mjs +21 -26
- package/build-module/resolvers.mjs.map +2 -2
- package/build-module/selectors.mjs.map +2 -2
- package/build-module/sync.mjs +23 -0
- package/build-module/sync.mjs.map +2 -2
- package/build-module/utils/block-selection-history.mjs.map +2 -2
- package/build-module/utils/clear-unchanged-edits.mjs.map +2 -2
- package/build-module/utils/conservative-map-item.mjs.map +2 -2
- package/build-module/utils/crdt-blocks.mjs.map +2 -2
- package/build-module/utils/crdt-selection.mjs.map +2 -2
- package/build-module/utils/crdt-text.mjs.map +2 -2
- package/build-module/utils/crdt-user-selections.mjs +43 -16
- package/build-module/utils/crdt-user-selections.mjs.map +3 -3
- package/build-module/utils/crdt-utils.mjs.map +2 -2
- package/build-module/utils/crdt.mjs +2 -1
- package/build-module/utils/crdt.mjs.map +2 -2
- package/build-module/utils/get-template-info.mjs +28 -0
- package/build-module/utils/get-template-info.mjs.map +7 -0
- package/build-module/utils/get-template-part-icon.mjs +24 -0
- package/build-module/utils/get-template-part-icon.mjs.map +7 -0
- package/build-module/utils/log-entity-deprecation.mjs.map +2 -2
- package/build-module/utils/save-crdt-doc.mjs.map +2 -2
- package/build-types/actions.d.ts +4 -0
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/awareness/awareness-state.d.ts.map +1 -1
- package/build-types/awareness/base-awareness.d.ts +0 -3
- package/build-types/awareness/base-awareness.d.ts.map +1 -1
- package/build-types/awareness/block-lookup.d.ts +0 -3
- package/build-types/awareness/block-lookup.d.ts.map +1 -1
- package/build-types/awareness/post-editor-awareness.d.ts +0 -3
- package/build-types/awareness/post-editor-awareness.d.ts.map +1 -1
- package/build-types/awareness/typed-awareness.d.ts +0 -3
- package/build-types/awareness/typed-awareness.d.ts.map +1 -1
- package/build-types/awareness/types.d.ts +0 -6
- package/build-types/awareness/types.d.ts.map +1 -1
- package/build-types/awareness/utils.d.ts +0 -3
- package/build-types/awareness/utils.d.ts.map +1 -1
- package/build-types/batch/create-batch.d.ts.map +1 -1
- package/build-types/batch/default-processor.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-record-item.d.ts +6 -0
- package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/entity-type-list.d.ts +6 -0
- package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts +11 -0
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/index.d.ts +49 -0
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -0
- package/build-types/dynamic-entities.d.ts +0 -3
- package/build-types/dynamic-entities.d.ts.map +1 -1
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/entity-context.d.ts.map +1 -1
- package/build-types/entity-provider.d.ts.map +1 -1
- package/build-types/entity-types/attachment.d.ts +0 -3
- package/build-types/entity-types/attachment.d.ts.map +1 -1
- package/build-types/entity-types/base.d.ts +0 -3
- package/build-types/entity-types/base.d.ts.map +1 -1
- package/build-types/entity-types/comment.d.ts +0 -3
- package/build-types/entity-types/comment.d.ts.map +1 -1
- package/build-types/entity-types/font-collection.d.ts +0 -3
- package/build-types/entity-types/font-collection.d.ts.map +1 -1
- package/build-types/entity-types/font-family.d.ts +0 -3
- package/build-types/entity-types/font-family.d.ts.map +1 -1
- package/build-types/entity-types/global-styles-revision.d.ts +0 -3
- package/build-types/entity-types/global-styles-revision.d.ts.map +1 -1
- package/build-types/entity-types/helpers.d.ts +0 -3
- package/build-types/entity-types/helpers.d.ts.map +1 -1
- package/build-types/entity-types/icon.d.ts +0 -3
- package/build-types/entity-types/icon.d.ts.map +1 -1
- package/build-types/entity-types/index.d.ts +0 -3
- package/build-types/entity-types/index.d.ts.map +1 -1
- package/build-types/entity-types/menu-location.d.ts +0 -3
- package/build-types/entity-types/menu-location.d.ts.map +1 -1
- package/build-types/entity-types/nav-menu-item.d.ts +0 -3
- package/build-types/entity-types/nav-menu-item.d.ts.map +1 -1
- package/build-types/entity-types/nav-menu.d.ts +0 -3
- package/build-types/entity-types/nav-menu.d.ts.map +1 -1
- package/build-types/entity-types/page.d.ts +0 -3
- package/build-types/entity-types/page.d.ts.map +1 -1
- package/build-types/entity-types/plugin.d.ts +0 -3
- package/build-types/entity-types/plugin.d.ts.map +1 -1
- package/build-types/entity-types/post-revision.d.ts +0 -3
- package/build-types/entity-types/post-revision.d.ts.map +1 -1
- package/build-types/entity-types/post-status.d.ts +0 -3
- package/build-types/entity-types/post-status.d.ts.map +1 -1
- package/build-types/entity-types/post.d.ts +0 -3
- package/build-types/entity-types/post.d.ts.map +1 -1
- package/build-types/entity-types/settings.d.ts +0 -3
- package/build-types/entity-types/settings.d.ts.map +1 -1
- package/build-types/entity-types/sidebar.d.ts +0 -3
- package/build-types/entity-types/sidebar.d.ts.map +1 -1
- package/build-types/entity-types/taxonomy.d.ts +0 -3
- package/build-types/entity-types/taxonomy.d.ts.map +1 -1
- package/build-types/entity-types/term.d.ts +0 -3
- package/build-types/entity-types/term.d.ts.map +1 -1
- package/build-types/entity-types/test/attachment.test.d.ts +0 -8
- package/build-types/entity-types/test/attachment.test.d.ts.map +1 -1
- package/build-types/entity-types/theme.d.ts +0 -3
- package/build-types/entity-types/theme.d.ts.map +1 -1
- package/build-types/entity-types/type.d.ts +0 -3
- package/build-types/entity-types/type.d.ts.map +1 -1
- package/build-types/entity-types/user.d.ts +0 -3
- package/build-types/entity-types/user.d.ts.map +1 -1
- package/build-types/entity-types/widget-type.d.ts +0 -3
- package/build-types/entity-types/widget-type.d.ts.map +1 -1
- package/build-types/entity-types/widget.d.ts +0 -3
- package/build-types/entity-types/widget.d.ts.map +1 -1
- package/build-types/entity-types/wp-template-part.d.ts +0 -3
- package/build-types/entity-types/wp-template-part.d.ts.map +1 -1
- package/build-types/entity-types/wp-template.d.ts +0 -3
- package/build-types/entity-types/wp-template.d.ts.map +1 -1
- package/build-types/fetch/__experimental-fetch-link-suggestions.d.ts.map +1 -1
- package/build-types/fetch/__experimental-fetch-url-data.d.ts.map +1 -1
- package/build-types/fetch/index.d.ts.map +1 -1
- package/build-types/footnotes/get-footnotes-order.d.ts.map +1 -1
- package/build-types/footnotes/get-rich-text-values-cached.d.ts.map +1 -1
- package/build-types/footnotes/index.d.ts.map +1 -1
- package/build-types/hooks/index.d.ts +0 -3
- package/build-types/hooks/index.d.ts.map +1 -1
- package/build-types/hooks/use-entity-block-editor.d.ts.map +1 -1
- package/build-types/hooks/use-entity-id.d.ts.map +1 -1
- package/build-types/hooks/use-entity-prop.d.ts.map +1 -1
- package/build-types/hooks/use-entity-record.d.ts.map +1 -1
- package/build-types/hooks/use-entity-records.d.ts.map +1 -1
- package/build-types/hooks/use-post-editor-awareness-state.d.ts.map +1 -1
- package/build-types/hooks/use-query-select.d.ts.map +1 -1
- package/build-types/hooks/use-resource-permissions.d.ts.map +1 -1
- package/build-types/hooks/utils.d.ts +0 -6
- package/build-types/hooks/utils.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/build-types/locks/actions.d.ts.map +1 -1
- package/build-types/locks/engine.d.ts.map +1 -1
- package/build-types/locks/reducer.d.ts.map +1 -1
- package/build-types/locks/selectors.d.ts.map +1 -1
- package/build-types/private-actions.d.ts +19 -0
- package/build-types/private-actions.d.ts.map +1 -1
- package/build-types/private-apis.d.ts +13 -3
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts +12 -3
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/queried-data/get-query-parts.d.ts.map +1 -1
- package/build-types/queried-data/reducer.d.ts.map +1 -1
- package/build-types/queried-data/selectors.d.ts.map +1 -1
- package/build-types/reducer.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +1 -2
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/sync.d.ts +31 -3
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/types.d.ts +9 -8
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/block-selection-history.d.ts +0 -6
- package/build-types/utils/block-selection-history.d.ts.map +1 -1
- package/build-types/utils/clear-unchanged-edits.d.ts.map +1 -1
- package/build-types/utils/conservative-map-item.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts +0 -3
- package/build-types/utils/crdt-blocks.d.ts.map +1 -1
- package/build-types/utils/crdt-selection.d.ts +0 -3
- package/build-types/utils/crdt-selection.d.ts.map +1 -1
- package/build-types/utils/crdt-text.d.ts +0 -3
- package/build-types/utils/crdt-text.d.ts.map +1 -1
- package/build-types/utils/crdt-user-selections.d.ts.map +1 -1
- package/build-types/utils/crdt-utils.d.ts +0 -6
- package/build-types/utils/crdt-utils.d.ts.map +1 -1
- package/build-types/utils/crdt.d.ts +8 -0
- package/build-types/utils/crdt.d.ts.map +1 -1
- package/build-types/utils/get-template-info.d.ts +13 -0
- package/build-types/utils/get-template-info.d.ts.map +1 -0
- package/build-types/utils/get-template-part-icon.d.ts +9 -0
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -0
- package/build-types/utils/log-entity-deprecation.d.ts.map +1 -1
- package/build-types/utils/save-crdt-doc.d.ts.map +1 -1
- package/package.json +28 -22
- package/src/actions.js +120 -13
- package/src/awareness/awareness-state.ts +0 -3
- package/src/awareness/base-awareness.ts +0 -8
- package/src/awareness/block-lookup.ts +1 -8
- package/src/awareness/post-editor-awareness.ts +13 -10
- package/src/awareness/test/awareness-state.ts +0 -11
- package/src/awareness/test/base-awareness.ts +0 -7
- package/src/awareness/test/block-lookup.ts +0 -8
- package/src/awareness/test/post-editor-awareness.ts +0 -7
- package/src/awareness/test/typed-awareness.ts +0 -11
- package/src/awareness/test/utils.ts +0 -3
- package/src/awareness/typed-awareness.ts +0 -7
- package/src/awareness/types.ts +0 -7
- package/src/awareness/utils.ts +0 -3
- package/src/batch/create-batch.js +0 -3
- package/src/batch/default-processor.js +0 -4
- package/src/batch/test/create-batch.js +0 -3
- package/src/batch/test/default-processor.js +0 -7
- package/src/components/entities-saved-states/entity-record-item.js +53 -0
- package/src/components/entities-saved-states/entity-type-list.js +123 -0
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +98 -0
- package/src/components/entities-saved-states/index.js +231 -0
- package/src/components/entities-saved-states/style.scss +70 -0
- package/src/components/entities-saved-states/test/use-is-dirty.js +147 -0
- package/src/dynamic-entities.ts +0 -3
- package/src/entities.js +2 -11
- package/src/entity-context.js +0 -3
- package/src/entity-provider.js +0 -7
- package/src/entity-types/attachment.ts +0 -4
- package/src/entity-types/base.ts +0 -3
- package/src/entity-types/comment.ts +0 -3
- package/src/entity-types/font-collection.ts +0 -3
- package/src/entity-types/font-family.ts +0 -3
- package/src/entity-types/global-styles-revision.ts +0 -4
- package/src/entity-types/helpers.ts +0 -3
- package/src/entity-types/icon.ts +0 -4
- package/src/entity-types/index.ts +0 -3
- package/src/entity-types/menu-location.ts +0 -4
- package/src/entity-types/nav-menu-item.ts +0 -4
- package/src/entity-types/nav-menu.ts +0 -4
- package/src/entity-types/page.ts +0 -4
- package/src/entity-types/plugin.ts +0 -4
- package/src/entity-types/post-revision.ts +0 -4
- package/src/entity-types/post-status.ts +0 -3
- package/src/entity-types/post.ts +0 -4
- package/src/entity-types/settings.ts +0 -4
- package/src/entity-types/sidebar.ts +0 -4
- package/src/entity-types/taxonomy.ts +0 -4
- package/src/entity-types/term.ts +0 -4
- package/src/entity-types/test/attachment.test.ts +0 -4
- package/src/entity-types/theme.ts +0 -4
- package/src/entity-types/type.ts +0 -4
- package/src/entity-types/user.ts +0 -4
- package/src/entity-types/widget-type.ts +0 -4
- package/src/entity-types/widget.ts +0 -4
- package/src/entity-types/wp-template-part.ts +0 -4
- package/src/entity-types/wp-template.ts +0 -4
- package/src/fetch/__experimental-fetch-link-suggestions.ts +0 -3
- package/src/fetch/__experimental-fetch-url-data.js +0 -3
- package/src/fetch/index.js +0 -7
- package/src/fetch/test/__experimental-fetch-link-suggestions.js +0 -3
- package/src/fetch/test/__experimental-fetch-url-data.js +1 -7
- package/src/footnotes/get-footnotes-order.js +0 -3
- package/src/footnotes/get-rich-text-values-cached.js +0 -7
- package/src/footnotes/index.js +21 -8
- package/src/footnotes/test/index.js +57 -0
- package/src/hooks/index.ts +0 -3
- package/src/hooks/test/use-entity-record.js +0 -12
- package/src/hooks/test/use-entity-records.js +0 -12
- package/src/hooks/test/use-post-editor-awareness-state.ts +0 -7
- package/src/hooks/test/use-query-select.js +0 -11
- package/src/hooks/test/use-resource-permissions.js +0 -12
- package/src/hooks/use-entity-block-editor.js +0 -7
- package/src/hooks/use-entity-id.js +0 -7
- package/src/hooks/use-entity-prop.js +0 -7
- package/src/hooks/use-entity-record.ts +0 -7
- package/src/hooks/use-entity-records.ts +2 -9
- package/src/hooks/use-post-editor-awareness-state.ts +0 -7
- package/src/hooks/use-query-select.ts +0 -7
- package/src/hooks/use-resource-permissions.ts +0 -7
- package/src/hooks/utils.ts +0 -7
- package/src/index.js +0 -7
- package/src/lock-unlock.ts +0 -3
- package/src/locks/actions.js +0 -3
- package/src/locks/engine.js +0 -3
- package/src/locks/reducer.js +0 -3
- package/src/locks/selectors.js +0 -3
- package/src/locks/test/engine.js +0 -3
- package/src/locks/test/reducer.js +0 -7
- package/src/locks/test/selectors.js +0 -7
- package/src/locks/test/utils.js +0 -7
- package/src/private-actions.js +182 -7
- package/src/private-apis.ts +21 -4
- package/src/private-selectors.ts +22 -7
- package/src/queried-data/get-query-parts.js +0 -7
- package/src/queried-data/reducer.js +0 -7
- package/src/queried-data/selectors.js +0 -7
- package/src/queried-data/test/actions.js +0 -3
- package/src/queried-data/test/get-query-parts.js +0 -3
- package/src/queried-data/test/reducer.js +0 -7
- package/src/queried-data/test/selectors.js +0 -3
- package/src/reducer.js +0 -11
- package/src/resolvers.js +23 -40
- package/src/selectors.ts +0 -7
- package/src/style.scss +1 -0
- package/src/sync.ts +64 -7
- package/src/test/actions.js +843 -8
- package/src/test/deprecated-entity-logging.js +0 -7
- package/src/test/entities.js +0 -8
- package/src/test/entity-provider.js +0 -11
- package/src/test/private-actions.js +297 -7
- package/src/test/private-selectors.js +0 -3
- package/src/test/reducer.js +0 -7
- package/src/test/resolvers.js +0 -12
- package/src/test/rtc-rich-text-offset-space.test.js +0 -12
- package/src/test/selectors.js +0 -7
- package/src/test/store.js +8 -15
- package/src/types.ts +14 -12
- package/src/utils/block-selection-history.ts +0 -10
- package/src/utils/clear-unchanged-edits.ts +0 -3
- package/src/utils/conservative-map-item.js +0 -3
- package/src/utils/crdt-blocks.ts +0 -11
- package/src/utils/crdt-selection.ts +0 -7
- package/src/utils/crdt-text.ts +0 -3
- package/src/utils/crdt-user-selections.ts +85 -23
- package/src/utils/crdt-utils.ts +0 -7
- package/src/utils/crdt.ts +1 -12
- package/src/utils/get-template-info.js +46 -0
- package/src/utils/get-template-part-icon.js +27 -0
- package/src/utils/log-entity-deprecation.ts +0 -7
- package/src/utils/save-crdt-doc.js +0 -7
- package/src/utils/test/block-selection-history.test.ts +0 -7
- package/src/utils/test/clear-unchanged-edits.js +0 -3
- package/src/utils/test/conservative-map-item.js +0 -3
- package/src/utils/test/crdt-blocks.ts +0 -17
- package/src/utils/test/crdt-user-selections.ts +107 -30
- package/src/utils/test/crdt-utils.ts +0 -7
- package/src/utils/test/crdt.ts +0 -16
- package/src/utils/test/get-nested-value.js +0 -3
- package/src/utils/test/get-normalized-comma-separable.js +0 -3
- package/src/utils/test/get-template-info.js +218 -0
- package/src/utils/test/if-matching-action.js +0 -7
- package/src/utils/test/is-numeric-id.js +0 -3
- package/src/utils/test/log-entity-deprecation.js +0 -7
- package/src/utils/test/replace-action.js +0 -3
- package/src/utils/test/rtc-rich-text-cursor-scope.test.js +0 -14
- package/src/utils/test/rtc-rich-text-offset-space.test.js +0 -14
- package/src/utils/test/save-crdt-doc.js +0 -7
- package/src/utils/test/set-nested-value.js +0 -3
- package/src/utils/test/with-weak-map-cache.js +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/batch/default-processor.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import apiFetch from '@wordpress/api-fetch';\n\n/**\n * Maximum number of requests to place in a single batch request. Obtained by\n * sending a preflight OPTIONS request to /batch/v1/.\n *\n * @type {number?}\n */\nlet maxItems = null;\n\nfunction chunk( arr, chunkSize ) {\n\tconst tmp = [ ...arr ];\n\tconst cache = [];\n\twhile ( tmp.length ) {\n\t\tcache.push( tmp.splice( 0, chunkSize ) );\n\t}\n\n\treturn cache;\n}\n\n/**\n * Default batch processor. Sends its input requests to /batch/v1.\n *\n * @param {Array} requests List of API requests to perform at once.\n *\n * @return {Promise} Promise that resolves to a list of objects containing\n * either `output` (if that request was successful) or `error`\n * (if not ).\n */\nexport default async function defaultProcessor( requests ) {\n\tif ( maxItems === null ) {\n\t\tconst preflightResponse = await apiFetch( {\n\t\t\tpath: '/batch/v1',\n\t\t\tmethod: 'OPTIONS',\n\t\t} );\n\t\tmaxItems = preflightResponse.endpoints[ 0 ].args.requests.maxItems;\n\t}\n\n\tconst results = [];\n\n\tfor ( const batchRequests of chunk( requests, maxItems ) ) {\n\t\tconst batchResponse = await apiFetch( {\n\t\t\tpath: '/batch/v1',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tvalidation: 'require-all-validate',\n\t\t\t\trequests: batchRequests.map( ( request ) => ( {\n\t\t\t\t\tpath: request.path,\n\t\t\t\t\tbody: request.data, // Rename 'data' to 'body'.\n\t\t\t\t\tmethod: request.method,\n\t\t\t\t\theaders: request.headers,\n\t\t\t\t} ) ),\n\t\t\t},\n\t\t} );\n\n\t\tlet batchResults;\n\n\t\tif ( batchResponse.failed ) {\n\t\t\tbatchResults = batchResponse.responses.map( ( response ) => ( {\n\t\t\t\terror: response?.body,\n\t\t\t} ) );\n\t\t} else {\n\t\t\tbatchResults = batchResponse.responses.map( ( response ) => {\n\t\t\t\tconst result = {};\n\t\t\t\tif ( response.status >= 200 && response.status < 300 ) {\n\t\t\t\t\tresult.output = response.body;\n\t\t\t\t} else {\n\t\t\t\t\tresult.error = response.body;\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t} );\n\t\t}\n\n\t\tresults.push( ...batchResults );\n\t}\n\n\treturn results;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,cAAc;AAQrB,IAAI,WAAW;AAEf,SAAS,MAAO,KAAK,WAAY;AAChC,QAAM,MAAM,CAAE,GAAG,GAAI;AACrB,QAAM,QAAQ,CAAC;AACf,SAAQ,IAAI,QAAS;AACpB,UAAM,KAAM,IAAI,OAAQ,GAAG,SAAU,CAAE;AAAA,EACxC;AAEA,SAAO;AACR;AAWA,eAAO,iBAAyC,UAAW;AAC1D,MAAK,aAAa,MAAO;AACxB,UAAM,oBAAoB,MAAM,SAAU;AAAA,MACzC,MAAM;AAAA,MACN,QAAQ;AAAA,IACT,CAAE;AACF,eAAW,kBAAkB,UAAW,CAAE,EAAE,KAAK,SAAS;AAAA,EAC3D;AAEA,QAAM,UAAU,CAAC;AAEjB,aAAY,iBAAiB,MAAO,UAAU,QAAS,GAAI;AAC1D,UAAM,gBAAgB,MAAM,SAAU;AAAA,MACrC,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,QACL,YAAY;AAAA,QACZ,UAAU,cAAc,IAAK,CAAE,aAAe;AAAA,UAC7C,MAAM,QAAQ;AAAA,UACd,MAAM,QAAQ;AAAA;AAAA,UACd,QAAQ,QAAQ;AAAA,UAChB,SAAS,QAAQ;AAAA,QAClB,EAAI;AAAA,MACL;AAAA,IACD,CAAE;AAEF,QAAI;AAEJ,QAAK,cAAc,QAAS;AAC3B,qBAAe,cAAc,UAAU,IAAK,CAAE,cAAgB;AAAA,QAC7D,OAAO,UAAU;AAAA,MAClB,EAAI;AAAA,IACL,OAAO;AACN,qBAAe,cAAc,UAAU,IAAK,CAAE,aAAc;AAC3D,cAAM,SAAS,CAAC;AAChB,YAAK,SAAS,UAAU,OAAO,SAAS,SAAS,KAAM;AACtD,iBAAO,SAAS,SAAS;AAAA,QAC1B,OAAO;AACN,iBAAO,QAAQ,SAAS;AAAA,QACzB;AACA,eAAO;AAAA,MACR,CAAE;AAAA,IACH;AAEA,YAAQ,KAAM,GAAG,YAAa;AAAA,EAC/B;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// packages/core-data/src/components/entities-saved-states/entity-record-item.js
|
|
2
|
+
import { CheckboxControl, PanelRow } from "@wordpress/components";
|
|
3
|
+
import { __ } from "@wordpress/i18n";
|
|
4
|
+
import { useSelect } from "@wordpress/data";
|
|
5
|
+
import { decodeEntities } from "@wordpress/html-entities";
|
|
6
|
+
import { STORE_NAME } from "../../name.mjs";
|
|
7
|
+
import { getTemplateInfo } from "../../utils/get-template-info.mjs";
|
|
8
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
9
|
+
function EntityRecordItem({ record, checked, onChange }) {
|
|
10
|
+
const { name, kind, title, key } = record;
|
|
11
|
+
const { entityRecordTitle } = useSelect(
|
|
12
|
+
(select) => {
|
|
13
|
+
if ("postType" !== kind || "wp_template" !== name) {
|
|
14
|
+
return {
|
|
15
|
+
entityRecordTitle: title
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const template = select(STORE_NAME).getEditedEntityRecord(
|
|
19
|
+
kind,
|
|
20
|
+
name,
|
|
21
|
+
key
|
|
22
|
+
);
|
|
23
|
+
const { default_template_types: templateTypes = [] } = select(STORE_NAME).getCurrentTheme() ?? {};
|
|
24
|
+
return {
|
|
25
|
+
entityRecordTitle: getTemplateInfo({
|
|
26
|
+
template,
|
|
27
|
+
templateTypes
|
|
28
|
+
}).title
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
[name, kind, title, key]
|
|
32
|
+
);
|
|
33
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(PanelRow, { children: /* @__PURE__ */ jsx(
|
|
34
|
+
CheckboxControl,
|
|
35
|
+
{
|
|
36
|
+
label: decodeEntities(entityRecordTitle) || __("Untitled"),
|
|
37
|
+
checked,
|
|
38
|
+
onChange,
|
|
39
|
+
className: "entities-saved-states__change-control"
|
|
40
|
+
}
|
|
41
|
+
) }) });
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
EntityRecordItem as default
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=entity-record-item.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/entities-saved-states/entity-record-item.js"],
|
|
4
|
+
"sourcesContent": ["import { CheckboxControl, PanelRow } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { STORE_NAME } from '../../name';\nimport { getTemplateInfo } from '../../utils/get-template-info';\n\nexport default function EntityRecordItem( { record, checked, onChange } ) {\n\tconst { name, kind, title, key } = record;\n\n\t// Handle templates that might use default descriptive titles.\n\tconst { entityRecordTitle } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( 'postType' !== kind || 'wp_template' !== name ) {\n\t\t\t\treturn {\n\t\t\t\t\tentityRecordTitle: title,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst template = select( STORE_NAME ).getEditedEntityRecord(\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\tkey\n\t\t\t);\n\n\t\t\tconst { default_template_types: templateTypes = [] } =\n\t\t\t\tselect( STORE_NAME ).getCurrentTheme() ?? {};\n\n\t\t\treturn {\n\t\t\t\tentityRecordTitle: getTemplateInfo( {\n\t\t\t\t\ttemplate,\n\t\t\t\t\ttemplateTypes,\n\t\t\t\t} ).title,\n\t\t\t};\n\t\t},\n\t\t[ name, kind, title, key ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<PanelRow>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tdecodeEntities( entityRecordTitle ) || __( 'Untitled' )\n\t\t\t\t\t}\n\t\t\t\t\tchecked={ checked }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tclassName=\"entities-saved-states__change-control\"\n\t\t\t\t/>\n\t\t\t</PanelRow>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAkC9B,mBAEE,WAFF;AAhCa,SAAR,iBAAmC,EAAE,QAAQ,SAAS,SAAS,GAAI;AACzE,QAAM,EAAE,MAAM,MAAM,OAAO,IAAI,IAAI;AAGnC,QAAM,EAAE,kBAAkB,IAAI;AAAA,IAC7B,CAAE,WAAY;AACb,UAAK,eAAe,QAAQ,kBAAkB,MAAO;AACpD,eAAO;AAAA,UACN,mBAAmB;AAAA,QACpB;AAAA,MACD;AAEA,YAAM,WAAW,OAAQ,UAAW,EAAE;AAAA,QACrC;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAEA,YAAM,EAAE,wBAAwB,gBAAgB,CAAC,EAAE,IAClD,OAAQ,UAAW,EAAE,gBAAgB,KAAK,CAAC;AAE5C,aAAO;AAAA,QACN,mBAAmB,gBAAiB;AAAA,UACnC;AAAA,UACA;AAAA,QACD,CAAE,EAAE;AAAA,MACL;AAAA,IACD;AAAA,IACA,CAAE,MAAM,MAAM,OAAO,GAAI;AAAA,EAC1B;AAEA,SACC,gCACC,8BAAC,YACA;AAAA,IAAC;AAAA;AAAA,MACA,OACC,eAAgB,iBAAkB,KAAK,GAAI,UAAW;AAAA,MAEvD;AAAA,MACA;AAAA,MACA,WAAU;AAAA;AAAA,EACX,GACD,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// packages/core-data/src/components/entities-saved-states/entity-type-list.js
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { useSelect } from "@wordpress/data";
|
|
4
|
+
import { PanelBody, PanelRow } from "@wordpress/components";
|
|
5
|
+
import { getGlobalStylesChanges } from "@wordpress/global-styles-engine";
|
|
6
|
+
import EntityRecordItem from "./entity-record-item.mjs";
|
|
7
|
+
import { STORE_NAME } from "../../name.mjs";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function getEntityDescription(entity, count) {
|
|
10
|
+
switch (entity) {
|
|
11
|
+
case "site":
|
|
12
|
+
return 1 === count ? __("This change will affect your whole site.") : __("These changes will affect your whole site.");
|
|
13
|
+
case "wp_template":
|
|
14
|
+
return __(
|
|
15
|
+
"This change will affect other parts of your site that use this template."
|
|
16
|
+
);
|
|
17
|
+
case "page":
|
|
18
|
+
case "post":
|
|
19
|
+
return __("The following has been modified.");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function GlobalStylesDescription({ record }) {
|
|
23
|
+
const { editedRecord, savedRecord } = useSelect(
|
|
24
|
+
(select) => {
|
|
25
|
+
const { getEditedEntityRecord, getEntityRecord } = select(STORE_NAME);
|
|
26
|
+
return {
|
|
27
|
+
editedRecord: getEditedEntityRecord(
|
|
28
|
+
record.kind,
|
|
29
|
+
record.name,
|
|
30
|
+
record.key
|
|
31
|
+
),
|
|
32
|
+
savedRecord: getEntityRecord(
|
|
33
|
+
record.kind,
|
|
34
|
+
record.name,
|
|
35
|
+
record.key
|
|
36
|
+
)
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
[record.kind, record.name, record.key]
|
|
40
|
+
);
|
|
41
|
+
const globalStylesChanges = getGlobalStylesChanges(
|
|
42
|
+
editedRecord,
|
|
43
|
+
savedRecord,
|
|
44
|
+
{
|
|
45
|
+
maxResults: 10
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
return globalStylesChanges.length ? /* @__PURE__ */ jsx("ul", { className: "entities-saved-states__changes", children: globalStylesChanges.map((change) => /* @__PURE__ */ jsx("li", { children: change }, change)) }) : null;
|
|
49
|
+
}
|
|
50
|
+
function EntityDescription({ record, count }) {
|
|
51
|
+
if ("globalStyles" === record?.name) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const description = getEntityDescription(record?.name, count);
|
|
55
|
+
return description ? /* @__PURE__ */ jsx(PanelRow, { children: description }) : null;
|
|
56
|
+
}
|
|
57
|
+
function EntityTypeList({
|
|
58
|
+
list,
|
|
59
|
+
unselectedEntities,
|
|
60
|
+
setUnselectedEntities
|
|
61
|
+
}) {
|
|
62
|
+
const count = list.length;
|
|
63
|
+
const firstRecord = list[0];
|
|
64
|
+
const entityConfig = useSelect(
|
|
65
|
+
(select) => select(STORE_NAME).getEntityConfig(
|
|
66
|
+
firstRecord.kind,
|
|
67
|
+
firstRecord.name
|
|
68
|
+
),
|
|
69
|
+
[firstRecord.kind, firstRecord.name]
|
|
70
|
+
);
|
|
71
|
+
let entityLabel = entityConfig.label;
|
|
72
|
+
if (firstRecord?.name === "wp_template_part") {
|
|
73
|
+
entityLabel = 1 === count ? __("Template Part") : __("Template Parts");
|
|
74
|
+
}
|
|
75
|
+
return /* @__PURE__ */ jsxs(
|
|
76
|
+
PanelBody,
|
|
77
|
+
{
|
|
78
|
+
title: entityLabel,
|
|
79
|
+
initialOpen: true,
|
|
80
|
+
className: "entities-saved-states__panel-body",
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ jsx(EntityDescription, { record: firstRecord, count }),
|
|
83
|
+
list.map((record) => {
|
|
84
|
+
return /* @__PURE__ */ jsx(
|
|
85
|
+
EntityRecordItem,
|
|
86
|
+
{
|
|
87
|
+
record,
|
|
88
|
+
checked: !unselectedEntities.some(
|
|
89
|
+
(elt) => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property
|
|
90
|
+
),
|
|
91
|
+
onChange: (value) => setUnselectedEntities(record, value)
|
|
92
|
+
},
|
|
93
|
+
record.key || record.property
|
|
94
|
+
);
|
|
95
|
+
}),
|
|
96
|
+
"globalStyles" === firstRecord?.name && /* @__PURE__ */ jsx(GlobalStylesDescription, { record: firstRecord })
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
EntityTypeList as default
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=entity-type-list.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/entities-saved-states/entity-type-list.js"],
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { getGlobalStylesChanges } from '@wordpress/global-styles-engine';\nimport EntityRecordItem from './entity-record-item';\nimport { STORE_NAME } from '../../name';\n\nfunction getEntityDescription( entity, count ) {\n\tswitch ( entity ) {\n\t\tcase 'site':\n\t\t\treturn 1 === count\n\t\t\t\t? __( 'This change will affect your whole site.' )\n\t\t\t\t: __( 'These changes will affect your whole site.' );\n\t\tcase 'wp_template':\n\t\t\treturn __(\n\t\t\t\t'This change will affect other parts of your site that use this template.'\n\t\t\t);\n\t\tcase 'page':\n\t\tcase 'post':\n\t\t\treturn __( 'The following has been modified.' );\n\t}\n}\n\nfunction GlobalStylesDescription( { record } ) {\n\tconst { editedRecord, savedRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getEntityRecord } =\n\t\t\t\tselect( STORE_NAME );\n\t\t\treturn {\n\t\t\t\teditedRecord: getEditedEntityRecord(\n\t\t\t\t\trecord.kind,\n\t\t\t\t\trecord.name,\n\t\t\t\t\trecord.key\n\t\t\t\t),\n\t\t\t\tsavedRecord: getEntityRecord(\n\t\t\t\t\trecord.kind,\n\t\t\t\t\trecord.name,\n\t\t\t\t\trecord.key\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ record.kind, record.name, record.key ]\n\t);\n\n\tconst globalStylesChanges = getGlobalStylesChanges(\n\t\teditedRecord,\n\t\tsavedRecord,\n\t\t{\n\t\t\tmaxResults: 10,\n\t\t}\n\t);\n\treturn globalStylesChanges.length ? (\n\t\t<ul className=\"entities-saved-states__changes\">\n\t\t\t{ globalStylesChanges.map( ( change ) => (\n\t\t\t\t<li key={ change }>{ change }</li>\n\t\t\t) ) }\n\t\t</ul>\n\t) : null;\n}\n\nfunction EntityDescription( { record, count } ) {\n\tif ( 'globalStyles' === record?.name ) {\n\t\treturn null;\n\t}\n\tconst description = getEntityDescription( record?.name, count );\n\treturn description ? <PanelRow>{ description }</PanelRow> : null;\n}\n\nexport default function EntityTypeList( {\n\tlist,\n\tunselectedEntities,\n\tsetUnselectedEntities,\n} ) {\n\tconst count = list.length;\n\tconst firstRecord = list[ 0 ];\n\tconst entityConfig = useSelect(\n\t\t( select ) =>\n\t\t\tselect( STORE_NAME ).getEntityConfig(\n\t\t\t\tfirstRecord.kind,\n\t\t\t\tfirstRecord.name\n\t\t\t),\n\t\t[ firstRecord.kind, firstRecord.name ]\n\t);\n\n\tlet entityLabel = entityConfig.label;\n\tif ( firstRecord?.name === 'wp_template_part' ) {\n\t\tentityLabel =\n\t\t\t1 === count ? __( 'Template Part' ) : __( 'Template Parts' );\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ entityLabel }\n\t\t\tinitialOpen\n\t\t\tclassName=\"entities-saved-states__panel-body\"\n\t\t>\n\t\t\t<EntityDescription record={ firstRecord } count={ count } />\n\t\t\t{ list.map( ( record ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityRecordItem\n\t\t\t\t\t\tkey={ record.key || record.property }\n\t\t\t\t\t\trecord={ record }\n\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t! unselectedEntities.some(\n\t\t\t\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\t\t\t\telt.kind === record.kind &&\n\t\t\t\t\t\t\t\t\telt.name === record.name &&\n\t\t\t\t\t\t\t\t\telt.key === record.key &&\n\t\t\t\t\t\t\t\t\telt.property === record.property\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetUnselectedEntities( record, value )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\t{ 'globalStyles' === firstRecord?.name && (\n\t\t\t\t<GlobalStylesDescription record={ firstRecord } />\n\t\t\t) }\n\t\t</PanelBody>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,WAAW,gBAAgB;AACpC,SAAS,8BAA8B;AACvC,OAAO,sBAAsB;AAC7B,SAAS,kBAAkB;AAiDvB,cAqCF,YArCE;AA/CJ,SAAS,qBAAsB,QAAQ,OAAQ;AAC9C,UAAS,QAAS;AAAA,IACjB,KAAK;AACJ,aAAO,MAAM,QACV,GAAI,0CAA2C,IAC/C,GAAI,4CAA6C;AAAA,IACrD,KAAK;AACJ,aAAO;AAAA,QACN;AAAA,MACD;AAAA,IACD,KAAK;AAAA,IACL,KAAK;AACJ,aAAO,GAAI,kCAAmC;AAAA,EAChD;AACD;AAEA,SAAS,wBAAyB,EAAE,OAAO,GAAI;AAC9C,QAAM,EAAE,cAAc,YAAY,IAAI;AAAA,IACrC,CAAE,WAAY;AACb,YAAM,EAAE,uBAAuB,gBAAgB,IAC9C,OAAQ,UAAW;AACpB,aAAO;AAAA,QACN,cAAc;AAAA,UACb,OAAO;AAAA,UACP,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,QACA,aAAa;AAAA,UACZ,OAAO;AAAA,UACP,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,OAAO,MAAM,OAAO,MAAM,OAAO,GAAI;AAAA,EACxC;AAEA,QAAM,sBAAsB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,MACC,YAAY;AAAA,IACb;AAAA,EACD;AACA,SAAO,oBAAoB,SAC1B,oBAAC,QAAG,WAAU,kCACX,8BAAoB,IAAK,CAAE,WAC5B,oBAAC,QAAoB,oBAAX,MAAmB,CAC5B,GACH,IACG;AACL;AAEA,SAAS,kBAAmB,EAAE,QAAQ,MAAM,GAAI;AAC/C,MAAK,mBAAmB,QAAQ,MAAO;AACtC,WAAO;AAAA,EACR;AACA,QAAM,cAAc,qBAAsB,QAAQ,MAAM,KAAM;AAC9D,SAAO,cAAc,oBAAC,YAAW,uBAAa,IAAc;AAC7D;AAEe,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,QAAQ,KAAK;AACnB,QAAM,cAAc,KAAM,CAAE;AAC5B,QAAM,eAAe;AAAA,IACpB,CAAE,WACD,OAAQ,UAAW,EAAE;AAAA,MACpB,YAAY;AAAA,MACZ,YAAY;AAAA,IACb;AAAA,IACD,CAAE,YAAY,MAAM,YAAY,IAAK;AAAA,EACtC;AAEA,MAAI,cAAc,aAAa;AAC/B,MAAK,aAAa,SAAS,oBAAqB;AAC/C,kBACC,MAAM,QAAQ,GAAI,eAAgB,IAAI,GAAI,gBAAiB;AAAA,EAC7D;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ;AAAA,MACR,aAAW;AAAA,MACX,WAAU;AAAA,MAEV;AAAA,4BAAC,qBAAkB,QAAS,aAAc,OAAgB;AAAA,QACxD,KAAK,IAAK,CAAE,WAAY;AACzB,iBACC;AAAA,YAAC;AAAA;AAAA,cAEA;AAAA,cACA,SACC,CAAE,mBAAmB;AAAA,gBACpB,CAAE,QACD,IAAI,SAAS,OAAO,QACpB,IAAI,SAAS,OAAO,QACpB,IAAI,QAAQ,OAAO,OACnB,IAAI,aAAa,OAAO;AAAA,cAC1B;AAAA,cAED,UAAW,CAAE,UACZ,sBAAuB,QAAQ,KAAM;AAAA;AAAA,YAZhC,OAAO,OAAO,OAAO;AAAA,UAc5B;AAAA,QAEF,CAAE;AAAA,QACA,mBAAmB,aAAa,QACjC,oBAAC,2BAAwB,QAAS,aAAc;AAAA;AAAA;AAAA,EAElD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// packages/core-data/src/components/entities-saved-states/hooks/use-is-dirty.js
|
|
2
|
+
import { useSelect } from "@wordpress/data";
|
|
3
|
+
import { useMemo, useState } from "@wordpress/element";
|
|
4
|
+
import { STORE_NAME } from "../../../name.mjs";
|
|
5
|
+
var useIsDirty = () => {
|
|
6
|
+
const { editedEntities, siteEdits, siteEntityConfig } = useSelect(
|
|
7
|
+
(select) => {
|
|
8
|
+
const {
|
|
9
|
+
__experimentalGetDirtyEntityRecords,
|
|
10
|
+
getEntityRecordEdits,
|
|
11
|
+
getEntityConfig
|
|
12
|
+
} = select(STORE_NAME);
|
|
13
|
+
return {
|
|
14
|
+
editedEntities: __experimentalGetDirtyEntityRecords(),
|
|
15
|
+
siteEdits: getEntityRecordEdits("root", "site"),
|
|
16
|
+
siteEntityConfig: getEntityConfig("root", "site")
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
[]
|
|
20
|
+
);
|
|
21
|
+
const dirtyEntityRecords = useMemo(() => {
|
|
22
|
+
const editedEntitiesWithoutSite = editedEntities.filter(
|
|
23
|
+
(record) => !(record.kind === "root" && record.name === "site")
|
|
24
|
+
);
|
|
25
|
+
const siteEntityLabels = siteEntityConfig?.meta?.labels ?? {};
|
|
26
|
+
const {
|
|
27
|
+
title: siteTitleEdit,
|
|
28
|
+
description: siteDescriptionEdit,
|
|
29
|
+
site_logo: siteLogoEdit,
|
|
30
|
+
site_icon: siteIconEdit,
|
|
31
|
+
...otherSiteEdits
|
|
32
|
+
} = siteEdits ?? {};
|
|
33
|
+
const orderedSiteProperties = [
|
|
34
|
+
siteTitleEdit !== void 0 && "title",
|
|
35
|
+
siteDescriptionEdit !== void 0 && "description",
|
|
36
|
+
siteLogoEdit !== void 0 && "site_logo",
|
|
37
|
+
siteIconEdit !== void 0 && "site_icon",
|
|
38
|
+
...Object.keys(otherSiteEdits)
|
|
39
|
+
].filter(Boolean);
|
|
40
|
+
const editedSiteEntities = orderedSiteProperties.map(
|
|
41
|
+
(property) => ({
|
|
42
|
+
kind: "root",
|
|
43
|
+
name: "site",
|
|
44
|
+
title: siteEntityLabels[property] || property,
|
|
45
|
+
property
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
return [...editedEntitiesWithoutSite, ...editedSiteEntities];
|
|
49
|
+
}, [editedEntities, siteEdits, siteEntityConfig]);
|
|
50
|
+
const [unselectedEntities, _setUnselectedEntities] = useState([]);
|
|
51
|
+
const setUnselectedEntities = ({ kind, name, key, property }, checked) => {
|
|
52
|
+
if (checked) {
|
|
53
|
+
_setUnselectedEntities(
|
|
54
|
+
unselectedEntities.filter(
|
|
55
|
+
(elt) => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
} else {
|
|
59
|
+
_setUnselectedEntities([
|
|
60
|
+
...unselectedEntities,
|
|
61
|
+
{ kind, name, key, property }
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
|
|
66
|
+
return {
|
|
67
|
+
dirtyEntityRecords,
|
|
68
|
+
isDirty,
|
|
69
|
+
setUnselectedEntities,
|
|
70
|
+
unselectedEntities
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
useIsDirty
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=use-is-dirty.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/entities-saved-states/hooks/use-is-dirty.js"],
|
|
4
|
+
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { useMemo, useState } from '@wordpress/element';\nimport { STORE_NAME } from '../../../name';\n\n/**\n * Custom hook that determines if any entities are dirty (edited) and provides a way to manage selected/unselected entities.\n *\n * @return {Object} An object containing the following properties:\n * - dirtyEntityRecords: An array of dirty entity records.\n * - isDirty: A boolean indicating if there are any dirty entity records.\n * - setUnselectedEntities: A function to set the unselected entities.\n * - unselectedEntities: An array of unselected entities.\n */\nexport const useIsDirty = () => {\n\tconst { editedEntities, siteEdits, siteEntityConfig } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__experimentalGetDirtyEntityRecords,\n\t\t\t\tgetEntityRecordEdits,\n\t\t\t\tgetEntityConfig,\n\t\t\t} = select( STORE_NAME );\n\n\t\t\treturn {\n\t\t\t\teditedEntities: __experimentalGetDirtyEntityRecords(),\n\t\t\t\tsiteEdits: getEntityRecordEdits( 'root', 'site' ),\n\t\t\t\tsiteEntityConfig: getEntityConfig( 'root', 'site' ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst dirtyEntityRecords = useMemo( () => {\n\t\t// Remove site object and decouple into its edited pieces.\n\t\tconst editedEntitiesWithoutSite = editedEntities.filter(\n\t\t\t( record ) => ! ( record.kind === 'root' && record.name === 'site' )\n\t\t);\n\n\t\tconst siteEntityLabels = siteEntityConfig?.meta?.labels ?? {};\n\t\tconst {\n\t\t\ttitle: siteTitleEdit,\n\t\t\tdescription: siteDescriptionEdit,\n\t\t\tsite_logo: siteLogoEdit,\n\t\t\tsite_icon: siteIconEdit,\n\t\t\t...otherSiteEdits\n\t\t} = siteEdits ?? {};\n\t\tconst orderedSiteProperties = [\n\t\t\tsiteTitleEdit !== undefined && 'title',\n\t\t\tsiteDescriptionEdit !== undefined && 'description',\n\t\t\tsiteLogoEdit !== undefined && 'site_logo',\n\t\t\tsiteIconEdit !== undefined && 'site_icon',\n\t\t\t...Object.keys( otherSiteEdits ),\n\t\t].filter( Boolean );\n\t\tconst editedSiteEntities = orderedSiteProperties.map(\n\t\t\t( property ) => ( {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t\ttitle: siteEntityLabels[ property ] || property,\n\t\t\t\tproperty,\n\t\t\t} )\n\t\t);\n\n\t\treturn [ ...editedEntitiesWithoutSite, ...editedSiteEntities ];\n\t}, [ editedEntities, siteEdits, siteEntityConfig ] );\n\n\t// Unchecked entities to be ignored by save function.\n\tconst [ unselectedEntities, _setUnselectedEntities ] = useState( [] );\n\n\tconst setUnselectedEntities = (\n\t\t{ kind, name, key, property },\n\t\tchecked\n\t) => {\n\t\tif ( checked ) {\n\t\t\t_setUnselectedEntities(\n\t\t\t\tunselectedEntities.filter(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind !== kind ||\n\t\t\t\t\t\telt.name !== name ||\n\t\t\t\t\t\telt.key !== key ||\n\t\t\t\t\t\telt.property !== property\n\t\t\t\t)\n\t\t\t);\n\t\t} else {\n\t\t\t_setUnselectedEntities( [\n\t\t\t\t...unselectedEntities,\n\t\t\t\t{ kind, name, key, property },\n\t\t\t] );\n\t\t}\n\t};\n\n\tconst isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;\n\n\treturn {\n\t\tdirtyEntityRecords,\n\t\tisDirty,\n\t\tsetUnselectedEntities,\n\t\tunselectedEntities,\n\t};\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,gBAAgB;AAClC,SAAS,kBAAkB;AAWpB,IAAM,aAAa,MAAM;AAC/B,QAAM,EAAE,gBAAgB,WAAW,iBAAiB,IAAI;AAAA,IACvD,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,UAAW;AAEvB,aAAO;AAAA,QACN,gBAAgB,oCAAoC;AAAA,QACpD,WAAW,qBAAsB,QAAQ,MAAO;AAAA,QAChD,kBAAkB,gBAAiB,QAAQ,MAAO;AAAA,MACnD;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAEA,QAAM,qBAAqB,QAAS,MAAM;AAEzC,UAAM,4BAA4B,eAAe;AAAA,MAChD,CAAE,WAAY,EAAI,OAAO,SAAS,UAAU,OAAO,SAAS;AAAA,IAC7D;AAEA,UAAM,mBAAmB,kBAAkB,MAAM,UAAU,CAAC;AAC5D,UAAM;AAAA,MACL,OAAO;AAAA,MACP,aAAa;AAAA,MACb,WAAW;AAAA,MACX,WAAW;AAAA,MACX,GAAG;AAAA,IACJ,IAAI,aAAa,CAAC;AAClB,UAAM,wBAAwB;AAAA,MAC7B,kBAAkB,UAAa;AAAA,MAC/B,wBAAwB,UAAa;AAAA,MACrC,iBAAiB,UAAa;AAAA,MAC9B,iBAAiB,UAAa;AAAA,MAC9B,GAAG,OAAO,KAAM,cAAe;AAAA,IAChC,EAAE,OAAQ,OAAQ;AAClB,UAAM,qBAAqB,sBAAsB;AAAA,MAChD,CAAE,cAAgB;AAAA,QACjB,MAAM;AAAA,QACN,MAAM;AAAA,QACN,OAAO,iBAAkB,QAAS,KAAK;AAAA,QACvC;AAAA,MACD;AAAA,IACD;AAEA,WAAO,CAAE,GAAG,2BAA2B,GAAG,kBAAmB;AAAA,EAC9D,GAAG,CAAE,gBAAgB,WAAW,gBAAiB,CAAE;AAGnD,QAAM,CAAE,oBAAoB,sBAAuB,IAAI,SAAU,CAAC,CAAE;AAEpE,QAAM,wBAAwB,CAC7B,EAAE,MAAM,MAAM,KAAK,SAAS,GAC5B,YACI;AACJ,QAAK,SAAU;AACd;AAAA,QACC,mBAAmB;AAAA,UAClB,CAAE,QACD,IAAI,SAAS,QACb,IAAI,SAAS,QACb,IAAI,QAAQ,OACZ,IAAI,aAAa;AAAA,QACnB;AAAA,MACD;AAAA,IACD,OAAO;AACN,6BAAwB;AAAA,QACvB,GAAG;AAAA,QACH,EAAE,MAAM,MAAM,KAAK,SAAS;AAAA,MAC7B,CAAE;AAAA,IACH;AAAA,EACD;AAEA,QAAM,UAAU,mBAAmB,SAAS,mBAAmB,SAAS;AAExE,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// packages/core-data/src/components/entities-saved-states/index.js
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { Button, Flex, FlexItem } from "@wordpress/components";
|
|
4
|
+
import { __, _n, sprintf } from "@wordpress/i18n";
|
|
5
|
+
import {
|
|
6
|
+
useCallback,
|
|
7
|
+
useRef,
|
|
8
|
+
createInterpolateElement
|
|
9
|
+
} from "@wordpress/element";
|
|
10
|
+
import {
|
|
11
|
+
__experimentalUseDialog as useDialog,
|
|
12
|
+
useInstanceId
|
|
13
|
+
} from "@wordpress/compose";
|
|
14
|
+
import { useDispatch } from "@wordpress/data";
|
|
15
|
+
import EntityTypeList from "./entity-type-list.mjs";
|
|
16
|
+
import { useIsDirty } from "./hooks/use-is-dirty.mjs";
|
|
17
|
+
import { unlock } from "../../lock-unlock.mjs";
|
|
18
|
+
import { STORE_NAME } from "../../name.mjs";
|
|
19
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
function EntitiesSavedStates({
|
|
21
|
+
close,
|
|
22
|
+
renderDialog,
|
|
23
|
+
variant
|
|
24
|
+
}) {
|
|
25
|
+
const isDirtyProps = useIsDirty();
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
EntitiesSavedStatesExtensible,
|
|
28
|
+
{
|
|
29
|
+
close,
|
|
30
|
+
renderDialog,
|
|
31
|
+
variant,
|
|
32
|
+
...isDirtyProps
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function EntitiesSavedStatesExtensible({
|
|
37
|
+
additionalPrompt = void 0,
|
|
38
|
+
close,
|
|
39
|
+
onSave = void 0,
|
|
40
|
+
saveEnabled: saveEnabledProp = void 0,
|
|
41
|
+
saveLabel = __("Save"),
|
|
42
|
+
renderDialog,
|
|
43
|
+
dirtyEntityRecords,
|
|
44
|
+
isDirty,
|
|
45
|
+
setUnselectedEntities,
|
|
46
|
+
unselectedEntities,
|
|
47
|
+
variant = "default",
|
|
48
|
+
successNoticeContent
|
|
49
|
+
}) {
|
|
50
|
+
const saveButtonRef = useRef();
|
|
51
|
+
const { saveDirtyEntities } = unlock(useDispatch(STORE_NAME));
|
|
52
|
+
const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
|
|
53
|
+
const { name } = record;
|
|
54
|
+
if (!acc[name]) {
|
|
55
|
+
acc[name] = [];
|
|
56
|
+
}
|
|
57
|
+
acc[name].push(record);
|
|
58
|
+
return acc;
|
|
59
|
+
}, {});
|
|
60
|
+
const {
|
|
61
|
+
site: siteSavables,
|
|
62
|
+
wp_template: templateSavables,
|
|
63
|
+
wp_template_part: templatePartSavables,
|
|
64
|
+
...contentSavables
|
|
65
|
+
} = partitionedSavables;
|
|
66
|
+
const sortedPartitionedSavables = [
|
|
67
|
+
siteSavables,
|
|
68
|
+
templateSavables,
|
|
69
|
+
templatePartSavables,
|
|
70
|
+
...Object.values(contentSavables)
|
|
71
|
+
].filter(Array.isArray);
|
|
72
|
+
const saveEnabled = saveEnabledProp ?? isDirty;
|
|
73
|
+
const dismissPanel = useCallback(() => close(), [close]);
|
|
74
|
+
const [saveDialogRef, saveDialogProps] = useDialog({
|
|
75
|
+
onClose: () => dismissPanel()
|
|
76
|
+
});
|
|
77
|
+
const dialogLabelId = useInstanceId(
|
|
78
|
+
EntitiesSavedStatesExtensible,
|
|
79
|
+
"entities-saved-states__panel-label"
|
|
80
|
+
);
|
|
81
|
+
const dialogDescriptionId = useInstanceId(
|
|
82
|
+
EntitiesSavedStatesExtensible,
|
|
83
|
+
"entities-saved-states__panel-description"
|
|
84
|
+
);
|
|
85
|
+
const selectItemsToSaveDescription = !!dirtyEntityRecords.length ? __("Select the items you want to save.") : void 0;
|
|
86
|
+
const isInline = variant === "inline";
|
|
87
|
+
const actionButtons = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
88
|
+
/* @__PURE__ */ jsx(
|
|
89
|
+
FlexItem,
|
|
90
|
+
{
|
|
91
|
+
isBlock: isInline ? false : true,
|
|
92
|
+
as: Button,
|
|
93
|
+
variant: isInline ? "tertiary" : "secondary",
|
|
94
|
+
size: isInline ? void 0 : "compact",
|
|
95
|
+
onClick: dismissPanel,
|
|
96
|
+
children: __("Cancel")
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
FlexItem,
|
|
101
|
+
{
|
|
102
|
+
isBlock: isInline ? false : true,
|
|
103
|
+
as: Button,
|
|
104
|
+
ref: saveButtonRef,
|
|
105
|
+
variant: "primary",
|
|
106
|
+
size: isInline ? void 0 : "compact",
|
|
107
|
+
disabled: !saveEnabled,
|
|
108
|
+
accessibleWhenDisabled: true,
|
|
109
|
+
onClick: () => saveDirtyEntities({
|
|
110
|
+
onSave,
|
|
111
|
+
dirtyEntityRecords,
|
|
112
|
+
entitiesToSkip: unselectedEntities,
|
|
113
|
+
close,
|
|
114
|
+
successNoticeContent
|
|
115
|
+
}),
|
|
116
|
+
className: "entities-saved-states__save-button",
|
|
117
|
+
children: saveLabel
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
] });
|
|
121
|
+
return /* @__PURE__ */ jsxs(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
ref: renderDialog ? saveDialogRef : void 0,
|
|
125
|
+
...renderDialog && saveDialogProps,
|
|
126
|
+
className: clsx("entities-saved-states__panel", {
|
|
127
|
+
"is-inline": isInline
|
|
128
|
+
}),
|
|
129
|
+
role: renderDialog ? "dialog" : void 0,
|
|
130
|
+
"aria-labelledby": renderDialog ? dialogLabelId : void 0,
|
|
131
|
+
"aria-describedby": renderDialog ? dialogDescriptionId : void 0,
|
|
132
|
+
children: [
|
|
133
|
+
!isInline && /* @__PURE__ */ jsx(Flex, { className: "entities-saved-states__panel-header", gap: 2, children: actionButtons }),
|
|
134
|
+
/* @__PURE__ */ jsxs("div", { className: "entities-saved-states__text-prompt", children: [
|
|
135
|
+
/* @__PURE__ */ jsx("div", { className: "entities-saved-states__text-prompt--header-wrapper", children: /* @__PURE__ */ jsx(
|
|
136
|
+
"strong",
|
|
137
|
+
{
|
|
138
|
+
id: renderDialog ? dialogLabelId : void 0,
|
|
139
|
+
className: "entities-saved-states__text-prompt--header",
|
|
140
|
+
children: __("Are you ready to save?")
|
|
141
|
+
}
|
|
142
|
+
) }),
|
|
143
|
+
/* @__PURE__ */ jsxs("div", { id: renderDialog ? dialogDescriptionId : void 0, children: [
|
|
144
|
+
additionalPrompt,
|
|
145
|
+
/* @__PURE__ */ jsx("p", { className: "entities-saved-states__text-prompt--changes-count", children: isDirty ? createInterpolateElement(
|
|
146
|
+
sprintf(
|
|
147
|
+
/* translators: %d: number of site changes waiting to be saved. */
|
|
148
|
+
_n(
|
|
149
|
+
"There is <strong>%d site change</strong> waiting to be saved.",
|
|
150
|
+
"There are <strong>%d site changes</strong> waiting to be saved.",
|
|
151
|
+
dirtyEntityRecords.length
|
|
152
|
+
),
|
|
153
|
+
dirtyEntityRecords.length
|
|
154
|
+
),
|
|
155
|
+
{ strong: /* @__PURE__ */ jsx("strong", {}) }
|
|
156
|
+
) : selectItemsToSaveDescription })
|
|
157
|
+
] })
|
|
158
|
+
] }),
|
|
159
|
+
sortedPartitionedSavables.map((list) => {
|
|
160
|
+
return /* @__PURE__ */ jsx(
|
|
161
|
+
EntityTypeList,
|
|
162
|
+
{
|
|
163
|
+
list,
|
|
164
|
+
unselectedEntities,
|
|
165
|
+
setUnselectedEntities
|
|
166
|
+
},
|
|
167
|
+
list[0].name
|
|
168
|
+
);
|
|
169
|
+
}),
|
|
170
|
+
isInline && /* @__PURE__ */ jsx(
|
|
171
|
+
Flex,
|
|
172
|
+
{
|
|
173
|
+
direction: "row",
|
|
174
|
+
justify: "flex-end",
|
|
175
|
+
className: "entities-saved-states__panel-footer",
|
|
176
|
+
children: actionButtons
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
export {
|
|
184
|
+
EntitiesSavedStatesExtensible,
|
|
185
|
+
EntitiesSavedStates as default
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/entities-saved-states/index.js"],
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseCallback,\n\tuseRef,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport {\n\t__experimentalUseDialog as useDialog,\n\tuseInstanceId,\n} from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport EntityTypeList from './entity-type-list';\nimport { useIsDirty } from './hooks/use-is-dirty';\nimport { unlock } from '../../lock-unlock';\nimport { STORE_NAME } from '../../name';\n\n/**\n * Renders the component for managing saved states of entities.\n *\n * @param {Object} props The component props.\n * @param {Function} props.close The function to close the dialog.\n * @param {boolean=} props.renderDialog Whether to render the component with modal dialog behavior.\n * @param {string} props.variant Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function EntitiesSavedStates( {\n\tclose,\n\trenderDialog,\n\tvariant,\n} ) {\n\tconst isDirtyProps = useIsDirty();\n\treturn (\n\t\t<EntitiesSavedStatesExtensible\n\t\t\tclose={ close }\n\t\t\trenderDialog={ renderDialog }\n\t\t\tvariant={ variant }\n\t\t\t{ ...isDirtyProps }\n\t\t/>\n\t);\n}\n\n/**\n * Renders a panel for saving entities with dirty records.\n *\n * @param {Object} props The component props.\n * @param {string} props.additionalPrompt Additional prompt to display.\n * @param {Function} props.close Function to close the panel.\n * @param {Function} props.onSave Function to call when saving entities.\n * @param {boolean} props.saveEnabled Flag indicating if save is enabled.\n * @param {string} props.saveLabel Label for the save button.\n * @param {boolean} props.renderDialog Whether to render the component with modal dialog behavior.\n * @param {Array} props.dirtyEntityRecords Array of dirty entity records.\n * @param {boolean} props.isDirty Flag indicating if there are dirty entities.\n * @param {Function} props.setUnselectedEntities Function to set unselected entities.\n * @param {Array} props.unselectedEntities Array of unselected entities.\n * @param {string} props.variant Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start.\n * @param {string} props.successNoticeContent Optional custom success notice content.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport function EntitiesSavedStatesExtensible( {\n\tadditionalPrompt = undefined,\n\tclose,\n\tonSave = undefined,\n\tsaveEnabled: saveEnabledProp = undefined,\n\tsaveLabel = __( 'Save' ),\n\trenderDialog,\n\tdirtyEntityRecords,\n\tisDirty,\n\tsetUnselectedEntities,\n\tunselectedEntities,\n\tvariant = 'default',\n\tsuccessNoticeContent,\n} ) {\n\tconst saveButtonRef = useRef();\n\tconst { saveDirtyEntities } = unlock( useDispatch( STORE_NAME ) );\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\tconst saveEnabled = saveEnabledProp ?? isDirty;\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\tconst dialogLabelId = useInstanceId(\n\t\tEntitiesSavedStatesExtensible,\n\t\t'entities-saved-states__panel-label'\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tEntitiesSavedStatesExtensible,\n\t\t'entities-saved-states__panel-description'\n\t);\n\n\tconst selectItemsToSaveDescription = !! dirtyEntityRecords.length\n\t\t? __( 'Select the items you want to save.' )\n\t\t: undefined;\n\n\tconst isInline = variant === 'inline';\n\n\tconst actionButtons = (\n\t\t<>\n\t\t\t<FlexItem\n\t\t\t\tisBlock={ isInline ? false : true }\n\t\t\t\tas={ Button }\n\t\t\t\tvariant={ isInline ? 'tertiary' : 'secondary' }\n\t\t\t\tsize={ isInline ? undefined : 'compact' }\n\t\t\t\tonClick={ dismissPanel }\n\t\t\t>\n\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t</FlexItem>\n\t\t\t<FlexItem\n\t\t\t\tisBlock={ isInline ? false : true }\n\t\t\t\tas={ Button }\n\t\t\t\tref={ saveButtonRef }\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tsize={ isInline ? undefined : 'compact' }\n\t\t\t\tdisabled={ ! saveEnabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsaveDirtyEntities( {\n\t\t\t\t\t\tonSave,\n\t\t\t\t\t\tdirtyEntityRecords,\n\t\t\t\t\t\tentitiesToSkip: unselectedEntities,\n\t\t\t\t\t\tclose,\n\t\t\t\t\t\tsuccessNoticeContent,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tclassName=\"entities-saved-states__save-button\"\n\t\t\t>\n\t\t\t\t{ saveLabel }\n\t\t\t</FlexItem>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ renderDialog ? saveDialogRef : undefined }\n\t\t\t{ ...( renderDialog && saveDialogProps ) }\n\t\t\tclassName={ clsx( 'entities-saved-states__panel', {\n\t\t\t\t'is-inline': isInline,\n\t\t\t} ) }\n\t\t\trole={ renderDialog ? 'dialog' : undefined }\n\t\t\taria-labelledby={ renderDialog ? dialogLabelId : undefined }\n\t\t\taria-describedby={ renderDialog ? dialogDescriptionId : undefined }\n\t\t>\n\t\t\t{ ! isInline && (\n\t\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t\t{ actionButtons }\n\t\t\t\t</Flex>\n\t\t\t) }\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<div className=\"entities-saved-states__text-prompt--header-wrapper\">\n\t\t\t\t\t<strong\n\t\t\t\t\t\tid={ renderDialog ? dialogLabelId : undefined }\n\t\t\t\t\t\tclassName=\"entities-saved-states__text-prompt--header\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Are you ready to save?' ) }\n\t\t\t\t\t</strong>\n\t\t\t\t</div>\n\t\t\t\t<div id={ renderDialog ? dialogDescriptionId : undefined }>\n\t\t\t\t\t{ additionalPrompt }\n\t\t\t\t\t<p className=\"entities-saved-states__text-prompt--changes-count\">\n\t\t\t\t\t\t{ isDirty\n\t\t\t\t\t\t\t? createInterpolateElement(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %d: number of site changes waiting to be saved. */\n\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t'There is <strong>%d site change</strong> waiting to be saved.',\n\t\t\t\t\t\t\t\t\t\t\t'There are <strong>%d site changes</strong> waiting to be saved.',\n\t\t\t\t\t\t\t\t\t\t\tdirtyEntityRecords.length\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tdirtyEntityRecords.length\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{ strong: <strong /> }\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: selectItemsToSaveDescription }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\n\t\t\t{ isInline && (\n\t\t\t\t<Flex\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\tclassName=\"entities-saved-states__panel-footer\"\n\t\t\t\t>\n\t\t\t\t\t{ actionButtons }\n\t\t\t\t</Flex>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,QAAQ,MAAM,gBAAgB;AACvC,SAAS,IAAI,IAAI,eAAe;AAChC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC,2BAA2B;AAAA,EAC3B;AAAA,OACM;AACP,SAAS,mBAAmB;AAC5B,OAAO,oBAAoB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAmBzB,SA4FA,UA5FA,KA4FA,YA5FA;AAPa,SAAR,oBAAsC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,eAAe,WAAW;AAChC,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACE,GAAG;AAAA;AAAA,EACN;AAEF;AAqBO,SAAS,8BAA+B;AAAA,EAC9C,mBAAmB;AAAA,EACnB;AAAA,EACA,SAAS;AAAA,EACT,aAAa,kBAAkB;AAAA,EAC/B,YAAY,GAAI,MAAO;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AACD,GAAI;AACH,QAAM,gBAAgB,OAAO;AAC7B,QAAM,EAAE,kBAAkB,IAAI,OAAQ,YAAa,UAAW,CAAE;AAEhE,QAAM,sBAAsB,mBAAmB,OAAQ,CAAE,KAAK,WAAY;AACzE,UAAM,EAAE,KAAK,IAAI;AACjB,QAAK,CAAE,IAAK,IAAK,GAAI;AACpB,UAAK,IAAK,IAAI,CAAC;AAAA,IAChB;AACA,QAAK,IAAK,EAAE,KAAM,MAAO;AACzB,WAAO;AAAA,EACR,GAAG,CAAC,CAAE;AAGN,QAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,kBAAkB;AAAA,IAClB,GAAG;AAAA,EACJ,IAAI;AACJ,QAAM,4BAA4B;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG,OAAO,OAAQ,eAAgB;AAAA,EACnC,EAAE,OAAQ,MAAM,OAAQ;AAExB,QAAM,cAAc,mBAAmB;AAGvC,QAAM,eAAe,YAAa,MAAM,MAAM,GAAG,CAAE,KAAM,CAAE;AAE3D,QAAM,CAAE,eAAe,eAAgB,IAAI,UAAW;AAAA,IACrD,SAAS,MAAM,aAAa;AAAA,EAC7B,CAAE;AACF,QAAM,gBAAgB;AAAA,IACrB;AAAA,IACA;AAAA,EACD;AACA,QAAM,sBAAsB;AAAA,IAC3B;AAAA,IACA;AAAA,EACD;AAEA,QAAM,+BAA+B,CAAC,CAAE,mBAAmB,SACxD,GAAI,oCAAqC,IACzC;AAEH,QAAM,WAAW,YAAY;AAE7B,QAAM,gBACL,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,SAAU,WAAW,QAAQ;AAAA,QAC7B,IAAK;AAAA,QACL,SAAU,WAAW,aAAa;AAAA,QAClC,MAAO,WAAW,SAAY;AAAA,QAC9B,SAAU;AAAA,QAER,aAAI,QAAS;AAAA;AAAA,IAChB;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,SAAU,WAAW,QAAQ;AAAA,QAC7B,IAAK;AAAA,QACL,KAAM;AAAA,QACN,SAAQ;AAAA,QACR,MAAO,WAAW,SAAY;AAAA,QAC9B,UAAW,CAAE;AAAA,QACb,wBAAsB;AAAA,QACtB,SAAU,MACT,kBAAmB;AAAA,UAClB;AAAA,UACA;AAAA,UACA,gBAAgB;AAAA,UAChB;AAAA,UACA;AAAA,QACD,CAAE;AAAA,QAEH,WAAU;AAAA,QAER;AAAA;AAAA,IACH;AAAA,KACD;AAGD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,KAAM,eAAe,gBAAgB;AAAA,MACnC,GAAK,gBAAgB;AAAA,MACvB,WAAY,KAAM,gCAAgC;AAAA,QACjD,aAAa;AAAA,MACd,CAAE;AAAA,MACF,MAAO,eAAe,WAAW;AAAA,MACjC,mBAAkB,eAAe,gBAAgB;AAAA,MACjD,oBAAmB,eAAe,sBAAsB;AAAA,MAEtD;AAAA,SAAE,YACH,oBAAC,QAAK,WAAU,uCAAsC,KAAM,GACzD,yBACH;AAAA,QAGD,qBAAC,SAAI,WAAU,sCACd;AAAA,8BAAC,SAAI,WAAU,sDACd;AAAA,YAAC;AAAA;AAAA,cACA,IAAK,eAAe,gBAAgB;AAAA,cACpC,WAAU;AAAA,cAER,aAAI,wBAAyB;AAAA;AAAA,UAChC,GACD;AAAA,UACA,qBAAC,SAAI,IAAK,eAAe,sBAAsB,QAC5C;AAAA;AAAA,YACF,oBAAC,OAAE,WAAU,qDACV,oBACC;AAAA,cACA;AAAA;AAAA,gBAEC;AAAA,kBACC;AAAA,kBACA;AAAA,kBACA,mBAAmB;AAAA,gBACpB;AAAA,gBACA,mBAAmB;AAAA,cACpB;AAAA,cACA,EAAE,QAAQ,oBAAC,YAAO,EAAG;AAAA,YACrB,IACA,8BACJ;AAAA,aACD;AAAA,WACD;AAAA,QAEE,0BAA0B,IAAK,CAAE,SAAU;AAC5C,iBACC;AAAA,YAAC;AAAA;AAAA,cAEA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,YAHM,KAAM,CAAE,EAAE;AAAA,UAIjB;AAAA,QAEF,CAAE;AAAA,QAEA,YACD;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,SAAQ;AAAA,YACR,WAAU;AAAA,YAER;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/dynamic-entities.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import type { GetRecordsHttpQuery, State } from './selectors';\nimport type * as ET from './entity-types';\n\nexport type WPEntityTypes< C extends ET.Context = 'edit' > = {\n\tComment: ET.Comment< C >;\n\tGlobalStyles: ET.GlobalStylesRevision< C >;\n\tMedia: ET.Attachment< C >;\n\tMenu: ET.NavMenu< C >;\n\tMenuItem: ET.NavMenuItem< C >;\n\tMenuLocation: ET.MenuLocation< C >;\n\tPlugin: ET.Plugin< C >;\n\tPostType: ET.Type< C >;\n\tRevision: ET.PostRevision< C >;\n\tSidebar: ET.Sidebar< C >;\n\tSite: ET.Settings< C >;\n\tStatus: ET.PostStatusObject< C >;\n\tTaxonomy: ET.Taxonomy< C >;\n\tTerm: ET.Term< C >;\n\tTheme: ET.Theme< C >;\n\tUnstableBase: ET.UnstableBase< C >;\n\tUser: ET.User< C >;\n\tWidget: ET.Widget< C >;\n\tWidgetType: ET.WidgetType< C >;\n};\n\n/**\n * A simple utility that pluralizes a string.\n * Converts:\n * - \"post\" to \"posts\"\n * - \"taxonomy\" to \"taxonomies\"\n * - \"media\" to \"mediaItems\"\n * - \"status\" to \"statuses\"\n *\n * It does not pluralize \"GlobalStyles\" due to lack of clarity about it at time of writing.\n */\ntype PluralizeEntity< T extends string > = T extends 'GlobalStyles'\n\t? never\n\t: T extends 'Media'\n\t? 'MediaItems'\n\t: T extends 'Status'\n\t? 'Statuses'\n\t: T extends `${ infer U }y`\n\t? `${ U }ies`\n\t: `${ T }s`;\n\n/**\n * A simple utility that singularizes a string.\n *\n * Converts:\n * - \"posts\" to \"post\"\n * - \"taxonomies\" to \"taxonomy\"\n * - \"mediaItems\" to \"media\"\n * - \"statuses\" to \"status\"\n */\ntype SingularizeEntity< T extends string > = T extends 'MediaItems'\n\t? 'Media'\n\t: T extends 'Statuses'\n\t? 'Status'\n\t: T extends `${ infer U }ies`\n\t? `${ U }y`\n\t: T extends `${ infer U }s`\n\t? U\n\t: T;\n\nexport type SingularGetters = {\n\t[ Key in `get${ keyof WPEntityTypes }` ]: (\n\t\tstate: State,\n\t\tid: number | string,\n\t\tquery?: GetRecordsHttpQuery\n\t) => WPEntityTypes[ Key extends `get${ infer E }` ? E : never ] | undefined;\n};\n\nexport type PluralGetters = {\n\t[ Key in `get${ PluralizeEntity< keyof WPEntityTypes > }` ]: (\n\t\tstate: State,\n\t\tquery?: GetRecordsHttpQuery\n\t) => Array<\n\t\tWPEntityTypes[ Key extends `get${ infer E }`\n\t\t\t? SingularizeEntity< E >\n\t\t\t: never ]\n\t> | null;\n};\n\ntype ActionOptions = {\n\tthrowOnError?: boolean;\n};\n\ntype DeleteRecordsHttpQuery = Record< string, any >;\n\nexport type SaveActions = {\n\t[ Key in `save${ keyof WPEntityTypes }` ]: (\n\t\tdata: Partial<\n\t\t\tWPEntityTypes[ Key extends `save${ infer E }` ? E : never ]\n\t\t>,\n\t\toptions?: ActionOptions\n\t) => Promise< void >;\n};\n\nexport type DeleteActions = {\n\t[ Key in `delete${ keyof WPEntityTypes }` ]: (\n\t\tid: number | string,\n\t\tquery?: DeleteRecordsHttpQuery,\n\t\toptions?: ActionOptions\n\t) => Promise< void >;\n};\n\nexport let dynamicActions: SaveActions & DeleteActions;\n\nexport let dynamicSelectors: SingularGetters & PluralGetters;\n"],
|
|
5
|
+
"mappings": ";AA0GO,IAAI;AAEJ,IAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|