@wordpress/edit-site 6.33.3-next.36001005c.0 → 6.33.3

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.
Files changed (53) hide show
  1. package/build/components/dataviews-actions/index.js +8 -6
  2. package/build/components/dataviews-actions/index.js.map +2 -2
  3. package/build/components/global-styles-renderer/index.js +4 -2
  4. package/build/components/global-styles-renderer/index.js.map +3 -3
  5. package/build/components/page-templates/fields.js +19 -26
  6. package/build/components/page-templates/fields.js.map +2 -2
  7. package/build/components/page-templates/index.js +41 -31
  8. package/build/components/page-templates/index.js.map +2 -2
  9. package/build/components/revisions/index.js +2 -2
  10. package/build/components/revisions/index.js.map +2 -2
  11. package/build/components/sidebar-navigation-screen-templates-browse/content.js +6 -7
  12. package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +2 -2
  13. package/build/components/style-book/index.js +8 -4
  14. package/build/components/style-book/index.js.map +2 -2
  15. package/build-module/components/dataviews-actions/index.js +8 -6
  16. package/build-module/components/dataviews-actions/index.js.map +2 -2
  17. package/build-module/components/global-styles-renderer/index.js +3 -1
  18. package/build-module/components/global-styles-renderer/index.js.map +2 -2
  19. package/build-module/components/page-templates/fields.js +19 -26
  20. package/build-module/components/page-templates/fields.js.map +2 -2
  21. package/build-module/components/page-templates/index.js +41 -31
  22. package/build-module/components/page-templates/index.js.map +2 -2
  23. package/build-module/components/revisions/index.js +1 -1
  24. package/build-module/components/revisions/index.js.map +2 -2
  25. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +6 -7
  26. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +2 -2
  27. package/build-module/components/style-book/index.js +6 -2
  28. package/build-module/components/style-book/index.js.map +2 -2
  29. package/build-style/posts-rtl.css +13 -13
  30. package/build-style/posts.css +13 -13
  31. package/build-style/style-rtl.css +23 -23
  32. package/build-style/style.css +23 -23
  33. package/package.json +44 -45
  34. package/src/components/dataviews-actions/index.js +12 -10
  35. package/src/components/global-styles/font-library-modal/style.scss +3 -3
  36. package/src/components/global-styles/style.scss +1 -1
  37. package/src/components/global-styles-renderer/index.js +4 -1
  38. package/src/components/global-styles-sidebar/style.scss +2 -2
  39. package/src/components/page-templates/fields.js +23 -29
  40. package/src/components/page-templates/index.js +51 -38
  41. package/src/components/revisions/index.js +1 -1
  42. package/src/components/sidebar-navigation-screen/style.scss +1 -1
  43. package/src/components/sidebar-navigation-screen-patterns/style.scss +1 -1
  44. package/src/components/sidebar-navigation-screen-templates-browse/content.js +6 -7
  45. package/src/components/site-hub/style.scss +1 -1
  46. package/src/components/style-book/index.js +6 -3
  47. package/tsconfig.json +0 -1
  48. package/tsconfig.tsbuildinfo +1 -1
  49. package/build/hooks/use-global-styles-output.js +0 -77
  50. package/build/hooks/use-global-styles-output.js.map +0 -7
  51. package/build-module/hooks/use-global-styles-output.js +0 -52
  52. package/build-module/hooks/use-global-styles-output.js.map +0 -7
  53. package/src/hooks/use-global-styles-output.js +0 -80
@@ -93,41 +93,32 @@ export default function PageTemplates() {
93
93
  combinedTemplates: false,
94
94
  } );
95
95
  const { records: staticRecords, isResolving: isLoadingStaticData } =
96
- useEntityRecordsWithPermissions( 'postType', 'wp_registered_template', {
96
+ useEntityRecordsWithPermissions( 'root', 'registeredTemplate', {
97
+ // This should not be needed, the endpoint returns all registered
98
+ // templates, but it's not possible right now to turn off pagination
99
+ // for entity configs.
97
100
  per_page: -1,
98
101
  } );
99
102
 
100
103
  const activeTemplates = useMemo( () => {
101
- const _active = [ ...staticRecords ].filter(
102
- ( record ) => ! record.is_custom
103
- );
104
+ const _active = [ ...staticRecords ];
104
105
  if ( activeTemplatesOption ) {
105
106
  for ( const activeSlug in activeTemplatesOption ) {
106
107
  const activeId = activeTemplatesOption[ activeSlug ];
107
- if ( activeId === false ) {
108
- // Remove the template from the array.
108
+ // Replace the template in the array.
109
+ const template = userRecords.find(
110
+ ( userRecord ) =>
111
+ userRecord.id === activeId &&
112
+ userRecord.theme === activeTheme.stylesheet
113
+ );
114
+ if ( template ) {
109
115
  const index = _active.findIndex(
110
- ( template ) => template.slug === activeSlug
116
+ ( { slug } ) => slug === template.slug
111
117
  );
112
118
  if ( index !== -1 ) {
113
- _active.splice( index, 1 );
114
- }
115
- } else {
116
- // Replace the template in the array.
117
- const template = userRecords.find(
118
- ( userRecord ) =>
119
- userRecord.id === activeId &&
120
- userRecord.theme === activeTheme.stylesheet
121
- );
122
- if ( template ) {
123
- const index = _active.findIndex(
124
- ( { slug } ) => slug === template.slug
125
- );
126
- if ( index !== -1 ) {
127
- _active[ index ] = template;
128
- } else {
129
- _active.push( template );
130
- }
119
+ _active[ index ] = template;
120
+ } else {
121
+ _active.push( template );
131
122
  }
132
123
  }
133
124
  }
@@ -135,33 +126,55 @@ export default function PageTemplates() {
135
126
  return _active;
136
127
  }, [ userRecords, staticRecords, activeTemplatesOption, activeTheme ] );
137
128
 
138
- let _records;
139
129
  let isLoadingData;
140
130
  if ( activeView === 'active' ) {
141
- _records = activeTemplates;
142
131
  isLoadingData = isLoadingUserRecords || isLoadingStaticData;
143
132
  } else if ( activeView === 'user' ) {
144
- _records = userRecords;
145
133
  isLoadingData = isLoadingUserRecords;
146
134
  } else {
147
- _records = staticRecords;
148
135
  isLoadingData = isLoadingStaticData;
149
136
  }
150
137
 
151
138
  const records = useMemo( () => {
139
+ function isCustom( record ) {
140
+ // For registered templates, the is_custom field is defined.
141
+ return (
142
+ record.is_custom ??
143
+ // For user templates it's custom if the is_wp_suggestion meta
144
+ // field is not set and the slug is not found in the default
145
+ // template types.
146
+ ( ! record.meta?.is_wp_suggestion &&
147
+ ! defaultTemplateTypes.some(
148
+ ( type ) => type.slug === record.slug
149
+ ) )
150
+ );
151
+ }
152
+
153
+ let _records;
154
+ if ( activeView === 'active' ) {
155
+ // Don't show active custom templates in the active view.
156
+ _records = activeTemplates.filter(
157
+ ( record ) => ! isCustom( record )
158
+ );
159
+ } else if ( activeView === 'user' ) {
160
+ _records = userRecords;
161
+ } else {
162
+ _records = staticRecords;
163
+ }
152
164
  return _records.map( ( record ) => ( {
153
165
  ...record,
154
- _isActive: activeTemplates.find(
166
+ _isActive: activeTemplates.some(
155
167
  ( template ) => template.id === record.id
156
168
  ),
157
- _isCustom:
158
- record.is_custom ||
159
- ( ! record.meta?.is_wp_suggestion &&
160
- ! defaultTemplateTypes.find(
161
- ( type ) => type.slug === record.slug
162
- ) ),
169
+ _isCustom: isCustom( record ),
163
170
  } ) );
164
- }, [ _records, activeTemplates, defaultTemplateTypes ] );
171
+ }, [
172
+ activeTemplates,
173
+ defaultTemplateTypes,
174
+ userRecords,
175
+ staticRecords,
176
+ activeView,
177
+ ] );
165
178
 
166
179
  const users = useSelect(
167
180
  ( select ) => {
@@ -325,7 +338,7 @@ export default function PageTemplates() {
325
338
  onChangeSelection={ onChangeSelection }
326
339
  isItemClickable={ () => true }
327
340
  onClickItem={ ( item ) => {
328
- if ( item.type === 'wp_registered_template' ) {
341
+ if ( typeof item.id === 'string' ) {
329
342
  setSelectedRegisteredTemplate( item );
330
343
  } else {
331
344
  history.navigate(
@@ -20,11 +20,11 @@ import { useContext, useMemo } from '@wordpress/element';
20
20
 
21
21
  import { unlock } from '../../lock-unlock';
22
22
  import EditorCanvasContainer from '../editor-canvas-container';
23
- import { useGlobalStylesOutputWithConfig } from '../../hooks/use-global-styles-output';
24
23
 
25
24
  const {
26
25
  ExperimentalBlockEditorProvider,
27
26
  GlobalStylesContext,
27
+ useGlobalStylesOutputWithConfig,
28
28
  __unstableBlockStyleVariationOverridesWithConfig,
29
29
  } = unlock( blockEditorPrivateApis );
30
30
  const { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );
@@ -76,7 +76,7 @@
76
76
  color: $gray-300;
77
77
  font-size: 11px;
78
78
  text-transform: uppercase;
79
- font-weight: $font-weight-medium;
79
+ font-weight: 500;
80
80
  }
81
81
 
82
82
  .edit-site-sidebar-navigation-screen__content .edit-site-global-styles-variations_item {
@@ -22,7 +22,7 @@
22
22
 
23
23
  h2 {
24
24
  font-size: 11px;
25
- font-weight: $font-weight-medium;
25
+ font-weight: 500;
26
26
  text-transform: uppercase;
27
27
  }
28
28
  }
@@ -38,13 +38,12 @@ export default function DataviewsTemplatesSidebarContent() {
38
38
  const {
39
39
  query: { activeView = 'active' },
40
40
  } = useLocation();
41
- const { records } = useEntityRecords(
42
- 'postType',
43
- 'wp_registered_template',
44
- {
45
- per_page: -1,
46
- }
47
- );
41
+ const { records } = useEntityRecords( 'root', 'registeredTemplate', {
42
+ // This should not be needed, the endpoint returns all registered
43
+ // templates, but it's not possible right now to turn off pagination for
44
+ // entity configs.
45
+ per_page: -1,
46
+ } );
48
47
  const firstItemPerAuthorText = useMemo( () => {
49
48
  const firstItemPerAuthor = records?.reduce( ( acc, template ) => {
50
49
  const author = template.author_text;
@@ -29,7 +29,7 @@
29
29
  display: block;
30
30
  flex-grow: 1;
31
31
  font-size: 15px;
32
- font-weight: $font-weight-medium;
32
+ font-weight: 500;
33
33
  overflow: hidden;
34
34
  // Add space for the ↗ to render.
35
35
  padding-right: $grid-unit-20;
@@ -56,10 +56,13 @@ import {
56
56
  STYLE_BOOK_COLOR_GROUPS,
57
57
  STYLE_BOOK_PREVIEW_CATEGORIES,
58
58
  } from '../style-book/constants';
59
- import { useGlobalStylesOutputWithConfig } from '../../hooks/use-global-styles-output';
60
59
 
61
- const { ExperimentalBlockEditorProvider, useGlobalStyle, GlobalStylesContext } =
62
- unlock( blockEditorPrivateApis );
60
+ const {
61
+ ExperimentalBlockEditorProvider,
62
+ useGlobalStyle,
63
+ GlobalStylesContext,
64
+ useGlobalStylesOutputWithConfig,
65
+ } = unlock( blockEditorPrivateApis );
63
66
  const { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );
64
67
 
65
68
  const { Tabs } = unlock( componentsPrivateApis );
package/tsconfig.json CHANGED
@@ -21,7 +21,6 @@
21
21
  { "path": "../element" },
22
22
  { "path": "../escape-html" },
23
23
  { "path": "../fields" },
24
- { "path": "../global-styles-engine" },
25
24
  { "path": "../hooks" },
26
25
  { "path": "../html-entities" },
27
26
  { "path": "../i18n" },