@wordpress/fields 0.1.0 → 0.3.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 +4 -0
- package/README.md +12 -0
- package/build/actions/delete-post.js +9 -9
- package/build/actions/delete-post.js.map +1 -1
- package/build/actions/duplicate-post.js +3 -3
- package/build/actions/duplicate-post.js.map +1 -1
- package/build/actions/export-pattern.js.map +1 -1
- package/build/actions/permanently-delete-post.js +4 -3
- package/build/actions/permanently-delete-post.js.map +1 -1
- package/build/actions/reset-post.js +2 -2
- package/build/actions/reset-post.js.map +1 -1
- package/build/actions/restore-post.js +6 -5
- package/build/actions/restore-post.js.map +1 -1
- package/build/actions/trash-post.js +5 -4
- package/build/actions/trash-post.js.map +1 -1
- package/build/actions/view-post-revisions.js +1 -1
- package/build/actions/view-post-revisions.js.map +1 -1
- package/build/fields/featured-image/featured-image-edit.js +113 -0
- package/build/fields/featured-image/featured-image-edit.js.map +1 -0
- package/build/fields/featured-image/featured-image-view.js +41 -0
- package/build/fields/featured-image/featured-image-view.js.map +1 -0
- package/build/fields/featured-image/index.js +30 -0
- package/build/fields/featured-image/index.js.map +1 -0
- package/build/fields/index.js +21 -0
- package/build/fields/index.js.map +1 -1
- package/build/fields/parent/index.js +34 -0
- package/build/fields/parent/index.js.map +1 -0
- package/build/fields/parent/parent-edit.js +243 -0
- package/build/fields/parent/parent-edit.js.map +1 -0
- package/build/fields/parent/parent-view.js +39 -0
- package/build/fields/parent/parent-view.js.map +1 -0
- package/build/fields/parent/utils.js +20 -0
- package/build/fields/parent/utils.js.map +1 -0
- package/build/fields/slug/index.js +30 -0
- package/build/fields/slug/index.js.map +1 -0
- package/build/fields/slug/slug-edit.js +132 -0
- package/build/fields/slug/slug-edit.js.map +1 -0
- package/build/fields/slug/slug-view.js +30 -0
- package/build/fields/slug/slug-view.js.map +1 -0
- package/build/mutation/index.js +3 -2
- package/build/mutation/index.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/actions/delete-post.js +11 -12
- package/build-module/actions/delete-post.js.map +1 -1
- package/build-module/actions/duplicate-post.js +4 -5
- package/build-module/actions/duplicate-post.js.map +1 -1
- package/build-module/actions/export-pattern.js.map +1 -1
- package/build-module/actions/permanently-delete-post.js +4 -3
- package/build-module/actions/permanently-delete-post.js.map +1 -1
- package/build-module/actions/rename-post.js +1 -2
- package/build-module/actions/rename-post.js.map +1 -1
- package/build-module/actions/reorder-page.js +1 -2
- package/build-module/actions/reorder-page.js.map +1 -1
- package/build-module/actions/reset-post.js +3 -4
- package/build-module/actions/reset-post.js.map +1 -1
- package/build-module/actions/restore-post.js +6 -5
- package/build-module/actions/restore-post.js.map +1 -1
- package/build-module/actions/trash-post.js +6 -6
- package/build-module/actions/trash-post.js.map +1 -1
- package/build-module/actions/view-post-revisions.js +1 -1
- package/build-module/actions/view-post-revisions.js.map +1 -1
- package/build-module/fields/featured-image/featured-image-edit.js +105 -0
- package/build-module/fields/featured-image/featured-image-edit.js.map +1 -0
- package/build-module/fields/featured-image/featured-image-view.js +33 -0
- package/build-module/fields/featured-image/featured-image-view.js.map +1 -0
- package/build-module/fields/featured-image/index.js +24 -0
- package/build-module/fields/featured-image/index.js.map +1 -0
- package/build-module/fields/index.js +3 -0
- package/build-module/fields/index.js.map +1 -1
- package/build-module/fields/parent/index.js +28 -0
- package/build-module/fields/parent/index.js.map +1 -0
- package/build-module/fields/parent/parent-edit.js +230 -0
- package/build-module/fields/parent/parent-edit.js.map +1 -0
- package/build-module/fields/parent/parent-view.js +32 -0
- package/build-module/fields/parent/parent-view.js.map +1 -0
- package/build-module/fields/parent/utils.js +14 -0
- package/build-module/fields/parent/utils.js.map +1 -0
- package/build-module/fields/slug/index.js +23 -0
- package/build-module/fields/slug/index.js.map +1 -0
- package/build-module/fields/slug/slug-edit.js +125 -0
- package/build-module/fields/slug/slug-edit.js.map +1 -0
- package/build-module/fields/slug/slug-view.js +24 -0
- package/build-module/fields/slug/slug-view.js.map +1 -0
- package/build-module/mutation/index.js +3 -2
- package/build-module/mutation/index.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-style/styles-rtl.css +134 -0
- package/build-style/styles.css +134 -0
- package/build-types/actions/delete-post.d.ts.map +1 -1
- package/build-types/fields/featured-image/featured-image-edit.d.ts +7 -0
- package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -0
- package/build-types/fields/featured-image/featured-image-view.d.ts +7 -0
- package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -0
- package/build-types/fields/featured-image/index.d.ts +11 -0
- package/build-types/fields/featured-image/index.d.ts.map +1 -0
- package/build-types/fields/index.d.ts +3 -0
- package/build-types/fields/index.d.ts.map +1 -1
- package/build-types/fields/parent/index.d.ts +14 -0
- package/build-types/fields/parent/index.d.ts.map +1 -0
- package/build-types/fields/parent/parent-edit.d.ts +9 -0
- package/build-types/fields/parent/parent-edit.d.ts.map +1 -0
- package/build-types/fields/parent/parent-view.d.ts +7 -0
- package/build-types/fields/parent/parent-view.d.ts.map +1 -0
- package/build-types/fields/parent/utils.d.ts +6 -0
- package/build-types/fields/parent/utils.d.ts.map +1 -0
- package/build-types/fields/slug/index.d.ts +11 -0
- package/build-types/fields/slug/index.d.ts.map +1 -0
- package/build-types/fields/slug/slug-edit.d.ts +8 -0
- package/build-types/fields/slug/slug-edit.d.ts.map +1 -0
- package/build-types/fields/slug/slug-view.d.ts +9 -0
- package/build-types/fields/slug/slug-view.d.ts.map +1 -0
- package/build-types/types.d.ts +2 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +27 -23
- package/src/actions/delete-post.tsx +8 -5
- package/src/actions/duplicate-post.tsx +2 -2
- package/src/actions/view-post-revisions.tsx +1 -1
- package/src/fields/featured-image/featured-image-edit.tsx +122 -0
- package/src/fields/featured-image/featured-image-view.tsx +38 -0
- package/src/fields/featured-image/index.ts +24 -0
- package/src/fields/featured-image/style.scss +95 -0
- package/src/fields/index.ts +3 -0
- package/src/fields/parent/index.ts +27 -0
- package/src/fields/parent/parent-edit.tsx +348 -0
- package/src/fields/parent/parent-view.tsx +33 -0
- package/src/fields/parent/utils.ts +18 -0
- package/src/fields/slug/index.ts +23 -0
- package/src/fields/slug/slug-edit.tsx +156 -0
- package/src/fields/slug/slug-view.tsx +26 -0
- package/src/fields/slug/style.scss +22 -0
- package/src/mutation/index.ts +3 -3
- package/src/styles.scss +1 -0
- package/src/types.ts +2 -0
- package/tsconfig.json +3 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/fields/parent/utils.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,wBAAwB,CAAE,IAAI,EAAE,QAAQ,UAMvD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Field } from '@wordpress/dataviews';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import type { BasePost } from '../../types';
|
|
9
|
+
declare const slugField: Field<BasePost>;
|
|
10
|
+
export default slugField;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/slug/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,QAAA,MAAM,SAAS,EAAE,KAAK,CAAE,QAAQ,CAO/B,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DataFormControlProps } from '@wordpress/dataviews';
|
|
2
|
+
/**
|
|
3
|
+
* Internal dependencies
|
|
4
|
+
*/
|
|
5
|
+
import type { BasePost } from '../../types';
|
|
6
|
+
declare const SlugEdit: ({ field, onChange, data, }: DataFormControlProps<BasePost>) => import("react").JSX.Element;
|
|
7
|
+
export default SlugEdit;
|
|
8
|
+
//# sourceMappingURL=slug-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slug-edit.d.ts","sourceRoot":"","sources":["../../../src/fields/slug/slug-edit.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGjE;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,QAAA,MAAM,QAAQ,+BAIX,oBAAoB,CAAE,QAAQ,CAAE,gCA6HlC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slug-view.d.ts","sourceRoot":"","sources":["../../../src/fields/slug/slug-view.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,QAAA,MAAM,QAAQ,aAAe;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,WAa9C,CAAC;AAEF,eAAe,QAAQ,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,WAAW,GACX,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,OAAO,CAAC;AAEX,MAAM,WAAW,UAAU;IAC1B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,G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W,QAAQ;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE;QACV,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,SAAS,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACF;AAGD,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,CAAC,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.
|
|
3
|
+
"version": "0.3.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",
|
|
@@ -31,28 +31,31 @@
|
|
|
31
31
|
"src/**/*.scss"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/runtime": "
|
|
35
|
-
"@wordpress/api-fetch": "
|
|
36
|
-
"@wordpress/blob": "
|
|
37
|
-
"@wordpress/blocks": "
|
|
38
|
-
"@wordpress/components": "
|
|
39
|
-
"@wordpress/compose": "
|
|
40
|
-
"@wordpress/core-data": "
|
|
41
|
-
"@wordpress/data": "
|
|
42
|
-
"@wordpress/dataviews": "
|
|
43
|
-
"@wordpress/element": "
|
|
44
|
-
"@wordpress/hooks": "
|
|
45
|
-
"@wordpress/html-entities": "
|
|
46
|
-
"@wordpress/i18n": "
|
|
47
|
-
"@wordpress/icons": "
|
|
48
|
-
"@wordpress/
|
|
49
|
-
"@wordpress/
|
|
50
|
-
"@wordpress/
|
|
51
|
-
"@wordpress/
|
|
52
|
-
"@wordpress/
|
|
53
|
-
"@wordpress/
|
|
34
|
+
"@babel/runtime": "7.25.7",
|
|
35
|
+
"@wordpress/api-fetch": "*",
|
|
36
|
+
"@wordpress/blob": "*",
|
|
37
|
+
"@wordpress/blocks": "*",
|
|
38
|
+
"@wordpress/components": "*",
|
|
39
|
+
"@wordpress/compose": "*",
|
|
40
|
+
"@wordpress/core-data": "*",
|
|
41
|
+
"@wordpress/data": "*",
|
|
42
|
+
"@wordpress/dataviews": "*",
|
|
43
|
+
"@wordpress/element": "*",
|
|
44
|
+
"@wordpress/hooks": "*",
|
|
45
|
+
"@wordpress/html-entities": "*",
|
|
46
|
+
"@wordpress/i18n": "*",
|
|
47
|
+
"@wordpress/icons": "*",
|
|
48
|
+
"@wordpress/media-utils": "*",
|
|
49
|
+
"@wordpress/notices": "*",
|
|
50
|
+
"@wordpress/patterns": "*",
|
|
51
|
+
"@wordpress/primitives": "*",
|
|
52
|
+
"@wordpress/private-apis": "*",
|
|
53
|
+
"@wordpress/router": "*",
|
|
54
|
+
"@wordpress/url": "*",
|
|
55
|
+
"@wordpress/warning": "*",
|
|
54
56
|
"change-case": "4.1.2",
|
|
55
|
-
"client-zip": "^2.4.5"
|
|
57
|
+
"client-zip": "^2.4.5",
|
|
58
|
+
"remove-accents": "^0.5.0"
|
|
56
59
|
},
|
|
57
60
|
"peerDependencies": {
|
|
58
61
|
"react": "^18.0.0"
|
|
@@ -60,5 +63,6 @@
|
|
|
60
63
|
"publishConfig": {
|
|
61
64
|
"access": "public"
|
|
62
65
|
},
|
|
63
|
-
"
|
|
66
|
+
"wpScript": true,
|
|
67
|
+
"gitHead": "dcf4613b33b0eda14e203ac30f700ed0db70347f"
|
|
64
68
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { trash } from '@wordpress/icons';
|
|
5
|
-
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
5
|
+
import { __, _x, _n, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { useState } from '@wordpress/element';
|
|
7
7
|
import {
|
|
8
8
|
Button,
|
|
@@ -66,8 +66,8 @@ const deletePostAction: Action< Template | TemplatePart | Pattern > = {
|
|
|
66
66
|
items.length
|
|
67
67
|
)
|
|
68
68
|
: sprintf(
|
|
69
|
-
// translators: %s: The template or template part's
|
|
70
|
-
|
|
69
|
+
// translators: %s: The template or template part's title
|
|
70
|
+
_x( 'Delete "%s"?', 'template part' ),
|
|
71
71
|
getItemTitle( items[ 0 ] )
|
|
72
72
|
) }
|
|
73
73
|
</Text>
|
|
@@ -100,8 +100,11 @@ const deletePostAction: Action< Template | TemplatePart | Pattern > = {
|
|
|
100
100
|
)
|
|
101
101
|
)
|
|
102
102
|
: sprintf(
|
|
103
|
-
/* translators: The template/part's name. */
|
|
104
|
-
|
|
103
|
+
/* translators: %s: The template/part's name. */
|
|
104
|
+
_x(
|
|
105
|
+
'"%s" deleted.',
|
|
106
|
+
'template part'
|
|
107
|
+
),
|
|
105
108
|
decodeEntities(
|
|
106
109
|
getItemTitle( item )
|
|
107
110
|
)
|
|
@@ -38,7 +38,7 @@ const duplicatePost: Action< BasePost > = {
|
|
|
38
38
|
...items[ 0 ],
|
|
39
39
|
title: sprintf(
|
|
40
40
|
/* translators: %s: Existing template title */
|
|
41
|
-
|
|
41
|
+
_x( '%s (Copy)', 'template' ),
|
|
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 template e.g: "
|
|
107
|
+
// translators: %s: Title of the created post or template, e.g: "Hello world".
|
|
108
108
|
__( '"%s" successfully created.' ),
|
|
109
109
|
decodeEntities( newItem.title?.rendered || item.title )
|
|
110
110
|
),
|
|
@@ -17,7 +17,7 @@ const viewPostRevisions: Action< Post > = {
|
|
|
17
17
|
const revisionsCount =
|
|
18
18
|
items[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
|
|
19
19
|
return sprintf(
|
|
20
|
-
/* translators: %s: number of revisions */
|
|
20
|
+
/* translators: %s: number of revisions. */
|
|
21
21
|
__( 'View revisions (%s)' ),
|
|
22
22
|
revisionsCount
|
|
23
23
|
);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Button, __experimentalGrid as Grid } from '@wordpress/components';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { useCallback, useRef } from '@wordpress/element';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import { MediaUpload } from '@wordpress/media-utils';
|
|
9
|
+
import { lineSolid } from '@wordpress/icons';
|
|
10
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
+
import type { DataFormControlProps } from '@wordpress/dataviews';
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import type { BasePost } from '../../types';
|
|
16
|
+
import { __ } from '@wordpress/i18n';
|
|
17
|
+
|
|
18
|
+
export const FeaturedImageEdit = ( {
|
|
19
|
+
data,
|
|
20
|
+
field,
|
|
21
|
+
onChange,
|
|
22
|
+
}: DataFormControlProps< BasePost > ) => {
|
|
23
|
+
const { id } = field;
|
|
24
|
+
|
|
25
|
+
const value = field.getValue( { item: data } );
|
|
26
|
+
|
|
27
|
+
const media = useSelect(
|
|
28
|
+
( select ) => {
|
|
29
|
+
const { getEntityRecord } = select( coreStore );
|
|
30
|
+
return getEntityRecord( 'root', 'media', value );
|
|
31
|
+
},
|
|
32
|
+
[ value ]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const onChangeControl = useCallback(
|
|
36
|
+
( newValue: number ) =>
|
|
37
|
+
onChange( {
|
|
38
|
+
[ id ]: newValue,
|
|
39
|
+
} ),
|
|
40
|
+
[ id, onChange ]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const url = media?.source_url;
|
|
44
|
+
const title = media?.title?.rendered;
|
|
45
|
+
const ref = useRef( null );
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<fieldset className="fields-controls__featured-image">
|
|
49
|
+
<div className="fields-controls__featured-image-container">
|
|
50
|
+
<MediaUpload
|
|
51
|
+
onSelect={ ( selectedMedia: { id: number } ) => {
|
|
52
|
+
onChangeControl( selectedMedia.id );
|
|
53
|
+
} }
|
|
54
|
+
allowedTypes={ [ 'image' ] }
|
|
55
|
+
render={ ( { open }: { open: () => void } ) => {
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
ref={ ref }
|
|
59
|
+
role="button"
|
|
60
|
+
tabIndex={ -1 }
|
|
61
|
+
onClick={ () => {
|
|
62
|
+
open();
|
|
63
|
+
} }
|
|
64
|
+
onKeyDown={ open }
|
|
65
|
+
>
|
|
66
|
+
<Grid
|
|
67
|
+
rowGap={ 0 }
|
|
68
|
+
columnGap={ 8 }
|
|
69
|
+
templateColumns="24px 1fr 24px"
|
|
70
|
+
>
|
|
71
|
+
{ url && (
|
|
72
|
+
<>
|
|
73
|
+
<img
|
|
74
|
+
className="fields-controls__featured-image-image"
|
|
75
|
+
alt=""
|
|
76
|
+
width={ 24 }
|
|
77
|
+
height={ 24 }
|
|
78
|
+
src={ url }
|
|
79
|
+
/>
|
|
80
|
+
<span className="fields-controls__featured-image-title">
|
|
81
|
+
{ title }
|
|
82
|
+
</span>
|
|
83
|
+
</>
|
|
84
|
+
) }
|
|
85
|
+
{ ! url && (
|
|
86
|
+
<>
|
|
87
|
+
<span
|
|
88
|
+
className="fields-controls__featured-image-placeholder"
|
|
89
|
+
style={ {
|
|
90
|
+
width: '24px',
|
|
91
|
+
height: '24px',
|
|
92
|
+
} }
|
|
93
|
+
/>
|
|
94
|
+
<span className="fields-controls__featured-image-title">
|
|
95
|
+
{ __( 'Choose an image…' ) }
|
|
96
|
+
</span>
|
|
97
|
+
</>
|
|
98
|
+
) }
|
|
99
|
+
{ url && (
|
|
100
|
+
<>
|
|
101
|
+
<Button
|
|
102
|
+
size="small"
|
|
103
|
+
className="fields-controls__featured-image-remove-button"
|
|
104
|
+
icon={ lineSolid }
|
|
105
|
+
onClick={ (
|
|
106
|
+
event: React.MouseEvent< HTMLButtonElement >
|
|
107
|
+
) => {
|
|
108
|
+
event.stopPropagation();
|
|
109
|
+
onChangeControl( 0 );
|
|
110
|
+
} }
|
|
111
|
+
/>
|
|
112
|
+
</>
|
|
113
|
+
) }
|
|
114
|
+
</Grid>
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
} }
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
</fieldset>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import type { BasePost } from '../../types';
|
|
11
|
+
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
12
|
+
|
|
13
|
+
export const FeaturedImageView = ( {
|
|
14
|
+
item,
|
|
15
|
+
}: DataViewRenderFieldProps< BasePost > ) => {
|
|
16
|
+
const mediaId = item.featured_media;
|
|
17
|
+
|
|
18
|
+
const media = useSelect(
|
|
19
|
+
( select ) => {
|
|
20
|
+
const { getEntityRecord } = select( coreStore );
|
|
21
|
+
return mediaId ? getEntityRecord( 'root', 'media', mediaId ) : null;
|
|
22
|
+
},
|
|
23
|
+
[ mediaId ]
|
|
24
|
+
);
|
|
25
|
+
const url = media?.source_url;
|
|
26
|
+
|
|
27
|
+
if ( url ) {
|
|
28
|
+
return (
|
|
29
|
+
<img
|
|
30
|
+
className="fields-controls__featured-image-image"
|
|
31
|
+
src={ url }
|
|
32
|
+
alt=""
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return <span className="fields-controls__featured-image-placeholder" />;
|
|
38
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Field } from '@wordpress/dataviews';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { BasePost } from '../../types';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { FeaturedImageEdit } from './featured-image-edit';
|
|
12
|
+
import { FeaturedImageView } from './featured-image-view';
|
|
13
|
+
|
|
14
|
+
const featuredImageField: Field< BasePost > = {
|
|
15
|
+
id: 'featured_media',
|
|
16
|
+
type: 'text',
|
|
17
|
+
label: __( 'Featured Image' ),
|
|
18
|
+
getValue: ( { item } ) => item.featured_media,
|
|
19
|
+
Edit: FeaturedImageEdit,
|
|
20
|
+
render: FeaturedImageView,
|
|
21
|
+
enableSorting: false,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default featuredImageField;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
.fields-controls__featured-image-placeholder {
|
|
2
|
+
border-radius: $radius-small;
|
|
3
|
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
|
|
4
|
+
display: inline-block;
|
|
5
|
+
padding: 0;
|
|
6
|
+
background:
|
|
7
|
+
$white
|
|
8
|
+
linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.fields-controls__featured-image-title {
|
|
12
|
+
width: 100%;
|
|
13
|
+
color: $gray-900;
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
text-overflow: ellipsis;
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.fields-controls__featured-image-image {
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
border-radius: $radius-small;
|
|
23
|
+
align-self: center;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.fields-controls__featured-image-container {
|
|
27
|
+
.fields-controls__featured-image-placeholder {
|
|
28
|
+
margin: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
span {
|
|
32
|
+
margin-right: auto;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fieldset.fields-controls__featured-image {
|
|
37
|
+
.fields-controls__featured-image-container {
|
|
38
|
+
border: $border-width solid $gray-300;
|
|
39
|
+
border-radius: $radius-small;
|
|
40
|
+
padding: 8px 12px;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
&:hover {
|
|
43
|
+
background-color: $gray-100;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.fields-controls__featured-image-placeholder {
|
|
48
|
+
width: 24px;
|
|
49
|
+
height: 24px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
span {
|
|
53
|
+
align-self: center;
|
|
54
|
+
text-align: start;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.fields-controls__featured-image-upload-button {
|
|
59
|
+
padding: 0;
|
|
60
|
+
height: fit-content;
|
|
61
|
+
&:hover,
|
|
62
|
+
&:focus {
|
|
63
|
+
border: 0;
|
|
64
|
+
color: unset;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.fields-controls__featured-image-remove-button {
|
|
69
|
+
place-self: end;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.dataforms-layouts-panel__field-control {
|
|
74
|
+
.fields-controls__featured-image-image {
|
|
75
|
+
width: 16px;
|
|
76
|
+
height: 16px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.fields-controls__featured-image-placeholder {
|
|
80
|
+
width: 16px;
|
|
81
|
+
height: 16px;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.dataviews-view-table__cell-content-wrapper {
|
|
86
|
+
.fields-controls__featured-image-image {
|
|
87
|
+
width: 32px;
|
|
88
|
+
height: 32px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.fields-controls__featured-image-placeholder {
|
|
92
|
+
width: 32px;
|
|
93
|
+
height: 32px;
|
|
94
|
+
}
|
|
95
|
+
}
|
package/src/fields/index.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Field } from '@wordpress/dataviews';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { BasePost } from '../../types';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { ParentEdit } from './parent-edit';
|
|
12
|
+
import { ParentView } from './parent-view';
|
|
13
|
+
|
|
14
|
+
const parentField: Field< BasePost > = {
|
|
15
|
+
id: 'parent',
|
|
16
|
+
type: 'text',
|
|
17
|
+
label: __( 'Parent' ),
|
|
18
|
+
getValue: ( { item } ) => item.parent,
|
|
19
|
+
Edit: ParentEdit,
|
|
20
|
+
render: ParentView,
|
|
21
|
+
enableSorting: true,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This field is used to display the post parent.
|
|
26
|
+
*/
|
|
27
|
+
export default parentField;
|