@wordpress/fields 0.25.3-next.36001005c.0 → 0.26.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 +2 -0
- package/build/actions/duplicate-post.js +3 -3
- package/build/actions/duplicate-post.js.map +2 -2
- package/build/actions/reset-post.js +6 -15
- package/build/actions/reset-post.js.map +2 -2
- package/build/actions/trash-post.js +1 -1
- package/build/actions/trash-post.js.map +2 -2
- package/build/fields/featured-image/featured-image-edit.js +88 -59
- package/build/fields/featured-image/featured-image-edit.js.map +3 -3
- package/build-module/actions/duplicate-post.js +3 -3
- package/build-module/actions/duplicate-post.js.map +2 -2
- package/build-module/actions/reset-post.js +7 -16
- package/build-module/actions/reset-post.js.map +2 -2
- package/build-module/actions/trash-post.js +1 -1
- package/build-module/actions/trash-post.js.map +2 -2
- package/build-module/fields/featured-image/featured-image-edit.js +93 -61
- package/build-module/fields/featured-image/featured-image-edit.js.map +2 -2
- package/build-types/actions/duplicate-post.d.ts.map +1 -1
- package/build-types/actions/reset-post.d.ts +2 -2
- package/build-types/actions/reset-post.d.ts.map +1 -1
- package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -1
- package/package.json +26 -26
- package/src/actions/duplicate-post.tsx +3 -7
- package/src/actions/reset-post.tsx +15 -30
- package/src/actions/trash-post.tsx +1 -1
- package/src/fields/featured-image/featured-image-edit.tsx +113 -66
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/actions/reset-post.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { dispatch, select, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\n// @ts-ignore\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { dispatch, select, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\n// @ts-ignore\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from './utils';\nimport type { CoreDataError, TemplatePart } from '../types';\n\nconst isTemplateRevertable = ( templateOrTemplatePart: TemplatePart ) => {\n\tif ( ! templateOrTemplatePart ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\ttemplateOrTemplatePart.source === 'custom' &&\n\t\t( Boolean( templateOrTemplatePart?.plugin ) ||\n\t\t\ttemplateOrTemplatePart?.has_theme_file )\n\t);\n};\n\n/**\n * Copied - pasted from https://github.com/WordPress/gutenberg/blob/bf1462ad37d4637ebbf63270b9c244b23c69e2a8/packages/editor/src/store/private-actions.js#L233-L365\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nconst revertTemplate = async (\n\ttemplate: TemplatePart,\n\t{ allowUndo = true } = {}\n) => {\n\tconst noticeId = 'edit-site-template-reverted';\n\tdispatch( noticesStore ).removeNotice( noticeId );\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tdispatch( noticesStore ).createErrorNotice(\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t}\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\n\t\tif ( ! templateEntityConfig ) {\n\t\t\tdispatch( noticesStore ).createErrorNotice(\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: template.origin }\n\t\t);\n\n\t\tconst fileTemplate = ( await apiFetch( {\n\t\t\tpath: fileTemplatePath,\n\t\t} ) ) as any;\n\t\tif ( ! fileTemplate ) {\n\t\t\tdispatch( noticesStore ).createErrorNotice(\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\n\t\tconst edited = select( coreStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t) as any;\n\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\n\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = () => {\n\t\t\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\tedited.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t};\n\n\t\t\tdispatch( noticesStore ).createSuccessNotice(\n\t\t\t\t__( 'Template reset.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: noticeId,\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\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}\n\t} catch ( error: any ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\n\t\tdispatch( noticesStore ).createErrorNotice( errorMessage, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}\n};\n\nconst resetPostAction: Action< TemplatePart > = {\n\tid: 'reset-post',\n\tlabel: __( 'Reset' ),\n\tisEligible: ( item ) => {\n\t\treturn (\n\t\t\titem.type === 'wp_template_part' &&\n\t\t\titem?.source === 'custom' &&\n\t\t\titem?.has_theme_file\n\t\t);\n\t},\n\ticon: backup,\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tmodalFocusOnMount: 'firstContentElement',\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\t\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst onConfirm = async () => {\n\t\t\ttry {\n\t\t\t\tfor ( const template of items ) {\n\t\t\t\t\tawait revertTemplate( template, {\n\t\t\t\t\t\tallowUndo: false,\n\t\t\t\t\t} );\n\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\ttemplate.id\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\titems.length > 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %d: The number of items. */\n\t\t\t\t\t\t\t\t__( '%d items reset.' ),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t ),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: 'revert-template-action',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tconst fallbackErrorMessage =\n\t\t\t\t\titems.length === 1\n\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t'An error occurred while reverting the template part.'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t'An error occurred while reverting the template parts.'\n\t\t\t\t\t\t );\n\n\t\t\t\tconst typedError = error as CoreDataError;\n\t\t\t\tconst errorMessage =\n\t\t\t\t\ttypedError.message && typedError.code !== 'unknown_error'\n\t\t\t\t\t\t? typedError.message\n\t\t\t\t\t\t: fallbackErrorMessage;\n\n\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t}\n\t\t};\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ __( 'Reset to default and clear all customizations?' ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tawait onConfirm();\n\t\t\t\t\t\t\tonActionPerformed?.( items );\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\n/**\n * Reset action for Template and TemplatePart.\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WAAW,UACX;AAEJ,0BAAmB,cAAc,EAAE,MAAM,WAAW,CAAE;AAAA,MACvD;AAAA,IACD;AACA,WACC,qBAAC,UAAO,SAAQ,KACf;AAAA,0BAAC,QACE,aAAI,gDAAiD,GACxD;AAAA,MACA,qBAAC,UAAO,SAAQ,SACf;AAAA;AAAA,UAAC;AAAA;AAAA,YACA,uBAAqB;AAAA,YACrB,SAAQ;AAAA,YACR,SAAU;AAAA,YACV,UAAW;AAAA,YACX,wBAAsB;AAAA,YAEpB,aAAI,QAAS;AAAA;AAAA,QAChB;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,uBAAqB;AAAA,YACrB,SAAQ;AAAA,YACR,SAAU,YAAY;AACrB,wBAAW,IAAK;AAChB,oBAAM,UAAU;AAChB,kCAAqB,KAAM;AAC3B,wBAAW,KAAM;AACjB,2BAAa;AAAA,YACd;AAAA,YACA;AAAA,YACA,UAAW;AAAA,YACX,wBAAsB;AAAA,YAEpB,aAAI,OAAQ;AAAA;AAAA,QACf;AAAA,SACD;AAAA,OACD;AAAA,EAEF;AACD;AAKA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/actions/trash-post.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst trashPost: Action< PostWithPermissions > = {\n\tid: 'move-to-trash',\n\tlabel: __( '
|
|
5
|
-
"mappings": "AAiDI,cAmBA,YAnBA;AA9CJ,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,SAAS,iBAAiB;AACnC,SAAS,IAAI,IAAI,SAAS,UAAU;AACpC,SAAS,SAAS,oBAAoB;AACtC,SAAS,gBAAgB;AACzB;AAAA,EACC;AAAA,EACA,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AAMP,SAAS,oBAAoB;AAG7B,MAAM,YAA2C;AAAA,EAChD,IAAI;AAAA,EACJ,OAAO,GAAI,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst trashPost: Action< PostWithPermissions > = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( item.type === 'wp_template_part' || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn (\n\t\t\t!! item.status &&\n\t\t\t! [ 'auto-draft', 'trash' ].includes( item.status ) &&\n\t\t\titem.permissions?.delete\n\t\t);\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tmodalFocusOnMount: 'firstContentElement',\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ items.length === 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The item's title.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move \"%s\" to the trash?'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: The number of items (2 or more).\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d item to the trash ?',\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d items to the trash ?',\n\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\t\t\t\titems.map( ( item ) =>\n\t\t\t\t\t\t\t\t\tdeleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\titem.type,\n\t\t\t\t\t\t\t\t\t\titem.id.toString(),\n\t\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t// If all the promises were fulfilled with success.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpromiseResult.every(\n\t\t\t\t\t\t\t\t\t( { status } ) => status === 'fulfilled'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tlet successMessage;\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: The item's title. */\n\t\t\t\t\t\t\t\t\t\t__( '\"%s\" moved to the trash.' ),\n\t\t\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %d: The number of items. */\n\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t'%d item moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\t'%d items moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tid: 'move-to-trash-action',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If there was at least one failure.\n\t\t\t\t\t\t\t\tlet errorMessage;\n\t\t\t\t\t\t\t\t// If we were trying to delete a single item.\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage =\n\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// If we were trying to delete multiple items.\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst errorMessages = new Set< string >();\n\t\t\t\t\t\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\t\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\t\terrorMessages.add(\n\t\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the items to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while moving the items to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\t\t\tonActionPerformed( items );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x( 'Trash', 'verb' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\n/**\n * Trash action for P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ACpC,CAAE,EAAE,OAAO,MAAO,WAAW;AAAA,kBAC9B;AACA,6BAAY,iBAAiB,gBAAiB;AAC7C,0BAAM,aAAa;AAGnB,wBAAK,WAAW,QAAQ,SAAU;AACjC,oCAAc;AAAA,wBACb,WAAW,OAAO;AAAA,sBACnB;AAAA,oBACD;AAAA,kBACD;AACA,sBAAK,cAAc,SAAS,GAAI;AAC/B,mCAAe;AAAA,sBACd;AAAA,oBACD;AAAA,kBACD,WAAY,cAAc,SAAS,GAAI;AACtC,mCAAe;AAAA;AAAA,sBAEd;AAAA,wBACC;AAAA,sBACD;AAAA,sBACA,CAAE,GAAG,aAAc,EAAG,CAAE;AAAA,oBACzB;AAAA,kBACD,OAAO;AACN,mCAAe;AAAA;AAAA,sBAEd;AAAA,wBACC;AAAA,sBACD;AAAA,sBACA,CAAE,GAAG,aAAc,EAAE,KAAM,GAAI;AAAA,oBAChC;AAAA,kBACD;AAAA,gBACD;AACA,kCAAmB,cAAc;AAAA,kBAChC,MAAM;AAAA,gBACP,CAAE;AAAA,cACH;AACA,kBAAK,mBAAoB;AACxB,kCAAmB,KAAM;AAAA,cAC1B;AACA,wBAAW,KAAM;AACjB,2BAAa;AAAA,YACd;AAAA,YACA;AAAA,YACA,UAAW;AAAA,YACX,wBAAsB;AAAA,YAEpB,aAAI,SAAS,MAAO;AAAA;AAAA,QACvB;AAAA,SACD;AAAA,OACD;AAAA,EAEF;AACD;AAKA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,40 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, __experimentalGrid as Grid } from "@wordpress/components";
|
|
3
3
|
import { useSelect } from "@wordpress/data";
|
|
4
|
-
import { useCallback, useRef } from "@wordpress/element";
|
|
5
|
-
import {
|
|
4
|
+
import { useCallback, useRef, useState } from "@wordpress/element";
|
|
5
|
+
import {
|
|
6
|
+
privateApis as mediaUtilsPrivateApis,
|
|
7
|
+
MediaUpload
|
|
8
|
+
} from "@wordpress/media-utils";
|
|
6
9
|
import { lineSolid } from "@wordpress/icons";
|
|
7
10
|
import { store as coreStore } from "@wordpress/core-data";
|
|
8
11
|
import { __ } from "@wordpress/i18n";
|
|
12
|
+
import { unlock } from "../../lock-unlock";
|
|
13
|
+
const { MediaUploadModal } = unlock(mediaUtilsPrivateApis);
|
|
14
|
+
function ConditionalMediaUpload({ render, ...props }) {
|
|
15
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
16
|
+
if (window.__experimentalDataViewsMediaModal) {
|
|
17
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
18
|
+
render && render({ open: () => setIsModalOpen(true) }),
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
MediaUploadModal,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
isOpen: isModalOpen,
|
|
24
|
+
onClose: () => {
|
|
25
|
+
setIsModalOpen(false);
|
|
26
|
+
props.onClose?.();
|
|
27
|
+
},
|
|
28
|
+
onSelect: (media) => {
|
|
29
|
+
setIsModalOpen(false);
|
|
30
|
+
props.onSelect?.(media);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
] });
|
|
35
|
+
}
|
|
36
|
+
return /* @__PURE__ */ jsx(MediaUpload, { ...props, render });
|
|
37
|
+
}
|
|
9
38
|
const FeaturedImageEdit = ({
|
|
10
39
|
data,
|
|
11
40
|
field,
|
|
@@ -30,74 +59,77 @@ const FeaturedImageEdit = ({
|
|
|
30
59
|
const title = media?.title?.rendered;
|
|
31
60
|
const ref = useRef(null);
|
|
32
61
|
return /* @__PURE__ */ jsx("fieldset", { className: "fields-controls__featured-image", children: /* @__PURE__ */ jsx("div", { className: "fields-controls__featured-image-container", children: /* @__PURE__ */ jsx(
|
|
33
|
-
|
|
62
|
+
ConditionalMediaUpload,
|
|
34
63
|
{
|
|
35
64
|
onSelect: (selectedMedia) => {
|
|
36
65
|
onChangeControl(selectedMedia.id);
|
|
37
66
|
},
|
|
38
67
|
allowedTypes: ["image"],
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
68
|
+
value,
|
|
69
|
+
title: __("Select Featured Image"),
|
|
70
|
+
render: ({ open }) => /* @__PURE__ */ jsx(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
ref,
|
|
74
|
+
role: "button",
|
|
75
|
+
tabIndex: -1,
|
|
76
|
+
onClick: open,
|
|
77
|
+
onKeyDown: (event) => {
|
|
78
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
79
|
+
event.preventDefault();
|
|
47
80
|
open();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
className: "fields-controls__featured-image-image",
|
|
62
|
-
alt: "",
|
|
63
|
-
width: 24,
|
|
64
|
-
height: 24,
|
|
65
|
-
src: url
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
/* @__PURE__ */ jsx("span", { className: "fields-controls__featured-image-title", children: title })
|
|
69
|
-
] }),
|
|
70
|
-
!url && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
71
|
-
/* @__PURE__ */ jsx(
|
|
72
|
-
"span",
|
|
73
|
-
{
|
|
74
|
-
className: "fields-controls__featured-image-placeholder",
|
|
75
|
-
style: {
|
|
76
|
-
width: "24px",
|
|
77
|
-
height: "24px"
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
),
|
|
81
|
-
/* @__PURE__ */ jsx("span", { className: "fields-controls__featured-image-title", children: __("Choose an image\u2026") })
|
|
82
|
-
] }),
|
|
83
|
-
url && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
84
|
-
Button,
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
children: /* @__PURE__ */ jsxs(
|
|
84
|
+
Grid,
|
|
85
|
+
{
|
|
86
|
+
rowGap: 0,
|
|
87
|
+
columnGap: 8,
|
|
88
|
+
templateColumns: "24px 1fr 24px",
|
|
89
|
+
children: [
|
|
90
|
+
url && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
91
|
+
/* @__PURE__ */ jsx(
|
|
92
|
+
"img",
|
|
85
93
|
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
className: "fields-controls__featured-image-image",
|
|
95
|
+
alt: "",
|
|
96
|
+
width: 24,
|
|
97
|
+
height: 24,
|
|
98
|
+
src: url
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ jsx("span", { className: "fields-controls__featured-image-title", children: title })
|
|
102
|
+
] }),
|
|
103
|
+
!url && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
"span",
|
|
106
|
+
{
|
|
107
|
+
className: "fields-controls__featured-image-placeholder",
|
|
108
|
+
style: {
|
|
109
|
+
width: "24px",
|
|
110
|
+
height: "24px"
|
|
92
111
|
}
|
|
93
112
|
}
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ jsx("span", { className: "fields-controls__featured-image-title", children: __("Choose an image\u2026") })
|
|
115
|
+
] }),
|
|
116
|
+
url && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
117
|
+
Button,
|
|
118
|
+
{
|
|
119
|
+
size: "small",
|
|
120
|
+
className: "fields-controls__featured-image-remove-button",
|
|
121
|
+
icon: lineSolid,
|
|
122
|
+
onClick: (event) => {
|
|
123
|
+
event.stopPropagation();
|
|
124
|
+
onChangeControl(0);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
) })
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
)
|
|
101
133
|
}
|
|
102
134
|
) }) });
|
|
103
135
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/fields/featured-image/featured-image-edit.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport {\n\tprivateApis as mediaUtilsPrivateApis,\n\tMediaUpload,\n} from '@wordpress/media-utils';\nimport { lineSolid } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePostWithEmbeddedFeaturedMedia } from '../../types';\nimport { unlock } from '../../lock-unlock';\n\nconst { MediaUploadModal } = unlock( mediaUtilsPrivateApis );\n\n/**\n * Conditional Media component that uses MediaUploadModal when experiment is enabled,\n * otherwise falls back to media-utils MediaUpload.\n *\n * @param {Object} root0 Component props.\n * @param {Function} root0.render Render prop function that receives { open } object.\n * @param {Object} root0.props Other props passed to the media upload component.\n * @return {JSX.Element} The component.\n */\nfunction ConditionalMediaUpload( { render, ...props }: any ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tif ( ( window as any ).__experimentalDataViewsMediaModal ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ render && render( { open: () => setIsModalOpen( true ) } ) }\n\t\t\t\t<MediaUploadModal\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\tprops.onClose?.();\n\t\t\t\t\t} }\n\t\t\t\t\tonSelect={ ( media: any ) => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\tprops.onSelect?.( media );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n\n\t// Fallback to media-utils MediaUpload when experiment is disabled\n\treturn <MediaUpload { ...props } render={ render } />;\n}\n\nexport const FeaturedImageEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePostWithEmbeddedFeaturedMedia > ) => {\n\tconst { id } = field;\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'postType', 'attachment', value );\n\t\t},\n\t\t[ value ]\n\t);\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\tconst url = media?.source_url;\n\tconst title = media?.title?.rendered;\n\tconst ref = useRef( null );\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__featured-image\">\n\t\t\t<div className=\"fields-controls__featured-image-container\">\n\t\t\t\t<ConditionalMediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: any ) => {\n\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t} }\n\t\t\t\t\tallowedTypes={ [ 'image' ] }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\ttitle={ __( 'Select Featured Image' ) }\n\t\t\t\t\trender={ ( { open }: any ) => (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tevent.key === 'Enter' ||\n\t\t\t\t\t\t\t\t\tevent.key === ' '\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr 24px\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\twidth={ 24 }\n\t\t\t\t\t\t\t\t\t\t\theight={ 24 }\n\t\t\t\t\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose an image\u2026' ) }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-remove-button\"\n\t\t\t\t\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\tonChangeControl( 0 );\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n};\n"],
|
|
5
|
+
"mappings": "AAqCG,mBAEC,KAFD;AAlCH,SAAS,QAAQ,sBAAsB,YAAY;AACnD,SAAS,iBAAiB;AAC1B,SAAS,aAAa,QAAQ,gBAAgB;AAC9C;AAAA,EACC,eAAe;AAAA,EACf;AAAA,OACM;AACP,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AAEnC,SAAS,UAAU;AAMnB,SAAS,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
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate-post.d.ts","sourceRoot":"","sources":["../../src/actions/duplicate-post.tsx"],"names":[],"mappings":"AAeA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,UAAU,CAAC;AAGxD,UAAU,gBAAgB,CAAE,IAAI;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,iBAAiB,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,CAAC;CAC9C;AAED,UAAU,MAAM,CAAE,IAAI;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,OAAO,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAE,KAAK,EAAE,gBAAgB,CAAE,IAAI,CAAE,KAAM,GAAG,CAAC,OAAO,CAAC;CAChE;AAED,QAAA,MAAM,aAAa,EAAE,MAAM,CAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"duplicate-post.d.ts","sourceRoot":"","sources":["../../src/actions/duplicate-post.tsx"],"names":[],"mappings":"AAeA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,UAAU,CAAC;AAGxD,UAAU,gBAAgB,CAAE,IAAI;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,iBAAiB,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,CAAC;CAC9C;AAED,UAAU,MAAM,CAAE,IAAI;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,OAAO,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAE,KAAK,EAAE,gBAAgB,CAAE,IAAI,CAAE,KAAM,GAAG,CAAC,OAAO,CAAC;CAChE;AAED,QAAA,MAAM,aAAa,EAAE,MAAM,CAAE,QAAQ,CAyJpC,CAAC;AAEF;;GAEG;AACH,eAAe,aAAa,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Action } from '@wordpress/dataviews';
|
|
2
|
-
import type {
|
|
3
|
-
declare const resetPostAction: Action<
|
|
2
|
+
import type { TemplatePart } from '../types';
|
|
3
|
+
declare const resetPostAction: Action<TemplatePart>;
|
|
4
4
|
/**
|
|
5
5
|
* Reset action for Template and TemplatePart.
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-post.d.ts","sourceRoot":"","sources":["../../src/actions/reset-post.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAQnD,OAAO,KAAK,EAAiB,
|
|
1
|
+
{"version":3,"file":"reset-post.d.ts","sourceRoot":"","sources":["../../src/actions/reset-post.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAQnD,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,UAAU,CAAC;AAsJ5D,QAAA,MAAM,eAAe,EAAE,MAAM,CAAE,YAAY,CAuG1C,CAAC;AAEF;;GAEG;AACH,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"featured-image-edit.d.ts","sourceRoot":"","sources":["../../../src/fields/featured-image/featured-image-edit.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"featured-image-edit.d.ts","sourceRoot":"","sources":["../../../src/fields/featured-image/featured-image-edit.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGjE;;GAEG;AACH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAyCrE,eAAO,MAAM,iBAAiB,+BAI3B,oBAAoB,CAAE,iCAAiC,CAAE,gCA0G3D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/fields",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -39,30 +39,30 @@
|
|
|
39
39
|
"src/**/*.scss"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@wordpress/api-fetch": "^7.
|
|
43
|
-
"@wordpress/base-styles": "^6.10.
|
|
44
|
-
"@wordpress/blob": "^4.
|
|
45
|
-
"@wordpress/block-editor": "^15.
|
|
46
|
-
"@wordpress/blocks": "^15.
|
|
47
|
-
"@wordpress/components": "^30.7.
|
|
48
|
-
"@wordpress/compose": "^7.
|
|
49
|
-
"@wordpress/core-data": "^7.
|
|
50
|
-
"@wordpress/data": "^10.
|
|
51
|
-
"@wordpress/dataviews": "^10.
|
|
52
|
-
"@wordpress/date": "^5.
|
|
53
|
-
"@wordpress/element": "^6.
|
|
54
|
-
"@wordpress/hooks": "^4.
|
|
55
|
-
"@wordpress/html-entities": "^4.
|
|
56
|
-
"@wordpress/i18n": "^6.
|
|
57
|
-
"@wordpress/icons": "^11.
|
|
58
|
-
"@wordpress/media-utils": "^5.
|
|
59
|
-
"@wordpress/notices": "^5.
|
|
60
|
-
"@wordpress/patterns": "^2.
|
|
61
|
-
"@wordpress/primitives": "^4.
|
|
62
|
-
"@wordpress/private-apis": "^1.
|
|
63
|
-
"@wordpress/router": "^1.
|
|
64
|
-
"@wordpress/url": "^4.
|
|
65
|
-
"@wordpress/warning": "^3.
|
|
42
|
+
"@wordpress/api-fetch": "^7.34.0",
|
|
43
|
+
"@wordpress/base-styles": "^6.10.0",
|
|
44
|
+
"@wordpress/blob": "^4.34.0",
|
|
45
|
+
"@wordpress/block-editor": "^15.7.0",
|
|
46
|
+
"@wordpress/blocks": "^15.7.0",
|
|
47
|
+
"@wordpress/components": "^30.7.0",
|
|
48
|
+
"@wordpress/compose": "^7.34.0",
|
|
49
|
+
"@wordpress/core-data": "^7.34.0",
|
|
50
|
+
"@wordpress/data": "^10.34.0",
|
|
51
|
+
"@wordpress/dataviews": "^10.2.0",
|
|
52
|
+
"@wordpress/date": "^5.34.0",
|
|
53
|
+
"@wordpress/element": "^6.34.0",
|
|
54
|
+
"@wordpress/hooks": "^4.34.0",
|
|
55
|
+
"@wordpress/html-entities": "^4.34.0",
|
|
56
|
+
"@wordpress/i18n": "^6.7.0",
|
|
57
|
+
"@wordpress/icons": "^11.1.0",
|
|
58
|
+
"@wordpress/media-utils": "^5.34.0",
|
|
59
|
+
"@wordpress/notices": "^5.34.0",
|
|
60
|
+
"@wordpress/patterns": "^2.34.0",
|
|
61
|
+
"@wordpress/primitives": "^4.34.0",
|
|
62
|
+
"@wordpress/private-apis": "^1.34.0",
|
|
63
|
+
"@wordpress/router": "^1.34.0",
|
|
64
|
+
"@wordpress/url": "^4.34.0",
|
|
65
|
+
"@wordpress/warning": "^3.34.0",
|
|
66
66
|
"change-case": "4.1.2",
|
|
67
67
|
"client-zip": "^2.4.5",
|
|
68
68
|
"clsx": "2.1.1",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "ceebff807958d2e8fc755b5a20473939c78b4d1d"
|
|
78
78
|
}
|
|
@@ -62,9 +62,7 @@ const duplicatePost: Action< BasePost > = {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const isTemplate =
|
|
66
|
-
item.type === 'wp_template' ||
|
|
67
|
-
item.type === 'wp_registered_template';
|
|
65
|
+
const isTemplate = item.type === 'wp_template';
|
|
68
66
|
|
|
69
67
|
const newItemObject = {
|
|
70
68
|
status: isTemplate ? 'publish' : 'draft',
|
|
@@ -108,9 +106,7 @@ const duplicatePost: Action< BasePost > = {
|
|
|
108
106
|
try {
|
|
109
107
|
const newItem = await saveEntityRecord(
|
|
110
108
|
'postType',
|
|
111
|
-
item.type
|
|
112
|
-
? 'wp_template'
|
|
113
|
-
: item.type,
|
|
109
|
+
item.type,
|
|
114
110
|
newItemObject,
|
|
115
111
|
{ throwOnError: true }
|
|
116
112
|
);
|
|
@@ -149,7 +145,7 @@ const duplicatePost: Action< BasePost > = {
|
|
|
149
145
|
return (
|
|
150
146
|
<form onSubmit={ createPage }>
|
|
151
147
|
<VStack spacing={ 3 }>
|
|
152
|
-
{ item.
|
|
148
|
+
{ typeof item.id === 'string' && (
|
|
153
149
|
<div>
|
|
154
150
|
{ __(
|
|
155
151
|
'You are about to duplicate a bundled template. Changes will not be live until you activate the new template.'
|
|
@@ -22,12 +22,10 @@ import apiFetch from '@wordpress/api-fetch';
|
|
|
22
22
|
/**
|
|
23
23
|
* Internal dependencies
|
|
24
24
|
*/
|
|
25
|
-
import { getItemTitle
|
|
26
|
-
import type { CoreDataError,
|
|
25
|
+
import { getItemTitle } from './utils';
|
|
26
|
+
import type { CoreDataError, TemplatePart } from '../types';
|
|
27
27
|
|
|
28
|
-
const isTemplateRevertable = (
|
|
29
|
-
templateOrTemplatePart: Template | TemplatePart
|
|
30
|
-
) => {
|
|
28
|
+
const isTemplateRevertable = ( templateOrTemplatePart: TemplatePart ) => {
|
|
31
29
|
if ( ! templateOrTemplatePart ) {
|
|
32
30
|
return false;
|
|
33
31
|
}
|
|
@@ -48,7 +46,7 @@ const isTemplateRevertable = (
|
|
|
48
46
|
* reverting the template. Default true.
|
|
49
47
|
*/
|
|
50
48
|
const revertTemplate = async (
|
|
51
|
-
template: TemplatePart
|
|
49
|
+
template: TemplatePart,
|
|
52
50
|
{ allowUndo = true } = {}
|
|
53
51
|
) => {
|
|
54
52
|
const noticeId = 'edit-site-template-reverted';
|
|
@@ -175,15 +173,14 @@ const revertTemplate = async (
|
|
|
175
173
|
}
|
|
176
174
|
};
|
|
177
175
|
|
|
178
|
-
const resetPostAction: Action<
|
|
176
|
+
const resetPostAction: Action< TemplatePart > = {
|
|
179
177
|
id: 'reset-post',
|
|
180
178
|
label: __( 'Reset' ),
|
|
181
179
|
isEligible: ( item ) => {
|
|
182
180
|
return (
|
|
183
|
-
|
|
181
|
+
item.type === 'wp_template_part' &&
|
|
184
182
|
item?.source === 'custom' &&
|
|
185
|
-
|
|
186
|
-
item?.has_theme_file )
|
|
183
|
+
item?.has_theme_file
|
|
187
184
|
);
|
|
188
185
|
},
|
|
189
186
|
icon: backup,
|
|
@@ -226,26 +223,14 @@ const resetPostAction: Action< Template | TemplatePart > = {
|
|
|
226
223
|
}
|
|
227
224
|
);
|
|
228
225
|
} catch ( error ) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
'An error occurred while reverting the templates.'
|
|
238
|
-
);
|
|
239
|
-
} else {
|
|
240
|
-
fallbackErrorMessage =
|
|
241
|
-
items.length === 1
|
|
242
|
-
? __(
|
|
243
|
-
'An error occurred while reverting the template part.'
|
|
244
|
-
)
|
|
245
|
-
: __(
|
|
246
|
-
'An error occurred while reverting the template parts.'
|
|
247
|
-
);
|
|
248
|
-
}
|
|
226
|
+
const fallbackErrorMessage =
|
|
227
|
+
items.length === 1
|
|
228
|
+
? __(
|
|
229
|
+
'An error occurred while reverting the template part.'
|
|
230
|
+
)
|
|
231
|
+
: __(
|
|
232
|
+
'An error occurred while reverting the template parts.'
|
|
233
|
+
);
|
|
249
234
|
|
|
250
235
|
const typedError = error as CoreDataError;
|
|
251
236
|
const errorMessage =
|
|
@@ -23,7 +23,7 @@ import type { CoreDataError, PostWithPermissions } from '../types';
|
|
|
23
23
|
|
|
24
24
|
const trashPost: Action< PostWithPermissions > = {
|
|
25
25
|
id: 'move-to-trash',
|
|
26
|
-
label: __( '
|
|
26
|
+
label: __( 'Trash' ),
|
|
27
27
|
isPrimary: true,
|
|
28
28
|
icon: trash,
|
|
29
29
|
isEligible( item ) {
|