@wordpress/fields 0.5.1-next.cd6172eb0.0 → 0.6.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/README.md +32 -36
- package/build/actions/delete-post.js +5 -0
- package/build/actions/delete-post.js.map +1 -1
- package/build/actions/duplicate-pattern.js +4 -0
- package/build/actions/duplicate-pattern.js.map +1 -1
- package/build/actions/duplicate-post.js +8 -3
- package/build/actions/duplicate-post.js.map +1 -1
- package/build/actions/duplicate-template-part.js +3 -0
- package/build/actions/duplicate-template-part.js.map +1 -1
- package/build/actions/export-pattern.js +5 -0
- package/build/actions/export-pattern.js.map +1 -1
- package/build/actions/index.js +0 -21
- package/build/actions/index.js.map +1 -1
- package/build/actions/permanently-delete-post.js +5 -0
- package/build/actions/permanently-delete-post.js.map +1 -1
- package/build/actions/rename-post.js +4 -0
- package/build/actions/rename-post.js.map +1 -1
- package/build/actions/reorder-page.js +4 -0
- package/build/actions/reorder-page.js.map +1 -1
- package/build/actions/reset-post.js +4 -0
- package/build/actions/reset-post.js.map +1 -1
- package/build/actions/restore-post.js +5 -0
- package/build/actions/restore-post.js.map +1 -1
- package/build/actions/trash-post.js +5 -0
- package/build/actions/trash-post.js.map +1 -1
- package/build/actions/view-post-revisions.js +4 -0
- package/build/actions/view-post-revisions.js.map +1 -1
- package/build/actions/view-post.js +4 -0
- package/build/actions/view-post.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +32 -41
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/create-template-part-modal/utils.js +1 -0
- package/build/components/create-template-part-modal/utils.js.map +1 -1
- package/build/fields/featured-image/index.js +4 -0
- package/build/fields/featured-image/index.js.map +1 -1
- package/build/fields/index.js +21 -0
- package/build/fields/index.js.map +1 -1
- package/build/fields/order/index.js +4 -0
- package/build/fields/order/index.js.map +1 -1
- package/build/fields/page-title/index.js +36 -0
- package/build/fields/page-title/index.js.map +1 -0
- package/build/fields/page-title/view.js +45 -0
- package/build/fields/page-title/view.js.map +1 -0
- package/build/fields/parent/index.js +1 -1
- package/build/fields/parent/index.js.map +1 -1
- package/build/fields/parent/parent-edit.js +1 -0
- package/build/fields/parent/parent-edit.js.map +1 -1
- package/build/fields/password/index.js +1 -1
- package/build/fields/password/index.js.map +1 -1
- package/build/fields/pattern-title/index.js +36 -0
- package/build/fields/pattern-title/index.js.map +1 -0
- package/build/fields/pattern-title/view.js +45 -0
- package/build/fields/pattern-title/view.js.map +1 -0
- package/build/fields/slug/index.js +4 -0
- package/build/fields/slug/index.js.map +1 -1
- package/build/fields/status/status-view.js +1 -0
- package/build/fields/status/status-view.js.map +1 -1
- package/build/fields/template/index.js +4 -3
- package/build/fields/template/index.js.map +1 -1
- package/build/fields/template/template-edit.js +1 -0
- package/build/fields/template/template-edit.js.map +1 -1
- package/build/fields/template-title/index.js +36 -0
- package/build/fields/template-title/index.js.map +1 -0
- package/build/fields/title/index.js +10 -3
- package/build/fields/title/index.js.map +1 -1
- package/build/fields/title/view.js +48 -0
- package/build/fields/title/view.js.map +1 -0
- package/build/index.native.js +0 -26
- package/build/index.native.js.map +1 -1
- package/build/mutation/index.js +1 -0
- package/build/mutation/index.js.map +1 -1
- package/build-module/actions/delete-post.js +5 -0
- package/build-module/actions/delete-post.js.map +1 -1
- package/build-module/actions/duplicate-pattern.js +4 -0
- package/build-module/actions/duplicate-pattern.js.map +1 -1
- package/build-module/actions/duplicate-post.js +8 -3
- package/build-module/actions/duplicate-post.js.map +1 -1
- package/build-module/actions/duplicate-template-part.js +3 -0
- package/build-module/actions/duplicate-template-part.js.map +1 -1
- package/build-module/actions/export-pattern.js +5 -0
- package/build-module/actions/export-pattern.js.map +1 -1
- package/build-module/actions/index.js +0 -3
- package/build-module/actions/index.js.map +1 -1
- package/build-module/actions/permanently-delete-post.js +5 -0
- package/build-module/actions/permanently-delete-post.js.map +1 -1
- package/build-module/actions/rename-post.js +4 -0
- package/build-module/actions/rename-post.js.map +1 -1
- package/build-module/actions/reorder-page.js +4 -0
- package/build-module/actions/reorder-page.js.map +1 -1
- package/build-module/actions/reset-post.js +4 -0
- package/build-module/actions/reset-post.js.map +1 -1
- package/build-module/actions/restore-post.js +5 -0
- package/build-module/actions/restore-post.js.map +1 -1
- package/build-module/actions/trash-post.js +5 -0
- package/build-module/actions/trash-post.js.map +1 -1
- package/build-module/actions/view-post-revisions.js +4 -0
- package/build-module/actions/view-post-revisions.js.map +1 -1
- package/build-module/actions/view-post.js +4 -0
- package/build-module/actions/view-post.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +32 -41
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/create-template-part-modal/utils.js +1 -0
- package/build-module/components/create-template-part-modal/utils.js.map +1 -1
- package/build-module/fields/featured-image/index.js +4 -0
- package/build-module/fields/featured-image/index.js.map +1 -1
- package/build-module/fields/index.js +3 -0
- package/build-module/fields/index.js.map +1 -1
- package/build-module/fields/order/index.js +4 -0
- package/build-module/fields/order/index.js.map +1 -1
- package/build-module/fields/page-title/index.js +30 -0
- package/build-module/fields/page-title/index.js.map +1 -0
- package/build-module/fields/page-title/view.js +39 -0
- package/build-module/fields/page-title/view.js.map +1 -0
- package/build-module/fields/parent/index.js +1 -1
- package/build-module/fields/parent/index.js.map +1 -1
- package/build-module/fields/parent/parent-edit.js +1 -0
- package/build-module/fields/parent/parent-edit.js.map +1 -1
- package/build-module/fields/password/index.js +1 -1
- package/build-module/fields/password/index.js.map +1 -1
- package/build-module/fields/pattern-title/index.js +30 -0
- package/build-module/fields/pattern-title/index.js.map +1 -0
- package/build-module/fields/pattern-title/view.js +36 -0
- package/build-module/fields/pattern-title/view.js.map +1 -0
- package/build-module/fields/slug/index.js +4 -0
- package/build-module/fields/slug/index.js.map +1 -1
- package/build-module/fields/status/status-view.js +1 -0
- package/build-module/fields/status/status-view.js.map +1 -1
- package/build-module/fields/template/index.js +4 -3
- package/build-module/fields/template/index.js.map +1 -1
- package/build-module/fields/template/template-edit.js +1 -0
- package/build-module/fields/template/template-edit.js.map +1 -1
- package/build-module/fields/template-title/index.js +30 -0
- package/build-module/fields/template-title/index.js.map +1 -0
- package/build-module/fields/title/index.js +9 -2
- package/build-module/fields/title/index.js.map +1 -1
- package/build-module/fields/title/view.js +39 -0
- package/build-module/fields/title/view.js.map +1 -0
- package/build-module/index.native.js +1 -2
- package/build-module/index.native.js.map +1 -1
- package/build-module/mutation/index.js +1 -0
- package/build-module/mutation/index.js.map +1 -1
- package/build-style/style-rtl.css +24 -0
- package/build-style/style.css +24 -0
- package/build-types/actions/delete-post.d.ts +3 -0
- package/build-types/actions/delete-post.d.ts.map +1 -1
- package/build-types/actions/duplicate-pattern.d.ts +3 -0
- package/build-types/actions/duplicate-pattern.d.ts.map +1 -1
- package/build-types/actions/duplicate-post.d.ts +3 -0
- package/build-types/actions/duplicate-post.d.ts.map +1 -1
- package/build-types/actions/duplicate-template-part.d.ts +3 -0
- package/build-types/actions/duplicate-template-part.d.ts.map +1 -1
- package/build-types/actions/export-pattern.d.ts +3 -0
- package/build-types/actions/export-pattern.d.ts.map +1 -1
- package/build-types/actions/index.d.ts +0 -3
- package/build-types/actions/index.d.ts.map +1 -1
- package/build-types/actions/permanently-delete-post.d.ts +3 -0
- package/build-types/actions/permanently-delete-post.d.ts.map +1 -1
- package/build-types/actions/rename-post.d.ts +3 -0
- package/build-types/actions/rename-post.d.ts.map +1 -1
- package/build-types/actions/reorder-page.d.ts +3 -0
- package/build-types/actions/reorder-page.d.ts.map +1 -1
- package/build-types/actions/reset-post.d.ts +3 -0
- package/build-types/actions/reset-post.d.ts.map +1 -1
- package/build-types/actions/restore-post.d.ts +3 -0
- package/build-types/actions/restore-post.d.ts.map +1 -1
- package/build-types/actions/trash-post.d.ts +3 -0
- package/build-types/actions/trash-post.d.ts.map +1 -1
- package/build-types/actions/view-post-revisions.d.ts +3 -0
- package/build-types/actions/view-post-revisions.d.ts.map +1 -1
- package/build-types/actions/view-post.d.ts +3 -0
- package/build-types/actions/view-post.d.ts.map +1 -1
- package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
- package/build-types/fields/featured-image/index.d.ts +3 -0
- package/build-types/fields/featured-image/index.d.ts.map +1 -1
- package/build-types/fields/index.d.ts +3 -0
- package/build-types/fields/index.d.ts.map +1 -1
- package/build-types/fields/order/index.d.ts +3 -0
- package/build-types/fields/order/index.d.ts.map +1 -1
- package/build-types/fields/page-title/index.d.ts +14 -0
- package/build-types/fields/page-title/index.d.ts.map +1 -0
- package/build-types/fields/page-title/view.d.ts +8 -0
- package/build-types/fields/page-title/view.d.ts.map +1 -0
- package/build-types/fields/parent/index.d.ts +1 -1
- package/build-types/fields/password/index.d.ts +1 -1
- package/build-types/fields/pattern-title/index.d.ts +14 -0
- package/build-types/fields/pattern-title/index.d.ts.map +1 -0
- package/build-types/fields/pattern-title/view.d.ts +9 -0
- package/build-types/fields/pattern-title/view.d.ts.map +1 -0
- package/build-types/fields/slug/index.d.ts +3 -0
- package/build-types/fields/slug/index.d.ts.map +1 -1
- package/build-types/fields/template/index.d.ts +3 -0
- package/build-types/fields/template/index.d.ts.map +1 -1
- package/build-types/fields/template-title/index.d.ts +14 -0
- package/build-types/fields/template-title/index.d.ts.map +1 -0
- package/build-types/fields/title/index.d.ts +7 -2
- package/build-types/fields/title/index.d.ts.map +1 -1
- package/build-types/fields/title/view.d.ts +14 -0
- package/build-types/fields/title/view.d.ts.map +1 -0
- package/build-types/index.native.d.ts +0 -2
- package/build-types/index.native.d.ts.map +1 -1
- package/package.json +24 -24
- package/src/actions/delete-post.tsx +3 -0
- package/src/actions/duplicate-pattern.tsx +3 -0
- package/src/actions/duplicate-post.tsx +6 -3
- package/src/actions/duplicate-template-part.tsx +3 -1
- package/src/actions/export-pattern.tsx +3 -0
- package/src/actions/index.ts +0 -3
- package/src/actions/permanently-delete-post.tsx +3 -0
- package/src/actions/rename-post.tsx +3 -0
- package/src/actions/reorder-page.tsx +3 -0
- package/src/actions/reset-post.tsx +3 -0
- package/src/actions/restore-post.tsx +3 -0
- package/src/actions/trash-post.tsx +3 -0
- package/src/actions/view-post-revisions.tsx +3 -0
- package/src/actions/view-post.tsx +3 -0
- package/src/components/create-template-part-modal/index.tsx +25 -26
- package/src/fields/featured-image/index.ts +3 -0
- package/src/fields/index.ts +3 -0
- package/src/fields/order/index.ts +3 -0
- package/src/fields/page-title/index.ts +28 -0
- package/src/fields/page-title/style.scss +10 -0
- package/src/fields/page-title/view.tsx +38 -0
- package/src/fields/parent/index.ts +1 -1
- package/src/fields/password/index.tsx +1 -1
- package/src/fields/pattern-title/index.ts +28 -0
- package/src/fields/pattern-title/style.scss +3 -0
- package/src/fields/pattern-title/view.tsx +32 -0
- package/src/fields/slug/index.ts +3 -0
- package/src/fields/template/index.ts +3 -1
- package/src/fields/template-title/index.ts +28 -0
- package/src/fields/title/index.ts +9 -3
- package/src/fields/title/style.scss +8 -0
- package/src/fields/title/view.tsx +43 -0
- package/src/index.native.ts +0 -2
- package/src/style.scss +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/actions/duplicate-post.native.js +0 -9
- package/build/actions/duplicate-post.native.js.map +0 -1
- package/build/actions/export-pattern.native.js +0 -9
- package/build/actions/export-pattern.native.js.map +0 -1
- package/build/actions/reorder-page.native.js +0 -9
- package/build/actions/reorder-page.native.js.map +0 -1
- package/build/fields/title/title-view.js +0 -61
- package/build/fields/title/title-view.js.map +0 -1
- package/build-module/actions/duplicate-post.native.js +0 -3
- package/build-module/actions/duplicate-post.native.js.map +0 -1
- package/build-module/actions/export-pattern.native.js +0 -3
- package/build-module/actions/export-pattern.native.js.map +0 -1
- package/build-module/actions/reorder-page.native.js +0 -3
- package/build-module/actions/reorder-page.native.js.map +0 -1
- package/build-module/fields/title/title-view.js +0 -55
- package/build-module/fields/title/title-view.js.map +0 -1
- package/build-types/actions/duplicate-post.native.d.ts +0 -3
- package/build-types/actions/duplicate-post.native.d.ts.map +0 -1
- package/build-types/actions/export-pattern.native.d.ts +0 -3
- package/build-types/actions/export-pattern.native.d.ts.map +0 -1
- package/build-types/actions/reorder-page.native.d.ts +0 -3
- package/build-types/actions/reorder-page.native.d.ts.map +0 -1
- package/build-types/fields/title/title-view.d.ts +0 -9
- package/build-types/fields/title/title-view.d.ts.map +0 -1
- package/src/actions/duplicate-post.native.tsx +0 -3
- package/src/actions/export-pattern.native.tsx +0 -3
- package/src/actions/reorder-page.native.tsx +0 -3
- package/src/fields/title/title-view.tsx +0 -61
|
@@ -5,7 +5,12 @@ import type { Field } from '@wordpress/dataviews';
|
|
|
5
5
|
/**
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
9
|
-
declare const titleField: Field<
|
|
8
|
+
import type { CommonPost } from '../../types';
|
|
9
|
+
declare const titleField: Field<CommonPost>;
|
|
10
|
+
/**
|
|
11
|
+
* Title for the any entity with a `title` property.
|
|
12
|
+
* For patterns, pages or templates you should use the respective field
|
|
13
|
+
* because there are some differences in the rendering, labels, etc.
|
|
14
|
+
*/
|
|
10
15
|
export default titleField;
|
|
11
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/title/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD;;GAEG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/title/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,QAAA,MAAM,UAAU,EAAE,KAAK,CAAE,UAAU,CASlC,CAAC;AAEF;;;;GAIG;AACH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Internal dependencies
|
|
4
|
+
*/
|
|
5
|
+
import type { CommonPost } from '../../types';
|
|
6
|
+
export declare function BaseTitleView({ item, className, children, }: {
|
|
7
|
+
item: CommonPost;
|
|
8
|
+
className?: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export default function TitleView({ item }: {
|
|
12
|
+
item: CommonPost;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/fields/title/view.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,wBAAgB,aAAa,CAAE,EAC9B,IAAI,EACJ,SAAS,EACT,QAAQ,GACR,EAAE;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACrB,+BAYA;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,+BAEhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/fields",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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,29 +33,29 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/runtime": "7.25.7",
|
|
36
|
-
"@wordpress/api-fetch": "
|
|
37
|
-
"@wordpress/blob": "
|
|
38
|
-
"@wordpress/block-editor": "
|
|
39
|
-
"@wordpress/blocks": "
|
|
36
|
+
"@wordpress/api-fetch": "*",
|
|
37
|
+
"@wordpress/blob": "*",
|
|
38
|
+
"@wordpress/block-editor": "*",
|
|
39
|
+
"@wordpress/blocks": "*",
|
|
40
40
|
"@wordpress/components": "*",
|
|
41
|
-
"@wordpress/compose": "
|
|
42
|
-
"@wordpress/core-data": "
|
|
43
|
-
"@wordpress/data": "
|
|
44
|
-
"@wordpress/dataviews": "
|
|
45
|
-
"@wordpress/date": "
|
|
46
|
-
"@wordpress/element": "
|
|
47
|
-
"@wordpress/hooks": "
|
|
48
|
-
"@wordpress/html-entities": "
|
|
49
|
-
"@wordpress/i18n": "
|
|
50
|
-
"@wordpress/icons": "
|
|
51
|
-
"@wordpress/media-utils": "
|
|
52
|
-
"@wordpress/notices": "
|
|
53
|
-
"@wordpress/patterns": "
|
|
54
|
-
"@wordpress/primitives": "
|
|
55
|
-
"@wordpress/private-apis": "
|
|
56
|
-
"@wordpress/router": "
|
|
57
|
-
"@wordpress/url": "
|
|
58
|
-
"@wordpress/warning": "
|
|
41
|
+
"@wordpress/compose": "*",
|
|
42
|
+
"@wordpress/core-data": "*",
|
|
43
|
+
"@wordpress/data": "*",
|
|
44
|
+
"@wordpress/dataviews": "*",
|
|
45
|
+
"@wordpress/date": "*",
|
|
46
|
+
"@wordpress/element": "*",
|
|
47
|
+
"@wordpress/hooks": "*",
|
|
48
|
+
"@wordpress/html-entities": "*",
|
|
49
|
+
"@wordpress/i18n": "*",
|
|
50
|
+
"@wordpress/icons": "*",
|
|
51
|
+
"@wordpress/media-utils": "*",
|
|
52
|
+
"@wordpress/notices": "*",
|
|
53
|
+
"@wordpress/patterns": "*",
|
|
54
|
+
"@wordpress/primitives": "*",
|
|
55
|
+
"@wordpress/private-apis": "*",
|
|
56
|
+
"@wordpress/router": "*",
|
|
57
|
+
"@wordpress/url": "*",
|
|
58
|
+
"@wordpress/warning": "*",
|
|
59
59
|
"change-case": "4.1.2",
|
|
60
60
|
"client-zip": "^2.4.5",
|
|
61
61
|
"clsx": "2.1.1",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "b432c18934c9db866b6dba7d37517a4e97d642e3"
|
|
71
71
|
}
|
|
@@ -37,8 +37,8 @@ const duplicatePost: Action< BasePost > = {
|
|
|
37
37
|
const [ item, setItem ] = useState< BasePost >( {
|
|
38
38
|
...items[ 0 ],
|
|
39
39
|
title: sprintf(
|
|
40
|
-
/* translators: %s: Existing
|
|
41
|
-
_x( '%s (Copy)', '
|
|
40
|
+
/* translators: %s: Existing post title */
|
|
41
|
+
_x( '%s (Copy)', 'post' ),
|
|
42
42
|
getItemTitle( items[ 0 ] )
|
|
43
43
|
),
|
|
44
44
|
} );
|
|
@@ -104,7 +104,7 @@ const duplicatePost: Action< BasePost > = {
|
|
|
104
104
|
|
|
105
105
|
createSuccessNotice(
|
|
106
106
|
sprintf(
|
|
107
|
-
// translators: %s: Title of the created post
|
|
107
|
+
// translators: %s: Title of the created post, e.g: "Hello world".
|
|
108
108
|
__( '"%s" successfully created.' ),
|
|
109
109
|
decodeEntities( newItem.title?.rendered || item.title )
|
|
110
110
|
),
|
|
@@ -171,4 +171,7 @@ const duplicatePost: Action< BasePost > = {
|
|
|
171
171
|
},
|
|
172
172
|
};
|
|
173
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Duplicate action for BasePost.
|
|
176
|
+
*/
|
|
174
177
|
export default duplicatePost;
|
package/src/actions/index.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export { default as viewPost } from './view-post';
|
|
2
2
|
export { default as reorderPage } from './reorder-page';
|
|
3
|
-
export { default as reorderPageNative } from './reorder-page.native';
|
|
4
3
|
export { default as duplicatePost } from './duplicate-post';
|
|
5
|
-
export { default as duplicatePostNative } from './duplicate-post.native';
|
|
6
4
|
export { default as renamePost } from './rename-post';
|
|
7
5
|
export { default as resetPost } from './reset-post';
|
|
8
6
|
export { default as duplicatePattern } from './duplicate-pattern';
|
|
9
7
|
export { default as exportPattern } from './export-pattern';
|
|
10
|
-
export { default as exportPatternNative } from './export-pattern.native';
|
|
11
8
|
export { default as viewPostRevisions } from './view-post-revisions';
|
|
12
9
|
export { default as permanentlyDeletePost } from './permanently-delete-post';
|
|
13
10
|
export { default as restorePost } from './restore-post';
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
symbolFilled as symbolFilledIcon,
|
|
29
29
|
} from '@wordpress/icons';
|
|
30
30
|
import { store as noticesStore } from '@wordpress/notices';
|
|
31
|
-
// @ts-
|
|
31
|
+
// @ts-expect-error serialize is not typed
|
|
32
32
|
import { serialize } from '@wordpress/blocks';
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -50,6 +50,13 @@ type CreateTemplatePartModalContentsProps = {
|
|
|
50
50
|
defaultTitle?: string;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
type TemplatePartArea = {
|
|
54
|
+
area: string;
|
|
55
|
+
label: string;
|
|
56
|
+
icon: string;
|
|
57
|
+
description: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
53
60
|
/**
|
|
54
61
|
* 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
62
|
* This component should not live in this package, it should be moved to a dedicated package responsible for managing template.
|
|
@@ -64,7 +71,7 @@ export default function CreateTemplatePartModal( {
|
|
|
64
71
|
} & CreateTemplatePartModalContentsProps ) {
|
|
65
72
|
const defaultModalTitle = useSelect(
|
|
66
73
|
( select ) =>
|
|
67
|
-
// @ts-
|
|
74
|
+
// @ts-expect-error getPostType is not typed with 'wp_template_part' as argument.
|
|
68
75
|
select( coreStore ).getPostType( 'wp_template_part' )?.labels
|
|
69
76
|
?.add_new_item,
|
|
70
77
|
[]
|
|
@@ -77,7 +84,6 @@ export default function CreateTemplatePartModal( {
|
|
|
77
84
|
focusOnMount="firstContentElement"
|
|
78
85
|
size="medium"
|
|
79
86
|
>
|
|
80
|
-
{ /* @ts-ignore */ }
|
|
81
87
|
<CreateTemplatePartModalContents { ...restProps } />
|
|
82
88
|
</Modal>
|
|
83
89
|
);
|
|
@@ -125,22 +131,14 @@ export function CreateTemplatePartModalContents( {
|
|
|
125
131
|
const [ isSubmitting, setIsSubmitting ] = useState( false );
|
|
126
132
|
const instanceId = useInstanceId( CreateTemplatePartModal );
|
|
127
133
|
|
|
128
|
-
const defaultTemplatePartAreas = useSelect(
|
|
129
|
-
|
|
134
|
+
const defaultTemplatePartAreas = useSelect(
|
|
135
|
+
( select ) =>
|
|
130
136
|
// @ts-expect-error getEntityRecord is not typed with unstableBase as argument.
|
|
131
137
|
select( coreStore ).getEntityRecord< {
|
|
132
|
-
default_template_part_areas: Array<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
}, [] );
|
|
138
|
+
default_template_part_areas: Array< TemplatePartArea >;
|
|
139
|
+
} >( 'root', '__unstableBase' )?.default_template_part_areas,
|
|
140
|
+
[]
|
|
141
|
+
);
|
|
144
142
|
|
|
145
143
|
async function createTemplatePart() {
|
|
146
144
|
if ( ! title || isSubmitting ) {
|
|
@@ -220,12 +218,13 @@ export function CreateTemplatePartModalContents( {
|
|
|
220
218
|
}
|
|
221
219
|
checked={ area }
|
|
222
220
|
>
|
|
223
|
-
{ defaultTemplatePartAreas.map(
|
|
224
|
-
|
|
221
|
+
{ ( defaultTemplatePartAreas ?? [] ).map( ( item ) => {
|
|
222
|
+
const icon = getTemplatePartIcon( item.icon );
|
|
223
|
+
return (
|
|
225
224
|
<Radio
|
|
226
225
|
__next40pxDefaultSize
|
|
227
|
-
key={ label }
|
|
228
|
-
value={
|
|
226
|
+
key={ item.label }
|
|
227
|
+
value={ item.area }
|
|
229
228
|
className="fields-create-template-part-modal__area-radio"
|
|
230
229
|
>
|
|
231
230
|
<Flex align="start" justify="start">
|
|
@@ -233,19 +232,19 @@ export function CreateTemplatePartModalContents( {
|
|
|
233
232
|
<Icon icon={ icon } />
|
|
234
233
|
</FlexItem>
|
|
235
234
|
<FlexBlock className="fields-create-template-part-modal__option-label">
|
|
236
|
-
{ label }
|
|
237
|
-
<div>{ description }</div>
|
|
235
|
+
{ item.label }
|
|
236
|
+
<div>{ item.description }</div>
|
|
238
237
|
</FlexBlock>
|
|
239
238
|
|
|
240
239
|
<FlexItem className="fields-create-template-part-modal__checkbox">
|
|
241
|
-
{ area ===
|
|
240
|
+
{ area === item.area && (
|
|
242
241
|
<Icon icon={ check } />
|
|
243
242
|
) }
|
|
244
243
|
</FlexItem>
|
|
245
244
|
</Flex>
|
|
246
245
|
</Radio>
|
|
247
|
-
)
|
|
248
|
-
) }
|
|
246
|
+
);
|
|
247
|
+
} ) }
|
|
249
248
|
</RadioGroup>
|
|
250
249
|
</BaseControl>
|
|
251
250
|
<HStack justify="right">
|
package/src/fields/index.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { default as slugField } from './slug';
|
|
2
2
|
export { default as titleField } from './title';
|
|
3
|
+
export { default as pageTitleField } from './page-title';
|
|
4
|
+
export { default as templateTitleField } from './template-title';
|
|
5
|
+
export { default as patternTitleField } from './pattern-title';
|
|
3
6
|
export { default as orderField } from './order';
|
|
4
7
|
export { default as featuredImageField } from './featured-image';
|
|
5
8
|
export { default as templateField } from './template';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Field } from '@wordpress/dataviews';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import type { BasePost } from '../../types';
|
|
11
|
+
import { getItemTitle } from '../../actions/utils';
|
|
12
|
+
import PageTitleView from './view';
|
|
13
|
+
|
|
14
|
+
const pageTitleField: Field< BasePost > = {
|
|
15
|
+
type: 'text',
|
|
16
|
+
id: 'title',
|
|
17
|
+
label: __( 'Title' ),
|
|
18
|
+
placeholder: __( 'No title' ),
|
|
19
|
+
getValue: ( { item } ) => getItemTitle( item ),
|
|
20
|
+
render: PageTitleView,
|
|
21
|
+
enableHiding: false,
|
|
22
|
+
enableGlobalSearch: true,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Title for the page entity.
|
|
27
|
+
*/
|
|
28
|
+
export default pageTitleField;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
import type { Settings } from '@wordpress/core-data';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import type { CommonPost } from '../../types';
|
|
13
|
+
import { BaseTitleView } from '../title/view';
|
|
14
|
+
|
|
15
|
+
export default function PageTitleView( { item }: { item: CommonPost } ) {
|
|
16
|
+
const { frontPageId, postsPageId } = useSelect( ( select ) => {
|
|
17
|
+
const { getEntityRecord } = select( coreStore );
|
|
18
|
+
const siteSettings = getEntityRecord(
|
|
19
|
+
'root',
|
|
20
|
+
'site'
|
|
21
|
+
) as Partial< Settings >;
|
|
22
|
+
return {
|
|
23
|
+
frontPageId: siteSettings?.page_on_front,
|
|
24
|
+
postsPageId: siteSettings?.page_for_posts,
|
|
25
|
+
};
|
|
26
|
+
}, [] );
|
|
27
|
+
return (
|
|
28
|
+
<BaseTitleView item={ item } className="fields-field__page-title">
|
|
29
|
+
{ [ frontPageId, postsPageId ].includes( item.id as number ) && (
|
|
30
|
+
<span className="fields-field__page-title__badge">
|
|
31
|
+
{ item.id === frontPageId
|
|
32
|
+
? __( 'Homepage' )
|
|
33
|
+
: __( 'Posts Page' ) }
|
|
34
|
+
</span>
|
|
35
|
+
) }
|
|
36
|
+
</BaseTitleView>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Field } from '@wordpress/dataviews';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import type { Pattern } from '../../types';
|
|
11
|
+
import { getItemTitle } from '../../actions/utils';
|
|
12
|
+
import PatternTitleView from './view';
|
|
13
|
+
|
|
14
|
+
const patternTitleField: Field< Pattern > = {
|
|
15
|
+
type: 'text',
|
|
16
|
+
id: 'title',
|
|
17
|
+
label: __( 'Title' ),
|
|
18
|
+
placeholder: __( 'No title' ),
|
|
19
|
+
getValue: ( { item } ) => getItemTitle( item ),
|
|
20
|
+
render: PatternTitleView,
|
|
21
|
+
enableHiding: false,
|
|
22
|
+
enableGlobalSearch: true,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Title for the pattern entity.
|
|
27
|
+
*/
|
|
28
|
+
export default patternTitleField;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { Icon, lockSmall } from '@wordpress/icons';
|
|
6
|
+
import { Tooltip } from '@wordpress/components';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import { privateApis as patternPrivateApis } from '@wordpress/patterns';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import type { CommonPost } from '../../types';
|
|
14
|
+
import { BaseTitleView } from '../title/view';
|
|
15
|
+
import { unlock } from '../../lock-unlock';
|
|
16
|
+
|
|
17
|
+
export const { PATTERN_TYPES } = unlock( patternPrivateApis );
|
|
18
|
+
|
|
19
|
+
export default function PatternTitleView( { item }: { item: CommonPost } ) {
|
|
20
|
+
return (
|
|
21
|
+
<BaseTitleView item={ item } className="fields-field__pattern-title">
|
|
22
|
+
{ item.type === PATTERN_TYPES.theme && (
|
|
23
|
+
<Tooltip
|
|
24
|
+
placement="top"
|
|
25
|
+
text={ __( 'This pattern cannot be edited.' ) }
|
|
26
|
+
>
|
|
27
|
+
<Icon icon={ lockSmall } size={ 24 } />
|
|
28
|
+
</Tooltip>
|
|
29
|
+
) }
|
|
30
|
+
</BaseTitleView>
|
|
31
|
+
);
|
|
32
|
+
}
|
package/src/fields/slug/index.ts
CHANGED
|
@@ -14,9 +14,11 @@ const templateField: Field< BasePost > = {
|
|
|
14
14
|
id: 'template',
|
|
15
15
|
type: 'text',
|
|
16
16
|
label: __( 'Template' ),
|
|
17
|
-
getValue: ( { item } ) => item.template,
|
|
18
17
|
Edit: TemplateEdit,
|
|
19
18
|
enableSorting: false,
|
|
20
19
|
};
|
|
21
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Template field for BasePost.
|
|
23
|
+
*/
|
|
22
24
|
export default templateField;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Field } from '@wordpress/dataviews';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import type { Template } from '../../types';
|
|
11
|
+
import { getItemTitle } from '../../actions/utils';
|
|
12
|
+
import TitleView from '../title/view';
|
|
13
|
+
|
|
14
|
+
const templateTitleField: Field< Template > = {
|
|
15
|
+
type: 'text',
|
|
16
|
+
label: __( 'Template' ),
|
|
17
|
+
placeholder: __( 'No title' ),
|
|
18
|
+
id: 'title',
|
|
19
|
+
getValue: ( { item } ) => getItemTitle( item ),
|
|
20
|
+
render: TitleView,
|
|
21
|
+
enableHiding: false,
|
|
22
|
+
enableGlobalSearch: true,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Title for the template entity.
|
|
27
|
+
*/
|
|
28
|
+
export default templateTitleField;
|
|
@@ -7,11 +7,11 @@ import { __ } from '@wordpress/i18n';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
10
|
+
import type { CommonPost } from '../../types';
|
|
11
11
|
import { getItemTitle } from '../../actions/utils';
|
|
12
|
-
import TitleView from './
|
|
12
|
+
import TitleView from './view';
|
|
13
13
|
|
|
14
|
-
const titleField: Field<
|
|
14
|
+
const titleField: Field< CommonPost > = {
|
|
15
15
|
type: 'text',
|
|
16
16
|
id: 'title',
|
|
17
17
|
label: __( 'Title' ),
|
|
@@ -19,6 +19,12 @@ const titleField: Field< BasePost > = {
|
|
|
19
19
|
getValue: ( { item } ) => getItemTitle( item ),
|
|
20
20
|
render: TitleView,
|
|
21
21
|
enableHiding: false,
|
|
22
|
+
enableGlobalSearch: true,
|
|
22
23
|
};
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Title for the any entity with a `title` property.
|
|
27
|
+
* For patterns, pages or templates you should use the respective field
|
|
28
|
+
* because there are some differences in the rendering, labels, etc.
|
|
29
|
+
*/
|
|
24
30
|
export default titleField;
|