@eightshift/frontend-libs-tailwind 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eightshift/frontend-libs-tailwind",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "A framework for creating modern Gutenberg themes with styling provided by Tailwind CSS.",
5
5
  "author": {
6
6
  "name": "Eightshift team",
@@ -26,46 +26,45 @@
26
26
  "url": "https://github.com/infinum/eightshift-frontend-libs-tailwind/issues"
27
27
  },
28
28
  "scripts": {
29
- "lintJs": "bunx eslint",
30
- "lint": "bun run lintJs",
29
+ "lintJs": "eslint",
31
30
  "prepare": "husky"
32
31
  },
33
32
  "homepage": "https://github.com/infinum/eightshift-frontend-libs-tailwind#readme",
34
33
  "license": "MIT",
35
34
  "dependencies": {
36
35
  "@stylistic/eslint-plugin": "^5.10.0",
37
- "@stylistic/stylelint-plugin": "^5.1.0",
38
- "@swc/core": "^1.15.30",
39
- "@tailwindcss/webpack": "^4.2.4",
40
- "@wordpress/dependency-extraction-webpack-plugin": "^6.44.0",
36
+ "@stylistic/stylelint-plugin": "^5.2.0",
37
+ "@swc/core": "^1.15.40",
38
+ "@tailwindcss/webpack": "^4.3.0",
39
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.47.0",
41
40
  "browserslist": "^4.28.2",
42
41
  "css-loader": "^7.1.4",
43
42
  "css-minimizer-webpack-plugin": "^8.0.0",
44
- "eslint": "^10.2.1",
43
+ "eslint": "^10.4.1",
45
44
  "eslint-config-prettier": "^10.1.8",
46
- "eslint-plugin-prettier": "^5.5.5",
45
+ "eslint-plugin-prettier": "^5.5.6",
47
46
  "eslint-plugin-react": "^7.37.5",
48
47
  "eslint-plugin-react-hooks": "^7.1.1",
49
48
  "eslint-plugin-unused-imports": "^4.4.1",
50
49
  "glob": "^13.0.6",
51
- "globals": "^17.5.0",
50
+ "globals": "^17.6.0",
52
51
  "husky": "^9.1.7",
53
52
  "lightningcss": "^1.32.0",
54
53
  "mini-css-extract-plugin": "^2.10.2",
55
54
  "prettier": "^3.8.3",
56
- "prettier-plugin-tailwindcss": "^0.7.2",
55
+ "prettier-plugin-tailwindcss": "^0.7.4",
57
56
  "sonner": "^2.0.7",
58
- "stylelint": "^17.8.0",
57
+ "stylelint": "^17.12.0",
59
58
  "stylelint-config-standard": "^40.0.0",
60
59
  "swc-loader": "^0.2.7",
61
- "terser-webpack-plugin": "^5.4.0",
62
- "webpack": "^5.106.2",
63
- "webpack-cli": "^7.0.2",
60
+ "terser-webpack-plugin": "^5.6.1",
61
+ "webpack": "^5.107.2",
62
+ "webpack-cli": "^7.0.3",
64
63
  "webpack-manifest-plugin": "^6.0.1",
65
64
  "webpack-merge": "^6.0.1"
66
65
  },
67
66
  "devDependencies": {
68
- "@wordpress/api-fetch": "^7.44.0",
67
+ "@wordpress/api-fetch": "^7.47.0",
69
68
  "lint-staged": "^16.4.0"
70
69
  },
71
70
  "peerDependencies": {
@@ -75,9 +74,6 @@
75
74
  "lint-staged": {
76
75
  "*.js": [
77
76
  "bun run lintJs"
78
- ],
79
- "*.php": [
80
- "composer test"
81
77
  ]
82
78
  }
83
79
  }
@@ -29,14 +29,13 @@
29
29
  "type": "boolean",
30
30
  "description": "Set to 'false' to disable wrapper.",
31
31
  "default": true
32
- },
33
- "useLegacyComponents": {
34
- "type": "boolean",
35
- "description": "Set to 'true' to use legacy components.",
36
- "default": false
37
32
  }
38
33
  }
39
34
  },
35
+ "blockOptions": {
36
+ "type": "object",
37
+ "description": "Blocks object represents all blocks in your project. You can set global block settings here that will be used in every block manifest.json only used in Block Editor. You can override this in every block manifest.json."
38
+ },
40
39
  "globalVariables": {
41
40
  "type": "object",
42
41
  "description": "Project-specific configuration options.",
@@ -64,15 +63,8 @@
64
63
  }
65
64
  }
66
65
  },
67
- "required": [
68
- "breakpoints"
69
- ]
66
+ "required": ["breakpoints"]
70
67
  }
71
68
  },
72
- "required": [
73
- "namespace",
74
- "background",
75
- "foreground",
76
- "globalVariables"
77
- ]
69
+ "required": ["namespace", "background", "foreground", "globalVariables"]
78
70
  }
@@ -26,15 +26,7 @@ import { clsx } from '@eightshift/ui-components/utilities';
26
26
  * @preserve
27
27
  */
28
28
  export const BlockInserter = (props) => {
29
- const {
30
- clientId,
31
- label,
32
- small = false,
33
- className,
34
- prioritizePatterns = false,
35
- alwaysVisible = false,
36
- hidden,
37
- } = props;
29
+ const { clientId, label, small = false, className, prioritizePatterns = false, alwaysVisible = false, hidden } = props;
38
30
 
39
31
  const currentBlockClientId = useSuspenseSelect((select) => select('core/block-editor')?.getSelectedBlockClientId());
40
32
 
@@ -59,10 +51,7 @@ export const BlockInserter = (props) => {
59
51
  let labelText = label;
60
52
 
61
53
  if (label === true) {
62
- labelText = sprintf(
63
- __('Add %s', 'eightshift-frontend-libs'),
64
- hasSingleBlockType ? blockTitle : __('a block', 'eightshift-frontend-libs'),
65
- );
54
+ labelText = sprintf(__('Add %s', 'eightshift-frontend-libs'), hasSingleBlockType ? blockTitle : __('a block', 'eightshift-frontend-libs'));
66
55
  }
67
56
 
68
57
  return (
@@ -1,16 +1,7 @@
1
1
  import { __ } from '@wordpress/i18n';
2
2
  import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
3
3
  import { Button, FilePickerShell } from '@eightshift/ui-components';
4
- import {
5
- animationFile,
6
- closedCaptions,
7
- fileMetadata,
8
- imageFile,
9
- itemSelect,
10
- swap,
11
- upload,
12
- videoFile,
13
- } from '@eightshift/ui-components/icons';
4
+ import { animationFile, closedCaptions, fileMetadata, imageFile, itemSelect, swap, upload, videoFile } from '@eightshift/ui-components/icons';
14
5
 
15
6
  /**
16
7
  * A customizable button for managing files from the Media library.
@@ -180,17 +171,7 @@ export const ManageFileButton = (props) => {
180
171
  *
181
172
  */
182
173
  export const FileSelector = (props) => {
183
- const {
184
- onChange,
185
- fileId,
186
- fileName,
187
- noDelete,
188
- noUpload,
189
- labels,
190
- allowedTypes,
191
- kind = 'file',
192
- ...filePickerShellProps
193
- } = props;
174
+ const { onChange, fileId, fileName, noDelete, noUpload, labels, allowedTypes, kind = 'file', ...filePickerShellProps } = props;
194
175
 
195
176
  const commonManageFileButtonProps = {
196
177
  onChange,
@@ -236,11 +236,7 @@ export const LinkSectionEditor = (props) => {
236
236
  setTimeout(() => {
237
237
  target.parentElement.nextElementSibling?.querySelector('[contenteditable="true"]')?.focus();
238
238
  }, 25);
239
- } else if (
240
- code === 'Backspace' &&
241
- header === '' &&
242
- (items?.length < 1 || items?.every(({ text }) => text === ''))
243
- ) {
239
+ } else if (code === 'Backspace' && header === '' && (items?.length < 1 || items?.every(({ text }) => text === ''))) {
244
240
  event.preventDefault();
245
241
 
246
242
  // Jump to end of previous input.
@@ -31,17 +31,7 @@ import { BlockInserter } from '@eightshift/frontend-libs-tailwind/scripts';
31
31
  * @preserve
32
32
  */
33
33
  export const PickerPlaceholder = (props) => {
34
- const {
35
- title: rawTitle,
36
- presets: rawPresets,
37
- blockIcon: rawBlockIcon,
38
- onChange,
39
- clientId,
40
- manifest,
41
- inserter,
42
- presetsHeading = __('Select a preset', 'eightshift-frontend-libs-tailwind'),
43
- hidden,
44
- } = props;
34
+ const { title: rawTitle, presets: rawPresets, blockIcon: rawBlockIcon, onChange, clientId, manifest, inserter, presetsHeading = __('Select a preset', 'eightshift-frontend-libs-tailwind'), hidden } = props;
45
35
 
46
36
  const title = rawTitle ?? manifest?.title;
47
37
  const blockIcon = rawBlockIcon ?? manifest?.icon?.src;
@@ -73,9 +63,7 @@ export const PickerPlaceholder = (props) => {
73
63
  <Button
74
64
  key={index}
75
65
  onPress={async () => {
76
- const blocksToInsert = blockData.map(({ name: blockName, attributes: blockAttrs }) =>
77
- createBlock(blockName, blockAttrs),
78
- );
66
+ const blocksToInsert = blockData.map(({ name: blockName, attributes: blockAttrs }) => createBlock(blockName, blockAttrs));
79
67
 
80
68
  onChange(attrsToSet);
81
69
 
@@ -29,10 +29,7 @@ export const ServerSideRender = (props) => {
29
29
  {...rest}
30
30
  block={block}
31
31
  attributes={attributes}
32
- className={clsx(
33
- 'es:pointer-events-none es:rounded-lg es:border es:border-dotted es:border-gray-300 es:p-2 es:flow-root',
34
- className,
35
- )}
32
+ className={clsx('es:pointer-events-none es:rounded-lg es:border es:border-dotted es:border-gray-300 es:p-2 es:flow-root', className)}
36
33
  />
37
34
  );
38
35
  };
@@ -9,11 +9,7 @@ import { useThemeOptions } from './use-theme-options';
9
9
 
10
10
  export const EsThemeOptionsContext = createContext(null);
11
11
 
12
- export const ThemeOptionsPage = ({
13
- title = __('Theme options', 'eightshift-frontend-libs-tailwind'),
14
- children,
15
- settingName = 'eightshift-theme-options',
16
- }) => {
12
+ export const ThemeOptionsPage = ({ title = __('Theme options', 'eightshift-frontend-libs-tailwind'), children, settingName = 'eightshift-theme-options' }) => {
17
13
  const themeOptions = useThemeOptions(settingName);
18
14
  const { isLoading, saveSettings } = themeOptions;
19
15
 
@@ -28,9 +24,7 @@ export const ThemeOptionsPage = ({
28
24
  pending={isLoading}
29
25
  icon={save}
30
26
  >
31
- {isLoading
32
- ? __('Saving...', 'eightshift-frontend-libs-tailwind')
33
- : __('Save', 'eightshift-frontend-libs-tailwind')}
27
+ {isLoading ? __('Saving...', 'eightshift-frontend-libs-tailwind') : __('Save', 'eightshift-frontend-libs-tailwind')}
34
28
  </Button>
35
29
  }
36
30
  />
@@ -109,20 +109,15 @@ export const checkAttr = (key, attributes, manifest, undefinedAllowed = false) =
109
109
  let tipOutput = '';
110
110
 
111
111
  if ('components' in manifest) {
112
- tipOutput =
113
- ' If you are using additional components, check if you used the correct block/component prefix in your attribute name.';
112
+ tipOutput = ' If you are using additional components, check if you used the correct block/component prefix in your attribute name.';
114
113
  }
115
114
 
116
115
  // Bailout if key is missing.
117
116
  if (typeof manifestKey === 'undefined') {
118
117
  if ('blockName' in manifest) {
119
- throw Error(
120
- `${key} key does not exist in the ${manifest.blockName} block manifest. Please check your implementation.${tipOutput}`,
121
- );
118
+ throw Error(`${key} key does not exist in the ${manifest.blockName} block manifest. Please check your implementation.${tipOutput}`);
122
119
  } else {
123
- throw Error(
124
- `${key} key does not exist in the ${manifest.componentName} component manifest. Please check your implementation.${tipOutput}`,
125
- );
120
+ throw Error(`${key} key does not exist in the ${manifest.componentName} component manifest. Please check your implementation.${tipOutput}`);
126
121
  }
127
122
  }
128
123
 
@@ -231,21 +226,7 @@ export const props = (newName, attributes, manual = {}) => {
231
226
  const output = {};
232
227
 
233
228
  // Check which attributes we need to include.
234
- const includes = [
235
- 'blockName',
236
- 'blockClientId',
237
- 'blockTopLevelId',
238
- 'blockFullName',
239
- 'blockClass',
240
- 'blockJsClass',
241
- 'componentJsClass',
242
- 'selectorClass',
243
- 'additionalClass',
244
- 'setAttributes',
245
- 'uniqueWrapperId',
246
- 'options',
247
- 'clientId',
248
- ];
229
+ const includes = ['blockName', 'blockClientId', 'blockTopLevelId', 'blockFullName', 'blockClass', 'blockJsClass', 'componentJsClass', 'selectorClass', 'additionalClass', 'setAttributes', 'uniqueWrapperId', 'options', 'clientId'];
249
230
 
250
231
  // Check if in test mode and use different setting.
251
232
  const blockName = process.env.NODE_ENV === 'test' ? attributes.blockName.default : attributes.blockName;
@@ -112,10 +112,8 @@ export const GutenbergBlock = (props) => {
112
112
  toolbar: ToolbarComponent,
113
113
  editor: EditorComponent,
114
114
  noOptionsContainer = false,
115
- toolbarPortalElement = document.querySelector('.block-editor-iframe__scale-container > iframe')?.contentWindow
116
- ?.document?.body,
117
- editorPortalElement = document.querySelector('.block-editor-iframe__scale-container > iframe')?.contentWindow
118
- ?.document?.body,
115
+ toolbarPortalElement = document.querySelector('.block-editor-iframe__scale-container > iframe')?.contentWindow?.document?.body,
116
+ editorPortalElement = document.querySelector('.block-editor-iframe__scale-container > iframe')?.contentWindow?.document?.body,
119
117
  optionsPortalElement = document?.body,
120
118
  title,
121
119
  } = props;
@@ -38,19 +38,7 @@ import apiFetch from '@wordpress/api-fetch';
38
38
  *
39
39
  */
40
40
  export function fetchFromWpRest(endpoint, options = {}) {
41
- const {
42
- processId = ({ id }) => id,
43
- labelProp = 'title',
44
- processLabel = (item) => item[labelProp],
45
- processMetadata = () => null,
46
- perPage = 30,
47
- routePrefix = 'wp/v2',
48
- fields = 'id,title',
49
- searchColumns,
50
- noUnescapeTitle = false,
51
- truncateTitle = 32,
52
- ...additionalParams
53
- } = options;
41
+ const { processId = ({ id }) => id, labelProp = 'title', processLabel = (item) => item[labelProp], processMetadata = () => null, perPage = 30, routePrefix = 'wp/v2', fields = 'id,title', searchColumns, noUnescapeTitle = false, truncateTitle = 32, ...additionalParams } = options;
54
42
 
55
43
  return async (searchText = '', abortSignal) => {
56
44
  let params = {
@@ -83,8 +71,7 @@ export function fetchFromWpRest(endpoint, options = {}) {
83
71
 
84
72
  return newData.map((item) => {
85
73
  const rawLabel = !noUnescapeTitle ? unescapeHTML(processLabel(item)) : processLabel(item);
86
- const truncatedLabel =
87
- Number.isInteger(truncateTitle) && truncateTitle > 0 ? truncate(rawLabel, truncateTitle) : rawLabel;
74
+ const truncatedLabel = Number.isInteger(truncateTitle) && truncateTitle > 0 ? truncate(rawLabel, truncateTitle) : rawLabel;
88
75
 
89
76
  return {
90
77
  label: truncatedLabel,
@@ -139,14 +126,7 @@ export const wpSearchRoute = fetchFromWpRest('search', {
139
126
  *
140
127
  */
141
128
  export function buildWpRestUrl(endpoint, options = {}) {
142
- const {
143
- perPage = 30,
144
- routePrefix = 'wp/v2',
145
- fields = 'id,title',
146
- searchColumns,
147
- noSearch,
148
- ...additionalParams
149
- } = options;
129
+ const { perPage = 30, routePrefix = 'wp/v2', fields = 'id,title', searchColumns, noSearch, ...additionalParams } = options;
150
130
 
151
131
  let params = {
152
132
  per_page: perPage,
@@ -7,12 +7,5 @@ export * from './fetch';
7
7
  export * from './options';
8
8
  export * from './utility';
9
9
  export * from './tailwindcss';
10
- export {
11
- getAttributes,
12
- getExample,
13
- getFullBlockName,
14
- getFullBlockNameVariation,
15
- registerBlocks,
16
- registerVariations,
17
- } from './registration';
10
+ export { getAttributes, getExample, getFullBlockName, getFullBlockNameVariation, registerBlocks, registerVariations } from './registration';
18
11
  export { STORE_NAME, BUILD_VERSION, setStore, setStoreGlobalWindow, setConfigFlags } from './store';
@@ -46,9 +46,7 @@ export const getOption = (key, attributes, manifest, isColor = false) => {
46
46
  const componentOptions = manifest?.options;
47
47
 
48
48
  // Determine if this is component or block and provide the name, not used for anything important but only to output the error msg.
49
- const name = Object.prototype.hasOwnProperty.call(manifest, 'blockName')
50
- ? manifest.blockName
51
- : manifest.componentName;
49
+ const name = Object.prototype.hasOwnProperty.call(manifest, 'blockName') ? manifest.blockName : manifest.componentName;
52
50
 
53
51
  // Bailout if componentOptions is missing.
54
52
  if (typeof componentOptions === 'undefined') {
@@ -83,11 +83,7 @@ export const registerBlocks = (
83
83
 
84
84
  // Get Block Transforms component from block name and transformsComponentPath.
85
85
  if (transformsComponentPath !== null) {
86
- const blockTransformsComponent = getBlockGenericComponent(
87
- blockManifest.blockName,
88
- transformsComponentPath,
89
- 'transforms',
90
- );
86
+ const blockTransformsComponent = getBlockGenericComponent(blockManifest.blockName, transformsComponentPath, 'transforms');
91
87
 
92
88
  if (blockTransformsComponent !== null) {
93
89
  blockManifest.transforms = blockTransformsComponent;
@@ -96,11 +92,7 @@ export const registerBlocks = (
96
92
 
97
93
  // Get Block Deprecations component from block name and deprecationsComponentPath.
98
94
  if (deprecationsComponentPath !== null) {
99
- const blockDeprecationsComponent = getBlockGenericComponent(
100
- blockManifest.blockName,
101
- deprecationsComponentPath,
102
- 'deprecations',
103
- );
95
+ const blockDeprecationsComponent = getBlockGenericComponent(blockManifest.blockName, deprecationsComponentPath, 'deprecations');
104
96
 
105
97
  if (blockDeprecationsComponent !== null) {
106
98
  blockManifest.deprecated = blockDeprecationsComponent;
@@ -118,26 +110,15 @@ export const registerBlocks = (
118
110
 
119
111
  // Get Block Overrides component from block name and overridesComponentPath.
120
112
  if (overridesComponentPath !== null) {
121
- const blockOverridesComponent = getBlockGenericComponent(
122
- blockManifest.blockName,
123
- overridesComponentPath,
124
- 'overrides',
125
- );
113
+ const blockOverridesComponent = getBlockGenericComponent(blockManifest.blockName, overridesComponentPath, 'overrides');
126
114
 
127
115
  if (blockOverridesComponent !== null) {
128
- blockManifest = Object.assign(blockManifest, blockOverridesComponent);
116
+ Object.assign(blockManifest, blockOverridesComponent);
129
117
  }
130
118
  }
131
119
 
132
120
  // Pass data to registerBlock helper to get final output for registerBlockType.
133
- const blockDetails = registerBlock(
134
- globalManifest,
135
- wrapperManifest,
136
- componentsManifest,
137
- blockManifest,
138
- wrapperComponent,
139
- blockComponent,
140
- );
121
+ const blockDetails = registerBlock(globalManifest, wrapperManifest, componentsManifest, blockManifest, wrapperComponent, blockComponent);
141
122
 
142
123
  // Format the 'deprecated' attribute details to match the format Gutenberg wants.
143
124
  if (blockDetails?.options?.deprecated) {
@@ -163,10 +144,7 @@ export const registerBlocks = (
163
144
  };
164
145
  },
165
146
 
166
- isEligible:
167
- deprecation?.isEligible ??
168
- ((attributes) =>
169
- Object.keys(deprecation.oldAttributes).every((v) => Object.keys(attributes).includes(v))),
147
+ isEligible: deprecation?.isEligible ?? ((attributes) => Object.keys(deprecation.oldAttributes).every((v) => Object.keys(attributes).includes(v))),
170
148
  save: blockDetails.options.save,
171
149
  };
172
150
  });
@@ -217,12 +195,7 @@ export const registerBlocks = (
217
195
  * );
218
196
  * ```
219
197
  */
220
- export const registerVariations = (
221
- globalManifest = {},
222
- variationsManifestPath,
223
- blocksManifestPath = null,
224
- overridesComponentPath = null,
225
- ) => {
198
+ export const registerVariations = (globalManifest = {}, variationsManifestPath, blocksManifestPath = null, overridesComponentPath = null) => {
226
199
  const variationsManifests = variationsManifestPath.keys().map(variationsManifestPath);
227
200
 
228
201
  // Iterate blocks to register.
@@ -233,23 +206,15 @@ export const registerVariations = (
233
206
  if (active) {
234
207
  // Get Block Overrides component from block name and overridesComponentPath.
235
208
  if (overridesComponentPath !== null) {
236
- const blockOverridesComponent = getBlockGenericComponent(
237
- variationManifest.name,
238
- overridesComponentPath,
239
- 'overrides',
240
- );
209
+ const blockOverridesComponent = getBlockGenericComponent(variationManifest.name, overridesComponentPath, 'overrides');
241
210
 
242
211
  if (blockOverridesComponent !== null) {
243
- variationManifest = Object.assign(variationManifest, blockOverridesComponent);
212
+ Object.assign(variationManifest, blockOverridesComponent);
244
213
  }
245
214
  }
246
215
 
247
216
  // Pass data to registerVariation helper to get final output for registerBlockVariation.
248
- const blockDetails = registerVariation(
249
- globalManifest,
250
- variationManifest,
251
- blocksManifestPath !== null ? blocksManifestPath.keys().map(blocksManifestPath) : [],
252
- );
217
+ const blockDetails = registerVariation(globalManifest, variationManifest, blocksManifestPath !== null ? blocksManifestPath.keys().map(blocksManifestPath) : []);
253
218
 
254
219
  // Native WP method for block registration.
255
220
  registerBlockVariation(blockDetails.blockName, blockDetails.options);
@@ -279,15 +244,11 @@ export const getBlockEditComponent = (blockName, paths, fileName) => {
279
244
  const pathsKeys = paths.keys();
280
245
 
281
246
  // Get Block edit component from block name and pathsKeys.
282
- const editComponent = pathsKeys
283
- .filter((filePath) => filePath === `./${blockName}/${blockName}-${fileName}.js`)
284
- .map(paths)[0];
247
+ const editComponent = pathsKeys.filter((filePath) => filePath === `./${blockName}/${blockName}-${fileName}.js`).map(paths)[0];
285
248
 
286
249
  // If edit component is missing throw and error.
287
250
  if (typeof editComponent === 'undefined') {
288
- throw Error(
289
- `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.`,
290
- );
251
+ throw Error(`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.`);
291
252
  }
292
253
 
293
254
  // No mater if class of functional component is used fetch the first item in an object.
@@ -295,9 +256,7 @@ export const getBlockEditComponent = (blockName, paths, fileName) => {
295
256
 
296
257
  // If edit component callback is missing throw and error.
297
258
  if (typeof editCallback === 'undefined') {
298
- throw Error(
299
- `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.`,
300
- );
259
+ throw Error(`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.`);
301
260
  }
302
261
 
303
262
  return editCallback;
@@ -320,9 +279,7 @@ export const getBlockGenericComponent = (blockName, paths, fileName) => {
320
279
  const pathsKeys = paths.keys();
321
280
 
322
281
  // Get Block edit component from block name and pathsKeys.
323
- const editComponent = pathsKeys
324
- .filter((filePath) => filePath === `./${blockName}/${blockName}-${fileName}.js`)
325
- .map(paths)[0];
282
+ const editComponent = pathsKeys.filter((filePath) => filePath === `./${blockName}/${blockName}-${fileName}.js`).map(paths)[0];
326
283
 
327
284
  // If edit component is missing throw and error.
328
285
  if (typeof editComponent === 'undefined') {
@@ -531,14 +488,7 @@ export const getIconOptions = (globalManifest, blockManifest) => {
531
488
  *
532
489
  * @returns {object}
533
490
  */
534
- export const prepareComponentAttribute = (
535
- manifest,
536
- newName,
537
- realName,
538
- isExample = false,
539
- parent = '',
540
- currentAttributes = false,
541
- ) => {
491
+ export const prepareComponentAttribute = (manifest, newName, realName, isExample = false, parent = '', currentAttributes = false) => {
542
492
  const output = {};
543
493
 
544
494
  // Define different data point for attributes or example.
@@ -609,30 +559,17 @@ export const prepareComponentAttributes = (componentsManifest, manifest, isExamp
609
559
 
610
560
  // Bailout if component doesn't exist.
611
561
  if (!component) {
612
- throw Error(
613
- `Component specified in "${name}" manifest doesn't exist in your components list. Please check if you project has "${realComponentName}" component.`,
614
- );
562
+ throw Error(`Component specified in "${name}" manifest doesn't exist in your components list. Please check if you project has "${realComponentName}" component.`);
615
563
  }
616
564
 
617
565
  let outputAttributes = {};
618
566
 
619
567
  // If component has more components do recursive loop.
620
568
  if (component?.components) {
621
- outputAttributes = prepareComponentAttributes(
622
- componentsManifest,
623
- component,
624
- isExample,
625
- `${newParent}${upperFirst(camelCase(newComponentName))}`,
626
- );
569
+ outputAttributes = prepareComponentAttributes(componentsManifest, component, isExample, `${newParent}${upperFirst(camelCase(newComponentName))}`);
627
570
  } else {
628
571
  // Output the component attributes if there is no nesting left, and append the parent prefixes.
629
- outputAttributes = prepareComponentAttribute(
630
- component,
631
- newComponentName,
632
- realComponentName,
633
- isExample,
634
- newParent,
635
- );
572
+ outputAttributes = prepareComponentAttribute(component, newComponentName, realComponentName, isExample, newParent);
636
573
  }
637
574
 
638
575
  // Populate the output recursively.
@@ -811,14 +748,7 @@ export const registerVariation = (globalManifest = {}, variationManifest = {}) =
811
748
  *
812
749
  * @returns {object}
813
750
  */
814
- export const registerBlock = (
815
- globalManifest = {},
816
- wrapperManifest = {},
817
- componentsManifest = {},
818
- blockManifest = {},
819
- wrapperComponent,
820
- blockComponent,
821
- ) => {
751
+ export const registerBlock = (globalManifest = {}, wrapperManifest = {}, componentsManifest = {}, blockManifest = {}, wrapperComponent, blockComponent) => {
822
752
  // Block Icon option.
823
753
  blockManifest['icon'] = getIconOptions(globalManifest, blockManifest);
824
754
 
@@ -856,15 +786,11 @@ export const registerBlock = (
856
786
  ...getExample('', blockManifest),
857
787
  };
858
788
 
859
- // Block supports.
860
- if (typeof blockManifest['supports'] === 'undefined') {
861
- blockManifest['supports'] = {};
862
- }
863
-
864
789
  return {
865
790
  blockName: fullBlockName,
866
791
  options: {
867
792
  ...blockManifest,
793
+ apiVersion: 3,
868
794
  blockName: fullBlockName,
869
795
  edit: getEditCallback(blockComponent, wrapperComponent),
870
796
  save: getSaveCallback(blockManifest),
@@ -887,10 +813,8 @@ export const registerBlock = (
887
813
 
888
814
  return customName;
889
815
  },
890
- supports: {
891
- ...blockManifest['supports'],
892
- __experimentalMetadata: true, // Required for renaming blocks.
893
- },
816
+ __experimentalMetadata: true,
817
+ ...(globalManifest?.blockOptions ?? {}),
894
818
  },
895
819
  };
896
820
  };