@eeacms/volto-eea-website-theme 2.3.0 → 3.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/CHANGELOG.md +24 -1
- package/README.md +6 -0
- package/package.json +3 -1
- package/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.jsx +45 -0
- package/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.test.jsx +88 -0
- package/src/components/manage/Blocks/ContextNavigation/ContextNavigationView.jsx +14 -0
- package/src/components/manage/Blocks/ContextNavigation/ContextNavigationView.test.jsx +71 -0
- package/src/components/manage/Blocks/ContextNavigation/index.js +30 -0
- package/src/components/manage/Blocks/ContextNavigation/schema.js +88 -0
- package/src/components/manage/Blocks/ContextNavigation/variations/Accordion.jsx +179 -0
- package/src/components/manage/Blocks/ContextNavigation/variations/Default.jsx +9 -0
- package/src/components/manage/Blocks/ContextNavigation/variations/index.js +18 -0
- package/src/components/manage/Blocks/Title/Edit.jsx +7 -4
- package/src/components/manage/Blocks/Title/View.jsx +14 -24
- package/src/components/manage/Blocks/Title/index.js +52 -0
- package/src/components/manage/Blocks/Title/variations/Default.jsx +43 -0
- package/src/components/manage/Blocks/Title/variations/WebReport.jsx +69 -0
- package/src/components/manage/Blocks/Title/variations/WebReportPage.jsx +59 -0
- package/src/components/manage/Blocks/Title/variations/styles.less +28 -0
- package/src/components/theme/Banner/View.jsx +5 -1
- package/src/components/theme/SubsiteClass.jsx +3 -1
- package/src/components/theme/WebReport/WebReportSectionView.jsx +49 -0
- package/src/customizations/volto/components/theme/Breadcrumbs/Breadcrumbs.jsx +20 -2
- package/src/customizations/volto/components/theme/Header/Header.jsx +3 -3
- package/src/customizations/volto/components/theme/View/DefaultView.jsx +190 -0
- package/src/hocs/withDeviceSize.test.jsx +79 -0
- package/src/index.js +20 -7
- package/src/customizations/volto/components/manage/Blocks/Block/BlocksForm.diff +0 -12
- package/src/customizations/volto/components/manage/Blocks/Block/BlocksForm.jsx +0 -289
- package/src/customizations/volto/components/manage/Blocks/Block/BlocksForm.txt +0 -2
- package/src/customizations/volto/components/manage/Diff/DiffField.jsx +0 -351
- package/src/customizations/volto/components/manage/Form/Form.diff +0 -2
- package/src/customizations/volto/components/manage/Form/Form.jsx +0 -952
- package/src/customizations/volto/components/manage/Form/Form.txt +0 -2
- package/src/customizations/volto/components/manage/Widgets/InternalUrlWidget.jsx +0 -189
@@ -1,351 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Diff field component.
|
3
|
-
* @module components/manage/Diff/DiffField
|
4
|
-
*/
|
5
|
-
|
6
|
-
import React from 'react';
|
7
|
-
// import { diffWords as dWords } from 'diff';
|
8
|
-
import { join, map } from 'lodash';
|
9
|
-
import PropTypes from 'prop-types';
|
10
|
-
import { Grid } from 'semantic-ui-react';
|
11
|
-
import ReactDOMServer from 'react-dom/server';
|
12
|
-
import { Provider } from 'react-intl-redux';
|
13
|
-
import { createBrowserHistory } from 'history';
|
14
|
-
import { ConnectedRouter } from 'connected-react-router';
|
15
|
-
import { useSelector } from 'react-redux';
|
16
|
-
|
17
|
-
import { Api } from '@plone/volto/helpers';
|
18
|
-
import configureStore from '@plone/volto/store';
|
19
|
-
import { DefaultView } from '@plone/volto/components/';
|
20
|
-
import { serializeNodes } from '@plone/volto-slate/editor/render';
|
21
|
-
|
22
|
-
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
23
|
-
|
24
|
-
/**
|
25
|
-
* Enhanced diff words utility
|
26
|
-
* @function diffWords
|
27
|
-
* @param oneStr Field one
|
28
|
-
* @param twoStr Field two
|
29
|
-
*/
|
30
|
-
|
31
|
-
/**
|
32
|
-
* Diff field component.
|
33
|
-
* @function DiffField
|
34
|
-
* @param {*} one Field one
|
35
|
-
* @param {*} two Field two
|
36
|
-
* @param {Object} schema Field schema
|
37
|
-
* @returns {string} Markup of the component.
|
38
|
-
*/
|
39
|
-
const DiffField = ({
|
40
|
-
one,
|
41
|
-
two,
|
42
|
-
contentOne,
|
43
|
-
contentTwo,
|
44
|
-
view,
|
45
|
-
schema,
|
46
|
-
diffLib,
|
47
|
-
}) => {
|
48
|
-
const language = useSelector((state) => state.intl.locale);
|
49
|
-
const readable_date_format = {
|
50
|
-
dateStyle: 'full',
|
51
|
-
timeStyle: 'short',
|
52
|
-
};
|
53
|
-
const splitWords = (str) => {
|
54
|
-
if (!str) return [];
|
55
|
-
const splitedArray = [];
|
56
|
-
let elementCurent = '';
|
57
|
-
let insideTag = false;
|
58
|
-
for (let i = 0; i < str.length; i++)
|
59
|
-
if (str[i] === '<') {
|
60
|
-
if (elementCurent) splitedArray.push(elementCurent);
|
61
|
-
elementCurent = '<';
|
62
|
-
insideTag = true;
|
63
|
-
} else if (str[i] === '>') {
|
64
|
-
elementCurent += '>';
|
65
|
-
splitedArray.push(elementCurent);
|
66
|
-
elementCurent = '';
|
67
|
-
insideTag = false;
|
68
|
-
} else if (str[i] === ' ' && insideTag === false) {
|
69
|
-
elementCurent += ' ';
|
70
|
-
splitedArray.push(elementCurent);
|
71
|
-
elementCurent = '';
|
72
|
-
} else elementCurent += str[i];
|
73
|
-
if (elementCurent) splitedArray.push(elementCurent);
|
74
|
-
return splitedArray;
|
75
|
-
};
|
76
|
-
|
77
|
-
const diffWords = (oneStr, twoStr) => {
|
78
|
-
return diffLib.diffArrays(splitWords(oneStr), splitWords(twoStr));
|
79
|
-
};
|
80
|
-
|
81
|
-
let parts, oneArray, twoArray;
|
82
|
-
if (schema.widget && schema.title !== 'Data sources and providers') {
|
83
|
-
switch (schema.widget) {
|
84
|
-
case 'richtext':
|
85
|
-
parts = diffWords(one?.data, two?.data);
|
86
|
-
break;
|
87
|
-
case 'datetime':
|
88
|
-
parts = diffWords(
|
89
|
-
new Intl.DateTimeFormat(language, readable_date_format)
|
90
|
-
.format(new Date(one))
|
91
|
-
.replace('\u202F', ' '),
|
92
|
-
new Intl.DateTimeFormat(language, readable_date_format)
|
93
|
-
.format(new Date(two))
|
94
|
-
.replace('\u202F', ' '),
|
95
|
-
);
|
96
|
-
break;
|
97
|
-
case 'json': {
|
98
|
-
const api = new Api();
|
99
|
-
const history = createBrowserHistory();
|
100
|
-
const store = configureStore(window.__data, history, api);
|
101
|
-
parts = diffWords(
|
102
|
-
ReactDOMServer.renderToStaticMarkup(
|
103
|
-
<Provider store={store}>
|
104
|
-
<ConnectedRouter history={history}>
|
105
|
-
<DefaultView content={contentOne} />
|
106
|
-
</ConnectedRouter>
|
107
|
-
</Provider>,
|
108
|
-
),
|
109
|
-
ReactDOMServer.renderToStaticMarkup(
|
110
|
-
<Provider store={store}>
|
111
|
-
<ConnectedRouter history={history}>
|
112
|
-
<DefaultView content={contentTwo} />
|
113
|
-
</ConnectedRouter>
|
114
|
-
</Provider>,
|
115
|
-
),
|
116
|
-
);
|
117
|
-
break;
|
118
|
-
}
|
119
|
-
case 'slate': {
|
120
|
-
const api = new Api();
|
121
|
-
const history = createBrowserHistory();
|
122
|
-
const store = configureStore(window.__data, history, api);
|
123
|
-
parts = diffWords(
|
124
|
-
ReactDOMServer.renderToStaticMarkup(
|
125
|
-
<Provider store={store}>
|
126
|
-
<ConnectedRouter history={history}>
|
127
|
-
{serializeNodes(one)}
|
128
|
-
</ConnectedRouter>
|
129
|
-
</Provider>,
|
130
|
-
),
|
131
|
-
ReactDOMServer.renderToStaticMarkup(
|
132
|
-
<Provider store={store}>
|
133
|
-
<ConnectedRouter history={history}>
|
134
|
-
{serializeNodes(two)}
|
135
|
-
</ConnectedRouter>
|
136
|
-
</Provider>,
|
137
|
-
),
|
138
|
-
);
|
139
|
-
break;
|
140
|
-
}
|
141
|
-
case 'temporal': {
|
142
|
-
if (one?.temporal?.length > 0 && two.temporal?.length > 0) {
|
143
|
-
let firstString = one.temporal.reduce((acc, cur) => {
|
144
|
-
return acc + cur?.label + ', ';
|
145
|
-
}, '');
|
146
|
-
firstString = firstString.substring(0, firstString.length - 2);
|
147
|
-
let secondString = two.temporal.reduce((acc, cur) => {
|
148
|
-
return acc + cur?.label + ', ';
|
149
|
-
}, '');
|
150
|
-
secondString = secondString.substring(0, secondString.length - 2);
|
151
|
-
parts = diffWords(firstString, secondString);
|
152
|
-
}
|
153
|
-
break;
|
154
|
-
}
|
155
|
-
case 'geolocation': {
|
156
|
-
if (one?.geolocation?.length > 0 && two.geolocation?.length > 0) {
|
157
|
-
let firstString = one.geolocation.reduce((acc, cur) => {
|
158
|
-
return acc + cur?.label + ', ';
|
159
|
-
}, '');
|
160
|
-
firstString = firstString.substring(0, firstString.length - 2);
|
161
|
-
let secondString = two.geolocation.reduce((acc, cur) => {
|
162
|
-
return acc + cur?.label + ', ';
|
163
|
-
}, '');
|
164
|
-
secondString = secondString.substring(0, secondString.length - 2);
|
165
|
-
parts = diffWords(firstString, secondString);
|
166
|
-
}
|
167
|
-
break;
|
168
|
-
}
|
169
|
-
case 'textarea':
|
170
|
-
default:
|
171
|
-
parts = diffWords(one, two);
|
172
|
-
break;
|
173
|
-
}
|
174
|
-
} else if (schema.title === 'Data sources and providers') {
|
175
|
-
if (one?.data?.length > 0 && two.data?.length > 0) {
|
176
|
-
let firstString = one.data.reduce((acc, cur) => {
|
177
|
-
return acc + cur?.title + ', ' + cur?.organisation + '<br/>';
|
178
|
-
}, '');
|
179
|
-
firstString = firstString.substring(0, firstString.length - 2);
|
180
|
-
let secondString = two.data.reduce((acc, cur) => {
|
181
|
-
return acc + cur?.title + ', ' + cur?.organisation + '<br/>';
|
182
|
-
}, '');
|
183
|
-
secondString = secondString.substring(0, secondString.length - 2);
|
184
|
-
parts = diffWords(firstString, secondString);
|
185
|
-
}
|
186
|
-
} else if (schema.type === 'object') {
|
187
|
-
parts = diffWords(one?.filename || one, two?.filename || two);
|
188
|
-
} else if (schema.type === 'array') {
|
189
|
-
oneArray = (one || []).map((i) => i?.title || i);
|
190
|
-
twoArray = (two || []).map((j) => j?.title || j);
|
191
|
-
parts = diffWords(oneArray, twoArray);
|
192
|
-
} else {
|
193
|
-
parts = diffWords(one?.title || one, two?.title || two);
|
194
|
-
}
|
195
|
-
|
196
|
-
return (
|
197
|
-
<Grid data-testid="DiffField">
|
198
|
-
<Grid.Row>
|
199
|
-
<Grid.Column width={12}>{schema.title}</Grid.Column>
|
200
|
-
</Grid.Row>
|
201
|
-
|
202
|
-
{view === 'split' && (
|
203
|
-
<Grid.Row>
|
204
|
-
<Grid.Column width={6} verticalAlign="top">
|
205
|
-
<span
|
206
|
-
dangerouslySetInnerHTML={{
|
207
|
-
__html: join(
|
208
|
-
map(parts, (part) => {
|
209
|
-
let combined = (part.value || []).reduce((acc, value) => {
|
210
|
-
if (
|
211
|
-
part.removed &&
|
212
|
-
!value.includes('<') &&
|
213
|
-
!value.includes('>') &&
|
214
|
-
!value.includes('>') &&
|
215
|
-
!value.includes('</') &&
|
216
|
-
!value.includes('"') &&
|
217
|
-
!value.includes('src') &&
|
218
|
-
!value.includes('href') &&
|
219
|
-
!value.includes('=')
|
220
|
-
)
|
221
|
-
return acc + `<span class="deletion">${value}</span>`;
|
222
|
-
if (
|
223
|
-
part.added &&
|
224
|
-
!value.includes('<') &&
|
225
|
-
!value.includes('>') &&
|
226
|
-
!value.includes('>') &&
|
227
|
-
!value.includes('</') &&
|
228
|
-
!value.includes('"') &&
|
229
|
-
!value.includes('src') &&
|
230
|
-
!value.includes('href') &&
|
231
|
-
!value.includes('=')
|
232
|
-
)
|
233
|
-
return acc;
|
234
|
-
return acc + value;
|
235
|
-
}, '');
|
236
|
-
return combined;
|
237
|
-
}),
|
238
|
-
'',
|
239
|
-
),
|
240
|
-
}}
|
241
|
-
/>
|
242
|
-
</Grid.Column>
|
243
|
-
<Grid.Column width={6} verticalAlign="top">
|
244
|
-
<span
|
245
|
-
dangerouslySetInnerHTML={{
|
246
|
-
__html: join(
|
247
|
-
map(parts, (part) => {
|
248
|
-
let combined = (part.value || []).reduce((acc, value) => {
|
249
|
-
if (
|
250
|
-
part.added &&
|
251
|
-
!value.includes('<') &&
|
252
|
-
!value.includes('>') &&
|
253
|
-
!value.includes('>') &&
|
254
|
-
!value.includes('</') &&
|
255
|
-
!value.includes('"') &&
|
256
|
-
!value.includes('src') &&
|
257
|
-
!value.includes('href') &&
|
258
|
-
!value.includes('=')
|
259
|
-
)
|
260
|
-
return acc + `<span class="addition">${value}</span>`;
|
261
|
-
if (
|
262
|
-
part.removed &&
|
263
|
-
!value.includes('<') &&
|
264
|
-
!value.includes('>') &&
|
265
|
-
!value.includes('>') &&
|
266
|
-
!value.includes('</') &&
|
267
|
-
!value.includes('"') &&
|
268
|
-
!value.includes('src') &&
|
269
|
-
!value.includes('href') &&
|
270
|
-
!value.includes('=')
|
271
|
-
)
|
272
|
-
return acc;
|
273
|
-
return acc + value;
|
274
|
-
}, '');
|
275
|
-
return combined;
|
276
|
-
}),
|
277
|
-
'',
|
278
|
-
),
|
279
|
-
}}
|
280
|
-
/>
|
281
|
-
</Grid.Column>
|
282
|
-
</Grid.Row>
|
283
|
-
)}
|
284
|
-
{view === 'unified' && (
|
285
|
-
<Grid.Row>
|
286
|
-
<Grid.Column width={16} verticalAlign="top">
|
287
|
-
<span
|
288
|
-
dangerouslySetInnerHTML={{
|
289
|
-
__html: join(
|
290
|
-
map(parts, (part) => {
|
291
|
-
let combined = (part.value || []).reduce((acc, value) => {
|
292
|
-
if (
|
293
|
-
part.removed &&
|
294
|
-
!value.includes('<') &&
|
295
|
-
!value.includes('>') &&
|
296
|
-
!value.includes('>') &&
|
297
|
-
!value.includes('</') &&
|
298
|
-
!value.includes('"') &&
|
299
|
-
!value.includes('src') &&
|
300
|
-
!value.includes('href') &&
|
301
|
-
!value.includes('=')
|
302
|
-
)
|
303
|
-
return acc + `<span class="deletion">${value}</span>`;
|
304
|
-
|
305
|
-
if (
|
306
|
-
part.added &&
|
307
|
-
!value.includes('<') &&
|
308
|
-
!value.includes('>') &&
|
309
|
-
!value.includes('>') &&
|
310
|
-
!value.includes('</') &&
|
311
|
-
!value.includes('"') &&
|
312
|
-
!value.includes('src') &&
|
313
|
-
!value.includes('href') &&
|
314
|
-
!value.includes('=')
|
315
|
-
)
|
316
|
-
return acc + `<span class="addition">${value}</span>`;
|
317
|
-
|
318
|
-
return acc + value;
|
319
|
-
}, '');
|
320
|
-
return combined;
|
321
|
-
}),
|
322
|
-
'',
|
323
|
-
),
|
324
|
-
}}
|
325
|
-
/>
|
326
|
-
</Grid.Column>
|
327
|
-
</Grid.Row>
|
328
|
-
)}
|
329
|
-
</Grid>
|
330
|
-
);
|
331
|
-
};
|
332
|
-
|
333
|
-
/**
|
334
|
-
* Property types.
|
335
|
-
* @property {Object} propTypes Property types.
|
336
|
-
* @static
|
337
|
-
*/
|
338
|
-
DiffField.propTypes = {
|
339
|
-
one: PropTypes.any.isRequired,
|
340
|
-
two: PropTypes.any.isRequired,
|
341
|
-
contentOne: PropTypes.any,
|
342
|
-
contentTwo: PropTypes.any,
|
343
|
-
view: PropTypes.string.isRequired,
|
344
|
-
schema: PropTypes.shape({
|
345
|
-
widget: PropTypes.string,
|
346
|
-
type: PropTypes.string,
|
347
|
-
title: PropTypes.string,
|
348
|
-
}).isRequired,
|
349
|
-
};
|
350
|
-
|
351
|
-
export default injectLazyLibs('diffLib')(DiffField);
|