@wordpress/fields 0.5.0 → 0.5.1-next.cd6172eb0.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 +29 -0
- package/build/actions/duplicate-template-part.js +68 -0
- package/build/actions/duplicate-template-part.js.map +1 -0
- package/build/actions/index.js +7 -0
- package/build/actions/index.js.map +1 -1
- package/build/actions/permanently-delete-post.js +0 -1
- package/build/actions/permanently-delete-post.js.map +1 -1
- package/build/actions/rename-post.js +2 -2
- package/build/actions/rename-post.js.map +1 -1
- package/build/actions/reset-post.js +3 -3
- package/build/actions/reset-post.js.map +1 -1
- package/build/actions/restore-post.js +0 -1
- package/build/actions/restore-post.js.map +1 -1
- package/build/actions/trash-post.js +0 -1
- package/build/actions/trash-post.js.map +1 -1
- package/build/actions/utils.js +4 -12
- package/build/actions/utils.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +213 -0
- package/build/components/create-template-part-modal/index.js.map +1 -0
- package/build/components/create-template-part-modal/utils.js +64 -0
- package/build/components/create-template-part-modal/utils.js.map +1 -0
- package/build/fields/index.js +7 -0
- package/build/fields/index.js.map +1 -1
- package/build/fields/slug/slug-view.js +1 -1
- package/build/fields/slug/slug-view.js.map +1 -1
- package/build/fields/slug/utils.js +3 -0
- package/build/fields/slug/utils.js.map +1 -1
- package/build/fields/template/index.js +28 -0
- package/build/fields/template/index.js.map +1 -0
- package/build/fields/template/template-edit.js +154 -0
- package/build/fields/template/template-edit.js.map +1 -0
- package/build/fields/title/title-view.js +1 -1
- package/build/fields/title/title-view.js.map +1 -1
- package/build/index.js +13 -0
- package/build/index.js.map +1 -1
- package/build/mutation/index.js +0 -1
- package/build/mutation/index.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/actions/duplicate-template-part.js +63 -0
- package/build-module/actions/duplicate-template-part.js.map +1 -0
- package/build-module/actions/index.js +1 -0
- package/build-module/actions/index.js.map +1 -1
- package/build-module/actions/permanently-delete-post.js +0 -1
- package/build-module/actions/permanently-delete-post.js.map +1 -1
- package/build-module/actions/rename-post.js +3 -3
- package/build-module/actions/rename-post.js.map +1 -1
- package/build-module/actions/reset-post.js +4 -4
- package/build-module/actions/reset-post.js.map +1 -1
- package/build-module/actions/restore-post.js +0 -1
- package/build-module/actions/restore-post.js.map +1 -1
- package/build-module/actions/trash-post.js +0 -1
- package/build-module/actions/trash-post.js.map +1 -1
- package/build-module/actions/utils.js +4 -11
- package/build-module/actions/utils.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +204 -0
- package/build-module/components/create-template-part-modal/index.js.map +1 -0
- package/build-module/components/create-template-part-modal/utils.js +55 -0
- package/build-module/components/create-template-part-modal/utils.js.map +1 -0
- package/build-module/fields/index.js +1 -0
- package/build-module/fields/index.js.map +1 -1
- package/build-module/fields/slug/slug-view.js +1 -1
- package/build-module/fields/slug/slug-view.js.map +1 -1
- package/build-module/fields/slug/utils.js +3 -0
- package/build-module/fields/slug/utils.js.map +1 -1
- package/build-module/fields/template/index.js +21 -0
- package/build-module/fields/template/index.js.map +1 -0
- package/build-module/fields/template/template-edit.js +144 -0
- package/build-module/fields/template/template-edit.js.map +1 -0
- package/build-module/fields/title/title-view.js +1 -1
- package/build-module/fields/title/title-view.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/mutation/index.js +0 -1
- package/build-module/mutation/index.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-style/style-rtl.css +74 -0
- package/build-style/style.css +74 -0
- package/build-types/actions/duplicate-template-part.d.ts +11 -0
- package/build-types/actions/duplicate-template-part.d.ts.map +1 -0
- package/build-types/actions/index.d.ts +1 -0
- package/build-types/actions/index.d.ts.map +1 -1
- package/build-types/actions/rename-post.d.ts.map +1 -1
- package/build-types/actions/reset-post.d.ts.map +1 -1
- package/build-types/actions/utils.d.ts +7 -8
- package/build-types/actions/utils.d.ts.map +1 -1
- package/build-types/components/create-template-part-modal/index.d.ts +34 -0
- package/build-types/components/create-template-part-modal/index.d.ts.map +1 -0
- package/build-types/components/create-template-part-modal/utils.d.ts +4 -0
- package/build-types/components/create-template-part-modal/utils.d.ts.map +1 -0
- package/build-types/fields/index.d.ts +1 -0
- package/build-types/fields/index.d.ts.map +1 -1
- package/build-types/fields/slug/utils.d.ts.map +1 -1
- package/build-types/fields/template/index.d.ts +8 -0
- package/build-types/fields/template/index.d.ts.map +1 -0
- package/build-types/fields/template/template-edit.d.ts +4 -0
- package/build-types/fields/template/template-edit.d.ts.map +1 -0
- package/build-types/fields/title/title-view.d.ts.map +1 -1
- package/build-types/index.d.ts +2 -1
- 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 +3 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +24 -23
- package/src/actions/duplicate-template-part.tsx +72 -0
- package/src/actions/index.ts +1 -0
- package/src/actions/rename-post.tsx +3 -6
- package/src/actions/reset-post.tsx +4 -9
- package/src/actions/utils.ts +7 -15
- package/src/components/create-template-part-modal/index.tsx +274 -0
- package/src/components/create-template-part-modal/style.scss +63 -0
- package/src/components/create-template-part-modal/test/utils.js +60 -0
- package/src/components/create-template-part-modal/utils.js +68 -0
- package/src/fields/index.ts +1 -0
- package/src/fields/slug/slug-view.tsx +1 -1
- package/src/fields/slug/utils.ts +4 -0
- package/src/fields/template/index.ts +22 -0
- package/src/fields/template/style.scss +23 -0
- package/src/fields/template/template-edit.tsx +210 -0
- package/src/fields/title/title-view.tsx +3 -4
- package/src/index.ts +2 -1
- package/src/style.scss +2 -0
- package/src/types.ts +3 -0
- package/tsconfig.json +2 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback, useMemo, useState } from '@wordpress/element';
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import { parse } from '@wordpress/blocks';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
// @ts-expect-error block-editor is not typed correctly.
|
|
12
|
+
import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
|
|
13
|
+
import { Button, Dropdown, MenuGroup, MenuItem, Modal } from '@wordpress/components';
|
|
14
|
+
import { useAsyncList } from '@wordpress/compose';
|
|
15
|
+
import { useSelect } from '@wordpress/data';
|
|
16
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
17
|
+
import { __ } from '@wordpress/i18n';
|
|
18
|
+
import { getItemTitle } from '../../actions/utils';
|
|
19
|
+
import { unlock } from '../../lock-unlock';
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
export const TemplateEdit = ({
|
|
22
|
+
data,
|
|
23
|
+
field,
|
|
24
|
+
onChange
|
|
25
|
+
}) => {
|
|
26
|
+
const {
|
|
27
|
+
id
|
|
28
|
+
} = field;
|
|
29
|
+
const postType = data.type;
|
|
30
|
+
const postId = typeof data.id === 'number' ? data.id : parseInt(data.id, 10);
|
|
31
|
+
const slug = data.slug;
|
|
32
|
+
const {
|
|
33
|
+
availableTemplates,
|
|
34
|
+
templates
|
|
35
|
+
} = useSelect(select => {
|
|
36
|
+
var _select$getEntityReco;
|
|
37
|
+
const allTemplates = (_select$getEntityReco = select(coreStore).getEntityRecords('postType', 'wp_template', {
|
|
38
|
+
per_page: -1,
|
|
39
|
+
post_type: postType
|
|
40
|
+
})) !== null && _select$getEntityReco !== void 0 ? _select$getEntityReco : [];
|
|
41
|
+
const {
|
|
42
|
+
getHomePage,
|
|
43
|
+
getPostsPageId
|
|
44
|
+
} = unlock(select(coreStore));
|
|
45
|
+
const isPostsPage = getPostsPageId() === +postId;
|
|
46
|
+
const isFrontPage = postType === 'page' && getHomePage()?.postId === +postId;
|
|
47
|
+
const allowSwitchingTemplate = !isPostsPage && !isFrontPage;
|
|
48
|
+
return {
|
|
49
|
+
templates: allTemplates,
|
|
50
|
+
availableTemplates: allowSwitchingTemplate ? allTemplates.filter(template => template.is_custom && template.slug !== data.template && !!template.content.raw // Skip empty templates.
|
|
51
|
+
) : []
|
|
52
|
+
};
|
|
53
|
+
}, [data.template, postId, postType]);
|
|
54
|
+
const templatesAsPatterns = useMemo(() => availableTemplates.map(template => ({
|
|
55
|
+
name: template.slug,
|
|
56
|
+
blocks: parse(template.content.raw),
|
|
57
|
+
title: decodeEntities(template.title.rendered),
|
|
58
|
+
id: template.id
|
|
59
|
+
})), [availableTemplates]);
|
|
60
|
+
const shownTemplates = useAsyncList(templatesAsPatterns);
|
|
61
|
+
const value = field.getValue({
|
|
62
|
+
item: data
|
|
63
|
+
});
|
|
64
|
+
const currentTemplate = useSelect(select => {
|
|
65
|
+
const foundTemplate = templates?.find(template => template.slug === value);
|
|
66
|
+
if (foundTemplate) {
|
|
67
|
+
return foundTemplate;
|
|
68
|
+
}
|
|
69
|
+
let slugToCheck;
|
|
70
|
+
// In `draft` status we might not have a slug available, so we use the `single`
|
|
71
|
+
// post type templates slug(ex page, single-post, single-product etc..).
|
|
72
|
+
// Pages do not need the `single` prefix in the slug to be prioritized
|
|
73
|
+
// through template hierarchy.
|
|
74
|
+
if (slug) {
|
|
75
|
+
slugToCheck = postType === 'page' ? `${postType}-${slug}` : `single-${postType}-${slug}`;
|
|
76
|
+
} else {
|
|
77
|
+
slugToCheck = postType === 'page' ? 'page' : `single-${postType}`;
|
|
78
|
+
}
|
|
79
|
+
if (postType) {
|
|
80
|
+
const templateId = select(coreStore).getDefaultTemplateId({
|
|
81
|
+
slug: slugToCheck
|
|
82
|
+
});
|
|
83
|
+
return select(coreStore).getEntityRecord('postType', 'wp_template', templateId);
|
|
84
|
+
}
|
|
85
|
+
}, [postType, slug, templates, value]);
|
|
86
|
+
const [showModal, setShowModal] = useState(false);
|
|
87
|
+
const onChangeControl = useCallback(newValue => onChange({
|
|
88
|
+
[id]: newValue
|
|
89
|
+
}), [id, onChange]);
|
|
90
|
+
return /*#__PURE__*/_jsxs("fieldset", {
|
|
91
|
+
className: "fields-controls__template",
|
|
92
|
+
children: [/*#__PURE__*/_jsx(Dropdown, {
|
|
93
|
+
popoverProps: {
|
|
94
|
+
placement: 'bottom-start'
|
|
95
|
+
},
|
|
96
|
+
renderToggle: ({
|
|
97
|
+
onToggle
|
|
98
|
+
}) => /*#__PURE__*/_jsx(Button, {
|
|
99
|
+
__next40pxDefaultSize: true,
|
|
100
|
+
variant: "tertiary",
|
|
101
|
+
size: "compact",
|
|
102
|
+
onClick: onToggle,
|
|
103
|
+
children: currentTemplate ? getItemTitle(currentTemplate) : ''
|
|
104
|
+
}),
|
|
105
|
+
renderContent: ({
|
|
106
|
+
onToggle
|
|
107
|
+
}) => /*#__PURE__*/_jsxs(MenuGroup, {
|
|
108
|
+
children: [/*#__PURE__*/_jsx(MenuItem, {
|
|
109
|
+
onClick: () => {
|
|
110
|
+
setShowModal(true);
|
|
111
|
+
onToggle();
|
|
112
|
+
},
|
|
113
|
+
children: __('Swap template')
|
|
114
|
+
}),
|
|
115
|
+
// The default template in a post is indicated by an empty string
|
|
116
|
+
value !== '' && /*#__PURE__*/_jsx(MenuItem, {
|
|
117
|
+
onClick: () => {
|
|
118
|
+
onChangeControl('');
|
|
119
|
+
onToggle();
|
|
120
|
+
},
|
|
121
|
+
children: __('Use default template')
|
|
122
|
+
})]
|
|
123
|
+
})
|
|
124
|
+
}), showModal && /*#__PURE__*/_jsx(Modal, {
|
|
125
|
+
title: __('Choose a template'),
|
|
126
|
+
onRequestClose: () => setShowModal(false),
|
|
127
|
+
overlayClassName: "fields-controls__template-modal",
|
|
128
|
+
isFullScreen: true,
|
|
129
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
130
|
+
className: "fields-controls__template-content",
|
|
131
|
+
children: /*#__PURE__*/_jsx(BlockPatternsList, {
|
|
132
|
+
label: __('Templates'),
|
|
133
|
+
blockPatterns: templatesAsPatterns,
|
|
134
|
+
shownPatterns: shownTemplates,
|
|
135
|
+
onClickPattern: template => {
|
|
136
|
+
onChangeControl(template.name);
|
|
137
|
+
setShowModal(false);
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
})]
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=template-edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useMemo","useState","parse","store","coreStore","__experimentalBlockPatternsList","BlockPatternsList","Button","Dropdown","MenuGroup","MenuItem","Modal","useAsyncList","useSelect","decodeEntities","__","getItemTitle","unlock","jsx","_jsx","jsxs","_jsxs","TemplateEdit","data","field","onChange","id","postType","type","postId","parseInt","slug","availableTemplates","templates","select","_select$getEntityReco","allTemplates","getEntityRecords","per_page","post_type","getHomePage","getPostsPageId","isPostsPage","isFrontPage","allowSwitchingTemplate","filter","template","is_custom","content","raw","templatesAsPatterns","map","name","blocks","title","rendered","shownTemplates","value","getValue","item","currentTemplate","foundTemplate","find","slugToCheck","templateId","getDefaultTemplateId","getEntityRecord","showModal","setShowModal","onChangeControl","newValue","className","children","popoverProps","placement","renderToggle","onToggle","__next40pxDefaultSize","variant","size","onClick","renderContent","onRequestClose","overlayClassName","isFullScreen","label","blockPatterns","shownPatterns","onClickPattern"],"sources":["@wordpress/fields/src/fields/template/template-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo, useState } from '@wordpress/element';\n// @ts-ignore\nimport { parse } from '@wordpress/blocks';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\n// @ts-expect-error block-editor is not typed correctly.\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tDropdown,\n\tMenuGroup,\n\tMenuItem,\n\tModal,\n} from '@wordpress/components';\nimport { useAsyncList } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { getItemTitle } from '../../actions/utils';\nimport type { BasePost } from '../../types';\nimport { unlock } from '../../lock-unlock';\n\nexport const TemplateEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\tconst postType = data.type;\n\tconst postId =\n\t\ttypeof data.id === 'number' ? data.id : parseInt( data.id, 10 );\n\tconst slug = data.slug;\n\n\tconst { availableTemplates, templates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst allTemplates =\n\t\t\t\tselect( coreStore ).getEntityRecords< WpTemplate >(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\t{\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\tpost_type: postType,\n\t\t\t\t\t}\n\t\t\t\t) ?? [];\n\n\t\t\tconst { getHomePage, getPostsPageId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\n\t\t\tconst isPostsPage = getPostsPageId() === +postId;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && getHomePage()?.postId === +postId;\n\n\t\t\tconst allowSwitchingTemplate = ! isPostsPage && ! isFrontPage;\n\n\t\t\treturn {\n\t\t\t\ttemplates: allTemplates,\n\t\t\t\tavailableTemplates: allowSwitchingTemplate\n\t\t\t\t\t? allTemplates.filter(\n\t\t\t\t\t\t\t( template ) =>\n\t\t\t\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\t\t\t\ttemplate.slug !== data.template &&\n\t\t\t\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t\t\t )\n\t\t\t\t\t: [],\n\t\t\t};\n\t\t},\n\t\t[ data.template, postId, postType ]\n\t);\n\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\n\tconst shownTemplates = useAsyncList( templatesAsPatterns );\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst currentTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst foundTemplate = templates?.find(\n\t\t\t\t( template ) => template.slug === value\n\t\t\t);\n\n\t\t\tif ( foundTemplate ) {\n\t\t\t\treturn foundTemplate;\n\t\t\t}\n\n\t\t\tlet slugToCheck;\n\t\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t\t// through template hierarchy.\n\t\t\tif ( slug ) {\n\t\t\t\tslugToCheck =\n\t\t\t\t\tpostType === 'page'\n\t\t\t\t\t\t? `${ postType }-${ slug }`\n\t\t\t\t\t\t: `single-${ postType }-${ slug }`;\n\t\t\t} else {\n\t\t\t\tslugToCheck =\n\t\t\t\t\tpostType === 'page' ? 'page' : `single-${ postType }`;\n\t\t\t}\n\n\t\t\tif ( postType ) {\n\t\t\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\t\t\tslug: slugToCheck,\n\t\t\t\t} );\n\n\t\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\ttemplateId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ postType, slug, templates, value ]\n\t);\n\n\tconst [ showModal, setShowModal ] = useState( false );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__template\">\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ currentTemplate\n\t\t\t\t\t\t\t? getItemTitle( currentTemplate )\n\t\t\t\t\t\t\t: '' }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onToggle } ) => (\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowModal( true );\n\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Swap template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// The default template in a post is indicated by an empty string\n\t\t\t\t\t\t\tvalue !== '' && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonChangeControl( '' );\n\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Use default template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"fields-controls__template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"fields-controls__template-content\">\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tlabel={ __( 'Templates' ) }\n\t\t\t\t\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\t\t\t\t\tshownPatterns={ shownTemplates }\n\t\t\t\t\t\t\tonClickPattern={ (\n\t\t\t\t\t\t\t\ttemplate: ( typeof templatesAsPatterns )[ 0 ]\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tonChangeControl( template.name );\n\t\t\t\t\t\t\t\tsetShowModal( false );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</fieldset>\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACnE;AACA,SAASC,KAAK,QAAQ,mBAAmB;AAEzC,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAGzD;AACA;AACA;AACA;AACA,SAASC,+BAA+B,IAAIC,iBAAiB,QAAQ,yBAAyB;AAC9F,SACCC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,KAAK,QACC,uBAAuB;AAC9B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,qBAAqB;AAElD,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE3C,OAAO,MAAMC,YAAY,GAAGA,CAAE;EAC7BC,IAAI;EACJC,KAAK;EACLC;AACiC,CAAC,KAAM;EACxC,MAAM;IAAEC;EAAG,CAAC,GAAGF,KAAK;EACpB,MA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AAE,CAAE,sBAAuB;QAAC,CACrB,CACV;MAAA,CAEQ;IACT,CACH,CAAC,EACAoD,SAAS,iBACVhD,IAAA,CAACR,KAAK;MACL2C,KAAK,EAAGvC,EAAE,CAAE,mBAAoB,CAAG;MACnCmE,cAAc,EAAGA,CAAA,KAAMd,YAAY,CAAE,KAAM,CAAG;MAC9Ce,gBAAgB,EAAC,iCAAiC;MAClDC,YAAY;MAAAZ,QAAA,eAEZrD,IAAA;QAAKoD,SAAS,EAAC,mCAAmC;QAAAC,QAAA,eACjDrD,IAAA,CAACb,iBAAiB;UACjB+E,KAAK,EAAGtE,EAAE,CAAE,WAAY,CAAG;UAC3BuE,aAAa,EAAGpC,mBAAqB;UACrCqC,aAAa,EAAG/B,cAAgB;UAChCgC,cAAc,EACb1C,QAA6C,IACzC;YACJuB,eAAe,CAAEvB,QAAQ,CAACM,IAAK,CAAC;YAChCgB,YAAY,CAAE,KAAM,CAAC;UACtB;QAAG,CACH;MAAC,CACE;IAAC,CACA,CACP;EAAA,CACQ,CAAC;AAEb,CAAC","ignoreList":[]}
|
|
@@ -23,7 +23,7 @@ const TitleView = ({
|
|
|
23
23
|
const {
|
|
24
24
|
getEntityRecord
|
|
25
25
|
} = select(coreStore);
|
|
26
|
-
const siteSettings = getEntityRecord('root', 'site'
|
|
26
|
+
const siteSettings = getEntityRecord('root', 'site');
|
|
27
27
|
return {
|
|
28
28
|
frontPageId: siteSettings?.page_on_front,
|
|
29
29
|
postsPageId: siteSettings?.page_for_posts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalHStack","HStack","decodeEntities","__","useSelect","store","coreStore","getItemTitle","jsx","_jsx","jsxs","_jsxs","TitleView","item","frontPageId","postsPageId","select","getEntityRecord","siteSettings","page_on_front","page_for_posts","renderedTitle","suffix","id","className","children","alignment","justify"],"sources":["@wordpress/fields/src/fields/title/title-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack } from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Settings } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\n\nconst TitleView = ( { item }: { item: BasePost } ) => {\n\tconst { frontPageId, postsPageId } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings
|
|
1
|
+
{"version":3,"names":["__experimentalHStack","HStack","decodeEntities","__","useSelect","store","coreStore","getItemTitle","jsx","_jsx","jsxs","_jsxs","TitleView","item","frontPageId","postsPageId","select","getEntityRecord","siteSettings","page_on_front","page_for_posts","renderedTitle","suffix","id","className","children","alignment","justify"],"sources":["@wordpress/fields/src/fields/title/title-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack } from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Settings } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\n\nconst TitleView = ( { item }: { item: BasePost } ) => {\n\tconst { frontPageId, postsPageId } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t) as Partial< Settings >;\n\t\treturn {\n\t\t\tfrontPageId: siteSettings?.page_on_front,\n\t\t\tpostsPageId: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\n\tconst renderedTitle = getItemTitle( item );\n\n\tlet suffix;\n\tif ( item.id === frontPageId ) {\n\t\tsuffix = (\n\t\t\t<span className=\"edit-site-post-list__title-badge\">\n\t\t\t\t{ __( 'Homepage' ) }\n\t\t\t</span>\n\t\t);\n\t} else if ( item.id === postsPageId ) {\n\t\tsuffix = (\n\t\t\t<span className=\"edit-site-post-list__title-badge\">\n\t\t\t\t{ __( 'Posts Page' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\treturn (\n\t\t<HStack\n\t\t\tclassName=\"edit-site-post-list__title\"\n\t\t\talignment=\"center\"\n\t\t\tjustify=\"flex-start\"\n\t\t>\n\t\t\t<span>\n\t\t\t\t{ decodeEntities( renderedTitle ) || __( '(no title)' ) }\n\t\t\t</span>\n\t\t\t{ suffix }\n\t\t</HStack>\n\t);\n};\n\nexport default TitleView;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,oBAAoB,IAAIC,MAAM,QAAQ,uBAAuB;AACtE,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAGzD;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEnD,MAAMC,SAAS,GAAGA,CAAE;EAAEC;AAAyB,CAAC,KAAM;EACrD,MAAM;IAAEC,WAAW;IAAEC;EAAY,CAAC,GAAGX,SAAS,CAAIY,MAAM,IAAM;IAC7D,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEV,SAAU,CAAC;IAC/C,MAAMY,YAAY,GAAGD,eAAe,CACnC,MAAM,EACN,MACD,CAAwB;IACxB,OAAO;MACNH,WAAW,EAAEI,YAAY,EAAEC,aAAa;MACxCJ,WAAW,EAAEG,YAAY,EAAEE;IAC5B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMC,aAAa,GAAGd,YAAY,CAAEM,IAAK,CAAC;EAE1C,IAAIS,MAAM;EACV,IAAKT,IAAI,CAACU,EAAE,KAAKT,WAAW,EAAG;IAC9BQ,MAAM,gBACLb,IAAA;MAAMe,SAAS,EAAC,kCAAkC;MAAAC,QAAA,EAC/CtB,EAAE,CAAE,UAAW;IAAC,CACb,CACN;EACF,CAAC,MAAM,IAAKU,IAAI,CAACU,EAAE,KAAKR,WAAW,EAAG;IACrCO,MAAM,gBACLb,IAAA;MAAMe,SAAS,EAAC,kCAAkC;MAAAC,QAAA,EAC/CtB,EAAE,CAAE,YAAa;IAAC,CACf,CACN;EACF;EAEA,oBACCQ,KAAA,CAACV,MAAM;IACNuB,SAAS,EAAC,4BAA4B;IACtCE,SAAS,EAAC,QAAQ;IAClBC,OAAO,EAAC,YAAY;IAAAF,QAAA,gBAEpBhB,IAAA;MAAAgB,QAAA,EACGvB,cAAc,CAAEmB,aAAc,CAAC,IAAIlB,EAAE,CAAE,YAAa;IAAC,CAClD,CAAC,EACLmB,MAAM;EAAA,CACD,CAAC;AAEX,CAAC;AAED,eAAeV,SAAS","ignoreList":[]}
|
package/build-module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/fields/src/index.ts"],"sourcesContent":["export * from './fields';\nexport * from './actions';\nexport type
|
|
1
|
+
{"version":3,"names":["default","CreateTemplatePartModal"],"sources":["@wordpress/fields/src/index.ts"],"sourcesContent":["export * from './fields';\nexport * from './actions';\nexport { default as CreateTemplatePartModal } from './components/create-template-part-modal';\nexport type { BasePostWithEmbeddedAuthor, PostType } from './types';\n"],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,SAASA,OAAO,IAAIC,uBAAuB,QAAQ,yCAAyC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","noticesStore","coreStore","dispatch","getErrorMessagesFromPromises","allSettledResults","errorMessages","Set","length","typedError","reason","message","add","failedPromises","filter","status","failedPromise","deletePostWithNotices","posts","notice","callbacks","createSuccessNotice","createErrorNotice","deleteEntityRecord","Promise","allSettled","map","post","type","id","force","throwOnError","every","_notice$success$type","successMessage","success","messages","getMessage","getBatchMessage","onActionPerformed","_notice$error$type","errorMessage","error","onActionError","editPostWithNotices","postsWithUpdates","editEntityRecord","saveEditedEntityRecord","originalPost","changes","_notice$success$type2","_notice$error$type2"],"sources":["@wordpress/fields/src/mutation/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport type { CoreDataError, Post } from '../types';\n\nfunction getErrorMessagesFromPromises< T >(\n\tallSettledResults: PromiseSettledResult< T >[]\n) {\n\tconst errorMessages = new Set< string >();\n\t// If there was at lease one failure.\n\tif ( allSettledResults.length === 1 ) {\n\t\tconst typedError = allSettledResults[ 0 ] as {\n\t\t\treason?: CoreDataError;\n\t\t};\n\t\tif ( typedError.reason?.message ) {\n\t\t\terrorMessages.add( typedError.reason.message );\n\t\t}\n\t} else {\n\t\tconst failedPromises = allSettledResults.filter(\n\t\t\t( { status } ) => status === 'rejected'\n\t\t);\n\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\tconst typedError = failedPromise as {\n\t\t\t\treason?: CoreDataError;\n\t\t\t};\n\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t}\n\t\t}\n\t}\n\treturn errorMessages;\n}\n\nexport type NoticeSettings< T extends Post > = {\n\tsuccess: {\n\t\tid?: string;\n\t\ttype?: string;\n\t\tmessages: {\n\t\t\tgetMessage: ( posts: T ) => string;\n\t\t\tgetBatchMessage: ( posts: T[] ) => string;\n\t\t};\n\t};\n\terror: {\n\t\tid?: string;\n\t\ttype?: string;\n\t\tmessages: {\n\t\t\tgetMessage: ( errors: Set< string > ) => string;\n\t\t\tgetBatchMessage: ( errors: Set< string > ) => string;\n\t\t};\n\t};\n};\n\nexport const deletePostWithNotices = async < T extends Post >(\n\tposts: T[],\n\tnotice: NoticeSettings< T >,\n\tcallbacks: {\n\t\tonActionPerformed?: ( posts: T[] ) => void;\n\t\tonActionError?: () => void;\n\t}\n) => {\n\tconst { createSuccessNotice, createErrorNotice } = dispatch( noticesStore );\n\tconst { deleteEntityRecord } = dispatch( coreStore );\n\tconst allSettledResults = await Promise.allSettled(\n\t\tposts.map( ( post ) => {\n\t\t\treturn deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.type,\n\t\t\t\tpost.id,\n\t\t\t\t{ force: true },\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t} )\n\t);\n\t// If all the promises were fulfilled with success.\n\tif ( allSettledResults.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\tlet successMessage;\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\tsuccessMessage = notice.success.messages.getMessage( posts[ 0 ] );\n\t\t} else {\n\t\t\tsuccessMessage = notice.success.messages.getBatchMessage( posts );\n\t\t}\n\t\tcreateSuccessNotice( successMessage, {\n\t\t\ttype: notice.success.type ?? 'snackbar',\n\t\t\tid: notice.success.id,\n\t\t} );\n\t\tcallbacks.onActionPerformed?.( posts );\n\t} else {\n\t\tconst errorMessages = getErrorMessagesFromPromises( allSettledResults );\n\t\tlet errorMessage = '';\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\terrorMessage = notice.error.messages.getMessage( errorMessages );\n\t\t} else {\n\t\t\terrorMessage =\n\t\t\t\tnotice.error.messages.getBatchMessage( errorMessages );\n\t\t}\n\n\t\tcreateErrorNotice( errorMessage, {\n\t\t\ttype: notice.error.type ?? 'snackbar',\n\t\t\tid: notice.error.id,\n\t\t} );\n\t\tcallbacks.onActionError?.();\n\t}\n};\n\nexport const editPostWithNotices = async < T extends Post >(\n\tpostsWithUpdates: {\n\t\toriginalPost: T;\n\t\tchanges: Partial< T >;\n\t}[],\n\tnotice: NoticeSettings< T >,\n\tcallbacks: {\n\t\tonActionPerformed?: ( posts: T[] ) => void;\n\t\tonActionError?: () => void;\n\t}\n) => {\n\tconst { createSuccessNotice, createErrorNotice } = dispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } = dispatch( coreStore );\n\tawait Promise.allSettled(\n\t\tpostsWithUpdates.map( ( post ) => {\n\t\t\treturn editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.originalPost.type,\n\t\t\t\tpost.originalPost.id,\n\t\t\t\t{\n\t\t\t\t\t...post.changes,\n\t\t\t\t}\n\t\t\t);\n\t\t} )\n\t);\n\tconst allSettledResults = await Promise.allSettled(\n\t\tpostsWithUpdates.map( ( post ) => {\n\t\t\treturn saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.originalPost.type,\n\t\t\t\tpost.originalPost.id,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} )\n\t);\n\t// If all the promises were fulfilled with success.\n\tif ( allSettledResults.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\tlet successMessage;\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\tsuccessMessage = notice.success.messages.getMessage(\n\t\t\t\tpostsWithUpdates[ 0 ].originalPost\n\t\t\t);\n\t\t} else {\n\t\t\tsuccessMessage = notice.success.messages.getBatchMessage(\n\t\t\t\tpostsWithUpdates.map( ( post ) => post.originalPost )\n\t\t\t);\n\t\t}\n\t\tcreateSuccessNotice( successMessage, {\n\t\t\ttype: notice.success.type ?? 'snackbar',\n\t\t\tid: notice.success.id,\n\t\t} );\n\t\tcallbacks.onActionPerformed?.(\n\t\t\tpostsWithUpdates.map( ( post ) => post.originalPost )\n\t\t);\n\t} else {\n\t\tconst errorMessages = getErrorMessagesFromPromises( allSettledResults );\n\t\tlet errorMessage = '';\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\terrorMessage = notice.error.messages.getMessage( errorMessages );\n\t\t} else {\n\t\t\terrorMessage =\n\t\t\t\tnotice.error.messages.getBatchMessage( errorMessages );\n\t\t}\n\n\t\tcreateErrorNotice( errorMessage, {\n\t\t\ttype: notice.error.type ?? 'snackbar',\n\t\t\tid: notice.error.id,\n\t\t} );\n\t\tcallbacks.onActionError?.();\n\t}\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,QAAQ,iBAAiB;;AAE1C;AACA;AACA;;AAGA,SAASC,4BAA4BA,CACpCC,iBAA8C,EAC7C;EACD,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAW,CAAC;EACzC;EACA,IAAKF,iBAAiB,CAACG,MAAM,KAAK,CAAC,EAAG;IACrC,MAAMC,UAAU,GAAGJ,iBAAiB,CAAE,CAAC,CAEtC;IACD,IAAKI,UAAU,CAACC,MAAM,EAAEC,OAAO,EAAG;MACjCL,aAAa,CAACM,GAAG,CAAEH,UAAU,CAACC,MAAM,CAACC,OAAQ,CAAC;IAC/C;EACD,CAAC,MAAM;IACN,MAAME,cAAc,GAAGR,iBAAiB,CAACS,MAAM,CAC9C,CAAE;MAAEC;IAAO,CAAC,KAAMA,MAAM,KAAK,UAC9B,CAAC;IACD,KAAM,MAAMC,aAAa,IAAIH,cAAc,EAAG;MAC7C,MAAMJ,UAAU,GAAGO,aAElB;MACD,IAAKP,UAAU,CAACC,MAAM,EAAEC,OAAO,EAAG;QACjCL,aAAa,CAACM,GAAG,CAAEH,UAAU,CAACC,MAAM,CAACC,OAAQ,CAAC;MAC/C;IACD;EACD;EACA,OAAOL,aAAa;AACrB;AAqBA,OAAO,MAAMW,qBAAqB,GAAG,MAAAA,CACpCC,KAAU,EACVC,MAA2B,EAC3BC,SAGC,KACG;EACJ,MAAM;IAAEC,mBAAmB;IAAEC;EAAkB,CAAC,GAAGnB,QAAQ,CAAEF,YAAa,CAAC;EAC3E,MAAM;IAAEsB;EAAmB,CAAC,GAAGpB,QAAQ,CAAED,SAAU,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AAI,cAAAuB,mBAAA,cAAAA,mBAAA,GAAI,UAAU;MACrCtB,EAAE,EAAEV,MAAM,CAACuB,KAAK,CAACb;IAClB,CAAE,CAAC;IACHT,SAAS,CAACuB,aAAa,GAAG,CAAC;EAC5B;AACD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["store","noticesStore","coreStore","dispatch","getErrorMessagesFromPromises","allSettledResults","errorMessages","Set","length","typedError","reason","message","add","failedPromises","filter","status","failedPromise","deletePostWithNotices","posts","notice","callbacks","createSuccessNotice","createErrorNotice","deleteEntityRecord","Promise","allSettled","map","post","type","id","force","throwOnError","every","_notice$success$type","successMessage","success","messages","getMessage","getBatchMessage","onActionPerformed","_notice$error$type","errorMessage","error","onActionError","editPostWithNotices","postsWithUpdates","editEntityRecord","saveEditedEntityRecord","originalPost","changes","_notice$success$type2","_notice$error$type2"],"sources":["@wordpress/fields/src/mutation/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport type { CoreDataError, Post } from '../types';\n\nfunction getErrorMessagesFromPromises< T >(\n\tallSettledResults: PromiseSettledResult< T >[]\n) {\n\tconst errorMessages = new Set< string >();\n\t// If there was at lease one failure.\n\tif ( allSettledResults.length === 1 ) {\n\t\tconst typedError = allSettledResults[ 0 ] as {\n\t\t\treason?: CoreDataError;\n\t\t};\n\t\tif ( typedError.reason?.message ) {\n\t\t\terrorMessages.add( typedError.reason.message );\n\t\t}\n\t} else {\n\t\tconst failedPromises = allSettledResults.filter(\n\t\t\t( { status } ) => status === 'rejected'\n\t\t);\n\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\tconst typedError = failedPromise as {\n\t\t\t\treason?: CoreDataError;\n\t\t\t};\n\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t}\n\t\t}\n\t}\n\treturn errorMessages;\n}\n\nexport type NoticeSettings< T extends Post > = {\n\tsuccess: {\n\t\tid?: string;\n\t\ttype?: string;\n\t\tmessages: {\n\t\t\tgetMessage: ( posts: T ) => string;\n\t\t\tgetBatchMessage: ( posts: T[] ) => string;\n\t\t};\n\t};\n\terror: {\n\t\tid?: string;\n\t\ttype?: string;\n\t\tmessages: {\n\t\t\tgetMessage: ( errors: Set< string > ) => string;\n\t\t\tgetBatchMessage: ( errors: Set< string > ) => string;\n\t\t};\n\t};\n};\n\nexport const deletePostWithNotices = async < T extends Post >(\n\tposts: T[],\n\tnotice: NoticeSettings< T >,\n\tcallbacks: {\n\t\tonActionPerformed?: ( posts: T[] ) => void;\n\t\tonActionError?: () => void;\n\t}\n) => {\n\tconst { createSuccessNotice, createErrorNotice } = dispatch( noticesStore );\n\tconst { deleteEntityRecord } = dispatch( coreStore );\n\tconst allSettledResults = await Promise.allSettled(\n\t\tposts.map( ( post ) => {\n\t\t\treturn deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.type,\n\t\t\t\tpost.id,\n\t\t\t\t{ force: true },\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t} )\n\t);\n\t// If all the promises were fulfilled with success.\n\tif ( allSettledResults.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\tlet successMessage;\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\tsuccessMessage = notice.success.messages.getMessage( posts[ 0 ] );\n\t\t} else {\n\t\t\tsuccessMessage = notice.success.messages.getBatchMessage( posts );\n\t\t}\n\t\tcreateSuccessNotice( successMessage, {\n\t\t\ttype: notice.success.type ?? 'snackbar',\n\t\t\tid: notice.success.id,\n\t\t} );\n\t\tcallbacks.onActionPerformed?.( posts );\n\t} else {\n\t\tconst errorMessages = getErrorMessagesFromPromises( allSettledResults );\n\t\tlet errorMessage = '';\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\terrorMessage = notice.error.messages.getMessage( errorMessages );\n\t\t} else {\n\t\t\terrorMessage =\n\t\t\t\tnotice.error.messages.getBatchMessage( errorMessages );\n\t\t}\n\n\t\tcreateErrorNotice( errorMessage, {\n\t\t\ttype: notice.error.type ?? 'snackbar',\n\t\t\tid: notice.error.id,\n\t\t} );\n\t\tcallbacks.onActionError?.();\n\t}\n};\n\nexport const editPostWithNotices = async < T extends Post >(\n\tpostsWithUpdates: {\n\t\toriginalPost: T;\n\t\tchanges: Partial< T >;\n\t}[],\n\tnotice: NoticeSettings< T >,\n\tcallbacks: {\n\t\tonActionPerformed?: ( posts: T[] ) => void;\n\t\tonActionError?: () => void;\n\t}\n) => {\n\tconst { createSuccessNotice, createErrorNotice } = dispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } = dispatch( coreStore );\n\tawait Promise.allSettled(\n\t\tpostsWithUpdates.map( ( post ) => {\n\t\t\treturn editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.originalPost.type,\n\t\t\t\tpost.originalPost.id,\n\t\t\t\t{\n\t\t\t\t\t...post.changes,\n\t\t\t\t}\n\t\t\t);\n\t\t} )\n\t);\n\tconst allSettledResults = await Promise.allSettled(\n\t\tpostsWithUpdates.map( ( post ) => {\n\t\t\treturn saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.originalPost.type,\n\t\t\t\tpost.originalPost.id,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} )\n\t);\n\t// If all the promises were fulfilled with success.\n\tif ( allSettledResults.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\tlet successMessage;\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\tsuccessMessage = notice.success.messages.getMessage(\n\t\t\t\tpostsWithUpdates[ 0 ].originalPost\n\t\t\t);\n\t\t} else {\n\t\t\tsuccessMessage = notice.success.messages.getBatchMessage(\n\t\t\t\tpostsWithUpdates.map( ( post ) => post.originalPost )\n\t\t\t);\n\t\t}\n\t\tcreateSuccessNotice( successMessage, {\n\t\t\ttype: notice.success.type ?? 'snackbar',\n\t\t\tid: notice.success.id,\n\t\t} );\n\t\tcallbacks.onActionPerformed?.(\n\t\t\tpostsWithUpdates.map( ( post ) => post.originalPost )\n\t\t);\n\t} else {\n\t\tconst errorMessages = getErrorMessagesFromPromises( allSettledResults );\n\t\tlet errorMessage = '';\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\terrorMessage = notice.error.messages.getMessage( errorMessages );\n\t\t} else {\n\t\t\terrorMessage =\n\t\t\t\tnotice.error.messages.getBatchMessage( errorMessages );\n\t\t}\n\n\t\tcreateErrorNotice( errorMessage, {\n\t\t\ttype: notice.error.type ?? 'snackbar',\n\t\t\tid: notice.error.id,\n\t\t} );\n\t\tcallbacks.onActionError?.();\n\t}\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,QAAQ,iBAAiB;;AAE1C;AACA;AACA;;AAGA,SAASC,4BAA4BA,CACpCC,iBAA8C,EAC7C;EACD,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAW,CAAC;EACzC;EACA,IAAKF,iBAAiB,CAACG,MAAM,KAAK,CAAC,EAAG;IACrC,MAAMC,UAAU,GAAGJ,iBAAiB,CAAE,CAAC,CAEtC;IACD,IAAKI,UAAU,CAACC,MAAM,EAAEC,OAAO,EAAG;MACjCL,aAAa,CAACM,GAAG,CAAEH,UAAU,CAACC,MAAM,CAACC,OAAQ,CAAC;IAC/C;EACD,CAAC,MAAM;IACN,MAAME,cAAc,GAAGR,iBAAiB,CAACS,MAAM,CAC9C,CAAE;MAAEC;IAAO,CAAC,KAAMA,MAAM,KAAK,UAC9B,CAAC;IACD,KAAM,MAAMC,aAAa,IAAIH,cAAc,EAAG;MAC7C,MAAMJ,UAAU,GAAGO,aAElB;MACD,IAAKP,UAAU,CAACC,MAAM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,GAAG,EAAE;IACrB,IAAKpC,iBAAiB,CAACG,MAAM,KAAK,CAAC,EAAG;MACrCiC,YAAY,GAAGtB,MAAM,CAACuB,KAAK,CAACN,QAAQ,CAACC,UAAU,CAAE/B,aAAc,CAAC;IACjE,CAAC,MAAM;MACNmC,YAAY,GACXtB,MAAM,CAACuB,KAAK,CAACN,QAAQ,CAACE,eAAe,CAAEhC,aAAc,CAAC;IACxD;IAEAgB,iBAAiB,CAAEmB,YAAY,EAAE;MAChCb,IAAI,GAAAuB,mBAAA,GAAEhC,MAAM,CAACuB,KAAK,CAACd,IAAI,cAAAuB,mBAAA,cAAAA,mBAAA,GAAI,UAAU;MACrCtB,EAAE,EAAEV,MAAM,CAACuB,KAAK,CAACb;IAClB,CAAE,CAAC;IACHT,SAAS,CAACuB,aAAa,GAAG,CAAC;EAC5B;AACD,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/fields/src/types.ts"],"sourcesContent":["type PostStatus =\n\t| 'publish'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface CommonPost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\tcontent: string | { raw: string; rendered: string };\n\ttype: string;\n\tid: string | number;\n\tblocks?: Object[];\n\t_links?: Links;\n}\n\ninterface Links {\n\t'predecessor-version'?: { href: string; id: number }[];\n\t'version-history'?: { href: string; count: number }[];\n\t[ key: string ]: { href: string }[] | undefined;\n}\n\ninterface Author {\n\tname: string;\n\tavatar_urls: Record< string, string >;\n}\n\ninterface EmbeddedAuthor {\n\tauthor: Author[];\n}\n\nexport interface BasePost extends CommonPost {\n\tcomment_status?: 'open' | 'closed';\n\texcerpt?: string | { raw: string; rendered: string };\n\tmeta?: Record< string, any >;\n\tparent?: number;\n\tpassword?: string;\n\ttemplate?: string;\n\tformat?: string;\n\tfeatured_media?: number;\n\tmenu_order?: number;\n\tping_status?: 'open' | 'closed';\n\tlink?: string;\n\tslug?: string;\n\tpermalink_template?: string;\n\tdate?: string;\n\tmodified?: string;\n\tauthor?: number;\n}\n\nexport interface BasePostWithEmbeddedAuthor extends BasePost {\n\t_embedded: EmbeddedAuthor;\n}\n\nexport interface Template extends CommonPost {\n\ttype: 'wp_template';\n\tis_custom: boolean;\n\tsource: string;\n\torigin: string;\n\tplugin?: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface TemplatePart extends CommonPost {\n\ttype: 'wp_template_part';\n\tsource: string;\n\torigin: string;\n\thas_theme_file: boolean;\n\tid: string;\n\tarea: string;\n\tplugin?: string;\n}\n\nexport interface Pattern extends CommonPost {\n\tslug: string;\n\ttitle: { raw: string };\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = Template | TemplatePart | Pattern | BasePost;\n\nexport type PostWithPermissions = Post & {\n\tpermissions: {\n\t\tdelete: boolean;\n\t\tupdate: boolean;\n\t};\n};\n\nexport interface PostType {\n\tslug: string;\n\tviewable: boolean;\n\tsupports?: {\n\t\t'page-attributes'?: boolean;\n\t\ttitle?: boolean;\n\t\trevisions?: boolean;\n\t};\n}\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/fields/src/types.ts"],"sourcesContent":["type PostStatus =\n\t| 'publish'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface CommonPost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\tcontent: string | { raw: string; rendered: string };\n\ttype: string;\n\tid: string | number;\n\tblocks?: Object[];\n\t_links?: Links;\n}\n\ninterface Links {\n\t'predecessor-version'?: { href: string; id: number }[];\n\t'version-history'?: { href: string; count: number }[];\n\t[ key: string ]: { href: string }[] | undefined;\n}\n\ninterface Author {\n\tname: string;\n\tavatar_urls: Record< string, string >;\n}\n\ninterface EmbeddedAuthor {\n\tauthor: Author[];\n}\n\nexport interface BasePost extends CommonPost {\n\tcomment_status?: 'open' | 'closed';\n\texcerpt?: string | { raw: string; rendered: string };\n\tmeta?: Record< string, any >;\n\tparent?: number;\n\tpassword?: string;\n\ttemplate?: string;\n\tformat?: string;\n\tfeatured_media?: number;\n\tmenu_order?: number;\n\tping_status?: 'open' | 'closed';\n\tlink?: string;\n\tslug?: string;\n\tpermalink_template?: string;\n\tdate?: string;\n\tmodified?: string;\n\tauthor?: number;\n}\n\nexport interface BasePostWithEmbeddedAuthor extends BasePost {\n\t_embedded: EmbeddedAuthor;\n}\n\nexport interface Template extends CommonPost {\n\ttype: 'wp_template';\n\tis_custom: boolean;\n\tsource: string;\n\torigin: string;\n\tplugin?: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface TemplatePart extends CommonPost {\n\ttype: 'wp_template_part';\n\tsource: string;\n\torigin: string;\n\thas_theme_file: boolean;\n\tid: string;\n\tarea: string;\n\tplugin?: string;\n}\n\nexport interface Pattern extends CommonPost {\n\tslug: string;\n\ttitle: { raw: string };\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = Template | TemplatePart | Pattern | BasePost;\n\nexport type PostWithPermissions = Post & {\n\tpermissions: {\n\t\tdelete: boolean;\n\t\tupdate: boolean;\n\t};\n};\n\nexport interface PostType {\n\tslug: string;\n\tviewable: boolean;\n\tsupports?: {\n\t\t'page-attributes'?: boolean;\n\t\ttitle?: boolean;\n\t\trevisions?: boolean;\n\t\tauthor?: string;\n\t\tthumbnail?: string;\n\t\tcomments?: string;\n\t};\n}\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n"],"mappings":"","ignoreList":[]}
|
|
@@ -116,6 +116,57 @@
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
.fields-create-template-part-modal {
|
|
120
|
+
z-index: 1000001;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.fields-create-template-part-modal__area-radio-group {
|
|
124
|
+
width: 100%;
|
|
125
|
+
border: 1px solid #757575;
|
|
126
|
+
border-radius: 2px;
|
|
127
|
+
}
|
|
128
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio {
|
|
129
|
+
display: block;
|
|
130
|
+
width: 100%;
|
|
131
|
+
height: 100%;
|
|
132
|
+
text-align: right;
|
|
133
|
+
padding: 12px;
|
|
134
|
+
}
|
|
135
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-secondary:hover, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-primary:hover {
|
|
136
|
+
margin: 0;
|
|
137
|
+
background-color: inherit;
|
|
138
|
+
border-bottom: 1px solid #757575;
|
|
139
|
+
border-radius: 0;
|
|
140
|
+
}
|
|
141
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio:not(:focus), .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-secondary:hover:not(:focus), .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-primary:hover:not(:focus) {
|
|
142
|
+
box-shadow: none;
|
|
143
|
+
}
|
|
144
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio:focus, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-secondary:hover:focus, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-primary:hover:focus {
|
|
145
|
+
border-bottom: 1px solid #fff;
|
|
146
|
+
}
|
|
147
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio:last-of-type, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-secondary:hover:last-of-type, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-primary:hover:last-of-type {
|
|
148
|
+
border-bottom: none;
|
|
149
|
+
}
|
|
150
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio:not(:hover), .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio[aria-checked=true] {
|
|
151
|
+
color: #1e1e1e;
|
|
152
|
+
cursor: auto;
|
|
153
|
+
}
|
|
154
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio:not(:hover) .fields-create-template-part-modal__option-label div, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio[aria-checked=true] .fields-create-template-part-modal__option-label div {
|
|
155
|
+
color: #949494;
|
|
156
|
+
}
|
|
157
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio .fields-create-template-part-modal__option-label {
|
|
158
|
+
padding-top: 4px;
|
|
159
|
+
white-space: normal;
|
|
160
|
+
}
|
|
161
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio .fields-create-template-part-modal__option-label div {
|
|
162
|
+
padding-top: 4px;
|
|
163
|
+
font-size: 12px;
|
|
164
|
+
}
|
|
165
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio .fields-create-template-part-modal__checkbox {
|
|
166
|
+
margin-right: auto;
|
|
167
|
+
min-width: 24px;
|
|
168
|
+
}
|
|
169
|
+
|
|
119
170
|
.fields-controls__slug .fields-controls__slug-external-icon {
|
|
120
171
|
margin-right: 5ch;
|
|
121
172
|
}
|
|
@@ -208,4 +259,27 @@ fieldset.fields-controls__featured-image .fields-controls__featured-image-remove
|
|
|
208
259
|
width: 32px;
|
|
209
260
|
height: 32px;
|
|
210
261
|
display: block;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.fields-controls__template-modal {
|
|
265
|
+
z-index: 1000001;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.fields-controls__template-content .block-editor-block-patterns-list {
|
|
269
|
+
column-count: 2;
|
|
270
|
+
column-gap: 24px;
|
|
271
|
+
padding-top: 2px;
|
|
272
|
+
}
|
|
273
|
+
@media (min-width: 782px) {
|
|
274
|
+
.fields-controls__template-content .block-editor-block-patterns-list {
|
|
275
|
+
column-count: 3;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
@media (min-width: 1280px) {
|
|
279
|
+
.fields-controls__template-content .block-editor-block-patterns-list {
|
|
280
|
+
column-count: 4;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
.fields-controls__template-content .block-editor-block-patterns-list .block-editor-block-patterns-list__list-item {
|
|
284
|
+
break-inside: avoid-column;
|
|
211
285
|
}
|
package/build-style/style.css
CHANGED
|
@@ -116,6 +116,57 @@
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
.fields-create-template-part-modal {
|
|
120
|
+
z-index: 1000001;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.fields-create-template-part-modal__area-radio-group {
|
|
124
|
+
width: 100%;
|
|
125
|
+
border: 1px solid #757575;
|
|
126
|
+
border-radius: 2px;
|
|
127
|
+
}
|
|
128
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio {
|
|
129
|
+
display: block;
|
|
130
|
+
width: 100%;
|
|
131
|
+
height: 100%;
|
|
132
|
+
text-align: left;
|
|
133
|
+
padding: 12px;
|
|
134
|
+
}
|
|
135
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-secondary:hover, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-primary:hover {
|
|
136
|
+
margin: 0;
|
|
137
|
+
background-color: inherit;
|
|
138
|
+
border-bottom: 1px solid #757575;
|
|
139
|
+
border-radius: 0;
|
|
140
|
+
}
|
|
141
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio:not(:focus), .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-secondary:hover:not(:focus), .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-primary:hover:not(:focus) {
|
|
142
|
+
box-shadow: none;
|
|
143
|
+
}
|
|
144
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio:focus, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-secondary:hover:focus, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-primary:hover:focus {
|
|
145
|
+
border-bottom: 1px solid #fff;
|
|
146
|
+
}
|
|
147
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio:last-of-type, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-secondary:hover:last-of-type, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio.is-primary:hover:last-of-type {
|
|
148
|
+
border-bottom: none;
|
|
149
|
+
}
|
|
150
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio:not(:hover), .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio[aria-checked=true] {
|
|
151
|
+
color: #1e1e1e;
|
|
152
|
+
cursor: auto;
|
|
153
|
+
}
|
|
154
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio:not(:hover) .fields-create-template-part-modal__option-label div, .fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio[aria-checked=true] .fields-create-template-part-modal__option-label div {
|
|
155
|
+
color: #949494;
|
|
156
|
+
}
|
|
157
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio .fields-create-template-part-modal__option-label {
|
|
158
|
+
padding-top: 4px;
|
|
159
|
+
white-space: normal;
|
|
160
|
+
}
|
|
161
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio .fields-create-template-part-modal__option-label div {
|
|
162
|
+
padding-top: 4px;
|
|
163
|
+
font-size: 12px;
|
|
164
|
+
}
|
|
165
|
+
.fields-create-template-part-modal__area-radio-group .components-button.fields-create-template-part-modal__area-radio .fields-create-template-part-modal__checkbox {
|
|
166
|
+
margin-left: auto;
|
|
167
|
+
min-width: 24px;
|
|
168
|
+
}
|
|
169
|
+
|
|
119
170
|
.fields-controls__slug .fields-controls__slug-external-icon {
|
|
120
171
|
margin-left: 5ch;
|
|
121
172
|
}
|
|
@@ -208,4 +259,27 @@ fieldset.fields-controls__featured-image .fields-controls__featured-image-remove
|
|
|
208
259
|
width: 32px;
|
|
209
260
|
height: 32px;
|
|
210
261
|
display: block;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.fields-controls__template-modal {
|
|
265
|
+
z-index: 1000001;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.fields-controls__template-content .block-editor-block-patterns-list {
|
|
269
|
+
column-count: 2;
|
|
270
|
+
column-gap: 24px;
|
|
271
|
+
padding-top: 2px;
|
|
272
|
+
}
|
|
273
|
+
@media (min-width: 782px) {
|
|
274
|
+
.fields-controls__template-content .block-editor-block-patterns-list {
|
|
275
|
+
column-count: 3;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
@media (min-width: 1280px) {
|
|
279
|
+
.fields-controls__template-content .block-editor-block-patterns-list {
|
|
280
|
+
column-count: 4;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
.fields-controls__template-content .block-editor-block-patterns-list .block-editor-block-patterns-list__list-item {
|
|
284
|
+
break-inside: avoid-column;
|
|
211
285
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Action } from '@wordpress/dataviews';
|
|
2
|
+
/**
|
|
3
|
+
* Internal dependencies
|
|
4
|
+
*/
|
|
5
|
+
import type { TemplatePart } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* This action is used to duplicate a template part.
|
|
8
|
+
*/
|
|
9
|
+
declare const duplicateTemplatePart: Action<TemplatePart>;
|
|
10
|
+
export default duplicateTemplatePart;
|
|
11
|
+
//# sourceMappingURL=duplicate-template-part.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicate-template-part.d.ts","sourceRoot":"","sources":["../../src/actions/duplicate-template-part.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;GAEG;AACH,OAAO,KAAK,EAAQ,YAAY,EAAE,MAAM,UAAU,CAAC;AAInD;;GAEG;AACH,QAAA,MAAM,qBAAqB,EAAE,MAAM,CAAE,YAAY,CAgDhD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -13,4 +13,5 @@ export { default as permanentlyDeletePost } from './permanently-delete-post';
|
|
|
13
13
|
export { default as restorePost } from './restore-post';
|
|
14
14
|
export { default as trashPost } from './trash-post';
|
|
15
15
|
export { default as deletePost } from './delete-post';
|
|
16
|
+
export { default as duplicateTemplatePart } from './duplicate-template-part';
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,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E,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename-post.d.ts","sourceRoot":"","sources":["../../src/actions/rename-post.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"rename-post.d.ts","sourceRoot":"","sources":["../../src/actions/rename-post.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAcnD,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAKnE,QAAA,MAAM,UAAU,EAAE,MAAM,CAAE,mBAAmB,CAyG5C,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-post.d.ts","sourceRoot":"","sources":["../../src/actions/reset-post.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"reset-post.d.ts","sourceRoot":"","sources":["../../src/actions/reset-post.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAQnD,OAAO,KAAK,EAAiB,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAwJtE,QAAA,MAAM,eAAe,EAAE,MAAM,CAAE,QAAQ,GAAG,YAAY,CAmHrD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { Post, TemplatePart, Template } from '../types';
|
|
5
|
-
export declare const TEMPLATE_POST_TYPE = "wp_template";
|
|
6
|
-
export declare const TEMPLATE_PART_POST_TYPE = "wp_template_part";
|
|
7
|
-
export declare const TEMPLATE_ORIGINS: {
|
|
8
|
-
custom: string;
|
|
9
|
-
theme: string;
|
|
10
|
-
plugin: string;
|
|
11
|
-
};
|
|
12
5
|
export declare function isTemplate(post: Post): post is Template;
|
|
13
6
|
export declare function isTemplatePart(post: Post): post is TemplatePart;
|
|
14
7
|
export declare function isTemplateOrTemplatePart(p: Post): p is Template | TemplatePart;
|
|
15
|
-
export declare function getItemTitle(item:
|
|
8
|
+
export declare function getItemTitle(item: {
|
|
9
|
+
title: string | {
|
|
10
|
+
rendered: string;
|
|
11
|
+
} | {
|
|
12
|
+
raw: string;
|
|
13
|
+
};
|
|
14
|
+
}): string;
|
|
16
15
|
/**
|
|
17
16
|
* Check if a template is removable.
|
|
18
17
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/actions/utils.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE7D,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/actions/utils.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE7D,wBAAgB,UAAU,CAAE,IAAI,EAAE,IAAI,GAAI,IAAI,IAAI,QAAQ,CAEzD;AAED,wBAAgB,cAAc,CAAE,IAAI,EAAE,IAAI,GAAI,IAAI,IAAI,YAAY,CAEjE;AAED,wBAAgB,wBAAwB,CACvC,CAAC,EAAE,IAAI,GACL,CAAC,IAAI,QAAQ,GAAG,YAAY,CAE9B;AAED,wBAAgB,YAAY,CAAE,IAAI,EAAE;IACnC,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACvD,UAWA;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAE,QAAQ,EAAE,QAAQ,GAAG,YAAY,WAYrE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type CreateTemplatePartModalContentsProps = {
|
|
2
|
+
defaultArea?: string;
|
|
3
|
+
blocks: any[];
|
|
4
|
+
confirmLabel?: string;
|
|
5
|
+
closeModal: () => void;
|
|
6
|
+
onCreate: (templatePart: any) => void;
|
|
7
|
+
onError?: () => void;
|
|
8
|
+
defaultTitle?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 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.
|
|
12
|
+
* This component should not live in this package, it should be moved to a dedicated package responsible for managing template.
|
|
13
|
+
* @param {Object} props The component props.
|
|
14
|
+
* @param props.modalTitle
|
|
15
|
+
*/
|
|
16
|
+
export default function CreateTemplatePartModal({ modalTitle, ...restProps }: {
|
|
17
|
+
modalTitle: string;
|
|
18
|
+
} & CreateTemplatePartModalContentsProps): import("react").JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* A React component that renders the content of a model for creating a template part.
|
|
21
|
+
* This component should not live in this package; it should be moved to a dedicated package responsible for managing template.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} props - The component props.
|
|
24
|
+
* @param {string} [props.defaultArea=uncategorized] - The default area for the template part.
|
|
25
|
+
* @param {Array} [props.blocks=[]] - The blocks to be included in the template part.
|
|
26
|
+
* @param {string} [props.confirmLabel='Add'] - The label for the confirm button.
|
|
27
|
+
* @param {Function} props.closeModal - Function to close the modal.
|
|
28
|
+
* @param {Function} props.onCreate - Function to call when the template part is successfully created.
|
|
29
|
+
* @param {Function} [props.onError] - Function to call when there is an error creating the template part.
|
|
30
|
+
* @param {string} [props.defaultTitle=''] - The default title for the template part.
|
|
31
|
+
*/
|
|
32
|
+
export declare function CreateTemplatePartModalContents({ defaultArea, blocks, confirmLabel, closeModal, onCreate, onError, defaultTitle, }: CreateTemplatePartModalContentsProps): import("react").JSX.Element;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/create-template-part-modal/index.tsx"],"names":[],"mappings":"AA0CA,KAAK,oCAAoC,GAAG;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,EAAE,CAAE,YAAY,EAAE,GAAG,KAAM,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAE,EAChD,UAAU,EACV,GAAG,SAAS,EACZ,EAAE;IACF,UAAU,EAAE,MAAM,CAAC;CACnB,GAAG,oCAAoC,+BAoBvC;AAaD;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAAE,EAChD,WAA6B,EAC7B,MAAW,EACX,YAA0B,EAC1B,UAAU,EACV,QAAQ,EACR,OAAO,EACP,YAAiB,GACjB,EAAE,oCAAoC,+BA4JtC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export function useExistingTemplateParts(): (import("@wordpress/core-data").Attachment<any> | import("@wordpress/core-data").Comment<any> | import("@wordpress/core-data").GlobalStylesRevision<any> | import("@wordpress/core-data").MenuLocation<any> | import("@wordpress/core-data").NavMenu<any> | import("@wordpress/core-data").NavMenuItem<any> | import("@wordpress/core-data").Page<any> | import("@wordpress/core-data").Plugin<any> | import("@wordpress/core-data").Post<any> | import("@wordpress/core-data").PostRevision<any> | import("@wordpress/core-data").Settings<any> | import("@wordpress/core-data").Sidebar<any> | import("@wordpress/core-data").Taxonomy<any> | import("@wordpress/core-data").Theme<any> | import("@wordpress/core-data").User<any> | import("@wordpress/core-data").Type<any> | import("@wordpress/core-data").Widget<any> | import("@wordpress/core-data").WidgetType<any> | import("@wordpress/core-data").WpTemplate<any> | import("@wordpress/core-data").WpTemplatePart<any> | Partial<import("@wordpress/core-data").Attachment<any> | import("@wordpress/core-data").Comment<any> | import("@wordpress/core-data").GlobalStylesRevision<any> | import("@wordpress/core-data").MenuLocation<any> | import("@wordpress/core-data").NavMenu<any> | import("@wordpress/core-data").NavMenuItem<any> | import("@wordpress/core-data").Page<any> | import("@wordpress/core-data").Plugin<any> | import("@wordpress/core-data").Post<any> | import("@wordpress/core-data").PostRevision<any> | import("@wordpress/core-data").Settings<any> | import("@wordpress/core-data").Sidebar<any> | import("@wordpress/core-data").Taxonomy<any> | import("@wordpress/core-data").Theme<any> | import("@wordpress/core-data").User<any> | import("@wordpress/core-data").Type<any> | import("@wordpress/core-data").Widget<any> | import("@wordpress/core-data").WidgetType<any> | import("@wordpress/core-data").WpTemplate<any> | import("@wordpress/core-data").WpTemplatePart<any>>)[];
|
|
2
|
+
export function getUniqueTemplatePartTitle(title: string, templateParts: Object): string;
|
|
3
|
+
export function getCleanTemplatePartSlug(title: string): string;
|
|
4
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/create-template-part-modal/utils.js"],"names":[],"mappings":"AAeO,i6DAcN;AAUM,kDAJI,MAAM,iBACN,MAAM,GACL,MAAM,CAkBjB;AAUM,gDAHI,MAAM,GACL,MAAM,CAIjB"}
|
|
@@ -2,6 +2,7 @@ export { default as slugField } from './slug';
|
|
|
2
2
|
export { default as titleField } from './title';
|
|
3
3
|
export { default as orderField } from './order';
|
|
4
4
|
export { default as featuredImageField } from './featured-image';
|
|
5
|
+
export { default as templateField } from './template';
|
|
5
6
|
export { default as parentField } from './parent';
|
|
6
7
|
export { default as passwordField } from './password';
|
|
7
8
|
export { default as statusField } from './status';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/fields/slug/utils.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,eAAO,MAAM,OAAO,SAAW,QAAQ,KAAI,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/fields/slug/utils.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,eAAO,MAAM,OAAO,SAAW,QAAQ,KAAI,MAQ1C,CAAC"}
|