@eeacms/volto-tabs-block 8.1.0 → 9.0.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +42 -3
  2. package/locales/de/LC_MESSAGES/volto.po +187 -182
  3. package/locales/en/LC_MESSAGES/volto.po +187 -182
  4. package/locales/es/LC_MESSAGES/volto.po +189 -184
  5. package/locales/it/LC_MESSAGES/volto.po +187 -182
  6. package/locales/pt_BR/LC_MESSAGES/volto.po +187 -182
  7. package/locales/ro/LC_MESSAGES/volto.po +187 -182
  8. package/locales/volto.pot +189 -184
  9. package/package.json +1 -1
  10. package/src/components/Edit.jsx +7 -7
  11. package/src/components/View.jsx +7 -7
  12. package/src/components/index.js +4 -4
  13. package/src/components/{templates → variations}/accordion/Edit.jsx +2 -2
  14. package/src/components/{templates → variations}/accordion/View.jsx +4 -1
  15. package/src/components/{templates → variations}/carousel/HorizontalView.jsx +1 -1
  16. package/src/components/{templates → variations}/carousel/VerticalView.jsx +1 -1
  17. package/src/components/{templates → variations}/default/Edit.jsx +1 -1
  18. package/src/components/{templates → variations}/horizontal-responsive/Edit.jsx +1 -1
  19. package/src/helpers.js +17 -1
  20. /package/src/components/{templates → variations}/accordion/index.js +0 -0
  21. /package/src/components/{templates → variations}/accordion/schema.js +0 -0
  22. /package/src/components/{templates → variations}/carousel/index.js +0 -0
  23. /package/src/components/{templates → variations}/carousel/schema.js +0 -0
  24. /package/src/components/{templates → variations}/default/View.jsx +0 -0
  25. /package/src/components/{templates → variations}/default/index.js +0 -0
  26. /package/src/components/{templates → variations}/default/schema.js +0 -0
  27. /package/src/components/{templates → variations}/horizontal-responsive/View.jsx +0 -0
  28. /package/src/components/{templates → variations}/horizontal-responsive/index.js +0 -0
  29. /package/src/components/{templates → variations}/horizontal-responsive/schema.js +0 -0
@@ -12,7 +12,8 @@ import { TABS_BLOCK } from '@eeacms/volto-tabs-block/constants';
12
12
  import { empty, emptyTab } from '@eeacms/volto-tabs-block/helpers';
13
13
  import { StyleWrapperView } from '@eeacms/volto-block-style/StyleWrapper';
14
14
  import { BlockStyleWrapperEdit } from '@eeacms/volto-block-style/BlockStyleWrapper';
15
- import { DefaultEdit } from './templates/default';
15
+ import { getVariation } from '@eeacms/volto-tabs-block/helpers';
16
+ import { DefaultEdit } from './variations/default';
16
17
  import { useIntl } from 'react-intl';
17
18
 
18
19
  import '@eeacms/volto-tabs-block/less/edit.less';
@@ -23,7 +24,7 @@ const Edit = (props) => {
23
24
  const intl = useIntl();
24
25
  const { onChangeBlock, onChangeField } = props;
25
26
  const { data = {}, block = null } = props;
26
- const template = data.variation || 'default';
27
+ const variation = getVariation(data);
27
28
  const tabsData = data.data || {};
28
29
  const tabsList = tabsData.blocks_layout?.items || [];
29
30
  const tabs = tabsData.blocks || {};
@@ -38,11 +39,11 @@ const Edit = (props) => {
38
39
  const verticalAlign = data.verticalAlign || 'flex-start';
39
40
  const tabsBlockConfig = config.blocks.blocksConfig[TABS_BLOCK];
40
41
 
41
- const activeTemplate = config.blocks.blocksConfig[
42
+ const activeVariation = config.blocks.blocksConfig[
42
43
  TABS_BLOCK
43
- ].variations.filter((v, _i) => v.id === template);
44
+ ].variations.filter((v, _i) => v.id === variation);
44
45
 
45
- const TabsEdit = activeTemplate?.[0]?.edit || DefaultEdit;
46
+ const TabsEdit = activeVariation?.[0]?.edit || DefaultEdit;
46
47
 
47
48
  const schemaObject = tabsBlockConfig.blockSchema(props);
48
49
 
@@ -168,7 +169,7 @@ const Edit = (props) => {
168
169
  Tabs
169
170
  </legend>
170
171
  <div
171
- className={cx('tabs-block edit', theme, verticalAlign, template)}
172
+ className={cx('tabs-block edit', theme, verticalAlign, variation)}
172
173
  ref={view}
173
174
  role="presentation"
174
175
  onKeyDown={(e) => {
@@ -200,7 +201,6 @@ const Edit = (props) => {
200
201
  tabsData={tabsData}
201
202
  tabsList={tabsList}
202
203
  node={view}
203
- template={template}
204
204
  onChangeTabData={onChangeTabData}
205
205
  onSelectBlock={onSelectBlock}
206
206
  setActiveBlock={setActiveBlock}
@@ -5,10 +5,11 @@ import { withRouter } from 'react-router';
5
5
  import { StyleWrapperView } from '@eeacms/volto-block-style/StyleWrapper';
6
6
  import { TABS_BLOCK } from '@eeacms/volto-tabs-block/constants';
7
7
  import {
8
+ getVariation,
8
9
  isTabEmpty,
9
10
  getParentTabFromHash,
10
11
  } from '@eeacms/volto-tabs-block/helpers';
11
- import { DefaultView } from './templates/default';
12
+ import { DefaultView } from './variations/default';
12
13
  import { withScrollToTarget } from '@eeacms/volto-tabs-block/hocs';
13
14
 
14
15
  import config from '@plone/volto/registry';
@@ -20,7 +21,7 @@ const View = (props) => {
20
21
  const view = React.useRef(null);
21
22
  const { data = {}, uiContainer = '', location, history } = props;
22
23
  const metadata = props.metadata || props.properties;
23
- const template = data.variation || 'default';
24
+ const variation = getVariation(data);
24
25
  const tabsData = data.data || {};
25
26
  const tabs = tabsData.blocks || {};
26
27
  const tabsList = (tabsData.blocks_layout?.items || []).filter((tab) => {
@@ -32,11 +33,11 @@ const View = (props) => {
32
33
  const theme = data.theme || 'light';
33
34
  const verticalAlign = data.verticalAlign || 'flex-start';
34
35
 
35
- const activeTemplate = config.blocks.blocksConfig[
36
+ const activeVariation = config.blocks.blocksConfig[
36
37
  TABS_BLOCK
37
- ].variations.filter((v, _i) => v.id === template);
38
+ ].variations.filter((v, _i) => v.id === variation);
38
39
 
39
- const TabsView = activeTemplate?.[0]?.view || DefaultView;
40
+ const TabsView = activeVariation?.[0]?.view || DefaultView;
40
41
 
41
42
  const query = React.useMemo(() => {
42
43
  const { search } = location;
@@ -95,7 +96,7 @@ const View = (props) => {
95
96
  styled={true}
96
97
  >
97
98
  <div
98
- className={cx('tabs-block', template, theme, verticalAlign)}
99
+ className={cx('tabs-block', variation, theme, verticalAlign)}
99
100
  id={props.id}
100
101
  ref={view}
101
102
  >
@@ -117,7 +118,6 @@ const View = (props) => {
117
118
  tabData={tabData}
118
119
  tabsData={tabsData}
119
120
  tabsList={tabsList}
120
- template={template}
121
121
  uiContainer={uiContainer}
122
122
  setActiveTab={handleActiveTabChange}
123
123
  />
@@ -7,7 +7,7 @@ export { TabsEdit, TabsView };
7
7
  export { layoutSchema };
8
8
 
9
9
  export * from './schema';
10
- export * from './templates/default';
11
- export * from './templates/accordion';
12
- export * from './templates/horizontal-responsive';
13
- export * from './templates/carousel';
10
+ export * from './variations/default';
11
+ export * from './variations/accordion';
12
+ export * from './variations/horizontal-responsive';
13
+ export * from './variations/carousel';
@@ -1,5 +1,5 @@
1
- import Edit from '@eeacms/volto-tabs-block/components/templates/default/Edit';
2
- import { accordionSchemaEnhancer } from '@eeacms/volto-tabs-block/components/templates/accordion/schema';
1
+ import Edit from '@eeacms/volto-tabs-block/components/variations/default/Edit';
2
+ import { accordionSchemaEnhancer } from '@eeacms/volto-tabs-block/components/variations/accordion/schema';
3
3
  import cx from 'classnames';
4
4
 
5
5
  const AccordionEdit = (props) => {
@@ -17,6 +17,7 @@ import { getParentTabFromHash } from '@eeacms/volto-tabs-block/helpers';
17
17
  import { withScrollToTarget } from '@eeacms/volto-tabs-block/hocs';
18
18
 
19
19
  import '@eeacms/volto-tabs-block/less/menu.less';
20
+ import { getVariation } from '../../../helpers';
20
21
 
21
22
  class Tab extends React.Component {
22
23
  render() {
@@ -39,9 +40,11 @@ const View = (props) => {
39
40
  id,
40
41
  } = props;
41
42
 
43
+ const variation = getVariation(data);
44
+
42
45
  const accordionConfig = config.blocks.blocksConfig[
43
46
  TABS_BLOCK
44
- ].variations.filter((v, _i) => v.id === data.variation);
47
+ ].variations.filter((v, _i) => v.id === variation);
45
48
  const {
46
49
  icons,
47
50
  semanticIcon,
@@ -6,7 +6,7 @@ import { Icon, RenderBlocks } from '@plone/volto/components';
6
6
 
7
7
  import rightArrowSVG from '@eeacms/volto-tabs-block/icons/right-key.svg';
8
8
  import leftArrowSVG from '@eeacms/volto-tabs-block/icons/left-key.svg';
9
- import { carouselSchemaEnhancer } from '@eeacms/volto-tabs-block/components/templates/carousel/schema';
9
+ import { carouselSchemaEnhancer } from '@eeacms/volto-tabs-block/components/variations/carousel/schema';
10
10
 
11
11
  import 'slick-carousel/slick/slick.css';
12
12
  import 'slick-carousel/slick/slick-theme.css';
@@ -6,7 +6,7 @@ import { RenderBlocks } from '@plone/volto/components';
6
6
  import 'slick-carousel/slick/slick.css';
7
7
  import 'slick-carousel/slick/slick-theme.css';
8
8
  import '@eeacms/volto-tabs-block/less/carousel.less';
9
- import { carouselSchemaEnhancer } from '@eeacms/volto-tabs-block/components/templates/carousel/schema';
9
+ import { carouselSchemaEnhancer } from '@eeacms/volto-tabs-block/components/variations/carousel/schema';
10
10
 
11
11
  const Slider = loadable(() => import('react-slick'));
12
12
 
@@ -7,7 +7,7 @@ import { Menu, Tab, Input, Container } from 'semantic-ui-react';
7
7
  import { BlocksForm } from '@plone/volto/components';
8
8
  import { emptyBlocksForm } from '@plone/volto/helpers';
9
9
  import EditBlockWrapper from '@eeacms/volto-tabs-block/components/EditBlockWrapper';
10
- import { defaultSchemaEnhancer } from '@eeacms/volto-tabs-block/components/templates/default/schema';
10
+ import { defaultSchemaEnhancer } from '@eeacms/volto-tabs-block/components/variations/default/schema';
11
11
  import { AssetTab } from '@eeacms/volto-tabs-block/components';
12
12
  import {
13
13
  SimpleMarkdown,
@@ -10,7 +10,7 @@ import { Menu, Tab, Container, Dropdown, Input } from 'semantic-ui-react';
10
10
  import { emptyBlocksForm } from '@plone/volto/helpers';
11
11
  import { BlocksForm } from '@plone/volto/components';
12
12
  import EditBlockWrapper from '@eeacms/volto-tabs-block/components/EditBlockWrapper';
13
- import { defaultSchemaEnhancer } from '@eeacms/volto-tabs-block/components/templates/default/schema';
13
+ import { defaultSchemaEnhancer } from '@eeacms/volto-tabs-block/components/variations/default/schema';
14
14
  import {
15
15
  SimpleMarkdown,
16
16
  getMenuPosition,
package/src/helpers.js CHANGED
@@ -4,9 +4,25 @@ import {
4
4
  applySchemaDefaults,
5
5
  getBlocksFieldname,
6
6
  getBlocksLayoutFieldname,
7
+ blockHasValue,
7
8
  } from '@plone/volto/helpers';
8
9
  import { visitBlocks, toSlug } from '@eeacms/volto-anchors/helpers';
9
10
 
11
+ const variationsMapping = {
12
+ carousel: 'carousel-horizontal',
13
+ carousel_vertical: 'carousel-vertical',
14
+ };
15
+
16
+ export const getVariation = (data) => {
17
+ const { variation, template } = data;
18
+ return (
19
+ variationsMapping[variation || template] ||
20
+ variation ||
21
+ template ||
22
+ 'default'
23
+ );
24
+ };
25
+
10
26
  export const empty = ({ schema, intl }) => {
11
27
  const tabId = uuid();
12
28
  const data = {
@@ -71,7 +87,7 @@ export const isTabEmpty = (content) => {
71
87
  if (blocksNo === 1) {
72
88
  const blockId = content[blocks_layout_field].items[0];
73
89
  const block = blocks[blockId];
74
- if (block['@type'] === 'slate' && !block['plaintext']) {
90
+ if (!blockHasValue(block)) {
75
91
  return true;
76
92
  }
77
93
  }