@eightshift/frontend-libs-tailwind 1.2.0 → 1.3.1
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/.prettierrc +1 -1
- package/CHANGELOG.md +12 -0
- package/blocks/init/assets/scripts/application-admin.js +1 -1
- package/blocks/init/src/Blocks/assets/scripts/link-section-editor.js +5 -1
- package/blocks/init/src/Blocks/assets/scripts/shared.js +3 -1
- package/blocks/init/src/Blocks/components/button/components/button-options.js +20 -2
- package/blocks/init/src/Blocks/components/card/components/card-editor.js +2 -1
- package/blocks/init/src/Blocks/components/icon/icon.php +3 -1
- package/blocks/init/src/Blocks/components/image/components/image-editor.js +7 -1
- package/blocks/init/src/Blocks/components/image/components/image-options.js +17 -3
- package/blocks/init/src/Blocks/components/list/components/list-options.js +3 -1
- package/blocks/init/src/Blocks/components/modal/assets/index.js +9 -7
- package/blocks/init/src/Blocks/components/paragraph/components/paragraph-options.js +3 -1
- package/blocks/init/src/Blocks/components/share/assets/index.js +5 -1
- package/blocks/init/src/Blocks/components/share/components/share-options.js +11 -2
- package/blocks/init/src/Blocks/components/video/components/video-editor.js +4 -2
- package/blocks/init/src/Blocks/components/video/components/video-options.js +24 -3
- package/blocks/init/src/Blocks/components/video/manifest.json +1 -1
- package/blocks/init/src/Blocks/components/video/video.php +0 -2
- package/blocks/init/src/Blocks/custom/carousel/assets/pagination.js +8 -2
- package/blocks/init/src/Blocks/custom/column/components/column-options.js +12 -4
- package/blocks/init/src/Blocks/custom/columns/components/columns-editor.js +6 -2
- package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-options.js +29 -8
- package/blocks/init/src/Blocks/custom/map/components/map-editor.js +12 -2
- package/blocks/init/src/Blocks/custom/map/components/map-options.js +40 -11
- package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-options.js +3 -1
- package/blocks/init/src/Blocks/custom/site-footer/manifest.json +1 -1
- package/blocks/init/src/Blocks/custom/site-navigation/manifest.json +1 -1
- package/blocks/init/src/Blocks/wrapper/components/wrapper-options.js +19 -4
- package/package.json +15 -15
- package/schemas/block.json +16 -16
- package/schemas/component.json +18 -18
- package/scripts/components/block-inserter.js +4 -1
- package/scripts/components/link-section-editor.js +5 -1
- package/scripts/components/media-picker.js +12 -1
- package/scripts/components/picker-placeholder.js +6 -2
- package/scripts/components/server-side-render.js +4 -1
- package/scripts/components/settings/settings.js +8 -2
- package/scripts/editor/attributes.js +33 -3
- package/scripts/editor/editor.js +7 -1
- package/scripts/editor/fetch.js +2 -1
- package/scripts/editor/index.js +8 -1
- package/scripts/editor/options.js +3 -1
- package/scripts/editor/registration.js +87 -17
- package/scripts/editor/tailwindcss.js +96 -58
- package/scripts/helpers/index.js +7 -1
- package/scripts/index.js +15 -2
- package/webpack/base.mjs +3 -1
- package/webpack/helpers.mjs +13 -3
- package/webpack/project.mjs +8 -2
|
@@ -84,7 +84,11 @@ export const registerBlocks = (
|
|
|
84
84
|
|
|
85
85
|
// Get Block Transforms component from block name and transformsComponentPath.
|
|
86
86
|
if (transformsComponentPath !== null) {
|
|
87
|
-
const blockTransformsComponent = getBlockGenericComponent(
|
|
87
|
+
const blockTransformsComponent = getBlockGenericComponent(
|
|
88
|
+
blockManifest.blockName,
|
|
89
|
+
transformsComponentPath,
|
|
90
|
+
'transforms',
|
|
91
|
+
);
|
|
88
92
|
|
|
89
93
|
if (blockTransformsComponent !== null) {
|
|
90
94
|
blockManifest.transforms = blockTransformsComponent;
|
|
@@ -93,7 +97,11 @@ export const registerBlocks = (
|
|
|
93
97
|
|
|
94
98
|
// Get Block Deprecations component from block name and deprecationsComponentPath.
|
|
95
99
|
if (deprecationsComponentPath !== null) {
|
|
96
|
-
const blockDeprecationsComponent = getBlockGenericComponent(
|
|
100
|
+
const blockDeprecationsComponent = getBlockGenericComponent(
|
|
101
|
+
blockManifest.blockName,
|
|
102
|
+
deprecationsComponentPath,
|
|
103
|
+
'deprecations',
|
|
104
|
+
);
|
|
97
105
|
|
|
98
106
|
if (blockDeprecationsComponent !== null) {
|
|
99
107
|
blockManifest.deprecated = blockDeprecationsComponent;
|
|
@@ -111,7 +119,11 @@ export const registerBlocks = (
|
|
|
111
119
|
|
|
112
120
|
// Get Block Overrides component from block name and overridesComponentPath.
|
|
113
121
|
if (overridesComponentPath !== null) {
|
|
114
|
-
const blockOverridesComponent = getBlockGenericComponent(
|
|
122
|
+
const blockOverridesComponent = getBlockGenericComponent(
|
|
123
|
+
blockManifest.blockName,
|
|
124
|
+
overridesComponentPath,
|
|
125
|
+
'overrides',
|
|
126
|
+
);
|
|
115
127
|
|
|
116
128
|
if (blockOverridesComponent !== null) {
|
|
117
129
|
blockManifest = Object.assign(blockManifest, blockOverridesComponent);
|
|
@@ -119,7 +131,14 @@ export const registerBlocks = (
|
|
|
119
131
|
}
|
|
120
132
|
|
|
121
133
|
// Pass data to registerBlock helper to get final output for registerBlockType.
|
|
122
|
-
const blockDetails = registerBlock(
|
|
134
|
+
const blockDetails = registerBlock(
|
|
135
|
+
globalManifest,
|
|
136
|
+
wrapperManifest,
|
|
137
|
+
componentsManifest,
|
|
138
|
+
blockManifest,
|
|
139
|
+
wrapperComponent,
|
|
140
|
+
blockComponent,
|
|
141
|
+
);
|
|
123
142
|
|
|
124
143
|
// Format the 'deprecated' attribute details to match the format Gutenberg wants.
|
|
125
144
|
if (blockDetails?.options?.deprecated) {
|
|
@@ -145,7 +164,10 @@ export const registerBlocks = (
|
|
|
145
164
|
};
|
|
146
165
|
},
|
|
147
166
|
|
|
148
|
-
isEligible:
|
|
167
|
+
isEligible:
|
|
168
|
+
deprecation?.isEligible ??
|
|
169
|
+
((attributes) =>
|
|
170
|
+
Object.keys(deprecation.oldAttributes).every((v) => Object.keys(attributes).includes(v))),
|
|
149
171
|
save: blockDetails.options.save,
|
|
150
172
|
};
|
|
151
173
|
});
|
|
@@ -196,7 +218,12 @@ export const registerBlocks = (
|
|
|
196
218
|
* );
|
|
197
219
|
* ```
|
|
198
220
|
*/
|
|
199
|
-
export const registerVariations = (
|
|
221
|
+
export const registerVariations = (
|
|
222
|
+
globalManifest = {},
|
|
223
|
+
variationsManifestPath,
|
|
224
|
+
blocksManifestPath = null,
|
|
225
|
+
overridesComponentPath = null,
|
|
226
|
+
) => {
|
|
200
227
|
const variationsManifests = variationsManifestPath.keys().map(variationsManifestPath);
|
|
201
228
|
|
|
202
229
|
// Set all store values.
|
|
@@ -210,7 +237,11 @@ export const registerVariations = (globalManifest = {}, variationsManifestPath,
|
|
|
210
237
|
if (active) {
|
|
211
238
|
// Get Block Overrides component from block name and overridesComponentPath.
|
|
212
239
|
if (overridesComponentPath !== null) {
|
|
213
|
-
const blockOverridesComponent = getBlockGenericComponent(
|
|
240
|
+
const blockOverridesComponent = getBlockGenericComponent(
|
|
241
|
+
variationManifest.name,
|
|
242
|
+
overridesComponentPath,
|
|
243
|
+
'overrides',
|
|
244
|
+
);
|
|
214
245
|
|
|
215
246
|
if (blockOverridesComponent !== null) {
|
|
216
247
|
variationManifest = Object.assign(variationManifest, blockOverridesComponent);
|
|
@@ -218,7 +249,11 @@ export const registerVariations = (globalManifest = {}, variationsManifestPath,
|
|
|
218
249
|
}
|
|
219
250
|
|
|
220
251
|
// Pass data to registerVariation helper to get final output for registerBlockVariation.
|
|
221
|
-
const blockDetails = registerVariation(
|
|
252
|
+
const blockDetails = registerVariation(
|
|
253
|
+
globalManifest,
|
|
254
|
+
variationManifest,
|
|
255
|
+
blocksManifestPath !== null ? blocksManifestPath.keys().map(blocksManifestPath) : [],
|
|
256
|
+
);
|
|
222
257
|
|
|
223
258
|
// Native WP method for block registration.
|
|
224
259
|
registerBlockVariation(blockDetails.blockName, blockDetails.options);
|
|
@@ -248,11 +283,15 @@ export const getBlockEditComponent = (blockName, paths, fileName) => {
|
|
|
248
283
|
const pathsKeys = paths.keys();
|
|
249
284
|
|
|
250
285
|
// Get Block edit component from block name and pathsKeys.
|
|
251
|
-
const editComponent = pathsKeys
|
|
286
|
+
const editComponent = pathsKeys
|
|
287
|
+
.filter((filePath) => filePath === `./${blockName}/${blockName}-${fileName}.js`)
|
|
288
|
+
.map(paths)[0];
|
|
252
289
|
|
|
253
290
|
// If edit component is missing throw and error.
|
|
254
291
|
if (typeof editComponent === 'undefined') {
|
|
255
|
-
throw Error(
|
|
292
|
+
throw Error(
|
|
293
|
+
`It looks like you are missing block edit component for block: ${blockName}, please check if you have ${blockName}-block.js file in your block folder.`,
|
|
294
|
+
);
|
|
256
295
|
}
|
|
257
296
|
|
|
258
297
|
// No mater if class of functional component is used fetch the first item in an object.
|
|
@@ -260,7 +299,9 @@ export const getBlockEditComponent = (blockName, paths, fileName) => {
|
|
|
260
299
|
|
|
261
300
|
// If edit component callback is missing throw and error.
|
|
262
301
|
if (typeof editCallback === 'undefined') {
|
|
263
|
-
throw Error(
|
|
302
|
+
throw Error(
|
|
303
|
+
`It looks like you are missing block edit component for block: ${blockName}, please check if you have ${blockName}-block.js file in your block folder.`,
|
|
304
|
+
);
|
|
264
305
|
}
|
|
265
306
|
|
|
266
307
|
return editCallback;
|
|
@@ -283,7 +324,9 @@ export const getBlockGenericComponent = (blockName, paths, fileName) => {
|
|
|
283
324
|
const pathsKeys = paths.keys();
|
|
284
325
|
|
|
285
326
|
// Get Block edit component from block name and pathsKeys.
|
|
286
|
-
const editComponent = pathsKeys
|
|
327
|
+
const editComponent = pathsKeys
|
|
328
|
+
.filter((filePath) => filePath === `./${blockName}/${blockName}-${fileName}.js`)
|
|
329
|
+
.map(paths)[0];
|
|
287
330
|
|
|
288
331
|
// If edit component is missing throw and error.
|
|
289
332
|
if (typeof editComponent === 'undefined') {
|
|
@@ -492,7 +535,14 @@ export const getIconOptions = (globalManifest, blockManifest) => {
|
|
|
492
535
|
*
|
|
493
536
|
* @returns {object}
|
|
494
537
|
*/
|
|
495
|
-
export const prepareComponentAttribute = (
|
|
538
|
+
export const prepareComponentAttribute = (
|
|
539
|
+
manifest,
|
|
540
|
+
newName,
|
|
541
|
+
realName,
|
|
542
|
+
isExample = false,
|
|
543
|
+
parent = '',
|
|
544
|
+
currentAttributes = false,
|
|
545
|
+
) => {
|
|
496
546
|
const output = {};
|
|
497
547
|
|
|
498
548
|
// Define different data point for attributes or example.
|
|
@@ -563,17 +613,30 @@ export const prepareComponentAttributes = (componentsManifest, manifest, isExamp
|
|
|
563
613
|
|
|
564
614
|
// Bailout if component doesn't exist.
|
|
565
615
|
if (!component) {
|
|
566
|
-
throw Error(
|
|
616
|
+
throw Error(
|
|
617
|
+
`Component specified in "${name}" manifest doesn't exist in your components list. Please check if you project has "${realComponentName}" component.`,
|
|
618
|
+
);
|
|
567
619
|
}
|
|
568
620
|
|
|
569
621
|
let outputAttributes = {};
|
|
570
622
|
|
|
571
623
|
// If component has more components do recursive loop.
|
|
572
624
|
if (component?.components) {
|
|
573
|
-
outputAttributes = prepareComponentAttributes(
|
|
625
|
+
outputAttributes = prepareComponentAttributes(
|
|
626
|
+
componentsManifest,
|
|
627
|
+
component,
|
|
628
|
+
isExample,
|
|
629
|
+
`${newParent}${upperFirst(camelCase(newComponentName))}`,
|
|
630
|
+
);
|
|
574
631
|
} else {
|
|
575
632
|
// Output the component attributes if there is no nesting left, and append the parent prefixes.
|
|
576
|
-
outputAttributes = prepareComponentAttribute(
|
|
633
|
+
outputAttributes = prepareComponentAttribute(
|
|
634
|
+
component,
|
|
635
|
+
newComponentName,
|
|
636
|
+
realComponentName,
|
|
637
|
+
isExample,
|
|
638
|
+
newParent,
|
|
639
|
+
);
|
|
577
640
|
}
|
|
578
641
|
|
|
579
642
|
// Populate the output recursively.
|
|
@@ -752,7 +815,14 @@ export const registerVariation = (globalManifest = {}, variationManifest = {}) =
|
|
|
752
815
|
*
|
|
753
816
|
* @returns {object}
|
|
754
817
|
*/
|
|
755
|
-
export const registerBlock = (
|
|
818
|
+
export const registerBlock = (
|
|
819
|
+
globalManifest = {},
|
|
820
|
+
wrapperManifest = {},
|
|
821
|
+
componentsManifest = {},
|
|
822
|
+
blockManifest = {},
|
|
823
|
+
wrapperComponent,
|
|
824
|
+
blockComponent,
|
|
825
|
+
) => {
|
|
756
826
|
// Block Icon option.
|
|
757
827
|
blockManifest['icon'] = getIconOptions(globalManifest, blockManifest);
|
|
758
828
|
|
|
@@ -21,10 +21,15 @@ import { clsx } from '@eightshift/ui-components/utilities';
|
|
|
21
21
|
*/
|
|
22
22
|
export const getTwPart = (part, manifest, ...custom) => {
|
|
23
23
|
if (!part || !manifest || !manifest?.tailwind || Object.keys(manifest?.tailwind ?? {}).length === 0) {
|
|
24
|
-
return
|
|
24
|
+
return clsx(...custom);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
let partClasses =
|
|
28
|
+
manifest?.tailwind?.parts?.[part]?.twClassesEditor ?? manifest?.tailwind?.parts?.[part]?.twClasses ?? '';
|
|
29
|
+
|
|
30
|
+
if (Array.isArray(partClasses)) {
|
|
31
|
+
partClasses = partClasses.join(' ');
|
|
32
|
+
}
|
|
28
33
|
|
|
29
34
|
return clsx(partClasses, ...custom);
|
|
30
35
|
};
|
|
@@ -50,46 +55,56 @@ export const getTwPart = (part, manifest, ...custom) => {
|
|
|
50
55
|
*/
|
|
51
56
|
export const getTwDynamicPart = (part, attributes, manifest, ...custom) => {
|
|
52
57
|
if (!part || !manifest || !manifest?.tailwind || Object.keys(manifest?.tailwind ?? {}).length === 0) {
|
|
53
|
-
return
|
|
58
|
+
return clsx(...custom);
|
|
54
59
|
}
|
|
55
60
|
|
|
56
|
-
const baseClasses =
|
|
61
|
+
const baseClasses =
|
|
62
|
+
manifest?.tailwind?.parts?.[part]?.twClassesEditor ?? manifest?.tailwind?.parts?.[part]?.twClasses ?? '';
|
|
57
63
|
|
|
58
|
-
const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce(
|
|
65
|
+
(current, [attributeName, { responsive, twClasses, twClassesEditor, part: partName }]) => {
|
|
66
|
+
if (partName !== part) {
|
|
67
|
+
return current;
|
|
68
|
+
}
|
|
62
69
|
|
|
63
|
-
|
|
70
|
+
const value = checkAttr(attributeName, attributes, manifest, true);
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
if (!value) {
|
|
73
|
+
return current;
|
|
74
|
+
}
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
76
|
+
if (!responsive) {
|
|
77
|
+
const currentClasses = twClassesEditor?.[value] ?? twClasses?.[value];
|
|
72
78
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
if (Array.isArray(currentClasses)) {
|
|
80
|
+
return [...current, ...currentClasses];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return [...current, currentClasses];
|
|
76
84
|
}
|
|
77
85
|
|
|
78
|
-
const
|
|
86
|
+
const responsiveClasses = Object.keys(value).reduce((curr, breakpoint) => {
|
|
87
|
+
if (breakpoint === '_desktopFirst') {
|
|
88
|
+
return curr;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let currentClasses = twClassesEditor?.[value[breakpoint]] ?? twClasses?.[value[breakpoint]];
|
|
79
92
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
if (!Array.isArray(currentClasses)) {
|
|
94
|
+
currentClasses = [currentClasses];
|
|
95
|
+
}
|
|
83
96
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
97
|
+
if (breakpoint === '_default') {
|
|
98
|
+
return [...curr, ...currentClasses];
|
|
99
|
+
}
|
|
87
100
|
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
return [...curr, ...currentClasses.split(' ').map((currentClass) => `${breakpoint}:${currentClass}`)];
|
|
102
|
+
}, []);
|
|
90
103
|
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
return [...current, ...responsiveClasses];
|
|
105
|
+
},
|
|
106
|
+
[],
|
|
107
|
+
);
|
|
93
108
|
|
|
94
109
|
return clsx(baseClasses, ...mainClasses, ...custom);
|
|
95
110
|
};
|
|
@@ -112,46 +127,59 @@ export const getTwDynamicPart = (part, attributes, manifest, ...custom) => {
|
|
|
112
127
|
*/
|
|
113
128
|
export const getTwClasses = (attributes, manifest, ...custom) => {
|
|
114
129
|
if (!attributes || !manifest || !manifest?.tailwind || Object.keys(manifest?.tailwind ?? {}).length === 0) {
|
|
115
|
-
return
|
|
130
|
+
return clsx(...custom);
|
|
116
131
|
}
|
|
117
132
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce((current, [attributeName, { responsive, twClasses, twClassesEditor, part: partName }]) => {
|
|
121
|
-
if (partName) {
|
|
122
|
-
return current;
|
|
123
|
-
}
|
|
133
|
+
let baseClasses = manifest?.tailwind?.base?.twClassesEditor ?? manifest?.tailwind?.base?.twClasses ?? '';
|
|
124
134
|
|
|
125
|
-
|
|
135
|
+
if (Array.isArray(baseClasses)) {
|
|
136
|
+
baseClasses = baseClasses.join(' ');
|
|
137
|
+
}
|
|
126
138
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce(
|
|
140
|
+
(current, [attributeName, { responsive, twClasses, twClassesEditor, part: partName }]) => {
|
|
141
|
+
if (partName) {
|
|
142
|
+
return current;
|
|
143
|
+
}
|
|
130
144
|
|
|
131
|
-
|
|
132
|
-
return [...current, twClassesEditor?.[value] ?? twClasses?.[value]];
|
|
133
|
-
}
|
|
145
|
+
const value = checkAttr(attributeName, attributes, manifest, true);
|
|
134
146
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return curr;
|
|
147
|
+
if (!value) {
|
|
148
|
+
return current;
|
|
138
149
|
}
|
|
139
150
|
|
|
140
|
-
|
|
151
|
+
if (!responsive) {
|
|
152
|
+
let currentClasses = twClassesEditor?.[value] ?? twClasses?.[value];
|
|
141
153
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
154
|
+
if (Array.isArray(currentClasses)) {
|
|
155
|
+
currentClasses = currentClasses.join(' ');
|
|
156
|
+
}
|
|
145
157
|
|
|
146
|
-
|
|
147
|
-
return [...curr, ...currentClasses.split(' ').map((currentClass) => `${breakpoint}:${currentClass}`)];
|
|
158
|
+
return [...current, currentClasses];
|
|
148
159
|
}
|
|
149
160
|
|
|
150
|
-
|
|
151
|
-
|
|
161
|
+
const responsiveClasses = Object.keys(value).reduce((curr, breakpoint) => {
|
|
162
|
+
if (breakpoint === '_desktopFirst') {
|
|
163
|
+
return curr;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let currentClasses = twClassesEditor?.[value[breakpoint]] ?? twClasses?.[value[breakpoint]];
|
|
167
|
+
|
|
168
|
+
if (!Array.isArray(currentClasses)) {
|
|
169
|
+
currentClasses = [currentClasses];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (breakpoint === '_default') {
|
|
173
|
+
return [...curr, ...currentClasses];
|
|
174
|
+
}
|
|
152
175
|
|
|
153
|
-
|
|
154
|
-
|
|
176
|
+
return [...curr, ...currentClasses.map((currentClass) => `${breakpoint}:${currentClass}`)];
|
|
177
|
+
}, []);
|
|
178
|
+
|
|
179
|
+
return [...current, ...responsiveClasses];
|
|
180
|
+
},
|
|
181
|
+
[],
|
|
182
|
+
);
|
|
155
183
|
|
|
156
184
|
const combinationClasses =
|
|
157
185
|
manifest?.tailwind?.combinations?.reduce((current, { attributes: conditions, twClasses, twClassesEditor }) => {
|
|
@@ -171,7 +199,13 @@ export const getTwClasses = (attributes, manifest, ...custom) => {
|
|
|
171
199
|
}
|
|
172
200
|
}
|
|
173
201
|
|
|
174
|
-
|
|
202
|
+
let currentClasses = twClassesEditor ?? twClasses;
|
|
203
|
+
|
|
204
|
+
if (!Array.isArray(currentClasses)) {
|
|
205
|
+
currentClasses = [currentClasses];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return [...current, ...currentClasses];
|
|
175
209
|
}, []) ?? [];
|
|
176
210
|
|
|
177
211
|
return clsx(baseClasses, ...mainClasses, ...combinationClasses, ...custom);
|
|
@@ -297,9 +331,13 @@ function* extractKeys(obj, parentKey = '', isResponsive = false) {
|
|
|
297
331
|
}
|
|
298
332
|
|
|
299
333
|
const combineAndRemoveDuplicates = (results) => {
|
|
300
|
-
return results.reduce((acc, {
|
|
334
|
+
return results.reduce((acc, { value, responsive }) => {
|
|
301
335
|
acc[responsive] = acc[responsive] ? `${acc[responsive]} ${value}` : value;
|
|
302
336
|
|
|
337
|
+
if (Array.isArray(acc[responsive])) {
|
|
338
|
+
acc[responsive] = acc[responsive].join(' ');
|
|
339
|
+
}
|
|
340
|
+
|
|
303
341
|
return acc;
|
|
304
342
|
}, {});
|
|
305
343
|
};
|
package/scripts/helpers/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// All exports are sorted in alphabetical order.
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export {
|
|
4
|
+
getBreakpointData,
|
|
5
|
+
getBreakpointNames,
|
|
6
|
+
getGlobalManifest,
|
|
7
|
+
getBreakpointUiData,
|
|
8
|
+
getResponsiveData,
|
|
9
|
+
} from './breakpoints';
|
|
4
10
|
export { cookies } from './cookies';
|
|
5
11
|
export { dynamicImport } from './dynamic-import';
|
package/scripts/index.js
CHANGED
|
@@ -15,10 +15,23 @@ export * from './editor/fetch';
|
|
|
15
15
|
export * from './editor/options';
|
|
16
16
|
export * from './editor/utility';
|
|
17
17
|
export * from './editor/tailwindcss';
|
|
18
|
-
export {
|
|
18
|
+
export {
|
|
19
|
+
getAttributes,
|
|
20
|
+
getExample,
|
|
21
|
+
getFullBlockName,
|
|
22
|
+
getFullBlockNameVariation,
|
|
23
|
+
registerBlocks,
|
|
24
|
+
registerVariations,
|
|
25
|
+
} from './editor/registration';
|
|
19
26
|
export { STORE_NAME, BUILD_VERSION, setStore, setStoreGlobalWindow, setConfigFlags } from './editor/store';
|
|
20
27
|
|
|
21
28
|
// Helpers.
|
|
22
|
-
export {
|
|
29
|
+
export {
|
|
30
|
+
getBreakpointData,
|
|
31
|
+
getBreakpointNames,
|
|
32
|
+
getGlobalManifest,
|
|
33
|
+
getBreakpointUiData,
|
|
34
|
+
getResponsiveData,
|
|
35
|
+
} from './helpers/breakpoints';
|
|
23
36
|
export { cookies } from './helpers/cookies';
|
|
24
37
|
export { dynamicImport } from './helpers/dynamic-import';
|
package/webpack/base.mjs
CHANGED
|
@@ -26,7 +26,9 @@ export default (options) => {
|
|
|
26
26
|
if (!options.overrides.includes('definePlugin')) {
|
|
27
27
|
plugins.push(
|
|
28
28
|
new webpack.DefinePlugin({
|
|
29
|
-
'process.env.VERSION': JSON.stringify(
|
|
29
|
+
'process.env.VERSION': JSON.stringify(
|
|
30
|
+
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
|
|
31
|
+
),
|
|
30
32
|
'process.browser': true,
|
|
31
33
|
}),
|
|
32
34
|
);
|
package/webpack/helpers.mjs
CHANGED
|
@@ -25,7 +25,9 @@ function getConfig(
|
|
|
25
25
|
blocksManifestSettingsPath = 'src/Blocks/manifest.json',
|
|
26
26
|
) {
|
|
27
27
|
if (typeof projectDir === 'undefined') {
|
|
28
|
-
throw Error(
|
|
28
|
+
throw Error(
|
|
29
|
+
'projectDir parameter is empty, please provide. This key represents: Current project directory absolute path. For example: __dirname',
|
|
30
|
+
);
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
if (typeof projectPathConfig === 'undefined') {
|
|
@@ -57,8 +59,16 @@ function getConfig(
|
|
|
57
59
|
applicationEntry: path.resolve(absolutePath, assetsPathConfigClean, 'application.js'),
|
|
58
60
|
applicationAdminEntry: path.resolve(absolutePath, assetsPathConfigClean, 'application-admin.js'),
|
|
59
61
|
applicationBlocksEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-blocks.js'),
|
|
60
|
-
applicationBlocksEditorEntry: path.resolve(
|
|
61
|
-
|
|
62
|
+
applicationBlocksEditorEntry: path.resolve(
|
|
63
|
+
absolutePath,
|
|
64
|
+
blocksAssetsPathConfigClean,
|
|
65
|
+
'application-blocks-editor.js',
|
|
66
|
+
),
|
|
67
|
+
applicationBlocksFrontendEntry: path.resolve(
|
|
68
|
+
absolutePath,
|
|
69
|
+
blocksAssetsPathConfigClean,
|
|
70
|
+
'application-blocks-frontend.js',
|
|
71
|
+
),
|
|
62
72
|
|
|
63
73
|
blocksManifestSettingsPath: path.resolve(absolutePath, blocksManifestSettingsPathClean),
|
|
64
74
|
};
|
package/webpack/project.mjs
CHANGED
|
@@ -34,12 +34,18 @@ export default (options) => {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// Load ApplicationBlocksEditor Entrypoint.
|
|
37
|
-
if (
|
|
37
|
+
if (
|
|
38
|
+
!options.overrides.includes('applicationBlocksEditor') &&
|
|
39
|
+
fs.existsSync(options.config.applicationBlocksEditorEntry)
|
|
40
|
+
) {
|
|
38
41
|
entry.applicationBlocksEditor = options.config.applicationBlocksEditorEntry;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
// Load applicationBlocksFrontend Entrypoint.
|
|
42
|
-
if (
|
|
45
|
+
if (
|
|
46
|
+
!options.overrides.includes('applicationBlocksFrontend') &&
|
|
47
|
+
fs.existsSync(options.config.applicationBlocksFrontendEntry)
|
|
48
|
+
) {
|
|
43
49
|
entry.applicationBlocksFrontend = options.config.applicationBlocksFrontendEntry;
|
|
44
50
|
}
|
|
45
51
|
|