@eightshift/frontend-libs-tailwind 1.1.1 → 1.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.
Files changed (59) hide show
  1. package/.prettierrc +1 -1
  2. package/CHANGELOG.md +16 -1
  3. package/blocks/init/assets/scripts/application-admin.js +1 -1
  4. package/blocks/init/src/Blocks/assets/scripts/link-section-editor.js +5 -1
  5. package/blocks/init/src/Blocks/assets/scripts/shared.js +3 -1
  6. package/blocks/init/src/Blocks/assets/styles/application-blocks.css +1 -0
  7. package/blocks/init/src/Blocks/components/button/button.php +6 -0
  8. package/blocks/init/src/Blocks/components/button/components/button-options.js +20 -2
  9. package/blocks/init/src/Blocks/components/card/components/card-editor.js +2 -1
  10. package/blocks/init/src/Blocks/components/icon/icon.php +3 -1
  11. package/blocks/init/src/Blocks/components/image/components/image-editor.js +7 -1
  12. package/blocks/init/src/Blocks/components/image/components/image-options.js +17 -3
  13. package/blocks/init/src/Blocks/components/list/components/list-options.js +3 -1
  14. package/blocks/init/src/Blocks/components/list/manifest.json +1 -1
  15. package/blocks/init/src/Blocks/components/modal/assets/index.js +9 -7
  16. package/blocks/init/src/Blocks/components/paragraph/components/paragraph-editor.js +1 -1
  17. package/blocks/init/src/Blocks/components/paragraph/components/paragraph-options.js +3 -1
  18. package/blocks/init/src/Blocks/components/share/assets/index.js +6 -2
  19. package/blocks/init/src/Blocks/components/share/components/share-options.js +11 -2
  20. package/blocks/init/src/Blocks/components/share/share.php +7 -4
  21. package/blocks/init/src/Blocks/components/video/components/video-editor.js +5 -3
  22. package/blocks/init/src/Blocks/components/video/components/video-options.js +25 -4
  23. package/blocks/init/src/Blocks/components/video/manifest.json +5 -1
  24. package/blocks/init/src/Blocks/custom/carousel/assets/pagination.js +8 -2
  25. package/blocks/init/src/Blocks/custom/column/components/column-options.js +12 -4
  26. package/blocks/init/src/Blocks/custom/columns/components/columns-editor.js +6 -2
  27. package/blocks/init/src/Blocks/custom/columns/manifest.json +63 -37
  28. package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-options.js +29 -8
  29. package/blocks/init/src/Blocks/custom/image/manifest.json +4 -76
  30. package/blocks/init/src/Blocks/custom/map/components/map-editor.js +12 -2
  31. package/blocks/init/src/Blocks/custom/map/components/map-options.js +40 -11
  32. package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-options.js +3 -1
  33. package/blocks/init/src/Blocks/custom/site-footer/site-footer.php +5 -3
  34. package/blocks/init/src/Blocks/custom/video/manifest.json +0 -76
  35. package/blocks/init/src/Blocks/wrapper/components/wrapper-options.js +38 -7
  36. package/blocks/init/src/Blocks/wrapper/manifest.json +4 -1
  37. package/bun.lockb +0 -0
  38. package/package.json +27 -27
  39. package/schemas/block.json +16 -16
  40. package/schemas/component.json +18 -18
  41. package/scripts/components/block-inserter.js +4 -1
  42. package/scripts/components/file-picker.js +31 -17
  43. package/scripts/components/link-section-editor.js +5 -1
  44. package/scripts/components/media-picker.js +36 -11
  45. package/scripts/components/picker-placeholder.js +6 -2
  46. package/scripts/components/server-side-render.js +4 -1
  47. package/scripts/components/settings/settings.js +8 -2
  48. package/scripts/editor/attributes.js +8 -3
  49. package/scripts/editor/editor.js +7 -1
  50. package/scripts/editor/fetch.js +3 -2
  51. package/scripts/editor/index.js +8 -1
  52. package/scripts/editor/options.js +3 -1
  53. package/scripts/editor/registration.js +87 -17
  54. package/scripts/editor/tailwindcss.js +96 -58
  55. package/scripts/helpers/index.js +7 -1
  56. package/scripts/index.js +15 -2
  57. package/webpack/base.mjs +3 -1
  58. package/webpack/helpers.mjs +13 -3
  59. package/webpack/project.mjs +8 -2
package/.prettierrc CHANGED
@@ -6,7 +6,7 @@
6
6
  "jsxSingleQuote": true,
7
7
  "singleQuote": true,
8
8
  "singleAttributePerLine": true,
9
- "printWidth": 180,
9
+ "printWidth": 120,
10
10
  "arrowParens": "always",
11
11
  "bracketSpacing": true,
12
12
  "semi": true,
package/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).
6
6
 
7
+ ## [1.3.0] - 2024-08-08
8
+ - `twClasses` and `twClassesEditor` can now be passed as an array
9
+ - Updated schemas to account for the `twClasses`/`twClassesEditor` changes.
10
+ - Tailwind output functions will now output the custom classes if no Tailwind classes are in the output.
11
+ - Tweaked Prettier config.
12
+ - Updated dependencies.
13
+
14
+ ## [1.2.0] - 2024-08-08
15
+ - Fixed default `perPage` param in `wpSearchRoute`.
16
+ - Updated image and file pickers with support for `hidden` prop and accepted types passthrough.
17
+ - Fixed some reported bugs in a couple of built-in blocks.
18
+ - Updated dependencies.
19
+
7
20
  ## [1.1.1] - 2024-07-11
8
21
  - Fixed default global manifest.
9
22
  - Removed erroneous styles.
@@ -22,11 +35,13 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a
22
35
  - Added `PickerPlaceholder` component.
23
36
  - Added option for dynamic parts and the `getTwDynamicPart` helper.
24
37
 
25
- ## [1.0.0] - 2024-06
38
+ ## [1.0.0] - 2024-06-17
26
39
  - Initial release.
27
40
 
28
41
  [Unreleased]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/master...HEAD
29
42
 
43
+ [1.3.0]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.2.0...1.3.0
44
+ [1.2.0]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.1.1...1.2.0
30
45
  [1.1.1]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.1.0...1.1.1
31
46
  [1.1.0]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.0.0...1.1.0
32
47
  [1.0.0]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/0.0.1...1.0.0
@@ -4,4 +4,4 @@
4
4
 
5
5
  import { dynamicImport } from '@eightshift/frontend-libs-tailwind/scripts/helpers';
6
6
 
7
- dynamicImport(require.context('./../../src/blocks/components', true, /assets-admin\/index\.js$/));
7
+ dynamicImport(require.context('./../../src/Blocks/components', true, /assets-admin\/index\.js$/));
@@ -175,7 +175,11 @@ export const LinkSectionEditor = (props) => {
175
175
  setTimeout(() => {
176
176
  target.parentElement.nextElementSibling?.querySelector('[contenteditable="true"]')?.focus();
177
177
  }, 25);
178
- } else if (code === 'Backspace' && header === '' && (items?.length < 1 || items?.every(({ text }) => text === ''))) {
178
+ } else if (
179
+ code === 'Backspace' &&
180
+ header === '' &&
181
+ (items?.length < 1 || items?.every(({ text }) => text === ''))
182
+ ) {
179
183
  event.preventDefault();
180
184
 
181
185
  // Jump to end of previous input.
@@ -5,7 +5,9 @@ const colorData = getColorData(themeColors);
5
5
 
6
6
  export const getColorOption = (key, manifest) => {
7
7
  if (!manifest?.options?.[key]) {
8
- throw new Error(`The key ${key} is not defined in the manifest options for ${manifest?.componentName ?? manifest?.title}.`);
8
+ throw new Error(
9
+ `The key ${key} is not defined in the manifest options for ${manifest?.componentName ?? manifest?.title}.`,
10
+ );
9
11
  }
10
12
 
11
13
  return colorData?.filter(({ slug }) => manifest?.options?.[key]?.includes(slug)) ?? [];
@@ -0,0 +1 @@
1
+ @import './fonts.css';
@@ -27,8 +27,14 @@ $buttonContent = Helpers::checkAttr('buttonContent', $attributes, $manifest);
27
27
 
28
28
  $buttonAriaLabel = Helpers::checkAttr('buttonAriaLabel', $attributes, $manifest);
29
29
 
30
+ $buttonIconUse = Helpers::checkAttr('buttonIconUse', $attributes, $manifest);
31
+
30
32
  $buttonAttrs = [];
31
33
 
34
+ if (!$buttonIconUse && empty($buttonContent)) {
35
+ return;
36
+ }
37
+
32
38
  if (!empty($additionalAttributes)) {
33
39
  $buttonAttrs = $additionalAttributes;
34
40
  }
@@ -1,7 +1,25 @@
1
1
  import { __ } from '@wordpress/i18n';
2
- import { getOption, checkAttr, getAttrKey, props, getOptions, wpSearchRoute, getHiddenOptions } from '@eightshift/frontend-libs-tailwind/scripts';
2
+ import {
3
+ getOption,
4
+ checkAttr,
5
+ getAttrKey,
6
+ props,
7
+ getOptions,
8
+ wpSearchRoute,
9
+ getHiddenOptions,
10
+ } from '@eightshift/frontend-libs-tailwind/scripts';
3
11
  import { IconOptions } from '../../icon/components/icon-options';
4
- import { ButtonGroup, ColorPicker, ComponentToggle, HStack, InputField, LinkInput, OptionSelect, Spacer, Toggle } from '@eightshift/ui-components';
12
+ import {
13
+ ButtonGroup,
14
+ ColorPicker,
15
+ ComponentToggle,
16
+ HStack,
17
+ InputField,
18
+ LinkInput,
19
+ OptionSelect,
20
+ Spacer,
21
+ Toggle,
22
+ } from '@eightshift/ui-components';
5
23
  import { icons } from '@eightshift/ui-components/icons';
6
24
  import { upperFirst } from '@eightshift/ui-components/utilities';
7
25
  import manifest from './../manifest.json';
@@ -15,7 +15,8 @@ export const CardEditor = (attributes) => {
15
15
  additionalClass: {
16
16
  image: getTwPart('image', manifest),
17
17
  picture: getTwPart('imagePicture', manifest),
18
- imagePlaceholder: '!border-x-0 !border-t-0 !border-solid !w-full !h-auto aspect-3/2 [&_svg]:!size-12 border-b !rounded-none bg-gray-100 !border-b-gray-200',
18
+ imagePlaceholder:
19
+ '!border-x-0 !border-t-0 !border-solid !w-full !h-auto aspect-3/2 [&_svg]:!size-12 border-b !rounded-none bg-gray-100 !border-b-gray-200',
19
20
  },
20
21
  })}
21
22
  />
@@ -28,7 +28,9 @@ $icon = $manifest['icons'][$iconName];
28
28
 
29
29
  $className = Helpers::getTwClasses($attributes, $manifest, $additionalClass);
30
30
 
31
- $icon = str_replace('<svg ', "<svg class=\"{$className}\"", $icon);
31
+ if (!empty($className)) {
32
+ $icon = str_replace('<svg ', '<svg class="' . htmlspecialchars($className) . '" ', $icon);
33
+ }
32
34
 
33
35
  // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped
34
36
  echo $icon;
@@ -1,4 +1,10 @@
1
- import { checkAttr, getBreakpointData, getBreakpointNames, getTwClasses, getTwPart } from '@eightshift/frontend-libs-tailwind/scripts';
1
+ import {
2
+ checkAttr,
3
+ getBreakpointData,
4
+ getBreakpointNames,
5
+ getTwClasses,
6
+ getTwPart,
7
+ } from '@eightshift/frontend-libs-tailwind/scripts';
2
8
  import { ImagePlaceholder } from '@eightshift/ui-components';
3
9
  import manifest from './../manifest.json';
4
10
 
@@ -1,5 +1,13 @@
1
1
  import { __ } from '@wordpress/i18n';
2
- import { checkAttr, getAttrKey, MediaPicker, generateOptionsFromValue, getOption, getHiddenOptions, getResponsiveData } from '@eightshift/frontend-libs-tailwind/scripts';
2
+ import {
3
+ checkAttr,
4
+ getAttrKey,
5
+ MediaPicker,
6
+ generateOptionsFromValue,
7
+ getOption,
8
+ getHiddenOptions,
9
+ getResponsiveData,
10
+ } from '@eightshift/frontend-libs-tailwind/scripts';
3
11
  import manifest from './../manifest.json';
4
12
  import { ComponentToggle, OptionSelect, Responsive, Spacer, Toggle } from '@eightshift/ui-components';
5
13
  import { icons } from '@eightshift/ui-components/icons';
@@ -33,7 +41,11 @@ export const ImageOptions = (attributes) => {
33
41
  icon={icons.imageFile}
34
42
  label={__('Image', 'eightshift-ui-components')}
35
43
  options={generateOptionsFromValue(imageData, (v) =>
36
- truncateMiddle(v?.url?.replace(window.location.origin, '')?.replace(/\/wp-content\/uploads\/\d{4}\/\d{2}\//g, '') ?? __('Not set', '%g_textdomain%'), 15),
44
+ truncateMiddle(
45
+ v?.url?.replace(window.location.origin, '')?.replace(/\/wp-content\/uploads\/\d{4}\/\d{2}\//g, '') ??
46
+ __('Not set', '%g_textdomain%'),
47
+ 15,
48
+ ),
37
49
  )}
38
50
  hidden={hiddenOptions?.imagePicker}
39
51
  {...responsiveData}
@@ -86,7 +98,9 @@ export const ImageOptions = (attributes) => {
86
98
  icon={icons.expandXl}
87
99
  label={__('Stretch', '%g_textdomain%')}
88
100
  checked={imageSize === 'stretch'}
89
- onChange={(value) => setAttributes({ [getAttrKey('imageSize', attributes, manifest)]: value ? 'stretch' : 'default' })}
101
+ onChange={(value) =>
102
+ setAttributes({ [getAttrKey('imageSize', attributes, manifest)]: value ? 'stretch' : 'default' })
103
+ }
90
104
  hidden={hiddenOptions?.stretch}
91
105
  />
92
106
 
@@ -35,7 +35,9 @@ export const ListOptions = (attributes) => {
35
35
  <ToggleButton
36
36
  selected={listFontWeight === '700'}
37
37
  icon={icons.bold}
38
- onChange={(value) => setAttributes({ [getAttrKey('listFontWeight', attributes, manifest)]: value ? '700' : '400' })}
38
+ onChange={(value) =>
39
+ setAttributes({ [getAttrKey('listFontWeight', attributes, manifest)]: value ? '700' : '400' })
40
+ }
39
41
  tooltip={__('Bold', '%g_textdomain%')}
40
42
  hidden={hiddenOptions.weight}
41
43
  />
@@ -91,7 +91,7 @@
91
91
  },
92
92
  "tailwind": {
93
93
  "base": {
94
- "twClasses": "font-sans [&>a]:underline font-synthesis-none",
94
+ "twClasses": "font-sans [&_a]:underline font-synthesis-none",
95
95
  "twClassesEditor": "font-sans [&>a]:underline font-synthesis-none"
96
96
  },
97
97
  "options": {
@@ -11,15 +11,17 @@ domReady(() => {
11
11
  }
12
12
 
13
13
  elements.forEach((element) => {
14
- document.querySelectorAll(`[href=":open-modal-${element.id}:"],[data-micromodal-trigger="${element.id}"]`).forEach((trigger) => {
15
- trigger.addEventListener('click', (event) => {
16
- event.preventDefault();
14
+ document
15
+ .querySelectorAll(`[href=":open-modal-${element.id}:"],[data-micromodal-trigger="${element.id}"]`)
16
+ .forEach((trigger) => {
17
+ trigger.addEventListener('click', (event) => {
18
+ event.preventDefault();
17
19
 
18
- MicroModal.show(element.id, {
19
- disableScroll: true,
20
- awaitCloseAnimation: true,
20
+ MicroModal.show(element.id, {
21
+ disableScroll: true,
22
+ awaitCloseAnimation: true,
23
+ });
21
24
  });
22
25
  });
23
- });
24
26
  });
25
27
  });
@@ -34,7 +34,7 @@ export const ParagraphEditor = (attributes) => {
34
34
  onMerge={mergeBlocks}
35
35
  onReplace={onReplace}
36
36
  onRemove={onRemove}
37
- deleteEnter={true}
37
+ deleteEnter
38
38
  />
39
39
  );
40
40
  };
@@ -34,7 +34,9 @@ export const ParagraphOptions = (attributes) => {
34
34
  <ToggleButton
35
35
  selected={paragraphFontWeight === '700'}
36
36
  icon={icons.bold}
37
- onChange={(value) => setAttributes({ [getAttrKey('paragraphFontWeight', attributes, manifest)]: value ? '700' : '400' })}
37
+ onChange={(value) =>
38
+ setAttributes({ [getAttrKey('paragraphFontWeight', attributes, manifest)]: value ? '700' : '400' })
39
+ }
38
40
  tooltip={__('Bold', '%g_textdomain%')}
39
41
  hidden={hiddenOptions.weight}
40
42
  />
@@ -2,7 +2,7 @@ import domReady from '@wordpress/dom-ready';
2
2
  import manifest from '../manifest.json';
3
3
 
4
4
  domReady(async () => {
5
- const shareTargets = document.querySelectorAll(`.${manifest.componentJsClass}`);
5
+ const shareTargets = document.querySelectorAll(`.${manifest.componentJsClass}[data-mode='share']`);
6
6
 
7
7
  if (shareTargets.length < 1) {
8
8
  return;
@@ -17,7 +17,11 @@ domReady(async () => {
17
17
  if ('share' in navigator && navigator?.canShare(navigatorShareData)) {
18
18
  await navigator?.share(navigatorShareData);
19
19
  } else {
20
- window.open(shareUrl, 'share-post', 'height=600,width=800,left=0,top=0,location=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1');
20
+ window.open(
21
+ shareUrl,
22
+ 'share-post',
23
+ 'height=600,width=800,left=0,top=0,location=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1',
24
+ );
21
25
  }
22
26
  };
23
27
 
@@ -1,7 +1,14 @@
1
1
  import { __ } from '@wordpress/i18n';
2
2
  import { checkAttr, getAttrKey, getHiddenOptions } from '@eightshift/frontend-libs-tailwind/scripts';
3
3
  import manifest from '../manifest.json';
4
- import { ComponentToggle, OptionSelect, DraggableList, DraggableListItem, Spacer, Switch } from '@eightshift/ui-components';
4
+ import {
5
+ ComponentToggle,
6
+ OptionSelect,
7
+ DraggableList,
8
+ DraggableListItem,
9
+ Spacer,
10
+ Switch,
11
+ } from '@eightshift/ui-components';
5
12
  import { icons, JsxSvg } from '@eightshift/ui-components/icons';
6
13
 
7
14
  export const ShareOptions = (attributes) => {
@@ -36,7 +43,9 @@ export const ShareOptions = (attributes) => {
36
43
  },
37
44
  ];
38
45
 
39
- const pickerSectionTitle = shareMode ? __('Share targets', '%g_textdomain%') : __('Social networks', '%g_textdomain%');
46
+ const pickerSectionTitle = shareMode
47
+ ? __('Share targets', '%g_textdomain%')
48
+ : __('Social networks', '%g_textdomain%');
40
49
 
41
50
  return (
42
51
  <ComponentToggle
@@ -22,9 +22,12 @@ $shareMode = Helpers::checkAttr('shareMode', $attributes, $manifest);
22
22
  $additionalClass = $attributes['additionalClass'] ?? '';
23
23
 
24
24
  ?>
25
- <div class="<?php echo esc_attr(Helpers::getTwPart('container', $manifest, $additionalClass)); ?>">
25
+ <div
26
+ class="<?php echo esc_attr(Helpers::getTwPart('container', $manifest, $additionalClass, $manifest['componentJsClass'])); ?>"
27
+ data-mode="<?php echo esc_attr($shareMode); ?>"
28
+ >
26
29
  <?php
27
- if ($shareMode) {
30
+ if ($shareMode === 'share') {
28
31
  foreach ($shareTargets as $networkName) {
29
32
  $shareUrl = $manifest['networks'][$networkName]['shareUrl'] ?? '';
30
33
  $shareUrl = str_replace('POST_TITLE', get_the_title(), $shareUrl);
@@ -32,7 +35,7 @@ $additionalClass = $attributes['additionalClass'] ?? '';
32
35
  $shareUrl = str_replace('POST_FEATURED_IMAGE', get_the_post_thumbnail_url(get_the_ID(), 'large'), $shareUrl);
33
36
  ?>
34
37
  <button
35
- class="<?php echo esc_attr(Helpers::getTwPart('icon', $manifest)); ?>"
38
+ class="<?php echo esc_attr(Helpers::getTwPart('icon', $manifest, "{$manifest['componentJsClass']}-link")); ?>"
36
39
  data-network="<?php echo esc_attr($networkName); ?>"
37
40
  data-share-url="<?php echo esc_url($shareUrl); ?>"
38
41
  data-page-title="<?php echo esc_attr(get_the_title()); ?>"
@@ -44,7 +47,7 @@ $additionalClass = $attributes['additionalClass'] ?? '';
44
47
  ?>
45
48
  </button>
46
49
  <?php }
47
- } else {
50
+ } elseif ($shareMode === 'links') {
48
51
  foreach ($shareTargets as $networkName) {
49
52
  ?>
50
53
  <a
@@ -34,10 +34,11 @@ export const VideoEditor = (attributes) => {
34
34
  setAttributes({
35
35
  [getAttrKey('videoId', attributes, manifest)]: id,
36
36
  [getAttrKey('videoUrl', attributes, manifest)]: url,
37
- [getAttrKey('videoMimeType', attributes, manifest)]: typeof mime === 'undefined' ? mime_type : mime,
37
+ [getAttrKey('videoMimeType', attributes, manifest)]:
38
+ typeof mime === 'undefined' ? mime_type : mime,
38
39
  })
39
40
  }
40
- allowedTypes={['video/mp4', 'video/webm']}
41
+ allowedTypes={manifest.allowedTypes}
41
42
  kind='video'
42
43
  />
43
44
 
@@ -47,7 +48,8 @@ export const VideoEditor = (attributes) => {
47
48
  setAttributes({
48
49
  [getAttrKey('videoId', attributes, manifest)]: id,
49
50
  [getAttrKey('videoUrl', attributes, manifest)]: url,
50
- [getAttrKey('videoMimeType', attributes, manifest)]: typeof mime === 'undefined' ? mime_type : mime,
51
+ [getAttrKey('videoMimeType', attributes, manifest)]:
52
+ typeof mime === 'undefined' ? mime_type : mime,
51
53
  })
52
54
  }
53
55
  allowedTypes={['video/mp4', 'video/webm']}
@@ -1,6 +1,24 @@
1
1
  import { __, sprintf } from '@wordpress/i18n';
2
- import { getOption, checkAttr, getAttrKey, FileSelector, getHiddenOptions, MediaPicker } from '@eightshift/frontend-libs-tailwind/scripts';
3
- import { AnimatedVisibility, BaseControl, Expandable, InputField, Notice, OptionSelect, Repeater, RepeaterItem, Spacer, Toggle } from '@eightshift/ui-components';
2
+ import {
3
+ getOption,
4
+ checkAttr,
5
+ getAttrKey,
6
+ FileSelector,
7
+ getHiddenOptions,
8
+ MediaPicker,
9
+ } from '@eightshift/frontend-libs-tailwind/scripts';
10
+ import {
11
+ AnimatedVisibility,
12
+ BaseControl,
13
+ Expandable,
14
+ InputField,
15
+ Notice,
16
+ OptionSelect,
17
+ Repeater,
18
+ RepeaterItem,
19
+ Spacer,
20
+ Toggle,
21
+ } from '@eightshift/ui-components';
4
22
  import { icons } from '@eightshift/ui-components/icons';
5
23
  import manifest from '../manifest.json';
6
24
 
@@ -58,7 +76,7 @@ export const VideoOptions = (attributes) => {
58
76
  }
59
77
  fileId={videoId}
60
78
  fileName={videoUrl?.slice(videoUrl?.lastIndexOf('/') + 1)}
61
- allowedTypes={['video/mp4', 'video/webm']}
79
+ allowedTypes={manifest.allowedTypes}
62
80
  kind='video'
63
81
  />
64
82
 
@@ -109,7 +127,10 @@ export const VideoOptions = (attributes) => {
109
127
  <Notice
110
128
  type='warning'
111
129
  label={__('Video plays automatically, with sound, and without controls', '%g_textdomain%')}
112
- subtitle={__('This will bother most users and is an accessibility issue. Consider changing some of the options.', '%g_textdomain%')}
130
+ subtitle={__(
131
+ 'This will bother most users and is an accessibility issue. Consider changing some of the options.',
132
+ '%g_textdomain%',
133
+ )}
113
134
  icon={icons.a11yWarning}
114
135
  alignIconToTitle
115
136
  />
@@ -112,5 +112,9 @@
112
112
  "twClasses": "aspect-video w-full rounded-xl border border-gray-800 bg-gradient-to-br from-gray-800 to-black shadow-md"
113
113
  }
114
114
  }
115
- }
115
+ },
116
+ "allowedTypes": [
117
+ "video/mp4",
118
+ "video/webm"
119
+ ]
116
120
  }
@@ -8,7 +8,8 @@ export const addPagination = (emblaApi, dotsNode) => {
8
8
 
9
9
  dotNodes = emblaApi.scrollSnapList().map((_, index) => {
10
10
  const elem = document.createElement('button');
11
- elem.className = 'size-2.5 rounded-full border border-gray-500 transition hover:scale-105 focus:outline-none focus-visible:ring focus-visible:ring-navy-500/30';
11
+ elem.className =
12
+ 'size-2.5 rounded-full border border-gray-500 transition hover:scale-105 focus:outline-none focus-visible:ring focus-visible:ring-navy-500/30';
12
13
 
13
14
  elem.addEventListener('click', () => emblaApi.scrollTo(index), false);
14
15
  dotsNode.appendChild(elem);
@@ -26,7 +27,12 @@ export const addPagination = (emblaApi, dotsNode) => {
26
27
  });
27
28
  };
28
29
 
29
- emblaApi.on('init', addDots).on('reInit', addDots).on('init', toggleDotBtnsActive).on('reInit', toggleDotBtnsActive).on('select', toggleDotBtnsActive);
30
+ emblaApi
31
+ .on('init', addDots)
32
+ .on('reInit', addDots)
33
+ .on('init', toggleDotBtnsActive)
34
+ .on('reInit', toggleDotBtnsActive)
35
+ .on('select', toggleDotBtnsActive);
30
36
 
31
37
  return () => {
32
38
  dotsNode.innerHTML = '';
@@ -209,7 +209,9 @@ export const ColumnOptions = ({ attributes, setAttributes }) => {
209
209
  }
210
210
  icon={icons.gridAutoRows}
211
211
  label={__('Row span', '%g_textdomain%')}
212
- options={generateOptionsFromValue(columnRowSpan, (v) => (!v ? __('Not set', '%g_textdomain%') : sprintf(_n('1 row', '%d rows', v, '%g_textdomain%'), v)))}
212
+ options={generateOptionsFromValue(columnRowSpan, (v) =>
213
+ !v ? __('Not set', '%g_textdomain%') : sprintf(_n('1 row', '%d rows', v, '%g_textdomain%'), v),
214
+ )}
213
215
  noModeSelect
214
216
  inline
215
217
  {...responsiveData}
@@ -311,7 +313,9 @@ export const ColumnOptions = ({ attributes, setAttributes }) => {
311
313
  setAttributes({ [getAttrKey('columnBackground', attributes, manifest)]: undefined });
312
314
  } else {
313
315
  setAttributes({
314
- [getAttrKey('columnBackground', attributes, manifest)]: Object.keys(manifest.tailwind.options.columnBackground.twClasses).find((key) => key.startsWith(value)),
316
+ [getAttrKey('columnBackground', attributes, manifest)]: Object.keys(
317
+ manifest.tailwind.options.columnBackground.twClasses,
318
+ ).find((key) => key.startsWith(value)),
315
319
  });
316
320
  }
317
321
  }}
@@ -323,7 +327,9 @@ export const ColumnOptions = ({ attributes, setAttributes }) => {
323
327
  {backgroundType === 'solid' && (
324
328
  <ColorPicker
325
329
  colors={getColorOption('columnBackgroundSolid', manifest)}
326
- onChange={(value) => setAttributes({ [getAttrKey('columnBackground', attributes, manifest)]: `solid-${value}` })}
330
+ onChange={(value) =>
331
+ setAttributes({ [getAttrKey('columnBackground', attributes, manifest)]: `solid-${value}` })
332
+ }
327
333
  value={columnBackground?.replace('solid-', '')}
328
334
  aria-label={__('Background color', '%g_textdomain%')}
329
335
  />
@@ -360,7 +366,9 @@ export const ColumnOptions = ({ attributes, setAttributes }) => {
360
366
  />
361
367
  <OptionSelect
362
368
  value={columnGradientDirection}
363
- onChange={(value) => setAttributes({ [getAttrKey('columnGradientDirection', attributes, manifest)]: value })}
369
+ onChange={(value) =>
370
+ setAttributes({ [getAttrKey('columnGradientDirection', attributes, manifest)]: value })
371
+ }
364
372
  options={getOption('columnGradientDirection', attributes, manifest)}
365
373
  wrapperProps={{
366
374
  triggerIcon: <div className={rotationClassName[columnGradientDirection]}>{icons.arrowUpCircle}</div>,
@@ -10,7 +10,9 @@ import manifest from './../manifest.json';
10
10
  export const ColumnsEditor = ({ attributes, setAttributes, clientId }) => {
11
11
  const { title, layoutPresets } = manifest;
12
12
 
13
- const innerBlockCount = useSelect((select) => select('core/block-editor').getBlock(clientId).innerBlocks?.length ?? 0);
13
+ const innerBlockCount = useSelect(
14
+ (select) => select('core/block-editor').getBlock(clientId).innerBlocks?.length ?? 0,
15
+ );
14
16
 
15
17
  const blockProps = useBlockProps();
16
18
  const innerBlocksProps = useInnerBlocksProps(blockProps, {
@@ -36,7 +38,9 @@ export const ColumnsEditor = ({ attributes, setAttributes, clientId }) => {
36
38
  <Button
37
39
  key={index}
38
40
  onPress={async () => {
39
- const blocksToInsert = blockData.map(({ name: blockName, attributes: blockAttrs }) => createBlock(blockName, blockAttrs));
41
+ const blocksToInsert = blockData.map(({ name: blockName, attributes: blockAttrs }) =>
42
+ createBlock(blockName, blockAttrs),
43
+ );
40
44
 
41
45
  setAttributes(attrsToSet);
42
46