@eeacms/volto-tabs-block 5.0.8 → 6.0.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/locales/volto.pot CHANGED
@@ -1,7 +1,7 @@
1
1
  msgid ""
2
2
  msgstr ""
3
3
  "Project-Id-Version: Plone\n"
4
- "POT-Creation-Date: 2023-06-28T10:48:22.678Z\n"
4
+ "POT-Creation-Date: 2023-08-29T17:15:15.520Z\n"
5
5
  "Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
6
6
  "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
7
7
  "MIME-Version: 1.0\n"
@@ -13,4 +13,399 @@ msgstr ""
13
13
  "Preferred-Encodings: utf-8\n"
14
14
  "Domain: volto\n"
15
15
 
16
+ #: index
17
+ # defaultMessage: Accordion responsive
18
+ msgid "Accordion responsive"
19
+ msgstr ""
20
+
21
+ #: index
22
+ # defaultMessage: Default
23
+ msgid "Default"
24
+ msgstr ""
25
+
26
+ #: components/EditBlockWrapper
27
+ # defaultMessage: Unknown Block {block}
28
+ msgid "Unknown Block"
29
+ msgstr ""
30
+
31
+ #: components/templates/accordion/schema
32
+ # defaultMessage: Accordion tabs block
33
+ msgid "accordion-tabs-block"
34
+ msgstr ""
35
+
36
+ #: components/schema
37
+ # defaultMessage: Accordion responsive
38
+ msgid "accordionResponsive"
39
+ msgstr ""
40
+
41
+ #: components/templates/default/schema
42
+ #: components/templates/horizontal-responsive/schema
43
+ # defaultMessage: Alignment
44
+ msgid "alignment"
45
+ msgstr ""
46
+
47
+ #: components/templates/default/schema
48
+ #: components/templates/horizontal-responsive/schema
49
+ # defaultMessage: Black
50
+ msgid "black"
51
+ msgstr ""
52
+
53
+ #: components/templates/default/schema
54
+ #: components/templates/horizontal-responsive/schema
55
+ # defaultMessage: Blue
56
+ msgid "blue"
57
+ msgstr ""
58
+
59
+ #: components/schema
60
+ #: components/templates/default/schema
61
+ #: components/templates/horizontal-responsive/schema
62
+ # defaultMessage: Bottom
63
+ msgid "bottom"
64
+ msgstr ""
65
+
66
+ #: components/templates/default/schema
67
+ #: components/templates/horizontal-responsive/schema
68
+ # defaultMessage: Brown
69
+ msgid "brown"
70
+ msgstr ""
71
+
72
+ #: components/templates/carousel/schema
73
+ # defaultMessage: Carousel block
74
+ msgid "carousel-tabs-block"
75
+ msgstr ""
76
+
77
+ #: components/schema
78
+ # defaultMessage: Carousel horizontal
79
+ msgid "carouselHorizontal"
80
+ msgstr ""
81
+
82
+ #: components/schema
83
+ # defaultMessage: Carousel vertical (prototype)
84
+ msgid "carouselVerticalPrototype"
85
+ msgstr ""
86
+
87
+ #: components/templates/default/schema
88
+ #: components/templates/horizontal-responsive/schema
89
+ # defaultMessage: Center
90
+ msgid "center"
91
+ msgstr ""
92
+
93
+ #: components/templates/default/schema
94
+ #: components/templates/horizontal-responsive/schema
95
+ # defaultMessage: Color
96
+ msgid "color"
97
+ msgstr ""
98
+
99
+ #: components/templates/carousel/schema
100
+ # defaultMessage: Dark
101
+ msgid "dark"
102
+ msgstr ""
103
+
104
+ #: components/schema
105
+ #: components/templates/accordion/schema
106
+ #: components/templates/carousel/schema
107
+ #: components/templates/default/schema
108
+ #: components/templates/horizontal-responsive/schema
109
+ # defaultMessage: Default
110
+ msgid "default"
111
+ msgstr ""
112
+
113
+ #: components/templates/default/schema
114
+ # defaultMessage: Default tabs block
115
+ msgid "default-tabs-block"
116
+ msgstr ""
117
+
118
+ #: components/EditBlockWrapper
119
+ # defaultMessage: delete
120
+ msgid "delete"
121
+ msgstr ""
122
+
123
+ #: components/templates/accordion/schema
124
+ #: components/templates/default/schema
125
+ #: components/templates/horizontal-responsive/schema
126
+ # defaultMessage: Description
127
+ msgid "description"
128
+ msgstr ""
129
+
130
+ #: components/templates/default/schema
131
+ #: components/templates/horizontal-responsive/schema
132
+ # defaultMessage: Green
133
+ msgid "green"
134
+ msgstr ""
135
+
136
+ #: components/templates/carousel/schema
137
+ #: components/templates/default/schema
138
+ #: components/templates/horizontal-responsive/schema
139
+ # defaultMessage: Grey
140
+ msgid "grey"
141
+ msgstr ""
142
+
143
+ #: components/templates/horizontal-responsive/schema
144
+ # defaultMessage: Horizontal tabs block
145
+ msgid "horizontal-tabs-block"
146
+ msgstr ""
147
+
148
+ #: components/schema
149
+ # defaultMessage: Horizontal responsive
150
+ msgid "horizontalResponsive"
151
+ msgstr ""
152
+
153
+ #: components/templates/default/schema
154
+ #: components/templates/horizontal-responsive/schema
155
+ # defaultMessage: Huge
156
+ msgid "huge"
157
+ msgstr ""
158
+
159
+ #: components/templates/accordion/schema
160
+ # defaultMessage: Icon position on the right
161
+ msgid "icon-position-on-the-right"
162
+ msgstr ""
163
+
164
+ #: components/templates/accordion/schema
165
+ # defaultMessage: Inverted
166
+ msgid "inverted"
167
+ msgstr ""
168
+
169
+ #: components/templates/default/schema
170
+ #: components/templates/horizontal-responsive/schema
171
+ # defaultMessage: Large
172
+ msgid "large"
173
+ msgstr ""
174
+
175
+ #: components/templates/default/schema
176
+ #: components/templates/horizontal-responsive/schema
177
+ # defaultMessage: Left
178
+ msgid "left"
179
+ msgstr ""
180
+
181
+ #: components/templates/default/schema
182
+ #: components/templates/horizontal-responsive/schema
183
+ # defaultMessage: Left side
184
+ msgid "left-side"
185
+ msgstr ""
186
+
187
+ #: components/templates/carousel/schema
188
+ # defaultMessage: Light
189
+ msgid "light"
190
+ msgstr ""
191
+
192
+ #: components/templates/default/schema
193
+ #: components/templates/horizontal-responsive/schema
194
+ # defaultMessage: Massive
195
+ msgid "massive"
196
+ msgstr ""
197
+
198
+ #: components/templates/accordion/schema
199
+ #: components/templates/default/schema
200
+ #: components/templates/horizontal-responsive/schema
201
+ # defaultMessage: Menu
202
+ msgid "menu"
203
+ msgstr ""
204
+
205
+ #: components/templates/default/schema
206
+ #: components/templates/horizontal-responsive/schema
207
+ # defaultMessage: Borderless
208
+ msgid "menu-border-less"
209
+ msgstr ""
210
+
211
+ #: components/templates/default/schema
212
+ #: components/templates/horizontal-responsive/schema
213
+ # defaultMessage: Compact
214
+ msgid "menu-compact"
215
+ msgstr ""
216
+
217
+ #: components/templates/default/schema
218
+ #: components/templates/horizontal-responsive/schema
219
+ # defaultMessage: Fluid
220
+ msgid "menu-fluid"
221
+ msgstr ""
222
+
223
+ #: components/templates/default/schema
224
+ #: components/templates/horizontal-responsive/schema
225
+ # defaultMessage: Inverted
226
+ msgid "menu-inverted"
227
+ msgstr ""
228
+
229
+ #: components/templates/default/schema
230
+ #: components/templates/horizontal-responsive/schema
231
+ # defaultMessage: Pointing
232
+ msgid "menu-pointing"
233
+ msgstr ""
234
+
235
+ #: components/templates/default/schema
236
+ #: components/templates/horizontal-responsive/schema
237
+ # defaultMessage: Secondary
238
+ msgid "menu-secondary"
239
+ msgstr ""
240
+
241
+ #: components/templates/default/schema
242
+ #: components/templates/horizontal-responsive/schema
243
+ # defaultMessage: Stackable
244
+ msgid "menu-stackable"
245
+ msgstr ""
246
+
247
+ #: components/templates/default/schema
248
+ #: components/templates/horizontal-responsive/schema
249
+ # defaultMessage: Tabular
250
+ msgid "menu-tabular"
251
+ msgstr ""
252
+
253
+ #: components/templates/default/schema
254
+ #: components/templates/horizontal-responsive/schema
255
+ # defaultMessage: Text
256
+ msgid "menu-text"
257
+ msgstr ""
258
+
259
+ #: components/schema
260
+ # defaultMessage: Middle
261
+ msgid "middle"
262
+ msgstr ""
263
+
264
+ #: components/templates/default/schema
265
+ #: components/templates/horizontal-responsive/schema
266
+ # defaultMessage: Mini
267
+ msgid "mini"
268
+ msgstr ""
269
+
270
+ #: components/templates/default/schema
271
+ #: components/templates/horizontal-responsive/schema
272
+ # defaultMessage: Olive
273
+ msgid "olive"
274
+ msgstr ""
275
+
276
+ #: components/templates/default/schema
277
+ #: components/templates/horizontal-responsive/schema
278
+ # defaultMessage: Orange
279
+ msgid "orange"
280
+ msgstr ""
281
+
282
+ #: components/templates/default/schema
283
+ #: components/templates/horizontal-responsive/schema
284
+ # defaultMessage: Pink
285
+ msgid "pink"
286
+ msgstr ""
287
+
288
+ #: components/templates/default/schema
289
+ #: components/templates/horizontal-responsive/schema
290
+ # defaultMessage: Position
291
+ msgid "position"
292
+ msgstr ""
293
+
294
+ #: components/templates/accordion/schema
295
+ # defaultMessage: Position left/right of the icon in the accordion tab
296
+ msgid "position-left-right-of-the-icon-in-the-accordion-tab"
297
+ msgstr ""
298
+
299
+ #: components/templates/default/schema
300
+ #: components/templates/horizontal-responsive/schema
301
+ # defaultMessage: Purple
302
+ msgid "purple"
303
+ msgstr ""
304
+
305
+ #: components/templates/default/schema
306
+ #: components/templates/horizontal-responsive/schema
307
+ # defaultMessage: Red
308
+ msgid "red"
309
+ msgstr ""
310
+
311
+ #: components/templates/default/schema
312
+ #: components/templates/horizontal-responsive/schema
313
+ # defaultMessage: Right
314
+ msgid "right"
315
+ msgstr ""
316
+
317
+ #: components/templates/default/schema
318
+ #: components/templates/horizontal-responsive/schema
319
+ # defaultMessage: Right side
320
+ msgid "right-side"
321
+ msgstr ""
322
+
323
+ #: components/templates/accordion/schema
324
+ # defaultMessage: Set the theme for the accordion tabs block
325
+ msgid "set-the-theme-for-the-accordion-tabs-block"
326
+ msgstr ""
327
+
328
+ #: components/templates/default/schema
329
+ #: components/templates/horizontal-responsive/schema
330
+ # defaultMessage: Size
331
+ msgid "size"
332
+ msgstr ""
333
+
334
+ #: components/templates/default/schema
335
+ #: components/templates/horizontal-responsive/schema
336
+ # defaultMessage: Small
337
+ msgid "small"
338
+ msgstr ""
339
+
340
+ #: components/templates/default/schema
341
+ #: components/templates/horizontal-responsive/schema
342
+ # defaultMessage: Space between
343
+ msgid "space-between"
344
+ msgstr ""
345
+
346
+ #: components/templates/accordion/schema
347
+ # defaultMessage: Style
348
+ msgid "style"
349
+ msgstr ""
350
+
351
+ #: components/schema
352
+ # defaultMessage: Tabs
353
+ msgid "tabs"
354
+ msgstr ""
355
+
356
+ #: components/schema
357
+ # defaultMessage: Tabs block
358
+ msgid "tabs-block"
359
+ msgstr ""
16
360
 
361
+ #: components/templates/default/schema
362
+ #: components/templates/horizontal-responsive/schema
363
+ # defaultMessage: Teal
364
+ msgid "teal"
365
+ msgstr ""
366
+
367
+ #: components/schema
368
+ # defaultMessage: Template
369
+ msgid "template"
370
+ msgstr ""
371
+
372
+ #: components/templates/accordion/schema
373
+ #: components/templates/carousel/schema
374
+ # defaultMessage: Theme
375
+ msgid "theme"
376
+ msgstr ""
377
+
378
+ #: components/templates/default/schema
379
+ #: components/templates/horizontal-responsive/schema
380
+ # defaultMessage: Tiny
381
+ msgid "tiny"
382
+ msgstr ""
383
+
384
+ #: components/schema
385
+ # defaultMessage: Title
386
+ msgid "title"
387
+ msgstr ""
388
+
389
+ #: components/schema
390
+ #: components/templates/default/schema
391
+ #: components/templates/horizontal-responsive/schema
392
+ # defaultMessage: Top
393
+ msgid "top"
394
+ msgstr ""
395
+
396
+ #: components/schema
397
+ # defaultMessage: Vertical align
398
+ msgid "vertical-align"
399
+ msgstr ""
400
+
401
+ #: components/templates/default/schema
402
+ #: components/templates/horizontal-responsive/schema
403
+ # defaultMessage: Violet
404
+ msgid "violet"
405
+ msgstr ""
406
+
407
+ #: components/templates/default/schema
408
+ #: components/templates/horizontal-responsive/schema
409
+ # defaultMessage: Yellow
410
+ msgid "yellow"
411
+ msgstr ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-tabs-block",
3
- "version": "5.0.8",
3
+ "version": "6.0.0",
4
4
  "description": "volto-tabs-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -31,8 +31,31 @@
31
31
  "@cypress/code-coverage": "^3.10.0",
32
32
  "@plone/scripts": "*",
33
33
  "babel-plugin-transform-class-properties": "^6.24.1",
34
+ "husky": "*",
35
+ "lint-staged": "*",
34
36
  "md5": "^2.3.0"
35
37
  },
38
+ "lint-staged": {
39
+ "src/**/*.{js,jsx,ts,tsx,json}": [
40
+ "make lint-fix",
41
+ "make prettier-fix"
42
+ ],
43
+ "src/**/*.{jsx}": [
44
+ "make i18n"
45
+ ],
46
+ "theme/**/*.{css,less}": [
47
+ "make stylelint-fix"
48
+ ],
49
+ "src/**/*.{css,less}": [
50
+ "make stylelint-fix"
51
+ ],
52
+ "theme/**/*.overrides": [
53
+ "make stylelint-fix"
54
+ ],
55
+ "src/**/*.overrides": [
56
+ "make stylelint-fix"
57
+ ]
58
+ },
36
59
  "scripts": {
37
60
  "release": "release-it",
38
61
  "release-major-beta": "release-it major --preRelease=beta",
@@ -50,6 +73,7 @@
50
73
  "lint:fix": "make lint-fix",
51
74
  "i18n": "make i18n",
52
75
  "cypress:run": "make cypress-run",
53
- "cypress:open": "make cypress-open"
76
+ "cypress:open": "make cypress-open",
77
+ "prepare": "husky install"
54
78
  }
55
79
  }
@@ -44,6 +44,7 @@ const Edit = (props) => {
44
44
  typeof templateSchema === 'function'
45
45
  ? templateSchema(config, props)
46
46
  : templateSchema,
47
+ props,
47
48
  );
48
49
 
49
50
  React.useEffect(() => {
@@ -15,7 +15,7 @@ import '@eeacms/volto-tabs-block/less/tabs.less';
15
15
 
16
16
  const View = (props) => {
17
17
  const view = React.useRef(null);
18
- const { data = {}, uiContainer = '' } = props;
18
+ const { data = {}, uiContainer = '', location, history } = props;
19
19
  const metadata = props.metadata || props.properties;
20
20
  const template = data.template || 'default';
21
21
  const tabsData = data.data || {};
@@ -31,7 +31,33 @@ const View = (props) => {
31
31
  config.blocks.blocksConfig[TABS_BLOCK].templates?.[template]?.view ||
32
32
  DefaultView;
33
33
 
34
+ const useQuery = () => {
35
+ const { search } = location;
36
+ return React.useMemo(() => new URLSearchParams(search), [search]);
37
+ };
38
+
39
+ const query = useQuery();
40
+ const activeTabId = query.get('activeTab');
41
+
42
+ const addQueryParam = (key, value) => {
43
+ const searchParams = new URLSearchParams(location.search);
44
+ searchParams.set(key, value);
45
+
46
+ history.push({
47
+ pathname: location.pathname,
48
+ search: searchParams.toString(),
49
+ });
50
+ };
51
+
52
+ const handleActiveTabChange = (id) => {
53
+ setActiveTab(id);
54
+ addQueryParam('activeTab', id);
55
+ };
56
+
34
57
  React.useEffect(() => {
58
+ if (tabsList.includes(activeTabId)) {
59
+ setActiveTab(activeTabId);
60
+ }
35
61
  const urlHash = props.location.hash.substring(1) || '';
36
62
  const parentTabId = getParentTabFromHash(data, urlHash);
37
63
  const id = parentTabId;
@@ -87,7 +113,7 @@ const View = (props) => {
87
113
  tabsList={tabsList}
88
114
  template={template}
89
115
  uiContainer={uiContainer}
90
- setActiveTab={setActiveTab}
116
+ setActiveTab={handleActiveTabChange}
91
117
  />
92
118
  </StyleWrapperView>
93
119
  </div>
@@ -1,22 +1,87 @@
1
1
  import { TABS_BLOCK } from '@eeacms/volto-tabs-block/constants';
2
+ import { defineMessages } from 'react-intl';
2
3
 
3
- export const schema = (config, templateSchema = {}) => {
4
+ const messages = defineMessages({
5
+ TabsBlock: {
6
+ id: 'tabs-block',
7
+ defaultMessage: 'Tabs block',
8
+ },
9
+ Default: {
10
+ id: 'default',
11
+ defaultMessage: 'Default',
12
+ },
13
+ Tabs: {
14
+ id: 'tabs',
15
+ defaultMessage: 'Tabs',
16
+ },
17
+ Title: {
18
+ id: 'title',
19
+ defaultMessage: 'Title',
20
+ },
21
+ Template: {
22
+ id: 'template',
23
+ defaultMessage: 'Template',
24
+ },
25
+ VerticalAlign: {
26
+ id: 'vertical-align',
27
+ defaultMessage: 'Vertical align',
28
+ },
29
+ Top: {
30
+ id: 'top',
31
+ defaultMessage: 'Top',
32
+ },
33
+ Middle: {
34
+ id: 'middle',
35
+ defaultMessage: 'Middle',
36
+ },
37
+ Bottom: {
38
+ id: 'bottom',
39
+ defaultMessage: 'Bottom',
40
+ },
41
+ default: {
42
+ id: 'default',
43
+ defaultMessage: 'Default',
44
+ },
45
+ accordionResponsive: {
46
+ id: 'accordionResponsive',
47
+ defaultMessage: 'Accordion responsive',
48
+ },
49
+ horizontalResponsive: {
50
+ id: 'horizontalResponsive',
51
+ defaultMessage: 'Horizontal responsive',
52
+ },
53
+ carouselHorizontal: {
54
+ id: 'carouselHorizontal',
55
+ defaultMessage: 'Carousel horizontal',
56
+ },
57
+ carouselVerticalPrototype: {
58
+ id: 'carouselVerticalPrototype',
59
+ defaultMessage: 'Carousel vertical (prototype)',
60
+ },
61
+ });
62
+
63
+ export const schema = (config, templateSchema = {}, props) => {
64
+ const { intl } = props;
4
65
  const templatesConfig = config.blocks.blocksConfig[TABS_BLOCK].templates;
5
- const templates = Object.keys(templatesConfig).map((template) => [
6
- template,
7
- templatesConfig[template].title || template,
8
- ]);
66
+ const templates = Object.keys(templatesConfig).map((template) => {
67
+ let templateTitle = templatesConfig[template].title || template;
68
+ let templateId = templatesConfig[template].id;
69
+ if (templateId && messages[`${templateId}`]) {
70
+ templateTitle = intl.formatMessage(messages[`${templateId}`]);
71
+ }
72
+ return [template, templateTitle];
73
+ });
9
74
 
10
75
  const defaultFieldset = templateSchema?.fieldsets?.filter(
11
76
  (fieldset) => fieldset.id === 'default',
12
77
  )[0];
13
78
 
14
79
  return {
15
- title: templateSchema?.title || 'Tabs block',
80
+ title: templateSchema?.title || intl.formatMessage(messages.TabsBlock),
16
81
  fieldsets: [
17
82
  {
18
83
  id: 'default',
19
- title: 'Default',
84
+ title: intl.formatMessage(messages.Default),
20
85
  fields: [
21
86
  'data',
22
87
  'title',
@@ -31,23 +96,23 @@ export const schema = (config, templateSchema = {}) => {
31
96
  ],
32
97
  properties: {
33
98
  data: {
34
- title: 'Tabs',
99
+ title: intl.formatMessage(messages.Tabs),
35
100
  type: 'tabs',
36
101
  },
37
102
  title: {
38
- title: 'Title',
103
+ title: intl.formatMessage(messages.Title),
39
104
  },
40
105
  template: {
41
- title: 'Template',
106
+ title: intl.formatMessage(messages.Template),
42
107
  choices: [...templates],
43
108
  default: 'default',
44
109
  },
45
110
  verticalAlign: {
46
- title: 'Vertical align',
111
+ title: intl.formatMessage(messages.VerticalAlign),
47
112
  choices: [
48
- ['flex-start', 'Top'],
49
- ['center', 'Middle'],
50
- ['flex-end', 'Bottom'],
113
+ ['flex-start', intl.formatMessage(messages.Top)],
114
+ ['center', intl.formatMessage(messages.Middle)],
115
+ ['flex-end', intl.formatMessage(messages.Bottom)],
51
116
  ],
52
117
  default: 'flex-start',
53
118
  },