@wordpress/edit-site 6.0.2 → 6.0.4
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/build/components/add-new-page/index.js +7 -1
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +30 -16
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/page-pages/index.js +38 -6
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/index.js +8 -2
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-templates/index.js +10 -3
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +4 -4
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +20 -88
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/components/add-new-page/index.js +8 -2
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +30 -16
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/page-pages/index.js +38 -6
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/index.js +8 -2
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +10 -3
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +5 -5
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +19 -86
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-style/style-rtl.css +13 -12
- package/build-style/style.css +13 -12
- package/package.json +17 -17
- package/src/components/add-new-page/index.js +14 -1
- package/src/components/add-new-pattern/index.js +37 -23
- package/src/components/block-editor/style.scss +0 -11
- package/src/components/page-pages/index.js +45 -11
- package/src/components/page-patterns/index.js +8 -2
- package/src/components/page-templates/index.js +9 -2
- package/src/components/sidebar-dataviews/default-views.js +13 -5
- package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +1 -875
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +29 -117
- package/src/style.scss +13 -0
|
@@ -48,17 +48,15 @@ export function removePropertyFromObject( object, property ) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
* and
|
|
51
|
+
* Fetches the current theme style variations that contain only the specified property
|
|
52
|
+
* and merges them with the user config.
|
|
53
53
|
*
|
|
54
|
-
* @param {Object}
|
|
55
|
-
* @param {string}
|
|
56
|
-
* @param {Function} props.filter Optional. The filter function to apply to the variations.
|
|
54
|
+
* @param {Object} props Object of hook args.
|
|
55
|
+
* @param {string} props.property The property to filter by.
|
|
57
56
|
* @return {Object[]|*} The merged object.
|
|
58
57
|
*/
|
|
59
58
|
export function useCurrentMergeThemeStyleVariationsWithUserConfig( {
|
|
60
59
|
property,
|
|
61
|
-
filter,
|
|
62
60
|
} ) {
|
|
63
61
|
const { variationsFromTheme } = useSelect( ( select ) => {
|
|
64
62
|
const _variationsFromTheme =
|
|
@@ -70,28 +68,34 @@ export function useCurrentMergeThemeStyleVariationsWithUserConfig( {
|
|
|
70
68
|
variationsFromTheme: _variationsFromTheme || [],
|
|
71
69
|
};
|
|
72
70
|
}, [] );
|
|
73
|
-
const { user:
|
|
71
|
+
const { user: userVariation } = useContext( GlobalStylesContext );
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
title: __( 'Default' ),
|
|
79
|
-
settings: {},
|
|
80
|
-
styles: {},
|
|
81
|
-
},
|
|
82
|
-
...variationsFromTheme,
|
|
83
|
-
];
|
|
84
|
-
}, [ variationsFromTheme ] );
|
|
73
|
+
return useMemo( () => {
|
|
74
|
+
const clonedUserVariation = cloneDeep( userVariation );
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
filter,
|
|
90
|
-
baseVariation: removePropertyFromObject(
|
|
91
|
-
cloneDeep( baseVariation ),
|
|
76
|
+
// Get user variation and remove the settings for the given property.
|
|
77
|
+
const userVariationWithoutProperty = removePropertyFromObject(
|
|
78
|
+
clonedUserVariation,
|
|
92
79
|
property
|
|
93
|
-
)
|
|
94
|
-
|
|
80
|
+
);
|
|
81
|
+
userVariationWithoutProperty.title = __( 'Default' );
|
|
82
|
+
|
|
83
|
+
const variationsWithSinglePropertyAndBase = variationsFromTheme
|
|
84
|
+
.filter( ( variation ) => {
|
|
85
|
+
return isVariationWithSingleProperty( variation, property );
|
|
86
|
+
} )
|
|
87
|
+
.map( ( variation ) => {
|
|
88
|
+
return mergeBaseAndUserConfigs(
|
|
89
|
+
userVariationWithoutProperty,
|
|
90
|
+
variation
|
|
91
|
+
);
|
|
92
|
+
} );
|
|
93
|
+
|
|
94
|
+
return [
|
|
95
|
+
userVariationWithoutProperty,
|
|
96
|
+
...variationsWithSinglePropertyAndBase,
|
|
97
|
+
];
|
|
98
|
+
}, [ property, userVariation, variationsFromTheme ] );
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
/**
|
|
@@ -123,98 +127,6 @@ export const filterObjectByProperty = ( object, property ) => {
|
|
|
123
127
|
return newObject;
|
|
124
128
|
};
|
|
125
129
|
|
|
126
|
-
/**
|
|
127
|
-
* Returns a new object with only the properties specified in `property`.
|
|
128
|
-
* Optional merges the baseVariation object with the variation object.
|
|
129
|
-
* Note: this function will only overwrite the specified property in baseVariation if it exists.
|
|
130
|
-
* The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.
|
|
131
|
-
* See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.
|
|
132
|
-
*
|
|
133
|
-
* @param {Object} props Object of hook args.
|
|
134
|
-
* @param {Object[]} props.variations The theme style variations to filter.
|
|
135
|
-
* @param {string} props.property The property to filter by.
|
|
136
|
-
* @param {Function} props.filter Optional. The filter function to apply to the variations.
|
|
137
|
-
* @param {Object} props.baseVariation Optional. Base or user settings to be updated with variation properties.
|
|
138
|
-
* @return {Object[]|*} The merged object.
|
|
139
|
-
*/
|
|
140
|
-
export default function useThemeStyleVariationsByProperty( {
|
|
141
|
-
variations,
|
|
142
|
-
property,
|
|
143
|
-
filter,
|
|
144
|
-
baseVariation,
|
|
145
|
-
} ) {
|
|
146
|
-
return useMemo( () => {
|
|
147
|
-
if ( ! property || ! variations || variations?.length === 0 ) {
|
|
148
|
-
return variations;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const clonedBaseVariation =
|
|
152
|
-
typeof baseVariation === 'object' &&
|
|
153
|
-
Object.keys( baseVariation ).length > 0
|
|
154
|
-
? cloneDeep( baseVariation )
|
|
155
|
-
: null;
|
|
156
|
-
|
|
157
|
-
let processedStyleVariations = variations.reduce(
|
|
158
|
-
( accumulator, variation ) => {
|
|
159
|
-
const variationFilteredByProperty = filterObjectByProperty(
|
|
160
|
-
cloneDeep( variation ),
|
|
161
|
-
property
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
// Remove variations that are empty once the property is filtered out.
|
|
165
|
-
if (
|
|
166
|
-
variation.title !== __( 'Default' ) &&
|
|
167
|
-
Object.keys( variationFilteredByProperty ).length === 0
|
|
168
|
-
) {
|
|
169
|
-
return accumulator;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
let result = {
|
|
173
|
-
...variationFilteredByProperty,
|
|
174
|
-
title: variation?.title,
|
|
175
|
-
description: variation?.description,
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
if ( clonedBaseVariation ) {
|
|
179
|
-
/*
|
|
180
|
-
* Overwrites all baseVariation object `styleProperty` properties
|
|
181
|
-
* with the theme variation `styleProperty` properties.
|
|
182
|
-
*/
|
|
183
|
-
result = mergeBaseAndUserConfigs(
|
|
184
|
-
clonedBaseVariation,
|
|
185
|
-
result
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Detect if this is a duplicate variation.
|
|
190
|
-
const isDuplicate = accumulator.some( ( item ) => {
|
|
191
|
-
return (
|
|
192
|
-
JSON.stringify( item.styles ) ===
|
|
193
|
-
JSON.stringify( result?.styles ) &&
|
|
194
|
-
JSON.stringify( item.settings ) ===
|
|
195
|
-
JSON.stringify( result?.settings )
|
|
196
|
-
);
|
|
197
|
-
} );
|
|
198
|
-
if ( isDuplicate ) {
|
|
199
|
-
return accumulator;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// If the variation is not a duplicate, add it to the accumulator.
|
|
203
|
-
accumulator.push( result );
|
|
204
|
-
return accumulator;
|
|
205
|
-
},
|
|
206
|
-
[] // Initial accumulator value.
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
if ( 'function' === typeof filter ) {
|
|
210
|
-
processedStyleVariations =
|
|
211
|
-
processedStyleVariations.filter( filter );
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return processedStyleVariations;
|
|
215
|
-
}, [ variations, property, baseVariation, filter ] );
|
|
216
|
-
}
|
|
217
|
-
|
|
218
130
|
/**
|
|
219
131
|
* Compares a style variation to the same variation filtered by a single property.
|
|
220
132
|
* Returns true if the variation contains only the property specified.
|
package/src/style.scss
CHANGED
|
@@ -36,6 +36,19 @@
|
|
|
36
36
|
@import "./components/pagination/style.scss";
|
|
37
37
|
@import "./components/global-styles/variations/style.scss";
|
|
38
38
|
|
|
39
|
+
/* stylelint-disable -- Disable reason: View Transitions not supported properly by stylelint. */
|
|
40
|
+
::view-transition-image-pair(root) {
|
|
41
|
+
isolation: auto;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
::view-transition-old(root),
|
|
45
|
+
::view-transition-new(root) {
|
|
46
|
+
animation: none;
|
|
47
|
+
mix-blend-mode: normal;
|
|
48
|
+
display: block;
|
|
49
|
+
}
|
|
50
|
+
/* stylelint-enable */
|
|
51
|
+
|
|
39
52
|
body.js #wpadminbar {
|
|
40
53
|
display: none;
|
|
41
54
|
}
|