@wordpress/fields 0.3.0 → 0.4.1-next.082ed6819.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 +20 -0
- package/build/actions/utils.js +2 -2
- package/build/actions/utils.js.map +1 -1
- package/build/fields/author/author-view.js +72 -0
- package/build/fields/author/author-view.js.map +1 -0
- package/build/fields/author/index.js +35 -0
- package/build/fields/author/index.js.map +1 -0
- package/build/fields/comment-status/index.js +40 -0
- package/build/fields/comment-status/index.js.map +1 -0
- package/build/fields/date/date-view.js +69 -0
- package/build/fields/date/date-view.js.map +1 -0
- package/build/fields/date/index.js +29 -0
- package/build/fields/date/index.js.map +1 -0
- package/build/fields/featured-image/featured-image-edit.js.map +1 -1
- package/build/fields/featured-image/featured-image-view.js.map +1 -1
- package/build/fields/featured-image/index.js +0 -3
- package/build/fields/featured-image/index.js.map +1 -1
- package/build/fields/index.js +35 -0
- package/build/fields/index.js.map +1 -1
- package/build/fields/order/index.js +1 -1
- package/build/fields/order/index.js.map +1 -1
- package/build/fields/parent/index.js +0 -3
- package/build/fields/parent/index.js.map +1 -1
- package/build/fields/parent/parent-edit.js +6 -6
- package/build/fields/parent/parent-edit.js.map +1 -1
- package/build/fields/parent/parent-view.js +1 -1
- package/build/fields/parent/parent-view.js.map +1 -1
- package/build/fields/password/edit.js +65 -0
- package/build/fields/password/edit.js.map +1 -0
- package/build/fields/password/index.js +30 -0
- package/build/fields/password/index.js.map +1 -0
- package/build/fields/slug/index.js +0 -3
- package/build/fields/slug/index.js.map +1 -1
- package/build/fields/slug/slug-edit.js +23 -26
- package/build/fields/slug/slug-edit.js.map +1 -1
- package/build/fields/slug/slug-view.js +3 -2
- package/build/fields/slug/slug-view.js.map +1 -1
- package/build/fields/slug/utils.js +21 -0
- package/build/fields/slug/utils.js.map +1 -0
- package/build/fields/status/index.js +37 -0
- package/build/fields/status/index.js.map +1 -0
- package/build/fields/status/status-elements.js +46 -0
- package/build/fields/status/status-elements.js.map +1 -0
- package/build/fields/status/status-view.js +41 -0
- package/build/fields/status/status-view.js.map +1 -0
- package/build/fields/title/index.js +5 -1
- package/build/fields/title/index.js.map +1 -1
- package/build/fields/title/title-view.js +61 -0
- package/build/fields/title/title-view.js.map +1 -0
- package/build/index.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/actions/utils.js +2 -2
- package/build-module/actions/utils.js.map +1 -1
- package/build-module/fields/author/author-view.js +64 -0
- package/build-module/fields/author/author-view.js.map +1 -0
- package/build-module/fields/author/index.js +29 -0
- package/build-module/fields/author/index.js.map +1 -0
- package/build-module/fields/comment-status/index.js +35 -0
- package/build-module/fields/comment-status/index.js.map +1 -0
- package/build-module/fields/date/date-view.js +62 -0
- package/build-module/fields/date/date-view.js.map +1 -0
- package/build-module/fields/date/index.js +23 -0
- package/build-module/fields/date/index.js.map +1 -0
- package/build-module/fields/featured-image/featured-image-edit.js +1 -2
- package/build-module/fields/featured-image/featured-image-edit.js.map +1 -1
- package/build-module/fields/featured-image/featured-image-view.js.map +1 -1
- package/build-module/fields/featured-image/index.js +2 -4
- package/build-module/fields/featured-image/index.js.map +1 -1
- package/build-module/fields/index.js +5 -0
- package/build-module/fields/index.js.map +1 -1
- package/build-module/fields/order/index.js +2 -1
- package/build-module/fields/order/index.js.map +1 -1
- package/build-module/fields/parent/index.js +2 -4
- package/build-module/fields/parent/index.js.map +1 -1
- package/build-module/fields/parent/parent-edit.js +10 -8
- package/build-module/fields/parent/parent-edit.js.map +1 -1
- package/build-module/fields/parent/parent-view.js +1 -1
- package/build-module/fields/parent/parent-view.js.map +1 -1
- package/build-module/fields/password/edit.js +58 -0
- package/build-module/fields/password/edit.js.map +1 -0
- package/build-module/fields/password/index.js +23 -0
- package/build-module/fields/password/index.js.map +1 -0
- package/build-module/fields/slug/index.js +2 -4
- package/build-module/fields/slug/index.js.map +1 -1
- package/build-module/fields/slug/slug-edit.js +25 -27
- package/build-module/fields/slug/slug-edit.js.map +1 -1
- package/build-module/fields/slug/slug-view.js +3 -2
- package/build-module/fields/slug/slug-view.js.map +1 -1
- package/build-module/fields/slug/utils.js +13 -0
- package/build-module/fields/slug/utils.js.map +1 -0
- package/build-module/fields/status/index.js +31 -0
- package/build-module/fields/status/index.js.map +1 -0
- package/build-module/fields/status/status-elements.js +40 -0
- package/build-module/fields/status/status-elements.js.map +1 -0
- package/build-module/fields/status/status-view.js +34 -0
- package/build-module/fields/status/status-view.js.map +1 -0
- package/build-module/fields/title/index.js +4 -1
- package/build-module/fields/title/index.js.map +1 -1
- package/build-module/fields/title/title-view.js +55 -0
- package/build-module/fields/title/title-view.js.map +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-style/{styles-rtl.css → style-rtl.css} +77 -0
- package/build-style/{styles.css → style.css} +77 -0
- package/build-types/fields/author/author-view.d.ts +9 -0
- package/build-types/fields/author/author-view.d.ts.map +1 -0
- package/build-types/fields/author/index.d.ts +14 -0
- package/build-types/fields/author/index.d.ts.map +1 -0
- package/build-types/fields/comment-status/index.d.ts +14 -0
- package/build-types/fields/comment-status/index.d.ts.map +1 -0
- package/build-types/fields/date/date-view.d.ts +9 -0
- package/build-types/fields/date/date-view.d.ts.map +1 -0
- package/build-types/fields/date/index.d.ts +14 -0
- package/build-types/fields/date/index.d.ts.map +1 -0
- package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -1
- package/build-types/fields/featured-image/featured-image-view.d.ts +1 -1
- package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -1
- package/build-types/fields/featured-image/index.d.ts.map +1 -1
- package/build-types/fields/index.d.ts +5 -0
- package/build-types/fields/index.d.ts.map +1 -1
- package/build-types/fields/order/index.d.ts.map +1 -1
- package/build-types/fields/parent/index.d.ts.map +1 -1
- package/build-types/fields/parent/parent-edit.d.ts +3 -0
- package/build-types/fields/parent/parent-edit.d.ts.map +1 -1
- package/build-types/fields/parent/parent-view.d.ts +1 -1
- package/build-types/fields/parent/parent-view.d.ts.map +1 -1
- package/build-types/fields/password/edit.d.ts +8 -0
- package/build-types/fields/password/edit.d.ts.map +1 -0
- package/build-types/fields/password/index.d.ts +14 -0
- package/build-types/fields/password/index.d.ts.map +1 -0
- package/build-types/fields/slug/index.d.ts.map +1 -1
- package/build-types/fields/slug/slug-edit.d.ts.map +1 -1
- package/build-types/fields/slug/slug-view.d.ts.map +1 -1
- package/build-types/fields/slug/utils.d.ts +6 -0
- package/build-types/fields/slug/utils.d.ts.map +1 -0
- package/build-types/fields/status/index.d.ts +14 -0
- package/build-types/fields/status/index.d.ts.map +1 -0
- package/build-types/fields/status/status-elements.d.ts +13 -0
- package/build-types/fields/status/status-elements.d.ts.map +1 -0
- package/build-types/fields/status/status-view.d.ts +9 -0
- package/build-types/fields/status/status-view.d.ts.map +1 -0
- package/build-types/fields/title/index.d.ts.map +1 -1
- package/build-types/fields/title/title-view.d.ts +9 -0
- package/build-types/fields/title/title-view.d.ts.map +1 -0
- package/build-types/index.d.ts +1 -0
- 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 +14 -1
- package/build-types/types.d.ts.map +1 -1
- package/package.json +23 -21
- package/src/actions/utils.ts +2 -2
- package/src/fields/author/author-view.tsx +63 -0
- package/src/fields/author/index.tsx +32 -0
- package/src/fields/comment-status/index.tsx +40 -0
- package/src/fields/date/date-view.tsx +92 -0
- package/src/fields/date/index.tsx +23 -0
- package/src/fields/featured-image/featured-image-edit.tsx +2 -1
- package/src/fields/featured-image/featured-image-view.tsx +1 -1
- package/src/fields/featured-image/index.ts +1 -2
- package/src/fields/featured-image/style.scss +2 -5
- package/src/fields/index.ts +5 -0
- package/src/fields/order/index.ts +2 -1
- package/src/fields/parent/index.ts +1 -2
- package/src/fields/parent/parent-edit.tsx +9 -9
- package/src/fields/parent/parent-view.tsx +2 -2
- package/src/fields/password/edit.tsx +68 -0
- package/src/fields/password/index.tsx +24 -0
- package/src/fields/slug/index.ts +1 -2
- package/src/fields/slug/slug-edit.tsx +21 -24
- package/src/fields/slug/slug-view.tsx +3 -2
- package/src/fields/slug/utils.ts +15 -0
- package/src/fields/status/index.tsx +32 -0
- package/src/fields/status/status-elements.tsx +50 -0
- package/src/fields/status/status-view.tsx +28 -0
- package/src/fields/title/index.ts +3 -0
- package/src/fields/title/title-view.tsx +62 -0
- package/src/index.ts +1 -0
- package/src/style.scss +2 -0
- package/src/types.ts +17 -1
- package/tsconfig.json +10 -9
- package/tsconfig.tsbuildinfo +1 -1
- package/src/styles.scss +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GACZ,
|
|
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,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,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,OAAO,EAAE,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,CAAC;CACf;AAED,UAAU,KAAK;IACd,qBAAqB,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC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,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/fields",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1-next.082ed6819.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",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"main": "build/index.js",
|
|
26
26
|
"module": "build-module/index.js",
|
|
27
27
|
"react-native": "src/index",
|
|
28
|
+
"wpScript": true,
|
|
28
29
|
"types": "build-types",
|
|
29
30
|
"sideEffects": [
|
|
30
31
|
"build-style/**",
|
|
@@ -32,29 +33,31 @@
|
|
|
32
33
|
],
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@babel/runtime": "7.25.7",
|
|
35
|
-
"@wordpress/api-fetch": "
|
|
36
|
-
"@wordpress/blob": "
|
|
37
|
-
"@wordpress/blocks": "
|
|
36
|
+
"@wordpress/api-fetch": "^7.12.1-next.082ed6819.0",
|
|
37
|
+
"@wordpress/blob": "^4.12.1-next.082ed6819.0",
|
|
38
|
+
"@wordpress/blocks": "^14.1.1-next.082ed6819.0",
|
|
38
39
|
"@wordpress/components": "*",
|
|
39
|
-
"@wordpress/compose": "
|
|
40
|
-
"@wordpress/core-data": "
|
|
40
|
+
"@wordpress/compose": "^7.12.1-next.082ed6819.0",
|
|
41
|
+
"@wordpress/core-data": "^7.12.1-next.082ed6819.0",
|
|
41
42
|
"@wordpress/data": "*",
|
|
42
43
|
"@wordpress/dataviews": "*",
|
|
43
|
-
"@wordpress/
|
|
44
|
-
"@wordpress/
|
|
45
|
-
"@wordpress/
|
|
46
|
-
"@wordpress/
|
|
47
|
-
"@wordpress/
|
|
48
|
-
"@wordpress/
|
|
49
|
-
"@wordpress/
|
|
50
|
-
"@wordpress/
|
|
51
|
-
"@wordpress/
|
|
52
|
-
"@wordpress/
|
|
53
|
-
"@wordpress/
|
|
54
|
-
"@wordpress/
|
|
55
|
-
"@wordpress/
|
|
44
|
+
"@wordpress/date": "^5.12.1-next.082ed6819.0",
|
|
45
|
+
"@wordpress/element": "^6.12.1-next.082ed6819.0",
|
|
46
|
+
"@wordpress/hooks": "^4.12.1-next.082ed6819.0",
|
|
47
|
+
"@wordpress/html-entities": "^4.12.1-next.082ed6819.0",
|
|
48
|
+
"@wordpress/i18n": "^5.12.1-next.082ed6819.0",
|
|
49
|
+
"@wordpress/icons": "^10.12.1-next.082ed6819.0",
|
|
50
|
+
"@wordpress/media-utils": "^5.12.1-next.082ed6819.0",
|
|
51
|
+
"@wordpress/notices": "^5.12.1-next.082ed6819.0",
|
|
52
|
+
"@wordpress/patterns": "^2.12.1-next.082ed6819.0",
|
|
53
|
+
"@wordpress/primitives": "^4.12.1-next.082ed6819.0",
|
|
54
|
+
"@wordpress/private-apis": "^1.12.1-next.082ed6819.0",
|
|
55
|
+
"@wordpress/router": "^1.12.1-next.082ed6819.0",
|
|
56
|
+
"@wordpress/url": "^4.12.1-next.082ed6819.0",
|
|
57
|
+
"@wordpress/warning": "^3.12.1-next.082ed6819.0",
|
|
56
58
|
"change-case": "4.1.2",
|
|
57
59
|
"client-zip": "^2.4.5",
|
|
60
|
+
"clsx": "2.1.1",
|
|
58
61
|
"remove-accents": "^0.5.0"
|
|
59
62
|
},
|
|
60
63
|
"peerDependencies": {
|
|
@@ -63,6 +66,5 @@
|
|
|
63
66
|
"publishConfig": {
|
|
64
67
|
"access": "public"
|
|
65
68
|
},
|
|
66
|
-
"
|
|
67
|
-
"gitHead": "dcf4613b33b0eda14e203ac30f700ed0db70347f"
|
|
69
|
+
"gitHead": "2bb7bad15ddb8e88210fab7d4a1ef1565466e424"
|
|
68
70
|
}
|
package/src/actions/utils.ts
CHANGED
|
@@ -34,10 +34,10 @@ export function getItemTitle( item: Post ) {
|
|
|
34
34
|
if ( typeof item.title === 'string' ) {
|
|
35
35
|
return decodeEntities( item.title );
|
|
36
36
|
}
|
|
37
|
-
if ( 'rendered' in item.title ) {
|
|
37
|
+
if ( item.title && 'rendered' in item.title ) {
|
|
38
38
|
return decodeEntities( item.title.rendered );
|
|
39
39
|
}
|
|
40
|
-
if ( 'raw' in item.title ) {
|
|
40
|
+
if ( item.title && 'raw' in item.title ) {
|
|
41
41
|
return decodeEntities( item.title.raw );
|
|
42
42
|
}
|
|
43
43
|
return '';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { useState } from '@wordpress/element';
|
|
11
|
+
import { commentAuthorAvatar as authorIcon } from '@wordpress/icons';
|
|
12
|
+
import { __experimentalHStack as HStack, Icon } from '@wordpress/components';
|
|
13
|
+
import { useSelect } from '@wordpress/data';
|
|
14
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
15
|
+
import type { User } from '@wordpress/core-data';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
import type { BasePostWithEmbeddedAuthor } from '../../types';
|
|
21
|
+
|
|
22
|
+
function AuthorView( { item }: { item: BasePostWithEmbeddedAuthor } ) {
|
|
23
|
+
const { text, imageUrl } = useSelect(
|
|
24
|
+
( select ) => {
|
|
25
|
+
const { getEntityRecord } = select( coreStore );
|
|
26
|
+
let user: User | undefined;
|
|
27
|
+
if ( !! item.author ) {
|
|
28
|
+
user = getEntityRecord( 'root', 'user', item.author );
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
imageUrl: user?.avatar_urls?.[ 48 ],
|
|
32
|
+
text: user?.name,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
[ item ]
|
|
36
|
+
);
|
|
37
|
+
const [ isImageLoaded, setIsImageLoaded ] = useState( false );
|
|
38
|
+
return (
|
|
39
|
+
<HStack alignment="left" spacing={ 0 }>
|
|
40
|
+
{ !! imageUrl && (
|
|
41
|
+
<div
|
|
42
|
+
className={ clsx( 'page-templates-author-field__avatar', {
|
|
43
|
+
'is-loaded': isImageLoaded,
|
|
44
|
+
} ) }
|
|
45
|
+
>
|
|
46
|
+
<img
|
|
47
|
+
onLoad={ () => setIsImageLoaded( true ) }
|
|
48
|
+
alt={ __( 'Author avatar' ) }
|
|
49
|
+
src={ imageUrl }
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
) }
|
|
53
|
+
{ ! imageUrl && (
|
|
54
|
+
<div className="page-templates-author-field__icon">
|
|
55
|
+
<Icon icon={ authorIcon } />
|
|
56
|
+
</div>
|
|
57
|
+
) }
|
|
58
|
+
<span className="page-templates-author-field__name">{ text }</span>
|
|
59
|
+
</HStack>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default AuthorView;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { BasePostWithEmbeddedAuthor } from '../../types';
|
|
11
|
+
import AuthorView from './author-view';
|
|
12
|
+
|
|
13
|
+
const authorField: Field< BasePostWithEmbeddedAuthor > = {
|
|
14
|
+
label: __( 'Author' ),
|
|
15
|
+
id: 'author',
|
|
16
|
+
type: 'integer',
|
|
17
|
+
elements: [],
|
|
18
|
+
render: AuthorView,
|
|
19
|
+
sort: ( a, b, direction ) => {
|
|
20
|
+
const nameA = a._embedded?.author?.[ 0 ]?.name || '';
|
|
21
|
+
const nameB = b._embedded?.author?.[ 0 ]?.name || '';
|
|
22
|
+
|
|
23
|
+
return direction === 'asc'
|
|
24
|
+
? nameA.localeCompare( nameB )
|
|
25
|
+
: nameB.localeCompare( nameA );
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Author field for BasePost.
|
|
31
|
+
*/
|
|
32
|
+
export default authorField;
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
|
|
12
|
+
const commentStatusField: Field< BasePost > = {
|
|
13
|
+
id: 'comment_status',
|
|
14
|
+
label: __( 'Discussion' ),
|
|
15
|
+
type: 'text',
|
|
16
|
+
Edit: 'radio',
|
|
17
|
+
enableSorting: false,
|
|
18
|
+
filterBy: {
|
|
19
|
+
operators: [],
|
|
20
|
+
},
|
|
21
|
+
elements: [
|
|
22
|
+
{
|
|
23
|
+
value: 'open',
|
|
24
|
+
label: __( 'Open' ),
|
|
25
|
+
description: __( 'Visitors can add new comments and replies.' ),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: 'closed',
|
|
29
|
+
label: __( 'Closed' ),
|
|
30
|
+
description: __(
|
|
31
|
+
'Visitors cannot add new comments or replies. Existing comments remain visible.'
|
|
32
|
+
),
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Comment status field for BasePost.
|
|
39
|
+
*/
|
|
40
|
+
export default commentStatusField;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
+
import { createInterpolateElement } from '@wordpress/element';
|
|
6
|
+
import { dateI18n, getDate, getSettings } from '@wordpress/date';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import type { BasePost } from '../../types';
|
|
12
|
+
|
|
13
|
+
const getFormattedDate = ( dateToDisplay: string | null ) =>
|
|
14
|
+
dateI18n(
|
|
15
|
+
getSettings().formats.datetimeAbbreviated,
|
|
16
|
+
getDate( dateToDisplay )
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const DateView = ( { item }: { item: BasePost } ) => {
|
|
20
|
+
const isDraftOrPrivate = [ 'draft', 'private' ].includes(
|
|
21
|
+
item.status ?? ''
|
|
22
|
+
);
|
|
23
|
+
if ( isDraftOrPrivate ) {
|
|
24
|
+
return createInterpolateElement(
|
|
25
|
+
sprintf(
|
|
26
|
+
/* translators: %s: page creation or modification date. */
|
|
27
|
+
__( '<span>Modified: <time>%s</time></span>' ),
|
|
28
|
+
getFormattedDate( item.date ?? null )
|
|
29
|
+
),
|
|
30
|
+
{
|
|
31
|
+
span: <span />,
|
|
32
|
+
time: <time />,
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const isScheduled = item.status === 'future';
|
|
38
|
+
if ( isScheduled ) {
|
|
39
|
+
return createInterpolateElement(
|
|
40
|
+
sprintf(
|
|
41
|
+
/* translators: %s: page creation date */
|
|
42
|
+
__( '<span>Scheduled: <time>%s</time></span>' ),
|
|
43
|
+
getFormattedDate( item.date ?? null )
|
|
44
|
+
),
|
|
45
|
+
{
|
|
46
|
+
span: <span />,
|
|
47
|
+
time: <time />,
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const isPublished = item.status === 'publish';
|
|
53
|
+
if ( isPublished ) {
|
|
54
|
+
return createInterpolateElement(
|
|
55
|
+
sprintf(
|
|
56
|
+
/* translators: %s: page creation time */
|
|
57
|
+
__( '<span>Published: <time>%s</time></span>' ),
|
|
58
|
+
getFormattedDate( item.date ?? null )
|
|
59
|
+
),
|
|
60
|
+
{
|
|
61
|
+
span: <span />,
|
|
62
|
+
time: <time />,
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Pending posts show the modified date if it's newer.
|
|
68
|
+
const dateToDisplay =
|
|
69
|
+
getDate( item.modified ?? null ) > getDate( item.date ?? null )
|
|
70
|
+
? item.modified
|
|
71
|
+
: item.date;
|
|
72
|
+
|
|
73
|
+
const isPending = item.status === 'pending';
|
|
74
|
+
if ( isPending ) {
|
|
75
|
+
return createInterpolateElement(
|
|
76
|
+
sprintf(
|
|
77
|
+
/* translators: %s: page creation or modification date. */
|
|
78
|
+
__( '<span>Modified: <time>%s</time></span>' ),
|
|
79
|
+
getFormattedDate( dateToDisplay ?? null )
|
|
80
|
+
),
|
|
81
|
+
{
|
|
82
|
+
span: <span />,
|
|
83
|
+
time: <time />,
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Unknow status.
|
|
89
|
+
return <time>{ getFormattedDate( item.date ?? null ) }</time>;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default DateView;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 DateView from './date-view';
|
|
12
|
+
|
|
13
|
+
const dateField: Field< BasePost > = {
|
|
14
|
+
id: 'date',
|
|
15
|
+
type: 'datetime',
|
|
16
|
+
label: __( 'Date' ),
|
|
17
|
+
render: DateView,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Date field for BasePost.
|
|
22
|
+
*/
|
|
23
|
+
export default dateField;
|
|
@@ -9,11 +9,12 @@ import { MediaUpload } from '@wordpress/media-utils';
|
|
|
9
9
|
import { lineSolid } from '@wordpress/icons';
|
|
10
10
|
import { store as coreStore } from '@wordpress/core-data';
|
|
11
11
|
import type { DataFormControlProps } from '@wordpress/dataviews';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* Internal dependencies
|
|
14
16
|
*/
|
|
15
17
|
import type { BasePost } from '../../types';
|
|
16
|
-
import { __ } from '@wordpress/i18n';
|
|
17
18
|
|
|
18
19
|
export const FeaturedImageEdit = ( {
|
|
19
20
|
data,
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
11
|
import type { BasePost } from '../../types';
|
|
11
|
-
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
12
12
|
|
|
13
13
|
export const FeaturedImageView = ( {
|
|
14
14
|
item,
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { Field } from '@wordpress/dataviews';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import type { BasePost } from '../../types';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import { FeaturedImageEdit } from './featured-image-edit';
|
|
12
12
|
import { FeaturedImageView } from './featured-image-view';
|
|
13
13
|
|
|
@@ -15,7 +15,6 @@ const featuredImageField: Field< BasePost > = {
|
|
|
15
15
|
id: 'featured_media',
|
|
16
16
|
type: 'text',
|
|
17
17
|
label: __( 'Featured Image' ),
|
|
18
|
-
getValue: ( { item } ) => item.featured_media,
|
|
19
18
|
Edit: FeaturedImageEdit,
|
|
20
19
|
render: FeaturedImageView,
|
|
21
20
|
enableSorting: false,
|
|
@@ -83,13 +83,10 @@ fieldset.fields-controls__featured-image {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
.dataviews-view-table__cell-content-wrapper {
|
|
86
|
-
.fields-controls__featured-image-image
|
|
87
|
-
width: 32px;
|
|
88
|
-
height: 32px;
|
|
89
|
-
}
|
|
90
|
-
|
|
86
|
+
.fields-controls__featured-image-image,
|
|
91
87
|
.fields-controls__featured-image-placeholder {
|
|
92
88
|
width: 32px;
|
|
93
89
|
height: 32px;
|
|
90
|
+
display: block;
|
|
94
91
|
}
|
|
95
92
|
}
|
package/src/fields/index.ts
CHANGED
|
@@ -3,3 +3,8 @@ export { default as titleField } from './title';
|
|
|
3
3
|
export { default as orderField } from './order';
|
|
4
4
|
export { default as featuredImageField } from './featured-image';
|
|
5
5
|
export { default as parentField } from './parent';
|
|
6
|
+
export { default as passwordField } from './password';
|
|
7
|
+
export { default as statusField } from './status';
|
|
8
|
+
export { default as commentStatusField } from './comment-status';
|
|
9
|
+
export { default as dateField } from './date';
|
|
10
|
+
export { default as authorField } from './author';
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Field } from '@wordpress/dataviews';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import type { BasePost } from '../../types';
|
|
10
11
|
|
|
11
12
|
const orderField: Field< BasePost > = {
|
|
12
|
-
type: 'integer',
|
|
13
13
|
id: 'menu_order',
|
|
14
|
+
type: 'integer',
|
|
14
15
|
label: __( 'Order' ),
|
|
15
16
|
description: __( 'Determines the order of pages.' ),
|
|
16
17
|
};
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { Field } from '@wordpress/dataviews';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import type { BasePost } from '../../types';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import { ParentEdit } from './parent-edit';
|
|
12
12
|
import { ParentView } from './parent-view';
|
|
13
13
|
|
|
@@ -15,7 +15,6 @@ const parentField: Field< BasePost > = {
|
|
|
15
15
|
id: 'parent',
|
|
16
16
|
type: 'text',
|
|
17
17
|
label: __( 'Parent' ),
|
|
18
|
-
getValue: ( { item } ) => item.parent,
|
|
19
18
|
Edit: ParentEdit,
|
|
20
19
|
render: ParentView,
|
|
21
20
|
enableSorting: true,
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import removeAccents from 'remove-accents';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -12,21 +17,16 @@ import {
|
|
|
12
17
|
// @ts-ignore
|
|
13
18
|
import { store as coreStore } from '@wordpress/core-data';
|
|
14
19
|
import type { DataFormControlProps } from '@wordpress/dataviews';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import removeAccents from 'remove-accents';
|
|
20
|
+
import { debounce } from '@wordpress/compose';
|
|
21
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
22
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
23
|
+
import { filterURLForDisplay } from '@wordpress/url';
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* Internal dependencies
|
|
23
27
|
*/
|
|
24
|
-
import { debounce } from '@wordpress/compose';
|
|
25
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
26
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
27
28
|
import type { BasePost } from '../../types';
|
|
28
29
|
import { getTitleWithFallbackName } from './utils';
|
|
29
|
-
import { filterURLForDisplay } from '@wordpress/url';
|
|
30
30
|
|
|
31
31
|
type TreeBase = {
|
|
32
32
|
id: number;
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Internal dependencies
|
|
9
11
|
*/
|
|
10
12
|
import type { BasePost } from '../../types';
|
|
11
|
-
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
12
13
|
import { getTitleWithFallbackName } from './utils';
|
|
13
|
-
import { __ } from '@wordpress/i18n';
|
|
14
14
|
|
|
15
15
|
export const ParentView = ( {
|
|
16
16
|
item,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
CheckboxControl,
|
|
6
|
+
__experimentalVStack as VStack,
|
|
7
|
+
TextControl,
|
|
8
|
+
} from '@wordpress/components';
|
|
9
|
+
import type { DataFormControlProps } from '@wordpress/dataviews';
|
|
10
|
+
import { useState } from '@wordpress/element';
|
|
11
|
+
import { __ } from '@wordpress/i18n';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import type { BasePost } from '../../types';
|
|
17
|
+
|
|
18
|
+
function PasswordEdit( {
|
|
19
|
+
data,
|
|
20
|
+
onChange,
|
|
21
|
+
field,
|
|
22
|
+
}: DataFormControlProps< BasePost > ) {
|
|
23
|
+
const [ showPassword, setShowPassword ] = useState(
|
|
24
|
+
!! field.getValue( { item: data } )
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const handleTogglePassword = ( value: boolean ) => {
|
|
28
|
+
setShowPassword( value );
|
|
29
|
+
if ( ! value ) {
|
|
30
|
+
onChange( { password: '' } );
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<VStack
|
|
36
|
+
as="fieldset"
|
|
37
|
+
spacing={ 4 }
|
|
38
|
+
className="fields-controls__password"
|
|
39
|
+
>
|
|
40
|
+
<CheckboxControl
|
|
41
|
+
__nextHasNoMarginBottom
|
|
42
|
+
label={ __( 'Password protected' ) }
|
|
43
|
+
help={ __( 'Only visible to those who know the password' ) }
|
|
44
|
+
checked={ showPassword }
|
|
45
|
+
onChange={ handleTogglePassword }
|
|
46
|
+
/>
|
|
47
|
+
{ showPassword && (
|
|
48
|
+
<div className="fields-controls__password-input">
|
|
49
|
+
<TextControl
|
|
50
|
+
label={ __( 'Password' ) }
|
|
51
|
+
onChange={ ( value ) =>
|
|
52
|
+
onChange( {
|
|
53
|
+
password: value,
|
|
54
|
+
} )
|
|
55
|
+
}
|
|
56
|
+
value={ field.getValue( { item: data } ) || '' }
|
|
57
|
+
placeholder={ __( 'Use a secure password' ) }
|
|
58
|
+
type="text"
|
|
59
|
+
__next40pxDefaultSize
|
|
60
|
+
__nextHasNoMarginBottom
|
|
61
|
+
maxLength={ 255 }
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
) }
|
|
65
|
+
</VStack>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
export default PasswordEdit;
|
|
@@ -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 PasswordEdit from './edit';
|
|
11
|
+
|
|
12
|
+
const passwordField: Field< BasePost > = {
|
|
13
|
+
id: 'password',
|
|
14
|
+
type: 'text',
|
|
15
|
+
Edit: PasswordEdit,
|
|
16
|
+
enableSorting: false,
|
|
17
|
+
enableHiding: false,
|
|
18
|
+
isVisible: ( item ) => item.status !== 'private',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* This field is used to display the post password.
|
|
23
|
+
*/
|
|
24
|
+
export default passwordField;
|
package/src/fields/slug/index.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { Field } from '@wordpress/dataviews';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import type { BasePost } from '../../types';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import SlugEdit from './slug-edit';
|
|
12
12
|
import SlugView from './slug-view';
|
|
13
13
|
|
|
@@ -15,7 +15,6 @@ const slugField: Field< BasePost > = {
|
|
|
15
15
|
id: 'slug',
|
|
16
16
|
type: 'text',
|
|
17
17
|
label: __( 'Slug' ),
|
|
18
|
-
getValue: ( { item } ) => item.slug,
|
|
19
18
|
Edit: SlugEdit,
|
|
20
19
|
render: SlugView,
|
|
21
20
|
};
|