@wordpress/fields 0.5.0 → 0.5.1-next.cd6172eb0.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/README.md +29 -0
- package/build/actions/duplicate-template-part.js +68 -0
- package/build/actions/duplicate-template-part.js.map +1 -0
- package/build/actions/index.js +7 -0
- package/build/actions/index.js.map +1 -1
- package/build/actions/permanently-delete-post.js +0 -1
- package/build/actions/permanently-delete-post.js.map +1 -1
- package/build/actions/rename-post.js +2 -2
- package/build/actions/rename-post.js.map +1 -1
- package/build/actions/reset-post.js +3 -3
- package/build/actions/reset-post.js.map +1 -1
- package/build/actions/restore-post.js +0 -1
- package/build/actions/restore-post.js.map +1 -1
- package/build/actions/trash-post.js +0 -1
- package/build/actions/trash-post.js.map +1 -1
- package/build/actions/utils.js +4 -12
- package/build/actions/utils.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +213 -0
- package/build/components/create-template-part-modal/index.js.map +1 -0
- package/build/components/create-template-part-modal/utils.js +64 -0
- package/build/components/create-template-part-modal/utils.js.map +1 -0
- package/build/fields/index.js +7 -0
- package/build/fields/index.js.map +1 -1
- package/build/fields/slug/slug-view.js +1 -1
- package/build/fields/slug/slug-view.js.map +1 -1
- package/build/fields/slug/utils.js +3 -0
- package/build/fields/slug/utils.js.map +1 -1
- package/build/fields/template/index.js +28 -0
- package/build/fields/template/index.js.map +1 -0
- package/build/fields/template/template-edit.js +154 -0
- package/build/fields/template/template-edit.js.map +1 -0
- package/build/fields/title/title-view.js +1 -1
- package/build/fields/title/title-view.js.map +1 -1
- package/build/index.js +13 -0
- package/build/index.js.map +1 -1
- package/build/mutation/index.js +0 -1
- package/build/mutation/index.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/actions/duplicate-template-part.js +63 -0
- package/build-module/actions/duplicate-template-part.js.map +1 -0
- package/build-module/actions/index.js +1 -0
- package/build-module/actions/index.js.map +1 -1
- package/build-module/actions/permanently-delete-post.js +0 -1
- package/build-module/actions/permanently-delete-post.js.map +1 -1
- package/build-module/actions/rename-post.js +3 -3
- package/build-module/actions/rename-post.js.map +1 -1
- package/build-module/actions/reset-post.js +4 -4
- package/build-module/actions/reset-post.js.map +1 -1
- package/build-module/actions/restore-post.js +0 -1
- package/build-module/actions/restore-post.js.map +1 -1
- package/build-module/actions/trash-post.js +0 -1
- package/build-module/actions/trash-post.js.map +1 -1
- package/build-module/actions/utils.js +4 -11
- package/build-module/actions/utils.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +204 -0
- package/build-module/components/create-template-part-modal/index.js.map +1 -0
- package/build-module/components/create-template-part-modal/utils.js +55 -0
- package/build-module/components/create-template-part-modal/utils.js.map +1 -0
- package/build-module/fields/index.js +1 -0
- package/build-module/fields/index.js.map +1 -1
- package/build-module/fields/slug/slug-view.js +1 -1
- package/build-module/fields/slug/slug-view.js.map +1 -1
- package/build-module/fields/slug/utils.js +3 -0
- package/build-module/fields/slug/utils.js.map +1 -1
- package/build-module/fields/template/index.js +21 -0
- package/build-module/fields/template/index.js.map +1 -0
- package/build-module/fields/template/template-edit.js +144 -0
- package/build-module/fields/template/template-edit.js.map +1 -0
- package/build-module/fields/title/title-view.js +1 -1
- package/build-module/fields/title/title-view.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/mutation/index.js +0 -1
- package/build-module/mutation/index.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-style/style-rtl.css +74 -0
- package/build-style/style.css +74 -0
- package/build-types/actions/duplicate-template-part.d.ts +11 -0
- package/build-types/actions/duplicate-template-part.d.ts.map +1 -0
- package/build-types/actions/index.d.ts +1 -0
- package/build-types/actions/index.d.ts.map +1 -1
- package/build-types/actions/rename-post.d.ts.map +1 -1
- package/build-types/actions/reset-post.d.ts.map +1 -1
- package/build-types/actions/utils.d.ts +7 -8
- package/build-types/actions/utils.d.ts.map +1 -1
- package/build-types/components/create-template-part-modal/index.d.ts +34 -0
- package/build-types/components/create-template-part-modal/index.d.ts.map +1 -0
- package/build-types/components/create-template-part-modal/utils.d.ts +4 -0
- package/build-types/components/create-template-part-modal/utils.d.ts.map +1 -0
- package/build-types/fields/index.d.ts +1 -0
- package/build-types/fields/index.d.ts.map +1 -1
- package/build-types/fields/slug/utils.d.ts.map +1 -1
- package/build-types/fields/template/index.d.ts +8 -0
- package/build-types/fields/template/index.d.ts.map +1 -0
- package/build-types/fields/template/template-edit.d.ts +4 -0
- package/build-types/fields/template/template-edit.d.ts.map +1 -0
- package/build-types/fields/title/title-view.d.ts.map +1 -1
- package/build-types/index.d.ts +2 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +1 -1
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/build-types/types.d.ts +3 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +24 -23
- package/src/actions/duplicate-template-part.tsx +72 -0
- package/src/actions/index.ts +1 -0
- package/src/actions/rename-post.tsx +3 -6
- package/src/actions/reset-post.tsx +4 -9
- package/src/actions/utils.ts +7 -15
- package/src/components/create-template-part-modal/index.tsx +274 -0
- package/src/components/create-template-part-modal/style.scss +63 -0
- package/src/components/create-template-part-modal/test/utils.js +60 -0
- package/src/components/create-template-part-modal/utils.js +68 -0
- package/src/fields/index.ts +1 -0
- package/src/fields/slug/slug-view.tsx +1 -1
- package/src/fields/slug/utils.ts +4 -0
- package/src/fields/template/index.ts +22 -0
- package/src/fields/template/style.scss +23 -0
- package/src/fields/template/template-edit.tsx +210 -0
- package/src/fields/title/title-view.tsx +3 -4
- package/src/index.ts +2 -1
- package/src/style.scss +2 -0
- package/src/types.ts +3 -0
- package/tsconfig.json +2 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/template/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAMlD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,QAAA,MAAM,aAAa,EAAE,KAAK,CAAE,QAAQ,CAOnC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataFormControlProps } from '@wordpress/dataviews';
|
|
2
|
+
import type { BasePost } from '../../types';
|
|
3
|
+
export declare const TemplateEdit: ({ data, field, onChange, }: DataFormControlProps<BasePost>) => import("react").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=template-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-edit.d.ts","sourceRoot":"","sources":["../../../src/fields/template/template-edit.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAmBjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,eAAO,MAAM,YAAY,+BAItB,oBAAoB,CAAE,QAAQ,CAAE,gCA+KlC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title-view.d.ts","sourceRoot":"","sources":["../../../src/fields/title/title-view.tsx"],"names":[],"mappings":"AAUA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,QAAA,MAAM,SAAS,aAAe;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"title-view.d.ts","sourceRoot":"","sources":["../../../src/fields/title/title-view.tsx"],"names":[],"mappings":"AAUA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,QAAA,MAAM,SAAS,aAAe;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,gCA0C/C,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './fields';
|
|
2
2
|
export * from './actions';
|
|
3
|
-
export
|
|
3
|
+
export { default as CreateTemplatePartModal } from './components/create-template-part-modal';
|
|
4
|
+
export type { BasePostWithEmbeddedAuthor, PostType } from './types';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAC7F,YAAY,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const lock: (object:
|
|
1
|
+
export declare const lock: (object: unknown, privateData: unknown) => void, unlock: <T = any>(object: unknown) => T;
|
|
2
2
|
//# sourceMappingURL=lock-unlock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-unlock.d.ts","sourceRoot":"","sources":["../src/lock-unlock.ts"],"names":[],"mappings":"AAIA,eAAO,MAAQ,IAAI,
|
|
1
|
+
{"version":3,"file":"lock-unlock.d.ts","sourceRoot":"","sources":["../src/lock-unlock.ts"],"names":[],"mappings":"AAIA,eAAO,MAAQ,IAAI,mDAAE,MAAM,iCAIzB,CAAC"}
|
package/build-types/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GACZ,SAAS,GACT,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,Y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,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/fields",
|
|
3
|
-
"version": "0.5.0",
|
|
3
|
+
"version": "0.5.1-next.cd6172eb0.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",
|
|
@@ -33,28 +33,29 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/runtime": "7.25.7",
|
|
36
|
-
"@wordpress/api-fetch": "
|
|
37
|
-
"@wordpress/blob": "
|
|
38
|
-
"@wordpress/
|
|
36
|
+
"@wordpress/api-fetch": "^7.13.1-next.cd6172eb0.0",
|
|
37
|
+
"@wordpress/blob": "^4.13.1-next.cd6172eb0.0",
|
|
38
|
+
"@wordpress/block-editor": "^14.8.1-next.cd6172eb0.0",
|
|
39
|
+
"@wordpress/blocks": "^14.2.1-next.cd6172eb0.0",
|
|
39
40
|
"@wordpress/components": "*",
|
|
40
|
-
"@wordpress/compose": "
|
|
41
|
-
"@wordpress/core-data": "
|
|
42
|
-
"@wordpress/data": "
|
|
43
|
-
"@wordpress/dataviews": "
|
|
44
|
-
"@wordpress/date": "
|
|
45
|
-
"@wordpress/element": "
|
|
46
|
-
"@wordpress/hooks": "
|
|
47
|
-
"@wordpress/html-entities": "
|
|
48
|
-
"@wordpress/i18n": "
|
|
49
|
-
"@wordpress/icons": "
|
|
50
|
-
"@wordpress/media-utils": "
|
|
51
|
-
"@wordpress/notices": "
|
|
52
|
-
"@wordpress/patterns": "
|
|
53
|
-
"@wordpress/primitives": "
|
|
54
|
-
"@wordpress/private-apis": "
|
|
55
|
-
"@wordpress/router": "
|
|
56
|
-
"@wordpress/url": "
|
|
57
|
-
"@wordpress/warning": "
|
|
41
|
+
"@wordpress/compose": "^7.13.1-next.cd6172eb0.0",
|
|
42
|
+
"@wordpress/core-data": "^7.13.1-next.cd6172eb0.0",
|
|
43
|
+
"@wordpress/data": "^10.13.1-next.cd6172eb0.0",
|
|
44
|
+
"@wordpress/dataviews": "^4.9.1-next.cd6172eb0.0",
|
|
45
|
+
"@wordpress/date": "^5.13.1-next.cd6172eb0.0",
|
|
46
|
+
"@wordpress/element": "^6.13.1-next.cd6172eb0.0",
|
|
47
|
+
"@wordpress/hooks": "^4.13.1-next.cd6172eb0.0",
|
|
48
|
+
"@wordpress/html-entities": "^4.13.1-next.cd6172eb0.0",
|
|
49
|
+
"@wordpress/i18n": "^5.13.1-next.cd6172eb0.0",
|
|
50
|
+
"@wordpress/icons": "^10.13.1-next.cd6172eb0.0",
|
|
51
|
+
"@wordpress/media-utils": "^5.13.1-next.cd6172eb0.0",
|
|
52
|
+
"@wordpress/notices": "^5.13.1-next.cd6172eb0.0",
|
|
53
|
+
"@wordpress/patterns": "^2.13.1-next.cd6172eb0.0",
|
|
54
|
+
"@wordpress/primitives": "^4.13.1-next.cd6172eb0.0",
|
|
55
|
+
"@wordpress/private-apis": "^1.13.1-next.cd6172eb0.0",
|
|
56
|
+
"@wordpress/router": "^1.13.1-next.cd6172eb0.0",
|
|
57
|
+
"@wordpress/url": "^4.13.1-next.cd6172eb0.0",
|
|
58
|
+
"@wordpress/warning": "^3.13.1-next.cd6172eb0.0",
|
|
58
59
|
"change-case": "4.1.2",
|
|
59
60
|
"client-zip": "^2.4.5",
|
|
60
61
|
"clsx": "2.1.1",
|
|
@@ -66,5 +67,5 @@
|
|
|
66
67
|
"publishConfig": {
|
|
67
68
|
"access": "public"
|
|
68
69
|
},
|
|
69
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "4cc93dc1781d8a7bc2bbde265913917920e2bd45"
|
|
70
71
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch } from '@wordpress/data';
|
|
5
|
+
import { _x, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
7
|
+
import { useMemo } from '@wordpress/element';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import { parse } from '@wordpress/blocks';
|
|
10
|
+
import type { Action } from '@wordpress/dataviews';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import type { Post, TemplatePart } from '../types';
|
|
16
|
+
import { CreateTemplatePartModalContents } from '../components/create-template-part-modal';
|
|
17
|
+
import { getItemTitle } from './utils';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* This action is used to duplicate a template part.
|
|
21
|
+
*/
|
|
22
|
+
const duplicateTemplatePart: Action< TemplatePart > = {
|
|
23
|
+
id: 'duplicate-template-part',
|
|
24
|
+
label: _x( 'Duplicate', 'action label' ),
|
|
25
|
+
isEligible: ( item ) => item.type === 'wp_template_part',
|
|
26
|
+
modalHeader: _x( 'Duplicate template part', 'action label' ),
|
|
27
|
+
RenderModal: ( { items, closeModal } ) => {
|
|
28
|
+
const [ item ] = items;
|
|
29
|
+
const blocks = useMemo( () => {
|
|
30
|
+
return (
|
|
31
|
+
item.blocks ??
|
|
32
|
+
parse(
|
|
33
|
+
typeof item.content === 'string'
|
|
34
|
+
? item.content
|
|
35
|
+
: item.content.raw,
|
|
36
|
+
{
|
|
37
|
+
__unstableSkipMigrationLogs: true,
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
}, [ item.content, item.blocks ] );
|
|
42
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
43
|
+
function onTemplatePartSuccess( templatePart: Post ) {
|
|
44
|
+
createSuccessNotice(
|
|
45
|
+
sprintf(
|
|
46
|
+
// translators: %s: The new template part's title e.g. 'Call to action (copy)'.
|
|
47
|
+
_x( '"%s" duplicated.', 'template part' ),
|
|
48
|
+
getItemTitle( templatePart )
|
|
49
|
+
),
|
|
50
|
+
{ type: 'snackbar', id: 'edit-site-patterns-success' }
|
|
51
|
+
);
|
|
52
|
+
closeModal?.();
|
|
53
|
+
}
|
|
54
|
+
return (
|
|
55
|
+
<CreateTemplatePartModalContents
|
|
56
|
+
blocks={ blocks }
|
|
57
|
+
defaultArea={ item.area }
|
|
58
|
+
defaultTitle={ sprintf(
|
|
59
|
+
/* translators: %s: Existing template part title */
|
|
60
|
+
_x( '%s (Copy)', 'template part' ),
|
|
61
|
+
getItemTitle( item )
|
|
62
|
+
) }
|
|
63
|
+
onCreate={ onTemplatePartSuccess }
|
|
64
|
+
onError={ closeModal }
|
|
65
|
+
confirmLabel={ _x( 'Duplicate', 'action label' ) }
|
|
66
|
+
closeModal={ closeModal ?? ( () => {} ) }
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default duplicateTemplatePart;
|
package/src/actions/index.ts
CHANGED
|
@@ -13,3 +13,4 @@ export { default as permanentlyDeletePost } from './permanently-delete-post';
|
|
|
13
13
|
export { default as restorePost } from './restore-post';
|
|
14
14
|
export { default as trashPost } from './trash-post';
|
|
15
15
|
export { default as deletePost } from './delete-post';
|
|
16
|
+
export { default as duplicateTemplatePart } from './duplicate-template-part';
|
|
@@ -26,9 +26,6 @@ import {
|
|
|
26
26
|
isTemplateRemovable,
|
|
27
27
|
isTemplate,
|
|
28
28
|
isTemplatePart,
|
|
29
|
-
TEMPLATE_ORIGINS,
|
|
30
|
-
TEMPLATE_PART_POST_TYPE,
|
|
31
|
-
TEMPLATE_POST_TYPE,
|
|
32
29
|
} from './utils';
|
|
33
30
|
import type { CoreDataError, PostWithPermissions } from '../types';
|
|
34
31
|
|
|
@@ -45,8 +42,8 @@ const renamePost: Action< PostWithPermissions > = {
|
|
|
45
42
|
// Templates, template parts and patterns have special checks for renaming.
|
|
46
43
|
if (
|
|
47
44
|
! [
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
'wp_template',
|
|
46
|
+
'wp_template_part',
|
|
50
47
|
...Object.values( PATTERN_TYPES ),
|
|
51
48
|
].includes( post.type )
|
|
52
49
|
) {
|
|
@@ -64,7 +61,7 @@ const renamePost: Action< PostWithPermissions > = {
|
|
|
64
61
|
|
|
65
62
|
if ( isTemplatePart( post ) ) {
|
|
66
63
|
return (
|
|
67
|
-
post.source ===
|
|
64
|
+
post.source === 'custom' &&
|
|
68
65
|
! post?.has_theme_file &&
|
|
69
66
|
post.permissions?.update
|
|
70
67
|
);
|
|
@@ -22,12 +22,7 @@ import apiFetch from '@wordpress/api-fetch';
|
|
|
22
22
|
/**
|
|
23
23
|
* Internal dependencies
|
|
24
24
|
*/
|
|
25
|
-
import {
|
|
26
|
-
getItemTitle,
|
|
27
|
-
isTemplateOrTemplatePart,
|
|
28
|
-
TEMPLATE_ORIGINS,
|
|
29
|
-
TEMPLATE_POST_TYPE,
|
|
30
|
-
} from './utils';
|
|
25
|
+
import { getItemTitle, isTemplateOrTemplatePart } from './utils';
|
|
31
26
|
import type { CoreDataError, Template, TemplatePart } from '../types';
|
|
32
27
|
|
|
33
28
|
const isTemplateRevertable = (
|
|
@@ -38,7 +33,7 @@ const isTemplateRevertable = (
|
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
return (
|
|
41
|
-
templateOrTemplatePart.source ===
|
|
36
|
+
templateOrTemplatePart.source === 'custom' &&
|
|
42
37
|
( Boolean( templateOrTemplatePart?.plugin ) ||
|
|
43
38
|
templateOrTemplatePart?.has_theme_file )
|
|
44
39
|
);
|
|
@@ -186,7 +181,7 @@ const resetPostAction: Action< Template | TemplatePart > = {
|
|
|
186
181
|
isEligible: ( item ) => {
|
|
187
182
|
return (
|
|
188
183
|
isTemplateOrTemplatePart( item ) &&
|
|
189
|
-
item?.source ===
|
|
184
|
+
item?.source === 'custom' &&
|
|
190
185
|
( Boolean( item.type === 'wp_template' && item?.plugin ) ||
|
|
191
186
|
item?.has_theme_file )
|
|
192
187
|
);
|
|
@@ -231,7 +226,7 @@ const resetPostAction: Action< Template | TemplatePart > = {
|
|
|
231
226
|
);
|
|
232
227
|
} catch ( error ) {
|
|
233
228
|
let fallbackErrorMessage;
|
|
234
|
-
if ( items[ 0 ].type ===
|
|
229
|
+
if ( items[ 0 ].type === 'wp_template' ) {
|
|
235
230
|
fallbackErrorMessage =
|
|
236
231
|
items.length === 1
|
|
237
232
|
? __(
|
package/src/actions/utils.ts
CHANGED
|
@@ -8,29 +8,23 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
8
8
|
*/
|
|
9
9
|
import type { Post, TemplatePart, Template } from '../types';
|
|
10
10
|
|
|
11
|
-
export const TEMPLATE_POST_TYPE = 'wp_template';
|
|
12
|
-
export const TEMPLATE_PART_POST_TYPE = 'wp_template_part';
|
|
13
|
-
export const TEMPLATE_ORIGINS = {
|
|
14
|
-
custom: 'custom',
|
|
15
|
-
theme: 'theme',
|
|
16
|
-
plugin: 'plugin',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
11
|
export function isTemplate( post: Post ): post is Template {
|
|
20
|
-
return post.type ===
|
|
12
|
+
return post.type === 'wp_template';
|
|
21
13
|
}
|
|
22
14
|
|
|
23
15
|
export function isTemplatePart( post: Post ): post is TemplatePart {
|
|
24
|
-
return post.type ===
|
|
16
|
+
return post.type === 'wp_template_part';
|
|
25
17
|
}
|
|
26
18
|
|
|
27
19
|
export function isTemplateOrTemplatePart(
|
|
28
20
|
p: Post
|
|
29
21
|
): p is Template | TemplatePart {
|
|
30
|
-
return p.type ===
|
|
22
|
+
return p.type === 'wp_template' || p.type === 'wp_template_part';
|
|
31
23
|
}
|
|
32
24
|
|
|
33
|
-
export function getItemTitle( item:
|
|
25
|
+
export function getItemTitle( item: {
|
|
26
|
+
title: string | { rendered: string } | { raw: string };
|
|
27
|
+
} ) {
|
|
34
28
|
if ( typeof item.title === 'string' ) {
|
|
35
29
|
return decodeEntities( item.title );
|
|
36
30
|
}
|
|
@@ -57,9 +51,7 @@ export function isTemplateRemovable( template: Template | TemplatePart ) {
|
|
|
57
51
|
// than the one returned from the endpoint. This is why we need to check for
|
|
58
52
|
// two props whether is custom or has a theme file.
|
|
59
53
|
return (
|
|
60
|
-
[ template.source, template.source ].includes(
|
|
61
|
-
TEMPLATE_ORIGINS.custom
|
|
62
|
-
) &&
|
|
54
|
+
[ template.source, template.source ].includes( 'custom' ) &&
|
|
63
55
|
! Boolean( template.type === 'wp_template' && template?.plugin ) &&
|
|
64
56
|
! template.has_theme_file
|
|
65
57
|
);
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
Icon,
|
|
6
|
+
BaseControl,
|
|
7
|
+
TextControl,
|
|
8
|
+
Flex,
|
|
9
|
+
FlexItem,
|
|
10
|
+
FlexBlock,
|
|
11
|
+
Button,
|
|
12
|
+
Modal,
|
|
13
|
+
__experimentalRadioGroup as RadioGroup,
|
|
14
|
+
__experimentalRadio as Radio,
|
|
15
|
+
__experimentalHStack as HStack,
|
|
16
|
+
__experimentalVStack as VStack,
|
|
17
|
+
} from '@wordpress/components';
|
|
18
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
19
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
20
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
21
|
+
import { useState } from '@wordpress/element';
|
|
22
|
+
import { __ } from '@wordpress/i18n';
|
|
23
|
+
import {
|
|
24
|
+
check,
|
|
25
|
+
footer as footerIcon,
|
|
26
|
+
header as headerIcon,
|
|
27
|
+
sidebar as sidebarIcon,
|
|
28
|
+
symbolFilled as symbolFilledIcon,
|
|
29
|
+
} from '@wordpress/icons';
|
|
30
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
import { serialize } from '@wordpress/blocks';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Internal dependencies
|
|
36
|
+
*/
|
|
37
|
+
import {
|
|
38
|
+
getCleanTemplatePartSlug,
|
|
39
|
+
getUniqueTemplatePartTitle,
|
|
40
|
+
useExistingTemplateParts,
|
|
41
|
+
} from './utils';
|
|
42
|
+
|
|
43
|
+
type CreateTemplatePartModalContentsProps = {
|
|
44
|
+
defaultArea?: string;
|
|
45
|
+
blocks: any[];
|
|
46
|
+
confirmLabel?: string;
|
|
47
|
+
closeModal: () => void;
|
|
48
|
+
onCreate: ( templatePart: any ) => void;
|
|
49
|
+
onError?: () => void;
|
|
50
|
+
defaultTitle?: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.
|
|
55
|
+
* This component should not live in this package, it should be moved to a dedicated package responsible for managing template.
|
|
56
|
+
* @param {Object} props The component props.
|
|
57
|
+
* @param props.modalTitle
|
|
58
|
+
*/
|
|
59
|
+
export default function CreateTemplatePartModal( {
|
|
60
|
+
modalTitle,
|
|
61
|
+
...restProps
|
|
62
|
+
}: {
|
|
63
|
+
modalTitle: string;
|
|
64
|
+
} & CreateTemplatePartModalContentsProps ) {
|
|
65
|
+
const defaultModalTitle = useSelect(
|
|
66
|
+
( select ) =>
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
select( coreStore ).getPostType( 'wp_template_part' )?.labels
|
|
69
|
+
?.add_new_item,
|
|
70
|
+
[]
|
|
71
|
+
);
|
|
72
|
+
return (
|
|
73
|
+
<Modal
|
|
74
|
+
title={ modalTitle || defaultModalTitle }
|
|
75
|
+
onRequestClose={ restProps.closeModal }
|
|
76
|
+
overlayClassName="fields-create-template-part-modal"
|
|
77
|
+
focusOnMount="firstContentElement"
|
|
78
|
+
size="medium"
|
|
79
|
+
>
|
|
80
|
+
{ /* @ts-ignore */ }
|
|
81
|
+
<CreateTemplatePartModalContents { ...restProps } />
|
|
82
|
+
</Modal>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const getTemplatePartIcon = ( iconName: string ) => {
|
|
87
|
+
if ( 'header' === iconName ) {
|
|
88
|
+
return headerIcon;
|
|
89
|
+
} else if ( 'footer' === iconName ) {
|
|
90
|
+
return footerIcon;
|
|
91
|
+
} else if ( 'sidebar' === iconName ) {
|
|
92
|
+
return sidebarIcon;
|
|
93
|
+
}
|
|
94
|
+
return symbolFilledIcon;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A React component that renders the content of a model for creating a template part.
|
|
99
|
+
* This component should not live in this package; it should be moved to a dedicated package responsible for managing template.
|
|
100
|
+
*
|
|
101
|
+
* @param {Object} props - The component props.
|
|
102
|
+
* @param {string} [props.defaultArea=uncategorized] - The default area for the template part.
|
|
103
|
+
* @param {Array} [props.blocks=[]] - The blocks to be included in the template part.
|
|
104
|
+
* @param {string} [props.confirmLabel='Add'] - The label for the confirm button.
|
|
105
|
+
* @param {Function} props.closeModal - Function to close the modal.
|
|
106
|
+
* @param {Function} props.onCreate - Function to call when the template part is successfully created.
|
|
107
|
+
* @param {Function} [props.onError] - Function to call when there is an error creating the template part.
|
|
108
|
+
* @param {string} [props.defaultTitle=''] - The default title for the template part.
|
|
109
|
+
*/
|
|
110
|
+
export function CreateTemplatePartModalContents( {
|
|
111
|
+
defaultArea = 'uncategorized',
|
|
112
|
+
blocks = [],
|
|
113
|
+
confirmLabel = __( 'Add' ),
|
|
114
|
+
closeModal,
|
|
115
|
+
onCreate,
|
|
116
|
+
onError,
|
|
117
|
+
defaultTitle = '',
|
|
118
|
+
}: CreateTemplatePartModalContentsProps ) {
|
|
119
|
+
const { createErrorNotice } = useDispatch( noticesStore );
|
|
120
|
+
const { saveEntityRecord } = useDispatch( coreStore );
|
|
121
|
+
const existingTemplateParts = useExistingTemplateParts();
|
|
122
|
+
|
|
123
|
+
const [ title, setTitle ] = useState( defaultTitle );
|
|
124
|
+
const [ area, setArea ] = useState( defaultArea );
|
|
125
|
+
const [ isSubmitting, setIsSubmitting ] = useState( false );
|
|
126
|
+
const instanceId = useInstanceId( CreateTemplatePartModal );
|
|
127
|
+
|
|
128
|
+
const defaultTemplatePartAreas = useSelect( ( select ) => {
|
|
129
|
+
const areas =
|
|
130
|
+
// @ts-expect-error getEntityRecord is not typed with unstableBase as argument.
|
|
131
|
+
select( coreStore ).getEntityRecord< {
|
|
132
|
+
default_template_part_areas: Array< {
|
|
133
|
+
area: string;
|
|
134
|
+
label: string;
|
|
135
|
+
icon: string;
|
|
136
|
+
description: string;
|
|
137
|
+
} >;
|
|
138
|
+
} >( 'root', '__unstableBase' )?.default_template_part_areas || [];
|
|
139
|
+
|
|
140
|
+
return areas.map( ( item ) => {
|
|
141
|
+
return { ...item, icon: getTemplatePartIcon( item.icon ) };
|
|
142
|
+
} );
|
|
143
|
+
}, [] );
|
|
144
|
+
|
|
145
|
+
async function createTemplatePart() {
|
|
146
|
+
if ( ! title || isSubmitting ) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
setIsSubmitting( true );
|
|
152
|
+
const uniqueTitle = getUniqueTemplatePartTitle(
|
|
153
|
+
title,
|
|
154
|
+
existingTemplateParts
|
|
155
|
+
);
|
|
156
|
+
const cleanSlug = getCleanTemplatePartSlug( uniqueTitle );
|
|
157
|
+
|
|
158
|
+
const templatePart = await saveEntityRecord(
|
|
159
|
+
'postType',
|
|
160
|
+
'wp_template_part',
|
|
161
|
+
{
|
|
162
|
+
slug: cleanSlug,
|
|
163
|
+
title: uniqueTitle,
|
|
164
|
+
content: serialize( blocks ),
|
|
165
|
+
area,
|
|
166
|
+
},
|
|
167
|
+
{ throwOnError: true }
|
|
168
|
+
);
|
|
169
|
+
await onCreate( templatePart );
|
|
170
|
+
|
|
171
|
+
// TODO: Add a success notice?
|
|
172
|
+
} catch ( error ) {
|
|
173
|
+
const errorMessage =
|
|
174
|
+
error instanceof Error &&
|
|
175
|
+
'code' in error &&
|
|
176
|
+
error.message &&
|
|
177
|
+
error.code !== 'unknown_error'
|
|
178
|
+
? error.message
|
|
179
|
+
: __(
|
|
180
|
+
'An error occurred while creating the template part.'
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
184
|
+
|
|
185
|
+
onError?.();
|
|
186
|
+
} finally {
|
|
187
|
+
setIsSubmitting( false );
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return (
|
|
191
|
+
<form
|
|
192
|
+
onSubmit={ async ( event ) => {
|
|
193
|
+
event.preventDefault();
|
|
194
|
+
await createTemplatePart();
|
|
195
|
+
} }
|
|
196
|
+
>
|
|
197
|
+
<VStack spacing="4">
|
|
198
|
+
<TextControl
|
|
199
|
+
__next40pxDefaultSize
|
|
200
|
+
__nextHasNoMarginBottom
|
|
201
|
+
label={ __( 'Name' ) }
|
|
202
|
+
value={ title }
|
|
203
|
+
onChange={ setTitle }
|
|
204
|
+
required
|
|
205
|
+
/>
|
|
206
|
+
<BaseControl
|
|
207
|
+
__nextHasNoMarginBottom
|
|
208
|
+
label={ __( 'Area' ) }
|
|
209
|
+
id={ `fields-create-template-part-modal__area-selection-${ instanceId }` }
|
|
210
|
+
className="fields-create-template-part-modal__area-base-control"
|
|
211
|
+
>
|
|
212
|
+
<RadioGroup
|
|
213
|
+
label={ __( 'Area' ) }
|
|
214
|
+
className="fields-create-template-part-modal__area-radio-group"
|
|
215
|
+
id={ `fields-create-template-part-modal__area-selection-${ instanceId }` }
|
|
216
|
+
onChange={ ( value ) =>
|
|
217
|
+
value && typeof value === 'string'
|
|
218
|
+
? setArea( value )
|
|
219
|
+
: () => void 0
|
|
220
|
+
}
|
|
221
|
+
checked={ area }
|
|
222
|
+
>
|
|
223
|
+
{ defaultTemplatePartAreas.map(
|
|
224
|
+
( { icon, label, area: value, description } ) => (
|
|
225
|
+
<Radio
|
|
226
|
+
__next40pxDefaultSize
|
|
227
|
+
key={ label }
|
|
228
|
+
value={ value }
|
|
229
|
+
className="fields-create-template-part-modal__area-radio"
|
|
230
|
+
>
|
|
231
|
+
<Flex align="start" justify="start">
|
|
232
|
+
<FlexItem>
|
|
233
|
+
<Icon icon={ icon } />
|
|
234
|
+
</FlexItem>
|
|
235
|
+
<FlexBlock className="fields-create-template-part-modal__option-label">
|
|
236
|
+
{ label }
|
|
237
|
+
<div>{ description }</div>
|
|
238
|
+
</FlexBlock>
|
|
239
|
+
|
|
240
|
+
<FlexItem className="fields-create-template-part-modal__checkbox">
|
|
241
|
+
{ area === value && (
|
|
242
|
+
<Icon icon={ check } />
|
|
243
|
+
) }
|
|
244
|
+
</FlexItem>
|
|
245
|
+
</Flex>
|
|
246
|
+
</Radio>
|
|
247
|
+
)
|
|
248
|
+
) }
|
|
249
|
+
</RadioGroup>
|
|
250
|
+
</BaseControl>
|
|
251
|
+
<HStack justify="right">
|
|
252
|
+
<Button
|
|
253
|
+
__next40pxDefaultSize
|
|
254
|
+
variant="tertiary"
|
|
255
|
+
onClick={ () => {
|
|
256
|
+
closeModal();
|
|
257
|
+
} }
|
|
258
|
+
>
|
|
259
|
+
{ __( 'Cancel' ) }
|
|
260
|
+
</Button>
|
|
261
|
+
<Button
|
|
262
|
+
__next40pxDefaultSize
|
|
263
|
+
variant="primary"
|
|
264
|
+
type="submit"
|
|
265
|
+
aria-disabled={ ! title || isSubmitting }
|
|
266
|
+
isBusy={ isSubmitting }
|
|
267
|
+
>
|
|
268
|
+
{ confirmLabel }
|
|
269
|
+
</Button>
|
|
270
|
+
</HStack>
|
|
271
|
+
</VStack>
|
|
272
|
+
</form>
|
|
273
|
+
);
|
|
274
|
+
}
|