@wordpress/fields 0.42.0 → 0.42.1-next.v.202607070741.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 +8 -0
- package/build/fields/index.cjs +6 -0
- package/build/fields/index.cjs.map +2 -2
- package/build/fields/parent/parent-edit.cjs +0 -1
- package/build/fields/parent/parent-edit.cjs.map +2 -2
- package/build/fields/pattern-description/index.cjs +56 -0
- package/build/fields/pattern-description/index.cjs.map +7 -0
- package/build/fields/pattern-sync-status/index.cjs +80 -0
- package/build/fields/pattern-sync-status/index.cjs.map +7 -0
- package/build/fields/template/template-edit.cjs +0 -2
- package/build/fields/template/template-edit.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build-module/fields/index.mjs +48 -44
- package/build-module/fields/index.mjs.map +2 -2
- package/build-module/fields/parent/parent-edit.mjs +0 -1
- package/build-module/fields/parent/parent-edit.mjs.map +2 -2
- package/build-module/fields/pattern-description/index.mjs +35 -0
- package/build-module/fields/pattern-description/index.mjs.map +7 -0
- package/build-module/fields/pattern-sync-status/index.mjs +59 -0
- package/build-module/fields/pattern-sync-status/index.mjs.map +7 -0
- package/build-module/fields/template/template-edit.mjs +0 -2
- package/build-module/fields/template/template-edit.mjs.map +2 -2
- package/build-style/style-rtl.css +6 -2
- package/build-style/style.css +6 -2
- package/build-types/fields/index.d.ts +2 -0
- package/build-types/fields/index.d.ts.map +1 -1
- package/build-types/fields/parent/parent-edit.d.ts.map +1 -1
- package/build-types/fields/pattern-description/index.d.ts +14 -0
- package/build-types/fields/pattern-description/index.d.ts.map +1 -0
- package/build-types/fields/pattern-sync-status/index.d.ts +14 -0
- package/build-types/fields/pattern-sync-status/index.d.ts.map +1 -0
- package/build-types/fields/template/template-edit.d.ts.map +1 -1
- package/build-types/types.d.ts +6 -1
- package/build-types/types.d.ts.map +1 -1
- package/package.json +27 -27
- package/src/components/media-edit/style.scss +0 -2
- package/src/fields/index.ts +2 -0
- package/src/fields/parent/parent-edit.tsx +0 -1
- package/src/fields/pattern-description/index.tsx +44 -0
- package/src/fields/pattern-sync-status/index.tsx +76 -0
- package/src/fields/template/template-edit.tsx +0 -2
- package/src/types.ts +3 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Field } from '@wordpress/dataviews';
|
|
5
|
+
import { __, _x } from '@wordpress/i18n';
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import { privateApis as patternPrivateApis } from '@wordpress/patterns';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import type { Pattern } from '../../types';
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
14
|
+
|
|
15
|
+
const { PATTERN_SYNC_TYPES, PATTERN_TYPES } = unlock( patternPrivateApis );
|
|
16
|
+
|
|
17
|
+
const SYNC_STATUS_FILTERS = [
|
|
18
|
+
{
|
|
19
|
+
value: PATTERN_SYNC_TYPES.full,
|
|
20
|
+
label: _x( 'Synced', 'pattern (singular)' ),
|
|
21
|
+
description: __( 'Patterns that are kept in sync across the site.' ),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: PATTERN_SYNC_TYPES.unsynced,
|
|
25
|
+
label: _x( 'Not synced', 'pattern (singular)' ),
|
|
26
|
+
description: __(
|
|
27
|
+
'Patterns that can be changed freely without affecting the site.'
|
|
28
|
+
),
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
function getPatternSyncStatus( item: Pattern ) {
|
|
33
|
+
if ( item.type && item.type !== PATTERN_TYPES.user ) {
|
|
34
|
+
return PATTERN_SYNC_TYPES.unsynced;
|
|
35
|
+
}
|
|
36
|
+
// When a pattern is first created directly from the post editor
|
|
37
|
+
// (`post-new.php?post_type=wp_block`), the top-level sync status is not
|
|
38
|
+
// set yet, so fall back to the meta value.
|
|
39
|
+
if ( item.meta?.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ) {
|
|
40
|
+
return PATTERN_SYNC_TYPES.unsynced;
|
|
41
|
+
}
|
|
42
|
+
return item.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const patternSyncStatusField: Field< Pattern > = {
|
|
46
|
+
id: 'sync-status',
|
|
47
|
+
type: 'text',
|
|
48
|
+
label: __( 'Sync status' ),
|
|
49
|
+
readOnly: true,
|
|
50
|
+
enableSorting: false,
|
|
51
|
+
enableHiding: true,
|
|
52
|
+
elements: SYNC_STATUS_FILTERS,
|
|
53
|
+
filterBy: {
|
|
54
|
+
operators: [ 'is' ],
|
|
55
|
+
isPrimary: true,
|
|
56
|
+
},
|
|
57
|
+
render: ( { item } ) => {
|
|
58
|
+
const syncStatus = getPatternSyncStatus( item );
|
|
59
|
+
return (
|
|
60
|
+
<span
|
|
61
|
+
className={ `fields-field__pattern-sync-status fields-field__pattern-sync-status-${ syncStatus }` }
|
|
62
|
+
>
|
|
63
|
+
{
|
|
64
|
+
SYNC_STATUS_FILTERS.find(
|
|
65
|
+
( { value } ) => value === syncStatus
|
|
66
|
+
)?.label
|
|
67
|
+
}
|
|
68
|
+
</span>
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Sync status field for patterns.
|
|
75
|
+
*/
|
|
76
|
+
export default patternSyncStatusField;
|
|
@@ -61,7 +61,6 @@ function ClassicTemplateEdit( {
|
|
|
61
61
|
);
|
|
62
62
|
return (
|
|
63
63
|
<SelectControl
|
|
64
|
-
__next40pxDefaultSize
|
|
65
64
|
label={ __( 'Template' ) }
|
|
66
65
|
hideLabelFromVision
|
|
67
66
|
value={ value }
|
|
@@ -126,7 +125,6 @@ function BlockThemeTemplateEdit( {
|
|
|
126
125
|
}, [ templates, defaultTemplateLabel ] );
|
|
127
126
|
return (
|
|
128
127
|
<SelectControl
|
|
129
|
-
__next40pxDefaultSize
|
|
130
128
|
label={ __( 'Template' ) }
|
|
131
129
|
hideLabelFromVision
|
|
132
130
|
value={ value }
|
package/src/types.ts
CHANGED
|
@@ -119,7 +119,9 @@ export interface TemplatePart extends CommonPost, TemplateAuthorFields {
|
|
|
119
119
|
export interface Pattern extends CommonPost {
|
|
120
120
|
slug: string;
|
|
121
121
|
title: { raw: string };
|
|
122
|
-
|
|
122
|
+
excerpt?: string | { raw: string; rendered: string };
|
|
123
|
+
meta?: Record< string, any >;
|
|
124
|
+
wp_pattern_sync_status?: string;
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
export interface SiteSettings {
|