@wordpress/fields 0.5.1-next.cd6172eb0.0 → 0.7.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/LICENSE.md +1 -1
- 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 +109 -65
- 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 +48 -52
- 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 +49 -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 +110 -66
- 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 +49 -53
- 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 +43 -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 +62 -32
- package/build-style/style.css +62 -32
- 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 +25 -25
- 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 +160 -86
- 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 +81 -66
- package/src/components/create-template-part-modal/style.scss +79 -54
- 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/view.tsx +41 -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 +2 -0
- package/tsconfig.json +1 -4
- 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,13 +5,8 @@ import {
|
|
|
5
5
|
Icon,
|
|
6
6
|
BaseControl,
|
|
7
7
|
TextControl,
|
|
8
|
-
Flex,
|
|
9
|
-
FlexItem,
|
|
10
|
-
FlexBlock,
|
|
11
8
|
Button,
|
|
12
9
|
Modal,
|
|
13
|
-
__experimentalRadioGroup as RadioGroup,
|
|
14
|
-
__experimentalRadio as Radio,
|
|
15
10
|
__experimentalHStack as HStack,
|
|
16
11
|
__experimentalVStack as VStack,
|
|
17
12
|
} from '@wordpress/components';
|
|
@@ -28,7 +23,7 @@ import {
|
|
|
28
23
|
symbolFilled as symbolFilledIcon,
|
|
29
24
|
} from '@wordpress/icons';
|
|
30
25
|
import { store as noticesStore } from '@wordpress/notices';
|
|
31
|
-
// @ts-
|
|
26
|
+
// @ts-expect-error serialize is not typed
|
|
32
27
|
import { serialize } from '@wordpress/blocks';
|
|
33
28
|
|
|
34
29
|
/**
|
|
@@ -40,6 +35,13 @@ import {
|
|
|
40
35
|
useExistingTemplateParts,
|
|
41
36
|
} from './utils';
|
|
42
37
|
|
|
38
|
+
function getAreaRadioId( value: string, instanceId: number ) {
|
|
39
|
+
return `fields-create-template-part-modal__area-option-${ value }-${ instanceId }`;
|
|
40
|
+
}
|
|
41
|
+
function getAreaRadioDescriptionId( value: string, instanceId: number ) {
|
|
42
|
+
return `fields-create-template-part-modal__area-option-description-${ value }-${ instanceId }`;
|
|
43
|
+
}
|
|
44
|
+
|
|
43
45
|
type CreateTemplatePartModalContentsProps = {
|
|
44
46
|
defaultArea?: string;
|
|
45
47
|
blocks: any[];
|
|
@@ -50,6 +52,13 @@ type CreateTemplatePartModalContentsProps = {
|
|
|
50
52
|
defaultTitle?: string;
|
|
51
53
|
};
|
|
52
54
|
|
|
55
|
+
type TemplatePartArea = {
|
|
56
|
+
area: string;
|
|
57
|
+
label: string;
|
|
58
|
+
icon: string;
|
|
59
|
+
description: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
53
62
|
/**
|
|
54
63
|
* 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
64
|
* This component should not live in this package, it should be moved to a dedicated package responsible for managing template.
|
|
@@ -64,7 +73,7 @@ export default function CreateTemplatePartModal( {
|
|
|
64
73
|
} & CreateTemplatePartModalContentsProps ) {
|
|
65
74
|
const defaultModalTitle = useSelect(
|
|
66
75
|
( select ) =>
|
|
67
|
-
// @ts-
|
|
76
|
+
// @ts-expect-error getPostType is not typed with 'wp_template_part' as argument.
|
|
68
77
|
select( coreStore ).getPostType( 'wp_template_part' )?.labels
|
|
69
78
|
?.add_new_item,
|
|
70
79
|
[]
|
|
@@ -77,7 +86,6 @@ export default function CreateTemplatePartModal( {
|
|
|
77
86
|
focusOnMount="firstContentElement"
|
|
78
87
|
size="medium"
|
|
79
88
|
>
|
|
80
|
-
{ /* @ts-ignore */ }
|
|
81
89
|
<CreateTemplatePartModalContents { ...restProps } />
|
|
82
90
|
</Modal>
|
|
83
91
|
);
|
|
@@ -125,22 +133,14 @@ export function CreateTemplatePartModalContents( {
|
|
|
125
133
|
const [ isSubmitting, setIsSubmitting ] = useState( false );
|
|
126
134
|
const instanceId = useInstanceId( CreateTemplatePartModal );
|
|
127
135
|
|
|
128
|
-
const defaultTemplatePartAreas = useSelect(
|
|
129
|
-
|
|
136
|
+
const defaultTemplatePartAreas = useSelect(
|
|
137
|
+
( select ) =>
|
|
130
138
|
// @ts-expect-error getEntityRecord is not typed with unstableBase as argument.
|
|
131
139
|
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
|
-
}, [] );
|
|
140
|
+
default_template_part_areas: Array< TemplatePartArea >;
|
|
141
|
+
} >( 'root', '__unstableBase' )?.default_template_part_areas,
|
|
142
|
+
[]
|
|
143
|
+
);
|
|
144
144
|
|
|
145
145
|
async function createTemplatePart() {
|
|
146
146
|
if ( ! title || isSubmitting ) {
|
|
@@ -203,51 +203,66 @@ export function CreateTemplatePartModalContents( {
|
|
|
203
203
|
onChange={ setTitle }
|
|
204
204
|
required
|
|
205
205
|
/>
|
|
206
|
-
<
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
className="fields-create-template-part-modal__area-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
value && typeof value === 'string'
|
|
218
|
-
? setArea( value )
|
|
219
|
-
: () => void 0
|
|
220
|
-
}
|
|
221
|
-
checked={ area }
|
|
222
|
-
>
|
|
223
|
-
{ defaultTemplatePartAreas.map(
|
|
224
|
-
( { icon, label, area: value, description } ) => (
|
|
225
|
-
<Radio
|
|
226
|
-
__next40pxDefaultSize
|
|
227
|
-
key={ label }
|
|
228
|
-
value={ value }
|
|
229
|
-
className="fields-create-template-part-modal__area-radio"
|
|
206
|
+
<fieldset>
|
|
207
|
+
<BaseControl.VisualLabel as="legend">
|
|
208
|
+
{ __( 'Area' ) }
|
|
209
|
+
</BaseControl.VisualLabel>
|
|
210
|
+
<div className="fields-create-template-part-modal__area-radio-group">
|
|
211
|
+
{ ( defaultTemplatePartAreas ?? [] ).map( ( item ) => {
|
|
212
|
+
const icon = getTemplatePartIcon( item.icon );
|
|
213
|
+
return (
|
|
214
|
+
<div
|
|
215
|
+
key={ item.area }
|
|
216
|
+
className="fields-create-template-part-modal__area-radio-wrapper"
|
|
230
217
|
>
|
|
231
|
-
<
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
218
|
+
<input
|
|
219
|
+
type="radio"
|
|
220
|
+
id={ getAreaRadioId(
|
|
221
|
+
item.area,
|
|
222
|
+
instanceId
|
|
223
|
+
) }
|
|
224
|
+
name={ `fields-create-template-part-modal__area-${ instanceId }` }
|
|
225
|
+
value={ item.area }
|
|
226
|
+
checked={ area === item.area }
|
|
227
|
+
onChange={ () => {
|
|
228
|
+
setArea( item.area );
|
|
229
|
+
} }
|
|
230
|
+
aria-describedby={ getAreaRadioDescriptionId(
|
|
231
|
+
item.area,
|
|
232
|
+
instanceId
|
|
233
|
+
) }
|
|
234
|
+
/>
|
|
235
|
+
<Icon
|
|
236
|
+
icon={ icon }
|
|
237
|
+
className="fields-create-template-part-modal__area-radio-icon"
|
|
238
|
+
/>
|
|
239
|
+
<label
|
|
240
|
+
htmlFor={ getAreaRadioId(
|
|
241
|
+
item.area,
|
|
242
|
+
instanceId
|
|
243
|
+
) }
|
|
244
|
+
className="fields-create-template-part-modal__area-radio-label"
|
|
245
|
+
>
|
|
246
|
+
{ item.label }
|
|
247
|
+
</label>
|
|
248
|
+
<Icon
|
|
249
|
+
icon={ check }
|
|
250
|
+
className="fields-create-template-part-modal__area-radio-checkmark"
|
|
251
|
+
/>
|
|
252
|
+
<p
|
|
253
|
+
className="fields-create-template-part-modal__area-radio-description"
|
|
254
|
+
id={ getAreaRadioDescriptionId(
|
|
255
|
+
item.area,
|
|
256
|
+
instanceId
|
|
257
|
+
) }
|
|
258
|
+
>
|
|
259
|
+
{ item.description }
|
|
260
|
+
</p>
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
} ) }
|
|
264
|
+
</div>
|
|
265
|
+
</fieldset>
|
|
251
266
|
<HStack justify="right">
|
|
252
267
|
<Button
|
|
253
268
|
__next40pxDefaultSize
|
|
@@ -3,61 +3,86 @@
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
.fields-create-template-part-modal__area-radio-group {
|
|
6
|
-
|
|
7
|
-
border: $border-width solid $gray-700;
|
|
6
|
+
border: $border-width solid $gray-600;
|
|
8
7
|
border-radius: $radius-small;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.fields-create-template-part-modal__area-radio-wrapper {
|
|
11
|
+
position: relative;
|
|
12
|
+
padding: $grid-unit-15;
|
|
13
|
+
|
|
14
|
+
display: grid;
|
|
15
|
+
align-items: center;
|
|
16
|
+
grid-template-columns: min-content 1fr min-content;
|
|
17
|
+
grid-gap: $grid-unit-05 $grid-unit-10;
|
|
18
|
+
|
|
19
|
+
color: $gray-900;
|
|
20
|
+
|
|
21
|
+
& + & {
|
|
22
|
+
border-top: $border-width solid $gray-600;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
input[type="radio"] {
|
|
26
|
+
position: absolute;
|
|
27
|
+
opacity: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:has(input[type="radio"]:checked) {
|
|
31
|
+
// This is needed to make sure that the focus ring always renders on top
|
|
32
|
+
// of the sibling radio "wrapper"'s borders.
|
|
33
|
+
z-index: 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:has(input[type="radio"]:not(:checked)):hover {
|
|
37
|
+
color: var(--wp-admin-theme-color);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Pass-through pointer events, so that the corresponding radio input
|
|
41
|
+
// gets checked when clicking on the underlying label
|
|
42
|
+
> *:not(.fields-create-template-part-modal__area-radio-label) {
|
|
43
|
+
pointer-events: none;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.fields-create-template-part-modal__area-radio-label {
|
|
48
|
+
// Capture pointer clicks for the whole radio wrapper
|
|
49
|
+
&::before {
|
|
50
|
+
content: "";
|
|
51
|
+
position: absolute;
|
|
52
|
+
inset: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
input[type="radio"]:not(:checked) ~ &::before {
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
input[type="radio"]:focus-visible ~ &::before {
|
|
60
|
+
outline: 4px solid transparent;
|
|
61
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.fields-create-template-part-modal__area-radio-icon,
|
|
66
|
+
.fields-create-template-part-modal__area-radio-checkmark {
|
|
67
|
+
fill: currentColor;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.fields-create-template-part-modal__area-radio-checkmark {
|
|
71
|
+
input[type="radio"]:not(:checked) ~ & {
|
|
72
|
+
opacity: 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.fields-create-template-part-modal__area-radio-description {
|
|
77
|
+
grid-column: 2 / 3;
|
|
78
|
+
margin: 0;
|
|
79
|
+
|
|
80
|
+
color: $gray-700;
|
|
81
|
+
font-size: $helptext-font-size;
|
|
82
|
+
line-height: normal;
|
|
83
|
+
text-wrap: pretty;
|
|
9
84
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
width: 100%;
|
|
13
|
-
height: 100%;
|
|
14
|
-
text-align: left;
|
|
15
|
-
padding: $grid-unit-15;
|
|
16
|
-
|
|
17
|
-
&,
|
|
18
|
-
&.is-secondary:hover,
|
|
19
|
-
&.is-primary:hover {
|
|
20
|
-
margin: 0;
|
|
21
|
-
background-color: inherit;
|
|
22
|
-
border-bottom: $border-width solid $gray-700;
|
|
23
|
-
border-radius: 0;
|
|
24
|
-
|
|
25
|
-
&:not(:focus) {
|
|
26
|
-
box-shadow: none;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&:focus {
|
|
30
|
-
border-bottom: $border-width solid $white;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&:last-of-type {
|
|
34
|
-
border-bottom: none;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&:not(:hover),
|
|
39
|
-
&[aria-checked="true"] {
|
|
40
|
-
color: $gray-900;
|
|
41
|
-
cursor: auto;
|
|
42
|
-
|
|
43
|
-
.fields-create-template-part-modal__option-label div {
|
|
44
|
-
color: $gray-600;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.fields-create-template-part-modal__option-label {
|
|
49
|
-
padding-top: $grid-unit-05;
|
|
50
|
-
white-space: normal;
|
|
51
|
-
|
|
52
|
-
div {
|
|
53
|
-
padding-top: $grid-unit-05;
|
|
54
|
-
font-size: $helptext-font-size;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.fields-create-template-part-modal__checkbox {
|
|
59
|
-
margin-left: auto;
|
|
60
|
-
min-width: $grid-unit-30;
|
|
61
|
-
}
|
|
85
|
+
input[type="radio"]:not(:checked):hover ~ & {
|
|
86
|
+
color: inherit;
|
|
62
87
|
}
|
|
63
88
|
}
|
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,41 @@
|
|
|
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
|
+
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
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
|
+
const { Badge } = unlock( componentsPrivateApis );
|
|
17
|
+
|
|
18
|
+
export default function PageTitleView( { item }: { item: CommonPost } ) {
|
|
19
|
+
const { frontPageId, postsPageId } = useSelect( ( select ) => {
|
|
20
|
+
const { getEntityRecord } = select( coreStore );
|
|
21
|
+
const siteSettings = getEntityRecord(
|
|
22
|
+
'root',
|
|
23
|
+
'site'
|
|
24
|
+
) as Partial< Settings >;
|
|
25
|
+
return {
|
|
26
|
+
frontPageId: siteSettings?.page_on_front,
|
|
27
|
+
postsPageId: siteSettings?.page_for_posts,
|
|
28
|
+
};
|
|
29
|
+
}, [] );
|
|
30
|
+
return (
|
|
31
|
+
<BaseTitleView item={ item } className="fields-field__page-title">
|
|
32
|
+
{ [ frontPageId, postsPageId ].includes( item.id as number ) && (
|
|
33
|
+
<Badge>
|
|
34
|
+
{ item.id === frontPageId
|
|
35
|
+
? __( 'Homepage' )
|
|
36
|
+
: __( 'Posts Page' ) }
|
|
37
|
+
</Badge>
|
|
38
|
+
) }
|
|
39
|
+
</BaseTitleView>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -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;
|