@wordpress/edit-site 6.0.0 → 6.1.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.
Files changed (205) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-page/index.js +2 -1
  3. package/build/components/add-new-page/index.js.map +1 -1
  4. package/build/components/app/index.js +17 -1
  5. package/build/components/app/index.js.map +1 -1
  6. package/build/components/editor/index.js +55 -69
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/editor/use-editor-title.js +39 -0
  9. package/build/components/editor/use-editor-title.js.map +1 -0
  10. package/build/components/global-styles/font-library-modal/installed-fonts.js +1 -0
  11. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  12. package/build/components/global-styles/screen-css.js +1 -1
  13. package/build/components/global-styles/screen-css.js.map +1 -1
  14. package/build/components/global-styles/screen-revisions/index.js +4 -23
  15. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  16. package/build/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
  17. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  18. package/build/components/global-styles/shadows-edit-panel.js +1 -0
  19. package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
  20. package/build/components/global-styles/variations/variation.js +11 -16
  21. package/build/components/global-styles/variations/variation.js.map +1 -1
  22. package/build/components/global-styles/variations/variations-color.js +2 -1
  23. package/build/components/global-styles/variations/variations-color.js.map +1 -1
  24. package/build/components/global-styles/variations/variations-typography.js +1 -0
  25. package/build/components/global-styles/variations/variations-typography.js.map +1 -1
  26. package/build/components/global-styles-sidebar/index.js +2 -0
  27. package/build/components/global-styles-sidebar/index.js.map +1 -1
  28. package/build/components/layout/index.js +23 -95
  29. package/build/components/layout/index.js.map +1 -1
  30. package/build/components/page/header.js +1 -0
  31. package/build/components/page/header.js.map +1 -1
  32. package/build/components/page-patterns/header.js +2 -1
  33. package/build/components/page-patterns/header.js.map +1 -1
  34. package/build/components/page-patterns/index.js +5 -5
  35. package/build/components/page-patterns/index.js.map +1 -1
  36. package/build/components/pagination/index.js +17 -8
  37. package/build/components/pagination/index.js.map +1 -1
  38. package/build/components/posts-app/index.js +50 -0
  39. package/build/components/posts-app/index.js.map +1 -0
  40. package/build/components/sidebar-dataviews/dataview-item.js +6 -2
  41. package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
  42. package/build/components/sidebar-navigation-screen/index.js +1 -1
  43. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  44. package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +1 -0
  45. package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -1
  46. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +1 -0
  47. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  48. package/build/components/sidebar-navigation-screen-patterns/category-item.js +1 -1
  49. package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
  50. package/build/components/sidebar-navigation-screen-patterns/index.js +1 -1
  51. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  52. package/build/components/site-hub/index.js +38 -128
  53. package/build/components/site-hub/index.js.map +1 -1
  54. package/build/hooks/commands/use-set-command-context.js +53 -0
  55. package/build/hooks/commands/use-set-command-context.js.map +1 -0
  56. package/build/hooks/push-changes-to-global-styles/index.js +3 -2
  57. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  58. package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +20 -88
  59. package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
  60. package/build/index.js +15 -2
  61. package/build/index.js.map +1 -1
  62. package/build/posts.js +34 -0
  63. package/build/posts.js.map +1 -0
  64. package/build/store/private-actions.js +33 -18
  65. package/build/store/private-actions.js.map +1 -1
  66. package/build-module/components/add-new-page/index.js +2 -1
  67. package/build-module/components/add-new-page/index.js.map +1 -1
  68. package/build-module/components/app/index.js +17 -1
  69. package/build-module/components/app/index.js.map +1 -1
  70. package/build-module/components/editor/index.js +55 -69
  71. package/build-module/components/editor/index.js.map +1 -1
  72. package/build-module/components/editor/use-editor-title.js +31 -0
  73. package/build-module/components/editor/use-editor-title.js.map +1 -0
  74. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +1 -0
  75. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  76. package/build-module/components/global-styles/screen-css.js +1 -1
  77. package/build-module/components/global-styles/screen-css.js.map +1 -1
  78. package/build-module/components/global-styles/screen-revisions/index.js +4 -23
  79. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  80. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
  81. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  82. package/build-module/components/global-styles/shadows-edit-panel.js +1 -0
  83. package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
  84. package/build-module/components/global-styles/variations/variation.js +11 -16
  85. package/build-module/components/global-styles/variations/variation.js.map +1 -1
  86. package/build-module/components/global-styles/variations/variations-color.js +3 -2
  87. package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
  88. package/build-module/components/global-styles/variations/variations-typography.js +1 -0
  89. package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
  90. package/build-module/components/global-styles-sidebar/index.js +2 -0
  91. package/build-module/components/global-styles-sidebar/index.js.map +1 -1
  92. package/build-module/components/layout/index.js +27 -99
  93. package/build-module/components/layout/index.js.map +1 -1
  94. package/build-module/components/page/header.js +1 -0
  95. package/build-module/components/page/header.js.map +1 -1
  96. package/build-module/components/page-patterns/header.js +2 -1
  97. package/build-module/components/page-patterns/header.js.map +1 -1
  98. package/build-module/components/page-patterns/index.js +5 -5
  99. package/build-module/components/page-patterns/index.js.map +1 -1
  100. package/build-module/components/pagination/index.js +17 -8
  101. package/build-module/components/pagination/index.js.map +1 -1
  102. package/build-module/components/posts-app/index.js +43 -0
  103. package/build-module/components/posts-app/index.js.map +1 -0
  104. package/build-module/components/sidebar-dataviews/dataview-item.js +6 -2
  105. package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
  106. package/build-module/components/sidebar-navigation-screen/index.js +1 -1
  107. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  108. package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +1 -0
  109. package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -1
  110. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +1 -0
  111. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  112. package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +2 -2
  113. package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
  114. package/build-module/components/sidebar-navigation-screen-patterns/index.js +1 -1
  115. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  116. package/build-module/components/site-hub/index.js +40 -130
  117. package/build-module/components/site-hub/index.js.map +1 -1
  118. package/build-module/hooks/commands/use-set-command-context.js +46 -0
  119. package/build-module/hooks/commands/use-set-command-context.js.map +1 -0
  120. package/build-module/hooks/push-changes-to-global-styles/index.js +3 -2
  121. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  122. package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +19 -86
  123. package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
  124. package/build-module/index.js +8 -2
  125. package/build-module/index.js.map +1 -1
  126. package/build-module/posts.js +27 -0
  127. package/build-module/posts.js.map +1 -0
  128. package/build-module/store/private-actions.js +33 -18
  129. package/build-module/store/private-actions.js.map +1 -1
  130. package/build-style/posts-rtl.css +1707 -0
  131. package/build-style/posts.css +1707 -0
  132. package/build-style/style-rtl.css +59 -104
  133. package/build-style/style.css +59 -104
  134. package/package.json +41 -41
  135. package/src/components/add-new-page/index.js +2 -1
  136. package/src/components/app/index.js +17 -1
  137. package/src/components/block-editor/style.scss +11 -0
  138. package/src/components/editor/index.js +69 -103
  139. package/src/components/editor/style.scss +1 -5
  140. package/src/components/editor/use-editor-title.js +35 -0
  141. package/src/components/global-styles/font-library-modal/installed-fonts.js +1 -0
  142. package/src/components/global-styles/screen-css.js +1 -1
  143. package/src/components/global-styles/screen-revisions/index.js +4 -24
  144. package/src/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
  145. package/src/components/global-styles/screen-revisions/style.scss +4 -8
  146. package/src/components/global-styles/shadows-edit-panel.js +1 -0
  147. package/src/components/global-styles/style.scss +1 -7
  148. package/src/components/global-styles/variations/variation.js +14 -19
  149. package/src/components/global-styles/variations/variations-color.js +12 -4
  150. package/src/components/global-styles/variations/variations-typography.js +5 -1
  151. package/src/components/global-styles-sidebar/index.js +2 -0
  152. package/src/components/global-styles-sidebar/style.scss +0 -1
  153. package/src/components/layout/index.js +41 -137
  154. package/src/components/layout/style.scss +18 -58
  155. package/src/components/page/header.js +1 -0
  156. package/src/components/page/style.scss +6 -0
  157. package/src/components/page-patterns/header.js +8 -2
  158. package/src/components/page-patterns/index.js +15 -12
  159. package/src/components/page-patterns/style.scss +6 -0
  160. package/src/components/pagination/index.js +21 -16
  161. package/src/components/posts-app/index.js +39 -0
  162. package/src/components/sidebar/style.scss +4 -4
  163. package/src/components/sidebar-dataviews/dataview-item.js +6 -2
  164. package/src/components/sidebar-navigation-screen/index.js +1 -1
  165. package/src/components/sidebar-navigation-screen/style.scss +2 -2
  166. package/src/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +1 -0
  167. package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +1 -0
  168. package/src/components/sidebar-navigation-screen-patterns/category-item.js +11 -2
  169. package/src/components/sidebar-navigation-screen-patterns/index.js +5 -1
  170. package/src/components/site-hub/index.js +55 -146
  171. package/src/components/site-hub/style.scss +1 -4
  172. package/src/components/site-icon/style.scss +0 -4
  173. package/src/hooks/commands/use-set-command-context.js +37 -0
  174. package/src/hooks/push-changes-to-global-styles/index.js +3 -2
  175. package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +1 -875
  176. package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +29 -117
  177. package/src/index.js +10 -2
  178. package/src/posts.js +29 -0
  179. package/src/posts.scss +46 -0
  180. package/src/store/private-actions.js +58 -30
  181. package/build/components/block-editor/block-inspector-button.js +0 -57
  182. package/build/components/block-editor/block-inspector-button.js.map +0 -1
  183. package/build/components/block-editor/inserter-media-categories.js +0 -183
  184. package/build/components/block-editor/inserter-media-categories.js.map +0 -1
  185. package/build/components/template-part-converter/convert-to-regular.js +0 -38
  186. package/build/components/template-part-converter/convert-to-regular.js.map +0 -1
  187. package/build/components/template-part-converter/convert-to-template-part.js +0 -84
  188. package/build/components/template-part-converter/convert-to-template-part.js.map +0 -1
  189. package/build/components/template-part-converter/index.js +0 -67
  190. package/build/components/template-part-converter/index.js.map +0 -1
  191. package/build-module/components/block-editor/block-inspector-button.js +0 -50
  192. package/build-module/components/block-editor/block-inspector-button.js.map +0 -1
  193. package/build-module/components/block-editor/inserter-media-categories.js +0 -177
  194. package/build-module/components/block-editor/inserter-media-categories.js.map +0 -1
  195. package/build-module/components/template-part-converter/convert-to-regular.js +0 -31
  196. package/build-module/components/template-part-converter/convert-to-regular.js.map +0 -1
  197. package/build-module/components/template-part-converter/convert-to-template-part.js +0 -79
  198. package/build-module/components/template-part-converter/convert-to-template-part.js.map +0 -1
  199. package/build-module/components/template-part-converter/index.js +0 -59
  200. package/build-module/components/template-part-converter/index.js.map +0 -1
  201. package/src/components/block-editor/block-inspector-button.js +0 -60
  202. package/src/components/block-editor/inserter-media-categories.js +0 -227
  203. package/src/components/template-part-converter/convert-to-regular.js +0 -32
  204. package/src/components/template-part-converter/convert-to-template-part.js +0 -78
  205. package/src/components/template-part-converter/index.js +0 -59
@@ -45,17 +45,15 @@ export function removePropertyFromObject(object, property) {
45
45
  }
46
46
 
47
47
  /**
48
- * A convenience wrapper for `useThemeStyleVariationsByProperty()` that fetches the current theme style variations,
49
- * and user-defined global style/settings object.
48
+ * Fetches the current theme style variations that contain only the specified property
49
+ * and merges them with the user config.
50
50
  *
51
- * @param {Object} props Object of hook args.
52
- * @param {string} props.property The property to filter by.
53
- * @param {Function} props.filter Optional. The filter function to apply to the variations.
51
+ * @param {Object} props Object of hook args.
52
+ * @param {string} props.property The property to filter by.
54
53
  * @return {Object[]|*} The merged object.
55
54
  */
56
55
  export function useCurrentMergeThemeStyleVariationsWithUserConfig({
57
- property,
58
- filter
56
+ property
59
57
  }) {
60
58
  const {
61
59
  variationsFromTheme
@@ -66,21 +64,21 @@ export function useCurrentMergeThemeStyleVariationsWithUserConfig({
66
64
  };
67
65
  }, []);
68
66
  const {
69
- user: baseVariation
67
+ user: userVariation
70
68
  } = useContext(GlobalStylesContext);
71
- const variations = useMemo(() => {
72
- return [{
73
- title: __('Default'),
74
- settings: {},
75
- styles: {}
76
- }, ...variationsFromTheme];
77
- }, [variationsFromTheme]);
78
- return useThemeStyleVariationsByProperty({
79
- variations,
80
- property,
81
- filter,
82
- baseVariation: removePropertyFromObject(cloneDeep(baseVariation), property)
83
- });
69
+ return useMemo(() => {
70
+ const clonedUserVariation = cloneDeep(userVariation);
71
+
72
+ // Get user variation and remove the settings for the given property.
73
+ const userVariationWithoutProperty = removePropertyFromObject(clonedUserVariation, property);
74
+ userVariationWithoutProperty.title = __('Default');
75
+ const variationsWithSinglePropertyAndBase = variationsFromTheme.filter(variation => {
76
+ return isVariationWithSingleProperty(variation, property);
77
+ }).map(variation => {
78
+ return mergeBaseAndUserConfigs(userVariationWithoutProperty, variation);
79
+ });
80
+ return [userVariationWithoutProperty, ...variationsWithSinglePropertyAndBase];
81
+ }, [property, userVariation, variationsFromTheme]);
84
82
  }
85
83
 
86
84
  /**
@@ -111,71 +109,6 @@ export const filterObjectByProperty = (object, property) => {
111
109
  return newObject;
112
110
  };
113
111
 
114
- /**
115
- * Returns a new object with only the properties specified in `property`.
116
- * Optional merges the baseVariation object with the variation object.
117
- * Note: this function will only overwrite the specified property in baseVariation if it exists.
118
- * The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.
119
- * See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.
120
- *
121
- * @param {Object} props Object of hook args.
122
- * @param {Object[]} props.variations The theme style variations to filter.
123
- * @param {string} props.property The property to filter by.
124
- * @param {Function} props.filter Optional. The filter function to apply to the variations.
125
- * @param {Object} props.baseVariation Optional. Base or user settings to be updated with variation properties.
126
- * @return {Object[]|*} The merged object.
127
- */
128
- export default function useThemeStyleVariationsByProperty({
129
- variations,
130
- property,
131
- filter,
132
- baseVariation
133
- }) {
134
- return useMemo(() => {
135
- if (!property || !variations || variations?.length === 0) {
136
- return variations;
137
- }
138
- const clonedBaseVariation = typeof baseVariation === 'object' && Object.keys(baseVariation).length > 0 ? cloneDeep(baseVariation) : null;
139
- let processedStyleVariations = variations.reduce((accumulator, variation) => {
140
- const variationFilteredByProperty = filterObjectByProperty(cloneDeep(variation), property);
141
-
142
- // Remove variations that are empty once the property is filtered out.
143
- if (variation.title !== __('Default') && Object.keys(variationFilteredByProperty).length === 0) {
144
- return accumulator;
145
- }
146
- let result = {
147
- ...variationFilteredByProperty,
148
- title: variation?.title,
149
- description: variation?.description
150
- };
151
- if (clonedBaseVariation) {
152
- /*
153
- * Overwrites all baseVariation object `styleProperty` properties
154
- * with the theme variation `styleProperty` properties.
155
- */
156
- result = mergeBaseAndUserConfigs(clonedBaseVariation, result);
157
- }
158
-
159
- // Detect if this is a duplicate variation.
160
- const isDuplicate = accumulator.some(item => {
161
- return JSON.stringify(item.styles) === JSON.stringify(result?.styles) && JSON.stringify(item.settings) === JSON.stringify(result?.settings);
162
- });
163
- if (isDuplicate) {
164
- return accumulator;
165
- }
166
-
167
- // If the variation is not a duplicate, add it to the accumulator.
168
- accumulator.push(result);
169
- return accumulator;
170
- }, [] // Initial accumulator value.
171
- );
172
- if ('function' === typeof filter) {
173
- processedStyleVariations = processedStyleVariations.filter(filter);
174
- }
175
- return processedStyleVariations;
176
- }, [variations, property, baseVariation, filter]);
177
- }
178
-
179
112
  /**
180
113
  * Compares a style variation to the same variation filtered by a single property.
181
114
  * Returns true if the variation contains only the property specified.
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","coreStore","useContext","useMemo","privateApis","blockEditorPrivateApis","editorPrivateApis","__","cloneDeep","unlock","GlobalStylesContext","mergeBaseAndUserConfigs","removePropertyFromObject","object","property","Object","keys","length","key","useCurrentMergeThemeStyleVariationsWithUserConfig","filter","variationsFromTheme","select","_variationsFromTheme","__experimentalGetCurrentThemeGlobalStylesVariations","user","baseVariation","variations","title","settings","styles","useThemeStyleVariationsByProperty","filterObjectByProperty","newObject","forEach","newFilter","clonedBaseVariation","processedStyleVariations","reduce","accumulator","variation","variationFilteredByProperty","result","description","isDuplicate","some","item","JSON","stringify","push","isVariationWithSingleProperty","variationWithProperty"],"sources":["@wordpress/edit-site/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport cloneDeep from '../../utils/clone-deep';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\nconst { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );\n\n/**\n * Removes all instances of a property from an object.\n *\n * @param {Object} object The object to remove the property from.\n * @param {string} property The property to remove.\n * @return {Object} The modified object.\n */\nexport function removePropertyFromObject( object, property ) {\n\tif ( ! property || typeof property !== 'string' ) {\n\t\treturn object;\n\t}\n\n\tif (\n\t\ttypeof object !== 'object' ||\n\t\t! object ||\n\t\t! Object.keys( object ).length\n\t) {\n\t\treturn object;\n\t}\n\n\tfor ( const key in object ) {\n\t\tif ( key === property ) {\n\t\t\tdelete object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tremovePropertyFromObject( object[ key ], property );\n\t\t}\n\t}\n\treturn object;\n}\n\n/**\n * A convenience wrapper for `useThemeStyleVariationsByProperty()` that fetches the current theme style variations,\n * and user-defined global style/settings object.\n *\n * @param {Object} props Object of hook args.\n * @param {string} props.property The property to filter by.\n * @param {Function} props.filter Optional. The filter function to apply to the variations.\n * @return {Object[]|*} The merged object.\n */\nexport function useCurrentMergeThemeStyleVariationsWithUserConfig( {\n\tproperty,\n\tfilter,\n} ) {\n\tconst { variationsFromTheme } = useSelect( ( select ) => {\n\t\tconst _variationsFromTheme =\n\t\t\tselect(\n\t\t\t\tcoreStore\n\t\t\t).__experimentalGetCurrentThemeGlobalStylesVariations();\n\n\t\treturn {\n\t\t\tvariationsFromTheme: _variationsFromTheme || [],\n\t\t};\n\t}, [] );\n\tconst { user: baseVariation } = useContext( GlobalStylesContext );\n\n\tconst variations = useMemo( () => {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttitle: __( 'Default' ),\n\t\t\t\tsettings: {},\n\t\t\t\tstyles: {},\n\t\t\t},\n\t\t\t...variationsFromTheme,\n\t\t];\n\t}, [ variationsFromTheme ] );\n\n\treturn useThemeStyleVariationsByProperty( {\n\t\tvariations,\n\t\tproperty,\n\t\tfilter,\n\t\tbaseVariation: removePropertyFromObject(\n\t\t\tcloneDeep( baseVariation ),\n\t\t\tproperty\n\t\t),\n\t} );\n}\n\n/**\n * Returns a new object, with properties specified in `property`,\n * maintain the original object tree structure.\n * The function is recursive, so it will perform a deep search for the given property.\n * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the property is `test`.\n *\n * @param {Object} object The object to filter\n * @param {Object} property The property to filter by\n * @return {Object} The merged object.\n */\nexport const filterObjectByProperty = ( object, property ) => {\n\tif ( ! object ) {\n\t\treturn {};\n\t}\n\n\tconst newObject = {};\n\tObject.keys( object ).forEach( ( key ) => {\n\t\tif ( key === property ) {\n\t\t\tnewObject[ key ] = object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tconst newFilter = filterObjectByProperty( object[ key ], property );\n\t\t\tif ( Object.keys( newFilter ).length ) {\n\t\t\t\tnewObject[ key ] = newFilter;\n\t\t\t}\n\t\t}\n\t} );\n\treturn newObject;\n};\n\n/**\n * Returns a new object with only the properties specified in `property`.\n * Optional merges the baseVariation object with the variation object.\n * Note: this function will only overwrite the specified property in baseVariation if it exists.\n * The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.\n * See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.\n *\n * @param {Object} props Object of hook args.\n * @param {Object[]} props.variations The theme style variations to filter.\n * @param {string} props.property The property to filter by.\n * @param {Function} props.filter Optional. The filter function to apply to the variations.\n * @param {Object} props.baseVariation Optional. Base or user settings to be updated with variation properties.\n * @return {Object[]|*} The merged object.\n */\nexport default function useThemeStyleVariationsByProperty( {\n\tvariations,\n\tproperty,\n\tfilter,\n\tbaseVariation,\n} ) {\n\treturn useMemo( () => {\n\t\tif ( ! property || ! variations || variations?.length === 0 ) {\n\t\t\treturn variations;\n\t\t}\n\n\t\tconst clonedBaseVariation =\n\t\t\ttypeof baseVariation === 'object' &&\n\t\t\tObject.keys( baseVariation ).length > 0\n\t\t\t\t? cloneDeep( baseVariation )\n\t\t\t\t: null;\n\n\t\tlet processedStyleVariations = variations.reduce(\n\t\t\t( accumulator, variation ) => {\n\t\t\t\tconst variationFilteredByProperty = filterObjectByProperty(\n\t\t\t\t\tcloneDeep( variation ),\n\t\t\t\t\tproperty\n\t\t\t\t);\n\n\t\t\t\t// Remove variations that are empty once the property is filtered out.\n\t\t\t\tif (\n\t\t\t\t\tvariation.title !== __( 'Default' ) &&\n\t\t\t\t\tObject.keys( variationFilteredByProperty ).length === 0\n\t\t\t\t) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\tlet result = {\n\t\t\t\t\t...variationFilteredByProperty,\n\t\t\t\t\ttitle: variation?.title,\n\t\t\t\t\tdescription: variation?.description,\n\t\t\t\t};\n\n\t\t\t\tif ( clonedBaseVariation ) {\n\t\t\t\t\t/*\n\t\t\t\t\t * Overwrites all baseVariation object `styleProperty` properties\n\t\t\t\t\t * with the theme variation `styleProperty` properties.\n\t\t\t\t\t */\n\t\t\t\t\tresult = mergeBaseAndUserConfigs(\n\t\t\t\t\t\tclonedBaseVariation,\n\t\t\t\t\t\tresult\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Detect if this is a duplicate variation.\n\t\t\t\tconst isDuplicate = accumulator.some( ( item ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tJSON.stringify( item.styles ) ===\n\t\t\t\t\t\t\tJSON.stringify( result?.styles ) &&\n\t\t\t\t\t\tJSON.stringify( item.settings ) ===\n\t\t\t\t\t\t\tJSON.stringify( result?.settings )\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t\tif ( isDuplicate ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\t// If the variation is not a duplicate, add it to the accumulator.\n\t\t\t\taccumulator.push( result );\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t[] // Initial accumulator value.\n\t\t);\n\n\t\tif ( 'function' === typeof filter ) {\n\t\t\tprocessedStyleVariations =\n\t\t\t\tprocessedStyleVariations.filter( filter );\n\t\t}\n\n\t\treturn processedStyleVariations;\n\t}, [ variations, property, baseVariation, filter ] );\n}\n\n/**\n * Compares a style variation to the same variation filtered by a single property.\n * Returns true if the variation contains only the property specified.\n *\n * @param {Object} variation The variation to compare.\n * @param {string} property The property to compare.\n * @return {boolean} Whether the variation contains only a single property.\n */\nexport function isVariationWithSingleProperty( variation, property ) {\n\tconst variationWithProperty = filterObjectByProperty(\n\t\tcloneDeep( variation ),\n\t\tproperty\n\t);\n\n\treturn (\n\t\tJSON.stringify( variationWithProperty?.styles ) ===\n\t\t\tJSON.stringify( variation?.styles ) &&\n\t\tJSON.stringify( variationWithProperty?.settings ) ===\n\t\t\tJSON.stringify( variation?.settings )\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,UAAU,EAAEC,OAAO,QAAQ,oBAAoB;AACxD,SAASC,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASD,WAAW,IAAIE,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,SAAS,MAAM,wBAAwB;AAC9C,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EAAEC;AAAoB,CAAC,GAAGD,MAAM,CAAEJ,sBAAuB,CAAC;AAChE,MAAM;EAAEM;AAAwB,CAAC,GAAGF,MAAM,CAAEH,iBAAkB,CAAC;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,wBAAwBA,CAAEC,MAAM,EAAEC,QAAQ,EAAG;EAC5D,IAAK,CAAEA,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAG;IACjD,OAAOD,MAAM;EACd;EAEA,IACC,OAAOA,MAAM,KAAK,QAAQ,IAC1B,CAAEA,MAAM,IACR,CAAEE,MAAM,CAACC,IAAI,CAAEH,MAAO,CAAC,CAACI,MAAM,EAC7B;IACD,OAAOJ,MAAM;EACd;EAEA,KAAM,MAAMK,GAAG,IAAIL,MAAM,EAAG;IAC3B,IAAKK,GAAG,KAAKJ,QAAQ,EAAG;MACvB,OAAOD,MAAM,CAAEK,GAAG,CAAE;IACrB,CAAC,MAAM,IAAK,OAAOL,MAAM,CAAEK,GAAG,CAA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AEgC,SAAU,CAAC,EACtB1B,QACD,CAAC;EAED,OACCiC,IAAI,CAACC,SAAS,CAAEG,qBAAqB,EAAErB,MAAO,CAAC,KAC9CiB,IAAI,CAACC,SAAS,CAAER,SAAS,EAAEV,MAAO,CAAC,IACpCiB,IAAI,CAACC,SAAS,CAAEG,qBAAqB,EAAEtB,QAAS,CAAC,KAChDkB,IAAI,CAACC,SAAS,CAAER,SAAS,EAAEX,QAAS,CAAC;AAExC","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","store","coreStore","useContext","useMemo","privateApis","blockEditorPrivateApis","editorPrivateApis","__","cloneDeep","unlock","GlobalStylesContext","mergeBaseAndUserConfigs","removePropertyFromObject","object","property","Object","keys","length","key","useCurrentMergeThemeStyleVariationsWithUserConfig","variationsFromTheme","select","_variationsFromTheme","__experimentalGetCurrentThemeGlobalStylesVariations","user","userVariation","clonedUserVariation","userVariationWithoutProperty","title","variationsWithSinglePropertyAndBase","filter","variation","isVariationWithSingleProperty","map","filterObjectByProperty","newObject","forEach","newFilter","variationWithProperty","JSON","stringify","styles","settings"],"sources":["@wordpress/edit-site/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport cloneDeep from '../../utils/clone-deep';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\nconst { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );\n\n/**\n * Removes all instances of a property from an object.\n *\n * @param {Object} object The object to remove the property from.\n * @param {string} property The property to remove.\n * @return {Object} The modified object.\n */\nexport function removePropertyFromObject( object, property ) {\n\tif ( ! property || typeof property !== 'string' ) {\n\t\treturn object;\n\t}\n\n\tif (\n\t\ttypeof object !== 'object' ||\n\t\t! object ||\n\t\t! Object.keys( object ).length\n\t) {\n\t\treturn object;\n\t}\n\n\tfor ( const key in object ) {\n\t\tif ( key === property ) {\n\t\t\tdelete object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tremovePropertyFromObject( object[ key ], property );\n\t\t}\n\t}\n\treturn object;\n}\n\n/**\n * Fetches the current theme style variations that contain only the specified property\n * and merges them with the user config.\n *\n * @param {Object} props Object of hook args.\n * @param {string} props.property The property to filter by.\n * @return {Object[]|*} The merged object.\n */\nexport function useCurrentMergeThemeStyleVariationsWithUserConfig( {\n\tproperty,\n} ) {\n\tconst { variationsFromTheme } = useSelect( ( select ) => {\n\t\tconst _variationsFromTheme =\n\t\t\tselect(\n\t\t\t\tcoreStore\n\t\t\t).__experimentalGetCurrentThemeGlobalStylesVariations();\n\n\t\treturn {\n\t\t\tvariationsFromTheme: _variationsFromTheme || [],\n\t\t};\n\t}, [] );\n\tconst { user: userVariation } = useContext( GlobalStylesContext );\n\n\treturn useMemo( () => {\n\t\tconst clonedUserVariation = cloneDeep( userVariation );\n\n\t\t// Get user variation and remove the settings for the given property.\n\t\tconst userVariationWithoutProperty = removePropertyFromObject(\n\t\t\tclonedUserVariation,\n\t\t\tproperty\n\t\t);\n\t\tuserVariationWithoutProperty.title = __( 'Default' );\n\n\t\tconst variationsWithSinglePropertyAndBase = variationsFromTheme\n\t\t\t.filter( ( variation ) => {\n\t\t\t\treturn isVariationWithSingleProperty( variation, property );\n\t\t\t} )\n\t\t\t.map( ( variation ) => {\n\t\t\t\treturn mergeBaseAndUserConfigs(\n\t\t\t\t\tuserVariationWithoutProperty,\n\t\t\t\t\tvariation\n\t\t\t\t);\n\t\t\t} );\n\n\t\treturn [\n\t\t\tuserVariationWithoutProperty,\n\t\t\t...variationsWithSinglePropertyAndBase,\n\t\t];\n\t}, [ property, userVariation, variationsFromTheme ] );\n}\n\n/**\n * Returns a new object, with properties specified in `property`,\n * maintain the original object tree structure.\n * The function is recursive, so it will perform a deep search for the given property.\n * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the property is `test`.\n *\n * @param {Object} object The object to filter\n * @param {Object} property The property to filter by\n * @return {Object} The merged object.\n */\nexport const filterObjectByProperty = ( object, property ) => {\n\tif ( ! object ) {\n\t\treturn {};\n\t}\n\n\tconst newObject = {};\n\tObject.keys( object ).forEach( ( key ) => {\n\t\tif ( key === property ) {\n\t\t\tnewObject[ key ] = object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tconst newFilter = filterObjectByProperty( object[ key ], property );\n\t\t\tif ( Object.keys( newFilter ).length ) {\n\t\t\t\tnewObject[ key ] = newFilter;\n\t\t\t}\n\t\t}\n\t} );\n\treturn newObject;\n};\n\n/**\n * Compares a style variation to the same variation filtered by a single property.\n * Returns true if the variation contains only the property specified.\n *\n * @param {Object} variation The variation to compare.\n * @param {string} property The property to compare.\n * @return {boolean} Whether the variation contains only a single property.\n */\nexport function isVariationWithSingleProperty( variation, property ) {\n\tconst variationWithProperty = filterObjectByProperty(\n\t\tcloneDeep( variation ),\n\t\tproperty\n\t);\n\n\treturn (\n\t\tJSON.stringify( variationWithProperty?.styles ) ===\n\t\t\tJSON.stringify( variation?.styles ) &&\n\t\tJSON.stringify( variationWithProperty?.settings ) ===\n\t\t\tJSON.stringify( variation?.settings )\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,UAAU,EAAEC,OAAO,QAAQ,oBAAoB;AACxD,SAASC,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASD,WAAW,IAAIE,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,SAAS,MAAM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AAEqB,SAAU,CAAC,CAACpB,MAAM,EAAG;QACtCkB,SAAS,CAAEjB,GAAG,CAAE,GAAGmB,SAAS;MAC7B;IACD;EACD,CAAE,CAAC;EACH,OAAOF,SAAS;AACjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASH,6BAA6BA,CAAED,SAAS,EAAEjB,QAAQ,EAAG;EACpE,MAAMwB,qBAAqB,GAAGJ,sBAAsB,CACnD1B,SAAS,CAAEuB,SAAU,CAAC,EACtBjB,QACD,CAAC;EAED,OACCyB,IAAI,CAACC,SAAS,CAAEF,qBAAqB,EAAEG,MAAO,CAAC,KAC9CF,IAAI,CAACC,SAAS,CAAET,SAAS,EAAEU,MAAO,CAAC,IACpCF,IAAI,CAACC,SAAS,CAAEF,qBAAqB,EAAEI,QAAS,CAAC,KAChDH,IAAI,CAACC,SAAS,CAAET,SAAS,EAAEW,QAAS,CAAC;AAExC","ignoreList":[]}
@@ -5,7 +5,7 @@ import { store as blocksStore } from '@wordpress/blocks';
5
5
  import { registerCoreBlocks, __experimentalGetCoreBlocks, __experimentalRegisterExperimentalCoreBlocks } from '@wordpress/block-library';
6
6
  import { dispatch } from '@wordpress/data';
7
7
  import deprecated from '@wordpress/deprecated';
8
- import { createRoot } from '@wordpress/element';
8
+ import { createRoot, StrictMode } from '@wordpress/element';
9
9
  import { store as editorStore } from '@wordpress/editor';
10
10
  import { store as preferencesStore } from '@wordpress/preferences';
11
11
  import { registerLegacyWidgetBlock, registerWidgetGroupBlock } from '@wordpress/widgets';
@@ -79,7 +79,9 @@ export function initializeEditor(id, settings) {
79
79
  // Prevent the default browser action for files dropped outside of dropzones.
80
80
  window.addEventListener('dragover', e => e.preventDefault(), false);
81
81
  window.addEventListener('drop', e => e.preventDefault(), false);
82
- root.render( /*#__PURE__*/_jsx(App, {}));
82
+ root.render( /*#__PURE__*/_jsx(StrictMode, {
83
+ children: /*#__PURE__*/_jsx(App, {})
84
+ }));
83
85
  return root;
84
86
  }
85
87
  export function reinitializeEditor() {
@@ -91,4 +93,8 @@ export function reinitializeEditor() {
91
93
  export { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';
92
94
  export { store } from './store';
93
95
  export * from './deprecated';
96
+
97
+ // Temporary: While the posts dashboard is being iterated on
98
+ // it's being built in the same package as the site editor.
99
+ export { initializePostsDashboard } from './posts';
94
100
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["store","blocksStore","registerCoreBlocks","__experimentalGetCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","dispatch","deprecated","createRoot","editorStore","preferencesStore","registerLegacyWidgetBlock","registerWidgetGroupBlock","editSiteStore","App","jsx","_jsx","initializeEditor","id","settings","target","document","getElementById","root","reapplyBlockTypeFilters","coreBlocks","filter","name","setFreeformFallbackBlockName","inserter","globalThis","IS_GUTENBERG_PLUGIN","enableFSEBlocks","setDefaults","welcomeGuide","welcomeGuideStyles","welcomeGuidePage","welcomeGuideTemplate","allowRightClickOverrides","distractionFree","editorMode","fixedToolbar","focusMode","inactivePanels","keepCaretInsideBlock","openPanels","showBlockBreadcrumbs","showListViewByDefault","updateSettings","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","reinitializeEditor","since","version","default","PluginTemplateSettingPanel"],"sources":["@wordpress/edit-site/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport App from './components/app';\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter(\n\t\t( { name } ) => name !== 'core/freeform'\n\t);\n\tregisterCoreBlocks( coreBlocks );\n\tdispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t\twelcomeGuidePage: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\tdistractionFree: false,\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfocusMode: false,\n\t\tinactivePanels: [],\n\t\tkeepCaretInsideBlock: false,\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowListViewByDefault: false,\n\t} );\n\n\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tdispatch( editorStore ).updateEditorSettings( {\n\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t} );\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render( <App /> );\n\n\treturn root;\n}\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editSite.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';\nexport { store } from './store';\nexport * from './deprecated';\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SACCC,kBAAkB,EAClBC,2BAA2B,EAC3BC,4CAA4C,QACtC,0BAA0B;AACjC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASP,KAAK,IAAIQ,WAAW,QAAQ,mBAAmB;AACxD,SAASR,KAAK,IAAIS,gBAAgB,QAAQ,wBAAwB;AAClE,SACCC,yBAAyB,EACzBC,wBAAwB,QAClB,oBAAoB;;AAE3B;AACA;AACA;AACA,OAAO,SAAS;AAChB,SAASX,KAAK,IAAIY,aAAa,QAAQ,SAAS;AAChD,OAAOC,GAAG,MAAM,kBAAkB;;AAElC;AACA;AACA;AACA;AACA;AACA;AALA,SAAAC,GAAA,IAAAC,IAAA;AAMA,OAAO,SAASC,gBAAgBA,CAAEC,EAAE,EAAEC,QAAQ,EAAG;EAChD,MAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAc,CAAEJ,EAAG,CAAC;EAC5C,MAAMK,IAAI,GAAGf,UAAU,CAAEY,MAAO,CAAC;EAEjCd,QAAQ,CAAEJ,WAAY,CAAC,CAACsB,uBAAuB,CAAC,CAAC;EACjD,MAAMC,UAAU,GAAGrB,2BAA2B,CAAC,C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,CAAC;;EAEH;EACAC,MAAM,CAACC,gBAAgB,CAAE,UAAU,EAAIC,CAAC,IAAMA,CAAC,CAACC,cAAc,CAAC,CAAC,EAAE,KAAM,CAAC;EACzEH,MAAM,CAACC,gBAAgB,CAAE,MAAM,EAAIC,CAAC,IAAMA,CAAC,CAACC,cAAc,CAAC,CAAC,EAAE,KAAM,CAAC;EAErEhC,IAAI,CAACiC,MAAM,eAAExC,IAAA,CAACF,GAAG,IAAE,CAAE,CAAC;EAEtB,OAAOS,IAAI;AACZ;AAEA,OAAO,SAASkC,kBAAkBA,CAAA,EAAG;EACpClD,UAAU,CAAE,gCAAgC,EAAE;IAC7CmD,KAAK,EAAE,KAAK;IACZC,OAAO,EAAE;EACV,CAAE,CAAC;AACJ;AAEA,SAASC,OAAO,IAAIC,0BAA0B,QAAQ,4CAA4C;AAClG,SAAS5D,KAAK,QAAQ,SAAS;AAC/B,cAAc,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["store","blocksStore","registerCoreBlocks","__experimentalGetCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","dispatch","deprecated","createRoot","StrictMode","editorStore","preferencesStore","registerLegacyWidgetBlock","registerWidgetGroupBlock","editSiteStore","App","jsx","_jsx","initializeEditor","id","settings","target","document","getElementById","root","reapplyBlockTypeFilters","coreBlocks","filter","name","setFreeformFallbackBlockName","inserter","globalThis","IS_GUTENBERG_PLUGIN","enableFSEBlocks","setDefaults","welcomeGuide","welcomeGuideStyles","welcomeGuidePage","welcomeGuideTemplate","allowRightClickOverrides","distractionFree","editorMode","fixedToolbar","focusMode","inactivePanels","keepCaretInsideBlock","openPanels","showBlockBreadcrumbs","showListViewByDefault","updateSettings","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","children","reinitializeEditor","since","version","default","PluginTemplateSettingPanel","initializePostsDashboard"],"sources":["@wordpress/edit-site/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport App from './components/app';\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter(\n\t\t( { name } ) => name !== 'core/freeform'\n\t);\n\tregisterCoreBlocks( coreBlocks );\n\tdispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t\twelcomeGuidePage: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\tdistractionFree: false,\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfocusMode: false,\n\t\tinactivePanels: [],\n\t\tkeepCaretInsideBlock: false,\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowListViewByDefault: false,\n\t} );\n\n\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tdispatch( editorStore ).updateEditorSettings( {\n\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t} );\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render(\n\t\t<StrictMode>\n\t\t\t<App />\n\t\t</StrictMode>\n\t);\n\n\treturn root;\n}\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editSite.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';\nexport { store } from './store';\nexport * from './deprecated';\n\n// Temporary: While the posts dashboard is being iterated on\n// it's being built in the same package as the site editor.\nexport { initializePostsDashboard } from './posts';\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SACCC,kBAAkB,EAClBC,2BAA2B,EAC3BC,4CAA4C,QACtC,0BAA0B;AACjC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SAASC,UAAU,EAAEC,UAAU,QAAQ,oBAAoB;AAC3D,SAASR,KAAK,IAAIS,WAAW,QAAQ,mBAAmB;AACxD,SAAST,KAAK,IAAIU,gBAAgB,QAAQ,wBAAwB;AAClE,SACCC,yBAAyB,EACzBC,wBAAwB,QAClB,o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ordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import PostsApp from './components/posts-app';
10
+
11
+ /**
12
+ * Initializes the "Posts Dashboard"
13
+ * @param {string} id DOM element id.
14
+ */
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ export function initializePostsDashboard(id) {
17
+ if (!globalThis.IS_GUTENBERG_PLUGIN) {
18
+ return;
19
+ }
20
+ const target = document.getElementById(id);
21
+ const root = createRoot(target);
22
+ root.render( /*#__PURE__*/_jsx(StrictMode, {
23
+ children: /*#__PURE__*/_jsx(PostsApp, {})
24
+ }));
25
+ return root;
26
+ }
27
+ //# sourceMappingURL=posts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createRoot","StrictMode","PostsApp","jsx","_jsx","initializePostsDashboard","id","globalThis","IS_GUTENBERG_PLUGIN","target","document","getElementById","root","render","children"],"sources":["@wordpress/edit-site/src/posts.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRoot, StrictMode } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport PostsApp from './components/posts-app';\n\n/**\n * Initializes the \"Posts Dashboard\"\n * @param {string} id DOM element id.\n */\nexport function initializePostsDashboard( id ) {\n\tif ( ! globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\treturn;\n\t}\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\troot.render(\n\t\t<StrictMode>\n\t\t\t<PostsApp />\n\t\t</StrictMode>\n\t);\n\n\treturn root;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,UAAU,QAAQ,oBAAoB;;AAE3D;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,wBAAwB;;AAE7C;AACA;AACA;AACA;AAHA,SAAAC,GAAA,IAAAC,IAAA;AAIA,OAAO,SAASC,wBAAwBA,CAAEC,EAAE,EAAG;EAC9C,IAAK,CAAEC,UAAU,CAACC,mBAAmB,EAAG;IACvC;EACD;EACA,MAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAc,CAAEL,EAAG,CAAC;EAC5C,MAAMM,IAAI,GAAGZ,UAAU,CAAES,MAAO,CAAC;EAEjCG,IAAI,CAACC,MAAM,eACVT,IAAA,CAACH,UAAU;IAAAa,QAAA,eACVV,IAAA,CAACF,QAAQ,IAAE;EAAC,CACD,CACb,CAAC;EAED,OAAOU,IAAI;AACZ","ignoreList":[]}
@@ -14,27 +14,42 @@ export const setCanvasMode = mode => ({
14
14
  registry,
15
15
  dispatch
16
16
  }) => {
17
- const isMediumOrBigger = window.matchMedia('(min-width: 782px)').matches;
18
- registry.dispatch(blockEditorStore).__unstableSetEditorMode('edit');
19
- const isPublishSidebarOpened = registry.select(editorStore).isPublishSidebarOpened();
20
- dispatch({
21
- type: 'SET_CANVAS_MODE',
22
- mode
23
- });
24
- const isEditMode = mode === 'edit';
25
- if (isPublishSidebarOpened && !isEditMode) {
26
- registry.dispatch(editorStore).closePublishSidebar();
27
- }
17
+ const switchCanvasMode = () => {
18
+ registry.batch(() => {
19
+ const isMediumOrBigger = window.matchMedia('(min-width: 782px)').matches;
20
+ registry.dispatch(blockEditorStore).clearSelectedBlock();
21
+ registry.dispatch(editorStore).setDeviceType('Desktop');
22
+ registry.dispatch(blockEditorStore).__unstableSetEditorMode('edit');
23
+ const isPublishSidebarOpened = registry.select(editorStore).isPublishSidebarOpened();
24
+ dispatch({
25
+ type: 'SET_CANVAS_MODE',
26
+ mode
27
+ });
28
+ const isEditMode = mode === 'edit';
29
+ if (isPublishSidebarOpened && !isEditMode) {
30
+ registry.dispatch(editorStore).closePublishSidebar();
31
+ }
28
32
 
29
- // Check if the block list view should be open by default.
30
- // If `distractionFree` mode is enabled, the block list view should not be open.
31
- // This behavior is disabled for small viewports.
32
- if (isMediumOrBigger && isEditMode && registry.select(preferencesStore).get('core', 'showListViewByDefault') && !registry.select(preferencesStore).get('core', 'distractionFree')) {
33
- registry.dispatch(editorStore).setIsListViewOpened(true);
33
+ // Check if the block list view should be open by default.
34
+ // If `distractionFree` mode is enabled, the block list view should not be open.
35
+ // This behavior is disabled for small viewports.
36
+ if (isMediumOrBigger && isEditMode && registry.select(preferencesStore).get('core', 'showListViewByDefault') && !registry.select(preferencesStore).get('core', 'distractionFree')) {
37
+ registry.dispatch(editorStore).setIsListViewOpened(true);
38
+ } else {
39
+ registry.dispatch(editorStore).setIsListViewOpened(false);
40
+ }
41
+ registry.dispatch(editorStore).setIsInserterOpened(false);
42
+ });
43
+ };
44
+ if (!document.startViewTransition) {
45
+ switchCanvasMode();
34
46
  } else {
35
- registry.dispatch(editorStore).setIsListViewOpened(false);
47
+ document.documentElement.classList.add(`canvas-mode-${mode}-transition`);
48
+ const transition = document.startViewTransition(() => switchCanvasMode());
49
+ transition.finished.finally(() => {
50
+ document.documentElement.classList.remove(`canvas-mode-${mode}-transition`);
51
+ });
36
52
  }
37
- registry.dispatch(editorStore).setIsInserterOpened(false);
38
53
  };
39
54
 
40
55
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["store","blockEditorStore","preferencesStore","editorStore","setCanvasMode","mode","registry","dispatch","isMediumOrBigger","window","matchMedia","matches","__unstableSetEditorMode","isPublishSidebarOpened","select","type","isEditMode","closePublishSidebar","get","setIsListViewOpened","setIsInserterOpened","setEditorCanvasContainerView","view"],"sources":["@wordpress/edit-site/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Action that switches the canvas mode.\n *\n * @param {?string} mode Canvas mode.\n */\nexport const setCanvasMode =\n\t( mode ) =>\n\t( { registry, dispatch } ) => {\n\t\tconst isMediumOrBigger =\n\t\t\twindow.matchMedia( '(min-width: 782px)' ).matches;\n\t\tregistry.dispatch( blockEditorStore ).__unstableSetEditorMode( 'edit' );\n\t\tconst isPublishSidebarOpened = registry\n\t\t\t.select( editorStore )\n\t\t\t.isPublishSidebarOpened();\n\t\tdispatch( {\n\t\t\ttype: 'SET_CANVAS_MODE',\n\t\t\tmode,\n\t\t} );\n\t\tconst isEditMode = mode === 'edit';\n\t\tif ( isPublishSidebarOpened && ! isEditMode ) {\n\t\t\tregistry.dispatch( editorStore ).closePublishSidebar();\n\t\t}\n\n\t\t// Check if the block list view should be open by default.\n\t\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t\t// This behavior is disabled for small viewports.\n\t\tif (\n\t\t\tisMediumOrBigger &&\n\t\t\tisEditMode &&\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'showListViewByDefault' ) &&\n\t\t\t! registry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'distractionFree' )\n\t\t) {\n\t\t\tregistry.dispatch( editorStore ).setIsListViewOpened( true );\n\t\t} else {\n\t\t\tregistry.dispatch( editorStore ).setIsListViewOpened( false );\n\t\t}\n\t\tregistry.dispatch( editorStore ).setIsInserterOpened( false );\n\t};\n\n/**\n * Action that switches the editor canvas container view.\n *\n * @param {?string} view Editor canvas container view.\n */\nexport const setEditorCanvasContainerView =\n\t( view ) =>\n\t( { dispatch } ) => {\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITOR_CANVAS_CONTAINER_VIEW',\n\t\t\tview,\n\t\t} );\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,wBAAwB;AAClE,SAASF,KAAK,IAAIG,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GACvBC,IAAI,IACN,CAAE;EAAEC,QAAQ;EAAEC;AAAS,CAAC,KAAM;EAC7B,MAAMC,gBAAgB,GACrBC,MAAM,CAACC,UAAU,CAAE,oBAAqB,CAAC,CAACC,OAAO;EAClDL,QAAQ,CAACC,QAAQ,CAAEN,gBAAiB,CAAC,CAACW,uBAAuB,CAAE,MAAO,CAAC;EACvE,MAAMC,sBAAsB,GAAGP,QAAQ,CACrCQ,MAAM,CAAEX,WAAY,CAAC,CACrBU,sBAAsB,CAAC,CAAC;EAC1BN,QAAQ,CAAE;IACTQ,IAAI,EAAE,iBAAiB;IACvBV;EACD,CAAE,CAAC;EACH,MAAMW,UAAU,GAAGX,IAAI,KAAK,MAAM;EAClC,IAAKQ,sBAAsB,IAAI,CAAEG,UAAU,EAAG;IAC7CV,QAAQ,CAACC,QAAQ,CAAEJ,WAAY,CAAC,CAACc,mBAAmB,CAAC,CAAC;EACvD;;EAEA;EACA;EACA;EACA,IACCT,gBAAgB,IAChBQ,UAAU,IACVV,QAAQ,CACNQ,MAAM,CAAEZ,gBAAiB,CAAC,CAC1BgB,GAAG,CAAE,MAAM,EAAE,uBAAwB,CAAC,IACxC,CAAEZ,QAAQ,CACRQ,MAAM,CAAEZ,gBAAiB,CAAC,CAC1BgB,GAAG,CAAE,MAAM,EAAE,iBAAkB,CAAC,EACjC;IACDZ,QAAQ,CAACC,QAAQ,CAAEJ,WAAY,CAAC,CAACgB,mBAAmB,CAAE,IAAK,CAAC;EAC7D,CAAC,MAAM;IACNb,QAAQ,CAACC,QAAQ,CAAEJ,WAAY,CAAC,CAACgB,mBAAmB,CAAE,KAAM,CAAC;EAC9D;EACAb,QAAQ,CAACC,QAAQ,CAAEJ,WAAY,CAAC,CAACiB,mBAAmB,CAAE,KAAM,CAAC;AAC9D,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,4BAA4B,GACtCC,IAAI,IACN,CAAE;EAAEf;AAAS,CAAC,KAAM;EACnBA,QAAQ,CAAE;IACTQ,IAAI,EAAE,kCAAkC;IACxCO;EACD,CAAE,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["store","blockEditorStore","preferencesStore","editorStore","setCanvasMode","mode","registry","dispatch","switchCanvasMode","batch","isMediumOrBigger","window","matchMedia","matches","clearSelectedBlock","setDeviceType","__unstableSetEditorMode","isPublishSidebarOpened","select","type","isEditMode","closePublishSidebar","get","setIsListViewOpened","setIsInserterOpened","document","startViewTransition","documentElement","classList","add","transition","finished","finally","remove","setEditorCanvasContainerView","view"],"sources":["@wordpress/edit-site/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Action that switches the canvas mode.\n *\n * @param {?string} mode Canvas mode.\n */\nexport const setCanvasMode =\n\t( mode ) =>\n\t( { registry, dispatch } ) => {\n\t\tconst switchCanvasMode = () => {\n\t\t\tregistry.batch( () => {\n\t\t\t\tconst isMediumOrBigger =\n\t\t\t\t\twindow.matchMedia( '(min-width: 782px)' ).matches;\n\t\t\t\tregistry.dispatch( blockEditorStore ).clearSelectedBlock();\n\t\t\t\tregistry.dispatch( editorStore ).setDeviceType( 'Desktop' );\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t\t.__unstableSetEditorMode( 'edit' );\n\t\t\t\tconst isPublishSidebarOpened = registry\n\t\t\t\t\t.select( editorStore )\n\t\t\t\t\t.isPublishSidebarOpened();\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: 'SET_CANVAS_MODE',\n\t\t\t\t\tmode,\n\t\t\t\t} );\n\t\t\t\tconst isEditMode = mode === 'edit';\n\t\t\t\tif ( isPublishSidebarOpened && ! isEditMode ) {\n\t\t\t\t\tregistry.dispatch( editorStore ).closePublishSidebar();\n\t\t\t\t}\n\n\t\t\t\t// Check if the block list view should be open by default.\n\t\t\t\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t\t\t\t// This behavior is disabled for small viewports.\n\t\t\t\tif (\n\t\t\t\t\tisMediumOrBigger &&\n\t\t\t\t\tisEditMode &&\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.select( preferencesStore )\n\t\t\t\t\t\t.get( 'core', 'showListViewByDefault' ) &&\n\t\t\t\t\t! registry\n\t\t\t\t\t\t.select( preferencesStore )\n\t\t\t\t\t\t.get( 'core', 'distractionFree' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( editorStore )\n\t\t\t\t\t\t.setIsListViewOpened( true );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( editorStore )\n\t\t\t\t\t\t.setIsListViewOpened( false );\n\t\t\t\t}\n\t\t\t\tregistry.dispatch( editorStore ).setIsInserterOpened( false );\n\t\t\t} );\n\t\t};\n\n\t\tif ( ! document.startViewTransition ) {\n\t\t\tswitchCanvasMode();\n\t\t} else {\n\t\t\tdocument.documentElement.classList.add(\n\t\t\t\t`canvas-mode-${ mode }-transition`\n\t\t\t);\n\t\t\tconst transition = document.startViewTransition( () =>\n\t\t\t\tswitchCanvasMode()\n\t\t\t);\n\t\t\ttransition.finished.finally( () => {\n\t\t\t\tdocument.documentElement.classList.remove(\n\t\t\t\t\t`canvas-mode-${ mode }-transition`\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\t};\n\n/**\n * Action that switches the editor canvas container view.\n *\n * @param {?string} view Editor canvas container view.\n */\nexport const setEditorCanvasContainerView =\n\t( view ) =>\n\t( { dispatch } ) => {\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITOR_CANVAS_CONTAINER_VIEW',\n\t\t\tview,\n\t\t} );\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,wBAAwB;AAClE,SAASF,KAAK,IAAIG,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GACvBC,IAAI,IACN,CAAE;EAAEC,QAAQ;EAAEC;AAAS,CAAC,KAAM;EAC7B,MAAMC,gBAAgB,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